akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;
int main() {
    int N; cin >> N;
    vector<int> L(2 * N, 0);
    for (int i = 0; i < 2 * N; i++) cin >> L[i];
    sort(L.begin(), L.end(), greater<int>());
    int sum = 0;
    for (int i = 0; i < 2 * N; i += 2) sum += min(L[i], L[i + 1]);
    printf("%d\n", sum);
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull; 
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define SQ(a) (a)*(a)

template <class T, class U> ostream& operator<< (ostream &out, pair<T,U> c) { out << "(" << c.first << " "; out << c.second << ")"; return out; }
template <class T> ostream& operator<< (ostream &out, vector<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
const double PI  = 3.141592653589793238463;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, r = 0;
    cin >> n;
    int a, b;
    cin >> a >> b;
    FOR(i,0,n+1){
        int s = 0;
        int j = i;
        s += j/10000;
        j -= j/10000 * 10000;

        s += j/1000;
        j -= j/1000 * 1000;

        s += j/100;
        j -= j/100 * 100;

        s += j/10;
        j -= j/10 * 10;

        s += j;

        if(s >= a && s <= b){
            r += i;
        }
    }
    cout << r << endl;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define minit(a,b) memset(a,b,sizeof(a))

void maxUpdate(int& a, int b) {
	a = max(a, b);
}

int n, s[555], l[555], p[555], dp[555], m, dp2[555];

int main() {
	cin >> n;
	for_(i,0,n) cin >> s[i] >> l[i] >> p[i];
	
	minit(dp, -1);
	dp[0] = 0;

	for_(i,0,n) for_(j,0,395) {
		if (dp[j] == -1) continue;
		for_(k,s[i],l[i]+1) if (j + k <= 393) maxUpdate(dp[j+k], dp[j] + p[i]);
	}
	
	vector< int > ans;
	bool flag = true;
	
	cin >> m;
	for_(i,0,m) {
		int w;
		cin >> w;
		ans.push_back(dp[w]);
		if (ans[i] <= 0) flag = false;
	}
	
	if (flag) {
		for_(i,0,m) cout << ans[i] << endl;
	} else {
		cout << -1 << endl;
	}
}

Measured memory_bytes: 1232
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#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)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T & a, const T & b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

int dx4[4] = { 1,0,0,-1 };
int dy4[4] = { 0,1,-1,0 };

int dx2[2] = { 1,0 };
int dy2[2] = { 0,1 };

/******************************************************************************************/


char mp[105][105];
int check[105][105];

char dice[4][4]={{'6' ,'3' ,'1' ,'4'},
				{'2' ,'#' ,'2' ,'#'},
				{'1' ,'3' ,'6' ,'4'},
				{'5' ,'#' ,'5' ,'#'}};

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);


	int h,w;
	cin >> h >> w;

	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			cin >> mp[i][j];
			if(mp[i][j]=='#'){
				check[i][j]=-1;
			}
		}
	}

	if(mp[h-1][w-1]=='#'){
		cout << "NO" << endl;
		return 0;
	}
	
	queue<pii> que;


	vector<int> hoge = {0,6,2,3,4,5,1};

	que.push(pii(0,0));

	while(!que.empty()){

		pii now = que.front();
		que.pop();
		//cout << "( " << now.first << " , " << now.second << ")" << endl;
		if(check[now.first][now.second])continue;
		check[now.first][now.second]=1;

		for (int i = 0; i < 4; i++)
		{
			int ny = now.first+dy4[i];
			int nx = now.second+dx4[i];
			//cout << "a" << endl;
			if(0 <= nx && nx < w && 0 <= ny && ny < h && mp[ny][nx] != '#' && check[ny][nx] == 0){
				//cout << ny << " " << nx  << endl;
				//cout << mp[nx][nx] << " " << dice[ny%4][nx%4] << endl;
				if(mp[ny][nx] == dice[ny%4][nx%4]){
					que.push(pii(ny,nx));
				}
			}
		}
	}
	
	if(check[h-1][w-1]){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}

	return 0;
}




Measured memory_bytes: 3248
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	long long x,ans;
	
	cin >> x;

	if (x < 2100)
	{
		long long buf1, buf2;
		buf1 = x / 100;
		buf2 = x % 100;

		if (buf2 <= buf1 * 5)
		{
			cout << "1" << endl;
		}
		else
		{
			cout << "0" << endl;
		}
	}
	else
	{
		cout << "1" << endl;
	}
}

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

#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,a,n) for(ll i=a;i<n;i++)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef pair<ll, ll> pll;

const int INF = 100000000;
const ll LINF = 1e18+5;

