akhauriyash/Code-Regression huggingface dataset:
#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define repp(i, n) rep(i, n)
#define reppp(i, n) repp(i, n)
#define rrepp(i, n) rrep(i, n)
#define repss(i, n) reps(i, n)
#define repcc(i, n) repc(i, n)
#define repii(i, a, b) repi(i, a, b)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n;
  while (cin >> n) {
    vi32 ans;
    rep(i, 15) {
      if (n & bit(i)) ans.push_back(power(2, i));
    }
    cout << ans << '\n';
  }
}



Measured memory_bytes: 3128
#include <iostream>
#include <algorithm>
#include <string>
// #include <vector>
using namespace std;

int getSumOfDigits(int n){
  int sum = 0;
  while(n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main()
{
  int N, A, B;
  cin >> N >> A >> B;

  int ans = 0;
  for (int i = 1; i <= N; ++i){
     int sum = getSumOfDigits(i);
     if(A <= sum && sum <= B) {
       ans += i;
     }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

int N;
int a[200010];
int b[200010];
bool c[200010] = {};

int main() {
	cin >> N;
	REP(i, N) cin >> a[i];
	int M = 0;
	
	for (int i = N - 1; i >= 0; i--) {
		//まず前にないかかくにん 
		
		int tmp = i + 1;
		int sum = 0;
		

		while (true) {
			if (tmp <= N) {
				sum += a[tmp - 1];
//				cout << "tmp:" << tmp << " a[tmp - 1]:" << a[tmp - 1] << endl;
				tmp += i + 1;
			}
			else break;
		}
		a[i] = sum % 2;
		if (a[i] == 1) {
			c[i] = true;
			M++;
		}
//		cout << endl;
	}

	cout << M << endl;
	REP(i, N) {
		if (c[i]) {
			cout << i + 1 << endl;
		}
	}
}

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

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    float v[] = new float[n];
    for (int i = 0; i < n; i++) {
      v[i] = sc.nextFloat();
    }

    Arrays.sort(v);

    float avg = v[0];
    for (int i = 1; i < n; i++) {
      avg = (avg + v[i]) / 2;
    }
    System.out.println(avg);
  }
}


Measured memory_bytes: 23380
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()),(x.end())
#define sz(x)  ((ll)x.size())
#define FAST_IO ios_base :: sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
using namespace std;
#ifdef LOCAL
#include "uj.h"
#endif

const ll oo = 1e16;
const int maxn = 1e5 + 100;

int N;
void test_case(){
	cin >> N;
	int a[N],b[N],c[N];
	for(int i = 0;i<N;++i)
		cin  >> a[i] >> b[i] >> c[i];
	
	ll dp[maxn][3];
	memset(dp,0,sizeof(dp));
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	
	for(int i = 1;i<N;++i){
		dp[i][0] = max({dp[i][0],dp[i-1][1],dp[i-1][2]}) + a[i];
		dp[i][1] = max({dp[i][1],dp[i-1][0],dp[i-1][2]}) + b[i];
		dp[i][2] = max({dp[i][2],dp[i-1][0],dp[i-1][1]}) + c[i];
	}
	
	cout << max({dp[N-1][1],dp[N-1][0],dp[N-1][2]});
		 
	
}

	





int main(){
	FAST_IO;
	int tt;
	//cin>>tt;
	tt = 1;
	while(tt--){
		test_case();
	}
#ifndef ONLINE_JUDGE
 	cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 7100
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n,m; cin>>n>>m;
	const int need[10]={0,2,5,5,4,5,6,3,7,6};
	VI a(m); rep(i,m) cin>>a[i]; sort(RALL(a));
	int dp[n+5]; fill(dp,dp+n+5,-INF); dp[0]=0;
	rep(i,n){
		if(dp[i]==-INF) continue;
		rep(j,m){
			if(i+need[a[j]]>n) continue;
			chmax(dp[i+need[a[j]]],dp[i]+1);
		}
	}
	// rep(i,n+1) cerr<<dp[i]<<' ';
	// cerr<<endl;
	int keta=dp[n];
	int cnt=n;
	REP(i,keta){
		rep(j,m){
			if(cnt-need[a[j]]<0) continue;
			if(dp[cnt-need[a[j]]]==i){
				cout<<a[j]; cnt-=need[a[j]]; j=m;
			}
		}
	}
cout<<endl;


	return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  string ans="";
  if(a>0){
    ans = "Positive";
  }else if(b>=0){
    ans = "Zero";
  }else{
    int n=b-a;
    if(n%2==1)
      ans = "Positive";
    else
      ans = "Negative";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3572
import math
a, b, x = map(int, input().split())
A = math.degrees(math.atan((2*(a*a*b - x) / a/a/a)))
B = 90 - math.degrees(math.atan(x / (0.5 *(b*b)*a)))
if a * math.tan(math.radians(A)) < b:
  print(math.degrees(math.atan((2*(a*a*b - x) / a/a/a))))
else:
  print(90 - math.degrees(math.atan(x / (0.5 *(b*b)*a))))
  

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

using Size = int;
template<typename T> class Compression {
 public:
  Compression(const set<T>& list) : value_(begin(list), end(list)) {}
  Size size() const {return value_.size();}
  Size index(const T& v) const {return lower_bound(begin(value_), end(value_), v) - begin(value_);}
  T operator[](const Size i) const {return value_.at(i);}
 private:
  std::vector<T> value_;
};

int main() {
  using LL = long long;
  struct Segment {LL x, m, y;};
  const LL INF = 9e18;

  int N, M;
  cin >> N >> M;
  vector<Segment> V(N), H(M);
  for(auto p: {&V, &H}) for(auto& s: *p) cin >> s.x >> s.m >> s.y;

  set<LL> X = {-INF, 0, INF};
  set<LL> Y = {-INF, 0, INF};
  for(auto& s: V) {
    X.emplace(s.x);
    X.emplace(s.m);
    Y.emplace(s.y);
  }
  for(auto& s: H) {
    X.emplace(s.x);
    Y.emplace(s.m);
    Y.emplace(s.y);
  }
  Compression CX(X), CY(Y);

  // (0,-1) -> (-1,0) -> (0,1) -> (1,0)
  enum {L, U, R, D};
  const int NEXT[5] = {0, -1, 0, 1, 0};
  const int SX = CX.size() - 1;
  const int SY = CY.size() - 1;
  vector<vector<vector<bool>>> ng(4, vector<vector<bool>>(SX, vector<bool>(SY)));
  for(const auto& s: V) for(auto x=CX.index(s.x), y=CY.index(s.y); x<CX.index(s.m); ++x) ng[R][x][y-1] = ng[L][x][y] = true;
  for(const auto& s: H) for(auto x=CX.index(s.x), y=CY.index(s.m); y<CY.index(s.y); ++y) ng[D][x-1][y] = ng[U][x][y] = true;

  vector<vector<bool>> used(SX, vector<bool>(SY));
  struct Point {
    int x, y;
    Point(int x, int y) : x(x), y(y) {}
  };
  queue<Point> q;
  q.emplace(CX.index(0), CY.index(0));
  LL area = 0;
  while(!q.empty()) {
    auto cur = q.front();
    q.pop();
    if(used[cur.x][cur.y]) continue;
    used[cur.x][cur.y] = true;
    if(cur.x==0 || cur.x==SX-1 || cur.y==0 || cur.y==SY-1) {
      cout << "INF" << endl;
      return 0;
    }
    auto lx = CX[cur.x], hx = CX[cur.x+1];
    auto ly = CY[cur.y], hy = CY[cur.y+1];
    area += (hx-lx) * (hy-ly);
    for(auto k=0; k<4; ++k) if(!ng[k][cur.x][cur.y]) {
      Point nex(cur.x+NEXT[k], cur.y+NEXT[k+1]);
      if(!used[nex.x][nex.y]) q.emplace(nex);
    }
  }
  cout << area << endl;
}


Measured memory_bytes: 10236
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    string S;
    cin >> S;
    int N = S.size();
    int res = 0;
    REP(i, N) {
        if (S[i] == '+') {
            res++;
        } else {
            res--;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

lim = M+10  # 必要そうな階乗の限界を入れる
fact = [1] * (lim+1)
fact_inv = [1] * (lim+1)
for n in range(1, lim+1):
    fact[n] = (fact[n-1] * n) % mod
fact_inv[lim] = pow(fact[lim], mod-2, mod)
for n in range(lim, 0, -1):
    fact_inv[n-1] = (n * fact_inv[n]) % mod
def C(n, r):
    return (((fact[n] * fact_inv[r]) % mod) * fact_inv[n-r]) % mod

def P(n, r):
    return fact[n]*fact_inv[n-r]%mod

ans = 0
for k in range(N+1):
    ans += (-1)**(k%2) * C(N, k) * P(M-k, N-k)
    ans %= mod

ans *= P(M, N)
print(ans%mod)


Measured memory_bytes: 49432
package main

import (
	"fmt"
)

func gcd(m, n int) int {
	if m < n {
		m, n = n, m
	}
	if n == 0 {
		return m
	}
	return gcd(n, m%n)
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}

	ans := a[0]
	for i := 1; i < len(a); i++ {
		ans = gcd(ans, a[i])
	}
	fmt.Println(ans)
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vector<vector<int>> g(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--,b--;
		g[a].push_back(b);
	}
	vector<int> ans(n+1);
	auto bfs=[&](int v){
		queue<int> que;
		vector<int> dist(n,INF),pre(n,-1);
		que.push(v);
		dist[v]=0;
		while(!que.empty()){
			int now=que.front();
			que.pop();
			for(auto itr:g[now]){
				if(dist[itr]!=INF) continue;
				dist[itr]=dist[now]+1;
				pre[itr]=now;
				que.push(itr);
			}
		}
		int cnt=INF,st;
		rep(i,n){
			if(i==v) continue;
			for(auto itr:g[i]){
				if(itr==v){
					if(chmin(cnt,dist[i])){
						st=i;
					}
				}
			}
		}
		if(cnt==INF){
			vector<int> ret(n+1);
			return ret;
		}
		vector<int> ret;
		while(st!=-1){
			ret.push_back(st);
			st=pre[st];
		}
		return ret;
	};
	rep(i,n){
		vector<int> now=bfs(i);
		if(ans.size()>now.size()) ans=now;
	}
	if(ans.size()==n+1){
		cout<<-1<<endl;
		return 0;
	}
	cout<<ans.size()<<endl;
	for(auto v:ans){
		cout<<v+1<<endl;
	}
}

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

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

int main() {
  int N, countg, countw, countp, county;
  string s[100];
  cin >> N ;
  countg = 0;
  countw = 0;
  countp = 0;
  county = 0;
  rep (i, N) {
   cin >> s[i];
   if ( s[i] == "G" ) {
      countg ++;
   }
    if ( s[i] == "W" ) {
      countw ++;
   }
    if ( s[i] == "P" ) {
      countp ++;
   }
    if ( s[i] == "Y" ) {
      county ++;
   }
  }
  
  if (countg == 0 || countw == 0 || countp == 0 || county == 0) {
    cout << "Three" << endl;
  }
  
  else {
    cout << "Four" << endl;
  } 
  return 0;
}




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

#define pb push_back
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000

using namespace std;

typedef long long ll;   
typedef double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<int> vi;

int main(){
    ll a, b, n;

    cin>>a>>b>>n;

    if(n < b){
        cout<<(a*n)/b<<endl;
    }
    else{
        cout<<(a*(b-1))/b<<endl;
    }
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


Measured memory_bytes: 3784
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
#define U(v) cerr << #v << ": " << (v) << endl

struct SegmentTree2 {

    long long sum[1 << 18];
    long long lazy[1 << 18];
    int size;

    void init(int size) {
        this->size = 1 << (int)ceil(log2(size));
    }

    void hoge(int k, long long v) {
        lazy[k] += v / 2;
        sum[k] += v / 2;
    }

    void propagate(int k) {
        if (lazy[k]) {
            if (k < size - 1) {
                hoge(k * 2 + 1, lazy[k]);
                hoge(k * 2 + 2, lazy[k]);
            }
            lazy[k] = 0;
        }
    }

    void add(int a, int b, int v, int k, int l, int r) {
        if (b <= l || r <= a) {
            return;
        }
        if (a <= l && r <= b) {
            hoge(k, v * (r - l) * 2);
            return;
        }
        propagate(k);
        add(a, b, v, k * 2 + 1, l, (l + r) / 2);
        add(a, b, v, k * 2 + 2, (l + r) / 2, r);
        sum[k] = sum[k * 2 + 1] + sum[k * 2 + 2];
    }

    void add(int a, int b, int v) {
        add(a, b, v, 0, 0, size);
    }

    long long get(int a, int b, int k, int l, int r) {
        if (b <= l || r <= a) {
            return 0;
        }
        if (a <= l && r <= b) {
            return sum[k];
        }
        propagate(k);
        long long vl = get(a, b, k * 2 + 1, l, (l + r) / 2);
        long long vr = get(a, b, k * 2 + 2, (l + r) / 2, r);
        return vl + vr;
    }

    long long get(int a, int b) {
        return get(a, b, 0, 0, size);
    }
} st;

int main() {
    int n, q;
    cin >> n >> q;
    st.init(n);
    while (q--) {
        int i, s, t, x;
        cin >> i >> s >> t;
        --s;
        if (i) {
            cout << st.get(s, t) << endl;
        } else {
            cin >> x;
            st.add(s, t, x);
        }
    }
    return 0;
}

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

using ll = long long;

#define dbg(x) cerr << "[" #x << " : " << x << "]\n"

const int mod = (int)1e9+7;

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

int main()
{
    int h, w;
    scanf("%d%d", &h, &w);
    char grid[h+1][w+1];
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            scanf(" %c", &grid[i][j]);
        }
    }
    int ans = 0;
    for(int row = 0; row < h; row++) {
        for(int col = 0; col < w; col++) {
            int dist[h+1][w+1];
            int vis[h+1][w+1];
            memset(dist, 0, sizeof(dist));
            memset(vis, 0, sizeof(vis));
            queue<pair<int, int>> q;
            q.push({row, col});
            while(!q.empty()) {
                int x, y;
                tie(x, y) = q.front();
                q.pop();
                vis[x][y] = 1;
                if(grid[x][y] == '#') continue;
                for(int i = 0; i < 4; i++) {
                    int tx = x + dx[i];
                    int ty = y + dy[i];
                    if(tx >= h || tx < 0 || ty >= w || ty < 0) 
                        continue;
                    if(grid[tx][ty] == '.' && !vis[tx][ty]) {
                        if(dist[tx][ty] == 0) {
                            dist[tx][ty] = dist[x][y] + 1;
                            ans = max(ans, dist[tx][ty]);
                            q.push({tx, ty});
                        }
                    }
                }
            }
        }
    }
    printf("%d\n", ans);
}


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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  LL N;
  cin >> N;
  vector<LL> A(N);
  REP(i,N)
  {
    cin >> A[i];
  }

  SORT(A);

  LL max = 0;

  vector<LL> plus_or_zero;
  vector<LL> minus;

  for (LL i = 1; i <= N - 2;++i){
    max += abs(A[i]);
    if(A[i]>=0){
      plus_or_zero.push_back(A[i]);
    }else{
      minus.push_back(A[i]);
    }
  }
  max += A[N - 1];
  max -= A[0];

  cout << max << endl;

  LL prev = A[0];

  REP(i,plus_or_zero.size()){
    cout << prev SP plus_or_zero[i] << endl;
    prev = prev - plus_or_zero[i];
  }

  cout << A[N - 1] SP prev << endl;

  prev = A[N - 1] - prev;

  REP(i,minus.size()){
    cout << prev SP minus[i] << endl;
    prev = prev - minus[i];
  }
}

// a-(b-c)-(d-c)


// (a-((b-c)-d))


Measured memory_bytes: 3572
#include<iostream>
using namespace std;
int score[200000];//={0};
int main(){
	int N,K;
  	scanf("%d %d",&N,&K);
  	for(int i=0;i<N;i++){
    	scanf("%d",&score[i]);
    }
  	for(int i=0;i<N-K;i++){
    	printf(score[i+K]>score[i]?"Yes\n":"No\n");
    }
	return 0;
}

Measured memory_bytes: 4000
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int a = scanner.nextInt();
			String b = scanner.next();
			int c = scanner.nextInt();
			if (b.equals("?"))
				break;
			int e = 0;
			if (b.equals("+"))
				e = a + c;
			else if (b.equals("-"))
				e = a - c;
			else if (b.equals("*"))
				e = a * c;
			else
				e = a / c;
			System.out.println(e);

		}
	}
}

