akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int r,D,x;

	cin >> r >> D >> x;
	
	for(int i=0;i<10;i++)
	{
		x=r*x-D;
		cout << x << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
const int N = 100003;
int n, c[N], deg[N], head[N], to[N << 1], nxt[N << 1];
inline void add(int a, int b){
	static int cnt = 0;
	to[++ cnt] = b; nxt[cnt] = head[a]; head[a] = cnt;
}
int q[N], front, rear, d[N], m;
LL ans;
int main(){
	scanf("%d", &n);
	for(Rint i = 1;i < n;i ++){
		int a, b;
		scanf("%d%d", &a, &b);
		add(a, b); add(b, a);
		deg[a] ++; deg[b] ++;
	}
	for(Rint i = 1;i <= n;i ++) scanf("%d", c + i);
	if(n == 1){
		printf("%d\n%d", c[1], c[1]);
		return 0;
	}
	sort(c + 1, c + n + 1);
	for(Rint i = 1;i <= n;i ++)
		if(deg[i] == 1) q[rear ++] = i;
	while(front < rear){
		int now = q[front ++];
		d[now] = c[++ m];
		for(Rint i = head[now];i;i = nxt[i]) if(!d[to[i]]){
			-- deg[now]; -- deg[to[i]];
			if(deg[to[i]] == 1) q[rear ++] = to[i];
			ans += c[m];
		}
	}
	printf("%lld\n", ans);
	for(Rint i = 1;i <= n;i ++) printf("%d ", d[i]);
}

Measured memory_bytes: 640
import java.lang.Math;
import java.util.Scanner;
import java.util.TreeSet;
import java.util.Arrays;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        TreeSet<Integer> a = new TreeSet<>();

        for (int i = 0; i < n; i++) {
            a.add(sc.nextInt());
        }

        int answer_n = a.last();
        a.remove(a.last());

        int answer_r = 0;
        if (a.size() == 1) {
            answer_r = a.first();
        }
        else {
            int middle = answer_n / 2;
            int f = a.floor(middle);
            int c = a.ceiling(middle);

            int df = Math.abs(f - middle);
            int dc = Math.abs(c - middle);
            if (df == dc) {
                answer_r = c;
            }
            else {
                answer_r = df < dc ? f : c;
            }
        }

        System.out.println(answer_n + " " + answer_r);
    }
}


Measured memory_bytes: 66556
x = int(input())
flg = 0
while flg == 0:
    lo_flg = 1
    mx  = int(x**0.5)
    for i in range(2, mx+1):
        if x % i == 0:
            lo_flg = 0
            break
    flg = lo_flg
    if flg == 0:
        x+=1
