akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
int n,ans,a[200005],b[200005],x[200005],y[200005];
int can(int x,int y)
{
	return x&(1<<y);
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++) scanf("%d",&b[i]);
	for (int i=0;i<=28;i++)
	{
		for (int j=1;j<=n;j++) x[j]=a[j]%(1<<(i+1));
		for (int j=1;j<=n;j++) y[j]=b[j]%(1<<(i+1));
		std::sort(x+1,x+n+1);for (int j=1;j<=n/2;j++) std::swap(x[j],x[n-j+1]);
		std::sort(y+1,y+n+1);
		int l=1,r=0,cnt=0;
		while (l<=n&&!can(y[l]+x[1],i)&&(y[l]+x[1]<(1<<(i+1)))) ++l;
		while (r+1<=n&&!can(y[r+1]+x[1],i)&&(y[r+1]+x[1]<(1<<(i+1)))) ++r;
		for (int j=1;j<=n;j++)
		{
			while (l<=n&&!((y[l]+x[j])&(1<<i))&&(y[l]+x[j]<(1<<(i+1)))) ++l;
			while (r+1<=n&&((y[r+1]+x[j])&(1<<i))&&(y[r+1]+x[j]<(1<<(i+1)))) ++r;
//			printf("%d %d %d %d\n",i,j,l,r);
			if ((r-l+1)<0) continue;
			cnt=(cnt+(r-l+1))&1;
		}
		l=1,r=0;
		while (l<=n&&(y[l]+x[1]<(1<<(i+1)))) ++l;
		while (r+1<=n&&(y[r]+x[1]<(1<<(i+1)))) ++r;
		while (l<=n&&!can(y[l]+x[1],i)) ++l;
		while (r+1<=n&&!can(y[r+1]+x[1],i)) ++r;
		for (int j=1;j<=n;j++)
		{
			while (l<=n&&!((y[l]+x[j])&(1<<i))) ++l;
			while (r+1<=n&&((y[r+1]+x[j])&(1<<i))) ++r;
//			printf("%d %d %d %d\n",i,j,l,r);
			if ((r-l+1)<0) continue;
			cnt=(cnt+(r-l+1))&1;
		}
//		printf("%d\n",cnt);
		if (cnt) ans=ans+(1<<i);
	}
	printf("%d\n",ans);
}

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

int main()
{
    int k,x; cin>>k>>x;
    vector<int> v;

    for(int i=1;i<k;i++)
    {
        v.push_back(x+i);
        v.push_back(x-i);
    }
    v.push_back(x);
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++) cout<<v[i]<<' ';
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,p,x,y;
    cin>>a>>b>>c>>d>>p;
    x=a*p;
    y=b;

    if(p>c){
       y+=(p-c)*d;
    }
    
    if(x<y) cout<<x<<endl;
    else cout<<y<<endl;
}



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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

ll g(ll x){
	ll ki = 2;
	ll res = 0;
	REP(i, 46){
		ll kosu = 0;
		kosu += (x/ki)*(ki/2);
		kosu %= 2;
		if(x - (x/ki)*ki + 1 > ki/2){
			kosu += (x - (x/ki)*ki + 1 - ki/2);
			kosu %= 2;
		}
		if(kosu%2==1){
			res += (1ll<<i);
		}
		ki *= 2;
	}
	return res;
}

