akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int a[3][3];
int d[3][3];
 
int main() {
  rep(i,3)rep(j,3) cin >> a[i][j];
  int n;
  cin >> n;
  rep(ni,n) {
    int x;
    cin >> x;
    rep(i,3)rep(j,3) if (a[i][j] == x) d[i][j] = 1;
  }
  bool ans = false;
  rep(i,3) {
    int cnt = 0;
    rep(j,3) cnt += d[i][j];
    if (cnt == 3) ans = true;
  }
  rep(i,3) {
    int cnt = 0;
    rep(j,3) cnt += d[j][i];
    if (cnt == 3) ans = true;
  }
  {
    int cnt = 0;
    rep(j,3) cnt += d[j][j];
    if (cnt == 3) ans = true;
  }
  {
    int cnt = 0;
    rep(j,3) cnt += d[j][2-j];
    if (cnt == 3) ans = true;
  }
  puts(ans?"Yes":"No");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

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

	vector<long long> a(n);
	int p = 0;
	rep(i,n){
		cin >> a[i];
		if(abs(a[p]) < abs(a[i])){
			p = i;
		}
	}

	cout << 2 * n - 1 << endl;
	rep(i,n){
		cout << p + 1 << ' ' << i + 1 << endl;
	}
	if(a[p] < 0){
		for(int i = n; i > 1; i--){
			cout << i << ' ' << i - 1 << endl;
		}
	}else{
		range(i,1,n){
			cout << i << ' ' << i + 1 << endl;
		}
	}
}


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

int x, l;
unsigned long long k;  //注意数据规模 
char str1[10000], ch;

int main(){

	scanf("%s", str1);
	scanf("%llu", &k);
	x = 0;
	l = strlen(str1);
	ch = '1';
	while (x < l && x < k){
		if (str1[x] != '1'){
			ch = str1[x];
			break;
		}
		x++;
	}
	printf("%c", ch);
	
	return 0;
} 

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, K;
    cin >> N >> K;
    deque<int> queue;
    rep(i, N) {
        int v;
        cin >> v;
        queue.push_back(v);
    }
    ll ans = 0;
    rep(i, min(K + 1, N + 1)) {
        rep(j, min(N-i+1, K-i+1)) {
            int remain = K - i - j;
            deque<int> que = queue;
            vector<int> tmp;
            rep(a, i) {
                tmp.push_back(que.front());
                que.pop_front();
            }
            rep(a, j) {
                tmp.push_back(que.back());
                que.pop_back();
            }
            sort(tmp.begin(), tmp.end());
            ll num = 0;
            for (int q : tmp) {
                if (q <= 0 && remain >= 1) {
                    remain --;
                    continue;
                }
                num += q;
            }
            ans = max(ans, num);
            remain += j;
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
int main() {
  string s;
  cin >> s;
  if (s == "AAA" || s == "BBB")
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}
ll tree[Max];

ll query(ll idx)
{
    ll sum=0;

    while(idx>0)
    {
        sum+=tree[idx];

        idx-= idx & (-idx);

    }

    return sum;
}

void update(ll idx,ll x,ll n)
{
    while(idx<=n)
    {
        tree[idx]+=x;

        idx+= idx & (-idx);
    }
}

int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      cin>>n;

      for(i=1; i<=n; i++)
      {
          cin>>a;

          update(a,1,n);

          if(query(n)-query(a-1)==i)ans++;
      }

      cout<<ans<<endl;





}



Measured memory_bytes: 5192
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const long long int inf = 1e18;

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

    long long int ans = inf;
    for(int r=0; r<2; r++){
        long long int sum=0, t=0;
        for(int i=0; i<n; i++){
            sum += a[i];
            if(i%2==r && sum<=0){
                t += -sum+1;
                sum = 1;
            }else if(i%2!=r && sum>=0){
                t += sum+1;
                sum = -1;
            }
        }
        ans = min(ans, t);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
int n;
int x,ans;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        if((i*x)%2!=0)ans++;
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 3720
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
//		System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		int finded = 0;
		int lineSamount = scan.nextInt();
		int[] lineSnum = new int[lineSamount];
		for(int i=0; i<lineSamount; i++){
			lineSnum[i] = scan.nextInt();
		}
		int lineTamount = scan.nextInt();
		int[] lineTnum = new int[lineTamount+1];
		for(int i=0; i<lineTamount; i++){
			lineTnum[i] = scan.nextInt();
		}

		for(int i=0; i<lineTamount; i++){
			int left = 0 ;
			int right = lineSamount;
			int mid = lineSamount / 2 ;
			
			while(left<right){
				int move = 0;
				int plusmove = 0;
				int minusmove = 1;
//				System.out.println(left+" L R "+right);/
				mid = (left+right)/2;
				if(lineTnum[i] == lineSnum[mid]){
//					System.out.println("found!");
					finded++;
					break;
				}
				else if(lineTnum[i] < lineSnum[mid]){
					right = mid;
				}
				else if(lineTnum[i] > lineSnum[mid]){
					left = mid+1;
				}
//				System.out.println("mid = "+mid);
			}
//			System.out.println("ende");
		}
		System.out.println(finded);
	}
}