Measured memory_bytes: 17992
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
	string s;
	cin >> s;
	int ans=700;
	for(int i=0;i<3;i++){
		if(s[i]=='o')ans+=100;	
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
typedef long long int LL;
#define fr(i,p,n) for(LL i=p;i<n;i++)
#define fr1(i,p,n) for(LL i=p;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(10) << std::fixed;

using namespace std;
 
int main()
{
        LL n,k;
        cin>>n>>k;
        LL a[n];
        fr(i,0,n) cin>>a[i];
        LL ans=0;
        sort(a,a+n);
        fr(i,0,k)
        {
          ans+=a[i];
        }
         cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3640
p=print
while 1:
    m,f,r=map(int,input().split())
    x=m+f
    if m==f==r==-1:break
    elif m==-1 or f==-1 or x<30:p('F')
    elif x>=80:p('A')
    elif 65<=x<80:p('B')
    elif 50<=x<65 or r>=50:p('C')
    else:p('D')


Measured memory_bytes: 5596
#include<stdio.h>
int main(){
  int a;
  int n[101];
  double ans = 0.0;

  scanf("%d\n",&a);

  for (int i = 0; i < a; i++) {
    scanf("%d",&n[i]);
    ans += 1.0 / n[i];
  }
  printf("%f\n",1.0 / ans);
  return 0;
}


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

int main(){
    int N,M,sum=0,n=0;
    cin>>N>>M;
    vector<int>A(N);
    for (int i=0;i<N;i++){
        cin>>A.at(i);
        sum+=A.at(i);
    }
    for (int i=0;i<N;i++){
        if (!((A.at(i)*4*M)<sum)){
            n++;
        }
    }
    if (n>M-1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

}


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    string s;
    cin>> s;

    if( count (s.begin(), s.end(),s[0])== 2  && count (s.begin(), s.end(),s[1])== 2  && count (s.begin(), s.end(),s[2])== 2  && count (s.begin(), s.end(),s[3])== 2  )
cout << "Yes";
else
    cout << "No";
nl;

    return 0;
}




Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

type UnionFind struct {
	par []int
	r   []int
}

func newUnionFind(N int) *UnionFind {
	u := new(UnionFind)
	u.par = make([]int, N)
	u.r = make([]int, N)
	for i := 0; i < N; i++ {
		u.par[i] = i
		u.r[i] = 1
	}
	return u
}

func (p *UnionFind) root(x int) int {
	if p.par[x] == x {
		return x
	}
	return p.root(p.par[x])
}

func (p *UnionFind) unite(x, y int) {
	x = p.root(x)
	y = p.root(y)
	if p.r[x] < p.r[y] {
		p.par[x] = y
	} else {
		p.par[y] = x
		if p.r[x] == p.r[y] {
			p.r[x]++
		}
	}
}

func (p *UnionFind) same(x, y int) bool {
	return p.root(x) == p.root(y)
}

func main() {
	sc.Split(bufio.ScanWords)
	N, K, L := getInt(), getInt(), getInt()

	u0 := newUnionFind(N)
	u1 := newUnionFind(N)
	for i := 0; i < K; i++ {
		x, y := getInt()-1, getInt()-1
		u0.unite(x, y)
	}

	for i := 0; i < L; i++ {
		x, y := getInt()-1, getInt()-1
		u1.unite(x, y)
	}

	type key struct {
		x, y int
	}
	m := make(map[key]int, N*2)

	for i := 0; i < N; i++ {
		k := key{u0.root(i), u1.root(i)}
		m[k]++
	}

	wr := bufio.NewWriter(os.Stdout)

	for i := 0; i < N; i++ {
		k := key{u0.root(i), u1.root(i)}
		if i != N-1 {
			fmt.Fprintf(wr, "%d ", m[k])
		} else {
			fmt.Fprintf(wr, "%d\n", m[k])
		}
	}
	wr.Flush()
}


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

using namespace std;
mt19937_64 rng(58);

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n, q;
    cin >> n;
    ll sum = 0;
    map<int, int> count;
    for (int i=0; i<n; i++) {
        int x;
        cin >> x;
        count[x]++;
        sum += x;
    }
    cin >> q;
    for (int i=0; i<q; i++) {
        int b, c;
        cin >> b >> c;
        int x = count[b];
        count[b] = 0;
        count[c] += x;
        sum = sum + (c - b) * x;
        cout << sum << endl;
    }
}

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

int main() {
  int A, B, H, M;
  double C, d;

  cin >> A;
  cin >> B;
  cin >> H;
  cin >> M;

  d = abs(60 * H - 11 * M) / 30.0;

  if (d == 0) {
    cout << abs(B - A) << endl;
  } else if (d == 1) {
    cout << A + B << endl;
  } else if (d < 1) {
    C = sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * cos((abs(60 * H - 11 * M) * 3.1415926535897932384626433832795) / 360));
    cout << fixed << setprecision(9) << C << endl;
  } else if (1 < d) {
    C = sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * cos((abs(720 - 60 * H + 11 * M) * 3.1415926535897932384626433832795) / 360));
    cout << fixed << setprecision(9) << C << endl;
  }
}


