akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdexcept>
#include<cmath>
#include<memory>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define pf push_front
#define LIM 510000
#define MAX 510000
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;
bool prime[LIM];

void eratos(){
  rep(i,LIM)prime[i] = false;
  for(int i=3;i<LIM;i+=2)prime[i] = true;
  prime[2] = true;

  for(int i=3;i<=sqrt(LIM);i+=2){
    if(!prime[i])continue;
    for(int j=i+i;j<=sqrt(LIM);j+=i)
      prime[j] = false;
  }
}

void create(){
   for(int i=0;i<=MAX;i++)prime[i]=false;
   for(int i=3;i<=MAX;i+= 2)prime[i] = true;
   prime[2] = true;
   int limit = (int)sqrt(MAX)+1; 
     for(int i=3;i<=limit;i+=2){
    if(!prime[i])continue;
      for(int j=i+i;j<=MAX;j+=i){
        prime[j]=false;
      }
       
   }
 
}
 
bool isPrime(int n){
  for(int i=2;i<=sqrt((double)n);i++){
    if(n%i == 0)return false;
  }
  return true;
}

int main(){

  create();
  int n;
  while(true){
    cin >> n;
    if(n == 0)break;
 
    int cnt = 0;
    for(int i=2;i <= n/2;i++){
      
      if(prime[n-i] && prime[i] ){
	//	cout << i << "-th,"<< i << " " << n-i  << endl;
	
	cnt++;
      }
    }
    cout << cnt << endl;
  }


return 0;
}

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

double solve() {
    ll N;
    cin >> N;
    vector<ll> T(N), V(N);
    for ( int i = 0; i < N; i++ ) cin >> T[i];
    for ( int i = 0; i < N; i++ ) cin >> V[i];
    ll t_max = 0;
    for ( int i = 0; i < N; i++ ) {
        t_max += T[i];
    }
    vector<double> v(2*t_max+1, 1000);
    int ct = 0;
    for ( int i = 0; i < N; i++ ) {
        for ( int j = 0; j <= 2*T[i]; j++ ) {
            v[ct] = min(v[ct], (double)V[i]);
            if ( j != 2*T[i] ) ct++;
        }
    }
    double cv = 0;
    for ( ll t = 0; t < 2*t_max; t++ ) {
        v[t] = cv;
        cv = min(cv+0.5, v[t+1]);
    }
    cv = 0;
    for ( ll t = 2*t_max; t > 0 ; t-- ) {
        v[t] = cv;
        cv = min(cv+0.5, v[t-1]);
    }
    double ans = 0;
    for ( ll t = 0; t < 2*t_max; t++ ) {
        ans += v[t] + v[t+1];
    }
    ans /= 4;
    return ans;
}

int main() {
    cout.setf(ios::fixed);
    cout.precision(16);
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 512
while True:
    a, b, c = map(int, input().split())
    if a == -1 and b == -1 and c == -1:
        break
    if a == -1 or b == -1 or a + b < 30:
        print("F")
    elif a + b >= 80:
        print("A")
    elif a + b >= 65:
        print("B")
    elif a + b >= 50 or c >= 50:
        print("C")
    else:
        print("D")
    


Measured memory_bytes: 5592
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;

	if (A <= C && C <= B) {
		cout << "Yes" << endl;
	}
	else if(B<=C&&C<=A){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a =sc.nextInt();
     int b=sc.nextInt();
     int c = sc.nextInt();
     if (a< b){ if (b<c){
         System.out.println("Yes");
     } else {
         System.out.println("No");
     }   }else{System.out.println("No");}
     
        //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //String line = br.readLine();
    }
}



Measured memory_bytes: 26244
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>

#define MAX 1000000000
#define MIN -10000000000

using namespace std;
int main() {
    int n,i,j,m;
    //long long maxx=MIN,minx=MAX,sum=0;
    cin>>n>>m;
    vector<vector<int> > a(n,vector<int>(m));
    vector<int> b(m);
    vector<int> ans(n);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    for(i=0;i<m;i++){
        cin>>b[i];
    }

    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            a[i][j]*=b[j];
        }
    }

    for(i=0;i<n;i++){
        ans[i]=0;
        for(j=0;j<m;j++){
            ans[i]+=a[i][j];
        }
        cout <<ans[i] << endl;
    }


    //cout<< minx << " " << maxx << " " << sum <<endl;


    return 0;
}


Measured memory_bytes: 3196
//g++でビルド

#include "bits/stdc++.h"