Measured memory_bytes: 78060
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

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

	sort(a, a + n);
	int ans = 1;
	for(int i = 1;i < n;i++){
		if(a[i-1] < a[i]) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import sys

W = input()

T = sys.stdin.read()
#T = input()
#f = open("C:\\users\\inago\\desktop\\test.txt", mode="r")
#T = f.read()

T_word = T.split()
#print(T_word)

count = 0
for s in T_word:
    if s == "END_OF_TEXT":
        break
    
    target = s.lower()

    #print("count:%d,  target, W: %s, %s" % (count, target, W))
    if target == W:
        count += 1

print(count)

        



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  
  int ans = a * x + b * y;
  ans = min( ans, c * 2 * max(x, y) );

  if (x < y)
  {
    ans = min( ans, x * 2 * c + (y - x) * b );
  }
  else
  {
    ans = min( ans, y * 2 * c + (x - y) * a );
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	Int N, A, B;
	cin >> N >> A >> B;
	vector<Int> h(N);
	for (int i = 0; i < N; ++i) { cin >> h[i]; }

	auto check = [&](Int mid) -> bool {
		Int S = 0;
		for (int i = 0; i < N; ++i) {
			if (h[i] < B*mid) { continue; }
			S += (h[i] - B*mid + (A - B) - 1) / (A - B);
		}
		return S <= mid;
	};

	Int low = 0, high = 1e9;
	while (high - low > 1) {
		Int mid = (low + high) / 2;
		(check(mid) ? high : low) = mid;
	}
	cout << high << "\n";

	return 0;
}


Measured memory_bytes: 3988
#include"bits/stdc++.h"
#define endl '\n'

using namespace std;

int main(){
    ios::sync_with_stdio(0), cin.tie(0);
    vector<unsigned long long> v;
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        unsigned long long tmp;
        cin >> tmp;
        v.push_back(tmp);
        if(tmp == 0){
            cout << 0;
            return 0;
        }
    }
    unsigned long long rvalue = 1;
    for(int i = 0; i< N; i++){
        if((log10(rvalue) + log10(v[i])) > 19){
            cout << -1;
            return 0;
        }
        rvalue *= v[i];
        if(rvalue > 1000000000000000000){
            cout << -1;
            return 0;
        }
    }
    cout << rvalue;
    return 0;
}

Measured memory_bytes: 4208
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long N = scanner.nextLong();
        long M = scanner.nextLong();

        if (M > N*2) {
            long surplus = M - N*2;
            System.out.println(N+surplus/4);
        } else {
            System.out.println(M/2);
        }
    }
}

Measured memory_bytes: 21844
from itertools import combinations
from sys import stdin


ns = lambda: stdin.readline()
ni = lambda: int(stdin.readline())
na = lambda: list(map(int, stdin.readline().split()))

N = ni()

target = 'MARCH'
first = [0 for _ in range(5)]
for _ in range(N):
    s = ns()
    if s[0] in target:
        first[target.find(s[0])] += 1

res = 0
for c in combinations(first, 3):
    res += c[0]*c[1]*c[2]
    