Measured memory_bytes: 4128
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-8;
using vi = vector <int>;
using vvi = vector <vi>;

signed main() {
	int n;
	while(cin >> n, n){
		pair <int, int> mp[n];
		mp[0] = {0, 0};
		rep (i, n - 1) {
			int a, b;
			cin >> a >> b;
			mp[i + 1] = mp[a];
			if(b == 0)
				mp[i + 1].first--;
			else if (b == 1)
				mp[i + 1].second--;
			else if (b == 2)
				mp[i + 1].first++;
			else
				mp[i + 1].second++;
		}
		int macsx = -INF, minix = INF, macsy = -INF, miniy = INF;
		rep (i, n) {
			macsx = max(macsx, mp[i].first);
			macsy = max(macsy, mp[i].second);
			minix = min(minix, mp[i].first);
			miniy = min(miniy, mp[i].second);
		}
		cout << abs(macsx - minix) + 1 << " " << abs(macsy - miniy) + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3076
# Q_A
N = int(input())
A = list(map(int, input().split()))

# 重複数える
b = A[0]
cnt = 0
D = []
for i in range(N):
    if b != A[i]:
        D.append(cnt)
        b = A[i]
        cnt = 1
    else:
        cnt += 1
        b = A[i]        
D.append(cnt)
b = A[i]

re = 0
for val in D:
    re += val // 2

print(re)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] params = sc.nextLine().split(" ");
        long n = Long.parseLong(params[0]);
        long a = Long.parseLong( params[1]);
        long b = Long.parseLong( params[2]);

        long ab = n / ( a + b );
        long amari = n % ( a + b );

        System.out.println( a * ab + ( amari > a ? a : amari ) );

    }

}



