akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <array>

using namespace std;

enum dir_t {NORTH, EAST, WEST, SOUTH, CLKW, CCLKW};
enum face_t {TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT};

class Dice {
public:
    Dice(int32_t top, int32_t bottom, int32_t front, int32_t back, int32_t left, int32_t right) {
        val[TOP]    = top;
        val[BOTTOM] = bottom;
        val[FRONT]  = front;
        val[BACK]   = back;
        val[LEFT]   = left;
        val[RIGHT]  = right;
    }

    int32_t operator[](face_t f) {
        return val[f];
    }

    bool operator== (const Dice &d2) {
        return (*this).val == d2.val;
    }

    void roll(dir_t dir) {
        switch (dir) {
            case NORTH: inner_roll(TOP, FRONT, BOTTOM, BACK); break;
            case EAST:  inner_roll(TOP, LEFT, BOTTOM, RIGHT); break;
            case WEST:  inner_roll(TOP, RIGHT, BOTTOM, LEFT); break;
            case SOUTH: inner_roll(TOP, BACK, BOTTOM, FRONT); break;
            case CLKW:  inner_roll(FRONT, RIGHT, BACK, LEFT); break;
            case CCLKW: inner_roll(FRONT, LEFT, BACK, RIGHT); break;
        }
    }

    bool identical_with(Dice d) {
        for (int32_t i = 0; i < 6; i++) {
            for (int32_t j = 0; j < 4; j++) {
                if (d == *this) {
                    return true;
                }
                d.roll(CLKW);
            }

            if (i % 2 == 0) {
                d.roll(NORTH);
            } else {
                d.roll(WEST);
            }
        }

        return false;
    }

private:
    array<int32_t, 6> val;

    void inner_roll(face_t f1, face_t f2, face_t f3, face_t f4) {
        int32_t temp;
        temp = val[f1];
        val[f1] = val[f2];
        val[f2] = val[f3];
        val[f3] = val[f4];
        val[f4] = temp;

        return;
    }
};

int main() {
    int32_t top, bottom, front, back, left, right;

    cin >> top >> front >> right >> left >> back >> bottom;
    Dice d1(top, bottom, front, back, left, right);

    cin >> top >> front >> right >> left >> back >> bottom;
    Dice d2(top, bottom, front, back, left, right);

    if (d1.identical_with(d2)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int l;
    int r;
    cin >> l >> r;
    sum += (r - l + 1);
  }
  
  cout << sum << endl;
}



Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#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)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;
    int a[n];
    forn(i,n)   cin>>a[i];

    sort(a,a+n);
    cout<<a[(n/2)] - a[(n/2)-1]<<endl;
    return 0;
}



Measured memory_bytes: 640
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
	int h,a;
	scanf("%d%d",&h,&a);
	int t,ans=0;
	while(t<h)
	{
		t+=a;
		ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
N_prime = []

n = N
i = 2
while i <= N**0.5:
    if n%i != 0:
        i += 1
        continue
    
    N_prime.append(i)
    n = n/i
    if n == 1:
        break

if N_prime == [] and N != 1:
    N_prime.append(N)
elif n != 1:
    N_prime.append(int(n))

ct = []
for i in N_prime:
    if i not in ct:
        ct.append(i)
        temp_i = 1
        continue
    temp_i *= i
    if temp_i not in ct:
        ct.append(temp_i)
        temp_i = 1
        continue

print(len(ct))

Measured memory_bytes: 9500
s = input()
if len(s)%2 == 1 or len(s) == 0:
    print("No")
    exit()
while(len(s)):
    # print(s[:2])
    if s[:2] == "hi":
        if len(s) == 2:
            print("Yes")
            exit()
        s = s[2:]
    else:
        print("No")
        exit()
print("No")

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;

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

int main(){
  string N;
  cin >> N;
  REP(i, N.length()){
    N[i] -= '0';
  }

  int x=0, y= N[0]-1 + 9*(N.length()-1);
  REP(i, N.length()){
    x += N[i];
  }
  cout << max(x, y) << endl;
  return 0;
}


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

int main(){
    int n=0;
    string s;
    cin >>s;
    rep(i,4){
        if(s[i]=='+') n++;
        else n--;
    }
    cout << n << endl;
    return 0;
}




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

class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int N = Integer.parseInt(scn.next());
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = Integer.parseInt(scn.next());
		}
		Arrays.sort(A);
		boolean flag = true;
		if (N % 2 == 0) {
			for (int i = 0; i < N / 2; i++) {
				int tmp = i * 2 + 1;
				if (!(A[i * 2] == tmp && A[i * 2 + 1] == tmp)) {
					flag = false;
					break;
				}
			}
		} else {
			if (A[0] != 0) {
				flag = false;
			}
			if (flag) {
				for (int i = 0; i < (N - 1) / 2; i++) {
					int tmp = (i + 1) * 2;
					if (!(A[i * 2 + 1] == tmp && A[i * 2 + 2] == tmp)) {
						flag = false;

						break;
					}
				}
			}
		}

		if (flag) {
			long res = 1;
			long tmp = 1000000007;
			for (int i = 0; i < N / 2; i++) {
				res = (res * 2) % tmp;
			}
			System.out.println(res);
		} else {
			System.out.println(0);
		}
	}
}