print(res)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int n;
int c[505],s[505],f[505];
void solve(int now,int m){
	if(now==n){
		cout<<m<<endl;
		re;
	}
	if(m==1){
		solve(now+1,m+s[now]+c[now]);
	}
	else{
		if(m<=s[now]){
			solve(now+1,s[now]+c[now]);
		}
		else{
			for(;;m++){
				if(!((m-s[now])%f[now])){
					solve(now+1,m+c[now]);
					break;
				}
			}
		}
	}
	re;
}
int main(){
	cin>>n;
	forn(i,n-1){
		cin>>c[i]>>s[i]>>f[i];
	}
	forn(i,n){
		solve(i,0);
	}
	re 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N;
int a[100];

void solve(){
	sort(a, a + N, greater<int>());
	int ans = 0;
	rep(i, N){
		ans = ans + a[i] * (i % 2 ? -1 : 1);
	}
	cout << ans << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	rep(i, N) {
		cin >> a[i];
	}
		solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{

    int W, H, x, y, r;
    std::cin >> W >> H >> x >> y >> r;


    
    if (x > 0 && y > 0){
        if ( W >= (x + r) && H >= (y + r)){
            std::cout << "Yes\n";
        }else{
            std::cout << "No\n";
        }
    }else{
std::cout << "No\n";
}
    return 0;
}



Measured memory_bytes: 3104
#include <stdio.h>
int x,y,z;
int main(void){
  scanf("%d\n",&x);
  scanf("%d\n",&y);
  scanf("%d\n",&z);
  if((x==y&&x!=z)||(x==z&&x!=y)||(y==z&&y!=x)){
    printf("Yes");
  }else printf("No");
  return 0;
}

Measured memory_bytes: 1708
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i=0; i<N; i++) {
            A[i] = sc.nextInt();
        }

        System.out.println(solve(N, A));
    }

    /**
     * https://drken1215.hatenablog.com/entry/2018/06/26/125054
     * @param N
     * @param A
     * @return
     */
    private static long solve(int N, int[] A) {
        long ans = 0;
        int sum = 0;
        int right = 0;

        for (int left=0; left<N; left++) {
            while (right < N && (sum ^ A[right]) == (sum + A[right])) {
                sum += A[right++];
            }

            ans += right - left;
            if (left == right) {
                right++;
            } else {
                sum -= A[left];
            }
        }


        return ans;
    }
}

Measured memory_bytes: 81684
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

constexpr ll mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

