akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

bool visited[10][10];
pii a[10];
int n;

pii t[12] = {{-2, 1}, {-2, 0}, {-2, -1}, {-1, -2}, {0, -2}, {1, -2}, {2, -1}, {2, 0}, {2, 1}, {1, 2}, {0, 2}, {-1, 2}};

struct node
{
    int x, y, d;
};

string dfs(node in)
{
    stack<node> st;
    st.push(in);

    while (!st.empty())
    {
        node u = st.top();
        bool flag = 0;

        rep(i, 12)
        {
            node nt;
            nt.x = u.x + t[i].first, nt.y = u.y + t[i].second;
            if (!(a[u.d].first - 1 <= nt.x && nt.x <= a[u.d].first + 1 && a[u.d].second - 1 <= nt.y && nt.y <= a[u.d].second + 1))
                continue;
            if (!visited[nt.x][nt.y])
            {
                nt.d = u.d + 1;
                if (nt.d == n)
                    return "OK";
                st.push(nt);
                flag = 1;
            }
        }

        if (!flag)
        {
            visited[u.x][u.y] = 1;
            st.pop();
        }
    }

    return "NA";
}

int main()
{
    node in;
    while (cin >> in.x >> in.y, in.x != 0 && in.y != 0)
    {
        rep(i, 10) rep(j, 10) visited[i][j] = 0;
        in.d = 0;
        cin >> n;

        rep(i, n) cin >> a[i].first >> a[i].second;

        OP(dfs(in));
    }

    return 0;
}


Measured memory_bytes: 3104
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int d = scn.nextInt();
		int n = scn.nextInt();
      	int ans = 0;
        int dd = (int)Math.pow(100,d);
        ans = dd*n;
      	if(n==100){
      		ans = ans + dd;
    	}
      	System.out.println(ans);
	}
}


Measured memory_bytes: 35500
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]

n = II()
a = LI()

b = [0]*(n+1)
count = 0
for i in range(n):
    b[a[i]] += 1
for i in range(n+1):
    count += b[i]*(b[i]-1)/2
for i in a:
    print(int(count-b[i]+1))

Measured memory_bytes: 25456
import java.util.Scanner;
class Main
{
   public static void main(String[] args)
      {
             Scanner sc = new Scanner(System.in);
        String s;
        int len=0;
        int i;
        char[] c = new char[1200];
        s = sc.nextLine();
        len += s.length();
        c = s.toCharArray();
        for(i=0;i<len;i++){
        if('a'<=c[i]&&c[i]<='z') c[i] -= 32;
        else if('A'<=c[i]&&c[i]<='Z') c[i]+= 32;
        System.out.print(c[i]);
        }
        System.out.println();
}
}



Measured memory_bytes: 26760
//
// Created by Hideaki Imamura on 2020-01-02.
//

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

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

    if (a >= k) {
        cout << a - k << ' ' << b << endl;
    } else if (a < k && b >= k - a) {
        cout << 0 << ' ' << b - k + a << endl;
    } else {
        cout << 0 << ' ' << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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 <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N,K; cin >> N >> K;
    VL A(N); REP(i,N) cin >> A[i];
    sort(A.begin(),A.end());
    int ok = N, ng = -1;
    while(abs(ok-ng) > 1){
        int mid = (ok+ng) / 2;
        VVI dp(N+1,VI(5010,-1));
        dp[0][0] = 1;
        int cnt = 0;
        REP(i,N){
            if(i == mid) continue;
            REP(j,5010){
                dp[cnt+1][j] = dp[cnt][j];
            }
            REP(j,5010){
                if(j-A[i] >= 0) chmax(dp[cnt+1][j], dp[cnt][j-A[i]]);
            }
            cnt++;
        }
        bool pos = false;
        FOR(i,max(0LL,K-A[mid]),K){
            if(dp[N-1][i] == 1) pos = true;

        }
        if(pos) ok = mid;
        else ng = mid;
    }
    cout << ng + 1 << endl;

}

Measured memory_bytes: 101412
import re
lst = input()
if len(lst) >= 6:
    if re.findall("[0-9]",lst):
        if re.findall("[A-Z]",lst):
            if re.findall("[a-z]",lst):
                print("VALID")
            else: print("INVALID")
        else: print("INVALID")
    else: print("INVALID")
else: print("INVALID")


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int x;
  
  int plan1 = N * A;
  
  if (plan1 < B) {
    x = plan1;
  }
  else {
    x = B;
  }
  
  cout << x << endl;
}