using namespace std;

char area[60][60];
int point[60][60];

int main(){
    int h, w;
    cin >> h >> w;
    int white = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            char a;
            cin >> a;
            area[i][j] = a;
            if(a == '.') white++;
            point[i][j] = 1000000000;
        }
    }

    queue<int> xqueue;
    queue<int> yqueue;

    xqueue.push(0);
    yqueue.push(0);
    point[0][0] = 0;

    while(!xqueue.empty()){
        int x = xqueue.front(); xqueue.pop();
        int y = yqueue.front(); yqueue.pop();
        if(area[x][y] == '#'){
            //nothing to doa
        }else if(area[x][y] == '.'){
            int now = point[x][y];
            if(point[x-1][y] > now + 1 && x > 0){
                xqueue.push(x-1); yqueue.push(y);
                point[x-1][y] = now + 1;
            }
            if(point[x+1][y] > now + 1 && x < h-1){
                xqueue.push(x+1); yqueue.push(y);
                point[x+1][y] = now + 1;
            }
            if(point[x][y-1] > now + 1 && y > 0){
                xqueue.push(x); yqueue.push(y-1);
                point[x][y-1] = now + 1;
            }
            if(point[x][y+1] > now + 1 && y < w-1){
                xqueue.push(x); yqueue.push(y+1);
                point[x][y+1] = now + 1;
            }
        }
    }

    int result = 0;
    int max = point[h-1][w-1];

    if(max == 1000000000){
        result = -1;
    }else{
        result = white - max - 1;
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define abs(a) (((a)<0)?(-(a)):(a))
int n;
double min=10000000;
double t,a,h[1005];
int main(){
	scanf("%d",&n);
	scanf("%lf%lf",&t,&a);
	int ans=0;
	for (int i=1;i<=n;i++){
		double x;
		scanf("%lf",&x);
		x=t-x*0.006;
		if (abs(x-a)<min){
			min=abs(x-a);
			ans=i;
		}
	}
	printf("%d",ans);
}

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

const int MAX_N = 215;
int N, X;
int L[MAX_N];
int B[MAX_N];

void solve()
{
    int ans = 1;
    int at = 0;
    int idx = 1;
    while(idx <= N){
        at += L[idx++];
        if(at > X) break;
        ans++;
    }
    cout << min(ans,N+1) << endl;
}

int main()
{
  cin >> N >> X;
  for(int i=1;i<=N;++i)cin >> L[i];
  solve();
  return 0;
}


Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 26.11.2019 11:33:34       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  vector<int> seq;
  auto Do = [&](int k) {
    seq.push_back(k);
    for (int i = k; i < n; i++) {
      swap(p[i], p[i - k]);
    }
  };
  for (int it = 0; it < n - 1; it++) {
    Do(1);
    for (int i = 0; i < n - 1; i++) {
      if (p[n - 1] > p[0]) {
        Do(n - 1);
      }
      Do(1);
    }
  }
  for (int i = 0; i < n - 1; i++) {
    assert(p[i] < p[i + 1]);
  }
  cout << seq.size() << '\n';
  for (int x : seq) {
    cout << x << '\n';
  }
  return 0;
}


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

using namespace std;

#define f first
#define s second
#define pub push_back
#define pob pop_back
	
typedef vector<int> vi;
typedef vector<vi> graf;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> wgraf;

typedef vector<double> vd;
typedef pair<double,double> dd;
typedef vector<dd> vdd;

typedef uint64_t ui64;

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

	int n;
	string s;

	cin >> n >> s;

	int c;

	for(auto &x: s){

		c = x - 'A';

		c += n;
		c %= 26;

		x = 'A' + c;

	}

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,X;
	while(cin>>N>>X) {
		VI w(N);
		REP(i, N) cin>>w[i];
		ll v = abs(X-w[0]);
		REP(i, N) v = gcd(v, abs(w[i]-w[0]));
		
		cout<<v<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1024
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using Graph = vector<vector<int>>;
using Wgraph = vector<vector<pair<int, long long int>>>;
constexpr long long int INF = 1001001001001001LL;
constexpr long long int MOD = 1000000007LL;
constexpr double PI = 3.1415926535897932;
constexpr long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
constexpr long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#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(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define PB push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  
  int a, b; cin >> a >> b;
  if(a > 9) cout << -1 << endl;
  else if(b > 9) cout << -1 << endl;
  else cout << a * b << endl; 
  return 0;
}


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