Measured memory_bytes: 23508
#include <iostream>
#include <sstream>
#include <string>

using namespace std;

namespace {

std::string Join(const int* A, int n) {
  std::stringstream ss;
  if (n > 0)
    ss << A[0];
  for (int i = 1; i < n; ++i) {
    ss << " ";
    ss << A[i];
  }
  return ss.str();
}

void InsertionSort(int* A, int n) {
  cout << Join(A, n) << endl;
  for (int i = 1; i < n; ++i) {
    const int v = A[i];
    int j = i - 1;
    for (; j >= 0 && A[j] > v; --j) {
      A[j + 1] = A[j];
    }
    A[j + 1] = v;

    cout << Join(A, n) << endl;
  }
}

}  // namespace

int main() {
  int A[100];
  int n;

  cin >> n;
  for (int i = 0; i < n; ++i)
    cin >> A[i];
  InsertionSort(A, n);
  return 0;
}

Measured memory_bytes: 3124
def mulit(a):
  a_copy = list(a)
  return len(a) == len(set(a_copy))
def isTriangle(x):
  return x[0] + x[1] > x[2]

N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
a_len = len(A)
answer = []
for i in range(0, a_len-2):
  for j in range(i+1, a_len-1):
    for k in range(j+1, a_len):
      answer.append([A[i], A[j], A[k]])
      