Measured memory_bytes: 3608
//
// Created on 2020/04/10.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;

bool is_prime(int n){
    if (n == 1) return false;
    for (int i =2 ; pow(i,2) <= n ; ++i) {
        if(n % i == 0) return false;
    }
    return true;
}

int main() {
    int x;
    cin>>x;
    int i;
    for (i = 0; i < INF; ++i) {
        if(is_prime(x+i)) break;
    }

    cout<<x+i<<endl;
}


Measured memory_bytes: 256
H, W, K = map(int, input().split())
S = list(input() for i in range(H))

sum = [[0] * (W+1) for i in range((H+1))]
for i in range(H):
    for j in range(W):
        sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] + (1 if S[i][j] == '1' else 0)

ans = H + W - 2

for ptn in range(1<<H-1): # 2^H - 1 通り
    cand = 0

    sep = [0] # 横方向の分割リスト、ここ天才
    for i in range(H-1):
        if((ptn >> i) & 1): # & を取ることで、上の桁を消せる
            sep.append(i+1)
            cand += 1
    sep.append(H)

    left = 0 # left は直前の分割
    for pos in range(W):
    	cur = [] # cur は今見てるホワイトチョコの個数のリスト

    	# 横方向に分割されている各部分について
    	for i in range(len(sep) - 1):
    		cur.append(sum[sep[i+1]][pos+1] - sum[sep[i+1]][left] - sum[sep[i]][pos+1] + sum[sep[i]][left])

    	if max(cur) > K:
    		if left == pos: # 縦に分割できない場合(一列しかない場合)
    			cand = H * W
    			break
    		else:
    			cand += 1
    			left = pos

    ans = min(ans, cand)

print(ans)


Measured memory_bytes: 43484
# coding: utf-8
# Your code here!
import heapq

N,M=map(int,input().split())
A=list(map(int,input().split()))
heapq.heapify(A)

sosa=[]

for i in range(M):
    sosa.append(list(map(int,input().split()))[::-1])

sosa.sort(reverse=True)

for i in range(len(sosa)):
    
    for _ in range(sosa[i][1]):
        a=heapq.heappop(A)
        if sosa[i][0]>a:
            heapq.heappush(A,sosa[i][0])
        else:
            heapq.heappush(A,a)
            print(sum(A))
            exit()
print(sum(A))

Measured memory_bytes: 24524
#include<iostream>
#include<algorithm>
using namespace std;
long long a[5], sum, n, p, b[4] = { 0,0,1,3 };
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; }sort(a, a + n);
	if (n < 4) { p = b[n]; }
	if (n == 4) {
		if (sum < 9) { p = 4; }
		else if (a[0] < 3) { p = 5; }
		else { p = 6; }
	}
	if (n == 5) {
		if (sum < 12) { p = 6; }
		else if (a[1] < 3) { p = 7; }
		else if (a[0] < 3 || a[3] < 4) { p = 8; }
		else if (a[0] < 4) { p = 9; }
		else { p = 10; }
	}
	cout << sum - p << endl;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main()
{
  ll H; cin >> H;
  ll W; cin >> W;
  vector<string> a(H);
  for (int i=0; i<H; i++){
    cin >> a[i];
  }

  vector<vector<mint>> dp(H, vector<mint>(W, 0));
  dp[0][0] = 1;
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      if (a[i][j] == '#') continue;
      if (j > 0) dp[i][j] += dp[i][j-1];
      if (i > 0) dp[i][j] += dp[i-1][j];
    }
  }

  cout << dp[H-1][W-1].x << endl;

  return 0;
}


Measured memory_bytes: 9216
# = int(input())
X, N = map(int, input().split())
p = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]
zero = [0]*101
minimum = 101

if N == 0:
    print(X)
    exit()

for i in range(N):
    zero[p[i]] = 1

for i in range(101):
    if zero[i] == 0:
        if abs(X-i) < minimum:
            minimum = abs(X-i)
            count = i

for i in range(101, 120):
    if abs(X-i) < minimum:
        minimum = abs(X-i)
        count = i

for i in range(10):
    if abs(X+i) < minimum:
        minimum = abs(X+i)
        count = -i

print(count)


Measured memory_bytes: 9220
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <ctime>

#ifndef ONLINE_JUDGE
#include "LocalDebug.h"
#else 
#define dbg(...)
#endif