int main() {
  int row, column;
  //char input;
  cin >> row >> column;
  
  string square[50];
  for (int i=0;i<row;++i) { cin>>square[i]; }
  
  const int pos_row[8] = {-1,-1,-1,0,0,1,1,1};
  const int pos_col[8] = {-1,0,1,-1,1,-1,0,1};
  
  for (int i = 0; i < row; i++) {
    for (int j = 0; j < column; j++) {
      if (square[i][j] == '#') { continue; }
      
      int num = 0;
      for (int k = 0; k < 8; k++) {
        int row_num = i + pos_row[k];
        int col_num = j + pos_col[k];
        
        if (row_num < 0 or row <= row_num) continue;
        if (col_num < 0 or column <= col_num) continue;
        if (square[row_num][col_num] == '#') {
          num++;
          //cout << num;
        }
      }
      square[i][j] = char(num + '0');
    }
  }
  
  for (int i = 0; i < row; i++) {
    for (int j = 0; j < column; j++) {
      cout << square[i][j];
    }
    cout << endl;
  }
}


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

int main(){
  int a,b;
  cin >> a >> b;
  int c1 = (a + b)/2;
  double c2 = double(a + b)/double(2);
  if((c2 - c1) >= double(1)/double(2)) cout << c1 + 1 << endl;
  else cout << c1 << endl;
}

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

#define PB push_back

using namespace std;

const int N = 2e5 + 500;
const int OFF = (1 << 18);
const int INF = 0x3f3f3f3f;

vector < int > v[N];

int q,n,a[N],prf[N],dp[N],tour[3 * OFF];


void update(int i,int a,int b,int lo,int hi,int x){
    if(lo <= a && b <= hi){
        tour[i] = min(tour[i], x);
        return;
    }
    if(a > hi || b < lo) return;
    update(2 * i,a, (a+b) / 2,lo, hi, x);
    update(2 * i + 1,(a+b+2) / 2, b, lo, hi, x);
}

int query(int x){
    x += OFF;
    int ret = INF;
    for(;x;x>>=1)
        ret = min(ret, tour[x]);
    return ret;
}

int main(){
    memset(tour, INF, sizeof(tour));
    scanf("%d",&n);
    for(int i = 0;i<n;i++){
        scanf("%d",a+i);
        prf[i] = !a[i];
        if(i)
            prf[i] += prf[i - 1];
    }
    scanf("%d",&q);
    for(int i = 0;i<q;i++){
        int x,y;scanf("%d%d",&x,&y);
        x--,y--;
        v[y].PB(x);
    }
    for(int i = 0;i<n;i++){
        dp[i] = a[i] + (i ? query(i - 1) + prf[i - 1] : 0);
        sort(v[i].begin(),v[i].end());
        for(int j = 0;j<v[i].size();j++){
            dp[i] = min(prf[i] + (v[i][j] ? query(v[i][j] - 1) : 0), dp[i]);
            if(v[i][j])
                update(1, 0 ,OFF - 1,v[i][j], i - 1, query(v[i][j] - 1));
            else
                update(1, 0 ,OFF - 1,v[i][j], i - 1, 0);
        }
        tour[i + OFF] = min(tour[i + OFF], dp[i] - prf[i]);
    }
    printf("%d\n", query(n - 1) + prf[n - 1]);
}


Measured memory_bytes: 15232
s = input()
len_s = len(s)
is_ok = False
while(is_ok == False):
    len_s -= 2
    word = s[:len_s]
    if word[:len_s // 2] == word[len_s // 2 :]:
        is_ok = True
    else:
        pass
print(len_s)

Measured memory_bytes: 9036
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), k = fs.nextInt();
		int a[] = fs.nextIntArray(n);
		int nums[][] = new int[n+1][2001];
		for(int i=n-1;i>=0;i--) {
			for(int j=0;j<2001;j++) {
				if(j>a[i]) {
					nums[i][j] = nums[i+1][j]+1;
				}
				else {
					nums[i][j] = nums[i+1][j];
				}
			}
		}
		
		long ans = 0;
		for(int i=0;i<n;i++) {
			long tmp = nums[i+1][a[i]];
			long  tmp2 = nums[0][a[i]];
			long res = plus (mul(tmp,k) , mul(tmp2,div(mul(k,k-1),2)));
			ans = plus(ans,res);
		}
		System.out.println(ans);
	}
	
	//MOD culculations
	static long plus(long x, long y) {
		x %= mod;
		y %= mod;
		long res = (x + y) % mod;
		return res;
	}

	static long sub(long x, long y) {
		x %= mod;
		y %= mod;
		long res = (x - y + mod) % mod;
		return res;
	}

	static long mul(long x, long y) {
		x %= mod;
		y %= mod;
		long res = x * y % mod;
		return res;
	}

	static long div(long x, long y) {
		x %= mod;
		y %= mod;
		long res = x * modpow(y, mod - 2) % mod;
		return res;
	}

	//modの元での高速pow()
	static long modpow(long a, long p) {
		if (p == 0)
			return 1;
		if (p % 2 == 0) {
			long halfP = p / 2;
			long root = modpow(a, halfP);
			return root * root % mod;
		} else
			return a * modpow(a, p - 1) % mod;
	}

}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int sum_a = 0;
    REP(i,n){
        cin >> a[i];
        sum_a += a[i];
    }
    double ok = sum_a/(4.*m);
    int ans = 0;
    REP(i,n){
        ans+=(a[i] >= ok);
    }
    cout << ((ans >= m) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};