answer = [i for i in answer if mulit(i)]
answer = [i for i in answer if isTriangle(i)]
answer_len = len(answer)
print(f"{answer_len}")


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

int main() {
    int n;
    int a;
    int ans[200001] = {0};
    cin >> n;
    for(int i = 2; i <= n; i++){
        cin >> a;
        ans[a]++;
    }
    for(int i = 1; i <= n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

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

int N;
bool prime[1001];
int cnt[1001];
int dp[333][333];

void solve()
{
	memset(prime,true,sizeof(prime));
	prime[0]=prime[1]=false;
	for(int i=2;i<=1000;++i)if(prime[i]){
		for(int j=i*2;j<=1000;j+=i) prime[j]=false;
	}
	for(int i=2;i<=N;++i)if(prime[i]){
		int x = N;
		while(x >= i){
			cnt[i] += x / i;
			x /= i;
		}
	}
	dp[1][1]=1;
	for(int i=1;i<=N;++i)for(int j=0;j<=75;++j){
		for(int k=1;k<=cnt[i]+1;++k)if(j*k<=75){
			dp[i+1][j*k]+=dp[i][j];
		}
	}
	cout << dp[N][75] << '\n';
}

int main()
{
	cin >> N;
	solve();
	return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define N 1000050
using namespace std;
char s[N];
const char ch[] = {'N','E','W','S'};
int n,F[N];
int main() {
	scanf("%s",s+1);
	n = strlen(s+1);
	for (int i=1;i<=n;i++)
		for (int j=0;j<4;j++) 
			if (s[i] == ch[j]) F[j] = 1;
	
	if ((F[0]^F[3]) || (F[1]^F[2]))
		puts("No");
	else
		puts("Yes");
	return 0;
}

Measured memory_bytes: 2304
#include <stdio.h>
#include <string.h>

int main(void) {

  char s[200001];
  scanf("%s", s);
  int length = strlen(s);
  int count_A = 0;
  long operation = 0;
  for (int i = 0; i < length; i++) {
    if (s[i] == 'A') {
      count_A++;
    } else if (s[i] == 'B' && s[i+1] == 'C') {
      operation += count_A;
      i++;
    } else {
      count_A = 0;
    }
  }
  printf("%ld\n", operation);

  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mx 100000000000000000
int main()
{
    ll n,k;
    cin>>n>>k;
    ll a[n+1];
    vector<ll>dp(n+5,mx);
    dp[0]=0;
    for(ll i=0; i<n; i++)
        scanf("%lld",&a[i]);
    for(ll i=1; i<n; i++)
    {
        ll ind=max(1LL*0,i-k);
        for(ll j=ind; j<i; j++)
        {
            dp[i]=min(abs(a[i]-a[j])+dp[j],dp[i]);
        }
    }
    cout<<dp[n-1]<<endl;



}



Measured memory_bytes: 1792
/*g++ main.cpp -o main.out*/
/*./main.out*/

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

#define LL long long
#define ll long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int m[105][105];

int main()
{
    int a,b;
    cin>>a>>b;
    rer(i,51,100)rer(j,1,100)m[i][j]=1;
    a--,b--;

    for(int i=1; i<=50&&a>0; i+=2)
    {
        for(int j=1; j<=100; j+=2)
        {
            m[i][j]=1;
            a--;
            if(a<=0)
                break;
        }
        if(a<=0)
            break;
    }
    for(int i=52; i<=100&&b>0; i+=2)
    {
        for(int j=1; j<=100; j+=2)
        {
            m[i][j]=0;
            b--;
            if(b<=0)
                break;
        }
        if(b<=0)
            break;
    }
    cout<<100<<' '<<100<<endl;
    rer(i,1,100)
    {
        rer(j,1,100)
        {
            if(m[i][j]==1)cout<<'.';
            else cout<<'#';
        }
        cout<<endl;
    }
    return 0;
}











//









Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	var t int
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
		t += a[i]
	}

	f := func (i int) bool {
		return float64(i) < (float64(t) / (float64(4 * m)))
	}

	var c int
	for _, v := range a {
		if !f(v) {
			c++
		}
	}
	if c >= m {
		fmt.Println("Yes")
		return
	}

	fmt.Println("No")
}

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

int main(){
    double n, k; cin >> n >> k;
    double ans = 0;
    
    for(int i=1; i<=n; i++){
        double tmp = 1.0/n; 
        int now = i;
        while(now < k){
            now *= 2;
            tmp /= 2;
        }
        ans += tmp;
    }
    printf("%.12f\n", ans);
    return 0;
}

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


void solve(long long N, std::vector<long long> a){
sort(a.begin(), a.end());
int ans=0;
for(int i=N-1;i>=0;i=i-2){
if(i>0){
    ans+=a.at(i)-a.at(i-1);
}
if(i==0){
    ans+=a.at(i);
}
}
cout<<ans<<endl;
}
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 256
p=input
n,m=map(int,p().split())
l=[[int(i)for i in p().split()]for _ in[0]*n]
r=[1,-1]
print(max([sum(sorted([x[0]*r[k&1]+x[1]*r[k>>1&1]+x[2]*r[k>>2&1]for x in l],reverse=True)[:m])for k in range(8)]))

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

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

    if (b / a >= c) cout << c << endl;
    else cout << b / a << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main(void) {
  string s, t;
  cin >> s >> t;
  int cnt = 0;
  if(s[0] == t[0]) ++cnt;
  if(s[1] == t[1]) ++cnt;
  if(s[2] == t[2]) ++cnt;
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>



int main(){
	
	int i,j,N;
	char S[110];
	scanf("%d %s",&N, S);
	
	int len = strlen(S);
	
	if(len<=N){
		printf("%s\n",S);
	}
	else{
		
		for(i=0;i<N;i++){
			printf("%c",S[i]);
		}
		printf("...\n");
		
	}
		
	return 0;
}


Measured memory_bytes: 1660
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

string s;
int a, b, c, d;

int main()
{
	cin >> s;
	sort(s.begin(), s.end());
	if (s == "abc") {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n;
int m;
int dp[2][5005];

int main(){
	cin >> n >> m;
	dp[0][0] = 1;
	int cur = 0, nxt = 1;
	repn(i,n/2){
		rep(i,n) dp[nxt][i] = 0;
		for(int j=0;j<n;j++){
			if(dp[cur][j] == 0) continue;
			for(int k=0;j+k*i<n;k++){
				dp[nxt][j+k*i] += dp[cur][j];
				if(dp[nxt][j+k*i]>=m) dp[nxt][j+k*i]-=m;
			}
		}
		swap(cur,nxt);
	}
	repn(i,n-n/2){
		rep(i,n) dp[nxt][i] = 0;
		for(int j=0;j<n;j++){
			if(dp[cur][j] == 0) continue;
			for(int k=0;j+k*i<n;k++){
				dp[nxt][j+k*i] += dp[cur][j];
				if(dp[nxt][j+k*i]>=m) dp[nxt][j+k*i]-=m;
			}
		}
		swap(cur,nxt);
	}
	ll ans = 0;
	rep(i,n) ans += dp[cur][i];
	cout << (ans%m+m)%m << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long int n , k,sum=0;
	cin>>n>>k;
	long int arr[n];
	for(int i = 0 ; i < n ; i++)
	{
		cin>>arr[i];
	}
	int p = sizeof(arr) / sizeof(arr[0]); 
	sort(arr, arr + p, greater<int>()); 
	if(k==0)
	{
		for(int i = 0 ; i < n ;i++)
		{
			sum = sum+arr[i];
		}
		cout<<sum;
	}
	else if(k == n)
	{
		cout<<sum;
	}
	else
	{
		for(int i = k ; i < n ; i++)
		{
			sum = sum+arr[i];
		}
		cout<<sum;
	}
	
	return 0;
}

Measured memory_bytes: 1792
//testcode.cpp
#include <iostream>
#include <utility>
using namespace std;


int main()
{
  int a, b, c;
  cin >> a >> b;
  if (a < b)
  {
    swap(a,b);
  }

  if (a == b)
  {
    c = 2 * a;
  }
  
  else 
  {
    c = 2 * a - 1;
  }

    cout << c;

}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j,k;
    ll n;
    cin >> n;
    vector<ll> l(n);
    rep(i,n) cin >> l.at(i);
    sort(all(l));
    ll ans = 0;
    for(i = 0;i < n;++i){
        for(j = i+1;j < n;++j){
            for(k = j+1;k < n;++k){
                if(l.at(i) != l.at(j) && l.at(j) != l.at(k)){
                    if(l.at(i) + l.at(j) > l.at(k)) ++ans;
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
#define SG ((getchar())-(48))
#define F(a) for(register int (a)(43);(a)<=(45);(a)+=2)
#define PDZF(a) ((!((a)-(43)))?(1):(-1))
using namespace std;
string s;
signed main()
{
    int a(SG),b(SG),c(SG),d(SG);
    F(i){F(j){F(k){if(!((a+(b*(PDZF(i)))+(c*(PDZF(j)))+(d*(PDZF(k))))-7)){printf("%d%c%d%c%d%c%d=7",a,i,b,j,c,k,d);goto endreturn;}}}}
    endreturn:return putchar(10),0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

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

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

char field[12][13];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

void bfs(int y, int x) {
	if(y < 0 || 12 <= y || x < 0 || 12 <= x || field[y][x] == '0') return;
	field[y][x] = '0';
	rep(i,4) {
		bfs(y+dy[i], x+dx[i]);
	}
}

int main() {
	while(~scanf(" %s", field[0])) {
		for(int i = 1; i < 12; i++) scanf(" %s", field[i]);
		int ans = 0;
#if 0
		rep(y,12) {
			rep(x,12) {
				printf("%c", field[y][x]);
			}
			puts("");
		}
#endif
		rep(y,12) rep(x,12) {
			if(field[y][x] == '1') {
				ans++;
				bfs(y,x);
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

void print_ans(bool flag){
    if(flag){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }   
}

int main(){
    int n;
    cin >> n;
    bool ans = false;
    for(int i = 1; i <= sqrt(n); i++){
        ans |= (((n % i) == 0) && (n / i <= 9));
    }
    print_ans(ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>

using namespace std;

int main()
{
    int N,T,A;
    cin >> N >> T >> A;
    int h[1000];
    for(int i = 0; i < N; i++) cin >> h[i];
    double mintemp = 1000000, temp;
    int ans = 0;
    for(int i = 0; i < N; i++)
    {
       temp = abs(A - (T - h[i] * 0.006));
       if (mintemp >= temp)
       {
           mintemp = temp;
           ans = i;
       }
    }
    cout << ans + 1 << endl;

    return 0;
}


Measured memory_bytes: 256
H,W=map(int,input().split())
s=[None]*(H+2)
for i in range(H):
    s[i+1]=input()
s[0]="."*W
s[H+1]="."*W
a=1
for i in range(1,H+1):
    if s[i][0]=="#" and s[i-1][0]=="." and s[i+1][0]=="." and s[i][1]==".":
        a=0
        break
    for j in range(1,W-1):
        if s[i][j]=="#" and s[i-1][j]=="." and s[i+1][j]=="." and s[i][j+1]=="." and s[i][j-1]==".":
            a=0
            break
    if s[i][W-1]=="#" and s[i-1][W-1]=="." and s[i+1][W-1]=="." and s[i][W-2]==".":
        a=0
        break
if a:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

ll dp[10][2][2][2][2][2];

int main(){
  string s; cin >> s;
  int n=s.size();
  dp[0][0][0][0][0][0]=1;
  rep(i,n)rep(a,2)rep(b,2)rep(c,2)rep(f,2)rep(j,2){
    rep(d,10){
      int nd=s[i]-'0';
      int nj=j;
      if(j==0){
        if(d>nd) continue;
        if(d<nd) nj=1;
      }
      int nf=f;
      if(d!=0&&d!=3&&d!=5&&d!=7) continue; //0,3,5,7以外は通さない
      if(f==1&&d==0) continue; //0以外の文字を既に使ってるなら0は使えない
      if(f==0&&d!=0) nf=1; //0以外の数字を使ったら今後0を使えなくする
      int na=a,nb=b,nc=c;
      if(a==0&&d==3) na=1;
      if(b==0&&d==5) nb=1;
      if(c==0&&d==7) nc=1;
      dp[i+1][na][nb][nc][nf][nj]+=dp[i][a][b][c][f][j];
    }
  }
  cout << dp[n][1][1][1][1][0]+dp[n][1][1][1][1][1]+dp[n][1][1][1][0][0]+dp[n][1][1][1][0][1] << endl;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  map<pll,ll> m;
  reps(i,n){
    ll t=i%10;
    ll tmp=i;
    ll h;
    while(tmp){
      h=tmp;
      tmp/=10;
    }
    m[{h,t}]++;
  }
  ll ans=0;
  reps(i,9){
    reps(j,9){
      ans+=m[{i,j}]*m[{j,i}];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256