akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, f, s;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	f = 0;
	s = f + abs(a[1] - a[0]);
	for (int i = 2; i < n; i++) {
		int curr = min(s + abs(a[i] - a[i - 1]), f + abs(a[i] - a[i - 2]));
		f = s;
		s = curr;
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 4004
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	cout<<max(0,c-(a-b))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

const int MN = 188;

int N, M, J;
char a[MN][MN];
int f[MN][MN][MN], g[MN][MN][MN];

int main() {
	scanf("%d%d", &N, &M);
	for (int i = 1; i <= N; ++i) scanf("%s", a[i] + 1);
	int tN = N - 1, tM = M - 1;
	while (tN) ++J, tN >>= 1;
	while (tM) ++J, tM >>= 1;
	for (int l = 1; l <= N; ++l)
		for (int r = l; r <= N; ++r) {
			f[l][r][M + 1] = M;
			for (int j = M; j >= 1; --j) {
				int o = l == r || (a[l][j] == a[r][j] && f[l][r - 1][j] >= j);
				if (!o) f[l][r][j] = j - 1;
				else f[l][r][j] = a[l][j] == a[l][j + 1] ? f[l][r][j + 1] : j;
			}
		}
	for (int l = 1; l <= M; ++l)
		for (int r = l; r <= M; ++r) {
			g[l][r][N + 1] = N;
			for (int i = N; i >= 1; --i) {
				int o = l == r || (a[i][l] == a[i][r] && g[l][r - 1][i] >= i);
				if (!o) g[l][r][i] = i - 1;
				else g[l][r][i] = a[i][l] == a[i + 1][l] ? g[l][r][i + 1] : i;
			}
		}
	if (f[1][N][1] == M) return puts("0"), 0;
	for (int k = 1; k <= J; ++k) {
		for (int l = 1; l <= N; ++l)
			for (int r = l; r <= N; ++r)
				for (int j = 1; j <= M; ++j)
					f[l][r][j] = f[l][r][f[l][r][j] + 1];
		for (int l = 1; l <= M; ++l)
			for (int r = l; r <= M; ++r)
				for (int i = 1; i <= N; ++i)
					g[l][r][i] = g[l][r][g[l][r][i] + 1];
		for (int i = 1; i <= N; ++i)
			for (int j = 1; j <= M; ++j) {
				static int A[MN], B[MN];
				for (int z = i; z <= N; ++z) A[z] = f[i][z][j];
				for (int z = j; z <= M; ++z) B[z] = g[j][z][i];
				A[N + 1] = j - 1, B[M + 1] = i - 1;
				for (int z = i; z <= N; ++z)
					for (int w = A[z]; w > A[z + 1]; --w)
						g[j][w][i] = std::max(g[j][w][i], z);
				for (int z = j; z <= M; ++z)
					for (int w = B[z]; w > B[z + 1]; --w)
						f[i][w][j] = std::max(f[i][w][j], z);
			}
		if (f[1][N][1] == M) return printf("%d\n", k), 0;
	}
	return 0;
	puts("PinkRabbit");
}

Measured memory_bytes: 51200
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

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

    ll ans = 0;
    ll xa = min(K,a);
    ans += xa;
    K -= xa;
    ll xb = min(K, b);
    K -= xb;
    ll xc = min(K, c);
    K -= xc;
    ans-= xc; 
    //cerr << xa << " " << xb << " " << xc << endl;
    cout << ans << endl;
}


Measured memory_bytes: 3556
N = int(input())
L = list(map(int,input().split()))
L.sort()
#print(L)
cnt = 0
for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      #print(L[i],L[j],L[k])
      if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
        if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j]:
          cnt += 1
print(cnt)

Measured memory_bytes: 9140
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cctype>
#define INF 1000000000
using namespace std;
bool debug=false;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    long long ans;
    for(ans=0;ans<=15000000;ans++){
        if(a%2==1||b%2==1||c%2==1)break;
        int tmpa=a/2,tmpb=b/2,tmpc=c/2;
        a=tmpb+tmpc;
        b=tmpa+tmpc;
        c=tmpa+tmpb;
    }    
    if(ans>=15000000)cout<<-1<<endl;
    else cout<<ans<<endl;
   return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

struct BIT{
private:
  vector<int> array;
  int n;
public:
  BIT(int _n):array(_n+1,0),n(_n){}

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

  int add(int i){
    i++;
    while(i<=n){
      array[i]++;
      i+=i&-i;
    }
  }
};

int main(){
  LL n,a,b;
  cin >> n >> a >> b;
  vector<int> p(n);
  vector<int> pos(n);
  for(int i=0;i<n;i++){
    cin >> p[i];
    p[i]--;
    pos[p[i]]=i;
  }
  vector<vector<LL>> dp(n,vector<LL>(n,0));
  BIT bit(n);
  bit.add(pos[0]);
  for(int i=1;i<n;i++){
    for(int j=0;j<n;j++){
      if(pos[i]>j) dp[i][j]=dp[i-1][j];
      else{
        dp[i][j]=min((bit.sum(j)-bit.sum(pos[i])==0?0:a)+dp[i-1][j],b*(bit.sum(j)-bit.sum(pos[i]))+(pos[i]>0?dp[i-1][pos[i]-1]:0));
      }
      // cout << dp[i][j] << " ";
    }
    bit.add(pos[i]);
    // cout << endl;
  }
  cout << dp[n-1][n-1] << endl;
  return 0;
}


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