const ll LINF=1e18;
const ld PI=abs(acos(-1));

int main(){
	int n; cin >> n; int a[2][110];
	REP(i,0,2) REP(j,0,n) cin >> a[i][j];
	
	int Max = 0;
	for(int i = 0; i < n; i++){
		int total = 0, height = 0;
		
		for(int j = 0; j < n; j++){
			if(i == j){
				total += a[height][j];
				height = 1;
			}
				
			
			total += a[height][j];
		}
		
		Max = max(Max, total);
	}
	
	cout << Max << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,s,d,f,g,h,i,j;
	scanf("%d %d %d",&a,&s,&d);
	f=0;
	if(a==7)	f++;
	if(s==7)	f++;
	if(d==7)	f++;
	if(f==1)	printf("YES\n");
	if(f!=1)	printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#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;

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

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void add(int&,int);
int mul(int,int);
int powz(int,int);
template<typename A> ostream& operator<<(ostream&,vector<A>&);
 
const int N=500006;

void solve(){
	unsigned ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll orga=a,orgb=b;
	ll z=__gcd(c,d);a=(a-1)/z;b/=z;c/=z;d/=z;
	ll num1=b/c+b/d-(b/(c*d));
	ll num2=(a)/c+(a)/d-((a)/(c*d));
	debug(num1,num2);
	cout<<orgb-orga+1-(num1-num2);
}
	
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
	if(a<0)a+=mod;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
	    output<<i<<' ';
	return output;	
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

int N, K, arr[101010];

vector<vector<int>> graph;

pair<int, int> search(int v) {
    int perge_count = 0, max_dist = 1;
    for (const int w: graph[v]) {
        auto p = search(w);
        perge_count += p.first;
        if (v != 0 && p.second == K) {
            ++perge_count;
            continue;
        }
        max_dist = max(max_dist, p.second+1);
    }
    return make_pair(perge_count, max_dist);
}

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> K;
    for (int j = 0; j < N; ++j) {
        cin >> arr[j];
        --arr[j];
    }

    int offset = 0;
    if (arr[0] != 0) {
        ++offset;
        arr[0] = 0;
    }

    graph.resize(N);
    for (int j = 1; j < N; ++j) {
        graph[arr[j]].push_back(j);
    }

    auto result = search(0);
    cout << offset + result.first << endl;

    return 0;
}


Measured memory_bytes: 10752
#include<bits/stdc++.h>
using namespace std;
#define ll long long
///The greatest enemy of knowledge is not ignorance, it is illusion of knowledge

#include<bits/stdc++.h>
using namespace std;


#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpll vector<pll>
#define vpii vector<pii>
#define umap unordered_map
#define uset unordered_set
#define PQ priority_queue

#define printa(a,L,R) for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define printv(a) printa(a,0,a.size())
#define print2d(a,r,c) for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?'\n':' ')
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define fbo find_by_order
#define ook order_of_key
#define MP make_pair
#define UB upper_bound
#define LB lower_bound

#define F first
#define S second
#define mem(a,x) memset(a,x,sizeof(a))
#define inf 1e18
#define PI (acos(-1.0))
#define E 2.71828182845904523536
#define gamma 0.5772156649
#define nl "\n"
#define lg(r,n) (int)(log2(n)/log2(r))
#define pf printf
#define sf scanf
#define _ccase printf("Case %lld: ",++cs)
#define _case cout<<"Case "<<++cs<<": "
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; }