void go () {
	std::string s; std::cin >> s;
	for (auto x : s) 
		if (x == '?') std::cout << 'D'; 
		else std::cout << x;
}

int main () {
	int T = 1;
	time_t tic = clock();
	while (T--) go();
	time_t toc = clock();
	std::cerr << __FILE__ << " execution time : " << 1000.0 * (toc - tic) / CLOCKS_PER_SEC << "ms\n";
	return 0;
}


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

#define int long long
typedef pair<int, int> P;

signed main(){
  int n, u, v, m;
  cin >> n >> u >> v >> m;

  vector<P> A(1000001, P{-1, -1}), B;
  B = A;  
  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < n; j++ ) {
      int a;
      cin >> a;
      A[a] = P{i, j};      
    }
  }

  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < n; j++ ) {
      int a;
      cin >> a;
      B[a] = P{i, j};      
    }
  }

  vector<int> num(m); 
  for ( int i = 0; i < m; i++ ) {
    cin >> num[i];
  }

  vector<int> cnth1(n, 0), cntw1(n, 0), cnth2(n, 0), cntw2(n, 0);
  int cntl1 = 0, cntr1 = 0, cntl2 = 0, cntr2 = 0;
  int c1 = 0, c2 = 0;  
  for ( int i = 0; i < m; i++ ) {
    int a = num[i];
    P p1 = A[a], p2 = B[a];
    if ( p1.first != -1 ) {
      if ( ++cnth1[p1.first] == n ) c1++;
      if ( ++cntw1[p1.second] == n ) c1++;
      if ( p1.first == p1.second ) {
	if ( ++cntl1 == n ) c1++;
      }
      if ( p1.first + p1.second == n-1 ) {
	if ( ++cntr1 == n ) c1++;
      }
    }
    if ( p2.first != -1 ) {
      if ( ++cnth2[p2.first] == n ) c2++;
      if ( ++cntw2[p2.second] == n ) c2++;
      if ( p2.first == p2.second ) {
	if ( ++cntl2 == n ) c2++;
      }
      if ( p2.first + p2.second == n-1 ) {
	if ( ++cntr2 == n ) c2++;
      }

    }
    if ( n == 1 ) {
      if ( u > 1 && v > 1 ) {
	break;	
      } else if ( u == 1 && v > 1 ) {
	if ( c1 >= u ) {
	  cout << "USAGI" << endl;
	  return 0;
	}
      } else if ( u > 1 && v == 1 ) {
	cout << "NEKO" << endl;
	return 0;
      } else {
	if ( c1 >= u && c2 >= v ) {
	  break;      
	} else if ( c1 >= u ) {
	  cout << "USAGI" << endl;
	  return 0;
	} else if ( c2 >= v ) {
	  cout << "NEKO" << endl;
	  return 0;
	}
      }
    } else {
      if ( c1 >= u && c2 >= v ) {
	break;      
      } else if ( c1 >= u ) {
	cout << "USAGI" << endl;
	return 0;
      } else if ( c2 >= v ) {
	cout << "NEKO" << endl;
	return 0;
      }
    }
  }

  cout << "DRAW" << endl;
  
  return 0;
}



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

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

VI n(5, 0);

bool isStraight(){
    int s = 0;
    REP(i, 5) s+=n[i]-n[0]-i;
    if(s == 0) return true;
    else {
        if(n[0] == 1) n[0]+=13;
        SORT(n);

        s = 0;
        REP(i, 5) s+=n[i]-n[0]-i;
        if(s == 0) return true;
        else false;
    }
    return false;
}

int main(){
    while(scanf("%d,%d,%d,%d,%d", &n[0], &n[1], &n[2], &n[3], &n[4])!=EOF){
        int m = 0;
        SORT(n);
        REP(i, 4) FOR(j, i+1, 5) if(n[i]==n[j]) m++;
        switch(m){
            case 1:
                cout << "one pair" << endl;
                break;
            case 2:
                cout << "two pair" << endl;
                break;
            case 3:
                cout << "three card" << endl;
                break;
            case 4:
                cout << "full house" << endl;
                break;
            case 6:
                cout << "four card" << endl;
                break;
            default:
                if(isStraight()) cout << "straight" << endl;
                else cout << "null" << endl;
        }
    }
}

Measured memory_bytes: 1224
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <numeric>
#include <queue>
#include <vector>

using namespace std;

bool compare_F(pair<int, int> a, pair<int, int> b) {
  if (a.first != b.first) {
    return a.first < b.first;
  } else {
    return a.second > b.second;
  }
}

