akhauriyash/Code-Regression huggingface dataset:
//#define _CRT_SECURE_NO_WARNINGS
//#include <bits/stdc++.h>
#include "bits/stdc++.h"

#define rep(i,n) for(long long (i)=0;(i)<(long long)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define int long long

#define PI (3.14159265358979323)
#define MOD (1000000007LL)
#define INF (1LL<<60LL)
#define MAX_N (10000001)
#define MAX (1000000000000000000LL)
using namespace std;

signed main() {
	int n;
	string s;
	cin >> n >> s;
	int l = 0,r=n-1;
	int ans = 0;
	rep(i,n){
		while (l <= n - 1) {
			if (s[l] == 'W') break;
			l++;
		}
		while (0 <= r) {
			if (s[r] == 'R')break;
			r--;
		}
		if (l < r) ans++;
		else {
			break;
		}
		l++; r--;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') cout << "vowel" << endl;
  else cout << "consonant" << endl;
}

Measured memory_bytes: 3604
#include <stdio.h>

int main(void)
{
    int H, W;

    while(1)
    {
        scanf("%d %d", &H, &W);

        if(H == 0 && W == 0)
        {
            return 0;
        }

        int i, j;
        for(i = 0; i < H; ++i)
        {
            for(j = 0; j < W; ++j)
            {
                if(i == 0 || i + 1 == H || j == 0 || j + 1 == W)
                {
                    printf("#");
                }

                else
                {
                    printf(".");
                }
            }

            printf("\n");
        }

        printf("\n");
    }
}

Measured memory_bytes: 572
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	//n頂点m枝に対して隣接リストをつくる。
	int n, m;
	cin >> n >> m;
	vector<int> p(n+1);
	REP1(i, n) cin >> p[i];
	int u, v;
	//vector< vector <int> > ls(n); //0-origin
	vector< vector <int> > ls(n+1); //1-origin
	REP(i, m){ 
		cin >> u >> v; 
		ls[u].push_back(v); 
		ls[v].push_back(u);
	}
	//
	bool ch[n+1] ={};
	map<int, int> mp;
	queue<int> q;
	int now = 0;
	REP1(i, n){
		if(!ch[i]){
			now ++;
			ch[i] = true;
			q.push(i);
			mp[i] = now;
			while(!q.empty()){
				int t = q.front();
				q.pop();
				REP(j, ls[t].size()){
					if(!ch[ls[t][j]]){
						ch[ls[t][j]] = true;
						q.push(ls[t][j]);
						mp[ls[t][j]] = now;
					}
				}
			}
		}
	}
	REP1(i,n){
		//cout << mp[i] << " " << mp[p[i]] << endl;
		if(mp[p[i]] == mp[i]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 10880
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<String>();
    let tt = vec!["Sunny", "Cloudy", "Rainy"];
    for i in 0..3 {
        if s == tt[i] {
            println!("{}", tt[(i + 1) % 3]);
        }
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

int main() {
    int n, k; cin >> n >> k;
    map<int, long long> m;
    vector<int> v(n+1, 0);
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        v[i+1] = (v[i] + a - 1) % k;
    }
    for (int i = 0; i <= n; i++) {
        if (i - k >= 0) m[v[i-k]]--;
        ans += m[v[i]];
        m[v[i]]++; 
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int a,p;
	cin >>a >>p;
	p += a*3;
	
	cout << p/2 <<"\n";
	return 0;
}


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

int main() {
 
  int INF = 1000000000;

  int N, W;
  cin >> N >> W;

  vector<int> w(N + 1);
  vector<int> v(N + 1);
  int V = 0;
  for (int i = 0; i < N; i++) {
    cin >> w[i] >> v[i];
    V = max(V, v[i]);
  }

  vector<vector<int>> dp(N + 1, vector<int>(N * V + 1));

  for (int i = 0; i < N; i++) {
    fill(dp[i].begin(), dp[i].end(), INF);
  }

  dp[0][0] = 0;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= N * V; j++) {
      if (j < v[i]) {
        dp[i + 1][j] = dp[i][j];
      } else {
        dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
      }
    }
  }

  int answer = 0;

  for (int i = 0; i <= N * V; i++) {
    if (dp[N][i] <= W) {
      answer = max(answer, i);
    }
  }

  cout << answer << endl;

}

Measured memory_bytes: 40192
#include<bits/stdc++.h>
using namespace std;
main()
{
    int i,j;
    char n[4];
    cin>>n;
    i = (n[0]-48)*10 + n[1]-48;
    j = (n[2]-48)*10 + n[3]-48;
    if((i==0 && j==0) || (i>12 && j>12) || (i>12 && j==0) || (i==0 && j>12))
    {
        cout<<"NA"<<endl;
    }
    else
    {
    if(i<=12 && j<=12 && i!=0 && j!=0)
    {
        cout<<"AMBIGUOUS"<<endl;
    }
    else if((i<=12 && j>12) || (i<=12 && j==0))
    {
        cout<<"MMYY"<<endl;
    }
    else if((i>12 && j<=12) || (i==0 && j<=12))
    {
        cout<<"YYMM"<<endl;
    }
    }
    
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int a;
  int s=0;
  for(int i=1;;i++){
    s+=i;
    if(s>=n){
      a=i;
      break;
    }
  }
  for(int i=1;i<=a;i++){
    if(i!=s-n) cout<<i<<endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N = getint();
	int A[200001];
	rep(i, N) A[i] = getint();
	pakuri_sort(N, A);

	bool OK = 1;
	rep(i, N - 1) OK &= (A[i] != A[i + 1]);

	printf(OK ? "YES" : "NO");

	Would you please return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
using namespace std;
long long n,a,b,aa,bb,cc;
int main() {
	scanf("%lld",&n);
	scanf("%lld",&a);
	for (int i=1;i<n;i++){
		scanf("%lld",&b);
		aa=a; bb=b; 
		while (bb) {
			cc=aa%bb;
			aa=bb;
			bb=cc;
		}
		a=a/aa*b;
	}
	printf("%lld",a);
	return 0;
}

Measured memory_bytes: 256
n = int(input())

if n < 10:
    ans = n
elif n < 100:
    ans = 9
elif n < 1000:
    ans = n - 100 + 10
elif n < 10000:
    ans = 909
elif n < 100000:
    ans = n - 10000 + 910
elif n == 100000:
    ans = 90909

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int N,M,X;
  cin >> N >> M >> X;
  vector<int> A(M);
  for (int i=0; i<M; i++) cin >> A[i];
  
  int left = 0;
  int right = 0;
  for (int i=0; i<M; i++) {
    if (A[i] < X) left++;
    else right++;
  }
  int ans = min(left,right);
  cout << ans << endl;
}

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

/*vector<int> p(n);
cin >> p[i]*/

int main(){

    int n, m;
    int count = 0;
    cin >> n >> m;

    cout << (n*(n-1)/2) + (m*(m-1)/2) << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int n, h[100010], l[100010], r[100010], st[100010];
signed main(void)
{
  cin >> n;
  REP(i, n) cin >> h[i];
  int t = 0;
  REP(i, n) {
    while(t>0 && h[st[t-1]] >= h[i]) t--;
    l[i] = t == 0 ? 0 : (st[t-1]+1);
    st[t++] = i;
  }
  t = 0;
  for(int i=n-1; i>=0; --i) {
    while(t > 0 && h[st[t-1]] >= h[i]) t--;
    r[i] = t == 0 ? n : st[t-1];
    st[t++] = i;
  }
  ll ret = 0;
  REP(i, n) ret = max(ret, (ll)h[i]*(r[i]-l[i]));
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 4600
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        double sum = 0;
        double co = Math.pow(0.5, m);
        for (int i = 1; i <= 1000000; i++) {
            sum += (1900 * m + 100 * (n - m)) * i * Math.pow(1 - co, i - 1) * co;
        }
        System.out.println((int)Math.round(sum));
    }
}

Measured memory_bytes: 23252
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key){
    return u;
  }
  else if (k < u->key){
    return treeSearch(u->left,k);
  }
  else return treeSearch(u->right,k);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key)  x = x->left;
    else x = x->right;
  }
    z->parent = y;

    if(y == NIL) root = z;
    else if(z->key < y->key) y->left = z;
    else y->right = z;
}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}