#define asche cerr<<"Ekhane asche\n";
#define rev(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define grtsrt(v) sort(v.begin(),v.end(),greater<ll>())
#define all(v) v.begin(),v.end()
#define mnv(v) *min_element(v.begin(),v.end())
#define mxv(v) *max_element(v.begin(),v.end())
#define toint(a) atoi(a.c_str())
#define fast ios_base::sync_with_stdio(false)
#define valid(tx,ty) (tx>=0&&tx<n&&ty>=0&&ty<m)
#define one(x) __builtin_popcount(x)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define stree ll l=(n<<1),r=l+1,mid=b+(e-b)/2
#define fout(x) fixed<<setprecision(x)

#define SQ(x) ((x)*(x))
#define issq(x) (((ll)(sqrt((x))))*((ll)(sqrt((x))))==(x))
#define AMR std::ios::sync_with_stdio(false);cin.tie(NULL);
void min_self(ll &a, ll b){
a=min(a,b);
}

int main(){
AMR;
ll n,W,v[105],w[105];
cin>>n>>W;
for(int i=1; i<=n; i++)cin>>w[i]>>v[i];
ll sum_val=0;

for(int i=1 ;i<=n; i++)sum_val+=v[i];
vector<ll >dp(sum_val+10,inf);
dp[0]=0;
for(int item=1 ;item<=n ;item++){

    for(int i=sum_val- v[item];i>=0 ;i--){
        min_self( dp[i+v[item]],dp[i]+w[item]);
    }

}
int ans=0;
for(int i=1; i<=sum_val ;i++){
   if(dp[i]<=W)
    ans=max(ans,i);
}
cout<<ans<<endl;

}










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

using namespace std;

const int nax = 3005;
const int mod = 1e9 + 7;

void add_self (int &a,int b)
{
    a+=b;
    if (a>=mod)
        a-=mod;
}

int dp[nax][nax],pref[nax][nax];
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    string s;
    cin >> s;

    dp[1][1]=1;
    for (int len=2;len<=n;len++)
    {
        for (int i=1;i<len;i++)
            pref[len-1][i]=(pref[len-1][i-1]+dp[len-1][i])%mod;
        for (int b=1;b<=len;b++)
        {
            int L,R;
            if (s[len-2]=='<')
                L=1,R=b-1;
            else
                L=b,R=len-1;

            if (L<=R)
            add_self(dp[len][b],(pref[len-1][R]-pref[len-1][L-1]+mod)%mod);
        }
    }

    int answer=0;
    for (int i=1;i<=n;i++)
        add_self(answer,dp[n][i]);

    cout << answer;
}



Measured memory_bytes: 69504
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[3],i;
    for(i=0;i<3;i++)
        cin>>a[i];
    sort(a,a+3);
    int ans=a[2]-a[1];
    a[0]=a[0]+ans;
    int d=a[2]-a[0];
    if(d%2==0) d=d/2;
    else  d=(d/2)+2;
    ans=ans+d;
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#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 all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 2e9+7;