bool compare_S(pair<int, int> a, pair<int, int> b) {
  if (a.second != b.second) {
    return a.second > b.second;
  } else {
    return a.first > b.first;
  }
}

template <typename T>
void ArrayInput(vector<T> &A) {
  for (auto itr = A.begin(); itr != A.end(); ++itr) {
    cin >> *itr;
  }
}
template <typename T>
void ArrayPut(vector<T> &A) {
  for (auto itr = A.begin(); itr != A.end(); ++itr) {
    cout << *itr << " ";
  }
  cout << endl;
}

using Graph = vector<vector<uint32_t>>;
vector<bool> seen;
vector<uint32_t> dis, A_dis, T_dis;

void dfs(Graph &G, uint32_t v) {
  seen[v] = true;

  for (auto itr = G[v].begin(); itr != G[v].end(); ++itr) {
    if (seen[*itr]) continue;
    dis[*itr] = dis[v] + 1;
    dfs(G, *itr);
  }
}
bool JudgePrime(uint64_t N);
int main() {
  uint64_t X;
  cin >> X;
  if (JudgePrime(X)) {
    cout << X << endl;
  } else {
    X |= 1;
    while (!JudgePrime(X)) {
      X += 2;
    }
    cout << X << endl;
  }

  return 0;
}

bool JudgePrime(uint64_t N) {
  if (N == 2) return true;
  if (N & 0x01) {
    for (uint64_t i = 3; i * i <= N; i += 2) {
      if (N % i == 0) return false;
    }
    return true;
  } else {
    return false;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Sheryang main
typedef long long ll;
#pragma GCC optimize(3)
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
int read()
{
    int x=0,f=1;	char c=getchar();
    while(c<'0'||c>'9')	{if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9')	{x=x*10+c-'0';c=getchar();}
    return x*f;
}
struct ios
{
    inline char gc()
    {
        static const int IN_LEN=1<<18|1;
        static char buf[IN_LEN],*s,*t;
        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
    }
    template <typename _Tp> inline ios & operator >> (_Tp&x)
    {
        static char ch,sgn; ch = gc(), sgn = 0;
        for(;!isdigit(ch);ch=gc())
        {   
            if(ch==-1)return *this;sgn|=ch=='-';
        }
        for(x=0;isdigit(ch);ch=gc())x=(((x<<2)+x)<<1)+(ch^'0');
        sgn&&(x=-x); return *this;
    }
}io;
const int maxn = 1e5 + 7;
const int mod = 1e9 + 7;
/** keep hungry and keep calm! **/

/**
模拟#前缀和 
定义两个数组x y记录方格中各个数字的下标 
定义ans记录l->r之间的消耗 
**/
int a[305][305];
struct node
{
    int x;
    int y;
}p[90005];

int ans[90005];
int main()
{
    int h,w,d,len;	cin >> h >> w >> d;
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
		{
          scanf("%d",&a[i][j]);
          int n = a[i][j];
           p[n].x = i;
           p[n].y = j;
        }
    int q;	cin >> q;
    len = h*w;
    for(int i=1;i<=d;i++)
    {
        int l = i,r = len,sum = 0;
        ans[i] = 0;
        while(l <= r-d)
        {
            sum = sum+fabs(p[l].x-p[l+d].x)+fabs(p[l].y-p[l+d].y);
            l += d;
            ans[l] = sum;
        }
    }
    while(q--)
    {
        int l,r;	cin >> l >> r;
        printf("%d\n",ans[r]-ans[l]);
    }
}


Measured memory_bytes: 2560
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = 1e16;
const long long int Mod = 1000000007;
using ll = long long int; //long long int は64bit
using vi = vector<int>; using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(long long int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
typedef pair<ll,ll> Pair;
bool p_compare(const Pair& firstP, const Pair& secondP){ 
    return firstP.second < secondP.second; 
}//sort(all(v),p_compare)で昇順ソート
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////
//Snipet -> Caps Lock

ll n;
Vi v;
ll ma[6]={0};

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n;ll xxx;
    fill(ma,0);
    ll minm=INF;
    rep(i,5){
        cin>>xxx;
        chmin(minm,xxx);
    }
    if(n%minm==0)cout<<n/minm+4<<endl;
    if(n%minm!=0)cout<<(n/minm)+5<<endl;
    return 0;
}


Measured memory_bytes: 256
// Author -- Frame

#include<bits/stdc++.h>

#define lowbit(x) ((x)&(-(x)))
#define Finline __inline__ __attribute__ ((always_inline))
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
#define SZ(x) ((int)x.size())
#define mkpr std::make_pair
#define pb push_back

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef std::pair<int,int> pi;
typedef std::pair<ll,ll> pl;
using std::min;
using std::max;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x3f3f3f3f3f3f3f3f;

Finline uint rnd(){static uint seed=416;return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;}
template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>=0?a:-a;}
template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(b<a)&&(a=b);}
template <typename _Tp>Finline void read(_Tp &x)
{
	char ch(getchar());bool f(false);while(!isdigit(ch)) f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();while(isdigit(ch)) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
	f&&(x=-x);
}
template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args){read(t);read(args...);}
template <typename _Tp,typename... Args>Finline _Tp min(const _Tp &a,const _Tp &b,const Args &...args){return a<b?min(a,args...):min(b,args...);}
template <typename _Tp,typename... Args>Finline _Tp max(const _Tp &a,const _Tp &b,const Args &...args){return a<b?max(b,args...):max(a,args...);}
Finline int read_str(char *s)
{
	char ch(getchar());while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
	char *tar=s;*tar=ch,ch=getchar();while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
	return tar-s+1;
}