void preorder(Node u){
  if(u != NIL){
    printf(" %d",u->key);
    if(u->left != NIL)preorder(u->left);
    if(u->right != NIL)preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } 
else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
   }
  }

  return 0;
}

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

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

const int N = 1e5 + 10;

int n, a[N];

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

    cin >> n; forn(i,n) cin >> a[i], a[i]--;
    int res =0;
    forn(i,n) {
        if (a[a[i]] == i) res++;
    }
    cout << res/2 << endl;



    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;

const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
bool prime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main(){
  int n=100005;
  vector<int>total(n,0);
  rep(i,n){
    if(i==0)continue;
    if(prime(i)&&prime((i+1)/2)){
      total[i]=total[i-1]+1;
    }
    else total[i]=total[i-1];
  }
  int q;cin>>q;
  rep(i,q){
    int l,r;
    cin>>l>>r;
    cout<<total[r]-total[l-1]<<endl;
  }
}

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

int n;
string a;
int c[5];

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		if(a=="AC") c[1]++;
		else if(a=="WA") c[2]++;
		else if(a=="TLE") c[3]++;
		else c[4]++;
	}
	
	
	cout<<"AC"<<' '<<"x"<<' '<<c[1]<<endl;
	cout<<"WA"<<' '<<"x"<<' '<<c[2]<<endl;
	cout<<"TLE"<<' '<<"x"<<' '<<c[3]<<endl;
	cout<<"RE"<<' '<<"x"<<' '<<c[4]<<endl;

	
	return 0;
}