int main(){
	ll A, B;
	cin >> A >> B;
	ll r = g(B);
	cout << (g(B)^g(A-1)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    string s; cin >> s;
    string fst = s.substr(0,2);
    string snd = s.substr(2,2);
    
    bool ok1 = false;
    bool ok2 = false;
    if (1<=stoi(fst)&&stoi(fst)<=12) ok1 =true;
    if (1<=stoi(snd)&&stoi(snd)<=12) ok2 = true;

    if (ok1&&ok2) cout << "AMBIGUOUS" << endl;
    else if (ok1) cout << "MMYY" << endl;
    else if (ok2) cout << "YYMM" << endl;
    else cout << "NA" << endl;
    return 0;
}
































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

int A, B, C, X, Y;

int main()
{
  scanf( "%d%d%d%d%d", &A, &B, &C, &X, &Y );

  printf( "%d\n", A+B>2*C ? std::min( Y*2*C+std::max(0, (X-Y)*A ), X*2*C+std::max( 0, (Y-X)*B ) ) : X*A+Y*B );

  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX(x, y) (((x) > (y)) ? (x) : (y))

int main() {

	int n, i, max;
	scanf("%d", &n);

	unsigned short A[n+1];
	unsigned short B[n+1];

	max = (1<<30)*-1;
	for (i = 0; i < n; i++) {
		scanf("%hu", &A[i+1]);
		max = MAX(max, A[i+1]);
	}
	int C[max+1];
	memset(C, 0, sizeof(C));

	for (i = 0; i < n; i++) C[A[i+1]]++;
	for (i = 1; i <= max; i++) C[i] += C[i-1];

	for (i = n; i >= 1; i--) {
		B[C[A[i]]] = A[i];
		C[A[i]]--;
	}

	printf("%d", B[1]);
	for (i = 2; i <= n; i++) {
		printf(" %d", B[i]);
	}
	printf("\n");

	return 0;
}



Measured memory_bytes: 10512
#include<stdio.h>

int main(void){
    int x,y,t,i=1;
	while(1){
		scanf("%d %d",&x,&y);
		if(x==0 && y==0)break;
		if(x>y){
			t=x;
			x=y;
			y=t;
			printf("%d %d\n",x,y);
		}
		else{
			printf("%d %d\n",x,y);
	}
	}
	return 0;
}

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

public class Main {

	static int tmpa[];

	public static int solve() {
		int n = tmpa.length;
		int min = tmpa[0];
		if(min == 1)return 1;
		if(min == tmpa[n - 1])return min;
		for (int i = 1; i < n; ++i) {
			int tmp = tmpa[i] / min;
			int r = tmpa[i] % min;
			if(r == 0)r = 1;
			else r = 0;
			tmpa[i] -= min * (tmp - r);
		}
		Arrays.sort(tmpa);
		return solve();
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		tmpa = new int[n];
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextInt();
			tmpa[i] = a[i];
		}
		sc.close();
		Arrays.sort(tmpa);
		int ans = solve();
		System.out.println(ans);
	}

}


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

#define ll long long

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

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

const ll INF = 1LL << 60;
const ll MAX = 100005;
const ll MAX_N = 110;
const ll MAX_V = 100100;

ll N, W;
ll w[MAX_N], v[MAX_N];
ll dp[MAX_N][MAX_V];

int main() {
    cin >> N >> W;
    for(int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }

    for(int i = 0; i < MAX_N; i++) {
        for(int j = 0; j < MAX_V; j++) {
            dp[i][j] = INF;
        }
    }

    dp[0][0] = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < MAX_V; j++) {
            if(j >= v[i]) {
                chmin(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
            }
            chmin(dp[i + 1][j], dp[i][j]);
        }
    }

    ll res = 0;
    for(int i = 0; i < MAX_V; i++) {
        if(dp[N][i] <= W) {
            res = i;
        }
    }
    printf("%lld\n", res);
}


Measured memory_bytes: 86272
#include<stdio.h>