const int N=200005;
int fa[N],cnt[N];
int find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);}
int main()
{
	int n,m;read(n,m);
	int x,y;
	for(int i=1;i<=n;++i) fa[i]=i;
	for(int i=1;i<=m;++i)
	{
		read(x,y);
		fa[find(x)]=find(y);
	}
	for(int i=1;i<=n;++i) ++cnt[find(i)];
	int ans=0;
	for(int i=1;i<=n;++i) chmax(ans,cnt[i]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 10672
/*
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
*/
#include <bits/stdc++.h>
#define pb push_back
#define FOR(x,st,n) for(int x = (st); x < (n); ++ x)

using namespace std;


typedef long long unsigned ll;
typedef pair<int,int> P;
typedef vector<P> vp;
typedef vector<int> vi;
typedef vector<vi> vvi;

//const int N = 1e3+1;
//ll n,m,k,q;

int main(){


    int a,b;
    int n;
    cin>>n;

    int ct=1;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a==ct) ct++;
    }
    
    ct--;
    if(ct==0) cout<<-1<<endl;
    else  cout<<n-ct<<endl;
    
    return 0;
}


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

//@@@@@
//@ snippet FenwickTree
//@ alias   BIT
//@ options head
template <class T> struct FenwickTree {
  vector<T> dat;
  explicit FenwickTree(int size): dat(size + 5, 0) {}
  inline void add(int i, const T&v) { while(i < dat.size()){ dat[i]+=v; i += i&-i;} }
  inline T sum(int i)         const { return (i<=0)? 0 : dat[i] + sum(i - (i&-i)); }
  inline T sum(int s, int t)  const { return sum(t) - sum(s-1); }
};
//@@@@@



struct FastIO {
  FastIO() { cin.tie(nullptr); ios::sync_with_stdio(false); }
} fastIO_ydk ;


void AOJ_DSL_2_B()
{
  int N, Q;
  cin >> N >> Q;

  FenwickTree<int> ft(N);
  while(Q--) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com == 0) {
      ft.add(x, y);
    } else {
      cout << (ft.sum(x, y)) << '\n';
    }
  }
}

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



Measured memory_bytes: 3268
import java.util.Scanner;