print(x)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	ll n, p;
	cin >> n >> p;
	if( n == 1 ){
		cout << p << endl;
		return 0;
	}
	ll ans = 1;
	ll porig = p;
	
	for( ll i = 2; i*i <= porig; ++i ){
		ll cnt = 0;
		while( p % i == 0 ){
			p /= i;
			++cnt;
		}
		if( cnt >= n ){
			ll pro = 1;
			ll j = cnt/n;
			while( j-- ){
				pro *= i;
			}
			ans *= pro;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def print_row(s, e, w)
  (1..w).map { |i|
    i.odd? ? s : e
  }.join
end

def print_chessboard(h, w)
  (1..h).each do |i|
    puts "#{i.odd? ? print_row('#', '.', w) : print_row('.', '#', w)}"
  end
  puts ""
end

loop do
  h, w = gets.split.map(&:to_i)
  break if h == 0 && w == 0

  print_chessboard(h, w)
end



Measured memory_bytes: 8884
import statistics

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

a=int(input())	
b=make_divisors(a)
x=statistics.median_low(b)


y=a/x

print(int(x+y-2))


Measured memory_bytes: 5788
#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 = int;

int main()
{
    ll i,j,k;
    ll h,w;
    cin >> h >> w;
    ll inf = 160*80;
    vector<vector<ll>> a(h,vector<ll>(w,0));
    vector<vector<ll>> b(h,vector<ll>(w,0));
    for(i = 0;i < h;++i){
        rep(j,w) cin >> a.at(i).at(j);
    }
    for(i = 0;i < h;++i){
        rep(j,w) cin >> b.at(i).at(j);
    }
    vector<vector<vector<ll>>> dp(h, vector<vector<ll>>(w, vector<ll>(2*inf+1,0)));
    ll tmp = a.at(0).at(0) - b.at(0).at(0);
    dp.at(0).at(0).at(inf + tmp) = 1;
    dp.at(0).at(0).at(inf - tmp) = 1;
    for(i = 0;i < h;++i){
        rep(j,w){
            tmp = a.at(i).at(j) - b.at(i).at(j);
            if(i > 0){
                rep(k, 2*inf+1){
                    if(dp.at(i-1).at(j).at(k)){
                        dp.at(i).at(j).at(k + tmp) = 1;
                        dp.at(i).at(j).at(k - tmp) = 1;
                    }
                }
            }
            if(j > 0){
                rep(k, 2*inf+1){
                    if(dp.at(i).at(j-1).at(k)){
                        dp.at(i).at(j).at(k + tmp) = 1;
                        dp.at(i).at(j).at(k - tmp) = 1;
                    }
                }
            }
        }
    }
    ll ans = 1e9;
    for(i = 0;i < 2*inf + 1;++i){
        if(dp.at(h-1).at(w-1).at(i)){
            ans = min(ans, abs(i - inf));
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 651652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
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;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

ll gcd(ll a, ll b) {
    return b != 0 ? gcd(b, a % b) : a;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    for(int i = k+1; i < n+1; i++){
        ll l = (n-k)/i+1, m = i - k;
        ans += (l) * m;
        if(k==0) ans -= 1;
        //cout << ans << endl;
        ll a =  max(l * i - 1 - n, 0LL);
        ans -= a;
        //cout << "l: " << l << " m: " << m <<" minus: " << a << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#!/bin/python3

N = int(input())
T, A = [int(i) for i in input().split()]

points = [int(i) for i in input().split()]

mi = float('inf')

for i in range(N):
    tmp = T - points[i] * 0.006

    if abs(A - tmp) < mi:
        result = i + 1
        mi = abs(A - tmp)

print(result)


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

int main() {
 int n;
  cin>>n;
  map<string,int> p;
  vector<string> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(p[a[i]]==0) p[a[i]]=1;
    else p[a[i]]=0;
  }
  int count=0;
  for(int i=0;i<n;i++){
    count+=p[a[i]];
    p[a[i]]=0;
  }
  cout<<count<<endl;
}
  

Measured memory_bytes: 13312
#include <iostream>

using namespace std;

int main(void)
{
  int days;
  int kokugo_page;
  int math_page;
  int capa_kokugo;
  int capa_math;
  int max_days=0;
  int math_days;
  int kokugo_days;
  
  cin >> days;
  cin >> kokugo_page;
  cin >> math_page;
  cin >> capa_kokugo;
  cin >> capa_math;

  math_days=math_page/capa_math;
  if(math_page%capa_math!=0)
    math_days++;
  
  kokugo_days=kokugo_page/capa_kokugo;
  if(kokugo_page%capa_kokugo!=0)
    kokugo_days++;
  
  if(max_days<kokugo_days)
    max_days=kokugo_days;

  if(max_days<math_days)
    max_days=math_days;

  cout << days-max_days << endl;

  return 0;
}


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

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

int n;

int main(){
  while(cin>>n, n!=0){
    string str[1000];
    int a[1000];
    rep(i,n){
      cin>>str[i];
      int cnt=0;
      rep(j,str[i].length())
	if(str[i][j]=='.')cnt++;
      a[i]=cnt;
    }
    rep(i,n){
      rep(j,a[i]-1){
	bool flag=false;
	for(int k=i+1; k<n; k++){
	  if(a[k]==j+1){flag=true; break;}
	  if(a[k]<j+1)break;
	}
	  if(flag){
	    str[i][j]='|';
	  }
	  else{
	    str[i][j]=' ';
	  }
      }
	str[i][a[i]-1]='+';
      cout<<str[i]<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;

int main(){
    ll N; cin >> N;
    vector<ll> V(N); for(int i = 0; i < N; i++) cin >> V[i];
    ll SUM = 0;
    for(int i = 1; i < N; i++){
        if(V[i] < V[i-1]) {
            SUM += V[i-1] - V[i];
            V[i] = V[i-1];    
        }

    }
    cout << SUM << endl;

}


Measured memory_bytes: 4796
N = int(input())
list_A = []

for _ in range(N):
    A = int(input())
    list_A.append(A)
    
A = max(list_A)
index_A = list_A.index(A)

list_B = sorted(list_A, reverse=True)
B = list_B[1]

for i in range(N):    
    if list_A[i] == A:
        print(B)
    else:
        print(A)

Measured memory_bytes: 14112
#include <bits/stdc++.h>
#define rep(i,n1) for(int i=0;i<n1;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vi vec[200001];
int x[200001]={};
int dp[200001];

int main() {
	int n;
	cin>>n;
	int v[n];
	rep(i,n)cin>>v[i];
	sort(v,v+n);
	int r=0;
	rep(i,n-2){
		for(int j=i+1;j<n-1;++j){
			int a =v[i]+v[j];
			int high=n;			
			int low=j;
			while(1){
				if(high-low==1)break;
				int mid = (high+low)/2;
				if(v[mid]<a){
					low=mid;
				}else{
					high=mid;
				}
			}
			r+=low-j;
		}
	}
	cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 4992
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
 
public class Main implements Runnable {
	
    public static void main(String[] args) {
    	new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }
    
    public void run() {
        FastScanner sc = new FastScanner();
        
        int n = sc.nextInt();
        int q = sc.nextInt();
        
        int[] a = sc.nextIntArray(n);
        
        for(int i=0;i<q;i++){
        	System.out.println(subS(0,n-1,sc.nextLong(),a));
        }
    }
	
	//subintervalも条件を満たすときの尺取り（[from,to]のsubintervalのうち、条件を満たす区間の個数）
	long subS(int from, int to, long x, int[] a){
		long ans = 0;
		long sum = a[0];
		int l = from;
		int r = from;
		
		boolean con = true;
		while(con){
			if(sum<=x){
				ans += r-l+1;
				r++;
				if(r>to){
					con = false;
				}
				else{
					sum += a[r];
				}
			}
			else{
				sum -= a[l];
				l++;
				if(l>to){
					con = false;
				}
			}	
		}
		
		return ans;
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public int[] nextIntArray(int n){
		int[] a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public Integer[] nextIntegerArray(int n){
		Integer[] a = new Integer[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 27424
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

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

    bool ans = false;
    int cnt = 0;
    for (int i=0; i<n; i++) {
        int d1, d2;
        cin >> d1 >> d2;
        if (d1 == d2) cnt++;
        else cnt = 0;
        if (cnt>=3) ans = true;
    }

    cout << (ans? "Yes" : "No") << endl;
}

Measured memory_bytes: 3136
N = int(input())
H = list(map(int,input().split()))
dp = [0] * N
dp[0] = 0
for i in range(1, N):
    if i == 1:
        dp[i] = abs(H[1] - H[0])
    else:
        dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]), dp[i-2]+abs(H[i]-H[i-2]))
print(dp[N-1])


Measured memory_bytes: 52208
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(1){
        c = c-b;
        if(c <= 0){
            cout << "Yes" << endl;
            break;
        }
        a = a-d;
        if(a <= 0){
            cout << "No" << endl;
            break;
        }
    }

    return 0;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

ll XOR(ll a){
    if(a % 4 == 1)return 1;
    else if(a % 4 == 3)return 0;
    else if(a == 0)return 0;
    else return (XOR(a-1)^a);
}
signed main()
{   
    gearup;
    ll n,k; cin >> n >> k;
    double res = 0.0;
    rep1(i,n+1){
        int count = 1;
        int x = i;
        while(x < k){
            x *= 2;
            count++;
        }
        double pro = 1.0;
        rep(j,count-1){
            pro *= 2.0;
        }
        res += 1.0 / pro;
    }
    cout << fixed << setprecision(10) << res/n << endl;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define INF LONG_LONG_MAX
#define yn(f) cout << (f ? "Yes" : "No") << endl;

int n,k;

signed main() {
    cin >> n >> k;
    cout << min(n%k, k-(n%k)) << endl;
}




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

signed main() {
    int n; cin >> n;
    int ans = 0;
    for(int i=1; i<=n; i++)
        for(int j=1; j<=n; j++)
            for(int k=1; k<=n; k++)
                ans += gcd(gcd(i,j),k);
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <queue>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
namespace remoon {
    #define re register
    #define de double
    #define le long double
    #define ri register int
    #define ll long long
    #define sh short
    #define ui unsiged int
    #define ull unsigned long long
    #define pii pair<int, int>
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define tpr template <typename ra>
    #define rep(iu, st, ed) for(ri iu = st; iu <= ed; iu ++)
    #define drep(iu, ed, st) for(ri iu = ed; iu >= st; iu --)	
    #define gc getchar
    inline int read() {
        int p = 0, w = 1; char c = gc();
        while(c > '9' || c < '0') { if(c == '-') w = -1; c = gc(); }
        while(c >= '0' && c <= '9') p = p * 10 + c - '0', c = gc();
        return p * w;
    }
    int wr[50], rw;
    #define pc(iw) putchar(iw)
    tpr inline void write(ra o, char c = '\n') {
        if(!o) pc('0');
        if(o < 0) o = -o, pc('-');
        while(o) wr[++ rw] = o % 10, o /= 10;
        while(rw) pc(wr[rw --] + '0');
        pc(c);
    }
    tpr inline void cmin(ra &a, ra b) { if(a > b) a = b; }
    tpr inline void cmax(ra &a, ra b) { if(a < b) a = b; } 
    tpr inline bool ckmin(ra &a, ra b) { return (a > b) ? a = b, 1 : 0; }
    tpr inline bool ckmax(ra &a, ra b) { return (a < b) ? a = b, 1 : 0; }
}
using namespace std;
using namespace remoon;

namespace mod_zone {
    int mod = 0;
    inline void inc(int &a, int b) { a += b; if(a >= mod) a -= mod; }
    inline void dec(int &a, int b) { a -= b; if(a < 0) a += mod; }
    inline int Inc(int a, int b) { return (a + b >= mod) ? a + b - mod : a + b; }
    inline int Dec(int a, int b) { return (a - b < 0) ? a - b + mod : a - b; }
    inline int mul(int a, int b) { return 1ll * a * b % mod; }
    inline int fp(int a, int k) {
        int ret = 1;
        for( ; k; k >>= 1, a = mul(a, a))
        if(k & 1) ret = mul(ret, a);
        return ret;
    }
}
using namespace mod_zone;

ll ans, N;
de a, b, c, d;
int Q, H, S, D;

int main() {
	Q = read(); H = read(); 
	S = read(); D = read(); 
	N = read() * 4ll;
	
	a = Q / 1.00; b = H / 2.00;
	c = S / 4.00; d = D / 8.00;
		
	if(d < c && d < b && d < a) {
		ans += 1ll * (N / 8) * D;
		N %= 8;
	}
	
	if(c < b && c < a) {
		ans += 1ll * (N / 4) * S;
		N %= 4;
	}
	
	if(b < a) {
		ans += 1ll * (N / 2) * H;
		N %= 2;
	}
	
	ans += 1ll * N * Q; N %= 1;
	write(ans);
	return 0;
}

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

int main() {
  int n,a,b,c,d;
  cin >> n;
  d = n%10;
  c = (n%100-d)/10;
  b = (n%1000-n%100)/100;
  a = (n-b*100-c*10-d)/1000;
  //cout << a << b << c << d << endl;
  if (a==b&&b==c) {
    cout << "Yes" << endl;
  }
  else if (b==c&&c==d) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
  int N;
  cin>>N;
  pair<long long,long long> P[100001];
  P[0]=make_pair(-1000000000,0);
  for(int i=1;i<=N;i++){
    long long X,L;
    cin>>X>>L;
    P[i]=make_pair(X+L,L);
  }
  sort(P,P+N+1);
  int dp[100001]; //dp[i]:x<X[i]+L[i]
  dp[0]=0; dp[1]=1;
  for(int i=2;i<=N;i++){
    long long x=P[i].first-P[i].second*2;
    int left=0;
    int right=i;
    while(right-left!=1){
      int med=(left+right)/2;
      if(P[med].first<=x) left=med;
      else right=med;
    }
    dp[i]=max(dp[i-1],dp[left]+1);
  }
  cout<<dp[N]<<endl;
  
  return 0;
}

Measured memory_bytes: 5108
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	string s;
	cin>>s;
	int n = s.length();
	string x = s.substr(0, n/2);
	string y = s.substr((n/2)+1);
	
	string z = x;
	reverse(z.begin(), z.end());
	string w = y;
	reverse(w.begin(), w.end());
	
	string sr = s;
	reverse(sr.begin(), sr.end());
	
	if(z.compare(x) == 0 && y.compare(w) == 0 && sr.compare(s) == 0) cout<<"Yes"<<en;
	else cout<<"No"<<en;
	
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;
	int W[110];
	rep(i, 0, N)
	{
		cin >> W[i];
		if (0 < i)
		{
			W[i] += W[i - 1];
		}
	}

	int ans = INF;
	rep(i, 1, N)
	{
		chmin(ans, abs(W[N - 1] - W[i - 1] - W[i - 1]));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
XYH = [[int(_) for _ in input().split()] for i in range(N)]

W = 101

cs = [[0] * W for i in range(W)]

XYH.sort(key=lambda e:e[2], reverse=True)

h = XYH[0][2]
sx, sy = XYH[0][0:2]
for x in range(W):
    for y in range(W):
        cs[y][x] = h + abs(x - sx) + abs(y - sy)

#print(cs)

for i in range(1, N):
    h = XYH[i][2]
    sx, sy = XYH[i][0:2]
    for x in range(W):
        for y in range(W):
            h1 = h + abs(x - sx) + abs(y - sy)
            if h > 0:
                if cs[y][x] != h1:
                    cs[y][x] = 0
            else:
                if cs[y][x] > h1:
                    cs[y][x] = 0
    #print(cs)

cx, cy, ch = 0, 0, 0

for x in range(W):
    for y in range(W):
        h = cs[y][x]
        if h > 0:
            cx, cy, ch = x, y, h

print(cx, cy, ch)


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

bool isPrime(int n)  
{  
    // Corner cases  
    if (n <= 1)  return false;  
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;  
    
    for (int i=5; i*i<=n; i=i+6)  
        if (n%i == 0 || n%(i+2) == 0)  
           return false;  
    
    return true;  
} 
int nextPrime(int N) 
{ 
    if (N <= 1) 
        return 2; 
  
    int prime = N; 
    bool found = false; 
    while (!found) { 
        prime++; 
  
        if (isPrime(prime)) 
            found = true; 
    } 
  
    return prime; 
} 
  
// Driver code 
int main()
{ 
    int n;
    cin >>n;
  	if(isPrime(n))
  	{
  		cout<<n;
  		return 0;
	  }
    cout << nextPrime(n); 
  
    return 0; 
} 

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vi a(n);
  vvi x(n), y(n);
  rep(i,n){
    cin >> a[i];
    rep(j,a[i]) {
      int xi, yi;
      cin >> xi >> yi;
      xi--;
      x[i].push_back(xi);
      y[i].push_back(yi);
    }
  }
  int ans = 0;
  rep(i, 1<<n){
    bool ok = true;
    rep(j,n){
      if(ok == false) break;
      if(i>>j & 1){
        rep(k,a[j]){
          if(y[j][k] == 1 && i>>x[j][k] & 1) continue;
          if(y[j][k] == 0 && !(i>>x[j][k] & 1)) continue;
          ok = false;
        }
      }
    }
    if(ok) ans = max(ans, __builtin_popcount(i));
  }
  cout << ans << endl;
}


Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <vector>

int main() {
    int n;
    std::cin >> n;
    std::vector<double> v(n);
    for (int i = 0; i < n; i++) {
        std::cin >> v[i];
    }

    std::sort(v.begin(), v.end());

    double ans = (v[0] + v[1]) / 2;
    for (int i = 2; i < n; i++) {
        ans = (ans + v[i]) / 2;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int c[3][3];
    REP(i,3) REP(j,3) cin>>c[i][j];
    int a[3],b[3];
    a[0]=0;
    REP(i,3) b[i]=c[0][i]-a[0];
    REP(i,3) a[i]=c[i][0]-b[0];
    REP(i,3) REP(j,3) if(a[i]+b[j]!=c[i][j]){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include<type_traits>

using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr ll LONGINF = 1050000000000000000;


int main() {
	int n; cin >> n;
	vector<int> h(n);

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

	h[0] -= 1;

	bool x = true;
	//h[i-1]>(h[i]-1)  false
	for (int i = 1; i < n; i++) {
		if (h[i] == h[i - 1]) {

		}
		else if (h[i - 1] < h[i]) {
			h[i] -= 1;
		}
		else if (h[i - 1] > h[i]) {
			x = false;
		}
	}

	if (x) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}

Measured memory_bytes: 640
/*
   THE DARK NIGHT RISES
I LOVE YOU 72 AND WILL FOREVER DO SO
Patience, Persistence, Perseverance, Passion, Purpose
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
const int N = 2e5 + 20 ;
#define F first
#define S second
# define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mk make_pair
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define sz(x)       (int)x.size()
const long long int mod=1e9 + 7;
const long double EPS=1e-12;
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

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

int solve()
{
  ll n ;
  cin >> n ;
  std::vector<int> h(n);
  rep(i,0,n) cin >> h[i] ;
  std::vector<int> m(100005,1e9);
  m[1] = 0 ;
  for(int i = 1 ; i < n ;i++)
  {
    m[i+1] = min(abs(h[i]-h[i-1])+m[i],m[i+1]);
    m[i+2] = min(abs(h[i+1]-h[i-1])+m[i],m[i+2]);
  }
    cout << m[n] ;




}
int main()
{
  fast;
  ll t;
  t=1;
  //cin>>t;
  while(t--)
  {
    solve();
  }

  return 0;
}
// Patience, Persistence, Perseverance, Passion, Purpose
// I LOVE YOU 72 AND WILL FOREVER DO SO.

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

int main()
{
	int x;
	cin >> x;
	int ans;
	if (x >= 1800)
		ans = 1;
	else if (x >= 1600)
		ans = 2;
	else if (x >= 1400)
		ans = 3;
	else if (x >= 1200)
		ans = 4;
	else if (x >= 1000)
		ans = 5;
	else if (x >= 800)
		ans = 6;
	else if (x >= 600)
		ans = 7;
	else
		ans = 8;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int n;
  cin >> n;
  
  while(n--) {
    string s;
    cin >> s;
    set<string> se;
    for (int i=1;i<s.length();i++) {
      vector<string> s1(2,s.substr(0,i));
      vector<string> s2(2,s.substr(i));
      reverse(ALL(s1[1]));
      reverse(ALL(s2[1]));
      REP(j,2) {
        REP(k,2) {
          se.insert(s1[j]+s2[k]);
          se.insert(s2[k]+s1[j]);
        }
      }
    }
    cout << se.size() << endl;
  }
}

Measured memory_bytes: 992
import java.util.*;

public class Main {
  public static int merge(List<Integer> list, int left, int mid, int right, int count) {
    int n1 = mid - left;
    int n2 = right - mid;
    int[] arrL = new int[n1 + 1];
    int[] arrR = new int[n2 + 1];
    for(int i = 0; i < n1; i++) {
      arrL[i] = list.get(left + i);
    }
    arrL[n1] = Integer.MAX_VALUE;
    for(int i = 0; i < n2; i++) {
      arrR[i] = list.get(mid + i);
    }
    arrR[n2] = Integer.MAX_VALUE;
    int i = 0;
    int j = 0;
    for(int k = left; k < right; k++) {
      if(arrL[i] <= arrR[j]) {
        list.set(k, arrL[i]);
        i++;
      } else {
        list.set(k, arrR[j]);
        j++;
      }
    }
    count += right - left;
    return count;
  }
  public static int mergeSort(List<Integer> list, int left, int right) {
    if(left + 1 < right) {
      int mid = (left + right) / 2;
      int count1 = mergeSort(list, left, mid);
      int count2 = mergeSort(list, mid, right);
      int count = merge(list, left, mid, right, count1 + count2);
      return count;
    } else {
      return 0;
    }
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    List<Integer> arr = new ArrayList<>();
    for(int i = 0; i < n; i++) {
      arr.add(sc.nextInt());
    }
    int count = mergeSort(arr, 0, n);
    for(int i = 0; i < n; i++) {
      if(i == n - 1) {
        System.out.println(arr.get(i));
      } else {
        System.out.print(arr.get(i) + " ");
      }
    }
    System.out.println(count);
  }
}



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

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

  int m, n, k;
  string a[333];
  cin >> m >> n >> k;
  int firstRow = -1;
  for (int i = 0; i < m; i++)
  {
    cin >> a[i];
    for (char c : a[i])
      if (c == '#' && firstRow < 0)
        firstRow = i;
  }

  int ans[333][333];
  for (int i = firstRow, cur = 1; i < m; i++)
  {
    vector<int> strawberries;
    for (int j = 0; j < n; j++)
      if (a[i][j] == '#')
        strawberries.push_back(j);

    if (strawberries.empty())
    {
      for (int j = 0; j < n; j++)
        ans[i][j] = ans[i - 1][j];
    }
    else
    {
      strawberries.push_back(n);
      for (int j = 0; j < strawberries[0]; j++)
        ans[i][j] = cur;
      for (int k = 0; k + 1 < strawberries.size(); k++)
      {
        for (int j = strawberries[k]; j < strawberries[k + 1]; j++)
          ans[i][j] = cur;
        cur++;
      }
    }
  }

  for (int i = firstRow - 1; i >= 0; i--)
    for (int j = 0; j < n; j++)
      ans[i][j] = ans[i + 1][j];

  for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++)
      cout << ans[i][j] << " \n"[j == n - 1];
}


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

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

const int MOD=1e9+7;
const int INF=1<<30;
const int MAX=1e5;

int n;

template<class T>
inline void xmin(T &a, T b){a=(a<b)?a:b;}
template<class T>
inline void xmax(T &a, T b){a=(a>b)?a:b;}

int a,b;

void solve(){
    cin>>a>>b;
    if(a>9 || b>9){
        cout<<-1<<endl;
    }else{
        cout<<a*b<<endl;
    }
}

signed main(){
    //while(1)
    solve();
}


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

using namespace std;
using ll = long long;

vector<long long> primes;
vector<int> freq(1000'001, 0);

void calc(){
    int n = 1000000;
    vector<char> is_prime(n + 1, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i * i <= n; i++) {
        if (is_prime[i]) {
            primes.push_back(i);
            for (int j = i * i; j <= n; j += i)
                is_prime[j] = false;
        }
    }
}

void trial(long long n) {
    for (long long d : primes) {
        if (d * d > n)
            break;
        bool first = true;
        while (n % d == 0) {
            if(first)
                freq[d]++;
            first = false;
            n /= d;
        }
    }
    if (n > 1)
        freq[n]++;
}


int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    int i, n, m, j, u, v;
    cin >> n;
    calc();
    for(i = 0; i < n; i++){
        cin >> u;
        trial(u);
    }
    for(i = 0; i <= 1000'000; i ++){
        if(freq[i] == n){
            cout << "not coprime" << endl;
            return 0;
        }
    }

    for(i = 0; i <= 1000'000; i ++){
        if(freq[i] > 1){
            cout << "setwise coprime" << endl;
            return 0;
        }
    }
    
    cout << "pairwise coprime" << endl;
}

Measured memory_bytes: 8188
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

const int N = 100100;
VI edges[N];

ll dp[N];

void dfs(int v, int par) {
  VL ch;
  ll orl = 0;
  for (auto w: edges[v]) {
    if (w == par) { continue; }
    dfs(w, v);
    ch.push_back(dp[w]);
    orl |= dp[w];
  }
  vector<int> hb(64);
  REP(b, 0, 64) {
    int cnt = 0;
    for (ll t: ch) {
      if (t & (1LL << b)) {
	cnt += 1;
      }
    }
    hb[b] = cnt;
  }
  int c = 0;
  REP(b, 0, 64) {
    if (hb[b] >= 2) {
      c = b + 1;
    }
  }
  int t = -1;
  REP(b, c, 64) {
    if (hb[b] == 0) {
      t = b;
      break;
    }
  }
  ll mask = 1LL << t;
  dp[v] = (orl & ~(mask - 1)) | mask;
}

// This was implemented after the author read the editorial.
int main(void){
  int n;
  cin >> n;
  REP(i, 0, n - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  dfs(0, -1);
  int b = 0;
  REP(i, 0, 64) {
    if (dp[0] & 1LL << i) {
      b = i;
    }
  }
  cout << b << endl;
}


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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;
        private struct Data
        {
            public long a;
            public long b;
        }
        static void Solve()
        {
            var o = ReadAndParseLongArr();
            long n = o[0];
            long k = o[1];
            var datas = new List<Data>((int)n);
            for(int i=0;i<n;++i)
            {
                o = ReadAndParseLongArr();
                datas.Add( new Data()
                {
                    a = o[0],
                    b = o[1]
                });
            }
            datas.Sort((a, b) => a.a.CompareTo(b.a));

            var acc = new long[n];
            for(int i=0;i<n;++i)
            {
                acc[i] = datas[i].b;
            }
            for(int i=1;i<n;++i)
            {
                acc[i] += acc[i - 1];
            }
            
            long ans = 0;
            for(int i=0;i<n;++i)
            {
                if(k<= acc[i])
                {
                    ans = datas[i].a;
                    break;
                }
            }
            Console.WriteLine(ans);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 17588
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 510, mod = 1e9+7;
int n,m,a[N],cnt[N],dp[N][N][N];

inline void upd(int &x,int y){
	x+=y;
	if (x>=mod) x-=mod;
}
inline int power(int a,int b){
	int ret=1;
	for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) ret=1ll*ret*a%mod;
	return ret;
}
int fac[N],ifac[N],pw[N][N];
inline void init(int n){
	fac[0]=1;
	For(i,1,n) fac[i]=1ll*fac[i-1]*i%mod;
	ifac[n]=power(fac[n],mod-2);
	Dow(i,n-1,0) ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
	pw[0][0]=1;
	For(i,1,n){
		pw[i][0]=1;
		For(j,1,n) pw[i][j]=1ll*pw[i][j-1]*i%mod;
	}
}
inline int C(int n,int m){
	if (n<m||m<0) return 0;
	return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}

int main(){
	n=read(),m=read();
	For(i,1,n) cnt[read()]++;
	init(max(n,m));
	dp[m+1][0][0]=1;
	Dow(k,m+1,2) For(i,0,m) For(j,0,m/k) if (dp[k][i][j]){
		For(l,0,m/(k-1)){
			//dp[k][i][j]->dp[k-1][i+l*(k-1)][j+l]
			int tmp=1ll*dp[k][i][j]*pw[i+(k-1)*l-(k-2)*(j+l)][cnt[k-1]]%mod;
			upd(dp[k-1][i+l*(k-1)][j+l],1ll*tmp*ifac[l]%mod);
		}
	} 
	int ans=0;
	For(i,0,m) For(j,0,m) if (dp[1][i][j]){
		if (j-1>m-i) continue;
		int tmp=1ll*dp[1][i][j]*fac[j]%mod,x=m-i-(j-1),y=j+1;
		tmp=1ll*tmp*C(x+y-1,y-1)%mod;
		if ((m-i)&1) upd(ans,mod-tmp);
			else upd(ans,tmp); 
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 385744
#include<iostream>
using namespace std;
int k1;
long long ans,ans1;
int main(){
	int n,k;
	cin>>n>>k;
	ans=n/k;
	if(k%2==0){
		ans1=n/k+(n%k>=k/2);
	}
	long long ret=ans*ans*ans+ans1*ans1*ans1;
	cout<<ret<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
 	int a,b,c,i;	
  	int ans = 0;
 
  scanf("%d %d %d",&a,&b,&c);
  
  if(a<=b*c){
   printf("Yes");
    return 0;
  }
  
  printf("No");
  return 0;
}

Measured memory_bytes: 1724
n, m = [int(i) for i in input().split()]
X = [[int(i) for i in input().split()] for j in range(m)]

red = [False] * (n+1)
num = [1] * (n+1)

red[1] = True

for x, y in X:
    num[x] -= 1
    num[y] += 1

    if red[x]:
        red[y] = True    
        if num[x] == 0:
            red[x] = False

print(red.count(True))

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

#define int long long int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ff first
#define ss second
#define pb push_back

const int N = 1e5+5;
int a[N],dp[N];

int32_t main()
{
	IOS;
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=0;i<N;i++)
		dp[i] = 1e9;
	dp[1] = 0;
	dp[2] = abs(a[2]-a[1]);

	for(int i=3;i<=n;i++)
	{
		for(int j=1;j<=k && j<i;j++)
			dp[i] = min(abs(a[i]-a[i-j])+dp[i-j],dp[i]);
	}
	cout<<dp[n]<<endl;


	return 0;
}

Measured memory_bytes: 1792
// Why am I so dumb? :c
// chrono::system_clock::now().time_since_epoch().count()

//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;   
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int MAXN = (int)2e5 + 5;

char s[MAXN];

int cnt[26];

ll ans;

int n;

void solve() {
    scanf("%s", s);

    for (n = 0; s[n]; ++n);

    ans = 1;

    for (int i = 0; i < n; ++i) {
        int c = s[i] - 'a';
        ans += i;
        ans -= cnt[c]++;        
    }

    printf("%lld\n", ans);
}

int main() {
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 384
public class Main {


  private static void solve() {
    int n = ni();
    int h = ni();
    int w = ni();
    
    System.out.println((n - h + 1) * (n - w + 1));
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 22356
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;

static class Program
{
    static int Solve(int X)
    {
        for (int i = 1; true; ++i)
        {
            if (X >= 2000 - i * 200) { return i; }
        }
    }

    static void Main(string[] args)
    {
        int X = int.Parse(Console.ReadLine());
        Console.WriteLine(Solve(X));
    }
}


Measured memory_bytes: 27520
import java.util.Scanner

import scala.collection.mutable

object Main extends App {
  val sc = new Scanner(System.in)
  val n = sc.nextInt()
  val k = sc.nextInt()
  val hasOkashi = mutable.BitSet.empty
  (1 to k).foreach { i =>
    val d = sc.nextInt()
    (1 to d).foreach { j =>
      val sunukeNo = sc.nextInt()
      hasOkashi += sunukeNo
    }
  }
  println(n - hasOkashi.size)
}


Measured memory_bytes: 57308
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){
    int N,M,sum=0,a,b,ans;
    cin >> N;
    vector<int> vec(N);
    REP(i,N){
        cin >> vec[i];
        sum += vec[i];
    }

    cin >> M;
    for(int i=0;i<M;i++){
        cin >> a >> b;
        ans  = sum -(vec[a-1]) + b;

        cout << ans << endl;
    }
}

Measured memory_bytes: 256