akhauriyash/Code-Regression huggingface dataset:
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int a,b,c;
  cin >> a >> b >> c;

  for(int i = a;i <= a * b;i = i + a)
  {
    if(i % b == c) {cout <<"YES"<<endl;return 0;}
  }

  cout << "NO" << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize,
    }
    let start = min(a, b);
    let goal = max(a, b);
    println!("{}", if start < c && c < goal { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
h,w,k = map(int,input().split())
c = []
for a in range(h):
  c.append(list(input()))
res = 0

for i in range(2 ** h):
  for j in range(2 ** w):
    i_s = []
    j_s = []
    for x in range(h):  
      if ((i >> x) & 1): 
        i_s.append(x)  
    for y in range(w):  
      if ((j >> y) & 1): 
        j_s.append(y)  
    b_s = 0
    for i_t in i_s:
      for j_t in j_s:
        if c[i_t][j_t] == "#":
          b_s += 1
    if b_s == k:
      res += 1
print(res)

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

public final class Main {

	public static void main(String[] args) 
	throws IOException {
		// TODO Auto-generated method stub

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int[] arraysize = TempReaderCall.splitIntArrayFromString(TempReaderCall.getStdInRead(br));
		
		int[] ctotal = new int[arraysize[1]];
		ArrayList<String> list = TempReaderCall.getStdInReadlines(br, arraysize[0]);
		
		for (int i=0; i<arraysize[0]; i++){
			int[] rowdata = TempReaderCall.splitIntArrayFromString(list.get(i));
			addColumnData(ctotal, rowdata);
			System.out.println(list.get(i) + " " + sum(rowdata));
		}
		
		System.out.println(printRow(ctotal) + sum(ctotal));
		
	}
	
	static int sum (int[] data){
		int total = 0;
		for(int i=0; i < data.length; i++)
			total += data[i];
		
		return total;
	}
	
	static void addColumnData(int[] ctotal, int[] rowdata){
		for(int i=0; i<ctotal.length; i++)
			ctotal[i] += rowdata[i];
	}
	
	static String printRow(int[] ctotal){
		String line = "";
		for(int i=0; i < ctotal.length; i++) 
			line = line + Integer.toString(ctotal[i]) + " ";
		return line;
	}

}


class TempReaderCall{
	
	static ArrayList<String> getStdInReadlines(BufferedReader br, int line) throws IOException {
		ArrayList<String> list = new ArrayList<String>();
		for (int i = 0; i < line; i++)
			list.add(br.readLine());
		return list;
	}
	
	static String getStdInRead(BufferedReader br) throws IOException {
		return (br.readLine());
	}
	
	
	static int[] splitIntArrayFromString(String st) {
		String[] sts = st.split(" ");
		int[] data = new int[sts.length];
		
		for (int i=0;i<sts.length;i++){
			data[i] = Integer.parseInt(sts[i]);
		}
		
		return data;
	}
}

Measured memory_bytes: 27956
N = int(input())
S = list(map(int,input().split()))

ans = 0
if N < 3:
    ans = 0
else:
    for i in range(N):
        for j in range(i,N):
            for k in range(j,N):
                if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                    if S[i] + S[j] > S[k] and S[j] + S[k] > S[i] and S[k] + S[i] > S[j]:
                        ans += 1
print(ans)

Measured memory_bytes: 9204
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m,a[210001],i,j,k;
int main(){
	scanf("%d%d",&n,&m);memset(a,0,sizeof(a));
	for (i=1;i<=m;i++) scanf("%d%d",&j,&k),a[j]++,a[k]++;
	for (i=1;i<=n;i++)
	 if (a[i]&1){
	 	puts("NO");return 0;
	 }
	puts("YES");
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin>>N;
	vector<long>A(N+1);
	vector<long>B(N+1,0);
	for(long i=0;i<N;i++){
		cin>>A.at(i);
		B.at(A.at(i))+=1;
	}
	long long int sum=0;
	for(long i=0;i<=N;i++){
		long long k=B.at(i);
		sum+=k*(k-1)/2;
	}
	for(long k=0;k<N;k++){
		long long int ans=sum-(B.at(A.at(k))-1);
	cout<<ans<<endl;
	}
}


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

int main() {
    int N;
    cin >> N;
    int A[N];
    rep(i, N) cin >> A[i];

    sort(A, A + N);
    int idx = 0;
    int64_t sum = A[0];
    REP(i, 1, N) {
        if (A[i] > sum * 2) {
            idx = i;
        }
        sum += A[i];
    }
    cout << N - idx << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
struct shop{
  long price;
  int num;
};
int main(void){
  int m,n;
  int count=0;
  long ans=0;
  cin >> n >> m;
  vector<shop> v(n);
  for(int i=0;i<n;i++){
    cin >> v[i].price >> v[i].num;
  }
  sort(v.begin(),v.end(),[](const shop& x, const shop& y) { return x.price < y.price;});
  int j;
  for(j=0;j<n;j++){
    count+=v[j].num;
    ans+=v[j].num*v[j].price;
    if(count>=m){
      break;
    }
  }
  ans-=(count-m)*v[j].price;
  cout << ans;
  return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

map<ll, map<ll, ll> > input;
ll N;
ll ans;
ll data[20] = {0};

void rec(ll current) {
  if (current == N) {
    for (auto it: input) {
      for (auto it2: it.second) {
        ll from = it.first;
        ll to = it2.first;
        ll judge = it2.second;
        if (data[from] == 0) continue;
        if (data[to] != judge) return;
      }
    }
    ll tmp = 0;
    rep (i, N) if (data[i] == 1) tmp++;
    ans = max(ans, tmp);
    return;
  }
  data[current] = 0;
  rec(current + 1);
  data[current] = 1;
  rec(current + 1);
}

void solve() {
  cin >> N;
  rep (i, N) {
    ll A;
    cin >> A;
    rep (a, A) {
      ll x, y;
      cin >> x >> y;
      input[i][x-1] = y;
    }
  }
  ans = 0;
  rec(0);
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


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

int main(){
    int A, B;
    cin >> A >> B;
    int x = 10*B;
    while(x < 10*B+10){
        if(8*x/100 == A){
            cout << x << endl;
            return 0;
        }
        x++;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
const int L = 128, lim = 62;
int res, len, cnt[lim + 5];
char Fix(int k)
{
	if (k < 26)
		return 'a' + k;
	if (k < 52)
		return 'A' + k - 26;
	return '0' + k - 52;
}
bool Query(vector<char> X, int pos, char ch)
{
	X.insert(X.begin() + pos, ch);
	putchar('?'), putchar(' ');
	for (int i = 0; i < (int)X.size(); i++)
		putchar(X[i]);
	putchar(10);
	fflush(stdout);
	scanf("%d", &res);
	return res == len - (int)X.size();
}
vector<char> Solve(int l, int r)
{
	if (l == r)
		return vector<char>(cnt[l], Fix(l));
	int mid = (l + r) >> 1;
	vector<char> L = Solve(l, mid);
	vector<char> R = Solve(mid + 1, r);
	int p = 0;
	for (int i = 0; i <= (int)L.size(); i++)
		while (p < (int)R.size() && Query(L, i, R[p]))
			L.insert(L.begin() + i, R[p]), i++, p++;
	return L;
}
int main()
{
	for (int i = 0; i < lim; i++)
	{
		putchar('?'), putchar(' ');
		for (int j = 0; j < L; j++)
			putchar(Fix(i));
		putchar(10);
		fflush(stdout);
		scanf("%d", &res);
		cnt[i] = L - res, len += cnt[i];
	}
	vector<char> X = Solve(0, lim - 1);
	putchar('!'), putchar(' ');
	for (int i = 0; i < (int)X.size(); i++)
		putchar(X[i]);
	putchar(10);
}


Measured memory_bytes: 3804
line = readlines.map{ |s| s.chomp }
#line = ["3", "1 3 2", "3 1 2"]
n = line[0].to_i
#3
arr = (1..n).to_a
x = arr.permutation.collect{ |a| a.join(" ") }

# p x

p = line[1]
#"1 3 2"

q = line[2]
#"3 1 2"

#配列検索を行う
# ["1 2 3", "1 3 2", "2 1 3", "2 3 1", "3 1 2", "3 2 1"]
p1 = x.find_index { |n| n == p } + 1

q1 = x.find_index { |n| n == q } + 1

# puts p1 
# puts q1

result = p1 - q1

puts result.abs



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

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> edge(N+1, vector<int>());
    vector<int> in(N+1, 0);
    for (int i = 0; i < N-1+M; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        edge[a].push_back(b);
        in[b]++;
    }
    int root;
    for (int i = 1; i <= N; i++){
        if (in[i] == 0) {
            root = i;
            break;
        }
    }
    
    vector<int> par(N+1);
    par[root] = 0;
    queue<int> q;
    q.push(root);
    while (!q.empty()) {
        int now = q.front();
        q.pop();
        for (int nxt : edge[now]) {
            if (in[nxt] == 1) {
                par[nxt] = now;
                q.push(nxt);
            }
            else in[nxt]--;
        }
    }
    for (int i = 1; i <= N; i++) cout << par[i] << endl;
    return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define INF 1e9

void init()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
}

int main()
{
    init();
    int x,n;
    cin>>x>>n;
    vector<int> d(102,0);
    int p;
    rep(i,n){
        cin>>p;
        d[p]=1;
    }
    int x1=x;
    int x2=x;
    while(1){
        if(d[x1]==0){
            cout<<x1<<endl;
            break;
        }
        x1--;
        if(d[x2]==0){
            cout << x2 << endl;
            break;
        }
        x2++;
    }

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

const ll inf=1000000007;

inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}

int main()
{
    int d, t, v;
    scanf("%d%d%d",&d,&t,&v);
    int s=t*v;
    if(s>=d)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long X=1000000000+7;
const string d="dream";
const string e="erase";

int main() {
  int n,sum;
  cin>>n>>sum;
  if(sum%1000>0)
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
  else{
    sum/=1000;
    bool ans=false;
    int x,y;
    for(x=0;x<=n;++x){
      if(x*10>sum) break;
      for(y=0;y<=n-x;++y){
        if(x*10+y*5>sum) break;
        if(x*9+y*4+n==sum){
          ans=true;
          break;
        }
      }
      if(ans) break;
    }
    
    if(ans)
      cout<<x<<" "<<y<<" "<<n-x-y<<endl;
    else
    cout<<-1<<" "<<-1<<" "<<-1<<endl;      
  }
}


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

int n,m;
char A[55][55], B[55][55];

bool Check(int i,int j){
    for(int x = i, cnt1 = 1; cnt1 <= m; x++, cnt1++)
        for(int y = j, cnt2 = 1; cnt2 <= m; y++, cnt2++)
            if(A[x][y] != B[cnt1][cnt2]) return false;
    return true;
}

int main(){
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i++) scanf("%s", A[i] + 1);
    for(int i = 1; i <= m; i++) scanf("%s", B[i] + 1);

    //Check
    for(int i = 1; i + m - 1 <= n; i++){
        for(int j = 1; j + m - 1 <= n; j++){
           if(Check(i, j)){
            printf("Yes\n");
            return 0;
           }
        }
    }
    printf("No\n");
    return 0;
}



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

struct DisjointSet{
  vector<int> rank, p;

  DisjointSet(){}
  DisjointSet(int size){
    rank.resize(size, 0);
    p.resize(size, 0);
    rep(i, size) makeSet(i);
  }

  void makeSet(int x){
    p[x] = x;
    rank[x] = 0;
  }

  bool same(int x, int y){
    return findSet(x) == findSet(y);
  }

  void unit(int x, int y){
    link(findSet(x), findSet(y));
  }

  void link(int x, int y){
    if(rank[x] > rank[y]) p[y] = x;
    else if(rank[x] < rank[y]) p[x] = y;
    else {p[x] = y; rank[y]++;}
  }

  int findSet(int x){
    if(p[x] != x){
      p[x] = findSet(p[x]);
    }
    return p[x];
  }
};

int main(){
  int n, q; cin >> n >> q;
  DisjointSet ds = DisjointSet(n);

  rep(i, q){
    int com, x, y;
    cin >> com >> x >> y;
    if(com == 0){
      ds.unit(x, y);
    }
    else if(com == 1){
      cout << (ds.same(x, y) ? 1 : 0) << endl;
    }
  }

  return 0;
}





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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define PI 3.141592653589793
#define mod 1000000007
#define M 1000006
# define N 100005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

int main()
{
	int m;
	cin >> m;
	cout << (48-m);
	
}

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

using namespace std;

int main()
{
    int a, b, c;

    cin >> a >> b >> c;

    if (a + b + c >= 22) {
        cout << "bust" << endl;
    }
    else {
        cout << "win" << endl;
    }
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  int A, B; cin >> A >> B;
  if (A <= 8 && B <= 8) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long int a,b,c;
    scanf("%lld%lld%lld",&a,&b,&c);
    if(a>=c)
    {
        a=a-c;
        printf("%lld %lld\n",a,b);
    }
    else if(a+b>=c)
    {
        c=c-a;
        b=b-c;
        a=0;
        printf("%lld %lld\n",a,b);
    }
    else if(a+b<c)
    {
        a=0;
        b=0;
        printf("%lld %lld\n",a,b);
    }

}


Measured memory_bytes: 128
import java.util.*;

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

        int x = scanner.nextInt();
        int y = scanner.nextInt();

        for (;;) {
            if (y > x) {
                x = x ^ y;
                y = x ^ y;
                x = x ^ y;
            }
            if (y == 0) {
                System.out.println(x);
                return;
            }
            x -= y;
        }
    }
}



Measured memory_bytes: 26248
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(x) x.begin(),x.end()
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define endl "\n"
const ll maxn = 2e5+2;

int main()
{
    fastio;
    ll i, j, k, n, m, t;
    ll x;
    ll flag[maxn];
    memset(flag,0,sizeof(flag));

    cin>>x>>n;
    for ( i = 0; i < n; i++)
    {
        cin>>j;
        flag[j]=1;
    }

    j=1;
    if(flag[x]==0)
    {
        cout<<x<<endl;
        return 0;
    }

    while (1)
    {
        if(flag[x-j]==0)
        {
            cout<<x-j<<endl;
            break;
        }
        if(flag[x+j]==0)
        {
            cout<<x+j<<endl;
            break;
        }
        j++;
    }
    

        
    return 0;
}

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

using namespace std;

int func(int a){
    int c=0;
    while(a){
        c += a%10;
        a /= 10;
    }
    return c;
}
int main(){

    int N,ans = 1<<20;
    cin >> N;
    for(int i=1;i<=N/2;i++){
        int a = i;
        int b = N-i;
        ans = min(ans , func(a)+func(b));
    }
    cout << ans <<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,K=MAP()
A=LIST()

mx=max(K, max(A))
bmx=format(mx, 'b')
mxlen=len(bmx)
bK=format(K, '0'+str(mxlen)+'b')

# ビットが立っている数を各桁で集計しておく
cnt1=[0]*mxlen
for i in range(N):
    ba = format(A[i], '0'+str(mxlen)+'b')
    for j, bit in enumerate(ba):
        if bit=='1':
            cnt1[j]+=1
num0=[0]*mxlen
num1=[0]*mxlen
for i in range(mxlen):
    # カウントした方と逆になる
    num0[i]=cnt1[i]*2**(mxlen-i-1)
    num1[i]=(N-cnt1[i])*2**(mxlen-i-1)

# dp[i][j] := i桁目まで考えた時、j=0はi桁目まで一致(K=ans)、j=1は既にansがK未満(K>ans)になった状態
dp=list2d(mxlen+1, 2, -1)
dp[0][0]=0
for i in range(mxlen):
    if dp[i][1]!=-1:
        # smaller -> smaller
        dp[i+1][1]=max(dp[i+1][1], dp[i][1]+max(num0[i], num1[i]))
    if dp[i][0]!=-1:
        # exact -> exact
        if bK[i]=='0':
            dp[i+1][0]=max(dp[i+1][0], dp[i][0]+num0[i])
        else:
            dp[i+1][0]=max(dp[i+1][0], dp[i][0]+num1[i])
        # exact -> smaller
        if bK[i]=='1':
            dp[i+1][1]=max(dp[i+1][1], dp[i][0]+num0[i])
print(max(dp[mxlen][0], dp[mxlen][1]))


Measured memory_bytes: 14660
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
namespace icl = boost::icl;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> N,K;
  invec<ll>A(N);
  
  long double now = 1, prev;
  
  REP(i, K)
    now += A[i];
  
  prev = now;
  for (int i = K; i < N; i++) {
    now = now - A[i-K] + A[i];
    cout << (now>prev ? "Yes" : "No") << endl;
    prev = now;
  }


}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 4776
#include <stdio.h>
int main()
{
	int n,m,x,a[100],i,lc,rc;
	scanf("%d %d %d",&n,&m,&x);
	for(i = 0;i<m;i++) scanf("%d",&a[i]);
	
	i = 0;
	while(a[i++] < x);
	lc = --i;
	
	rc = m-lc;
	
	printf("%d\n", (lc<rc)? lc:rc);
	return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
)

// 品物の個数を決めうち
func oneOOToOneOFive(x int) bool {
	for c := 1; c <= x/100; c++ {
		if 100*c <= x && x <= 105*c {
			return true
		}
	}
	return false
}

func main() {
	var x int
	fmt.Scan(&x)
	if oneOOToOneOFive(x) {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 512
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
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()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

md=10**9+7
n=II()
aa=LI()
s=pow(sum(aa),2,md)
for a in aa:
    s-=a**2
    s%=md
inv2=pow(2,md-2,md)
s=s*inv2%md
print(s)


Measured memory_bytes: 31124
import sys
from math import sqrt, gcd, ceil, log
from bisect import bisect
from collections import defaultdict, Counter
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)

def fix(arr, d = 0):
	lis = [0]*len(arr)
	if d:
		gcd_ = arr[-1]
		for i in range(len(arr)-1, -1, -1):
			gcd_ = gcd(gcd_, arr[i])
			lis[i] = gcd_
	else:
		gcd_ = arr[0]
		for i in range(len(arr)):
			gcd_ = gcd(gcd_, arr[i])
			lis[i] = (gcd_)
	return(lis)

def solve():
	k = int(input())
	a, b = read()
	if a%k == 0 or b%k == 0 or a <= (b//k)*k <= b:
		print("OK")
	else:
		print("NG")

	





		

if __name__ == "__main__":
	solve()

Measured memory_bytes: 65384
import bisect
n = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0
for i in range(2,n):
  for j in range(1,i):
    flag = l[i]-l[j]
    ans_key = bisect.bisect_right(l,flag,0,j)
    ans += (j-ans_key)
print(ans)

Measured memory_bytes: 43760
import sys
sys.setrecursionlimit(10**9)


def dfs(v, p, dist):
    for u, w in tree[v]:
        if u == p:
            continue
        else:
            dist[u] = dist[v] + w
            dfs(u, v, dist)


n = int(input())
tree = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    tree[u - 1].append((v - 1, w))
    tree[v - 1].append((u - 1, w))

dist = [0 for _ in range(n)]
dfs(0, -1, dist)

for i in dist:
    if i % 2 == 0:
        print(0)
    else:
        print(1)


Measured memory_bytes: 82300
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
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>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

vector<vector<int>> children;
int dfs(int now) {
    int m=sz(children[now]);
    if(m==0) {
        return 0;
    }
    vector<int> vec;
    for(int child:children[now]) {
        vec.push_back(dfs(child));
    }
    sort(all(vec),greater<int>());
    int ret=0;
    rep(i,m) chmax(ret,vec[i]+i+1);
    return ret;
}

int main() {
    int n;
    cin>>n;
    children.resize(n);
    for(int i = 1; i < n; i++) {
        int x;
        cin>>x;
        x--;
        children[x].push_back(i);
    }
    cout<<dfs(0)<<endl;
}

Measured memory_bytes: 15104
N,K,Q = map(int,input().split())
A = [int(input()) for _ in range(Q)]

res = [K for _ in range(N)]

ac_num = [0]*N

for a in A:
    ac_num[a-1] += 1

for i in range(N):
    res[i] -= (Q - ac_num[i])


for i in res:
    if i > 0:
        print('Yes')
    else:
        print('No')

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

using namespace std;

typedef long long ll;
int main()
{
    string s, t;

    cin >> s >> t;

    int n = s.size();
    int c = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] != t[i])
            c++;
    }

    cout << c;
    return 0;
}


Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    priority_queue<int> pq;
    int c = 0;
    for(int i = 0; i < n; i++) {
        if(s[i] == 'R') pq.push(i);
        else c++;
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
        if(s[i] == 'W') {
            while(pq.size() && pq.top() < i) pq.pop();
            if(pq.size()) {
                swap(s[i], s[pq.top()]);
                pq.pop();
                ans++;
            }
        }
    }
    cout << min(ans, c);
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n";

void fast() {

    cin.tie(0);
    cin.sync_with_stdio(0);
}
ll n,a,arr[50+9],dp[50+9][50+9][2550];
ll ans(int i,int num,int sum){
    ll &ret=dp[i][num][sum];
    if(~ret)return ret;
    if(i==n)return dp[i][num][sum]=num&&((dd)sum/(dd)num==a);


    return ret=ans(i+1,num,sum)+ans(i+1,num+1,sum+arr[i]);

}
int main() {
        fast();
        cin>>n>>a;
    for (int i = 0; i <n ; ++i) {
        cin>>arr[i];
    }
    memset(dp,-1, sizeof(dp));
    cout<<ans(0,0,0);
}


Measured memory_bytes: 69760
from collections import deque

A = deque(list(input()))
B = deque(list(input()))
C = deque(list(input()))

def res(turn,str="NULL"):
    if len(turn) == 0: print(str.upper())
    else:
        str=turn.popleft()
        if str=="a": res(A,str)
        elif str=="b": res(B,str)
        elif str=="c": res(C,str)

res(A,"NULL")

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

int main(){
  int n;
  cin >> n;
  map<int, int> mp;
  int a;
  vector<long long> v;
  for ( int i = 0; i < n; i++){
    cin >> a;
    mp[a]++;
    if ( mp[a] % 2 == 0 && mp[a] > 0){
      v.push_back(a);
    }
  }

  sort(v.begin(), v.end(), greater<int>());
  if ( v.size() < 2){
    cout << 0 << endl;
  } else {
    long long ans =  v[0]*v[1];
    cout << ans << endl;
  }


  return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int a = in.nextInt();
    int b = in.nextInt();
    if (a < b) {
      System.out.println("a < b");
    }
    else if (a > b) {
      System.out.println("a > b");
    }
    else {
      System.out.println("a == b");
    }
  }
}

Measured memory_bytes: 26332
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(all(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(all(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
inline ll lin() { ll x; scanf("%lld",&x); return x;}
inline char chin() { char x; scanf("%c",&x); return x;}
inline string stin() { string x; cin >> x; return x;}
inline double din() { double x; scanf("%lf",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  ll a, b, k;
  cin >> a >> b >> k;
  ll x, y;
  if (k <= a) x = a-k, y = b;
  else if (k <= a+b) x = 0, y = b-(k-a);
  else x = 0, y = 0;
  cout << x SP y << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
		/*// 整数の入力
		int a = int.Parse(Console.ReadLine());*/
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
		int k = int.Parse(input[0]);
		int s = int.Parse(input[1]);
		// 文字列の入力
		//string s = Console.ReadLine();
		//出力
        int count = 0;
        for(int x=0; x<=k; x++){
            for(int y=0; y<=k; y++){
                int z = s-x-y;
                if(0 <= z && z <= k) count++;
            }
        }
		Console.WriteLine(count);
	}
}

Measured memory_bytes: 11092
N = int(input())
h_list = list(map(int, input().split()))

count = min(h_list)
h_list = [item - min(h_list) for item in h_list] + [0]
first = 0
for h in range(len(h_list) - 1):
    if h_list[h] > h_list[h + 1]:
        count += h_list[h] - first
        first = h_list[h + 1]
    else:
        continue
print(count)

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

int main(int argc, char const *argv[])
{
    int n, k;
    string s;

    cin >> n >> k;
    cin >> s;

    char c = s[k-1];
    s[k-1] = c - ('A' - 'a');

    cout << s << endl;
    
    return 0;
}


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

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

	vector<int> x(n);
	for (int i = 0; i < n; i++) {
		cin >> x.at(i);
	}

	priority_queue<uint64_t, vector<uint64_t>, greater<uint64_t>> hp;
	for (int p = 1; p <= 100; p++) {
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += (x.at(i) - p) * (x.at(i) - p);
		}
		hp.push(sum);
	}
	

	cout << hp.top() << endl;

	return 0;
}

Measured memory_bytes: 256
#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 a,b,c;
    cin >> a >> b >> c;
    int m = max(max(a,b),c);
    cout << m*10 + a + b + c - m << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind, COM//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 1; ll INF = 9999999999999;
vl flag, color; vll path;
//***********//
int main() {
	string L;
	cin >> L;
	N = L.length();
	vl A(N);
	for (i = 0; i < N; i++) {
		A[i] = ctoi(L[i]);
	}
	// dp[i][smaller][j]
	// 今調べている桁をi, 未満フラグをsmaller, 0が出た回数をjとする
	vll dp(N + 1, vl(2,0));
	// 0桁目は便宜上0であると考える
	// 0桁目は0しかありえないがこれはsmallerが確定していないのでsmaller=0しかありえない
	// 結局dp[0][0][0]=1, それ以外は全て0で初期化すればよい
	for (i = 0; i < N + 1; i++) {
		for (j = 0; j < 2; j++) {
			dp[i][k] = 0;
		}
	}
	dp[0][0] = 1;
	for (i = 0; i < N; i++) {
		for (ll smaller = 0; smaller < 2; smaller++) {
			for (ll x = 0; x <= (smaller ? 1 : A[i]); x++) {
				// j==K で x>0 の時はサイズオーバーで死ぬのでcontinue処理！
				if (!smaller && x > A[i]) {
					dp[i + 1][smaller || x < A[i]] = 0;
				}
				else {
					dp[i + 1][smaller || x < A[i]] = (dp[i + 1][smaller || x < A[i]] + (dp[i][smaller]) * (x + 1)) % MOD;
				}
				//cout << x << " ";
			}
		}
	}
	// [smaller || x < A[i]]は以下の寄与条件を反映させたものである。
	// smaller=0 から smaller=0 → x = A[i] のとき寄与
	// smaller=0 から smaller=1 → x < A[i] のとき寄与
	// smaller = 1 から smaller = 0 → 常に寄与なし
	// smaller=1 から smaller=1 → 常に寄与
	// [j + (x > 0)]は以下の寄与条件を反映させたものである。(但しj==Kのときのみ例外処理アリ)
	// j=p から j=p → x=0のとき寄与
	// j=p から j=p+1 → x!=0のとき寄与
	cout << (dp[N][0] + dp[N][1])%MOD;
}


Measured memory_bytes: 6656
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int num = Integer.valueOf(sc.nextInt());
    
    while(num > 0) {
      num = num - 1000;
    } 
    if (num != 0) {
      num = (-1) * num;
    }

    System.out.println(num);
    sc.close();
  }
}

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

int main() {
  int n;
  cin >> n;
  int r = 0;
  for (int t = 0; n--;) {
    int a, b;
    cin >> a >> b;
    if (a == b) {
      t++;
    } else {
      t = 0;
    }
    r = max(r, t);
  }
  cout << (r >= 3 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3632
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var hw = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var h = hw[0];
        var w = hw[1];
        var grid = new bool[h][];
        for (int i = 0; i < h; i++)
        {
            grid[i] = Console.ReadLine().Trim().Select(x => x == '#').ToArray();
        }

        var rowEmpty = new bool[h];
        for (int y = 0; y < h; y++)
        {
            rowEmpty[y] = grid[y].All(c => !c);
        }
        var colEmpty = new bool[w];
        for (int x = 0; x < w; x++)
        {
            for (int y = 0; y < h; y++)
            {
                colEmpty[x] |= grid[y][x];
            }

            colEmpty[x] = !colEmpty[x];
        }

        var compressed = new StringBuilder();
        for (int y = 0; y < h; y++)
        {
            if (rowEmpty[y])
            {
                continue;
            }

            for (int x = 0; x < w; x++)
            {
                if (colEmpty[x])
                {
                    continue;
                }

                compressed.Append(grid[y][x] ? '#' : '.');
            }
            compressed.AppendLine();
        }
        Console.WriteLine(compressed);
    }
}

Measured memory_bytes: 13448
#include<stdio.h>
#include<iostream>

using namespace std;

int N;
int dp[2][101];
int a[2][101];
int main(){
    cin >> N;
    for(int i=0; i<2; i++){
        for(int j=0; j<N; j++){
            cin >> a[i][j];
        }
    }
    dp[0][0] = a[0][0];
    dp[1][0] = dp[0][0] + a[1][0];
    for(int i=0; i<N;i++){
        dp[0][i+1] = dp[0][i] + a[0][i+1];
        dp[1][i+1] = max( dp[0][i+1],dp[1][i] ) + a[1][i+1];
    }
    cout << dp[1][N] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include <vector> 
#define m 1000000007
using namespace std;
using ll = long long ;

int main () 
{ 
	int n;
	ll sum = 0,x;
	vector<ll> v;

	cin >> n ;

	cin >> x;
	v.push_back(x);
	for( int i=1 ; i<n ; i++ )
	{
		cin >> x;
		v.push_back( (x+v[i-1])%m );
	}

	// for( auto o : v)
	// 	cout << o << ' ';
	// puts("");

	sum = ( v[0]*( (v[n-1]-v[0]) %m) )%m;
	if(sum<0)
		sum+=m;
		// cout << sum << ' ';

	for( int i=1 ; i<n ; i++ )
	{
		sum = (sum+ ( ( (v[i]-v[i-1])*(v[n-1]-v[i]) ) % m ) )%m;
	if(sum<0)
		sum+=m;
		// cout << sum << ' ';
	}

	cout << sum << endl;

    return 0; 
}

Measured memory_bytes: 4892
#include <iostream>
 
int main()
{
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);

   
  int min1=(b>=d)?d:b;
  int max1=(a>=c)?a:c;
    if(min1-max1<=0) 
        printf("0");
     
     else
         printf("%d",min1-max1);
    
  
}

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

int main() {
  int n,sumA,sumB,A;
  cin>>n;
  A = 2000;
  
  vector<int> vec(n);
  for(int i=0;i<n;i++){
  	cin>>vec.at(i);
  }
  
  for(int i=1;i<n;i++){
    sumA=0;
  sumB=0;
  	for(int j=0;j<i;j++){
    	sumA += vec.at(j);
    }
   for(int j=i;j<n;j++){
   		sumB += vec.at(j);
   }
    
    A = min(A,abs(sumA-sumB));
  
  }
   cout<<A<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
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; }
ll N;
string s;
vll animal;
//* sheep 0, wolf 1
bool check(ll a0, ll a1){
    
    animal[0] = a0; animal[1] = a1;
    for(ll i = 2; i < N; i++){
        if(animal[i-1]){ //* i-1 is wolf
            if(s[i-1]=='o')
                animal[i] = 1 - animal[i-2];
            else
                animal[i] = animal[i-2];
        }
        else{//* i-1 is sheep always true
            if(s[i-1]=='o')
                animal[i] = animal[i-2];
            else
                animal[i] = 1 - animal[i-2];
        }
    }
    //* check i=0
    if(animal[0]){//* 0 is wolf
        if(s[0] == 'o' && animal[N-1] == animal[1])
            return false;
        if(s[0] == 'x' && animal[N-1] != animal[1])
            return false;
    }else{
        if(s[0] == 'o' && animal[N-1] != animal[1])
            return false;
        if(s[0] == 'x' && animal[N-1] == animal[1])
            return false;
    }
    //* check i=N-1
    if(animal[N-1]){//* 0 is wolf
        if(s[N-1] == 'o' && animal[N-2] == animal[0])
            return false;
        if(s[N-1] == 'x' && animal[N-2] != animal[0])
            return false;
    }else{
        if(s[N-1] == 'o' && animal[N-2] != animal[0])
            return false;
        if(s[N-1] == 'x' && animal[N-2] == animal[0])
            return false;
    }
    return true;
}

int main(){
    scanf("%lld",&N);
    std::cin >> s;
    animal.resize(N, 0);
    bool isGood = false;
    isGood = check(0, 0);
    if(!isGood) isGood = check(0, 1);
    if(!isGood) isGood = check(1, 0);
    if(!isGood) isGood = check(1, 1);

    if(!isGood) cout<<-1<<endl;
    else{
        REP(i, N){
            if(animal[i]) cout<<"W";
            else cout<<"S";
        }
        cout<<endl;
    }

    return 0;
}


Measured memory_bytes: 1408
from collections import defaultdict
class UnionFind:
    def __init__(self, n):
        class KeyDict(dict):
            # 辞書にないときの対応
            def __missing__(self,key):
                self[key] = key
                return key
        self.parent = KeyDict()
        self.rank = defaultdict(int)
        self.weight = defaultdict(int)

    # 根を探す
    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            # 経路圧縮
            # 自分自身じゃない場合は、上にさかのぼって検索(再帰的に)
            y = self.find(self.parent[x])           
            self.weight[x] += self.weight[self.parent[x]]   #圧縮時にweightを更新(和)
            self.parent[x] = y      #親の置き換え(圧縮)
            return self.parent[x]

    # 結合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        # 低い方を高い方につなげる(親のランクによる)
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
        
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1

    ### 重み付き
    def weighted_union(self, x, y, w):
        # print("unite",x,y,w,self.weight)
        px = self.find(x)
        py = self.find(y)
        # 低い方を高い方につなげる(親のランクによる)
        # if px == py: return 0
        if self.rank[px] < self.rank[py]:
            self.parent[px] = py
            self.weight[px] = - w - self.weight[x] + self.weight[y]
        else:
            self.parent[py] = px
            self.weight[py] =  w + self.weight[x] - self.weight[y]
        if self.rank[px] == self.rank[py]:
            self.rank[px] += 1
        return 0

    # 判定
    def judge(self, x, y):
        return self.find(x) == self.find(y)



n, m = map(int, input().split())
ps = list(map(int, input().split()))

"""    
Unionfindで、自由に移動できるindexを同定
その中で、indexと数字がおなじになるものを同定
"""
uf = UnionFind(n)
for i in range(m):
    x,y = map(int, input().split())
    x -= 1
    y -= 1
    if not uf.judge(x,y):
        uf.union(x,y)

ps = [p-1 for p in ps]

ans = 0
for i,p in enumerate(ps):
    if uf.judge(i,p):
        ans += 1
        
print(ans)


Measured memory_bytes: 40020