// https://atcoder.jp/contests/abc159/submissions/11120535
public class Main {
  static final long MOD = 998_244_353;

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int S = sc.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }
    long ans = 0;
    long[] dp = new long[S + 1]; // dp[S]:= f(L,R) when A_i is used or not.
    for (int i = 0; i < N; i++) {
      // Case when A[i] is not used. This is a seed scaffold.
      dp[0] += 1;

      for (int j = S; j >= A[i]; j--) {
        dp[j] += dp[j - A[i]];
        dp[j] %= MOD;
      }
      ans += dp[S];
      ans %= MOD;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 28136
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long ll;


int main() {
	int n; cin >> n;
	vector<ll> a(n), b(n);
	ll sa = 0, sb = 0;
	for (int i = 0; i < n; i++) cin >> a[i], sa += a[i];
	for (int i = 0; i < n; i++) cin >> b[i], sb += b[i];
	if (sa < sb) {
		cout << -1 << endl;
		return 0;
	}
	ll sl = 0;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] >= b[i]) continue;
		sl += b[i] - a[i];
		cnt++;
	}
	vector<ll> d;
	for (int i = 0; i < n; i++) {
		if (a[i] <= b[i]) continue;
		d.push_back(a[i] - b[i]);
	}
	sort(d.rbegin(), d.rend());
	for (int i = 0; i < (int)d.size(); i++) {
		if (sl <= 0) break;
		sl -= d[i];
		cnt++;
	}
	if (sl > 0) {
		cout << -1 << endl;
		return 0;
	}
	cout << cnt << endl;
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (true) {
        int n;
        cin >> n;
        if (n == 0) break;
        int h[n + 1] = {};
        rep(i, n + 1) cin >> h[i];
        rep(i, n + 1) {
            vector<int> tmp;
            rep(j, n + 1) {
                if (i == j) continue;
                tmp.push_back(h[j]);
            }
            int diff = tmp[1] - tmp[0];
            bool ok = true;
            rep(j, n - 1) {
                if (diff != tmp[j + 1] - tmp[j]) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                cout << h[i] << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n;
  cin>>n;
  vector<string> s(n);
  REP(i, n) cin>>s[i];
  map<string, int> cnt;
  REP(i, n) cnt[s[i]]++;
  cout << "AC x " << cnt["AC"] << endl;
  cout << "WA x " << cnt["WA"] << endl;
  cout << "TLE x " << cnt["TLE"] << endl;
  cout << "RE x " << cnt["RE"] << endl;
  return 0;
}


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

void solve(long long N, long long D, std::vector<long long> X, std::vector<long long> Y){
    ll ans =0;
    for(int i=0;i<N;i++){
        if(X[i] * X[i] + Y[i]*Y[i] <=D*D){
            ans ++;
        }
    }
    cout << ans << endl;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    std::vector<long long> X(N);
    std::vector<long long> Y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&Y[i]);
    }
    solve(N, D, std::move(X), std::move(Y));
    return 0;
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a>b)
    {
        for(int i=1; i<=a; i++)
            printf("%d",b);
    }
    else if(a<b)
    {
        for(int i=1; i<=b; i++)
            printf("%d",a);
    }
    else
        for(int i=1; i<=a; i++)
            printf("%d",a);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
int n,m,cmp[100005],k;
vector<int>g[100005];
bool vis[100005];
void dfs(int v){
	vis[v]=true;
	for(int i=0;i<g[v].size();i++){
		int u=g[v][i];
		if(vis[u])continue;
		dfs(u);
	}
	cmp[v]=k++;
}
int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n+m-1;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		g[--b].PB(--a);
	}
	for(int i=0;i<n;i++)if(!vis[i])dfs(i);
	for(int i=0;i<n;i++){
		if(g[i].size()==0)cout<<0<<endl;
		else{
			int p=0;
			for(int j=0;j<g[i].size();j++){
				int u=g[i][j];
				if(cmp[u]>cmp[g[i][p]])p=j;
			}
			cout<<g[i][p]+1<<endl;
		}	
	}
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;

int binarysearch(int A[], int n, int key){
        int l = 0;
        int r = n;
        while(l < r){
            int mid=(l+r)/2;
            if(key == A[mid])
                return 1;
            else if(key > A[mid]){
                l = mid+1;
            }
            else if(key < A[mid]){
                r = mid;
            }
        }
        return 0;
    }

int main() 
{
    int sum=0;
    int n;
    cin >> n;
    int S[n];
    rep(i,n){
        cin >> S[i];
    }

    int q,key;
    cin >> q;
    rep(i,q){
        cin >> key;
        if(binarysearch(S,n,key))sum++;
    }

    cout << sum << endl;
}




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