int main() {
    int n;
    vs strings;
    cin >> n;
    rep(i, n) {
        string s; cin >> s;
        strings.pb(s);
    }
    set<string> sets(all(strings));
    if (strings.size() != sets.size()) {
        puts("No");
        return 0;
    }

    char next_first;
    rep(i, n) {
        if (i != 0 && next_first != strings[i][0]) {
            puts("No");
            return 0;
        }
        next_first = strings[i].back();
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define space " "
#define MOD (long long) 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename T> void __f(const char* variable_name, T&& value){cout << variable_name << ": " << value << endl;}
template <typename T1, typename... T2> void __f(const char* names, T1&& arg1, T2&&... args){const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);}

const ll N = 2e5 + 5;
vector<ll> gph[N];
vector<ll> dsu(N, -1), foes(N, 0);
ll *v;
ll n, m, k;

int set_find_rec(ll key){
    if(key>=dsu.size())
        throw exception();
    if(dsu[key]<0) // Reached the parent
        return key;
    return set_find_rec(dsu[key]); // Recursively search
}
int set_find(ll key){
    ll parent_of_key = set_find_rec(key); // Find parent
    if(parent_of_key == key) // If it's a parent node, no path compression
        return key;
    return dsu[key] = parent_of_key; // Otherwise, path compression
}
void set_union(ll a, ll b){
    ll parent_of_a = set_find(a);
    ll parent_of_b = set_find(b);
    if(parent_of_a==parent_of_b) // Belong to same set/connected component
        return;
    if(dsu[parent_of_a]<=dsu[parent_of_b]){ // A is bigger or equal to B (Reverse inequality due to -ve sign in size)
        dsu[parent_of_a] += dsu[parent_of_b]; // Update size
        dsu[parent_of_b] = parent_of_a; // Update parent of B
    }else{
        dsu[parent_of_b] += dsu[parent_of_a]; // Update size
        dsu[parent_of_a] = parent_of_b; // Update parent of A
    }
}

void solve(){
    cin >> n >> m >> k;
    ll x, y;
    for(ll i = 1; i <= m; i++){
        cin >> x >> y;
        gph[x].push_back(y);
        gph[y].push_back(x);
        set_union(x, y);
    }
    for(ll i = 1; i <= k; i++){
        cin >> x >> y;
        if(set_find(x) == set_find(y)){
            foes[x]++;
            foes[y]++;
        }
    }
    for(ll i = 1; i <= n; i++){
        ll par = set_find(i);
        ll sz = abs(dsu[par]);
        ll _foes = foes[i];
        cout << sz - 1 - ((ll)gph[i].size()) - _foes << space;
    }
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    // cout << "\n\nBLAH BLAH BLAH\n\n";
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

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

int main() {
    int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
    cout << min({
        A * X + B * Y,
        C * 2 * X + B * max(0, Y - X),
        A * max(0, X - Y) + C * 2 * Y
    }) << endl;
}


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

int main() {
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long r1, r2, c1, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    ++r2;
    ++c2;
    unsigned long N{r2 + c2};
    vector<unsigned long> factmod(N + 1, 1);
    for(unsigned long i{1}; i <= N; ++i)factmod[i] = factmod[i - 1] * i % MOD;
    const auto& binom = [&factmod](unsigned long k, unsigned long c) -> unsigned long {
        unsigned long r{factmod[k + c]}, a{factmod[k] * factmod[c] % MOD}, n{MOD - 2};
        while(n){
            if(n & 1)(r *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        return r;
    };
    unsigned long f11{binom(r1, c1)}, f12{binom(r1, c2)}, f21{binom(r2, c1)}, f22{binom(r2, c2)};
    cout << (MOD * 2 + f22 + f11 - f12 - f21) % MOD << endl;
    return 0;
}

Measured memory_bytes: 15872
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-24 16:44:10
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n, p; cin >> n >> p;
  vector<int> a(n); cin >> a;
  for_each(all(a), [](int& x){ x %= 2; });

  if (all_of(all(a), [](int x){ return !(x & 1); })) {
    if (p & 1) {
      cout << 0 << endl;
    } else {
      cout << (int64) pow(2LL, (int64) n) << endl;
    }
    return 0;
  }

  cout << (int64) pow(2LL, static_cast<int64>(n - 1)) << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		if(a<b && b<c) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}



Measured memory_bytes: 26140
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final String[] array = "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".split(", ");
        final Scanner scanner = new Scanner(System.in);
        final int index = scanner.nextInt() - 1;

        System.out.println(array[index]);
    }
}


Measured memory_bytes: 21844
//Created Time:2020年01月15日 星期三 17时06分57秒
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define N 302
#define mod 1000000007

using namespace std;

int n, m;
int f[N][N][N], mx[N][2], mn[N][2];

bool check(int ,int ,int);

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; ++i)
		mx[i][1] = mn[i][1] = n + 1;
	for(int i = 1; i <= m; ++i){
		int l, r, x; scanf("%d%d%d", &l, &r, &x);
		if(x == 1) mx[r][1] = min(mx[r][1], l - 1);
		if(x == 2) mx[r][0] = max(mx[r][0], l), mn[r][1] = min(mn[r][1], l - 1);
		if(x == 3) mn[r][0] = max(mn[r][0], l);
	} f[0][0][0] = 1;
	for(int i = 0; i <= n; ++i)
		for(int j = 0; j <= i; ++j)
			for(int k = 0; k <= i; ++k){
				if(!f[i][j][k]) continue;
				if(check(i + 1, j, k)) (f[i + 1][j][k] += f[i][j][k]) %= mod;
				if(check(i + 1, i, k)) (f[i + 1][i][k] += f[i][j][k]) %= mod;
				if(check(i + 1, j, i)) (f[i + 1][j][i] += f[i][j][k]) %= mod;
			}
	int ans = 0;
	for(int i = 0; i <= n; ++i)
		for(int j = 0; j <= n; ++j)
			(ans += f[n][i][j]) %= mod;
	cout << ans << endl;
	return 0;
}