class combination{
private:
    vector<mint> fact,inv,finv;
public:
    combination(int N){
        fact = inv = finv = vector<mint>(N+1);
        fact[0] = fact[1] = 1;
        inv[0] = inv[1] = 1;
        finv[0] = finv[1] = 1;
        for(ll i=2;i<=N;i++){
            fact[i] = fact[i-1]*i;
            inv[i] = (mint) mod - inv[mod%i]*(mod/i);
            finv[i] = finv[i-1]*inv[i];
        }
    }
    mint f(int i){
        return fact[i];
    }
    mint comb(int n,int k){
        if(n<k) return 0;
        if(n<0 || k<0) return 0;
        return fact[n]*finv[k]*finv[n-k];
    }
    mint hcomb(int n,int k){
        if(n==0 && k==0) return 1;
        return comb(n+k-1,k);
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<ll> X(N);
    combination C(N);
    for(int i=0;i<N;i++) cin >> X[i];
    mint ans = 0;
    vec<mint> S(N+1,0);
    for(int i=1;i<N;i++){
        mint a = i;
        S[i] = S[i-1]+a.inv();
        ans += S[i]*(X[i]-X[i-1]);
    }
    ans *= C.f(N-1);
    cout << ans.x << endl;
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;


int main() {

	int ans=0,L,R,d,cnt=0;
	cin>>L>>R>>d;
	for (int i = L; i <=R; ++i)
	{
		cnt=0;
		if(i%d==0){
			cnt++;

		}
		ans+=cnt;
	}

cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 3568
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF 1000000000000000007

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


int n;
int a[101];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	int cnt = 0;
	for(int i = 1; i < n-1; i++){
		if(a[i-1] < a[i] && a[i] < a[i+1]){
			cnt++;
		}
		else if(a[i-1] > a[i] && a[i] > a[i+1]){
			cnt++;
		}
	}
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main{
    public static void main(String[] args){
        Main m = new Main();
        m.input();
    }
 
    public void input(){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int ans = 0;
        for(int i = 1; i <= 32; i++){
            for(int j = 2; j < 10; j++){
                if((int)Math.pow(i,j) <= a &&(int)Math.pow(i, j) > ans){
                    ans = (int)Math.pow(i,j);  
                }
            }
        }
        sc.close();
        System.out.println(ans);
    }
    
    
}

Measured memory_bytes: 22740
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
using namespace std;
int main() {
	for (int i = 0;i < 7;++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		printf("%d\n", (a - b));
	}
}


Measured memory_bytes: 1028
N=int(input())
ans=set()
def saiki(A):
    if len(A)>0:
        B="".join(A)
        count=set(A)
        #print(count)
        if eval(B)<=N:
            if len(count)==3:
                ans.add(B)
        else:
            return
    for i in [3,5,7]:
        A.append(str(i))
        saiki(A)
        A.pop()
saiki([])
print(len(ans))


Measured memory_bytes: 79264
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

const int MXN = 2e5, IINF = 1e9 + 10, INF = 1e18 + IINF + 10, MOD = 1000000007;
const ld PI = 4.0 * atanl(1.0), PREC = .000001;
const char nl = '\n';

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define ins insert

int n, m, t, a[MXN];

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

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

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

int main() {
  fast();
  int k;
  cin >> n >> m >> k;
  for (int i = n; i <= m; ++i) {
    if (i < n + k or i > m - k) cout << i << "\n";
  }
  return 0;
}



Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#define INF 900000000

using namespace std;

int main()
{
	int W,H,x,y,r;
	
	cin>>W>>H>>x>>y>>r;
	
	if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H)cout<<"Yes"<<endl;
	
	else cout<<"No"<<endl; 
    
    return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int N=22;
char s[N][N];
int n, m;
int main(){
	int t, k, m;
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0; i<n; ++i){
		scanf("%s",s[i]);
	}
	int ans=0, cnt;
	for(int i=0; i<(1<<n); ++i){
		for(int j=0; j<(1<<m); ++j){
			cnt=0;
			for(int l=0; l<n; ++l){
				for(int d=0; d<m; ++d){
					if(!((1<<l)&i)&&!((1<<d)&j)){
						if(s[l][d]=='#'){
							++cnt;
						}
					}
				}
			}
			if(cnt==k)++ans;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3764
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    long a = sc.nextLong();
    long b = sc.nextLong();
    long k = sc.nextLong();
    
    long eatA = Math.min(k, a);
    a -= eatA;
    k -= eatA;
    
    long eatB = Math.min(k, b);
    b -= eatB;
    k -= eatB;
    os.println(a + " " + b);
  }
}

Measured memory_bytes: 22228
#include <iostream>
using namespace std;
int main() {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if (x-r>=0 && x+r<=w && y-r>=0 && y+r<=h) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		String S = scanner.next();
		scanner.close();

		String[] sarr = S.split("");
		int x = 0;
		int max = 0;
		for (int i = 0; i < N; i++) {
			if(sarr[i].equals("I")) {
				x++;
			} else {
				x--;
			}
			if(x > max) {
				max = x;
			}
		}

		System.out.println(max);
	}

}


Measured memory_bytes: 35680
n=int(input())
###
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(s[n-1])

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

int main(void){
    int N,K;
    cin >> N >> K;
    int count[N] = {};
    rep(i,K){
        int d;
        cin >> d;
        rep(i,d){
            int a;
            cin >> a;
            count[a-1] = 1;
        }
    }
    int ans = N;
    rep(i,N){
        ans -= count[i];
    }
    cout << ans <<endl;
    return 0;
}

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> H(N);
	for (int i = 0; i < N; i++)
	{
		cin >> H[i];
	}
	
	int answer = 1;
	int baseH = H[0];
	
	for (int i = 1; i < N; i++)
	{
		if (baseH <= H[i])
		{
			baseH = H[i];
			answer++;
		}
	}
	
	cout << answer << endl;
	
	return 0;
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



int main(){
    int n;cin >> n;
    int a[3][n+1];

    for(int i=0;i<3;i++){
        for(int j=0;j<n+1;j++){
            a[i][j]=0;
        }
    }

    for(int i=1;i<3;i++){
        for(int j=1;j<n+1;j++){
            cin >> a[i][j];
        }
    }


    for(int i=1;i<3;i++){
        for(int j=1;j<n+1;j++){
            a[i][j]+=max(a[i-1][j],a[i][j-1]);
        }
    }

    cout << a[2][n] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<set>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int lli;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli n, k, d, dk, i, j, x, z, cnt=0;
    cin >> n >> k;
    lli ara[n+7];
    set<lli> s;
    for(i=1; i<=n; i++) cin >> ara[i];
    while(k--){
        cin >> x >> z;
        if(ara[x]<ara[z]) s.insert(x);
        else if(ara[x]>ara[z]) s.insert(z);
        else{
            s.insert(x);
            s.insert(z);
        }
    }
    cout << n-s.size() << endl;
    return 0;
}


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

int main(){
    while(true){
    string str;
    cin >> str;
    if(str == "-"){
        break;
    }
    int m;
    cin >> m;
    for(int i =0 ; i<m ; i++){
        int h;
        cin >> h;
        string new1 = "";
        for(int j = h; j < str.size();j++){
            char a = str.at(j);
             new1 += a;
        }
        for(int k = 0; k < h; k++){
            char b = str.at(k);
            new1 += b;
        }
        str = new1;
    }
    cout << str << endl;
    }
}


Measured memory_bytes: 3176
import sys
x,y = map(int,input().split())
# x = list(map(int,input().split()))
a = 2*x - y/2
b = y/2 - x
if (a >= 0) & (b >= 0):
    if (a.is_integer()) & (b.is_integer()):
        print('Yes')
        sys.exit()
print('No')


Measured memory_bytes: 9172
#include<stdio.h>

int main(){
    
    int l,m,n;
    int a[101][101]={};
    int b[101][101]={};
    long long c[101][101]={};
    
    
    scanf("%d%d%d",&n,&m,&l);
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            scanf("%d",&b[i][j]);
        }
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            c[i][j]+=0;
            for(int k=0;k<m;k++){
                c[i][j]+=a[i][k]*b[k][j];
            }
        }
    }
    
    for(int i=0; i<n; i++) {
        for(int j=0; j<l; j++) {
            printf("%lld",c[i][j]);
            if(j !=l-1) {
                printf(" ");
            }
        }
        printf("\n");
    }
    
    return 0;
}