Measured memory_bytes: 48704
s = input()
ans = "Yes"
for i in range(len(s)):
    if i % 2 == 0 and (s[i] == "R" or s[i] == "U" or s[i] == "D"):
        continue
    elif i % 2 == 1 and (s[i] == "L" or s[i] == "U" or s[i] == "D"):
        continue
    else:
        ans = "No"
        break
print(ans)

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

int main() {
  long long N;
  cin >> N;
  vector<long long> A(N);

  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  
  long long pre = 0;
  long long sum = 0;
  for (int i=0; i<N; i++) {
    sum += max(pre - A[i], (long long) 0);
    pre = max(pre, A[i]);
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 4832
N = int(input())


def dfs(s):  # 文字列 s で始まる七五三数の個数
    if int(s) > N:
        return 0

    ret = 1 if all(s.count(c) > 0 for c in "753") else 0  # s 自体が七五三数なら +1
    for c in "753":
        ret += dfs(s + c)
    return ret


print(dfs("0"))  # 本当は dfs('') と書きたいが if int(s) > N のエラー回避のために


Measured memory_bytes: 2940
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] kidsInfo = new int[n];
		int answer = 0;
		for(int i=0;i <n;i++) {
			kidsInfo[i] = sc.nextInt();
		}
		Arrays.sort(kidsInfo);
		for(int kids :kidsInfo) {
			if(kids <= x) {
				answer++;
				x-= kids;
			}else {
				break;
			}
		}
		if(x >=1 && answer ==n) {
			answer--;
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 23764
import java.util.*;
import java.math.BigInteger;
class Main{

     public static void main(String []args){
      Scanner scan = new Scanner(System.in);
      String s = scan.next() ;
      char[] cd = s.toCharArray() ;
      ArrayList<Character> a = new ArrayList<>() ;
      for(int i = 0 ; i<s.length() ; i++){
          a.add(cd[i]);
      }
      
      int count = 0 ;
      char i ;
      for( i = 'a' ; i<= 'z' ; i++ ){
          if(!a.contains(i)){
              count++ ;
              break ;
          }
      }
      if(count == 0){
          System.out.println("None");
      }else{
          System.out.println(i);
      }
    }
}

Measured memory_bytes: 27240
n = int(input())
a = list(map(int, input().split()))

dp1 = []
dp2 = []

dp1.append(max(a[0] + a[1], -a[0] - a[1]))
dp2.append(max(-a[0] + a[1], a[0] - a[1]))

for i in range(2, n):
    dp1.append(max(dp1[-1] + a[i], dp2[-1] - a[i]))
    dp2.append(max(dp1[-2] - a[i], dp2[-1] + a[i])) # 上の行でappendしてるから直前の項は後ろから2番目

print(dp1[-1])


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

int main() {
    int a, b;
    cin >> a >> b;
    int res = -1;
    for (int i = 0; i < 10000; i++) {
        int c = i * (0.08);
        int d = i * (0.10);
        if (c == a and d == b) {
            res = i; break;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
def selection_sort(a) # N個の要素を含む0-オリジンの配列A
  count = 0
  for i in 0...(a.length)
    minj = i
    for j in i...(a.length)
      if a[j] < a[minj]
        minj = j
      end
    end
    if a[i] != a[minj]
      count += 1
    end
    old_ai = a[i]
    a[i] = a[minj]
    a[minj] = old_ai
  end

  puts a.join(" ")
  puts count
end

gets

a = gets.split.map(&:to_i)

selection_sort(a)



Measured memory_bytes: 6860
#include<iostream>

using namespace std;

int main(){
  while(1){
    int in, sum, min;
    cin >> in;
    min = in;
    if(in == 0) break;

    int pre;

    for(int z = 0; z*z*z <= in; z++){
      sum = in - z*z*z;
      for(int y = 0; y*y <= in-z*z*z; y++){
	sum = in - z*z*z - y*y;
	pre = z+y+sum;
	if(min > pre) min = pre;
      }
    }

    cout << min << endl;
  }
  return 0;
}

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

using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009ll
#define INFL 1000000000000000018ll
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mk make_pair
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<pair<int, PA> , vector<pair<int, PA> >, greater<pair<int, PA> > >PQG;

int N, A[100005], sum[100005], fact[100005], ans;

int modpow(int a, int p, int MOD)
{
    if(p == 0){
        return 1;
    }
    if(a == 1){
        return a;
    }
    if(p % 2 == 1){
        return a * modpow(a, p - 1, MOD) % MOD;
    }
    else{
        int A = modpow(a, p / 2, MOD);
        return A * A % MOD;
    }
}


signed main()
{
    cin >> N;
    fact[0] = 1;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        sum[i + 1] = modpow(i + 1, mod - 2, mod);
    }
    for(int i = 1; i <= N; i++){
        sum[i] += sum[i - 1];
        sum[i] %= mod;
        fact[i] = (fact[i - 1] * i) % mod;
    }
    int factN = fact[N];
    for(int i = 0; i < N; i++){
        ans = ((factN * A[i] % mod) * ((sum[i + 1] + sum[N - i] - 1) % mod) + ans) % mod;
    }
    cout << ans % mod << endl;

    return 0;
}
/*



*/


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int main(){
  string s; cin >> s;
  int n = s.size();
  vector<int> a(n);
  rep(i, n) a[i] = s[i] - '0';

  int mi = 1001001001;
  rep(i, n-2){
    int tmp = 100*a[i] + 10*a[i+1] + a[i+2];
    chmin(mi, abs(tmp-753));
  }

  cout << mi << endl;

  return 0;
}


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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  rep(i,0,s.size()) if(s[i] == '1') ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define forn(a,b,c) for(int a=b;a<=c;a++)
#define ford(a,b,c) for(int a=b;a>=c;a--)
#define f first
#define s second
typedef pair<int,int> pii;
const int N=4e2+5;
const int mod=998244353;
int n;ll a[N],s[N],dp[N][N];
ll calc(int l,int r){
    if(dp[l][r]!=-1){
        return dp[l][r];
    }
    dp[l][r]=LLONG_MAX;
    forn(k,l,r-1){
        ll curr=s[r]-s[l-1];
        if(k!=l)
            curr+=calc(l,k);
        if(k!=r-1)
            curr+=calc(k+1,r);
        dp[l][r]=min(dp[l][r],curr);
    }
    return dp[l][r];
}
int main()
{
    scanf("%d",&n);
    forn(i,1,n){scanf("%d",&a[i]);s[i]=s[i-1]+a[i];}
    fill(&dp[0][0], &dp[0][0] + N*N, -1);
    printf("%lld\n",calc(1,n));
    return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}

template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

int64 Solve() {
  int n;
  cin >> n;
  vector<int64> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }

  auto check_fn = [&]() -> bool {
    for (int i = 0; i < n; i++) {
      if (xs[i] >= n) return false;
    }
    return true;
  };
  if (check_fn()) return 0;

  int64 count = 0;
  do {
    for (int i = 0; i < n; i++) {
      int64 q = xs[i] / n;
      xs[i] -= q * n;
      for (int j = 0; j < n; j++) {
        if (j == i) continue;
        xs[j] += q;
      }
      count += q;
    }
  } while (!check_fn());
  return count;
}

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

  cout << Solve() << endl;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int k = ri() - 1;
	int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	printf("%d\n", a[k]);
	return 0;
}




Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import Counter, defaultdict


def read():
    H, W, M = map(int, input().strip().split())
    HW = []
    for i in range(M):
        h, w = map(int, input().strip().split())
        HW.append((h, w))
    return H, W, M, HW


def solve(H, W, M, HW):
    hcount = Counter()
    wcount = Counter()
    for h, w in HW:
        hcount[h] += 1
        wcount[w] += 1
    hm = hcount.most_common()
    wm = wcount.most_common()
    hmax = hm[0][1]
    wmax = wm[0][1]
    hn = len([1 for k, v in hcount.items() if v == hmax])
    wn = len([1 for k, v in wcount.items() if v == wmax])
    m = hn * wn
    for h, w in HW:
        if hcount[h] == hmax and wcount[w] == wmax:
            m -= 1
    if m == 0:
        return hmax + wmax - 1
    return hmax + wmax


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


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

int main() {
  string s;
  cin >> s;
  bool gb=true;
  for(int i=1;i<4;i++){
    if(s[i]==s[i-1])gb=false;
  }
  if(gb)cout<< "Good";
  else cout << "Bad";
}



Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
using namespace std;
int main()
{
    fastio;
    long long n,i;
    cin>>n;
    long long v[n],c[n],x=0,y=0;
    for(i=0;i<n;i++)
    {
        cin>>v[i];
    }
    for(i=0;i<n;i++)
    {
        cin>>c[i];
        if(v[i]>c[i])
        {
            x=x+v[i];
            y=y+c[i];
        }
    }
    cout<<x-y;
    return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#include<string.h>
#define inf 9000000000000000000
#define maxn 200006
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
#define endl '\n'
#define mapint_iterator map<int,int> :: iterator
#define mapll_iterator map<ll,ll> :: iterator
#define setint_iterator set<int> :: iterator
#define setll_iterator set<ll> :: iterator
#define setpint_iterator set<pint> :: iterator
#define setpll_iterator set<pll> :: iterator
#define trace(x) cout<<#x<<": "<<x<<" "<<endl
#define trace2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x,y,z) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a,b,c,d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<endl
#define cout2(a,b) cout<<a<<' '<<b<<endl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<endl
typedef priority_queue<ll,vector<ll>,greater<ll> > pqset;
typedef priority_queue<pint,vector<pint>,greater<pint> > pqset_ll;
#define pb push_back
#define fi first
#define se second
#include<ext/pb_ds/assoc_container.hpp>
ll dxk[]={0,0,1,-1,1,1,-1,-1};
ll dyk[]={1,-1,0,0,1,-1,1,-1};
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> os_pair;
#define acc (ios::sync_with_stdio(false),cin.tie(0))
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define repeat(i,start,n) for(ll i=start;i<n;i++)
#define print(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" ";}
ll ll_max(ll a,ll b,ll c){return max(a,max(b,c));}
int int_max(int a,int b,int c){return max(a,max(b,c));}
ll ll_min(ll a,ll b,ll c){return min(a,min(b,c));}
int int_min(int a,int b,int c){return min(a,min(b,c));}
ll max(int a,ll b){ return max((ll)a,b);}
ll min(int a,ll b){ return min((ll)a,b);} 
ll min(ll a,int b){ return min(a,(ll)b);}
ll max(ll a,int b){ return max(a,(ll)b);}
ll dx[]={0,0,1,-1};
ll dy[]={1,-1,0,0};
//ifstream cin("b_read_on.txt"); ofstream cout("output3.txt");
//Chronology: Binary Search,Greedy,dp,dfs and similar
//Use (<<) for multiplication
//Use (>>) for division
// In dp, first try top-down,then bottom-up
//ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed;cerr.tie(NULL);cout.precision(10);
// find_by_order -> value at index
// order_of_key -> index of value
void solve(int countu){
	double r;
	cin>>r;
	r*=(double)6.28318530717958623200;
	cout.precision(10);
	cout1(r);
}
int main(){
    int t=1;
	//scanf("%d",&t);
	int countu=1;
    while(t--){
    	solve(countu);
    	countu++;
    }
}

Measured memory_bytes: 3780
import java.util.*;
public class Main {
public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
	// 整数の入力
	int a = sc.nextInt();

  
     int b = sc.nextInt();
  		int  answer  = 0;
       
  		for (int i = 0; i< 2 ; i++){
        	if(a >= b){
               answer += a;
               a--;
            }else if(a < b ){
            	answer += b;
                b--;
            }
        }
  
  		System.out.println(answer);
  		
	}
}


Measured memory_bytes: 22612
use proconio::{fastout, input};

use std::cmp::{max, min};

fn pow(mut x: i64, mut y: i64, z: i64) -> i64 {
    let mut r = 1;
    while y > 0 {
        if y & 1 == 1 {
            r = r * x % z;
        }
        x = x * x % z;
        y >>= 1;
    }
    r
}

fn inv(x: i64, y: i64) -> i64 {
    pow((x % y + y) % y, y - 2, y)
}

#[fastout]
fn main() {
    const M: i64 = 1_000_000_007;
    input! {
        n: usize, mut k: usize,
        mut a: [i64; n],
    }
    let mut pos = 0;
    let mut zero = 0;
    let mut neg = 0;
    for &x in a.iter() {
        if x > 0 {
            pos += 1;
        } else if x < 0 {
            neg += 1;
        } else {
            zero += 1;
        }
    }
    if k > pos + neg {
        println!("0");
        return;
    }
    a.sort();
    // let mut l = 0;
    // let mut acc = 1;
    // while k > pos && k >= 2 {
    //     acc *= acc * (a[l] * a[l + 1] % M) % M;
    //     l += 2;
    //     k -= 2;
    // }
    // for i in n - k..n {
    //     acc *= acc * a[i] % M;
    // }
    // while k >= 2 && l < neg {
    //     if a[l] * a[l + 1] >= a[n - k] * a[n - k + 1] {
    //     } else {
    //         break;
    //     }
    //     acc = acc * a[l] % M * a[l + 1] % M;
    //     acc = acc * inv(a[n - k], M) % M * inv(a[n - k + 1], M) % M;
    //     l += 2;
    //     k -= 2;
    // }
    // println!("{}", acc);
    // return;

    if pos == 0 {
        if k % 2 == 0 {
            let mut acc = 1;
            for i in 0..k {
                acc = acc * a[i] % M;
            }
            acc = (acc % M + M) % M;
            if zero > 0 && acc < 0 {
                println!("0");
            } else {
                println!("{}", acc);
            }
        } else {
            let mut acc = 1;
            for i in n - k..n {
                acc = acc * a[i] % M;
            }
            acc = (acc % M + M) % M;
            if zero > 0 && acc < 0 {
                println!("0");
            } else {
                println!("{}", acc);
            }
        }
        return;
    }
    {
        let mut l = 0;
        let mut acc = 1;
        while k > pos {
            k -= 2;
            acc = acc * a[l] % M * a[l + 1] % M;
            l += 2;
        }
        for i in n - k..n {
            acc = acc * a[i] % M;
        }
        let mut ans = acc;
        for i in 0..(neg - l) / 2 {
            if n - k + i * 2 + 1 >= n {
                break;
            }
            if a[l + i * 2] * a[l + i * 2 + 1] > a[n - k + i * 2] * a[n - k + i * 2 + 1] {
            } else {
                break;
            }
            acc = acc * a[l + i * 2] % M * a[l + i * 2 + 1] % M;
            acc = acc * inv(a[n - k + i * 2], M) % M * inv(a[n - k + i * 2 + 1], M) % M;
            // ans = max(ans, acc);
        }
        acc = (acc % M + M) % M;
        println!("{}", acc);
    }
}


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

int main(){
    int *a;
    int *buf;
    int n = 0;
    int m = 0;
    int s = 0;
    int c = 0;
    cin >> n;
    a = new int[n];
    buf = new int[m];
    for(int i = 0; i < n; i++){
        a[i] = 10;
        buf[i] = 0;
    }
    cin >> m;
    

    for(int i = 0; i < m; i++){ 
        //cout << m;
        cin >> s;
        cin >> c;
        buf[s-1]++;
        //cout << s<<"\n"<< c<< "\n";
        if((s == 1 && c == 0 && n != 1)){
            cout << -1;
            delete[] a;
            return 0;
        }else if(buf[s-1] > 1){
            if(a[s-1] != c){
            cout << -1;
            delete[] a;
            return 0;
            }
        }
        a[s-1] = c;
    }
    for(int i= 0; i < n; i++){
        if(a[i] == 10){
            if(i == 0 && n != 1){
                a[i] = 1;
            }else{
                a[i] = 0;
            }
        }
    }

    for(int i = 0; i < n; i++){
        cout << a[i];
    }
    delete[] a;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long 
#define PB push_back
#define PII pair <long long , long long>
#define FAST ios::sync_with_stdio(false);cin.tie(0);

const int maxn = 2e3 + 30;
string a[maxn];
int vertex[maxn][maxn] , er[maxn][maxn] , ed[maxn][maxn];

int main() {
    int n , m , q;
    cin >> n >> m >> q;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if(a[i - 1][j - 1] == '1') {
                vertex[i][j]++;
            }
            vertex[i][j] += vertex[i - 1][j] + vertex[i][j - 1] - vertex[i - 1][j - 1];
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            // if(a[i - 1][j - 1] == '1' && a[i - 2][j - 1] == '1') {
            //     ed[i][j]++;
            // }
            if(a[i - 1][j - 1] == '1' && a[i][j - 1] == '1') {
                ed[i][j]++;
            }
            ed[i][j] += ed[i - 1][j] + ed[i][j - 1] - ed[i - 1][j - 1]; 
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            // if(a[i - 1][j - 1] == '1' && a[i - 1][j - 2] == '1') {
            //     er[i][j]++;
            // }
            if(a[i - 1][j - 1] == '1' && a[i - 1][j] == '1') {
                er[i][j]++;
            }
            er[i][j] += er[i - 1][j] + er[i][j - 1] - er[i - 1][j - 1]; 
        }
    }
    while(q--) {
        int x1 , y1 , x2 , y2;
        ll p1 = 0 , p2 = 0;
        cin >> x1 >> y1 >> x2 >> y2;
        p1 = vertex[x2][y2] - vertex[x2][y1 - 1] - vertex[x1 - 1][y2] + vertex[x1 - 1][y1 - 1];
        p2 += ed[x2 - 1][y2] - ed[x2 - 1][y1 - 1] - ed[x1 - 1][y2] + ed[x1 - 1][y1 - 1];
        p2 += er[x2][y2 - 1] - er[x1 - 1][y2 - 1] - er[x2][y1 - 1] + er[x1 - 1][y1 - 1];
        cout << p1 - p2 << endl;
    }
}

Measured memory_bytes: 54016
N,M=map(int,input().split())
checked=set()
from collections import defaultdict
branch=defaultdict(dict)
flag=True
for i in range(M):
    L,R,D=map(int,input().split())
    branch[L-1][R-1]=D
    branch[R-1][L-1]=-1*D
for i in range(N):
    if i in checked:
        continue
    if not flag:
        break
    dist=dict()
    dist[i]=0
    check={i}
    while len(check)>0:
        now=check.pop()
        checked|={now}
        for nex,d in branch[now].items():
            if nex not in dist.keys():
                dist[nex]=dist[now]+d
                check|={nex}
            elif dist[nex]!=dist[now]+d:
                flag=False
                check=set()
                break
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 90276
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

d.sort()
t.sort()
d_cnt=0
for i in range(len(t)):
        found=False
        for j in range(d_cnt,len(d)):
                if t[i]==d[j]:
                        d_cnt=j+1
                        found=True
                        break
        if not found:
                print("NO")
                exit()
print("YES")

Measured memory_bytes: 35556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<int ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

vector<int> prime;
vector<int> ls;

void sieve(int N){
    prime.resize(N+1,1);
    prime[0] = prime[1] = 0;
    for(int i=2;i*i<=N;i++){
        for(int j=i*i;j<=N;j+=i){
            prime[j] = 0;
        }
    }
    for(int i=2;i<=N;i++){
        if(prime[i])ls.push_back(i);
    }
}

int main() {
    sieve(int(1e5));
    int n;
    while(cin >> n){
        int a, b;
        a = *--lower_bound(ALL(ls),n);
        b = *upper_bound(ALL(ls),n);
        cout << a << " " << b << endl;
    }
    return 0;
}


Measured memory_bytes: 3200
import sys

N, M = [int(n) for n in input().split()]

def factorial_mod(n):
    result = 1
    for i in range(1,n+1):
        result = (result * i) % (10**9 + 7)
    return result

if abs(N - M) > 1:
    print(0)
    sys.exit(0)

N_fact = factorial_mod(N)
M_fact = factorial_mod(M)

if N == M:
    print((2*N_fact*M_fact) % (10**9 + 7))
else:
    print((N_fact*M_fact) % (10**9 + 7))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;

int main() {
  ldouble a, b, c;
  cin >> b >> c;
  rep(i, 2000){
    if((i+1)*0.08 >= b && (i+1)*0.08 < b+1 && (i+1)*0.1 >= c && (i+1)*0.1 < c+1){
      a = i+1;
      break;
    }
    if((i+1)*0.08 >= b+1 || (i+1)*0.1 >= c+1){
      a = -1;
      break;
    }
  }
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 256
MOD = 10**9+7
class mint:
    def __init__(self, x):
        self.x = x % MOD if isinstance(x, int) else int(x) % MOD
    def __str__(self):
        return str(self.x)
    __repr__ = __str__
    def __iadd__(self, other):
        self.x += other.x if isinstance(other, mint) else other
        self.x -= MOD if self.x >= MOD else 0
        return self
    def __isub__(self, other):
        self.x += MOD-other.x if isinstance(other, mint) else MOD-other
        self.x -= MOD if self.x >= MOD else 0
        return self
    def __imul__(self, other):
        self.x *= other.x if isinstance(other, mint) else other
        self.x %= MOD
        return self
    def __imod__(self, other):
        self.x %= other.x if isinstance(other, mint) else other
        self.x %= MOD
        return self
    def __add__(self, other):
        return (
            mint(self.x + other.x) if isinstance(other, mint) else
            mint(self.x + other)
        )
    def __sub__(self, other):
        return (
            mint(self.x - other.x) if isinstance(other, mint) else
            mint(self.x - other)
        )
    def __mul__(self, other):
        return (
            mint(self.x * other.x) if isinstance(other, mint) else
            mint(self.x * other)
        )
    def __mod__(self, other):
        return (
            mint(self.x % other.x) if isinstance(other, mint) else
            mint(self.x % other)
        )
    def __truediv__(self, other):
        return (
            mint(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, mint) else
            mint(self.x * pow(other, MOD - 2, MOD))
        )
    def __pow__(self, other):
        return (
            mint(pow(self.x, other.x, MOD)) if isinstance(other, mint) else
            mint(pow(self.x, other, MOD))
        )
    __radd__ = __add__
    def __rsub__(self, other):
        return (
            mint(other.x - self.x) if isinstance(other, mint) else
            mint(other - self.x)
        )
    __rmul__ = __mul__
    def __rmod__(self, other):
        return (
            mint(other.x % self.x) if isinstance(other, mint) else
            mint(other % self.x)
        )
    def __rtruediv__(self, other):
        return (
            mint(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, mint) else
            mint(other * pow(self.x, MOD - 2, MOD))
        )
    def __rpow__(self, other):
        return (
            mint(pow(other.x, self.x, MOD)) if isinstance(other, mint) else
            mint(pow(other, self.x, MOD))
        )



n,a,b = map(int, input().split())
ans=mint(0)

ans+=mint(2)**n-1

minus=mint(1)
for i in range(a):
    minus*=n-i
    minus/=i+mint(1)

ans-=minus

minus=mint(1)
for i in range(b):
    minus*=n-i
    minus/=i+mint(1)

ans-=minus

print(ans)


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define REP(k, n) for (ll k = 0; k < (ll)(n); ++k)
#define REPREV(k, n) for (ll k = (ll)(n)-1; k >= 0; --k)
#define FOR(k, a, b) for (ll k = (ll)(a); k < (ll)(b); ++k)
#define FORREV(k, a, b) for (ll k = (ll)(b)-1; k >= (ll)(a); --k)
#define FOREACH(e, v) for (auto& e : v)

#define TGET(t, i) get<i>(t)
#define TSET(t, i, a) get<i>(t) = a
// MinHeap - priority_queue<ll, vll, greater<ll>> pq;

#define EVEN(n) ((n)&1) == 0
#define ODD(n) ((n)&1) == 1

#define SORT(v) sort(v.begin(), v.end())
#define SORTREV(v) sort(v.rbegin(), v.rend())
#define SHUFFLE(v) random_shuffle(v.begin(), v.end())
//srand(unsigned(time(0)));

#define REMOVEAT(v, i) v.erase(v.begin() + i)
#define REVERSE(v) reverse(v.begin(), v.end())

ll MOD(ll x, ll m) {
    ll r = x % m;
    if (r < 0) {
        r += m;
    }
    return r;
}

ostream& operator<<(ostream& str, const pll& p) {
    str << p.first << " " << p.second;
    return str;
}

template <typename T>
void join(T& arr, string sep) {
    bool first = true;
    for (auto t : arr) {
        if (first) {
            first = false;
            cout << t;
        } else {
            cout << sep << t;
        }
    }
    cout << "\n";
}

#define POS "POSSIBLE"
#define IMPOS "IMPOSSIBLE"

// #define INF LLONG_MAX
// #define MINF LLONG_MIN
#define INF 9e18
#define MINF -INF

void solve() {
    ll n;
    cin >> n;
    vll a(n);
    ll sum = 0;
    map<ll, ll> mp;
    REP(i, n) {
        cin >> a[i];
        sum += a[i];
        mp[a[i]]++;
    }
    ll q;
    cin >> q;
    REP(i, q) {
        ll b, c;
        cin >> b >> c;
        ll size = mp[b];
        sum -= b * size;
        sum += c * size;
        mp[b] -= size;
        mp[c] += size;
        cout << sum << "\n";
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt = 1;
    // cin >> tt;
    for (int t = 1; t <= tt; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }

    return 0;
}

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

map<int, int>mp1, mp2;
int main() {
	string s;
	while (getline(cin, s), s != "") {
		int c; sscanf(s.data(), "%d,%*d", &c);
		mp1[c]++;
	}
	while (cin >> s) {
		int c; sscanf(s.data(), "%d,%*d", &c);
		mp2[c]++;
	}
	for (auto i : mp1) {
		if (mp2[i.first])
			cout << i.first << ' ' << i.second + mp2[i.first] << endl;
	}
	return 0;
}

Measured memory_bytes: 3124
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; ++i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)

const int MAX_N = 111;
const int MAX_K = 1e5+10;
const int MOD = 1e9+7;
int N, K;
ll dp[MAX_N][MAX_K], s[MAX_K];
int A[MAX_N];

int main () {
  cin >> N >> K;
  REP (i, N) cin >> A[i];
  REP (i, A[0]+1) dp[0][i] = 1;
  FOR (i, 1, N) {
    s[0] = dp[i-1][0];
    REP (j, MAX_K) (s[j+1] = s[j] + dp[i-1][j+1]) %= MOD;
    REP (j, MAX_K) {
      (dp[i][j] += s[j]) %= MOD;
      if (j > A[i]) (dp[i][j] -= s[j-A[i]-1]) %= MOD;
    }
  }
  cout << (dp[N-1][K]+MOD)%MOD << endl;
}

Measured memory_bytes: 80128
#include<bits/stdc++.h>
using namespace std;
map<int,int>vis;
int n,ans,k,a[200005];
int tmp[50];
int main()
{
	tmp[0]=1;
	for (int i=1;i<=30;i++) tmp[i]=tmp[i-1]<<1;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		vis[a[i]]++;
	}
	sort(a+1,a+n+1);
	for(int i=n;i>=1;i--)
	{
		int pos=upper_bound(tmp,tmp+30,a[i])-tmp;
		if(pos>=31||!vis[a[i]]) continue;
		k=tmp[pos]-a[i];
		if((k!=a[i]&&vis[k])||(k==a[i]&&vis[k]>1))
		{
			ans++;
			vis[k]--;
		}
		vis[a[i]]--;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 19712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,x;
    cin>>N>>x;
    int a[N];
    rep(i,N) cin>>a[i];
    int ans=0;
    for(int i=1;i<N;i++){
        int w=a[i]+a[i-1];
        int y=0;
        if(x<w) y=w-x;
        ans+=y;
        if(a[i]<y){
            a[i]=0;
            a[i-1]-=y-a[i];
        }else{
            a[i]-=y;
        }
    }
    cout << ans << endl;



}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> T;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define MP make_pair
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}

using Graph = vector<vector<pair<int, int>>>;
using vvec = vector<vector<int>>;
using vec = vector<int>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int h,n;
    cin>>h>>n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    int s=0;
    rep(i,n) s+=a[i];
    if(s>=h){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 1024
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int a, b;
    bool ans[] = {true, true, true};
    cin >> a >> b;
    ans[a-1] = false;
    ans[b-1] = false;
    REP(i, 3)
        if(ans[i]){
            cout << i+1 << endl;
        }
    return 0;

    return 0;
}

Measured memory_bytes: 256
import sys,math
n=int(input())
a=list(map(int,input().split()))
numbers={}
flag=0
for i in range(n):
  if a[i] in numbers:
    numbers[a[i]]+=1
  else:
    numbers[a[i]]=1
for pointer in range(2,10**6+1):
  count=0
  pointer2=pointer
  while pointer2<10**6+1:
    if pointer2 in numbers:
      count+=numbers[pointer2]
    pointer2+=pointer
  if count>=2:
    flag=1
    break
if flag==0:
  print('pairwise coprime')
  sys.exit()
ans=a[0]
for i in range(1,n):
  ans=math.gcd(a[i],ans)
if ans==1:
  print('setwise coprime')
else:
  print('not coprime')


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

int main(){
    int h, w, n, a, m[100][100];
    cin >> h >> w >> n;
    int sum = 0;
    rep(i, n){
        scanf("%d", &a);
        rep(_, a){
            m[sum / w][sum % w] = i+1;
            sum++;
        }
    }
    rep(i, h){
        rep(j, w){
            if(j) printf(" ");
            if(i % 2 == 0){
                printf("%d", m[i][j]);
            } else {
                printf("%d", m[i][w-1-j]);
            }
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main()
{
    long long n,d,x,y,s=0;
	cin>>n>>d;
	
	for(int i=0;i<n;i++)
    {
    	cin>>x>>y;
    	if(x*x+y*y<=d*d) s++;
	}
    cout<<s;
    return 0;
}

Measured memory_bytes: 3628
n = int(input())
d = {}
for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d.setdefault(s,1)
#d_keysort = sorted(d.items(), key=lambda x:x[0])[0]
mx = max(d.values())
ans_list = [k for k, v in d.items() if v == mx]
ans_list.sort()
for i in range(len(ans_list)):
         print(ans_list[i])

Measured memory_bytes: 32152
#include<stdio.h>
#define MAX 100000

int A[MAX],n;

int partition(int p, int r){
    int x,i,j,t;
    x = A[r];
    i = p-1;
    for(j=p;j<r;j++){
        if(A[j] <= x){
            i++;
            t = A[i];
            A[i] = A[j];
            A[j] = t;
        }
    }
    t = A[i+1];
    A[i+1] = A[r];
    A[r] = t;
    return i+1;
}

int main(){
    int i,q;
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&A[i]);
    
    q = partition(0,n-1);
    
    for(i=0; i<n;i++){
        if(i) printf(" ");
        if(i == q) printf("[");
        printf("%d",A[i]);
        if(i == q) printf("]");
    }
    printf("\n");
    
    return 0;
    
}


Measured memory_bytes: 2120
#include <iostream>

using namespace std;

int main() {
  long long int h, w;
  while(1) {
    cin >> h >> w;

    if(h == 0 && w == 0) break;
    
    for(int j=0; j<h; j++) {
        for(int i=0; i<w; i++) {
            cout << "#";
        }
        cout << endl;
    }
  
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3080
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)



main :: IO ()
main = do
    n <- readLn
    print $ (fromIntegral (d n)) / (fromIntegral n)

d :: Integer -> Integer
d n | mod n 2 == 0  = div n 2
    | otherwise     = div n 2 + 1


Measured memory_bytes: 508
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define repd(i, n) for (ll i = (n)-1; i >= 0; --i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

ll dp[100010];
vector<vector<ll>> vec(100010);

ll rec(ll i)
{
    if (dp[i] != -1)
        return dp[i];
    else
    {
        ll res = 0;
        for (auto j : vec[i])
            res = max(res, rec(j) + 1);
        dp[i] = res;
        return res;
    }
}
int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    vector<ll> syutujisu(n, 0);
    rep(i, m)
    {
        ll a, b;
        cin >> a >> b;
        --a, --b;
        vec[a].push_back(b);
        ++syutujisu[b];
    }
    rep(i, n) dp[i] = -1;
    ll ans = 0;
    rep(i, n)
        ans = max(ans, rec(i));
    cout << ans << endl;
}

Measured memory_bytes: 9344
#include<bits/stdc++.h>
using namespace std;
int main(){
string x;
cin>>x;
if(x=="a"){
   cout<<"b";}
    else if (x=="b"){
   cout<<"c";}
 else if (x=="c"){
   cout<<"d";}
 else if (x=="d"){
   cout<<"e";}
 else if (x=="e"){
   cout<<"f";}
 else if (x=="f"){
   cout<<"g";}
 else if (x=="g"){
   cout<<"h";}
 else if (x=="h"){
   cout<<"i";}
 else if (x=="i"){
   cout<<"j";}
 else if (x=="j"){
   cout<<"k";}
 else if (x=="k"){
   cout<<"l";}
 else if (x=="l"){
   cout<<"m";}
 else if (x=="m"){
   cout<<"n";}
 else if (x=="n"){
   cout<<"o";}
 else if (x=="o"){
   cout<<"p";}
 else if (x=="p"){
   cout<<"q";}
 else if (x=="q"){
   cout<<"r";}
 else if (x=="r"){
   cout<<"s";}
 else if (x=="s"){
   cout<<"t";}
 else if (x=="t"){
   cout<<"u";}
 else if (x=="u"){
   cout<<"v";}
 else if (x=="v"){
   cout<<"w";}
 else if (x=="w"){
   cout<<"x";}
 else if (x=="x"){
   cout<<"y";}
 else if (x=="y"){
   cout<<"z";}
 else if (x=="z"){
   cout<<"a";}
return 0;}


Measured memory_bytes: 256
/*
 * 文字列 S が与えられます。
 * 
 * 高橋君はこの文字列の好きな位置に好きなだけ文字 A を挿入することができます。
 * 
 * S を AKIHABARA に変えることはできるでしょうか？
 */

import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            // 入力
            String s = sc.next();
            
            // 先頭がAなら省く
            if(s.charAt(0) == 'A'){
            	s = s.substring(1);
            }
            
            // 先頭がKIHならOK
            if(s.length() > 4 && s.substring(0, 3).equals("KIH")){
           		s = s.substring(3);
           		// 先頭がAなら省く
           		if(s.charAt(0) == 'A'){
           			s = s.substring(1);
           		}
           		
           		// 先頭がBならOK
            	if(s.charAt(0) == 'B'){
            		s = s.substring(1);
            		// 先頭がAなら省く
            		if(s.charAt(0) == 'A'){
               			s = s.substring(1);
               		}
            		
            		// 残りがRまたはRAならOK
            		if(s.equals("R") || s.equals("RA")){
            			System.out.println("YES");
            			sc.close();
            			return;
                	}
            	}
            }
            // どこかしらで脱落したらNOを出力
            System.out.println("NO");
            sc.close();
        }
    }
	

Measured memory_bytes: 21844
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        String s=in.nextLine();
        String t=in.nextLine();
        int ans=0;
        for (int i = 0; i < s.length(); i++) {
            if(s.charAt(i)!=t.charAt(i)){
                ans++;
            }
        }
        System.out.println(ans);
    }
}

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

using namespace std;

typedef long long ll;

#define sz(x) int((x).size())

const int N=1e6+5,M=1e3+7,mod=1e9+7;

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

int b[N],n,m,k,tc,ans,d,x,y;

ll a[N];

char s[N];

vector<pair<int,int> > g[N];

ll solve() 
{ 
    ll ret=0; 
    for (int i = 0; i < 60; i++)  
    { 
        int z = 0, o = 0;  
        ll curr = 0;  
        for (int j = 0; j < n; j++) { 
            if (a[j] % 2 == 0) 
                z++; 
            else
                o++; 
            a[j] /= 2; 
        }        
        curr = ( ((ll)o * z %mod) * ((1LL << i)%mod))%mod;  
        ret = (ret+curr)%mod;  
    } 
    return ret; 
} 

int main() {
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    	scanf("%lld",&a[i]);
    printf("%lld\n",solve());
}



Measured memory_bytes: 30976
import heapq
n, m = map(int, input().split())
a=list(map(int, input().split()))
a=list(map(lambda x: x*(-1), a))
heapq.heapify(a)

for i in range(m):
  t=heapq.heappop(a)
  t=t*(-1)//2
  heapq.heappush(a, t*(-1))
print(sum(a)*(-1))


Measured memory_bytes: 14180