Measured memory_bytes: 3636
#!/usr/bin/env python
# coding: utf-8
#from sys import stdin
import time
#import itertools,sys
#import time,copy
#import math
#from math import factorial
#from itertools import product, permutations
#NUM="0123456789"
#A2Z="abcdefghijklmnopqrstuvwxyz"
#import math,sys,time
#import numpy as np

#from q000 import xxxx

# coding: utf-8

#Q042 Coded triangle numbers
import math,sys,time

def read_data():
#  f=open('in.txt')
#  n=int(f.readline())
  n=input()
  x=[]
#  for line in f:
#    x.append(map(int,line.split()))
  for i in range(10):
    x.append(map(int,raw_input().split()))
  return n, x

def is_area3(x,y):
  if x>7 or y>5: return False
  for dx in [0,1,2,1,0]:
    A = P[y][x-dx:x+dx+1]
    if A.count(0)>0: return False
    y += 1
  return True
      
def is_area2(x,y):
  if x>7 or y>7: return False
  for dy in [0,1,2]:
    A = P[y+dy][x:x+3]
    if A.count(0)>0: return False
  return True

def is_area1(x,y):
  if x>8 or y>7: return False
  for dx in [0, 1, 0]:
    A = P[y][x-dx:x+dx+1]
    if A.count(0)>0: return False
    y += 1
  return True

def ink(x,y,s,m):
  global P
  for dy,dx in [[0,0],[1,0],[-1,0],[0,1],[0,-1]]:
    P[y+dy][x+dx]+=m
  if s==1: return
  for dy,dx in [[1,1],[1,-1],[-1,1],[-1,-1]]:
    P[y+dy][x+dx]+=m
  if s==2: return
  for dy,dx in [[2,0],[-2,0],[0,2],[0,-2]]:
    P[y+dy][x+dx]+=m
  return

drops, P = read_data()
M=[]
i=-1
step =3
while i<99:
  i+=1
  y = i / 10
  x = i % 10
  if P[y][x]==0: continue
#  print
#  print "i=",i
#  print "Pi=",P
#  print "Mi=",M

  if step==3:
#    print "step 3"
    while is_area3(x,y):
      M.append([x,y,3])
      ink(x,y+2,3,-1)
    if P[y][x]==0:
      step = 3
#      print "Po=",P
#      print "Mo=",M
      continue
    else: step = 2

  if step==2:
#    print "step 2"
    while is_area2(x,y):
      M.append([x,y,2])
      ink(x+1,y+1,2,-1)
    if P[y][x]==0:
      step = 3
#      print "Po=",P
#      print "Mo=",M
      continue
    else: step = 1

  if step==1:
#    print "step 1"
    while is_area1(x,y):
      M.append([x,y,1])
      ink(x,y+1,1,-1)
    if P[y][x]==0:
      step = 3
#      print "Po=",P
#      print "Mo=",M
      continue
    else: step = 0

  dx=0
  dy=1
  if step==0 and len(M)>0:
    x,y,tmp = M.pop()
    if tmp==3: dy=2
    elif tmp==2: dx=1
    ink(x+dx,y+dy,tmp,1)
    i = y*10+x-1
    step = tmp-1
  else:
#    print "unsolvable"
    break
#  print "changed io=",i+1
#  print "Mo=",M
#  print "Po=",P
#  print
if drops <=12 and len(M)==drops:
  for x,y,s in M:
    dx=0
    dy=1
    if s==3: dy=2
    elif s==2: dx=1
    print x+dx,y+dy,s