Measured memory_bytes: 2088
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n = ni()
    a = na()

    result = {1: 0, 2: 0, 4: 0}

    for ai in a:
        if ai % 4 == 0:
            result[4] += 1
        elif ai % 2 == 0:
            result[2] += 1
        else:
            result[1] += 1

    flg = False
    if result[2] == 0:
        if result[4] >= result[1] - 1:
            flg = True
    else:
        if result[4] >= result[1]:
            flg = True

    print("Yes" if flg else "No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 16268
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int dp[3010][6010];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    memset(dp, -INF, sizeof(dp));
    int n, t;
    cin >> n >> t;
    vector<pair<int, int>> ab(n);
    for (int i = 0; i < n; i++)
    {
        cin >> ab[i].first >> ab[i].second;
    }
    sort(ALL(ab));
    dp[0][t - 1] = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 6010; j++)
        {
            chmax(dp[i + 1][j], dp[i][j]);
            if (j < t)
            {
                chmax(dp[i + 1][j + ab[i].first], dp[i][j] + ab[i].second);
            }
        }
    }
    int ans=-INF;
    for(int i=0;i<6010;i++){
        chmax(ans,dp[n][i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;

int main()
{
  int n, T;
  cin >> n >> T;
  vector<int> t(n);
  for (auto &e : t)
    cin >> e;
  ll x = 0;
  for (int i = 0; i < n - 1; ++i)
  {
    if (t[i + 1] - t[i] < T)
      x += (t[i + 1] - t[i]);
    else
      x += T;
  }
  x += T;
  cout << x << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int n,a[100005];
int main()
{
	cin>>n;
	int x;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		a[x]=i;
	}
	for(int i=1;i<=n;i++)
	cout<<a[i]<<" ";
	return 0; 
}

Measured memory_bytes: 1152
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

template<typename T> using maximum_heap = std::priority_queue<T, std::vector<T>, std::less<T>>;
template<typename T> using minimum_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
std::istream& operator>>(std::istream &is, std::vector<T> &v)
{
  for (typename std::vector<T>::size_type i = 0; i < v.size(); ++i) {
    is >> v[i];
  }
  return is;
}

using namespace std;

int64_t diff_abs(int64_t a, int64_t b)
{
  return abs(a - b);
}

int main()
{
  uint64_t X, N;
  cin >> X >> N;

  set<int64_t> p;
  N_TIMES(n, N) {
    int64_t v;
    cin >> v;

    p.insert(v);
  }

  int64_t min_diff_abs = 1e+8, min_val = X;
  for (int64_t x = -100; x <= 200; ++x) {
    if (p.find(x) != p.end()) { continue; }

    if (diff_abs(X, x) < min_diff_abs) {
      min_diff_abs = diff_abs(X, x);
      min_val = x;
    }
  }
  cout << min_val << endl;

  return 0;
}

Measured memory_bytes: 3628
while line = gets.chomp do
  exit if line == "0 0"
  n, x = line.split(" ").map(&:to_i)
  count = 0
  for i in 1..n do
    for j in i+1..n do
      for k in j+1..n do
        if i+j+k == x then
          count += 1
        end
      end
    end
  end
  printf "%d\n", count
end

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

int main() {
  string s;
  int Q;
  cin >> s >> Q;
  deque<char> d;
  for (char e : s) d.push_back(e);
  bool b = false;
  for (int i = 0; i < Q; i++) {
    int q;
    cin >> q;
    if (q == 1) b = !b;
    else {
      int a;
      char r;
      cin >> a >> r;
      if (a == 1 ^ b) d.push_front(r);
      else d.push_back(r);
    }
  }
  
  if (b) {
    while(!d.empty()) {
      cout << d.back();
      d.pop_back();
    }
  }
  else {
    while(!d.empty()) {
      cout << d.front();
      d.pop_front();
    }
  }
  cout << endl;
}

Measured memory_bytes: 896
import math
A, B ,H, M=map(int,input().split())
shita = (60*H+M)/2
phi = 6*M
C2 =A**2 + B**2 - 2 * A * B *math.cos(math.radians(shita-phi))
ans=math.sqrt(abs(C2))
print(ans)


Measured memory_bytes: 9500
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int N = in.nextInt();
            int M = in.nextInt();
            int R = in.nextInt();

            int[] r = new int[R];
            for (int i = 0; i < R; i++) {
                r[i] = in.nextInt() - 1;
            }

            int[][] distances = new int[N][N];
            for (int i = 0; i < distances.length; i++) {
                Arrays.fill(distances[i], (int) 1e9);
            }

            for (int i = 0; i < M; i++) {
                // minus 1 so we use the correct array index
                int A = in.nextInt() - 1;
                int B = in.nextInt() - 1;
                int C = in.nextInt();
                distances[A][B] = C;
                distances[B][A] = C;
            }

            floyd(N, distances);

            int min = dfs(0, new boolean[R], r, distances, -1);

            out.println(min);
        }

        private static int dfs(int index, boolean[] used, int[] r, int[][] distances, int from) {
            if (index >= r.length) {
                return 0;
            }

            int min = (int) 1e9;

            for (int i = 0; i < r.length; i++) {
                if (used[i]) {
                    continue;
                }

                used[i] = true;

                int to = r[i];
                int distance = (from == -1 ? 0 : distances[from][to]) + dfs(index + 1, used, r, distances, to);
                if (distance < min) {
                    min = distance;
                }

                used[i] = false;

            }

            return min;
        }

        private static void floyd(int n, int[][] l) {
            for (int b = 0; b < n; b++) {
                for (int a = 0; a < n; a++) {
                    for (int c = 0; c < n; c++) {
                        l[a][c] = Math.min(l[a][c], l[a][b] + l[b][c]);
                    }
                }
            }
        }

    }
}



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