int main(){
	int awal;
	int temp;
	int tomp;
	int hx;
	int hp;
	cin>>awal;
	temp=awal/500;
	hp=1000*temp;
	awal=awal%500;
	tomp=awal/5;
	hx=5*tomp;
	hp=hp+hx;
	cout<<hp<<endl;
	
	
	
	
	
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define BUFSIZE 10000
int K;
int rem1,rem2=0;

int swap(int x,int y){
	if(x>y){
		rem1=x;
		x=y;
		y=rem1;
	}
}

int gcd(int a,int b){
	swap(a,b);
	/*
	printf("%d %d",a,b);
	*/
	if(b%a==0){
		return a;	 
	}
	gcd(b%a,a);
}
int main(void){
    scanf("%d",&K);
	
	for(int i=1;i<=K;i++){
		for(int j=1;j<=K;j++){
			for(int n=1;n<=K;n++){
				
				rem2=rem2+gcd(gcd(i,j),n);
				
			}
		}
	}
	
	printf("%d",rem2);


}

Measured memory_bytes: 1680
#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>

#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 all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
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 = 1000000009;

// + - * / ^
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)
{
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	rep(i, b) {
		rep(j, w) {
			if(j < a) cout << 0;
			else cout << 1;
		}
		cout << endl;
	}
	rep(i, h - b) {
		rep(j, w) {
			if(j < a) cout << 1;
			else cout << 0;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
main :: IO ()
main = interact $ pickOdds'

pickOdds, pickOdds'
  :: [a] -> [a]
pickOdds []       = []
pickOdds [a]      = [a]
pickOdds (a:b:bs) = a : pickOdds bs 

pickOdds' = map snd . filter (odd . fst) . zip [1..]

pickOdds2 = map snd . filter fst . zip (cycle [True, False])

Measured memory_bytes: 1148
#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
  
  int sum = 0;
  char num[200001];
  cin>>num;
  for(int i = 0;i<strlen(num);i++){
    sum = sum+(num[i]-48);
  }
  if(sum%9 == 0){
    cout<<"Yes"<<"\n";
  }
  else{
    cout<<"No"<<"\n";
  }
  return 0;
}

Measured memory_bytes: 3204
def main():
    N = int(input())
    X = list(map(int, input().split()))
    sx = sorted(X)
    left = sx[N // 2 - 1]
    right = sx[N // 2]
    for x in X:
        if right > x:
            print(right)
        else:
            print(left)


main()


Measured memory_bytes: 25620
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"

using namespace std;
typedef long long ll;

int n;
int h[100100];
int dp[100100];

//iまで進んだ時から最小値
int dist(int i)
{
  int ans;
  if (dp[i] >= 0)
  {
    return dp[i];
  }
  else
  if (i == n - 1)
  {
    ans = 0;
  }
  else
  if (i == n - 2)
  {
    ans = abs(h[i] - h[i + 1]);
  }
  else
  {
    int a1 = dist(i + 1) + abs(h[i] - h[i + 1]);
    int a2 = dist(i + 2) + abs(h[i] - h[i + 2]);
    ans = min(a1, a2);
  }
  return dp[i] = ans;
}

int main()
{
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> h[i];
  }
  for (int i = 0; i < n; i++)
  {
    dp[i] = -1;
  }
  cout << dist(0) << "\n";
}

Measured memory_bytes: 4096
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>
#include<stack>
#include <utility>

const long long MOD = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

void dfs(string s, vector<bool> &table, llong N, vector<llong> &ans){
    llong temp=0;
    if(s.size()<=5){
        for(int i=0; i<s.size(); i++){
            temp = temp + (s[i]-'0')*pow(10, s.size()-i-1);
        }
        ans.push_back(temp);
    }else{
        return;
    }
    for(int i=0; i<10; i++){
        if(!table[i]){
            continue;
        }
        dfs(s+(char)(i+'0'), table, N, ans);
    }
}

int main(){
    llong N,K;
    cin >> N >> K;
    vector<llong> D(K,0);
    vector<bool> table(10, true);
    vector<llong> ans;
    string s="";
    for(int i=0; i<K; i++){
        cin >> D[i];
        table[D[i]] = false;
    }
    for(int i=1; i<10; i++){
        if(!table[i]){
            continue;
        }
        dfs(s+(char)(i+'0'), table, N, ans);
    }
    sort(ans.begin(), ans.end());
    for(int i=0; i<ans.size(); i++){
        if(ans[i]>=N){
            cout << ans[i] << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 4216
#include <stdio.h>

int main(){
    int h, w;
    int i, j;
    while(1){
        scanf("%d %d ", &h, &w);
        if(h==0&&w==0)break;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                if((i%2==0&&j%2==0)||(i%2==1&&j%2==1)){
                    printf("#");
                }else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2120
(let ((s (read-line)))
  (princ (if (and (char= (char s 0) #\A)
                  (= (count #\C (subseq s 2 (1- (length s)))) 1)
                  (string= (remove-if #'lower-case-p (remove #\C (subseq s 1) :count 1)) ""))
             "AC"
             "WA")))

Measured memory_bytes: 4068
#砂時計の砂X(秒)をセット #測った時間tをセット
X , t = map(int,input().split())
#残り時間を表示 (X - t)
#X > tのとき
if X > t:
    time = X - t
#X <= tのとき
else:
    time = 0
print(time)


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

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	if(a==b){
		cout << c << "\n";
	}else if(b==c){
		cout << a << "\n";
	}else if(a==c){
		cout << b << "\n";
	}

	return 0;
}


Measured memory_bytes: 256
$n, m = gets.split.map(&:to_i)

$bulbs = []
$res = 0
# $set = []

def bulb_on?(bulb, condition, switches)
  n = 0
  bulb.each { |i| n += switches[i] }
  return (n % 2) == condition
end

def solve(switches, idx, conditions)
  if idx == $n
    return if $n == 0
    all_on = true
    $bulbs.each_with_index do |b, bi|
      unless bulb_on?(b, conditions[bi], switches)
        all_on = false
        break
      end
    end
    $res += 1 if all_on
  else 
    [0, 1].each do |i|
      switches[idx] = i
      solve(switches, idx + 1, conditions)
    end
  end
end


m.times do |i|
  inp = gets.split.map(&:to_i)
  inp.shift
  $bulbs.push(inp.map { |i| i-1 })
end

switches = Array.new(10, 0)
conditions = gets.split.map(&:to_i)
solve(switches, 0, conditions)

puts $res


Measured memory_bytes: 1788
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;


int main(void)
{
	//変数の宣言
	char s[100010];
	int black=0;
	int white=0;


	//よく使う変数
	int i,j,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	int dummy;



	//データの読み込み


	scanf("%s",&s);
//	scanf_s("%s",&s,100010);


/*	for(i=0;i<n;i++){
//		scanf(%d",&h[i]);
		scanf_s("%d",&h[i]);
	}*/

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	len=strlen(s);
	for(i=0;i<len;i++){
		if(i%2==0){
			if(s[i]=='0'){
				black++;
			}else{
				white++;
			}
		}else{
			if(s[i]=='0'){
				white++;
			}else{
				black++;
			}
		}
	}


	//	printf("計算部分終了\n");

	//出力
	printf("%d",min(white,black));

	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 384
s = input()
x = int(s[:2])
y = int(s[2:])

def in_month(n):
    return 1 <= n <= 12

if in_month(x) and in_month(y):
    print('AMBIGUOUS')
elif in_month(x):
    print('MMYY')
elif in_month(y):
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-9;
const ll MOD=1e9+7;
int main(){
    int n,m;cin>>n>>m;
    vector<ll> a(n),b(m);
    for(int i=0;i<n;i++)cin>>a[i];
    ll sum=0;
    for(int i=0;i<m;i++){
        cin>>b[i];
        sum+=b[i];
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=sum*a[i];
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 4416
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();

    int x = sc.nextInt();

    int d = 0;

    int count = 0;
    if (d <= x) {
      count++;
    }
    for (int i = 1; i <= n; i++) {
      int l = sc.nextInt();
      d = d + l;
      if (d <= x) {
        count++;
      }
    }
    os.println(count);
  }
}

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

int n, q, vv, w;
set<int> get(int v)
{
    set<int> a;
    while (v and a.find(v) == a.end()) {
        a.insert(v);
        v = (v + n - 2) / n;
    }
    return a;
}
void solve()
{
    if (n == 1) {
        cout << min(vv, w) << endl;
        return;
    }
    auto s = get(vv);
    auto t = get(w);
    int ans = 1;
    for (auto ss : s) {
        if (t.find(ss) != t.end())
            ans = ss;
    }
    cout << ans << endl;
}
int main()
{
    n = 3;
    get(12);
    cin >> n >> q;
    rep(i, q) cin >> vv >> w, solve();
}


Measured memory_bytes: 1280
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<iostream>
using namespace std;
const int N=1500;
#define EPS 1e-6
int d[N][N];
int G[N][N];
int n,m;
int main()
{
    int ans=0;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			scanf("%d",&G[i][j]);
            d[i][j]=!G[i][j];
		}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
            if(G[i][j]==0){
                d[i][j]=min(min(d[i-1][j],d[i][j-1]),d[i-1][j-1])+1;
                ans=max(ans,d[i][j]);
            }
		}
	printf("%d\n",ans*ans);
}




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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++) cin >> h[i];
  sort(h.begin(), h.end());

  int ans = 1e9;
  for (int i = 0; i + k - 1 < n; i++) {
    ans = min(ans, h[i + k - 1] - h[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640