#start_time = time.clock() 

#print time.clock() - start_time, "seconds"

Measured memory_bytes: 4672
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      String S = sc.next();
      
      // 複数形作成
      int len = S.length();
      String result = "";
      if(S.charAt(len-1) == 's'){
        result = S + "es";
      }else{
        result = S + "s";
      }
      
      // 出力
      System.out.println(result);
    }

}

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

int main()
{
    int n,m;
    cin>>n>>m;
    std::vector<int> w(n);
    std::vector<int> v(n);
    for (int i = 0; i < n; ++i)
    {
    	cin>>w[i]>>v[i];
    }
    lli dp[n+1][m+1];
    for(int i=0;i<=n;i++)
    	dp[i][0]=0;
    for(int i=0;i<=m;i++)
    	dp[0][i]=0;

    for(int i=1;i<=n;i++){
    	for(int j=1;j<=m;j++){
    		if(j>=w[i-1]){
    			dp[i][j]=max(v[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);

    		}
    		else{
    			dp[i][j]=dp[i-1][j];
    		}
    	}
    }
    
    cout<<dp[n][m];
    return 0;
}
 

Measured memory_bytes: 82324
"""
座標圧縮
2D累積和
全探索
勝利
"""
n, k = map(int,input().split())
xs = set()
ys = set()
ps = []
# 座圧
for _ in range(n):
    x,y = map(int,input().split())
    ps.append((x,y))
    xs.add(x)
    ys.add(y)
xdic = {x:i for i,x in enumerate(sorted(list(xs)))}
ydic = {y:i for i,y in enumerate(sorted(list(ys)))}
rxdic = {i:x for i,x in enumerate(sorted(list(xs)))}
rydic = {i:y for i,y in enumerate(sorted(list(ys)))}

# 2D累積和
h = len(xdic)
w = len(ydic)
A = [[0 for i in range(w+1)] for j in range(h+1)]
Acum = [[0 for i in range(w+1)] for j in range(h+1)]

for x,y in ps:
    h = xdic[x]
    w = ydic[y]
    A[h][w] += 1

for i in range(len(xdic)):
    for j in range(len(ydic)):
        Acum[i+1][j+1] = Acum[i][j+1] + Acum[i+1][j] - Acum[i][j] + A[i][j]
      
# 探索
ans = 1 << 100
h = len(xdic)
w = len(ydic)
for i1 in range(h+1):
    for i2 in range(i1+1,h+1):
        for j1 in range(w+1):
            for j2 in range(j1+1,w+1):
                num = Acum[i2][j2]-Acum[i1][j2]-Acum[i2][j1]+Acum[i1][j1]
                # print((i1,i2),(j1,j2),num)
                if num == k:
                    x1 = rxdic[i1]
                    x2 = rxdic[i2-1]
                    y1 = rydic[j1]
                    y2 = rydic[j2-1]
                    S = (x2-x1)*(y2-y1)
                    ans = min(ans, S)
print(ans)

Measured memory_bytes: 9292
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for (size_t i = 0; i < (size_t) (n); i++)

using namespace std;
using ll = long long;

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

  auto as = vector<ll>(n);
  for (int i = 0; i < n; i++) cin >> as[i];

  auto addc = map<ll, vector<int>>();
  auto subc = map<ll, vector<int>>();
  REP(i, n) {
    addc[i + as[i]].push_back(i);
    subc[i - as[i]].push_back(i);
  }

  for (auto &p : addc) {
    sort(ALL(p.second));
    //cout << p.first << ": ";
    //REP(i, p.second.size()) {
    //  cout << p.second[i] << " ";
    //}
    //cout << endl;
  }
  for (auto &p : subc) {
    sort(ALL(p.second));
    //cout << p.first << ": ";
    //REP(i, p.second.size()) {
    //  cout << p.second[i] << " ";
    //}
    //cout << endl;
  }

  ll ans = 0;
  for (const auto &p : subc) {
    if (!addc.count(p.first)) continue;
    //cout << p.first << endl;

    REP(i, p.second.size()) {
      ans += distance(addc[p.first].begin(), lower_bound(ALL(addc[p.first]), p.second[i]));
    }
  }
  cout << ans << endl;
}


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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    int h,w,k;
    cin >> h >> w >> k;
    vector<int> s(h*w,0);
    for(int i = 0; i < h; i++) {
        string st;
        cin >> st;
        for(int j = 0; j < w; j++) {
            if(st[j]=='1') s[i*w+j]=1;
        }
    }

    int ans=INT_MAX;
    for(int bit = 0; bit < (1<<(h-1)); bit++) {
        int tans=__builtin_popcount(bit);
        vector<int> cutrow;
        for(int i = 0; i < h; i++) {
            if(bit&(1<<i)) cutrow.push_back(i);
        }
        cutrow.push_back(h); //sentinel
        int tn=cutrow.size();
//        for(auto &e : cutrow) {
//            cout << e << " ";
//        }
//        cout << "\n";
        vector<int> acm(tn,0);
        vector<int> add(tn,0);
        bool can=true;
        for(int j = 0; j < w; j++) {
            int idx=0;
            for(int i = 0; i < h; i++) {
                add[idx]+=s[i*w+j];
                if(i==cutrow[idx]) idx++;
            }
            bool fcut=false;
            for(int i = 0; i < tn; i++) {
                if(acm[i]+add[i]>k) fcut=true;
                if(add[i]>k) can=false;
            }
            if(fcut){
                tans++;
                for(auto &e : acm) e=0;
            }
            for(int i = 0; i < tn; i++) {
                acm[i]+=add[i];
                add[i]=0;
            }
        }
        if(can) ans=min(tans,ans);
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
#pragma GCC optimize "trapv"
#define pb push_back
#define fi first
#define se second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#include "debug.cpp"
#endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  int n; cin >> n;
  int ar[n] = {0};

  for(int i=0;i<n;i++){
    cin >> ar[i];
  }

  int suffix[n] = {0};
  int mod = 1e9+7;

  suffix[n-1] = ar[n-1]%mod;

  for(int i=n-2;i>=1;i--){
    suffix[i] = (suffix[i+1]%mod + ar[i]%mod)%mod;
  }

  int ans = 0;
  

  for(int i=0;i<n-1;i++){
    ans = ans + (ar[i]%mod*suffix[i+1])%mod;
    ans%=mod;
  }

  cout << ans << '\n';

  return 0;
}

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