int main (){
	int a, b, count = 0;
	scanf("%d %d", &a, &b);
	char s[a + b + 1];
	scanf("%s", &s);
	int len = strlen(s);
	
	if (s[a] != '-'){
		printf("No");
		return 0;
	}
	
	for(int i = 0; i < len; i++){
		if (s[i] == '-'){
			count++;
		}
	}
	if (count > 1) {
		printf("No");
		return 0;
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;
int main(void){
    string s[51];
    string cmp[51];
    int n,m,reg=0;
    cin >> n >> m;
    for(int i=0;i<n;i++){
            cin >> s[i];
    }
    for(int i=0;i<m;i++){
            cin >> cmp[i];
    }
    for(int i=0;i<=n-m;i++){
        for(int j=0;j<=n-m;j++){
            reg=0;
    rep(k, 0, m) rep(l, 0, m)if (s[i + k][j + l] == cmp[k][l]) reg++;
    if(reg==m*m){
       cout << "Yes" << endl;
       return 0;
   }
       
        }
    }
    
   
   
       cout << "No" << endl;
   return 0;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<typeinfo>
#include<cassert>
#include<functional>
#include<algorithm>
#include<climits>
#include<map>

using namespace std;



int main(){


	int A,B;

	string S;

	cin >> A >> B;

	cin >> S;

	int count = 0;

	for(int i = 0;i < A + B + 1;i++){
		if(i < A && S[i] >= '0' && S[i] <= '9'){
			count++;
		}
		if(i == A && S[i] =='-'){
			count++;
		}
		if(i > A && S[i] >= '0' && S[i] <= '9'){
			count++;
		}
	}

	if(count == A + B + 1){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

   return 0;

}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

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

  ll N,K;
  cin>>N>>K;
  vector<ll> A(N);
  rep(i,N)cin>>A[i];

  rep(i,K){
    bool check=true;
    rep(j,N){
      if(A[j]!=N)check=false;
    }
    if(check)break;

    vector<ll> imos(N+1,0);
    rep(j,N){
      ll l=max(0LL,j-A[j]);
      ll r=min(N,j+A[j]+1);
      imos[l]++; imos[r]--;
    }
    rep(j,N)imos[j+1]+=imos[j];
    rep(j,N)A[j]=imos[j];
  }

  rep(i,N)cout<<A[i]<<" ";
  cout<<endl;

  return 0;
}


Measured memory_bytes: 6368
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }


    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int x = cin.nextInt();
        int[] cost = new int[N];
        for (int i = 0; i < N; i++)
        {
            cost[i] = cin.nextInt();
        }
        long ans = 0;
        for (int i = 0; i < N; i++)
        {
            ans += cost[i];
        }

        long add = 0;
        for (int i = 0; i < N; i++)
        {
            add += x;
            long tmp = 0;
            int[] newcost = new int[N];
            for (int j = 0; j < N; j++)
            {
                newcost[j] = Math.Min(cost[j], cost[(j + N - 1) % N]);
                tmp += newcost[j];
            }
            cost = newcost;
            ans = Math.Min(ans, tmp + add);
        }
        Console.WriteLine(ans);
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 29280
let () =
  Scanf.scanf "%d\n" @@ fun n ->
  let arr = Array.make n 0 in
  let m = int_of_float (sqrt (float_of_int n)) in
  for x = 1 to m do
    for y = 1 to m do
      for z = 1 to m do
        let i = x * x + y * y + z * z + x * y + y * z + z * x in
        if i <= n then arr.(i-1) <- arr.(i-1) + 1
      done;
    done;
  done;
  Array.iter (fun x -> Printf.printf "%d\n" x) arr

Measured memory_bytes: 5624
use std::process;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: u64, 
        a: [u64; n],
    }   

    let mut ans = 0;
    let mut a = a;
    let mut c = 0;

    loop {
        c = 1;
        for i in &mut a {
            if *i%2 == 0 {
                *i = *i/2;
                ans += 1;
                c =0;
            }

        }
        if c==1 {
            break;
        }
    }
            println!("{}",ans);
}