int main(){
  int amount;
  int ren1[3][10] = {{}};
  int ren2[3][10] = {{}};
  int ren3[3][10] = {{}};
  int ren4[3][10] = {{}};
  int ren,flat,room,value;
  
  scanf("%d", &amount);

  for(int i=0; i < amount; i++){
    scanf("%d %d %d %d",&ren,&flat,&room,&value);
    switch(ren){
    case 1:
      ren1[flat-1][room-1] += value;
      break;
    case 2:
      ren2[flat-1][room-1] += value;
      break;
    case 3:
      ren3[flat-1][room-1] += value;
      break;
    case 4:
      ren4[flat-1][room-1] += value;
      break;

    }
    
  }

  for(int i=0; i<3; i++){
    for(int j=0; j<10; j++){
      printf(" %d", ren1[i][j]);
    }
    printf("\n");
  }
  printf("####################\n");
  for(int i=0; i<3; i++){
    for(int j=0; j<10; j++){
      printf(" %d", ren2[i][j]);
    }
    printf("\n");
  }
  printf("####################\n");
  for(int i=0; i<3; i++){
    for(int j=0; j<10; j++){
      printf(" %d", ren3[i][j]);
    }
    printf("\n");
  }
  printf("####################\n");
  for(int i=0; i<3; i++){
    for(int j=0; j<10; j++){
      printf(" %d", ren4[i][j]);
    }
    printf("\n");
  }
  return 0;
}



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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll k, t;
  cin >> k >> t;

  vector<ll> a(t);
  for (ll i = 0; i < t; ++i) {
    cin >> a[i];
  }

  if (t == 1) {
    cout << a[0]-1 << endl;
    return 0;
  }

  while (true) {
    sort(a.begin(), a.end(), greater<ll>());
    if (a[0] == 0 || a[1] == 0) break;
    
    a[0] -= a[1];
    a[1] = 0;
  }

  cout << max(a[0]-1, 0LL) << endl;

  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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

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

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

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(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	int n;cin>>n;
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i<n-2;i++){
		if(s.at(i)=='A' && s.at(i+1)=='B' && s.at(i+2)=='C'){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<n;i++)
typedef long long ll;
typedef vector<int> vec;
ll min(ll a,ll b){
  if(a<b)return a;
  return b;
}
int main(){
  int a,b,ans,m;
  cin>>a>>b;
  ans=-1;
  
  rep(i,10000){
   if(floor(i*0.08)==a&&floor(i*0.1)==b){
     ans=i;
     break;
   }
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

int main() {
  //
  int a,b;
  cin>>a>>b;
  int ans = 0;
  int tmp = 1;
  while (tmp < b) {
    tmp += a-1;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 888
// {{{ include and macros
#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(a, b) for(int unsafe_cnt=a; unsafe_cnt < b;unsafe_cnt++)
#include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <set>
using namespace std;
// }}}

// {{{ put
void newline() {cout << endl;}
template <typename T> void display(T input){cout << input;}
template <typename T> void put(T input){display(input); newline();}
// }}}

vector<int> to_top(const vector<int> v
                  ,const int p   // ???????§????
                  ,const int c){
  vector<int> w;
  for(int i=p; i<p+c; i++){
    w.push_back(v[i]);
  }
  for(int i=0; i<v.size(); i++){
    if(!(p<=i && i<p+c)){
      w.push_back(v[i]);
    }
  }
  return w;
}

int main() {
  int n, r;
  while(cin >> n >> r && n){
    vector<int> v;
    for(int i=n; i > 0; i--){v.push_back(i);}
    // for(int i=0;i<v.size();i++){display(v[i]);display(" ");} put("");
    for(int i=0; i < r; i++){
      int p, c;
      cin >> p >> c;
      v = to_top(v, p-1, c);
      // for(int i=0;i<v.size();i++){display(v[i]);display(" ");}put("");
    }
    put(v[0]);
  }
}

Measured memory_bytes: 3104
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef long long ll;

int		compare_string(const void *a, const void *b)
{
	return strcmp(*(const char **)a, *(const char **)b);
}

int main()
{
	int N;
	scanf("%d", &N);
	int p[N];
	char s[N][11];

	char **str;
	str = (char**)malloc(sizeof(char*) * N);
	int i = 0;
	while (i < N)
	{
		str[i] = (char *)malloc(sizeof(char) * 11);
		scanf("%s", s[i]);
		scanf("%d", &p[i]);
		strcpy(str[i], s[i]);
		i++;
	}
	qsort(str, N, sizeof *str, compare_string);
	int rank = 0;
	int j, k;
	int n[N];
	int max = 0;
	i = 0;
	while (i < N)
	{
		j = 0;
		n[i] = 0;
		max = -1;
		while (j < N)
		{
			if (strcmp(str[i], s[j]) == 0)
			{
				if (p[j] > max)
				{
					max = p[j];
					n[i] = j;
				}
			}
			j++;
		}
		p[n[i]] = -1;
		printf("%d\n", n[i] + 1);
		i++;
	}
	return (0);
}


Measured memory_bytes: 128
use std::io;

fn main() {
  let mut s = String::new();

  io::stdin().read_line(&mut s)
    .expect("failed to read line");
  let n: i32 = s.trim().parse().unwrap();
  let h: i32 = n / 3600;
  let m: i32 = n / 60 - h * 60;
  let s: i32 = n - h * 3600 - m * 60;

  println!("{}:{}:{}", h, m, s)
}



Measured memory_bytes: 5036
#17:43
n,m,q = map(int,input().split())
imos = [[0 for _ in range(n+1)] for _ in range(n+1)]
for _ in range(m):
  l,r = map(int,input().split())
  r -= 1
  imos[0][r] += 1
  imos[l][r] -= 1
#print(imos)
for i in range(n):
  for j in range(n):
    imos[i][j+1] += imos[i][j]
for j in range(n):
  for i in range(n):
    imos[i+1][j] += imos[i][j]
#print(imos)
for _ in range(q):
  x,y = map(int,input().split())
  x -= 1
  y -= 1
  print(imos[x][y])

Measured memory_bytes: 9712
# inputList = list(map(int, '''5
# 5 3 2 4 1'''.split()))
# N = inputList.pop(0)


def formatting(nums):
    for i in range(len(nums)):
        if i != len(nums) - 1:
            print(nums[i], end=' ')
        else:
            print(nums[i])


def bubbleSort(A, N):
    count = 0
    flag = 1
    while flag:
        flag = 0

        for j in range(N - 1, 0, -1):
            if A[j] < A[j-1]:
                temp = A[j]
                A[j] = A[j-1]
                A[j-1] = temp
                count += 1
                flag = 1
    formatting(A)
    print(count)




N = int(input())
inputList = list(map(int, input().split()))

bubbleSort(inputList, N)



Measured memory_bytes: 5612
#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

int N, ans = 0;
int A[200000];
bool B[200000] = {false};

int main() {
    scanf("%d", &N);
    REP(i, N) scanf("%d", A+i);
    sort(A, A+N);
    for(int i=N-1; i>=0; i--) {
        int p = 0;
        while(A[i] >= 1<<p) p++; 
        int x = (1<<p) - A[i];
        int j = lower_bound(A, A+N, x) - A;
        if(B[i] || B[j]) continue;
        if(j < i && A[j] == x) {
            B[j] = true;
            A[j]--;
            ans++;
        }
    }
    printf("%d", ans);
	return 0;
}

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

int main() {
    int S;
    cin >> S;
    
    int h, m, s;
    h = S / 3600;
    m = (S - (h * 3600)) / 60;
    s = S - (h * 3600) - (m * 60);
    
    cout << h << ':' << m << ':' << s << endl;
    return 0;
}


Measured memory_bytes: 3104
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
int N;
int main(int argc, char const *argv[])
{
    cin>>N;
    int ans=0;
    for(int i=N;i<=1000;i++){
        if(i%111==0){
            ans=i;
            goto LABEL;
        }
    }
    LABEL:
    cout<<ans<<endl;
    return 0;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int h,w;
    char s[144][144];

    Scd2(h,w);
    Rep(i,h){
        Scs(s[i]);
    }

    Rep(i,h+2){
        printf("#");
        Rep(j,w+1){
            if( j == w || i == 0 || i == h+1 )
                printf ("#");
            else
                printf ("%c", s[i-1][j]);
        }
        printf ("\n");
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define mp            make_pair
#define PI            3.14159265
#define M             1000000007
#define MM            998244353
#define fr            first
#define sc            second
#define all(v)        (v).begin(),(v).end()
#define rall(v)       (v).rbegin(),v.rend()
#define vc            vector
#define vi            vector<int>
#define pii           pair<int,int>
#define psi           pair<string,int>
#define pis           pair<int,string>
#define mii           map<int,int>
#define msi           map<string,int>

int solve() {
    int a; cin>>a;
    string s; cin>>s;
    if(a>=3200) cout<<s;
    else cout<<"red";
}

signed main() {
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

struct edge {
    int t, w;
};

using graph = vector<vector<edge>>;

void solve(int n, const graph& g) {
    vector<ll> d(n, -1);

    queue<int> q;
    q.push(0);
    d[0] = 0;

    while (!q.empty()) {
        int u = q.front(); q.pop();

        for (edge e : g[u]) {
            if (d[e.t] == -1) {
                q.push(e.t);
                d[e.t] = d[u] + e.w;
            }
        }
    }

    REP(i, n) cout << d[i] % 2 << endl;

    return;
}

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

    REP(i, n-1) {
        int u, v, w; cin >> u >> v >> w;
        --u; --v;
        g[u].push_back({v, w});
        g[v].push_back({u, w});
    }

    solve(n, g);

    return 0;
}


Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<pair<ll,ll> , null_type,less<pair<ll,ll> >, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M=1e5+5;
ll a[M],b[M];
ll sm[M],eq[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++)
	{
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	ll l=1,r=n,m,p=-1;
	ll tot=(n*(n+1))/2;
	tot=tot/2+1;
	while(l<r)
	{
		m=(l+r)/2;
		if(m==p)
			m++;
		p=m;
		ll x=b[p];
		for(ll i=1;i<=n;i++)
		{
			sm[i]=sm[i-1];
			if(a[i]<x)
				sm[i]++;
		}
		ordered_set od,ev;
		ll c=0;
		for(ll i=0;i<=n;i++)
		{
			if(i%2==0)
			{
				c+=ev.order_of_key({sm[i]-i/2,-1});
				c+=od.order_of_key({sm[i]-i/2,-1});
				ev.insert({sm[i]-i/2,i});
			}
			else
			{
				c+=ev.order_of_key({sm[i]-i/2,-1});
				c+=od.order_of_key({sm[i]-(i+1)/2,-1});
				od.insert({sm[i]-(i+1)/2,i});
			}
		}
		// cout<<m<<" "<<c<<endl;
		if(c>=tot)
			r=m-1;
		else
			l=m;
	}	
	cout<<b[l]<<"\n";
	return 0;
}

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

using namespace std;

const int maxN = 1e5+10;
int N,ans;
long long A[maxN];

int main()
{
    cin >> N;
    for (int i=0; i < N; i++) cin >> A[i];
    sort(A,A+N);
    long long sum = 0;
    for (int i=0; i < N-1; i++)
    {
        sum += A[i];
        if (sum*2 < A[i+1]) ans = i+1;
    }
    cout << N-ans;
}


Measured memory_bytes: 1024
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val c = sc.next()
    val ans = c match {
      case "a" | "e" | "i" | "o" | "u" => "vowel"
      case _ => "consonant"
    }
    println(ans)
  }
}


Measured memory_bytes: 25672
import Foundation

import Foundation

let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ") //ブランクで区切られている場合

var A = Int(split[0])!
//String -> Intの型変換はnilが返る可能性があるので、ラップされたOptional<Int>型が返るので強制アンラップ
var B = Int(split[1])!

var coin = 0
if (A >= B){
    coin += A
    A -= 1
}else{
    coin += B
    B -= 1
}
if (A >= B){
    coin += A
}else{
    coin += B
}

print(coin)


Measured memory_bytes: 14184
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

/* http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_H&lang=jp
??¨??§???????????¶????????????
????????? vi ????????? wi ??§??????????????? N ??????????????¨???????????? W ??????????????¶?????????????????????????¬?????????¶?????????????????????????????????????????§???????????¶???????????\????????????

???????????????????????????????¨??????§???????????????????????????
???????????????????????????????????? W ????¶?????????????
?????????????¨?????????§???????±??????????????????????

??¶?´?
1 ??? N ??? 40
1 ??? vi ??? 10^15
1 ??? wi ??? 10^15
1 ??? W ??? 10^15

*/

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N, W; cin >> N >> W;
	vector<ll> v(N), w(N);
	for (int i = 0; i < N;i++) cin >> v[i] >> w[i];
	
	/* ????????¨?????? */
	// ??????????????¨??????
	ll n1 = N / 2;
	vector<pll> ps(1 << n1);
	for (int i = 0; i < (1 << n1);i++) {
		ll sum_v = 0, sum_w = 0;
		for (int j = 0; j < n1;j++) {
			if (i >> j & 1) {
				sum_v += v[j];
				sum_w += w[j];
			}
		}
		ps[i] = { sum_w,sum_v };
	}
	// ????§????????´??????????
	sort(ps.begin(), ps.end());
	ll m = 1;
	for (int i = 1; i < (1 << n1);i++) {
		if (ps[m - 1].second < ps[i].second) {
			ps[m++] = ps[i];
		}
	}

	// ?????????????????¨??????
	ll res = 0;
	ll n2 = N - n1;
	for (int i = 0; i < (1 << n2);i++) {
		ll sum_v = 0, sum_w = 0;
		for (int j = 0; j < n2;j++) {
			if (i >> j & 1) {
				sum_v += v[n1 + j];
				sum_w += w[n1 + j];
			}
		}
		if (sum_w <= W) {
			auto idx = lower_bound(ps.begin(), ps.begin() + m, pll(W - sum_w,INF)) - ps.begin();
			ll V = ps[idx - 1].second;
			res = max(res, sum_v + V);
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 19204
# グラフの頂点と辺の数を読み取る
vertex,side = gets.split(" ").map{|v| v.to_i}

# ゴールまで行く方法を数えるカウンタ
$how_to_go_goal_count = 0

# グラフの作成
# グラフの作成時に、全ての辺の値を-1する。
# 最後に+1することを忘れないようにする。
i = 0
map = []
side.times do
    map[i] = gets.split(" ").map{|v| v.to_i - 1}
    map[i+1] = map[i].reverse
    i+=2
end

#p map
# ゴールまでの道順を記録する。
# この配列の一番後ろの数字は、現在の位置を表している。
# 例えば、[0,1,3]なら、0→1→3と移動してきており、現在の位置は3であると表している。
remenber_vertex = [0]

#1つだけ深く移動する。
def adventure(map,vertex,remenber_vertex)
    
    # 最初と最後を決める
    start_vertex = 0

    # 移動できるところを探す。
    (map.length).times do |i|
        #print i," "

        # mapの左側と現在地が同じということは、移動できる場所ということ。
        if map[i][0] == remenber_vertex.slice(-1)

            # もし、過去に行ったことがある場所なら、行かないことにする
            if remenber_vertex.any?{|v| v == map[i][1]}
                #print "残念ながら、",map[i][1],"は過去に行ったことがあります。探索を続けます。\n"
                next
            end

            # 移動してみる
            #puts "移動しました！"
            remenber_vertex.push(map[i][1])
            #p remenber_vertex

            # ゴールについたら、カウントする
            if remenber_vertex.length == vertex
                $how_to_go_goal_count += 1
                #puts "ゴールに到着！これまでの経路は"
                #p remenber_vertex
                #puts "です！"
                # 移動できなければorゴールしたらここに来る
                #puts "ゴールしたので、一番後ろの経路を破壊します"
                remenber_vertex.slice!(-1)
                #p remenber_vertex
            else
                # さらに移動する。
                #puts "さらに移動先を探します"
                adventure(map,vertex,remenber_vertex)
            end

        end

    end
    # 移動できなければここに来る
    #puts "移動できません、一番後ろの経路を破壊します"
    remenber_vertex.slice!(-1)
end

adventure(map,vertex,remenber_vertex)

#print "ゴールへの道順は全部で",$how_to_go_goal_count,"通りあります\n"
p $how_to_go_goal_count



Measured memory_bytes: 1788
import itertools

n = int(input())
a = tuple(map(int,input().split()))
ans = 0
for l in itertools.product([-1,0,1],repeat=n):
  t = 1
  for i in range(n):
    t*=(a[i]+l[i])
  if t%2==0:
    ans+=1
print(ans)

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

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    
    const int dx = tx - sx, dy = ty - sy;
    
    cout << string(dy,'U') << string(dx,'R');
    
    cout << string(dy,'D') << string(dx,'L');
    
    cout << 'L' << string(dy+1,'U') << string(dx+1,'R') << 'D';
    
    cout << 'R' << string(dy+1,'D') << string(dx+1,'L') << 'U';
    
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: i64 = input();
    let m: i64 = input();
    let k: i64 = input();

    let mut xans = 0i64;
    for i in 1..m {
        xans += i * (m - i);
        xans %= MOD;
    }
    xans *= n * n;
    xans %= MOD;

    let mut yans = 0i64;
    for i in 1..n {
        yans += i * (n - i);
        yans %= MOD;
    }
    yans *= m * m;
    yans %= MOD;

    let comb = Combination::new(n * m);
    let mut ans = (xans + yans) % MOD;
    ans *= comb.combination(n * m - 2, k - 2);
    ans %= MOD;
    println!("{}", ans);
}

const MOD: i64 = 1000000007;

struct Combination {
    fact: Vec<i64>,
    ifact: Vec<i64>,
}

impl Combination {
    fn new(n: i64) -> Combination {
        let n = n as usize;
        let mut f = vec![0; n + 1];
        f[0] = 1;
        for i in 1..n + 1 {
            f[i] = f[i - 1] * i as i64 % MOD;
        }
        let mut invf = vec![0; n + 1];
        invf[n] = Combination::inverse(f[n]);
        for i in (1..n + 1).rev() {
            invf[i - 1] = invf[i] * i as i64 % MOD;
        }
        Combination {
            fact: f,
            ifact: invf,
        }
    }

    fn inverse(x: i64) -> i64 {
        Combination::power(x, MOD - 2)
    }

    fn power(x: i64, p: i64) -> i64 {
        if p == 0 {
            1
        } else if p % 2 == 0 {
            let t = Combination::power(x, p / 2);
            t * t % MOD
        } else {
            Combination::power(x, p - 1) * x % MOD
        }
    }

    fn combination(&self, n: i64, k: i64) -> i64 {
        if n < 0 || k < 0 || k > n {
            0
        } else {
            let (n, k) = (n as usize, k as usize);
            self.fact[n] * self.ifact[k] % MOD * self.ifact[n - k] % MOD
        }
    }
}


Measured memory_bytes: 8444
N = int(input())
A = list(map(int, input().split()))

_a = 1
res = 0
for i in range(N):
    res += _a * (A[i] % 2 + 1) * 3 ** (N - i - 1)
    if A[i] % 2 == 0:
        _a *= 2
print(res)


Measured memory_bytes: 9128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,ans=0; cin>>n;
    vector<int> l(n,0);
    rep(i,n) cin>>l[i];
    rep(i,n)rep(j,n)rep(k,n){
        if(i>=j || j>=k) continue;
        if(l[i]==l[j] || l[j]==l[k] || l[k]==l[i]) continue;
        int c=l[i]+l[j]+l[k],d=max(l[i],max(l[j],l[k]));
        c-=d;
        if(c>d){
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
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;}
ll powmod(ll a,ll b,ll MOD){ll ans=1ll;while(b){if(b&1)ans=ans*a%MOD;a=a*a%MOD;b>>=1;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
ll n,m;
char s[maxn];
char t[maxn];
int main()
{
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\in.txt.txt","r",stdin);
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\out.txt.txt","w",stdout);
	// cout<<lcm(15,9)<<endl;
 	cin>>n>>m;
 	cin>>s+1>>t+1;
 	ll z=lcm(n,m);
 	int jie1=z/n;
 	int jie2=z/m;
// 	int re=lcm(jie2,jie1);
 	if(s[1]==t[1])
 	{

 		if(n>=m)
 		{
 			int now=1;
// 			repd(i,2,m)
            for(int i=2;i<=m&&((1+(i-1)*jie2)<=n)&&((1+(i-1)*jie1)<=m);i++)
 			{
 				if(s[1+(i-1)*jie2]!=t[1+(i-1)*jie1])
 				{
 					cout<<-1<<endl;
 					return 0;
 				}
 			}
 			cout<<z<<endl;
 		}else{
 			int now=1;
 			for(int i=2;i<=n&&((1+(i-1)*jie2)<=n)&&((1+(i-1)*jie1)<=m);i++)
 			{
 				if(s[1+(i-1)*jie2]!=t[1+(i-1)*jie1])
 				{
 					cout<<-1<<endl;
 					return 0;
 				}
 			}
 			cout<<z<<endl;
 		}
 	}else
 	{
 		cout<<-1<<endl;
 	}
    return 0;
}

inline void getInt(int* p) {char ch;do {ch = getchar();}
while (ch == ' ' || ch == '\n');if (ch == '-') {*p = -(getchar() - '0');
while ((ch = getchar()) >= '0' && ch <= '9') {*p = *p * 10 - ch + '0';}}
else {*p = ch - '0';while ((ch = getchar()) >= '0' && ch <= '9')
{*p = *p * 10 + ch - '0';}}}


Measured memory_bytes: 384
#include <stdio.h>
#include <malloc.h>
int main()
{
	char p[200] ;
	scanf("%s", p);
	int x = 0;
	//printf("%s      ",p);
	while (p[x] != NULL) 
	{
		x++;
	}
	//printf("%d      ",x);
	int hug = 0;
	for (int y = 0; y<x/2; y++ ) {
		if (p[y] != p[x - y-1]) {
			hug++;
		}
	}
	printf("%d", hug);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

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

    int input;
    int check = 0;

    for (int i = 0; i < N; i++)
    {
        cin >> input;
        if (input != i+1)
        {
            check++;
        }
    }

    if (check <= 2)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int A[20];
int n;

int solve(int p, int t);
int sort(void *a, void *b);

int main(void) {
	int i, q, M;
	
	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		scanf("%d", &A[i]);
	}
	
	qsort(A, n, sizeof(A[0]), sort);
	
	scanf("%d", &q);
	for (i = 0; i < q; ++i) {
		scanf("%d", &M);
		if (solve(-1, M)) {
			printf("yes\n");
		} else {
			printf("no\n");
		}
	}
	
	return 0;
}

int solve(int p, int t) {
	if ((p == n) || (t == 0)) {
		return t == 0;
	}
	if (t >= A[p + 1]) {
		if (solve(p + 1, t - A[p + 1])) {
			return 1;
		}
	}
	return solve(p + 1, t);
}

int sort(void *a, void *b) {
	return *(int*)b - *(int*)a;
}

Measured memory_bytes: 584
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

INF = 10**9
record_A = []
record_B = []

record_A.append((A[0], A[0]))

for i in range(1, N):
    if A[i] == A[i-1]:
        record_A.append((1, record_A[-1][1]))
    else:
        record_A.append((A[i], A[i]))

record_B.append((B[-1], B[-1]))

for i in reversed(range(N-1)):
    if B[i] == B[i+1]:
        record_B.append((1, record_B[-1][1]))
    else:
        record_B.append((B[i], B[i]))

ans = 1
mod = 10**9 + 7
for (lb_a, ub_a), (lb_b, ub_b) in zip(record_A, reversed(record_B)):
    lb, ub = max(lb_a, lb_b), min(ub_a, ub_b)
    if ub - lb < 0:
        print(0)
        break
    ans *= ub - lb + 1
    ans %= mod
else:
    print(ans)


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

#define INF 0x3f3f3f3f
#define int long long
#define pii pair<int, int>

const int N = 3005;

double dp[N][N];
double p[N];
double solve(int x, int k) {        // x coins with k heads
    // cout << x << " " << k << endl;
    if(!x and !k)
        return 1.00;
    if(x < 1 or k < 0)
        return 0.0;
    if(dp[x][k] != -1.0f)
        return dp[x][k];
    dp[x][k] = 0.0;
    dp[x][k] += ((1.0-p[x])*solve(x-1, k));      // using tails
    dp[x][k] += (p[x]*solve(x-1, k-1));         // using heads
    return dp[x][k];
}

int32_t main() {
    int i, j, n;
    double ans;
    scanf("%lld", &n);
    for(i = 1 ; i <= n ; i++) {
        scanf("%lf", &p[i]);
    }
    for(i = 0 ; i <= n ; i++)
        for(j = 0 ; j <= n ; j++)
            dp[i][j] = -1.0f;
    ans = 0.0;
    for(i = (n+1)/2 ; i <= n ; i++)
        ans += solve(n, i);
    printf("%.10lf", ans);
    return 0;
}


Measured memory_bytes: 70912
while true do
  a,b,c = gets.split(" ")
  a = a.to_i
  c = c.to_i
  case b
  when "?"
    break
  when "+"
    printf("%d\n",a+c)
  when "-"
    printf("%d\n",a-c)
  when "*"
    printf("%d\n",a*c)
  when "/"
    printf("%d\n",a/c)
  end
end

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

int main(){
  int N,K;
  cin >> N;
  cin >> K;
  long long int cnt = 0;
  int s;
    for(int b = K + 1;b <= N;b++){
      int l = N / b;
      cnt += l * (b - K);
      if(N - l * b > K - 1){
	cnt += N -l * b - (K - 1);
      }
    }
      if(K == 0)cnt -= N;
  cout << cnt << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

	int K = scan.nextInt();
	int S = scan.nextInt();

	int count = 0;
	for(int i = 0; i <= K; i++){
	    for(int j = 0; j <= K; j++){
		if((S-(i+j) >= 0) && (S-(i+j) <= K)){
		    count++;
		}
	    }
	}

	System.out.println(count);
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fo(p,n) for(int i=p;i<n;i++)
#define FIO ios_base::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);
#define endl "\n"
#define mp make_pair
#define pb push_back
#define M 1000000007
ll mod(ll x){
return ((x%M + M)%M);
}
ll add(ll a,ll b){
return mod(mod(a)+mod(b));
}
ll mul(ll a,ll b){
return mod(mod(a)*mod(b));
}

// ....................................................................................

int main()
{
    FIO
    ll t;
    t=1;
    // cin>>t;
    while(t--)
    {
     int n;
     cin>>n;
     int a[n];
     fo(0,n)
     cin>>a[i];
     int dp[n];
     fo(0,n)
     dp[i]=INT_MAX;
     dp[0]=0;
     for(int i=1;i<n;i++){
         dp[i]=min(dp[i],abs(a[i]-a[i-1])+dp[i-1]);
         if(i-2>=0)
         dp[i]=min(dp[i],abs(a[i]-a[i-2])+dp[i-2]);
     }
     cout<<dp[n-1];
    }
}

Measured memory_bytes: 4436
def Recording():
    n, c = map(int, input().split())
    num = 2*10**5+1 

    # チャンネルごとにimos配列
    imos = [[0]*num for _ in range(c)]
    
    # imos
    for _ in range(n):
        s, t, c0 = map(int, input().split())
        if imos[c0-1][s*2] < 0 and imos[c0-1][t*2-1] > 0:
            imos[c0-1][s*2] = 0
            imos[c0-1][t*2-1] = 0
        elif imos[c0-1][s*2] < 0:            
            imos[c0-1][s*2] = 0
            imos[c0-1][t*2] -= 1
        elif imos[c0-1][t*2-1] > 0:    
            imos[c0-1][s*2-1] += 1
            imos[c0-1][t*2-1] = 0
        else:
            imos[c0-1][s*2-1] += 1
            imos[c0-1][t*2] -= 1
    ans = [0 for _ in range(num)]
    for i in range(c):
        for j in range(1, num):
            imos[i][j] += imos[i][j-1]
            ans[j] += imos[i][j]
    print(max(ans))
    
if __name__ == '__main__':
    Recording()
    


Measured memory_bytes: 129920
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
using ll = long long;
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
int main(){
  ll n,tmp;
  cin >> n;
  ll a[n+1],b[n];
  rep(i,n+1){
    cin >> a[i];
  }
  rep(i,n){
    cin >> b[i];
  }
  ll sum = 0;
  rep(i,n){
    if(a[i] < b[i]){
      if(a[i+1] + a[i] <= b[i]){
        sum += a[i] + a[i+1];
        a[i] = 0;
        a[i+1] = 0;
      }else{
        sum += b[i];
        tmp = b[i]-a[i];
        a[i] = 0;
        a[i+1] = a[i+1] - tmp;
      }
    }else{
      sum += b[i];
    }
    rep(i,n){
      //cout << a[i] << " ";
    };
    //cout << endl;
  }
  cout << sum;
}


Measured memory_bytes: 1792
s = input()

if s[0] == "R" and s[1] == "R" and s[2] == "R":
  print(3)
elif s[0] == "R" and s[1] == "R":
  print(2)
elif s[2] == "R" and s[1] == "R":
  print(2)
elif s.count("R") >= 1:
  print(1)
else:
  print(0)

Measured memory_bytes: 9064
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 1000000

int main(){

    ll n,m;
    cin >> n;
    vector<ll> t(MAX_A);
    vector<ll> sum(MAX_A,0);
    REP(n){
        cin >> t[i];
        sum[i] = t[i];
    }

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


    /*REP(n){
        cout << sum[i] << endl;
    }*/

    //cout << endl;
    cin >> m;
    ll ans = 0;
    ll p,x;
    REP(m){
        cin >> p >> x;
        if(t[p-1] > x){
            ans = sum[n]-(t[p-1]-x);
            cout << ans << endl;
        }else if(t[p-1] < x){
            ans = sum[n]+(x-t[p-1]);
            cout << ans << endl;
        }else{
            cout << sum[n] << endl;
        }
    }






    return 0;
}

Measured memory_bytes: 15872
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Sat Jun 16 23:14:44 2018
//
package main

import "fmt"

var A, B int

func main() {
	fmt.Scan(&A, &B)

	if A <= 8 && B <= 8 {
		fmt.Println("Yay!")
		return
	}
	fmt.Println(":(")
}


Measured memory_bytes: 512
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)
    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]

uf = UnionFind(N)
pre = N*(N-1)//2
ans = [pre]
for i in range(M):
  a,b = AB[M-1-i]
  a -= 1
  b -= 1
  if not uf.isSameGroup(a,b):
    pre -= uf.Count(a)*uf.Count(b)
  ans.append(pre)
  uf.Unite(a,b)
for i in range(len(ans)-2,-1,-1):
  print(max(ans[i],0))


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

int main(){
    int N,M;
    cin >> N >> M;
    vector<vector<int> > r(M);
    rep(i,M){
        int k;cin >> k;
        r[i].resize(k);
        rep(j,k){
            cin >> r[i][j];
            r[i][j]--;
        }
    }

    vector<int> p(M);
    rep(i,M){
        cin >> p[i];
    }
    int res = 0;
    rep(bits,1 << N){
        bool ok = true;
        rep(j,M){
            int cnt = 0;
            if(!ok)break;
            for(auto e : r[j]){
                if(bits & (1 << e))cnt++;
            }
            cnt %= 2;
            if(cnt != p[j])ok = false;
        }
        if(ok)res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    string s, t;
    cin >> s >> t;

    int n = s.size();

    int p[256] = {};
    int b = 1;
    for (int i = 0; i < n; i++) {
        if (p[s[i]] == 0) {
            p[s[i]] = t[i];
        } else {
            if (p[s[i]] != t[i]) b = 0;
        }
    }

    int q[256] = {};
    for (int j = 0; j < 256; j++) {
        if (p[j] == 0) continue;
        if (q[p[j]] == 0) {
            q[p[j]] = 1;
        } else {
            b = 0;
        }
    }

    cout << (b ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A=0,B=0,C=0,D=0,N;
  cin>>N;
  vector<string> S(N);
  for (int i=0; i<N; i++) {
    cin >> S.at(i);
    if(S.at(i)=="AC") {
      A++;
    }
    else if (S.at(i)=="WA") {
      B++;
    }
    else if (S.at(i)=="TLE") {
      C++;
    }
    else {
      D++;
    }
  }
  cout <<"AC x "<<A<<endl;
  cout <<"WA x " <<B<<endl;
  cout <<"TLE x " <<C<<endl;
  cout <<"RE x " <<D<<endl;
}

Measured memory_bytes: 6368
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 100005, MAXM = 1003, Mod = 1000000007 , MAXLog = 20;

long long f(vector<int> &arr, int b) {
    long long ret = 0;
    for (int i = 0; i < arr.size(); ++i) {
        ret += abs(arr[i] - (b + i + 1));
    }
    return ret;
}

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout << fixed;

    int n;
    cin >> n;
    vector<int> arr(n);
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        ans += arr[i] - 1;
    }

    cout << ans << '\n';



    return 0;
}

Measured memory_bytes: 256