int main(){
    int64_t N,cnt;
    cnt = 0;
    string C;
    vector<int64_t> W(0);
    vector<int64_t> R(0);
    cin >> N >> C;
    for(int64_t i = 0; i < N; i++){
        if(C.at(i) == 'W'){
            W.push_back(i);
        }else{
            R.push_back(i);
        }
    }
    reverse(R.begin(), R.end());
    int64_t limit = min(W.size(),R.size());
    for(int64_t j = 0; j < limit; j++){
        if(W.at(j) < R.at(j)){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 5896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll n;cin>>n;
    vp v(n*2);
    rep(i,n*2)cin>>v[i].fi;
    rep(i,n*2)v[i].se=i;
    sort(all(v));
    ll ans=0;
    rep(i,n)ans+=v[i].fi;
    vi num(n);
    rep(i,n)num[v[i].se/2]++;
    rep(i,n)if(num[i]==0)dame(ans);
    vb done(2);
    rep(i,n)done[v[i].se%2]=true;
    if(done[0]&&done[1]){
        ll res=inf;
        ll mi=inf,ma=-inf;
        rep(i,n)if(v[i].se/2!=v[n].se/2)chmax(ma,v[i].fi);
        chmin(res,v[n].fi-ma);
        rep(i,n)if(v[i+n].se/2!=v[n-1].se/2)chmin(mi,v[i+n].fi);
        chmin(res,mi-v[n-1].fi);
        ans+=res;
    }
    out(ans);
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b);
#define chmin(a, b) a = min(a, b);
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define MOD 1000000007
//#define MOD 998244353
struct mint {
	int i;
	mint() : i(0) {}
	mint(int x) {
		i = int(x % MOD);
		if (i < 0) i += MOD;
	}
	template<class T> mint(T x) {
		i = int(x % MOD);
		if (i < 0) i += MOD;
	}
	mint operator+(const mint x) const {return i + x.i;}
	mint operator-(const mint x) const {return i - x.i;}
	mint operator*(const mint x) const {return (long long)i * x.i;}
	mint operator/(const mint x) const {return (long long)i * x.pow(MOD - 2).i;}
	mint inv() {return pow(MOD - 2);}
	template<class T> mint pow(T p) const {
		long long r = 1;
		long long t = i;
		for(; p > 0; p >>= 1) {
			if (p & 1) r = r * t % MOD;
			t = t * t % MOD;
		}
		return r;
	}
	template<class T1, class T2> static mint pow(T1 a, T2 b) {
		long long r = 1;
		long long t = (long long)(a % MOD);
		for(; b > 0; b >>= 1) {
			if (b & 1) r = r * t % MOD;
			t = t * t % MOD;
		}
		return r;
	}
	mint& operator+=(const mint x) {
		i = (i + x.i) % MOD;
		return *this;
	}
	mint& operator-=(const mint x) {
		i = i - x.i;
		if (i < 0) i += MOD;
		return *this;
	}
	mint& operator*=(const mint x) {
		i = (int)((long long)i * x.i % MOD);
		return *this;
	}
	mint& operator/=(const mint x) {
		i = (long long)i * x.pow(MOD - 2).i % MOD;
		return *this;
	}
};

std::ostream& operator<<(std::ostream& os, const mint& m) {
	return os << m.i;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<mint> dp(k+2);
    dp[0] = 1;
    rep(_, n) {
        int a;
        cin >> a;
        vector<mint> ndp(k+2);
        rep(i, k+1) {
            int ub = min(k+1, i+a+1);
			ndp[i] += dp[i];
			ndp[ub] -= dp[i];
        }
		for(int i = 1; i <= k; i++) {
			ndp[i] += ndp[i-1];
		}
        swap(dp, ndp);
    }
    cout << dp[k] << endl;
}


Measured memory_bytes: 4344
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static final int M = 3;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		long x = parseLong(sc.next());
		sc.close();
		long y500 = x / 500;
		x %= 500;
		long y5 = x / 5;
		out.println(y500*1000+y5*5);
	}
}