int main() {
    string S,T;
    cin >> S >> T;
    cout << T << S << endl;
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int a, b; cin >> a >> b;
  int result = (b-a-1) * (b-a) / 2 - a;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

const long long INF = LLONG_MAX / 10;
long long dfs(long long a, long long b, long long x) {
  static map<tuple<long long, long long, long long>, long long> memo;
  if (memo.count(make_tuple(a, b, x))) return memo[make_tuple(a, b, x)];
  if ((a & 1) ^ (b & 1) != (x & 1)) return INF;
  if (!x) return a < b ? INF : (a - b) / 2;
  long long ret1 = 2 * dfs(a / 2, b / 2, x / 2);
  long long ret2 = 2 * dfs((a - 1) / 2, (b + 1) / 2, x / 2) + 1;
  long long ret = min(ret1, ret2);
  if (ret >= INF) ret = INF;
  return memo[make_tuple(a, b, x)] = ret;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  long long A[N], X = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    X ^= A[i];
  }
  X ^= A[0] ^ A[1];
  long long ans = dfs(A[0], A[1], X);
  if (ans >= A[0]) ans = -1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604
N = int(input())
p = list(map(int,input().split()))
a = [N*(k+1) for k in range(N)]
b = [N*(N-k) for k in range(N)]
for k in range(N):
    b[p[k]-1] += k
print(*a, sep = " ")
print(*b, sep = " ")


Measured memory_bytes: 6300
uses
  SysUtils,
  Classes;
  
 procedure MainProc;
	var
		input, oddNum : Integer;
	begin
	ReadLn(input);
	oddNum := (input div 2) + (input mod 2);
	WriteLn(oddNum * (input - oddNum));
	end;
  
begin
MainProc;
end.


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
ll INF = 214748364700000000;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

int main(){
    ll N,a=0,b=0;cin >> N;
    vector<ll> A(N),B(N);
    rep(i,N){
        cin >> A[i];
        a += A[i];
    }
    rep(i,N){
        cin >> B[i];
        b += B[i];
    }
    if(b > a){
        cout << -1 << endl;
        return 0;
    }
    vector<ll> GOOD;
    ll need = 0,cnt = 0;
    rep(i,N){
        if(A[i] - B[i] >= 0){
            GOOD.push_back(A[i]-B[i]);
        }else{
            cnt++;
            need += B[i] - A[i];
        }
    }
    sort(ALL(GOOD));
    reverse(ALL(GOOD));
    ll n = 0,i = 0;
    while(n < need){
        n += GOOD[i];
        i++;
    }
    cout << cnt + i << endl;
}


Measured memory_bytes: 2936
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();

		List<Integer> results = new ArrayList<>();
		if (x <= y) {
			results.add(y - x);
		}
		if (-x <= y) {
			results.add(y - -x + 1);
		}
		if (x <= -y) {
			results.add(-y - x + 1);
		}
		if (-x <= -y) {
			results.add(-y - -x + 2);
		}

		System.out.println(results.stream().min(Integer::compareTo).get());
	}
}