long long N;
void func(long long cur, int use, long long &counter){
    if (cur > N) return; // ベースケース
    if (use == 0b111) ++counter; // 答えを増やす

    // 7 を付け加える
    func(cur * 10 + 7, use | 0b001, counter);

    // 5 を付け加える
    func(cur * 10 + 5, use | 0b010, counter);

    // 3 を付け加える
    func(cur * 10 + 3, use | 0b100, counter);
}

int main() {
    cin >> N;
    long long res = 0;
    func(0, 0, res);
    cout << res << endl;
}


Measured memory_bytes: 256
n,m,l=map(int,input().split())

lsta=[[int(a) for a in input().split()] for x in range(n)]
lstb=[[int(b) for b in input().split()] for y in range(m)]

for i in range(n):
    rows=[]
    for j in range(l):
        lstc=[]
        for k in range(m):
            c=lsta[i][k]*lstb[k][j]
            lstc.append(c)
        rows.append(sum(lstc))
    print(*rows)
    


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

int main(){
    string S;
    cin >> S;
    int num = 0;
    int ans = 0;
    for (int i = 0; i < S.size(); i++){
        if (S[i] == 'A' ||S[i] == 'T' ||S[i] == 'G' ||S[i] == 'C'){
            num++;
            ans = max(ans, num);
        }
        else num = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3580
n = int(input())
a = [int(item) for item in input().split()]

# sum must be 1+2+3+...+n
asum = sum(a)
if asum % ((n + 1)*n // 2) != 0:
    print("NO")
    exit()
k = asum // ((n + 1)*n // 2)

# Drop must be k
a.append(a[0])
drop = 0
for i in range(n):
    diff = a[i] + k - a[i+1]
    if diff == 0:
        continue
    else:
        if diff % n != 0 or diff < 0:
            print("NO")
            exit()
        else:
            drop += diff // n
if drop != k:
    print("NO")
    exit()

print("YES")

Measured memory_bytes: 14104
import java.util.Scanner;

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

		int[] x = new int[5];
		int pos = 0;
		for (int i = 0; i < 5; i++) {
			x[i] = sc.nextInt();
			if (x[i] == 0) {
				pos = i + 1;
			}
		}
		System.out.println(pos);
	}
}


Measured memory_bytes: 26908
#include<bits/stdc++.h>
#define pi acos(-1)
#define mx 1500000
#define mod 1000000007
#define pii pair<int,int>
typedef long long ll;
using namespace std;
void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main()
{
    fastio();
    int i,j,t,n,k,l,x,y;
    //cin>>t;
    //while(t--){
     string w;
     cin>>w;
     int v[28]={0};
     //cout<<w<<endl;
     for(i=0;i<w.size();i++){
        k=w[i]-97;
        v[k]++;
         }
      for(i=0;i<28;i++){
        if(v[i]%2==1){
            cout<<"No"<<endl;
            return 0;
        }
      }
     cout<<"Yes"<<endl;
     //}
 return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>
int main(void){
 
	//3つの狼の合計が偶数->〇
	//S->0 W->1
	//S->0x53
	//W->0x57
	//o->0x6f
	//x->0x78
	//012345
	//oxooxo
	//SSWWSS
	long long int N, i, h, x = 0, ok = 0;
	char c;
	static char say[100005];
	static long long int dou[100005];
	long long int  sta[2];
	volatile int stop;
	scanf("%lld", &N);
	fflush(stdin);
	for (i = 0; i < N; i++) {
		scanf(" %c", &say[i]);
	}say[N] = say[0]; say[N + 1] = say[1]; say[N + 2] = say[2];
	for (h = 0; h < 4; h++) {
		if (h == 0) { sta[0] = 0; sta[1] = 0; }
		if (h == 1) { sta[0] = 0; sta[1] = 1; }
		if (h == 2) { sta[0] = 1; sta[1] = 0; }
		if (h == 3) { sta[0] = 1; sta[1] = 1; }
		dou[0] = sta[0];
		dou[1] = sta[1];
		for (i = 2; i < N + 2; i++) {
			if (say[i - 1] == 0x6f) { x = 0; }
			else { x = 1; }
			if ((x + dou[i - 1] + dou[i - 2]) % 2 == 1) { dou[i] = 1; }
			else { dou[i] = 0; }
		}
		if (dou[N] == sta[0] && dou[N + 1] == sta[1]) {
			dou[1] = dou[N + 1];
			for (i = 0; i <N; i++) {
				if (dou[i] == 0) { c = 0x53; }
				else { c = 0x57; }
				printf("%c", c);
				ok = 1;
			}
			break;
		}
	}
	if (ok == 0) { printf("-1"); }
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> H(n);
  for (ll i = 0; i < n; i++) cin >> H[i];
  sort(H.begin(), H.end());
  ll sum = 0;
  for (ll i = 0; i < n - k; i++) {
    sum += H[i];
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 1792
import sys

def main():
    input = sys.stdin.readline
    n, k = map(int, input().split())
    a = [int(x) for x in input().split()]
    key = 30
    nn = n
    while nn > 0:
        key += 1
        nn //= 2
    
    for _ in range(min([key, k])):
        b = [0]*n
        for i in range(n):
            l, r = max([i-a[i], 0]), min([i+a[i], n-1])
            b[l] += 1
            if r != n-1:
                b[r+1] -= 1
        for i in range(n):
            a[i] = 0
            a[i] += b[i]
            if i != 0:
                 a[i] += a[i-1]
    print(*a)

if __name__ == "__main__":
    main()



Measured memory_bytes: 164160
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int X, A, B;
	cin >> X >> A >> B;
	X -= A;
	while (X - B >= 0) {
		X -= B;
	}
	cout << X << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n,i;
  long l[90];
  scanf("%d",&n);
  l[0]=2;
  l[1]=1;
  for (i=2;i<=n;i++) l[i]=l[i-1]+l[i-2];
  printf("%ld\n",l[n]);
  return 0;
}

Measured memory_bytes: 128
n,m,l=gets.split(' ')
n=n.to_i
m=m.to_i
l=l.to_i

X=Array.new(n){Array.new(m)}
Y=Array.new(m){Array.new(l)}
Z=Array.new(n){Array.new(l)}
for i in 1..n do
    X[i-1]=gets.split(' ').map(&:to_i)
end
for j in 1..m do
    Y[j-1]=gets.split(' ').map(&:to_i)
end

for p in 0..n-1
  for r in 0..l-1
    e=0
    for q in 0..m-1
      e+=X[p][q]*Y[q][r]
    end
    Z[p][r]=e
  end
end

for p in 0..n-1
  for r in 0..l-1
     if r<l-1 then
     printf("%d ", Z[p][r])
     else
     printf("%d\n", Z[p][r])
     end
  end
end

Measured memory_bytes: 9248
#include<stdio.h>
int main()
{
	int a, b;

	scanf("%d %d", &a, &b);
	if (1 < a < 100, 1 < b < 100){
		printf("%d %d\n", a*b, 2 * a + 2 * b);
	}
	
	else{ printf("error"); };

	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

int main()
{
   int k,x;
   cin >> k >> x;
   if(k*500>=x)
   {
      cout<<"Yes"<<endl;
   }
   else
   {
      cout<<"No"<<endl;
   }
   
   return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
#include<ios>
#include<iomanip>
//#include <boost/multiprecision/cpp_int.hpp>

//namespace mp = boost::multiprecision;
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
//using Bint = mp::cpp_int;


int main()
{
	int R,G,B,N;
	ll res=0;
	cin>>R>>G>>B>>N;
	vector<int>TR;
	for(int i=0;i*R<=N;i++)TR.push_back(N-(i*R));
	for(int i=0;i<TR.size();i++)
	{
		for(int g=0;TR[i]>=g*G;g++)
		{
			if((TR[i]-g*G)%B==0)res++;
		}
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void replace(string &str, int a, int b, string p) {

    for (int i = 0; i <= (b - a); i++) {
        str[i + a] = p[i];
    }
}

void reverse(string &str, int a, int b) {
    string newStr = str;

    for (int i = a, j = b; i <= b; i++, j--) {
        newStr[i] = str[j];
    }

    str = newStr;
}

void print(string str, int a, int b) {
    for (int i = a; i <= b; i++) {
        cout << str[i];
    }
    cout << "\n";
}


int main() {
    string str;
    cin >> str;

    int n;
    cin >> n;

    string order;
    int a, b;

    for (int i = 0; i < n; i++) {
        cin >> order;
        cin >> a >> b;
        
        if (order == "print") {
            print(str, a, b);
        } else if (order == "reverse") {
            reverse(str, a, b);
        } else if (order == "replace") {
            string p;
            cin >> p;
            replace(str, a, b, p);
        }
    }
}

Measured memory_bytes: 3196
from itertools import combinations
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

X,A=LI()
if X < A:
    print(0)
else:
    print(10)

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

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i=0; i<n; i++){
        int a; cin >> a;
        while(a%2 == 0){
            ans++;
            a /= 2;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int r, w, c, k;
    while (cin >> r >> w >> c >> k, r || w || w || c || k) {
        int ans = ceil(double(w * c - r) / k);
        cout << (ans >= 0 ? ans : 0) << endl;
    }
    
    return 0;
}

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

#define rep(i, k, n) for(int i = (k); i < (n); i++)
#define irep(i, k, n) for(int i = (k); i > (n); i--)
using namespace std;
using ll = long long;

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

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
typedef long long lli;
const int maxn = 2e5 + 5;
const lli INF = 1e12 + 5;
int n;
lli K;

vector<int> a, f;

void ReadInput()
{
    cin >> n >> K;
    a.resize(n); f.resize(n);
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    for(int i = 0; i < n; ++i)
        cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.begin(), f.end());
    reverse(f.begin(), f.end());
}

bool Check(lli x)
{
    lli cnt = 0;
    for(int i = 0; i < n; ++i)
    {
        lli temp = 1LL * a[i] * f[i];
        if(temp <= x) continue;
        lli dif = temp - x;
        lli t = dif / f[i];
        if(dif % f[i] != 0) ++t;
        cnt += min(t, (lli)a[i]);
        if(cnt > K) return false;
    }
    return true;
}

void Solve()
{
    lli low = 0, high = INF;
    while(low <= high)
    {
        lli mid = (low + high) / 2;
        if(Check(mid)) high = mid - 1;
        else low = mid + 1;
    }
    cout << low << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ReadInput();
    Solve();
}


Measured memory_bytes: 1792
#pragma warning(disable:4996)
#include <stdio.h>

int main(void) {
	char s[11];
	int a;
	scanf("%d%s", &a, s);
	if (a >= 3200) {
		printf("%s\n", s);
		return 0;
	}
	else {
		printf("red\n");
		return 0;
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll div_ceil(ll, ll);
vector<ll> divisor(ll);

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

int main() {
  ll N;
  std::cin >> N;
  std::vector<ll> v;
  v = divisor(N);
  ll sum = 0;
  for (auto i : v) {
    ll m = N / i - 1;
    if (i < m) {
      sum += m;
    } else {
      break;
    }
  }
  std::cout << sum << '\n';
}

ll div_ceil(ll a, ll b) {
  ll quotient = a / b;
  ll remainder = a % b;
  if (remainder == 0) {
    return quotient;
  } else {
    return quotient + 1;
  }
}

vector<ll> divisor(ll n) {
  vector<ll> v;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      v.PB(i);
      if (i * i != n) {
        v.PB(n / i);
      }
    }
  }
  sort(ALL(v));
  return v;
}


Measured memory_bytes: 384
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), math.MaxInt32)
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		return []byte(f1())
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

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

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

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

func main() {
	defer stdout.Flush()
	N := readInt()
	S := readString()

	dp := make([][]X, N)
	for i := range dp {
		dp[i] = make([]X, N)
	}

	var maxstreak int

	for i := 0; i < N; i++ {
		for j := 0; j < i; j++ {
			if S[i] != S[j] {
				continue
			}
			if j == 0 {
				maxstreak = max(maxstreak, 1)
				dp[i][j].streak = 1
				dp[i][j].origin = i
				continue
			}
			pi, pj := i-1, j-1
			if dp[pi][pj].streak == 0 {
				maxstreak = max(maxstreak, 1)
				dp[i][j].streak = 1
				dp[i][j].origin = i
				continue
			}
			dp[i][j].streak = dp[pi][pj].streak + 1
			dp[i][j].origin = dp[pi][pj].origin
			if dp[pi][pj].origin == j {
				dp[i][j].streak--
				dp[i][j].origin++
			}
			maxstreak = max(maxstreak, dp[i][j].streak)
		}
	}

	println(maxstreak)
}

type X struct {
	streak int
	origin int
}

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


Measured memory_bytes: 411776
//#include <iostream>
#include <stdio.h>

void display(int a[],int n){
    int i;
    for (i = 0; i < n; ++i) {
        if (i>0)
            printf(" ");
        printf("%d",a[i]);
    }
    printf("\n");
}

void insertionSort(int a[],int n){
    int v,i,j;
    for (i = 1; i < n; ++i) {
        v=a[i];
        for (j = i-1; j >=0&&a[j]>v ; --j) {
            a[j+1]=a[j];
        }
        a[j+1]=v;

        display(a,n);
    }
}


int main() {
    int n,i;
    int a[150];
    scanf("%d",&n);
    for (i = 0; i < n; ++i) {
        scanf("%d",&a[i]);
    }

    display(a,n);
    insertionSort(a,n);

    return 0;
}

Measured memory_bytes: 604
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  vs v = {"0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "1111111", "1101111"};
  while (cin >> n, n != -1) {
    string s = "0000000";
    while (n--) {
      int d;
      cin >> d;
      string t = v[d], diff = "";
      rep(i, 7) diff += s[i] == t[i] ? "0" : "1";
      cout << diff << endl;
      s = t;
    }
  }
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        int N, Q;
        cin >> N >> Q;
        if(N == 0) break;
        map<int, int> mp;
        while(N--) {
            int M;
            cin >> M;
            while(M--) {
                int d;
                cin >> d;
                mp[d]++;
            }
        }
            int ans = INF;
            for(int i = 0; i < 100; i++) {
                if(mp[i] > mp[ans]) ans = i;
            }
            if(mp[ans] < Q) ans = 0;
            cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3124
#include<iostream>
#include<stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
     
int main(){
  //整数の時はint
  int  n,ans;
  //文字の時はstring
  //string s;
      
  cin>>n;
  if(!(n%1000))
    ans=(n/1000)*1000-n;
  else
    ans=(n/1000+1)*1000-n;
  cout<<ans<<endl;
  return 0;
}


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

const int N = pow(10,9) + 7;

LL pow2(LL n){
    LL ans = 1;
    for(LL i = 0; i < n; ++i){
        ans = (ans * 2) % N;
    }

    return ans;
}

int main(){
    LL n;
    cin >> n;
    vector<LL> a(n);
    for(LL i = 0; i < n; ++i) cin >> a[i];

    LL ans = 0;

    for(LL i = 0; i <= 60; ++i){
        LL count1 = 0;
        for(LL j = 0; j < n; ++j) if(a[j] >> i & 1) count1++;
        LL count0 = n - count1;
        LL comb = ((count0 % N) * (count1 % N)) % N;
        ans += pow2(i) * comb % N;
        ans %= N;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define x first
#define y second
#define int int long long // 2e9 & 9e18
using namespace std; const int inf = numeric_limits<int>::max();
struct __io{__io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}} __io; // fast I/O
#ifdef LOCAL // setting up print debugging (yes lol)
template<class K, class V>ostream& operator<<(ostream&s,const pair<K,V>&p){s<<'<'<<p.x<<", "<<p.y<<'>';return s;}
template<class T, class=typename T::value_type, class=typename enable_if<!is_same<T,string>::value>::type>
ostream& operator<<(ostream&s,const T&v){s<<'[';for(auto&x:v){s<<x<<", ";}if(!v.empty()){s<<"\b\b";}s<<']';return s;}
void __prnt(){cerr<<endl;} template<class T, class...Ts>void __prnt(T&&a,Ts&&...etc){cerr<<a<<' ';__prnt(etc...);}
#define print(...) __prnt(__VA_ARGS__)
#else
#define print(...)
#endif

int n, m;

signed main() {
    cin >> n >> m;
    vector<int> good(n, 1);
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    int u, v;
    for (int i = 0; i < m; ++i) {
        cin >> u >> v;
        u--, v--;
        if (h[u] <= h[v]) good[u] = 0;
        if (h[u] >= h[v]) good[v] = 0;
    }

    int count = 0;
    for (int i = 0; i < n; ++i) {
        if (good[i]) ++count;
    }
    cout << count << endl;
}


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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> right;
    vector<int> left;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(x >= 0){
            right.push_back(x);
        }else{
            left.push_back(abs(x));
        }
    }
    sort(right.begin(), right.end());
    sort(left.begin(), left.end());

    int ans = 1000000000;

    for(int i = 0; i <= k; i++){//iは左側の数
        int migi_hashi = k-i;
        if(migi_hashi <= right.size() && i <= left.size()){
            if(i>0 && migi_hashi >0){
                int ouhuku = min(left[i-1], right[migi_hashi-1]);
                int dist = left[i-1] + right[migi_hashi-1] + ouhuku;
                ans = min(ans, dist);
            }else if(i == 0){
                int dist = right[migi_hashi-1];
                ans = min(ans, dist);
            }else if(migi_hashi == 0){
                int dist = left[i-1];
                ans = min(ans, dist);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

w,h,n = map(int, input().split())
x = ["" for _ in range(n)]
y = ["" for _ in range(n)]
a = ["" for _ in range(n)]

for i in range(n):
    x[i], y[i], a[i] = map(int, input().split())

hl = 0
hh = 0
wl = 0
wh = 0
for i in range(n):
    if a[i] == 1:
        wl = max(wl, x[i])
    if a[i] == 2:
        wh = max(wh, w - x[i])
    if a[i] == 3:
        hl = max(hl, y[i])
    if a[i] == 4:
        hh = max(hh, h - y[i])

"""
print("wl :", wl)
print("wh :", wh)
print("hl :", hl)
print("hh :", hh)
"""

ans_w = w - (wl+wh)
ans_h = h - (hl+hh)

if ans_w < 0 or ans_h < 0:
    print(0)
else:
    print(ans_w*ans_h)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int n;
	int dp[2][111] = {10000000};
	vector<int> a[2];
	cin >> n;
	if(n==0) break;
	REP(i,n){
	    int temp;
	    cin >> temp;
	    a[0].PB(temp);
	}
	REP(i,n){
	    int temp;
	    cin >> temp;
	    a[1].PB(temp);
	}

	int d[] = {0,1,2};
	REP(i,2)REP(j,111)dp[i][j] = 10000000;
	queue<int> p;
	queue<int> w;
	p.push(0);
	p.push(0);
	w.push(0);
	w.push(1);
	dp[0][0] = 0;
	dp[1][0] = 0;
	while(!p.empty()){
	    int i = p.front();
	    int ww = w.front();
	    if(i == 0){
		while(a[ww][i]==1){
		    i++;
		    if(i==n||a[ww][i]!=1){
			i--;
			dp[ww][i] = 0;
			break;
		    }
		}
	    }
	    p.pop();
	    w.pop();
	    REP(k,3){
		int ni = i + d[k];
		int num = (ww+1)%2;
		if(ni>=n) break;
		while(a[num][ni]==1){
		    ni++;
		    if(ni==n || a[num][ni]!=1){
			ni--;
			break;
		    }
		}
		while(a[num][ni]==2){
		    ni--;
		    if(ni==0) break;
		}
		if((dp[ww][i]+1)<dp[num][ni]){
		    dp[num][ni] = dp[ww][i]+1;
		    p.push(ni);
		    w.push(num);
		}
	    }
	}
	int ans = 10000000;
	REP(j,2){
	    ans = min(ans,dp[j][n-1]);
	}
	if(ans >= 10000000) cout << "NA" << endl;
	else cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int h,w, a[101][101], b[101][101], c[101][101];
bool dp[81][81][80*161];
void solve(){
	cin >> h >> w;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> a[i][j];
		}
	}
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> b[i][j];
			c[i][j] = abs(a[i][j]-b[i][j]);
		}
	}
	
	dp[0][0][c[0][0]] = 1;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			for(int k = 0; k < 80*160; k++){
				if(dp[i][j][k]){
					dp[i+1][j][k+c[i+1][j]] = 1;
					dp[i][j+1][k+c[i][j+1]] = 1;
					dp[i+1][j][abs(k-c[i+1][j])] = 1;
					dp[i][j+1][abs(k-c[i][j+1])] = 1;
				}
			}
		}
	}
	for(int k = 0; k < 80*160; k++){
		if(dp[h-1][w-1][k]){
			cout << k << endl;
			break;
		}
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 82048
K , N = map ( int , input().strip().split(" " ) ) ; 
arr = list ( map ( int , input().strip().split(" ") ) ) ; 


y = K ;
for p1 in range ( N ) :
	p2 = ( p1 -1 + N )  %  N ;
	if arr[p1] > arr[p2] :
		l1 = K - arr[p1] + arr[p2] ;	
	else :
		l1 = arr[p2] - arr[p1] ;
	
	p2 = ( p1 + 1 + N ) % N ; 
	if arr[p1] > arr[p2] : 
		l2 = arr[p1] - arr[p2] ;
	else:
		l2 = K - arr[p2] + arr[p1] ;
	l = min ( l1 , l2 ) ;
	y = min ( y , l1 ) ;
print ( y ) ;

Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0; i < N; i++)


int main()
{
  int H, W, N;
  char c;
  int sum[1005][1005][3];
  fill(sum[0][0],sum[1004][1005],0);
  cin >> H >> W >> N;
  for(int i = 1; i <= H; i++) {
    for(int j = 1; j <= W; j++) {
      scanf(" %c",&c);
      if(c == 'J') sum[i][j][0]++;
      else if(c == 'O') sum[i][j][1]++;
      else sum[i][j][2]++;
      Rep(k,3) {
	sum[i][j][k] += sum[i - 1][j][k] + sum[i][j - 1][k] - sum[i - 1][j - 1][k];
      }
    }
  }

  int A, B, C, D;
  while(N--) {
    cin >> A >> B >> C >> D;
    Rep(i,3) {
      cout << sum[C][D][i] - sum[A - 1][D][i] - sum[C][B - 1][i] + sum[A - 1][B - 1][i];
      if(i == 2)cout << endl;
      else cout << " ";
    }
  }
  return 0;
}

Measured memory_bytes: 14968
#include <iostream>
#include <string>
#include <cstring>
#include <queue>
#include <functional>

using namespace std;

#define ERROR_ID		0

#define PROCESS_ERROR(Condition)    \
{                                   \
		if (!(Condition))           \
		{                           \
			goto Exit0;             \
		}                           \
}

typedef unsigned char       BYTE;
typedef int                 BOOL;
typedef unsigned long       DWORD;
typedef long long			LLONG;

int main(int argc, char* argv[])
{
	string			szTargetStr;
	int				nLength;

	cin >> szTargetStr;

	nLength = szTargetStr.size() - 2;

	cout << szTargetStr[0] << nLength << szTargetStr[nLength + 1] << endl;
	return 0;
}

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

int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    int ct=0;
    while(1){
        bool flag = true;
        rep(i,n){
            if(a[i]%2!=0){
                flag = false;
                break;
            }
            a[i]/=2;
        }
        if(!flag) break;
        ct++;
    }
    cout << ct << endl;
}

Measured memory_bytes: 256
n = int(input())

x = dict()
for i in input().split():
    x[i] = x.get(i, 0) + 1

m = int(input())

y = dict()
for i in input().split():
    y[i] = y.get(i, 0) + 1

for i, j in y.items():
    if x.get(i, 0) < j:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 67412
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	a = int(input())
	al = list(IN())
	
	avg = sum(al) // a
	
	mm= None
	for i in range(3):
		pp=avg + i - 1
		rr = sum([(v-pp)**2 for v in al])
		mm = rr if mm is None or mm > rr else mm
		
	ret=mm
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)
		

Measured memory_bytes: 38384
#include <stdio.h>

int main(void)
{
	int e1,e2,e3,e4;
	scanf(" %d %d %d %d",&e1,&e2,&e3,&e4);
	if(e1==e2 && e3==e4 || e2==e4 && e1==e3 || e1==e4 && e2==e3){
		printf("yes\n");
	}
	else{
		printf("no\n");
	}
	return 0;
}


Measured memory_bytes: 2120
#include<iostream>

using namespace std;

int main(){

  char S[21];
  int idx;
  int flag=0;
  char ans[21];
  int ansidx;

  cin >> S;

  /*
  //debug
  cout << S << endl;
  */

  idx = 0;
  ansidx=0;
  while(S[idx] != '\0'){

    if(flag == 0){
      if(S[idx] == 'A'){
	ans[ansidx]=S[idx];
	ansidx++;
	flag=1;
      }
    }else{
      if(S[idx]=='Z'){
	ans[ansidx]=S[idx];
	ansidx++;
	flag=0;
      }
    }

    idx++;
  }
  ans[ansidx] = '\0';

  /*
  //debug
  cout << ans << endl;
  */

  ansidx--;
  while(ansidx > 0){
    if(ans[ansidx] == 'Z'){
      ans[ansidx+1] = '\0';
      ansidx++;
      break;
    }
    ansidx--;
  }


  if(ansidx < 2){
    cout << -1 << endl;
  }
  else{
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1144
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int a[3];
int main() {
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[0] + a[1] << endl;
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define mp make_pair
#define vvll vector <vll>
#define vsi vector <si>
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define MANX MAXN


const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;
vector <ll> b;
int n;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("a.in","r",stdin);
#endif
    int t;
    cin>>t;
    while (t--)
    {
        cin>>n;
        vector <ll> a(n);
        rep(i,n)
        cin>>a[i];
        b=vector <ll>(62,-1);
        string s;
        cin>>s;
      //  cout<<s<<'\n';
        bool ok=false;
        for (int i=n-1;i>=0;i--)
        {
            if (ok)
                break;
            for (ll j=0;j<62;j++)
            {
                if ((((a[i])>>j)&1ll)==0)
                    continue;
                if (b[j]!=-1)
                    a[i]^=b[j];
                else
                {
                    b[j]=a[i];
                    if (s[i]=='1')
                    {
                        ok=true;
                    }
                    break;
                }
            }
        }
        if (ok)
            cout<<1<<'\n';
        else
            cout<<0<<'\n';
    }



    //n=1 ?
    //recursion - matrix exponential
    //check ios_base, MAXN, mod1 before submit
    //if debug more than 15 minutes - write stress
}

Measured memory_bytes: 3616
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << ((a <= c && c <= b) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
int main(){
  int k,x;
    cin >> k >> x;
    if(k*500>=x){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int64_t> A(n);
    copy_n(istream_iterator<int64_t>(cin), n, A.begin());
    vector<vector<int>> B(n + 1, vector<int>(62)), C(n + 1, vector<int>(62));
    const int64_t p = 1e9 + 7;

    for (int i = 0; i < n; i++){
        for (int j = 0; j <= 61; j++){
            B[i + 1][j] = B[i][j];
            C[i + 1][j] = C[i][j];
            if ((A[i] >> j) & 1)
                B[i + 1][j]++;
            else
                C[i + 1][j]++;
        }
    }

    int64_t ans = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j <= 61; j++){
            ans += (1LL << j) % p * (((A[i] >> j) & 1) ? (C[n][j] - C[i + 1][j]) : (B[n][j] - B[i + 1][j]));
            ans %= p;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 166656
#include<bits/stdc++.h>
using namespace std;
string n;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>n;
	for(int i=0;i<n.size();i++)
	{
		if(i%2==0)
		cout<<n[i];
	}
	return 0;
}


Measured memory_bytes: 512
// Quick_Sort.cs

using System;

class Quick_Sort {

    public struct MarkAndNumber {
        public char mark;
        public int number;
    }

    public static void Main() {

        int n = int.Parse(Console.ReadLine());

        MarkAndNumber[] one = new MarkAndNumber[n];
        MarkAndNumber[] two = new MarkAndNumber[n];

        for(int i = 0; i < n; i++) {
            string[] str = Console.ReadLine().Split(' ');
            one[i].mark = two[i].mark = str[0][0];
            one[i].number = two[i].number = int.Parse(str[1]);
        }

        QuickSort(one, 0, n - 1);
        MergeSort(two, 0, n);

        if(Stable(one, two, n)) Console.WriteLine("Stable");
        else Console.WriteLine("Not stable");

        foreach (MarkAndNumber item in one) {
            Console.WriteLine(item.mark + " " + item.number);
        }
    }

    public static bool Stable(MarkAndNumber[] one, MarkAndNumber[] two, int n) {
        for(int i = 0; i < n; i++) {
            if(one[i].mark != two[i].mark) {
                return false;
            }
        }
        return true;
    }

    public static void MergeSort(MarkAndNumber[] one, int left, int right) {
        if(right > 1 + left) {
            int mid = (right + left) / 2;
            MergeSort(one, left, mid);
            MergeSort(one, mid, right);
            Merge(one, left, mid, right);
        }
    }

    public static void Merge(MarkAndNumber[] one, int left, int mid, int right) {

        int number1 = mid - left;
        int number2 = right - mid;

        MarkAndNumber[] Right = new MarkAndNumber[number2 + 1];
        MarkAndNumber[] Left = new MarkAndNumber[number1 + 1];

        for(int i = 0; i < number1; i++) Left[i] = one[left + i];
        for(int i = 0; i < number2; i++) Right[i] = one[mid + i];
        
        int max = int.MaxValue;
        Left[number1].number = Right[number2].number = max;

        int w = left;
        for(int i = 0, j = 0; w < right; w++) {

            if(Left[i].number <= Right[j].number) {
                one[w] = Left[i];
                i++;
            } else {
                one[w] = Right[j];
                j++;
            }
        }
    }

    public static void QuickSort(MarkAndNumber[] one, int n, int m) {
        if(n < m) {

            int num = Devide(one, n, m);
            QuickSort(one, n, num - 1);
            QuickSort(one, num + 1, m);

        }
    }

    public static int  Devide(MarkAndNumber[] one, int n, int m) {
        int oneNumber = one[m].number, i = n - 1;

        for(int j = n; j < m; j++) {
            if(one[j].number <= oneNumber) Swap(ref one[++i], ref one[j]);
        }

        Swap(ref one[i + 1], ref one[m]);

        return 1 + i;
    }

    public static void Swap<T>(ref T one, ref T two) {
        T tmp = one;
        one = two;
        two = tmp;
    }
}   

Measured memory_bytes: 13032
#include <iostream>
using namespace std;
  
int F[105][105];
int xg,yg;
  
  
void DFS(int Y,int X,int c){
  if(F[Y][X] != c){
    return;
  }
  
  F[Y][X] = -2000;
  DFS(Y-1,X  ,c);
  DFS(Y  ,X+1,c);
  DFS(Y+1,X  ,c);
  DFS(Y  ,X-1,c);
}
  
  
int main(){
  int w,h,xs,ys,n;
  while(1){
    cin >> w >> h;
    if(w == 0 && h == 0)
      break;

      
    cin >> xs >> ys >> xg >> yg >> n;
    int c[n],d[n],x[n],y[n],ca;
    for(int i=0;i<n;i++){
      cin >> c[i] >> d[i] >> x[i] >> y[i];
    }
    for(int i=0;i<n;i++){
      if(c[i] == 0)
        ca = 10;
      else if(i == n-1)
        ca = 0;
    }
    for(int i=0; i<102; i++){
          for(int j=0; j<102; j++){
            F[i][j]=10;
          }
    }
    for(int i=0;i<n;i++){
      if(d[i] == 0){
        for(int j=0;j<4;j++){
          F[x[i]+j][y[i]] = c[i];
          F[x[i]+j][y[i]+1] = c[i];
        }
      } else {
        for(int j=0;j<4;j++){
          F[x[i]][y[i]+j] = c[i];
          F[x[i]+1][y[i]+j] = c[i];
        }
      }
    }
 
  DFS(xs,ys,F[xs][ys]);
  
  if(F[xg][yg] == -2000){
    cout << "OK" << endl;
  } else {
    cout << "NG" <<endl;
  }
  }
}


Measured memory_bytes: 3664
S = input()

if len(S) % 2 == 0:
    num1 = len(S)//2
    num2 = len(S)//2
else:
    num1 = len(S)//2 +1
    num2 = len(S)//2

first = S[:num1]
second = S[num2:]
# print(first, second)

cnt = 0
for i in range(num1):
    # print(first[i], second[-(1 +i)])
    if first[i] != second[-(1+i)]:
        cnt += 1

print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

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

	 double p[n];
	for(ll i=0;i<n;i++)
		cin>>p[i];

	double dp[n+1][n+1],ans=0;

	for(ll i=0;i<=n;i++)
		for(ll j=0;j<=n;j++)
			dp[i][j]=0;
	dp[0][0]=1;

		for(ll i=1;i<=n;i++)
		{
			for(ll j=0;j<=i;j++)
			{
				dp[i][j]=dp[i-1][j]*(1-p[i-1]);
				if(j>0) dp[i][j]+=(dp[i-1][j-1]*p[i-1]);
			}
		}

		for(ll i=n/2+1;i<=n;i++)
			ans+=dp[n][i];

		cout<<fixed<<setprecision(11)<<ans<<endl;
}


Measured memory_bytes: 70656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int num = Integer.parseInt(br.readLine());
		System.out.println(num * 2 * Math.PI);
	}
}


Measured memory_bytes: 33112
#include<iostream>
#include<algorithm>
#include <string>
#include<cstdio>
#include<vector>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define D(n,retu) REP(i,n)(cin>>retu[i])
#define MAX 922337203685477580
using namespace std;
typedef long long ll;

int main() {
	ll n, m,goukei=1; cin >> n >> m;
	if (n > m) { swap(n, m); }
	if (abs(n - m) >= 2) {
		cout << "0" << endl;
	}
	
	else {
		if (abs(n - m) == 1) {
			REP(i, n) {
				goukei *= (i + 1); goukei = goukei % 1000000007;
			}
			REP(i, m) {
				goukei *= (i + 1); goukei = goukei % 1000000007;
			}
		}
		else {
			REP(i, n) {
				goukei *= (i + 1); goukei = goukei % 1000000007;
			}
			REP(i, m) {
				goukei *= (i + 1); goukei = goukei % 1000000007;
			}
			goukei *= 2;
		}	
		cout << goukei%1000000007 << endl;
	}

	return 0;
}

Measured memory_bytes: 256