Measured memory_bytes: 21972
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

//use num_bigint::BigInt;

use num;

fn main() {
    input! {
       N: usize,
       a:[usize;N],
    }

    let mut b: Vec<num::BigInt> = vec![];
    for i in 0..N {
        b.push(a[i].into());
    }
    let mut ans: num::BigInt = 1.into();
    let mut f = true;
    for i in 0..N {
        ans *= a[i];
        let b: num::BigInt = 1000000000000000000_usize.into();
        if ans > b {
            f = false;
            break;
        }
    }
    if !f {
        for i in 0..N {
            if a[i] == 0 {
                echo!(0);
                return;
            }
        }
        echo!(-1);
        return;
    }

    echo!(ans);
}


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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int neg = 0;
  ll sum = 0;
  rep(i, n) {
    neg += (a[i] < 0);
    sum += abs(a[i]);
  }

  ll ans = sum;
  if (neg & 1) {
    sort(a.begin(), a.end(), [](int x, int y) { return abs(x) < abs(y); });
    ans -= (ll)2 * abs(a[0]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll a,b,n;
  cin >> a >> b >> n;
  if(n>=b-1){
    cout << a*(b-1)/b << endl;
  }
  else{
    cout << a*n/b << endl;
  }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<ll, int>;

#define INF 1e18

int main() {
  string s;
  cin >> s;
  int x = 0;
  rep(i,s.size()) {
    x += s[i]-'0';
  }
  if (x%9==0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3716
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}

template<int N, typename T, T M>
struct ModFact {
    T inv[N+1];
    T fact[N+1];
    T ifact[N+1];
    constexpr ModFact() : fact(), ifact() {
        fact[0] = 1;
        for (int i = 0; i < N; i++)
            fact[i+1] = (fact[i]*(i+1))%M;
        ifact[N] = power(fact[N], M-2);
        for (int i = N-1; i >= 0; i--)
            ifact[i] = (ifact[i+1]*(i+1))%M;
        inv[0] = 0;
        for (int i = 0; i < N; i++)
            inv[i+1] = (fact[i]*ifact[i+1])%M;
    }
    constexpr T power(T a, T b) {
        T r = 1;
        while (b>0) {
            if((b&1)!=0) r = (r*a)%M;
            a = (a*a)%M;
            b >>= 1;
        }
        return r;
    }
    constexpr T comb(T n, T r) {
        return (((fact[n]*ifact[r])%M)*ifact[n-r])%M;
    }
};

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}

inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

ModFact<100000, ll, MOD> fact;

ll N;

int main() {
    ll N, ans = 0;
    int prev, now;
    N = getint();
    prev = getint();
    ll a = 0;
    REP(i, N-1) {
        now = getint();
        // cin >> now;
        a = (a + fact.inv[i+1]) % MOD;
        ans += a * (now - prev) % MOD;
        prev = now;
    }
    printf("%lld\n", ((ans%MOD)*fact.fact[N-1])%MOD);
	return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

vector<int> to[100005];

int main(int argc, char *argv[])
{
    int M, N;
    cin >> N >> M;

    for (int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        to[A].push_back(B);
        to[B].push_back(A);
    }
    int inf = 0x7fffffff;
    queue<int> q;
    vector<int> dist(N, inf);
    vector<int> pre(N, -1);
    dist[0] = 0;
    q.push(0);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int u : to[v]) {
            if(dist[u] != inf) {
                continue;
            }
            dist[u] = dist[v] + 1;
            pre[u] = v;
            q.push(u);
        }
    }
    cout << "Yes" << endl;
    for (int i = 0; i < N; i++) {
        if (i == 0) {
            continue;
        }
        int ans = pre[i];
        ans++;
        cout << ans << endl;
    }
    return 0;
}

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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] d = new int[n];
		for (int i = 0; i < n; i++) {
			d[i] = sc.nextInt();
		}
		sc.close();

		Arrays.parallelSort(d);

		int d1 = d[n / 2 - 1];
		int d2 = d[n / 2];
		System.out.println(d2 - d1);
	}
}