Measured memory_bytes: 4352
<?php

fscanf(STDIN, "%d", $a);
fscanf(STDIN, "%d", $b);
fscanf(STDIN, "%d", $c);
fscanf(STDIN, "%d", $x);

$cnt = 0;
for ($cntA = 0; $cntA <= $a; $cntA++) {
	$sumA = $cntA * 500;
	for ($cntB = 0; $cntB <= $b; $cntB++) {
		$sumB = $cntB * 100;
		for ($cntC = 0; $cntC <= $c; $cntC++) {
			$sumC = $cntC * 50;
			$sum = $sumA + $sumB + $sumC;
			if ($sum === $x) {
				$cnt++;
			}
		}
	}
}

printf("%d\n", $cnt);

Measured memory_bytes: 4604
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());

using ll = long long int;
const ll MOD = 1000000007;

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

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

ll mod_add(ll a, ll b) {
    return (a + b) % MOD;
}

ll mod_sub(ll a, ll b) {
    return (a + MOD - b) % MOD;
}

ll mod_mul(ll a, ll b){
    return (a * b) % MOD;
}

ll mod_pow(ll base, ll po) {
    if(po == 0)
        return 1;
    else if(po == 1)
        return base;
    ll new_base = mod_pow(base, po / 2);
    return mod_mul(mod_mul(new_base, new_base), po % 2 == 0 ? 1 : base);
}