Measured memory_bytes: 15692
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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, 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!{
        n:usize,
        k:usize,
        d:[String;k],
    }
    let mut ans=0;
    'outer : for i in n..(10*n+10) {
        for j in 0..k {
            if i.to_string().find(&d[j])!=None {
                break;
            }
            if j == k-1 {
                ans=i;
                break 'outer;
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
ans = A[0]
if N%2 == 0:
    for i in range(1,int((N/2))):
        ans += A[i]*2
else:
    for i in range(1,int(N/2)):
        ans += A[i]*2
    ans += A[int(N/2)]
print(ans)


Measured memory_bytes: 31540
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using std::sort;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}

const int N=80;
const int S=80*2*80;
int a[N][N],b[N][N],d[N][N];
bitset<S+S> dp[N][N];
int32_t main(){
    int n,m;
    cin>>n>>m;
    forn(i,n)forn(j,m)cin>>a[i][j];
    forn(i,n)forn(j,m){
        cin>>b[i][j];
        if(a[i][j]<b[i][j])swap(a[i][j],b[i][j]);
        d[i][j]=a[i][j]-b[i][j];
    }
    dp[0][0].set(+d[0][0]+S);
    dp[0][0].set(-d[0][0]+S);
    forn(i,n)forn(j,m){
        if(i){
            dp[i][j]|=dp[i-1][j]<<d[i][j];
            dp[i][j]|=dp[i-1][j]>>d[i][j];
        }
        if(j){
            dp[i][j]|=dp[i][j-1]<<d[i][j];
            dp[i][j]|=dp[i][j-1]>>d[i][j];
        }
    }
    int ans=1e9;
    forn(i,S+S){
        if(dp[n-1][m-1][i]){
            upn(ans,abs(i-S));
        }
    }
    cout<<ans<<'\n';

    return 0;
}


Measured memory_bytes: 20480
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

bool compare(std::tuple<int, std::string, int> t1, std::tuple<int, std::string, int> t2) {
    std::string s1 = std::get<1>(t1);
    std::string s2 = std::get<1>(t2);
    int p1 = std::get<2>(t1);
    int p2 = std::get<2>(t2);
    if (s1 == s2) {
        return p1 > p2;
    } else {
        return s1 < s2;
    }
}

int main() {
    int N;
    std::cin >> N;
    std::vector<std::tuple<int, std::string, int>> v;
    for (int i = 1; i <= N; ++i) {
        std::string S;
        int P;
        std::cin >> S >> P;
        v.emplace_back(std::make_tuple(i, S, P));
    }
    std::sort(v.begin(), v.end(), compare);
    for (std::vector<std::tuple<int, std::string, int>>::iterator it = v.begin(); it != v.end(); ++it) {
        std::cout << std::get<0>(*it) << "\n";
    }
    return 0;
}


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

using namespace std;


int gcd(int a, int b) {
  while(b) {
    a %= b;
    swap(a, b);
  }
  return a;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k, g, mx=0;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if (!i) g = a;
    g = gcd(g, a);
    mx = max(mx, a);
  }
  if (k<=mx && k%g==0) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  char a[6]={};
  char b[6]={};
  int aa, bb;
  string s;
  cin >> aa >> bb >> s;
  for(int i=0; i<aa; i++){
    if(s[i]=='-'){
      cout << "No" << endl;
      return 0;
    }
    if(s[aa]!='-'){
      cout << "No" << endl;
      return 0;
    }
  }
  for(int i=1; i<bb+1; i++){
    if(s[aa+i]=='-'){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  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++)
int main(){
  int n,k,ans=0;
  cin>>n>>k;
  vector<int>  h(n);
  rep(i,n)
    cin>>h.at(i);
  rep(i,n){
    if(h.at(i)>=k)
      ans++;
}
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <queue>
#include <algorithm>
#include <cstring>

using namespace std;

struct State{
  int tx, ty, kx, ky;
  State(int tx, int ty, int kx, int ky) : tx(tx), ty(ty), kx(kx), ky(ky) {} 
};

#define MAX 51
#define INF 1e9

int H, W, tx, ty, kx, ky;
int field[MAX][MAX];
const int ttx[] = {-1,0,0,1};
const int tty[] = {0,-1,1,0};
const int kkx[] = {1,0,0,-1};
const int kky[] = {0,1,-1,0};

bool inField(int y, int x){
  return 0 <= y && y < H && 0 <= x && x < W;
}

int bfs(){
  bool vis[MAX][MAX][MAX][MAX];
  memset(vis, false, sizeof(vis));
  vis[ty][tx][ky][kx] = true;
  queue<State> Q;
  Q.push(State(tx,ty,kx,ky));
  queue<int> cnt;
  cnt.push(0);

  int res = INF;
  while(!Q.empty()){
    State s = Q.front(); Q.pop();
    int _cnt = cnt.front(); cnt.pop();

    if(_cnt == 100) break;
    if(s.tx == s.kx && s.ty == s.ky){
      res = min(res, _cnt);
      break;
    }

    for(int i = 0 ; i < 4 ; i++){
      int ntx = s.tx + ttx[i], nty = s.ty + tty[i];
      int nkx = s.kx + kkx[i], nky = s.ky + kky[i];

      if(!inField(nty, ntx) || field[nty][ntx] == 1){
        ntx = s.tx, nty = s.ty;
      }
      if(!inField(nky, nkx) || field[nky][nkx] == 1){
        nkx = s.kx, nky = s.ky;
      }

      if(vis[nty][ntx][nky][nkx]) continue;
      vis[nty][ntx][nky][nkx] = true;
      Q.push(State(ntx, nty, nkx, nky));
      cnt.push(_cnt+1);
    }
  }
  return res;
}

int main(){
  while(cin >> W >> H, (W | H)){
    cin >> tx >> ty >> kx >> ky;
    tx--, ty--, kx--, ky--;
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
        cin >> field[i][j];
      }
    }
    int res = bfs();
    if(res == INF){
      cout << "NA" << endl;
    }else{
      cout << res << endl;
    }
  }

  return 0;
}

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


int main()
{
    int N;
    while(cin>>N)
    {
        if(N==0) break;
        vector<int> minis(N,1000000);
        vector<int> maxis(N,0);
        for(int c=0;c<N;c++)
        {
            for(int c2=0;c2<N;c2++)
            {
                int z;
                cin>>z;
                minis[c]=min(minis[c],z);
                maxis[c2]=max(maxis[c2],z);
            }
        }
        for(int c=0;c<N;c++)
            for(int c2=0;c2<N;c2++)
                if(minis[c]==maxis[c2])
                {
                    cout<<minis[c]<<endl;
                    goto end;
                }
        cout<<0<<endl;
        end:;

    }
}

Measured memory_bytes: 1192
#include<iostream>

using namespace std;
typedef long long ll;

int main(){
    ll a, b, k;
    cin >> a >> b >> k;
    if (k <= a)
    {
        a -= k;
    }
    else
    {
        k -= a;
        a = 0;
        b = (b <= k) ? 0 : b - k;
    }
    cout << a << " " << b << 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;

int main() {
  int A, B;
  cin >> A >> B; 
  int ans = 0;
  for(int i = A; i<=B; i++) {
    int x=i;
    int a=0,b=0,c=0,d=0;
    a=x%10;
    x/=10;
    b=x%10;
    x/=100;
    c=x%10;
    x/=10;
    d=x%10;
    if (a==d && b==c) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
  int n,a,b;
  long long x,next,min=0;
  std::cin >> n >> a >> b;
  std::cin >> x;
  for(int i=0;i<n-1;i++){
    next = 0;
    std::cin >> next;
    if(((next-x)*a)< b){
      min += (next-x)*a;
    }else min += b;
    x = next;
  }

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


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

int main() {
  int N;
  cin >> N;
  
  vector<int64_t> L(N+1);
  
  L.at(0)=2; L.at(1)=1;
  
  for(int i=0; i<N-1; i++){
    L.at(i+2)=L.at(i+1)+L.at(i);
  }
  
  cout << L.at(N) << endl;
  
  
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

template<typename T>
struct BIT {
  vector<T> data;
  BIT() {}
  BIT(int n) : data(n+1, 0) {}
  void init(int n) { data.assign(n+1, 0); }
  T sum(int ed) const {
    for(T res(0); ; ed &= ed-1) if(ed) res += data[ed]; else return res;
  }
  void add(int i, const T& x) {
    for(++i; i < (int)data.size(); i += i&-i) data[i] += x;
  }
};

struct L {
  int a, b, c;
};
bool operator<(const L& l1, const L& l2) {
  return - (double)l1.a / l1.b < - (double)l2.a / l2.b;
}

int n;
L ls[100000+10];

pair<double,int> ps[100000+10];
int countCross(double x) {
  REP(i, n) {
    double y = (-ls[i].a*x + ls[i].c) / ls[i].b;
    ps[i] = make_pair(y, i);
  }
  sort(ps, ps + n);
  // 転倒数を求める
  int res = 0;
  BIT<int> bit(n);
  REP(i, n) {
    int cur = ps[i].second;
    res += cur - bit.sum(cur);
    bit.add(cur, 1);
  }
  return res;
}

double calcX(void) {
  // 傾きの降順でソート
  sort(ls, ls + n);
  reverse(ls, ls + n);
  // 20000で1縮むような直線対が多分最左の交点を作るので、1e9には収まるはず
  double left = -1e9;
  double right = 1e9;
  int half = (n*(n-1)/2 + 1) / 2; // 切り上げ
  REP(times, 70) {
    double md = (left + right) / 2;
    int cross = countCross(md);
    if(cross < half) {
      left = md;
    } else {
      right = md;
    }
  }
  return right;
}

int main(void) {
  scanf("%d", &n);
  REP(i, n) {
    scanf("%d%d%d", &ls[i].a, &ls[i].b, &ls[i].c);
  }

  double x = calcX();
  REP(i, n) {
    swap(ls[i].a, ls[i].b);
  }

  double y = calcX();
  printf("%.20f %.20f\n", x, y);

  return 0;
}


Measured memory_bytes: 1536
fn main() {
    proconio::input! {
        h: usize,
        w: usize,
        ss: [proconio::marker::Chars; h],
    }
    let v = ss
        .iter()
        .map(|s| {
            s.iter()
                .map(|c| {
                    if *c == '#' {
                        None
                    } else {
                        Some(std::usize::MAX)
                    }
                })
                .collect::<Vec<_>>()
        })
        .collect::<Vec<_>>();
    let mut max = 0;
    for i in 0..h {
        for j in 0..w {
            if v[i][j] == None {
                continue;
            }
            let mut v = v.clone();
            let mut deque = std::collections::VecDeque::new();
            deque.push_back((i, j, 0));
            while let Some((x, y, dist)) = deque.pop_front() {
                if v[x][y].unwrap() > dist {
                    v[x][y] = Some(dist);
                    for &(new_x, new_y) in &[
                        (x.wrapping_sub(1), y),
                        (x, y.wrapping_sub(1)),
                        (x + 1, y),
                        (x, y + 1),
                    ] {
                        if new_x < h
                            && new_y < w
                            && v[new_x][new_y].is_some()
                            && v[new_x][new_y].unwrap() > dist + 1
                        {
                            deque.push_back((new_x, new_y, dist + 1));
                        }
                    }
                }
            }
            max = std::cmp::max(
                max,
                v.iter()
                    .map(|item| {
                        item.iter()
                            .filter(|x| x.is_some() && x.unwrap() != std::usize::MAX)
                            .map(|x| x.unwrap())
                            .max()
                            .or(Some(0))
                            .unwrap()
                    })
                    .max()
                    .unwrap(),
            );
        }
    }
    println!("{}", max);
}


Measured memory_bytes: 2176
import java.util.*;
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		for(int i = 0; i < n; i++) a[i] = sc.nextInt();
		for(int i = 0; i < n; i++) {
			if(i != 0) System.out.print(" ");
			System.out.print(a[n - i - 1]);
		}
		System.out.println();
	}
}

Measured memory_bytes: 26136
S = input()
S = list(S)

count = 0

if len(S) % 2 == 0:
  number = int(len(S) / 2)
  for i in range(number):
    if S[i] != S[-i - 1]:
      S[-i - 1] = S[i]
      count += 1
else:
  number = int(len(S) / 2 - 0.5)
  for i in range(number):
    if S[i] != S[-i - 1]:
      S[-i - 1] = S[i]
      count += 1
      
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#ifndef ONLINE_JUDGE
#define tr(...) {__l(__LINE__);__f(#__VA_ARGS__, __VA_ARGS__);}
inline void __l(int line) { cerr << "#" << line << ": "; }template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define tr(...)
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
const int N = 5*(int)1e5 + 10;
// make sure N size is correctttt!!!!!!!!!


int n, a[N];

void yes(){
   cout<<"YES"<<endl;
   exit (0);
}
void no(){
   cout<<"NO"<<endl;
   exit (0);   
}

bool check(string s){
   return s == "keyence";
}

int32_t main(){_

   string s;
   cin>>s;

   if(check(s)){
      yes();
   }

   int n = sz(s);
   for (int i = 0; i < n; ++i)
   {
      for (int j = i; j < n; ++j)
      {
         string str = s.substr(0,i) + s.substr(j+1);
         if(check(str))
            yes();
      }
   }

   no();

   //make sure N size is correct!!!!!!!!!
   return 0;
}

Measured memory_bytes: 256
import math
import bisect
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

prime=set([2])
for i in range(3,100001):
    if i%2!=0 and is_prime(i):
        prime.add(i)

sim_prime=[]
for p in prime:
    if (p+1)//2 in prime:
        sim_prime.append(p)
sim_prime.sort()


q=int(input())
ans_list=[]
for i in range(q):
    l,r=map(int,input().split())
    l_idx=bisect.bisect_left(sim_prime,l)
    r_idx=bisect.bisect_left(sim_prime,r)
    if sim_prime[min(r_idx,len(sim_prime)-1)]==r:
        r_idx+=1
    ans_list.append(r_idx-l_idx)

for g in range(len(ans_list)):
    print(ans_list[g])

Measured memory_bytes: 8640
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()

int main() {
    int N; cin >> N;
    ll a[N]; rep(i, N) cin >> a[i];
    ll dp[N + 1][N + 1]; //dp[i][j] : [i, j) において最適な行動におけるスコア
    rep(i, N + 1) dp[i][i] = 0;
    for(int i = 1; i <= N; ++i) {
        for(int j = 0; j + i <= N; ++j) {
            if((N - i) % 2 == 0) {
                dp[j][j + i] = max(dp[j][i + j - 1] + a[i + j - 1], dp[j + 1][i + j] + a[j]);
            }else {
                dp[j][j + i] = min(dp[j][i + j - 1] - a[i + j - 1], dp[j + 1][i + j] - a[j]);
            }
        }
    }
    cout << dp[0][N] << endl;
}


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

int main() {
  int N,M;
  cin >> N >> M;
  
  vector<vector<int>> A(M,vector<int>(2));
  
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < 2; j++) cin >> A.at(i).at(j);
  }
  
  int count = 0;
  for (int k = 1; k <= N; k++) {
    for (int i = 0; i < M; i++) {
      for (int j = 0; j < 2; j++) {
          if (A.at(i).at(j) == k) count++;
      }
    }
    cout << count << endl;
    count = 0;
  }
}

Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int main(){
  int a,b,k;
  cin >> a >> b >> k;
  if(b-a<2*k){
    for(int i=a;i<b+1;i++) cout << i << "\n";
  }
  else{
    for(int i=0;i<k;i++) cout << a+i << "\n";
    for(int i=b-k+1;i<b+1;i++) cout << i << "\n";
  }
  
  
  
  return 0;
}


Measured memory_bytes: 256
import sys
n, m, *ab = map(int, sys.stdin.read().split())
from_1, to_n = set(), set()
for a, b in zip(*[iter(ab)] * 2):
    if a == 1: from_1.add(b)
    if b == n: to_n.add(a)
print('POSSIBLE' if from_1 & to_n else "IMPOSSIBLE")


Measured memory_bytes: 46660
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<limits>
using namespace std;

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

typedef long long ll;

int main() {
	int a[5];
	int k;
	REP(i, 5) cin >> a[i];
	cin >> k;
	if (a[4] - a[0] <= k) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=5e5+50;
int gi(){
    char ch=getchar(); int x=0,q=0;
    while(ch<'0'||ch>'9') q=ch=='-'?1:q,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return q?-x:x;
}
int vis[N],d[N],head[N],nn[N][2],cnt=1,flag;
ll ans;
#define link(u,v) (nn[++cnt][1]=v,nn[cnt][0]=head[u],head[u]=cnt)
void dfs(int x,int op){
    if (vis[x]){
	if (op!=d[x]) flag=1;
	return;
    }
    vis[x]=1,d[x]=op;
    for (int i=head[x]; i; i=nn[i][0])
	dfs(nn[i][1],op^1);
    return;
}
int main(){
    int n=gi(),m=gi(),u,v;
    for (int i=1; i<=m; ++i)
	u=gi(),v=gi(),link(u,v),link(v,u);
    int a=0,b=0,c=0;
    for (int i=1;  i<=n; ++i)
	if (!head[i]) ++a;
    for (int i=1; i<=n; ++i)
	if (head[i]&&!vis[i]){
	    flag=0,dfs(i,0);
	    if (flag) ++b;
	    else ++c;
	}
    cout<<2ll*a*n-1ll*a*a+1ll*b*b+2ll*c*(b+c);
    return 0;
}


Measured memory_bytes: 10240
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
//////////////
int base = 100010;
vector<vector<int>>G(200020);
vector<bool>visit(200020,false);
vector<LL> pari(2, 0);

void f(int node) {
	if (visit[node])return;
	visit[node] = true;
	pari[node >= base]++;
	int len = G[node].size();
	
	for (int i = 0; i < len; ++i) {
		int ter = G[node][i];
		f(ter);
	}
	return;
}

void solve() {
	int N;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		int x, y;
		cin >> x >> y;
		y += base;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	LL ans = 0;
	for (int i = 1; i < 200020; ++i) {
		if (visit[i])continue;
		pari = vector<LL>(2, 0);
		f(i);
		ans += pari[0] * pari[1];
	}
	ans -= N;
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 10112
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n;cin>>n;
    ll ans=LINF;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            ans=min(ans,i+n/i-2);
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int N, Q;
vector<vector<int>> graph(200000);
vector<int> p(200000), x(200000), v(200000);

void DFS(int a, int b) {
  v[b] += v[a];
  for (int c : graph[b]) {
    if (c != a) DFS(b, c);
  }
  return;
}

int main() {
  cin >> N >> Q;
  for (int i = 0; i < N - 1; ++i) {
    int a, b;
    cin >> a >> b;
    graph[a - 1].push_back(b - 1);
    graph[b - 1].push_back(a - 1);
  }
  for (int i = 0; i < Q; ++i) {
    cin >> p[i] >> x[i];
    --p[i];
  }
  
  for (int i = 0; i < Q; ++i) v[p[i]] += x[i];
  for (int c : graph[0]) DFS(0, c);
  
  for (int i = 0; i < N; ++i) {
    cout << v[i];
    if (i != N - 1) cout << " ";
  }
  return 0;
}

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

int main() {
  int N, ans=0;
  cin >> N;
  
  for(int i=1; i<=9; i++) {
    for(int j=1; j<=9; j++) {
      if(i*j == N) {
        ans = 1;
        break;
      }
    }
  }
  
  if(ans == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}



Measured memory_bytes: 3596
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	int out=inf;
	loop(i,1,101){
		int s=0;
		rep(j,n)s+=(i-in[j])*(i-in[j]);
		cmin(out,s);
	}
	cout<<out<<endl;
}









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

int main() {
  
  int ninzu = 0; //合計人数
  int kumi; //入力した組数
  cin >> kumi;
  
  for( int i = 0; i < kumi ; i++ ){
  	int no_start,no_end;
    cin >> no_start >> no_end;
    ninzu += no_end - no_start + 1;
  }
  cout << ninzu << endl;
}

Measured memory_bytes: 256
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k:Integer;
  l:array of Integer;
  s,s123,s1,s2,s3:string;
  al:string = 'abcdefghijklmnopqrstuvwxyz';
  tf,tfl,tfr:Boolean;
begin
  try
    { TODO -oUser -cConsole メイン : ここにコードを記述してください }
    Readln(a);
    //Readln(s);
    count:=0;
    max  :=0;

    if a<1000 then
      Writeln('ABC')
    else
      Writeln('ABD');

    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;


int main(){
  string s;
  cin >> s;
  if(s[0]==s[2]){cout << "Yes" << endl;}else{cout << "No" << endl;}
}

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

using namespace std;

int const NMAX = 100;
char v[1 + NMAX][1 + NMAX];

int main() {

  int n, m;
  char inp;
  cin >> n >> m;
  for(int i = 1;i <= n;i++){
    for(int j = 1;j <= m;j++){
      cin >> v[i][j];
    }
  }
  for(int i = 0;i <= m + 1;i++){
    cout << "#";
  }
  cout << '\n';
  for(int i = 1;i <= n;i++){
    cout << "#";
    for(int j = 1;j <= m;j++){
      //cin >> inp;
      cout << v[i][j];
    }
    cout << "#\n";
  }
  for(int i = 0;i <= m + 1;i++){
    cout << "#";
  }
  return 0;
}


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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int left = a + b;
    int right = c + d;

    if (left > right) cout << "Left" << endl;
    else if (left < right) cout << "Right" << endl;
    else cout << "Balanced" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int H, W;
    cin >> H >> W;
    vector<int> cnt(26, 0);

    rep(i, H) {
        rep(j, W) {
            char a;
            cin >> a;
            cnt[a - 'a']++;
        }
    }

    bool flag = true;
    if (H % 2 == 0 && W % 2 == 0) {
        rep(i, 26) {
            if (cnt[i] % 4 != 0) {
                flag = false;
                break;
            }
        }
    }
    else if (H % 2 == 1 && W % 2 == 1) {
        int one = 0, two = 0;
        rep(i, 26) {
            if (cnt[i] % 4 == 3) {
                flag = false;
                break;
            }
            else if (cnt[i] % 4 == 1) {
                one++;
            }
            else if (cnt[i] % 4 == 2) {
                two++;
            }
        }
        if (one != 1) flag = false;
        if (two > (H - 1) / 2 + (W - 1) / 2) flag = false;
    }
    else {
        if (W % 2 == 0) swap(H, W);
        int  two = 0;
        rep(i, 26) {
            if (cnt[i] % 4 == 3 || cnt[i] % 4 == 1) {
                flag = false;
                break;
            }
            else if (cnt[i] % 4 == 2) {
                two++;
            }
        }
        if (two > H / 2) flag = false;
    }

    cout << (flag ? "Yes" : "No") << 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;
using ll = long long;
using pii = pair<int,int>;

int main(){
    int n;
    cin >> n;
    int s = 111;
    for(int i = 1;i<10;i++){
        if(s*i >= n){
            cout << s*i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))
ans = 0
for i in range(0, N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                if L[i]+L[j] > L[k] and L[j]+L[k] > L[i] and L[k]+L[i] > L[j]:
                    ans += 1
print(ans)


Measured memory_bytes: 9176
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
	int H, W = 0;
	int i, j;
	while (1){
		cin >> H >> W;
		if (H == 0 && W == 0){
			break;
		}
		for (i = 0; H > i; i++){
			for (j = 0; W > j; j++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,n;
  cin >> a >> b;
  if (a > b) {
    n += a;
    a--;
    n += a;
  } else if (b > a) {
    n += b;
    b--;
    n += b;
  } else {
    n += a;
    n += b;
  }
  cout << n << endl;
}

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

using namespace std;

char a[11][11];

int main () {
	int n, m;
	cin >> n >> m;
	for (int i = 1;i <= n;i ++) {
		for (int j = 1;j <= m;j ++) {
			cin >> a[i][j];
			if (a[i][j] != '#' || (i == 1 && j == 1)) continue;
			if (a[i - 1][j] == '#' && a[i][j - 1] == '#') {
				cout << "Impossible";
				return 0;
			}
			if (a[i - 1][j] != '#' && a[i][j - 1] != '#') {
				cout << "Impossible";
				return 0;
			}
		}
	}
	for (int i = 1;i <= n;i ++) {
		for (int j = 1;j <= m;j ++) {
			if (a[i][j] != '#') continue;
			if (a[i + 1][j] == '#' && a[i][j + 1] == '#') {
				cout << "Impossible";
				return 0;
			}
		}
	}
	if (a[n][m] != '#') cout << "Impossible";
	else cout << "Possible";
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <limits.h>
#include <map>
#include <numeric>

namespace test {
	std::string to_string (char val) {
		return std::string (1, val);
		// return std::string{val};
	}
	//if( str.find ("r") != string::npos)
}

using namespace std;
typedef long long int llint;

int main (void) {
	int n, m; cin >> n >> m;
	vector<pair<int, int>> ab;
	vector<pair<int, int>> cd;
	int x,y;
	for (int i = 0; i < n; i++) {
		cin >> x >> y;
		ab.push_back(make_pair(x,y));
	}
	for (int i = 0; i < m; i++) {
		cin >> x >> y;
		cd.push_back (make_pair (x, y));
	}
	pair<int,int> student;
	pair<int,int> marker;
	int min = INT_MAX;
	int result;
	for (int i = 0; i < n; i++) {
		student = ab[i];
		for (int j = 0; j < m; j++) {
			marker = cd[j];
			int tmp = abs(student.first - marker.first);
			tmp += abs(student.second - marker.second);
			if (tmp < min) {
				min = tmp;
				result = j + 1;
			}
		}
		cout << result << endl;
		min = INT_MAX;
	}
	return 0;
}

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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    u32 N;
    cin >> N;
    u32 value = N % 10;
    switch (value) {
    case 2:case 4: case 5: case 7: case 9:
        cout << "hon" << endl;
        break;
    case 0:case 1: case 6: case 8:
        cout << "pon" << endl;
        break;
    case 3:
        cout << "bon" << endl;
        break;
    }
}


Measured memory_bytes: 3648
#include <stdio.h>

int main(void){
        int n,a,b,c;
        int count=0;
        scanf("%d", &n);
        scanf("%d", &a);
        scanf("%d", &b);
        for(int i=1; i<=n ;i++){
                int sum=0;
                int j = i;
                while(j!=0){
                        sum+=j%10;
                        j/=10;
                }
                if(a <= sum && sum <=b){
                        //printf("%d ",sum);
                        count+=i;
                }

        }
        printf("%d",count);

        return 0;
}


Measured memory_bytes: 128
import java.util.*;

class Main{
	public static void main(String[] $){
		System.err.println();
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int[]l=new int[n];
		Arrays.setAll(l,i->s.nextInt());
		Arrays.sort(l);

		int p=0;
		for(int i=0;i<n-2;i++)
			for(int j=i+1;j<n-1;j++)
				for(int k=j+1;k<n;k++)
					if(l[j]<l[k]+l[i]&&l[k]<l[i]+l[j])
						++p;

		System.out.println(p);
	}
}


Measured memory_bytes: 27620
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	int ans = 0;
	char a, b, c;
	cin >> a >> b >> c;
	if (a == '1')ans++;
	if (b == '1')ans++;
	if (c == '1')ans++;
	print(ans);





	return 0;
}

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

int main()
{
    int a,b,c,t;
    cin >> a >> b >> c;
    if(a > b)t = a - b;
    if(c > t)cout << c-t << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

def main():
    inputslen = int(sys.stdin.readline().rstrip())
    inputs= sys.stdin.readline()

    sortvalue = [int(i) for i in inputs.split()]
    for i in range(1, inputslen):
        printvalue = map(str, sortvalue)
        print(' '.join(printvalue))

        compvalue = sortvalue[i]
        j = i - 1
        while j >= 0 and sortvalue[j] > compvalue:
            sortvalue[j+1] = sortvalue[j]
            j -= 1
        sortvalue[j+1] = compvalue

    printvalue = map(str, sortvalue)
    print(' '.join(printvalue))

if __name__ == '__main__':
    main()


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int>x(100);
  for(int i=0; i<N;i++){
  cin >>x.at(i);
  }
  int sum,small;small=10000000;
  for(int i=1;i<=100;i++){
    sum=0;
  	for(int j=0;j<N;j++){
    sum+= (x.at(j)-i)*(x.at(j)-i);
    }
    small=min(sum,small);
  
  }
  cout <<small<<endl;
  
  
  
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=[0]*(n+1)
b[0]=abs(a[0])
b[-1]=abs(a[-1])
c=b[0]+b[-1]
for i in range(n-1):
  b[i+1]=abs(a[i+1]-a[i])
  c+=b[i+1]
for i in range(n):
  if i==0:
    if 0<=a[i]<=a[i+1] or a[i+1]<=a[i]<=0:
      print(c)
    else:
      print(c-b[i]-b[i+1]+abs(a[i+1]))
    continue
  if i==n-1:
    if a[i-1]<=a[i]<=0 or 0<=a[i]<=a[i-1]:
      print(c)
    else:
      print(c-b[i]-b[i+1]+abs(a[i-1]))
    continue
  if a[i-1]<=a[i]<=a[i+1] or a[i+1]<=a[i]<=a[i-1]:
    print(c)
  else:
    print(c-b[i]-b[i+1]+abs(a[i-1]-a[i+1]))

Measured memory_bytes: 65032
#include <iostream>
using namespace std;
int main() {
    int A, B, C;
    cin >> A >> B >> C;
    
    bool a = A==7 && B==5 && C==5;
    bool b = A==5 && B==7 && C==5;
    bool c = A==5 && B==5 && C==7;
    if (a || b || c)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
	return 0;
}

Measured memory_bytes: 256