Measured memory_bytes: 52568
from collections import deque

def bfs(maze, visited, H, W, sx, sy):
    que = deque()
    que.append([sx, sy])
    visited[sx][sy] = 0
    ml = 0
    
    while que:
        x, y = que.popleft()
        
        for px, py in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
            nx, ny = x+px, y+py
            if (0<=nx<H)and(0<=ny<W):
                if (maze[nx][ny] == '.')and(visited[nx][ny]==-1):
                    que.append([nx, ny])
                    dist = visited[x][y] + 1
                    visited[nx][ny] = dist
                    ml = max(ml, dist)
    return ml
                    

H, W = map(int, input().split())
maze = [input() for _ in range(H)]
ans = 0
for i in range(H):
    for j in range(W):
        if maze[i][j] == '#':
            continue
        else:
            visited = [[-1]*W for _ in range(H)]
            ans = max(ans, bfs(maze, visited, H, W, i, j))
print(ans)

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

int main() {
  int n,ans;
  cin >> n;
  ans = 3*n*n;

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;

public class Main
{
	public static void main(String[] arg) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s;
		while((s=br.readLine())!=null)
		{
		    int n = Integer.valueOf(s);
		    int comb=0;
	    	    int[] a = new int[10];
		    for(int i=0; i<10; i++)
   		    	a[i] = i;

  	            for(int b=0; b<10; b++)
	                for(int c=0; c<10; c++)
			    for(int d=0; d<10; d++)
			    	if(Arrays.binarySearch(a,n-b-c-d)>=0)
				comb++;
  		    System.out.println(comb);
		}
	}
}

Measured memory_bytes: 9456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String s1="",s2="";
		while(true) {
			s1=bfr.readLine()+"END";
			if(s1.equals(".END")) {
				System.exit(0);
			}
			s2=bfr.readLine()+"END";

			String[] s1m=s1.split("\"");
			String[] s2m=s2.split("\"");
			int cnt=0;
			if(s1m.length!=s2m.length) {
				System.out.println("DIFFERENT");
			}else {
				boolean isnea=false;

				for(int i=0; i<s2m.length; i++) {
					if(!s1m[i].equals(s2m[i]) && i%2==1) {
						isnea=true;
						cnt++;
					}
					else if(i%2==0) {
						if(!s1m[i].equals(s2m[i])) {
							cnt=2;
						}
					}
				}
				if(cnt>1) {
					System.out.println("DIFFERENT");
				}
				else if(cnt==1) {
					System.out.println("CLOSE");
				}
				else if(cnt==0) {
					System.out.println("IDENTICAL");
				}
			}
		}
	}
}


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

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

int dp[2][2][3];

