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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 2e5 + 5;
const LL maxm = LL(1e18)+5;

double A = 0.08;
double B = 0.10;
int main()
{
    int a,b;
    cin >> a >> b;
    int ans = -1;
    _for(i,1,20000){
        if( ((int)(A*i) == a) && ((int)(B*i) == b) && ans < 0){
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		int x = a/b;
		int y = a%b;
		double z = 1.0 * a/b;

		String space = " ";

		System.out.println(x + space + y + space + String.format("%.8f", z));

		sc.close();
	}
}


Measured memory_bytes: 26396
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main()
{
    ll n,a = 0,b = 0,cnt = 0;
    cin >> n;
    vector<ll> p(n),q(n),c(n);
    rep0(i, n)cin >> p[i];
    rep0(i, n)cin >> q[i];
    iota(all(c), 1);
    while (next_permutation(all(c))) {
        ++cnt;
        if(c == p){
            a = cnt;
        }
        if(c == q){
            b = cnt;
        }
    }
    pf(abs(a - b))
    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
AS = gets.chomp.split.map(&:to_i)

h = Hash.new { |h, k| h[k] = [] }
AS.each do |a|
  h[a] << a
end

if h.all? { |k, v| v.length < 2 }
  puts(0)
  exit
end

ns = []
h.sort_by { |k, v| -k }.each do |k, v|
  next if v.length < 2
  before = 0
  v.each do |e|
    if e == before
      ns << [e, before]
      before = 0
    else
      before = e
    end
  end
end

result = 0
a = []
while b = ns.shift
  if !a.empty?
    result += a[0] * b[0]
    break
  else
    a = b
  end
end
p result

Measured memory_bytes: 27528
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a != 1 && b != 1){
        cout << 1 << endl;
    } else if (a != 2 && b != 2){
        cout << 2 << endl;
    } else {
        cout << 3 << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    bool f = 0, b = 0;
    if(S.back() == '0') {
        f = 1;
        S += '1';
    }
    reverse(All(S));
    if(S.back() == '0') {
        b = 1;
        S += '1';
    }
    N = S.size();
    int c = 0;
    vector<int> v;
    for(int i = 0; i < N; i++) {
        c++;
        if(i + 1 == N || S[i] != S[i + 1]) {
            v.pb(c);
            c = 0;
        }
    }
    int len = 2 * K + 1;
    int tmp = 0;
    int res = 0;
    if(len > v.size()) {
        for(auto x : v)
            res += x;
        cout << res - f - b << endl;
        return 0;
    }
    for(int i = 0; i + len - 1 < v.size(); i += 2) {
        if(i == 0) {
            for(int j = 0; j < len; j++) {
                tmp += v[j];
            }
        } else {
            tmp += v[i + len - 2] + v[i + len - 1];
        }
        int tmp2 = tmp;
        if(f && i == 0)
            tmp--;
        if(b && i + len == v.size())
            tmp--;
        res = max(tmp, res);
        tmp = tmp2;
        tmp -= v[i] + v[i + 1];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4072
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int l=1,r=n;
  for(int i=0;i<m;i++){
    int a,b;
    cin >> a >> b;
    l = max(l,a);
    r = min(r,b);
  }
  if(r-l+1>=0) cout << r-l+1 << endl;
  else{
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    String[] kang = {"ld", "mb", "mp", "nc", "nd", "ng", "nt", "nw", "ps", "qu", "cw", "ts"};

    Main(){
	Scanner sc = new Scanner(System.in);
	while(sc.hasNext()){
	    int n = Integer.parseInt(sc.nextLine());
	    if(n == 0){
		continue;
	    }
	    Wd[] wd = new Wd[38];
	    for(int i = 0; i < 26; i++){
		wd[i] = new Wd(String.valueOf((char)('a'+i)), i);
	    }
	    for(int i = 26; i < 38; i++){
		wd[i] = new Wd(kang[i-26], i);
	    }

	    for(int k = 0; k < n; k++){
		String[] str = (sc.nextLine()).split(" ");
		for(int i = 0; i < str.length; i++){
		    String st = str[i];
		    while(st.length() > 1){
			int t = -1;
			boolean f1 = false, f2 = false;
			String s1;
			if(st.length() > 2){
			    s1 = st.substring(0, 2);
			    for(int j = 26; j < 38; j++){
				if(s1.equals(wd[j].str)){
				    f1 = true;
				    t = j;
				    st = st.substring(2, st.length());
				    break;
				}
			    }
			} else if(st.length() == 2){
			    for(int j  = 26; j < 38; j++){
				if(st.equals(wd[j].str)){
				    f1 = f2 = true;
				    break;
				}
			    }
			    if(f1 && f2){
				break;
			    }
			}
			if(!f1){
			    s1 = st.substring(0, 1);
			    for(int j = 0; j < 26; j+=1){
				if(s1.equals(wd[j].str)){
				    f2 = true;
				    t = j;
				    st = st.substring(1, st.length());
				    break;
				}
			    }   
			}
			
			if(f1 || f2){
			    f1 = false;
			    if(st.length() > 1){
				s1 = st.substring(0, 2);
				for(int j = 26; j < 38; j++){
				    if(s1.equals(wd[j].str)){
					f1 = true;
					wd[t].plusCt(j);
					break;
				    }
				}
			    }
			    if(!f1){
				s1 = st.substring(0, 1);
				for(int j = 0; j < 26; j+=1){
				    if(s1.equals(wd[j].str)){
					wd[t].plusCt(j);
					break;
				    }
				}   
			    }
			}
			// next
		    }
		}
	    }
	    for(int i = 0; i < 38; i++){
		wd[i].getMax();
		wd[i].print(wd[wd[i].mx].str);
	    }
	}
    }

    public static void main(String[] args){
	new Main();
    }
}

class Wd{
    String str;
    int n, mx;
    int[] stlt;
    Wd(){
	this.str = "";
	this.n = 0;
    }


    Wd(String str, int n){
	this.str = str;
	this.n = n;
	stlt = new int[38];
    }

    void getMax(){
	this.mx = 0;
	for(int i = 1; i < 38; i++){
	    if(stlt[i] > stlt[mx]){
		mx = i;
	    }
	}
    }

    void plusCt(int c){
	stlt[c]++;
    }

    void print(String s){
	System.out.println(str+" "+s+" "+Integer.toString(stlt[mx]));
    }
}

Measured memory_bytes: 13000
N = int(input())
h = list(map(int, input().split()))

dp = [0]*N
dp[1] = abs(h[1]-h[0])

for i in range(2, N):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
#     dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
#     dp[i+2] = min(dp[i] + abs(h[i+2] - h[i]), dp[i+1] + abs(h[i+2] - h[i+1]))
print(dp[-1])

Measured memory_bytes: 13980
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args){
	try{
	    BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
	    String s1, s2, swap;
	    int carrier, b = Integer.valueOf(sc.readLine());
	    
	    for(int i=0; i<2*b; i+=2){
		int x, y, sum;
		ArrayList<Integer> hasil = new ArrayList<Integer>();
		carrier=0;
		s1 = sc.readLine();
		s2 = sc.readLine();
		if(s1.length()<s2.length()){
		    swap = s1;
		    s1 = s2;
		    s2 = swap;
		}
		if(s1.length()>80){
		    System.out.println("overflow");
		    continue;
		}
		for(int j=0; j<s1.length(); j++){
		    x = Integer.valueOf(s1.substring(s1.length()-(j+1),s1.length()-j));
		    if(j>=s2.length())
			y = 0;
		    else
			y = Integer.valueOf(s2.substring(s2.length()-(j+1),s2.length()-j));
		    
		    sum = x+y+carrier;
		    hasil.add(sum%10);
		    carrier = sum/10;
		}
		if(carrier!=0)
		    hasil.add(carrier);
		if(hasil.size()>80){
		    System.out.println("overflow");
		    continue;
		}
		for(int z=hasil.size()-1; z>=0; z--)
		    System.out.print(hasil.get(z));
		System.out.println();
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

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

using namespace std;

template <long long Mod> struct ModInt { /* {{{ */
  long long v;
  constexpr ModInt(const long long x = 0) {
    v = x % Mod;
    if (v < 0) {
      v += Mod;
    }
  }
  constexpr ModInt operator+(const ModInt rhs) const { return ModInt(*this) += rhs; }
  constexpr ModInt operator-(const ModInt rhs) const { return ModInt(*this) -= rhs; }
  constexpr ModInt operator*(const ModInt rhs) const { return ModInt(*this) *= rhs; }
  constexpr ModInt operator/(const ModInt rhs) const { return ModInt(*this) /= rhs; }
  const ModInt &operator+=(const ModInt rhs) {
    v += rhs.v;
    if (v >= Mod) {
      v -= Mod;
    }
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) {
    if (v < rhs.v) {
      v += Mod;
    }
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) {
    v = v * rhs.v % Mod;
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) {
    long long exp = Mod - 2;
    while (exp) {
      if (exp & 1) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }
  friend ostream &operator<<(ostream &s, ModInt<Mod> m) {
    s << m.v;
    return s;
  }
  friend istream &operator>>(istream &s, ModInt<Mod> m) {
    s >> m.v;
    return s;
  }
}; /* }}} */

const int mod = 1e9 + 7;
using modint = ModInt<mod>;

int main() {
  string S;
  cin >> S;
  int N = S.length();
  vector<vector<modint>> dp(N + 5, vector<modint>(4));
  dp[0][0] = 1;
  for (int i = 0; i < N; i++) {
    if (S[i] == '?') {
      dp[i + 1][0] = dp[i][0] * 3;
      dp[i + 1][1] = dp[i][1] * 3 + dp[i][0];
      dp[i + 1][2] = dp[i][2] * 3 + dp[i][1];
      dp[i + 1][3] = dp[i][3] * 3 + dp[i][2];
      continue;
    }
    dp[i + 1][0] = dp[i][0];
    dp[i + 1][1] = dp[i][1];
    dp[i + 1][2] = dp[i][2];
    dp[i + 1][3] = dp[i][3];
    if (S[i] == 'A') {
      dp[i + 1][1] += dp[i][0];
    }
    if (S[i] == 'B') {
      dp[i + 1][2] += dp[i][1];
    }
    if (S[i] == 'C') {
      dp[i + 1][3] += dp[i][2];
    }
  }
  cout << dp[N][3] << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 7424
// http://yumai6.hatenablog.com/entry/2015/12/21/222930

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

//---------------------------------------------------------------
//---------------------------------------------------------------

int N, A[11];

int count(int cnt = 0, bool flag = false) {
	if(cnt == N) {
		if(flag)		return 1;
		else			return 0;
	}
	int ans = 0;
	int d;
	for(int i = -1; i < 2; i++) {
		d = A[cnt] + i;
		if(d % 2 == 0) {
			ans += count(cnt + 1, true);
		} else {
			ans += count(cnt + 1, flag);
		}
	}
	return ans;
}

signed main(){
	cin >> N;
	REP(i, N)	cin >> A[i];
	
	cout << count() << endl;
	
	return 0;
}


Measured memory_bytes: 256
import math
a,b,x = map(int,input().split())
if 2*x/a/a - b >= 0: 
    print(180/math.pi*math.atan((b/a-x/a/a/a)*2))
else:
    print(180/math.pi*math.atan(a*b*b/2/x))


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

const int maxn=100003;

int n,q,p[maxn];
char s[maxn];

int main(){
	scanf("%d%d",&n,&q);
	scanf("%s",s+1);
	for(int i=2;i<=n;++i)
		if(s[i-1]=='A'&&s[i]=='C')
			p[i]=1;
	for(int i=1;i<=n;++i)
		p[i]+=p[i-1];
	while(q--){
		int l,r;
		scanf("%d%d",&l,&r);
		printf("%d\n",p[r]-p[l]);
	}
	return 0;
}

Measured memory_bytes: 1280
#include <cstdio>

const int MAXN=55;
long long k,r;
long long a[MAXN];

int main(){
	scanf("%lld",&k);
	printf("50\n");
	for(int i=1;i<=50;++i)
		a[i]=k/50;
	r=k%50;
	if(r==0){
		for(int i=1;i<=50;++i)
			printf("%lld ",a[i]+49);
	}
	else{
		for(int i=49;i;--i){
			if(r%i==0){
				for(int j=1;j<=i;++j)
					a[j]+=r*51/i;
				for(int j=1;j<=50;++j)
					a[j]-=i;
				for(int j=1;j<=50;++j)
					printf("%lld ",a[j]+49);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
using namespace std;
int isprime(int x)
{
  int i ;
  if(x<2) return 0 ;
  else if(x==2)  return 1;
  if(x%2 == 0) return 0;
  for( i = 3;i*i<=x;i++)
     if(x%i == 0) return 0;
  return 1;
}
int main ()
{
  int n,k,cnt = 0;
  cin>>n;
  for(int i = 0;i<n;i++)
  {
    scanf("%d",&k);
    if(isprime(k)) cnt++;
  }
  printf("%d\n",cnt);
  return 0 ;
}



Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[109];
    int n;
    scanf("%d",&n);
    int s1=0,s2=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        s2=s2+a[i];
    }
    s2=s2-a[1];
    s1=a[1];
    int minn=abs(s2-s1);
    for(int i=2;i<n;i++)
    {
        s1=s1+a[i];
        s2=s2-a[i];
        if(abs(s2-s1)<minn)minn=abs(s2-s1);

    }
    printf("%d\n",minn);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	string s, t; cin >> s >> t;
	vl sa(s.size(),0);
	vl sb(s.size(), 0);
	vl ta(s.size(), 0);
	vl tb(s.size(), 0);
	if (s[0] == 'A') {
		sa[0] = 1;
	} else {
		sb[0] = 1;
	}
	FOR(i, 1, s.size()) {
		if (s[i] == 'A') {
			sa[i] = sa[i - 1] + 1;
			sb[i] = sb[i - 1];
		} else {
			sa[i] = sa[i - 1];
			sb[i] = sb[i - 1] + 1;
		}
	}

	if (t[0] == 'A') {
		ta[0] = 1;
	} else {
		tb[0] = 1;
	}
	FOR(i, 1, t.size()) {
		if (t[i] == 'A') {
			ta[i] = ta[i - 1] + 1;
			tb[i] = tb[i - 1];
		} else {
			ta[i] = ta[i - 1];
			tb[i] = tb[i - 1] + 1;
		}
	}
	ll q; cin >> q;
	REP(i, q) {
		ll s1,s2,t1,t2;
		cin >> s1 >> s2 >> t1 >> t2;
		s1--, s2--, t1--, t2--;
		ll ssa = sa[s2] - (s1==0 ? 0 : sa[s1 - 1]);
		ll ssb = sb[s2] - (s1 == 0 ? 0 : sb[s1 - 1]);
		ll tta = ta[t2] - (t1 == 0 ? 0 : ta[t1 - 1]);
		ll ttb = tb[t2] - (t1 == 0 ? 0 : tb[t1 - 1]);
		if ((ssa * 2 + ssb) % 3 == (tta * 2 + ttb) % 3) {
			cout << "YES\n";
		} else if ((ssa + ssb * 2) % 3 == (tta + ttb * 2) % 3) {
			cout << "YES\n";
		} else {
			cout << "NO\n";
		}
	}
	cout << flush;
}

Measured memory_bytes: 4048
// AOJ 1049 Building Houses
// 2018.3.13 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define INF  10000000
int n;
int a[12][12];
int ans;
int id[12], pos[12]; char f[12];

void rec(int k, int len)
{
	int i, j, d;

	if (k >= n) {
		if (len < ans) ans = len;
		return;
	}
	for (i = 0; i < n; i++) if (!f[i]) {
		f[i] = 1, id[k] = i;
		d = a[id[k-1]][i] + len;
		for (j = 0; j < k; j++) {
			if (d - pos[j] < a[id[j]][i]) d = a[id[j]][i] + pos[j];
		}
		if (d < ans) { pos[k] = d, rec(k + 1, d); }
		f[i] = 0;
	}
}

int main()
{
	int i, r, c;

	while (n = in()) {
		for (r = 0; r < n; r++) for (c = 0; c < n; c++) a[r][c] = in();
		for (r = 0; r < n; r++) for (c = r + 1; c < n; c++) {
			if (a[c][r] > a[r][c]) a[r][c] = a[c][r];
			else a[c][r] = a[r][c];
		}
		if (n == 1) { puts("0"); continue; }

		ans = INF;
		memset(f, 0, sizeof(f));
		for (i = 0; i < n-1; i++) {
			id[0] = i, f[i] = 1, pos[0] = 0;
			rec(1, 0);
			f[i] = 0;
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 2040
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
bool c[300010];
int N,Q,maxc=-1,ans=0;
int s[300010];
int main()
{
    cin >> N >> Q;
    for(int i=0;i<N;i++)
    {
        int a;
        cin >> a;
        maxc=max(maxc,a);
        c[a]=true;
    }
    for(int i=0;i<=maxc;i++)
    {
        if(c[i])s[i+1]=i;
        else s[i+1]=s[i];
    }
    for(int i=0;i<Q;i++)
    {
        int q;
        cin >> q;
        ans=0;
        for(int d=maxc;;)
        {
            int p=d%q;
            ans=max(ans,p);
            if(d-p<=0)break;
            d=s[d-p];
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2624
#include <iostream>
#include <cmath>
using namespace std;
typedef long long LL;
const long long INF = 1LL << 60;

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

int main() {
        const int V = 100100;
        LL N, W; cin >> N >> W;
        LL dp[N+1][V];

        // initialization
        for (int i = 0; i <= N; ++i) for (int j = 0; j < V; ++j) dp[i][j] = INF;

        // initial term
        dp[0][0] = 0;

        // DP loop
        LL w, v;
        for (int i = 0; i <N; ++i) {
                cin >> w >> v;
                for (int sum_v = 0; sum_v < V; ++sum_v) {
                        if (sum_v - v >= 0) chmin(dp[i+1][sum_v], dp[i][sum_v-v] + w);
                        chmin(dp[i+1][sum_v], dp[i][sum_v]);
                }

        }

        // Find answer
        int res = 0;
        for (int i = 0; i < V; ++i) {
                if (dp[N][i]<=W) chmax(res, i);
        }
        cout << res << "\n";
        return 0;
}


Measured memory_bytes: 79232
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect
import heapq


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def main():
    S, T = get_inputs()
    print(T + S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 22088
N,M = map(int,input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
for dx in range(N-M+1):
    for dy in range(N-M+1):
        flg = True
        for i in range(M):
          if A[i+dx][dy:dy+M] != B[i]:
            flg = False
            break
        if flg:
          print("Yes")
          exit()
print("No")

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

val = [0] * (N)
for _ in range(Q):
    p, x = map(int, input().split())
    p -= 1
    val[p] += x


def dfs(s):
    used = [False]*N
    stack = []
    stack.append(s)
    while len(stack):
        now = stack[-1]
        used[now] = True
        stack.pop()
        for nxt in G[now]:
            if used[nxt]:
                continue
            val[nxt] += val[now]
            stack.append(nxt)

dfs(0)

answer = ' '.join(map(str, val[:]))
print(answer)


Measured memory_bytes: 66836
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n, k;
	cin >> n >> k;
	int h, ans = 0;
	REP(i, n) {
		cin >> h;
		if (h >= k)
			ans++;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n),b(n),c(n-1);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    cin >> b[i];
  }
  for(int i=0;i<n-1;i++){
    cin >> c[i];
  }
  int ans=0;
  for(int i=0;i<n-1;i++){
    ans+=b[a[i]-1];
    if(a[i+1]-a[i]==1){
      ans+=c[a[i]-1];
    }
  }
  ans+=b[a[n-1]-1];
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 998244353;
const long long INF = 1e16;
#define int long long

const int MAX_N = 1010;
const int MAX_V = 110;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);	
	int n; cin >> n;
	VE a(n), b(n); rep(i, n)cin >> a[i] >> b[i];
	int p = 1, q = 1;
	rep(i, n) {
		int tmp = max((p +a[i]-1)/ a[i], (q+b[i]-1) / b[i]);
		p = (tmp * a[i]); q = (tmp * b[i]);
	}
	cout << p + q << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int H, W, D;
    cin >> H >> W >> D;
    vector<vector<int>> A(H, vector<int>(W));
    vector<P> invA(H * W);
    REP(i, H) {
        REP(j, W) {
            cin >> A[i][j];
            A[i][j]--;
            invA[A[i][j]] = P(i, j);
        }
    }
    vector<int> dp(H * W);
    REP(d, D) {
        for (int x = d; x + D < H * W; x += D) {
            int i, j, k, l;
            tie(i, j) = invA[x];
            tie(k, l) = invA[x + D];
            dp[x + D] = dp[x] + abs(i - k) + abs(j - l);
        }
    }
    int Q;
    cin >> Q;
    REP(q, Q) {
        int L, R;
        cin >> L >> R;
        --L;
        --R;
        cout << dp[R] - dp[L] << endl;
    }

    return 0;
}


Measured memory_bytes: 4756
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,M;
    cin >> N >> M;
    ll V[N][3];
    rep(i,0,N){
        cin >> V[i][0] >> V[i][1] >> V[i][2];
    }
    ll maxi = 0;
    rep(i,0,8){
        vector<ll> arr(N);
        rep(j,0,N){
            arr[j] = (i & 1 ? 1 : -1) * V[j][0] + (i & 2 ? 1 : -1) * V[j][1] + (i & 4 ? 1 : -1) * V[j][2];
        }
        sort(arr.rbegin(), arr.rend());
        ll sum = 0;
        rep(j,0,M)sum += arr[j];
        maxi = max(maxi, sum);
    }
    cout << maxi << endl;
}

Measured memory_bytes: 256
N,Q =map(int,input().split())
S = input()
lr = [list(map(int,input().split())) for _ in range(Q)]

ans = 0
ans_ls = []
ans_ls.append(0)

for n in range(N-1):
  if S[n] == "A" and S[n+1] =="C":
    ans += 1
  ans_ls.append(ans)

for q in range(Q):
  print(ans_ls[lr[q][1]-1]-ans_ls[lr[q][0]-1])


Measured memory_bytes: 29716
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    long long t=0;
    for (register int i=1; i<=n; i++)
        if (i%3!=0&&i%5!=0) t+=i;
    cout << t << endl;
    return 0;
}

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

int main()
{
    int n,x,xx=0,v,k=0;
    scanf("%d%d",&n,&x);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&v);
        if(xx<=x)
        {
            k++;
        }
        xx+=v;
    }
    if(xx<=x)
        k++;
    printf("%d\n",k);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main(){
	int n;
	scanf("%d",&n);
	bool f=false;
	while(n){
		if(n%10==7)f=true;
		n/=10;
	}
	if(f)puts("Yes");
	else puts("No");
    return 0;
}


Measured memory_bytes: 3652
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_HW = 50;
int H, W;
char field[MAX_HW][MAX_HW];


int main() {
  cin >> H >> W;
  rep(i,H)rep(j,W) cin >> field[i][j];

  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (field[i][j] == '#') {
        bool judge = false;
        for (int k = 0; k < 4; ++k) {
          int x = i + dx[k], y = j + dy[k];
          if (0 <= x && x < H && 0 <= y && y < W && field[x][y] == '#') judge = true;
        }
        if (judge == false) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
  
}


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

#include <math.h> 

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

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

    // 素数である
    return true;
}

int main() {
  int n;
  cin >> n;
  
  while(1){
    if(IsPrime(n)){
      cout << n << endl;
      return 0;
    }
    n++;
  }
  
}

Measured memory_bytes: 3648
// AtCoder template
// 見た奴全員saba!
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

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

    int n, m; cin >> n >> m;
    map<int,int> ac_cnt;
    map<int,int> wa_cnt;
    int p; string s;
    int ac = 0;
    int wa = 0;
    rep(i,m){
        cin >> p >> s;
        if(s == "AC" && ac_cnt[p] == 0){
            ac_cnt[p]++;
            ac++;
            wa += wa_cnt[p];
        }else if(s == "WA"){
            wa_cnt[p]++;
        }
    }
    cout << ac << " " << wa << endl;
}

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

int main(){
    
    int N;
    cin >> N;
    set<int> st1;
    map<int,int> mp1;
    set<int> st2;
    map<int,int> mp2;
    int v;
    for(int i = 0; i < N;i++){
        cin >> v;
        if(i%2==0){
            st1.insert(v);
            mp1[v]++;
        }else{
            st2.insert(v);
            mp2[v]++;
        }
    }
    
    vector<tuple<int,int,int>> vec1;
    vector<tuple<int,int,int>> vec2;
    for(auto itr = st1.begin(); itr != st1.end(); ++itr) {
        vec1.push_back(make_tuple(mp1[*itr],*itr,1)); 
    }
    
    for(auto itr = st2.begin(); itr != st2.end(); ++itr) {
        vec2.push_back(make_tuple(mp2[*itr],*itr,2)); 
    }
    
    sort(vec1.begin(),vec1.end(),greater<tuple<int,int,int>>());
    sort(vec2.begin(),vec2.end(),greater<tuple<int,int,int>>());
    //for(auto u:vec)cout <<get<0>(u)<<" "<<get<1>(u)<<" "<<get<2>(u)<<endl;
    
    // if(vec.size()==2){
    //     if(get<1>(vec[0])==get<1>(vec[1])){cout << N/2 << endl;return 0;}
    // }
    
    int cont = 0;
    if(get<1>(vec1[0])!=get<1>(vec2[0])){
        cont += get<0>(vec1[0])+get<0>(vec2[0]);
    }else if(get<0>(vec1[0]) < get<0>(vec2[0])){
        cont += get<0>(vec1[1])+get<0>(vec2[0]);
    }else if(get<0>(vec1[0]) > get<0>(vec2[0])){
        cont += get<0>(vec1[0])+get<0>(vec2[1]);
    }else if(get<0>(vec1[1]) > get<0>(vec2[1])){
        cont += get<0>(vec1[1])+get<0>(vec2[0]);
    }else if(get<0>(vec1[1]) <= get<0>(vec2[1])){
        cont += get<0>(vec1[0])+get<0>(vec2[1]);
    }
 
    cout << N - cont << endl;
    
}



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

int main() {
    int H, W;
    cin >> H >> W;

    char vec[70][70];
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++){
            cin >> vec[i][j];
        }
    }

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++){
            int res = 0;
            if (vec[i][j] == '.') {
                for (int k = -1; k <= 1; k++){
                    for (int l = -1; l <= 1; l++) {
                        if (vec[i + k][j + l] == '#') {
                            res++;
                        }
                    }
                }
                vec[i][j] = '0' + res;
            }
        }
    }

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++){
            cout << vec[i][j];
        }
        cout << endl;
    }
}


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

int main(){
    int K,A,B;
    cin >> K >> A >> B;
    int n = A/K;
    int amari = A%K;
    if(amari == 0){
        cout << "OK" << endl;
        return 0;
    }

    if(K*(n+1) >= A && K*(n+1) <= B){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
ll A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z;
void Already2018() {
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << endl;
}
int main() {
	Already2018();
	return 0;
}

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

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

int main(){
	int n, m;
	cin >> n;
	m = s(n);
	if(n%m == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
from collections import deque
import sys
def main():
  a,b=map(int,sys.stdin.readline().split())
  e=[[]for i in range(a)]

  for i in range(a-1):
    c1,c2=map(int,sys.stdin.readline().split())
    e[c1-1].append(c2-1)
    e[c2-1].append(c1-1)

  g=[[]for i in range(a)]
  f=deque()
  f.append((0,-1))
  ans=[0 for _ in range(a)]
  for i in range(b):
    ten,p=map(int,input().split())
    ans[ten-1]+=p
  i=0
  while len(f)!=0:
    i,fr=f.popleft()
    for j in e[i]:
      if j==fr:
        continue
      else:
        ans[j]+=ans[i]
        f.append((j,i)) 
  print(*ans)
  
main()
    
  

  
  


Measured memory_bytes: 75072
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		ArrayList<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			list.add(a[i]);
		}
		Collections.sort(list);
		sc.close();
		BinaryIndexedTree tree = new BinaryIndexedTree(N);

		long ans = 0;
		for (int i = 0; i < N; i++) {
			a[i] = Collections.binarySearch(list, a[i]) + 1;
			ans += i - tree.sum(a[i]);
			tree.add(a[i], 1);
		}
		System.out.println(ans);

	}

	static class BinaryIndexedTree {
		int N;
		int[] bit;

		public BinaryIndexedTree(int N) {
			this.N = N;
			bit = new int[N + 1];

		}

		public int sum(int i) {
			int sum = 0;
			while (i > 0) {
				sum += bit[i];
				i -= i & -i;
			}
			return sum;
		}

		public void add(int i, int x) {
			while (i <= N) {
				bit[i] += x;
				i += i & -i;
			}
		}
	}

}



Measured memory_bytes: 107400
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int n,k;
int d[MAXN];
int pre[MAXN];

map <int,vector<int>> mp;

ll C2(ll a)
{
	return (a *(a-1)) / 2;
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	
	cin >> n >> k;

	for (int i = 0; i < n; ++i)
	{
		cin >> d[i];
		d[i]--;
		d[i] %= k;
	}

	pre[0] = d[0];
	for (int i = 1; i < n; ++i)
		pre[i] = (pre[i-1] + d[i]) % k;

	for (int i = 0; i < n; ++i)
		mp[pre[i]].pb(i);

	ll ans = 0;
	for (auto i : mp)
	{
		auto vec = i.second;

		for (int i = 0; i < vec.size(); ++i)
		{
			auto it = upper_bound(all(vec), vec[i] + k - 1);
			if(it == vec.begin()) continue;
			it--;
			
			int index = it - vec.begin();

			ans += index - i;
		}

	}

	for (int i = 0; i < mp[0].size(); ++i)
	{
		if (mp[0][i] > k-2)  break;
		ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 23680
#include <iostream> // {{{
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <cstdio> // }}}

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

using namespace std;

int main() {
    int x,y,z;
    cin >> x >> y >> z;
    rep(i,1000000){
        if((i*(y+z)+z) > x) {
            cout << i-1 << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
	double r = 0;

	cin >> r;
	cout << fixed << setprecision(6) << M_PI * r * r << " " << 2 * M_PI * r << endl;

    return 0;
}

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

int main(){
    int long long x;
    int long long i, ans, flag;
    cin >> x; 
    flag = 0;
    ans = 0;

    do{
e1:
        for(i = 2; i <= x; i++){
            if( x % i == 0 ){
                if(i == x){
                   flag = 1;
                    ans = x; 
                    break;
                }
                else{
                    x = x + 1;
                    flag = 0;
                    goto e1;

                }
            }
        }
    }while (flag = 0);

    cout << ans;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> x(n), y(n);
  vector<char> c(n);
  for (int i = 0; i < n; i++) {
    cin >> x.at(i) >> y.at(i) >> c.at(i);
  }
  vector<vector<int>> black(k, vector<int>(k)), s(k + 1, vector<int>(k + 1));
  for (int i = 0; i < n; i++) {
    int xr = x.at(i) % (2 * k), yr = y.at(i) % (2 * k);
    if ((xr >= k) == (yr >= k) and c.at(i) == 'B') {
      black.at(xr % k).at(yr % k)++;
    } else if ((xr >= k) != (yr >= k) and c.at(i) == 'W') {
      black.at(xr % k).at(yr % k)++;
    } else {
      black.at(xr % k).at(yr % k)--;
    }
  }
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < k; j++) {
      s.at(i + 1).at(j + 1) = s.at(i + 1).at(j) + s.at(i).at(j + 1) - s.at(i).at(j)
        + black.at(i).at(j);
    }
  }
  int black_max = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      black_max = max(black_max, abs(2 * s.at(i).at(k) + 2 * s.at(k).at(j)
                                     - 4 * s.at(i).at(j) - s.at(k).at(k)));
    }
  }
  cerr << black_max << endl;
  cout << (black_max + n) / 2 << endl;
}


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

char search(char cells[10]) {
    if (cells[4] != 's'
        && ((cells[0] == cells[4] && cells[4] == cells[8])
            || (cells[1] == cells[4] && cells[4] == cells[7])
            || (cells[2] == cells[4] && cells[4] == cells[6])
            || (cells[3] == cells[4] && cells[4] == cells[5])
        )) {
        return cells[4];
    } else if (cells[0] != 's'
               && ((cells[0] == cells[1] && cells[0] == cells[2])
                   || (cells[0] == cells[3] && cells[0] == cells[6])
               )) {
        return cells[0];
    } else if (cells[8] != 's'
               && ((cells[8] == cells[2] && cells[8] == cells[5])
                   || (cells[8] == cells[6] && cells[8] == cells[7])
               )) {
        return cells[8];
    }
    return 'd';
}

int main() {
    char cells[10];
    while (cin >> cells) {
        cout << search(cells) << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }


int main()
{
    int n,ans=0,seq=0,a;
    cin>>n;
    rep(i,n) {
        cin>>a;
        if(a==i+1) seq++;
        else if(seq) ans+=seq/2+seq%2,seq=0;
    }
    if(seq) ans+=seq/2+seq%2;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define ITR(v, i) for(auto ite = v.begin(); ite != v.end(); ite++)
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> x >> y;
    if(y < x)
        cout << "safe" << endl;
    else
        cout << "unsafe" << endl;
}

Measured memory_bytes: 3652
#include <stdio.h>
int main(){
  int N,N1,N2,N3;
   scanf("%d",&N);
  
  N1=N%10;
  N2=(N/10)%10;
  N3=N/100;
  if(N1==7 || N2==7 || N3==7){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1596
#include <algorithm>
#include <cstdio>
using namespace std;

const int MAX_N = 100008;

int cnt[MAX_N];

int main()
{
    int N, Q, x, b, c;
    scanf("%d", &N);
    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &x);
        sum += x;
        cnt[x]++;
    }
    scanf("%d", &Q);
    while (Q--)
    {
        scanf("%d%d", &b, &c);
        int &cur = cnt[b];
        cnt[c] += cur;
        sum += cur * (c - b);
        cur = 0;
        printf("%lld\n", sum);
    }
    return 0;
}


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

int bubbleSort(int a[], int n){
  int sw=0;
  bool flag=1;
  for(int i=0; flag; i++){
    flag=0;
    for(int j=n-1; j>=i+1; j--){
      if(a[j]<a[j-1]){
	swap(a[j],a[j-1]);
	flag=1;
	sw++;
      }
    }
  }
  return sw;
}

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

  sw=bubbleSort(a,n);

  for(int i=0; i<n; i++){
    if(i) cout<<" ";
    cout<<a[i];
  }
  cout<<endl;
  cout<<sw<<endl;

  return 0;
}



Measured memory_bytes: 3096
R = lambda: map(int, input().split())
 
n = int(input())
if n % 3:
    ans = 'YNeos'[any(R())::2]
else:
    a = sorted(R())
    m = n // 3
    if a[0] ^ a[m] ^ a[2 * m]:
        ans = 'No'
    elif any(len(set(a[i:i + m])) > 1 for i in range(0, n, m)):
        ans = 'No'
    else:
        ans = 'Yes'
print(ans)

Measured memory_bytes: 14212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr <<__LINE__<< ": " << #x << " -> " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" -> ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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 int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

bool flag = 1;

void fail() {
    cout << "No" << endl;
    exit(0);
}

void suc(string &ans) {
    cout << "Yes" << endl;
    rep(i, ans.size()) cout << ans[i] << endl;
    exit(0);
}

void solve() {
    int n, a, b, c;
    string s, pre;
    string ans = "";
    cin >> n >> a >> b >> c;
    if (a + b + c == 0) {
        rep(i, n) cin >> s;
        fail();
    } else if (a + b + c == 1) {
        rep(i, n) {
            cin >> s;
            if (s == "AB") {
                if (a) a--, b++, ans += 'B';
                else if (b) a++, b--, ans += 'A';
                else if (c) flag = 0;
            } else if (s == "AC") {
                if (a) a--, c++, ans += 'C';
                else if (b) flag = 0;
                else if (c) a++, c--, ans += 'A';
            } else {
                if (a) flag = 0;
                else if (b) b--, c++, ans += 'C';
                else if (c) b++, c--, ans += 'B';
            }
        }
        if (flag) {
            suc(ans);
        } else {
            fail();
        }
    }
    rep(i, n) {
        cin >> s;
        if  (i == 0 &&
            ((s == "AB" && !a && !b) ||
            (s == "AC" && !a && !c) ||
            (s == "BC" && !b && !c))) {
            flag = 0;
            break;
        }
        retry:
        if (s == "AB") {
            if (!a && !b) {
                if (pre == "AC") ans.back() = 'A', a+=2, c-=2;
                else ans.back() = 'B', b+=2, c-=2;
                goto retry;
            } else{
                if (a) a--, b++, ans += 'B';
                else a++, b--, ans += 'A';
            }
        } else if (s == "AC") {
            if (!a && !c) {
                if (pre == "AB") ans.back() = 'A', a+=2, b-=2;
                else ans.back() = 'C', c+=2, b-=2;
                goto retry;
            } else {
                if (a) a--, c++, ans += 'C';
                else a++, c--, ans += 'A';
            }
        } else {
            if (!b && !c) {
                if (pre == "AB") ans.back() = 'B', b+=2, a-=2;
                else ans.back() = 'C', c+=2, a-=2;
                goto retry;
            } else {
                if (b) b--, c++, ans += 'C';
                else b++, c--, ans += 'B';
            }
        }
        pre = s;
    }
    if (flag) {
        suc(ans);
    } else {
        fail();
    }
}

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


Measured memory_bytes: 3888