ll mod_div(ll a, ll b){
    return mod_mul(a, mod_pow(b, MOD - 2));
}

int main(){
    int a;
    cin >> a;
    if(a < 3200) {
        cout << "red" << endl;
        return 0;
    }
    string s;
    cin >> s;
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
  x,y=map(int,input().split())
  a.append((x,y))
s = 0
import itertools
import math
import fractions
for l in itertools.permutations(range(n)):

  for i in range(n-1):
    s += math.sqrt((a[l[i]][0]-a[l[i+1]][0])**2 + (a[l[i]][1]-a[l[i+1]][1])**2)
print(s/math.factorial(n))

Measured memory_bytes: 5048
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    string s,t;
    cin>>s>>t;
    int c=0;
    if (s[0]==t[0])
        c++;
    if (s[1]==t[1])
        c++;
    if (s[2]==t[2])
        c++;
    cout<<c;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int M = sc.nextInt();
    int a[] = new int[A];
    int b[] = new int[B];
    int x[] = new int[M];
    int y[] = new int[M];
    int c[] = new int[M];
    for(int i=0;i<A;i++){
      a[i]=sc.nextInt();
    }
    for(int i=0;i<B;i++){
      b[i]=sc.nextInt();
    }
    int ans=1000000;
    for(int i=0;i<M;i++){
      x[i]=sc.nextInt();
      y[i]=sc.nextInt();
      c[i]=sc.nextInt();
    }
    for(int i=0;i<M;i++){
      if(ans>a[x[i]-1]+b[y[i]-1]-c[i]){
        ans=a[x[i]-1]+b[y[i]-1]-c[i];
      }
    }
    Arrays.sort(a);
    Arrays.sort(b);
    if(ans>a[0]+b[0]){
      ans=a[0]+b[0];
    }
    System.out.println(ans);

  }
  

  
}


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

int n;
vector<int> h(100000);
vector<int> cost(100000);

int ans(int n)
{
    if (cost.at(n) != -1)
        return cost.at(n);
    cost.at(n) = min(ans(n - 1) + abs(h.at(n) - h.at(n - 1)),
                     ans(n - 2) + abs(h.at(n) - h.at(n - 2)));
    return cost.at(n);
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> h.at(i);
        cost.at(i) = -1;
    }
    cost.at(0) = 0;
    cost.at(1) = abs(h.at(1) - h.at(0));
    cout << ans(n - 1) << endl;

    return 0;
}

Measured memory_bytes: 4096