int main()
{
	int N;
	cin >> N;
	int pre = 0;
	dp[pre][0][0] = 1;
	for (int i = 2; i <= N; i++) if (isp(i)) {
		int cnt = 0, val = N;
		while (val /= i) cnt += val;
		int tmp = pre ^ 1;
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k < 3; k++) {
				dp[tmp][j][k] = 0;
			}
		}
		for (int a = 0, x = 1; a <= 1; a++, x *= 3) {
			for (int b = 0, y = 1; b <= 2; b++, y *= 5) {
				if (x * y - 1 <= cnt) {
					for (int j = 0; j + a <= 1; j++) {
						for (int k = 0; k + b <= 2; k++) {
							dp[tmp][j + a][k + b] += dp[pre][j][k];
						}
					}
				}
			}
		}
		pre = tmp;
	}
	cout << dp[pre][1][2] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	int a, b, c;
  	cin >> a >> b >> c;
  	int fives=0, sevens=0;
  	if(a == 5)
      fives++;
  	if(b == 5)
      fives++;
  	if(c == 5)
      fives++;
  
  	if(a == 7)
      sevens++;
  	if(b == 7)
      sevens++;
  	if(c == 7)
      sevens++;
  	if(fives == 2 && sevens == 1)
      cout << "YES";
 	else
      cout << "NO";
     return 0;
}

Measured memory_bytes: 256
import javax.management.MBeanRegistration;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.StringTokenizer;
import java.util.Scanner;
import java.lang.*;
import java.io.*;
import java.util.*;
import java.lang.Integer;
import java.util.HashMap;

public class Main {
    // driver function to test the above functions
    public static void main(String args[]) throws IOException {
        Reader.init(System.in);
        String n =Reader.next();
        char[] arr = n.toCharArray();
        int ans = -1;
        for (int i=0; i<arr.length; i++){
            if (arr[i]=='7'){
                System.out.println("Yes");
                ans = 0;
                break;
            }
        }
        if (ans==-1){
            System.out.println("No");
        }

    }
}

class Node{
    char val;
    Node nxt = null;
    Node prev=null;


}



class solu{

}

/** Class for buffered reading int and double values */
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }

    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }

    static String line() throws IOException {
        return reader.readLine();
    }
}

Measured memory_bytes: 32636
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;

const ll mod = 1000000007;




int main() {
	int s, w;
	cin >> s >> w;

	if (s <= w) {
		cout << "unsafe" << endl;
	} else {
		cout << "safe" << endl;		
	}



	return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int n,m;
    cin>>n;
    m = n;
    int sn = 0;
    while(m!=0){    
        sn += m%10;
        m /= 10;
    }
    if(n%sn==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxN = 100;
int n, d[maxN], cnt, tmp(0);

int main(){
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> d[i];
  sort(d,d+n);
  for (int i = 0; i < n; ++i){
    if (d[i] > tmp){
      tmp = d[i];
      cnt++;
    }
  }
  cout << cnt;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

int gcd(int x, int y){
    if(y==0) return x;
    else return gcd(y, x%y);
}

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

    int num=gcd(a[0], a[1]);
    for(int i=0; i<n; i++){
        num=gcd(num, a[i]);
    }
    cout << num << endl;
}

Measured memory_bytes: 640
A, B, C, K = map(int, input().split())

ans = 0

nokori = K

if A >= K:
    print(K)
    exit()

else:
    ans += A
    nokori = K - A

    if B >= nokori:
        print(ans)
        exit()
    
    else:
        nokori = nokori - B
        ans = ans - nokori
        print(ans)


Measured memory_bytes: 9176
#include <bits/stdc++.h>
#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++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

  int a,b,k;
  cin>>a>>b>>k;
  int count = 0;
  vector<int> ans;
  for(int i=1;i<101;i++){
    if(a%i==0&&b%i==0){
      count++;
      ans.pb(i);
    }
  }

  cout<<ans[count-k]<<endl;
 

  return 0;
}

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

using namespace std;
int n, ans[200001];
pair < int, int > a[200001];
int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a + 1, a + 1 + n);
    int mid = n / 2;
    for(int i = 1; i <= n; i++){
        if(mid >= i){
            ans[a[i].second] = a[mid + 1].first;
        }
        else{
            ans[a[i].second] = a[mid].first;
        }
    }
    for(int i = 1; i <= n; i++){
        cout << ans[i] << '\n';
    }
}


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

using namespace std;

#define ll long long int

int main(void){
    int n;
    cin >> n;
    vector<int> h;
    int hf,hb;
    for(int i=0;i<n;i++){
        hf=hb;
        cin >> hb;
        if(i>0){
            int diff=hf-hb;
            h.emplace_back(diff);
        }
    }

    int count=0;
    int max=0;
    for(auto v : h){//cout << v << endl;
        if(v>=0){
            count++;//printf("count=%d\n",count);
        }else{
            if(max<count){
                max=count;
            }
            count=0;
        }
    }
  
  	 if(max<count){
        max=count;
    }

    cout << max << endl;

}

Measured memory_bytes: 892