bool check(int a, int b, int c){
	if(b == c && b) return false;
	int Mn = min(b, c), Mx = max(b, c);
	return (Mn >= mn[a][0]) & (Mn <= mn[a][1]) & (Mx >= mx[a][0]) & (Mx <= mx[a][1]);
}

Measured memory_bytes: 105472
#include<stdio.h>
int main(void)
{
	int a,b,c,d,x,y,z;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	x=a+b+c+d;
	y=x/60;
	z=x%60;
	printf("%d\n",y);
	printf("%d\n",z);
	return 0;
}


Measured memory_bytes: 2736
using System;

namespace C_sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var items = Console.ReadLine().Split(' ');

                var x = int.Parse(items[0]);
                var y = int.Parse(items[1]);

                if (x == 0 && y == 0)
                {
                    break;
                }

                if (x < y)
                {
                    Console.WriteLine($"{x} {y}");
                }
                else
                {
                    Console.WriteLine($"{y} {x}");
                }
            }
        }
    }
}



Measured memory_bytes: 15920
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

int main(void) {
	string s;
	getline(cin, s);

	transform(s.begin(), s.end(), s.begin(), ::toupper);

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 1176
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
const int N=2e5+11;
queue<int> Q;
vector<int> V[N];
int vis[N],tmp[N],from[N],d[N],n,pre,ans,tim,col[N],i,j,k,u;
int main(){
//	freopen("ex.in","r",stdin);
	scanf("%d",&n);
	for(i=1;i<=n;++i){
		scanf("%d",&from[i]);
		d[from[i]]++;
	}
	for(i=1;i<=n;++i) if(d[i]==0) Q.push(i);
	while(!Q.empty()){
		u=Q.front(),Q.pop();
		tim++;
		for(i=0;i<V[u].size();++i) tmp[V[u][i]]=tim;
		for(i=0;tmp[i]==tim;++i);
		col[u]=i;
		V[from[u]].push_back(i);
		if(!(--d[from[u]])) Q.push(from[u]);
	}
	for(i=1;i<=n;++i) if(d[i]){u=i;break;}
	tim++;
	for(i=0;i<V[u].size();++i) tmp[V[u][i]]=tim;
	for(k=0;tmp[k]==tim;++k);
	ans=pre=k;
	for(i=from[u];i!=u;i=from[i]){
		tim++;
		tmp[pre]=tim;
		for(j=0;j<V[i].size();++j) tmp[V[i][j]]=tim;
		for(j=0;tmp[j]==tim;++j);
		pre=j;
	}
	if(pre!=ans){
		puts("POSSIBLE");
		return 0;
	}
	tim++;
	for(i=0;i<V[u].size();++i) tmp[V[u][i]]=tim;
	for(k=0;tmp[k]==tim;++k);
	ans=k;
	for(k++;tmp[k]==tim;++k);
	pre=k;
	for(i=from[u];i!=u;i=from[i]){
		tim++;
		tmp[pre]=tim;
		for(j=0;j<V[i].size();++j) tmp[V[i][j]]=tim;
		for(j=0;tmp[j]==tim;++j);
		pre=j;
	}
	if(pre==ans) puts("POSSIBLE");
	else puts("IMPOSSIBLE");
	return 0;
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll N, X;
VL p, d;
map<ll, ll> pnum;

ll pcnt(ll eat, ll lev) {
    if(lev == 0) {
        if(eat <= 0) return 0;
        return 1;
    } else if(eat <= 1 + d[lev - 1]) {
        return pcnt(eat - 1, lev - 1);
    } else {
        return p[lev - 1] + 1 + pcnt(eat - d[lev - 1] - 2, lev - 1);
    }
}

int main() {
    cin >> N >> X;
    d.resize(N + 1);
    p.resize(N + 1);
    d[0] = 1;
    p[0] = 1;
    REP(i, N) {
        d[i + 1] = 2 * d[i] + 3;
        p[i + 1] = 2 * p[i] + 1;
    }
    cout << pcnt(X, N) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		int count = 0;
		for(int i = 1; i < n / 2 + 1; ++i)
		{
			int sum = 0;
			for(int j = i; j < n / 2 + 2; ++j)
			{
				sum += j;
				if(sum == n)
				{
					count++;
				}
				else if(sum > n)
				{
					break;
				}
			}
		}
		cout << count << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

	string s;
	int mn[26];
	fill(mn, mn + 26, 100);
	for (int i = 0; i < n; i++) {
		cin >> s;

		int t[26] = {};
		for (int j = 0; j < s.length(); j++) {
			t[s[j] - 'a']++;
		}
		for (int j = 0; j < 26; j++) {
			mn[j] = min(mn[j], t[j]);
		}
	}
	
	bool f = false;
	for (int i = 0; i < 26; i++) {
		if (mn[i] != 0) {
			f = true;
			break;
		}
	}

	if (f) {
		for (int i = 0; i < 26; i++) {
			for (int j = 0; j < mn[i]; j++) {
				printf("%c", 'a' + i);
			}
		}
		cout << endl;
	} else {
		cout << "" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int s=min(a,b);
    int e=max(a,b);
    for(int i=s;i<=e;i++){
        if(i==c){
            cout<<"Yes"<<endl;
            break;
        }
        if(i==e){
            cout<<"No"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
/*
#include <boost/functional/hash.hpp>
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int mlint;
*/
#include <bits/stdc++.h>

#define debug 0
#define fcout(d) cout << fixed << setprecision(d)
#define urep(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define drep(i,s,t) for(int i = (int)(s); i >= (int)(t); --i)
#define rep(i,n) urep(i,0,(n) - 1)
#define rep1(i,n) urep(i,1,(n))
#define rrep(i,n) drep(i,(n) - 1,0)
#define all(v) begin(v),end(v)
#define rall(v) rbegin(v),rend(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define rsz resize
#define era erase
#define emp emplace
#define emf emplace_front
#define emb emplace_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second

using namespace std;

typedef long long ll;
typedef double db;
typedef vct<vct<ll>> mat;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef map<int,int> mpii;
typedef unordered_map<int,int> umpii;

const int dir[8][2] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const ll inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;
const ll mod = 1e9 + 7;
const db eps = 1e-15;

auto esc = [](auto ret) { cout << ret << endl; exit(0); };
auto odd = [](auto x) { return x & 1; };
auto even = [](auto x) { return !odd(x); };
auto qceil = [](auto x, auto y) { return x > 0 ? (x - 1) / y + 1 :  x / y; };
auto parity = [](auto x, auto y) { return odd(x) ^ even(y); };
auto chmax = [](auto& m, auto x) { if(m < x) { m = x; return 1; } return 0; };
auto chmin = [](auto& m, auto x) { if(m > x) { m = x; return 1; } return 0; };
auto cmprs  = [](auto& v) {
    auto tmp = v;
    sort(all(tmp));
    tmp.erase(unique(all(tmp)),end(tmp));
    for(auto it = begin(v); it != end(v); ++it) *it = l_bnd(all(tmp),*it) - begin(tmp) + 1;
    return tmp.size() != v.size();
};


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

    int n,k,bd[3001][3001]={};
    cin>>n>>k;
    rep(i,n){
        int x,y;
        char c;
        cin>>x>>y>>c;
        if(c=='B') x+=k;
        x%=2*k;
        y%=2*k;
        int xx,yy;
        if(x<k) xx=x+k;
        else xx=x-k;
        if(y<k) yy=y+k;
        else yy=y-k;
        bd[x+1][y+1]++;
        bd[xx+1][yy+1]++;
    }
	urep(i,2*k+1,3*k)rep1(j,2*k) bd[i][j]=bd[i-k*2][j];
	urep(j,2*k+1,3*k)rep1(i,k*3) bd[i][j]=bd[i][j-k*2];
    rep1(i,k*3)rep(j,k*3) bd[i][j+1]+=bd[i][j];
    rep1(j,k*3)rep(i,3*k) bd[i+1][j]+=bd[i][j];
    int ans=0;
    rep(j,2*k){
        rep(i,2*k){
            chmax(ans,bd[i+k][j+k]+bd[i][j]-bd[i][j+k]-bd[i+k][j]);
        }
    }
    esc(ans);
}


Measured memory_bytes: 35456
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		int N = I[0], K = I[1];
		var h = G;
		var dp = new int[N];
		for (var i = N - 2; i >= 0; i--)
		{
			dp[i] = int.MaxValue;
			for (var j = 1; j <= K; j++) if (i + j < N) dp[i] = Min(dp[i], dp[i + j] + Abs(h[i] - h[i + j]));
		}
		WriteLine(dp[0]);
	}
}


Measured memory_bytes: 20064