akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double PI = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	long long n, m, a, b;
	cin >> n >> m;
	vector<bool> x(n), y(n);
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		if (a == 1)
			x[b - 1] = true;
		else if (b == n)
			y[a - 1] = true;
	}
	if (m == 1 || m == 0) {
		puts("IMPOSSIBLE");
		return 0;
	}

	bool ans = false;
	for (int i = 0; i < n; i++) {
		if (x[i] & y[i]) {
			ans = true;
			break;
		}
	}
	if(ans)
		puts("POSSIBLE");
	else
		puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
const int N = 1 * 1e6 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
int v[1005];
ll POW(ll a,ll b){
    ll ans = 1;
    while(b){
        if(b & 1)
            ans = (ans % mod * a % mod) % mod;
        b >>= 1;
        a = (a % mod * a % mod) % mod;
    }
    return ans;
}
int main(){/*
    freopen("in","r",stdin);
    freopen("out","w",stdout);*/
    fast;
    vector<int> pr;
    for(int i = 2; i < 1005; i++)
        if(!v[i]){
            pr.pb(i);
            for(int j = i * i; j < 1005; j += i)
                v[j] = 1;
        }
    int n;
    cin >> n;
    ll ans = 1;
    vector<int> aux;
    fore(i,0,sz(pr)){    
        if(pr[i] <= n){
            int nn = n;
            ll exp = 0;
            ll fp = pr[i];
            while(nn / fp > 0){
                exp += nn / fp;
                fp *= pr[i];    
            }
            ans = (ans % mod * (exp + 1) % mod) % mod;
        }
        else
            break;
    }
    cout << ans << '\n';
    return 0;   
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

void draw(int n) {
  const static int dx[4] = {1,0,-1,0};
  const static int dy[4] = {0,1,0,-1};
  char M[100][100];
  fill(M[0], M[100], '#');
  if(n != 1) {
    int x = 1, y = n-1;
    int dir = 3;

    M[y][x] = ' ';
    
    while(1) {
      int t;
      for(t = 0; t < 2; t++) {
	int nx = x + dx[dir];
	int ny = y + dy[dir];
	int x2 = x + dx[dir]*2;
	int y2 = y + dy[dir]*2;
	if(nx >= 0 && nx < n && ny >= 0 && ny < n && M[ny][nx] == '#' &&
	   x2 >= 0 && x2 < n && y2 >= 0 && y2 < n && M[y2][x2] == '#') {
	  M[ny][nx] = ' ';
	  x = nx;
	  y = ny;
	  break;
	}
	dir = (dir+1)%4;
      }
      if(t == 2) break;
    }
  }

  rep(i, n) {
    rep(j, n) {
      cout << M[i][j];
    }
    cout << endl;
  }
}

main() {
  int d;
  cin >> d;
  rep(i, d) {
    int n;
    cin >> n;
    if(i != 0) cout << endl;
    draw(n);
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M,K;
  cin>>N>>M>>K;
  short kk[N*M+1]={};
  kk[0]=1;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=M;j++){
      kk[i*(M-j)+j*(N-i)]=1;
    }
  }
  if(kk[K])
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 2176
def diff(a, b, c):
    i = 0
    for aa, bb, cc in zip(a, b, c):
        if aa != bb and aa != cc and bb != cc:
            i += 2
        elif aa != bb or bb != cc:
            i += 1
    return i

n = int(input())
a = list(input())
b = list(input())
c = list(input())

print(diff(a, b, c))

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
  int W, H, x, y, r;
  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
  if((x - r) < 0 || (x + r) > W|| (y - r) < 0 || (y + r) > H){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
  return 0;
}



Measured memory_bytes: 2100
#include <stdio.h>

int main() {
	
	int N;
	scanf("%d",&N);
	
	if( N == 22 ){
		printf("Christmas Eve Eve Eve");
	}
	else if( N == 23 ){
		printf("Christmas Eve Eve");
	}
	else if( N == 24 ){
		printf("Christmas Eve");
	}
	else if( N == 25 ){
		printf("Christmas");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<ext/pb_ds/priority_queue.hpp>
using namespace std;
#define MAXN 100000+10
const int INF=99999999;
struct Ed{
	int u,dis;
	Ed(){}
	Ed(int u,int dis):u(u),dis(dis){}
	bool operator >(const Ed &a)const{return dis>a.dis;}
};
typedef __gnu_pbds::priority_queue<Ed,greater<Ed>,__gnu_pbds::thin_heap_tag> heap;
heap q;
heap::point_iterator it[MAXN];
int k,vis[MAXN],dis[MAXN];
void dijkstra(){
	for(int i=0;i<k;i++)dis[i]=INF;	
	dis[1]=0;
	for(int i=0;i<k;i++)it[i]=q.push((Ed){i,dis[i]});
	while(!q.empty()){
		int t,u=q.top().u;
		q.pop();
		if(vis[u])continue;
		vis[u]=1;
		t=u*10%k;
		if(!vis[t]&&dis[u]<dis[t]){
			dis[t]=dis[u];
			q.modify(it[t],(Ed){t,dis[t]});
		}
		t=(u+1)%k;
		if(!vis[t]&&dis[u]+1<dis[t]){
			dis[t]=dis[u]+1;
			q.modify(it[t],(Ed){t,dis[t]});
		}
	}
}
int main(){
	scanf("%d",&k);
	dijkstra();
	printf("%d\n",dis[0]+1);
	return 0;
}

Measured memory_bytes: 6528
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N, X = map(int, input().split())

all_elements = [1]
ps = [1]
bs = [0]
for i in range(50):
    all_elements.append(all_elements[-1] * 2 + 3)
    ps.append(ps[-1] * 2 + 1)
    bs.append(bs[-1] * 2 + 2)

def from_bottom(n, x):
    if n == 0:
        if x == 1: return 1
        else: return 0

    curr_elements = all_elements[n]
    prev_elements = all_elements[n - 1]

    if x <= 1:
        return 0
    if x <= prev_elements + 1:
        return from_bottom(n - 1, x - 1)
    if x == prev_elements + 1:
        return from_bottom(n - 1, x - 2) + 1
    if x <= prev_elements * 2 + 2:
        return 1 + ps[n - 1] + from_bottom(n - 1, x - 2 - prev_elements)
    if x == curr_elements:
        return ps[n]

def slow(n, x):
    burger = ['P']
    for i in range(n):
        burger = ['B'] + burger + ['P'] + burger + ['B'] 
    # print(burger)
    ans = 0
    for i in range(x):
        ans += burger[i] == 'P'
    return ans

# # debug
# while True:
#     for n in range(2, 50):
#         for x in range(6, all_elements[n]):
#             if from_bottom(n, x) != slow(n, x):
#                 print("error! n, x = ", n, x )
#                 print("wrong:", from_bottom(n, x))
#                 print("correct:", slow(n, x))
#                 sys.exit(0)

print(from_bottom(N, X))


Measured memory_bytes: 6860
def isprime(i):
  j=2
  while(j**2<=i):
    if(i%j==0):
      return False
    j+=1
  return True

n=int(input())
x=[]
for i in range(6,55552,5):
  if(isprime(i)):
    x.append(i)
  if(len(x)==n):
    break
print(*x)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;

int dp[100010][1001];
bool possible(int s, int c){
    if(s == 0 && c >= 0)return 1;
    if(s <= 0 || c <= 0)return 0;

    if(dp[s][c] != -1)return dp[s][c];

    if(5 * c < s)return dp[s][c] = 0;
    //cout << s << " " << c << '\n';
    dp[s][c] = 0;
    for(int k = 0; k <= 5; k++){
        dp[s][c] |= possible(s - k, c - 1);
    }
    return dp[s][c];
}
int main(){
 memset(dp, -1, sizeof dp);
 int X;
 cin >> X;
 for(int i = 0; i <= 1000; i++){
     int left = X - 100 * i;
     if(possible(left, i)){
        cout << 1 << '\n';
        return 0;
     }
 }
 cout << 0 << '\n';
}

Measured memory_bytes: 391296
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int h, w;
    cin >> h >> w;
    auto a = make_vec<char>(h, w);
    rep(i, h) rep(j, w) cin >> a[i][j];

    set<int> rmi, rmj;
    rep(i, h) {
        bool flag = true;
        rep(j, w) if (a[i][j] == '#') flag = false;
        if (flag) rmi.insert(i);
    }
    rep(j, w) {
        bool flag = true;
        rep(i, h) if (a[i][j] == '#') flag = false;
        if (flag) rmj.insert(j);
    }
    rep(i, h) {
        if (rmi.count(i)) continue;
        rep(j, w) {
            if (rmj.count(j)) continue;
            cout << a[i][j];
        }
        cout << endl;
    }
        
}


Measured memory_bytes: 3564
data = [
    "{0} {1}" .format(s, r)
    for s in ('S','H','C','D')
    for r in range(1, 13 + 1)
    ]

count = int(input())
for c in range(count):
    card = input()
    data.remove(card)

for c in data:
    print(c)

Measured memory_bytes: 7716
def countingsort(A, k):
    C = [0 for _ in range(k)]
    ret = [-1 for _ in A]
    for a in A:
        C[a] += 1
    for i in range(k - 1):
        C[i + 1] += C[i]
    for a in reversed(A):
        ret[C[a]-1] = a
        C[a] -= 1
    return ret


_, *A = map(int, open(0).read().split())
A = countingsort(A, max(A) + 1)
print(' '.join(map(str, A)))


Measured memory_bytes: 226268
object Main extends App {
  val n =  scala.io.StdIn.readInt()
  val zeinukiKiriage = math.ceil(n / 1.08)
  val zeinukiKirisage = math.floor(n / 1.08)
  val judge1 = zeinukiKiriage * 1.08
  val judge2 = zeinukiKirisage * 1.08
  if (judge1 < (n + 1) && judge1 >= n) {
    println(zeinukiKiriage.toInt)
  } else if (judge2 < (n + 1) && judge2 >= n) {
    println(zeinukiKirisage.toInt)
  } else {
    println(":(")
  }
}

Measured memory_bytes: 27208
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,m,p,pena[100005]={},f[100005]={},cnt1=0,cnt2=0;
  string s;
  cin >> n >> m;
  for(int i=0; i<m; i++) {
    cin >> p >> s;
    if(s=="WA"&&!f[p]) {
      pena[p]++;
    }
    else {
      f[p]=1;
    }
  }
  for(int i=1; i<=n; i++) {
    if(f[i]) {
      cnt1++;
      cnt2+=pena[i];
    }
  }
  cout << cnt1 << " " << cnt2 << endl;
}

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

int main() {

    int A,B;
    cin >> A >> B;
    
    if (A > B) {
        cout << A + (A - 1) << endl;
    }
    
    if (A < B) {
        cout << B + (B - 1) << endl;
    }
    
    if (A == B) {
             cout << A + B << endl;
    }
    
    
}


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

using namespace std;

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

	if (N == 1) {
		cout << "Hello World" << endl;
	}
	else if(N==2){
		int A, B;
		cin >> A >> B;
		cout << A + B << endl;
	}
}


Measured memory_bytes: 3512
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int s[510][510],n,m,Q,l,r,p,q,a[510][510],i,j;
  scanf("%d %d %d\n",&n,&m,&Q);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      a[i][j]=0;
    }
  }
  for(i=0;i<m;i++){
    scanf("%d %d\n",&l,&r);
    l--,r--;
    a[0][r]++;
    a[l+1][r]--;
  }
  for(i=0;i<n;i++){
    s[0][i]=0;
    s[i][0]=0;
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      s[i+1][j+1]=s[i][j+1]+s[i+1][j]-s[i][j]+a[i][j];
    }
  }
  for(i=0;i<Q;i++){
    scanf("%d %d\n",&p,&q);
    printf("%d\n",s[p][q]);
  }
  return 0;
}

Measured memory_bytes: 2944
until (n = gets.to_i).zero?
  arr, k = gets.split.map(&:to_i), 0
  
  loop do
    k += 1
    tmp = n.times.map{ |i| arr.count(arr[i]) }
    arr == tmp ? break : arr = tmp
  end
  
  puts k - 1, arr.join(" ")
end

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef long long ll;

const int MOD = 1000000007;

void solve() {
  int N;
  cin >> N;
  vector<vi> table(10, vi(10, 0));
  for (int i = 1; i < N + 1; i++) {
    string istr = to_string(i);
    table[int(istr[0] - '0')][int(istr[istr.size() - 1] - '0')]++;
  }
  int ans = 0;
  for (int i = 1; i < N + 1; i++) {
    string istr = to_string(i);
    ans += table[int(istr[istr.size() - 1] - '0')][int(istr[0] - '0')];
  }
  cout << ans << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
struct rectangle{
	int h,w,d;
};
int main(void){
	struct rectangle r[150*150],t;
	int i,j,c,h,w;
	c=0;
	for(i=0;i<150;i++){
		for(j=i+1;j<150;j++){
			r[c].h=i+1;
			r[c].w=j+1;
			r[c].d=(i+1)*(i+1)+(j+1)*(j+1);
			c++;
		}
	}
	for(i=0;i<c-1;i++){
		for(j=c-1;j>i;j--){
			if(r[j-1].d>r[j].d||(r[j-1].d==r[j].d&&r[j-1].h>r[j].h)){
				t=r[j-1];
				r[j-1]=r[j];
				r[j]=t;
			}
		}
	}
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0){
			break;
		}
		for(i=0;i<c;i++){
			if(h==r[i].h&&w==r[i].w){
				printf("%d %d\n",r[i+1].h,r[i+1].w);
				break;
			}
		}
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll k,n;
  cin>>k>>n;
  vll a(n);
  REP(i,n)cin>>a[i];

  sort(ALL(a));
  ll dist=0;
  REP1(i,n)dist = max(dist,a[i]-a[i-1]);
  dist = max(dist, k-a[n-1]+a[0]);

  ll ans = k-dist;
  cout<<ans<<endl;
}



Measured memory_bytes: 1792
#include <iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

void merge(int A[], int n, int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  for (int i = 0; i < n1; i++) L[i] = A[left + i];
  for (int i = 0; i < n2; i++) R[i] = A[mid + i];
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  int i = 0;
  int j = 0;
  for (int k = left; k < right; k++) {
    cnt++;
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(int A[], int n, int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int main() {
  int A[MAX], n, i;
  cnt = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> A[i];
  }

  mergeSort(A, n, 0, n);

  for (i = 0; i < n; i++) {
    if (i) cout << " ";
    cout << A[i];
  }
  cout << endl;

  cout << cnt << endl;
}


Measured memory_bytes: 6952
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define F first
#define S second
#define f(i,s,n) for(int i=(int)s;i<=(int)n;++i)
#define Fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
void solve()
{
	int n;cin>>n;
	ll maxa=INT_MIN,mina=INT_MAX,maxb=INT_MIN,minb=INT_MAX;
	f(i,0,n-1){
		ll x,y;cin>>x>>y;
		ll a=x+y;
		ll b=x-y;
		maxa=max(maxa,a);
		mina=min(mina,a);
		maxb=max(maxb,b);
		minb=min(minb,b);
	}
	cout<<max(maxa-mina,maxb-minb)<<'\n';

}
int main()
{	Fast;
	//int t;cin>>t;
	//while(t--)
	solve();
}
/*
# TestCase
4
6 8
1 10
3 6
6 6

# Participant
7

# Expected
9
--------------
# TestCase
4
6 4
5 9
2 7
3 9

# Participant
7

# Expected
8
---------------
# TestCase
4
10 1
5 5
1 5
1 4

*/

Measured memory_bytes: 3672
import java.util.*;
public class Main {

	private boolean isParallel(double ax, double ay, double bx, double by){
		final double EPS = 1.0e-8;
		double result = ax * by - bx * ay;
		if(Math.abs(result) < EPS)
			return true;
		else
			return false;
	}

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i=0; i < n; i++){
			double [] x = new double[4];
			double [] y = new double[4];
			for(int j=0; j < 4; j++){
				x[j] = sc.nextDouble();
				y[j] = sc.nextDouble();
			}
			double ax = x[1] - x[0];
			double ay = y[1] - y[0];
			double bx = x[3] - x[2];
			double by = y[3] - y[2];

			if(isParallel(ax, ay, bx, by))
				System.out.println("YES");
			else
				System.out.println("NO");
		}
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();

	}
}

Measured memory_bytes: 0
N = input()
count = 0
flag = 0
for i in range(1,N+1):
    IN = input()
    if flag:
        if (flag == i - 1):
            if  IN > 0:
                IN -= 1
                count += 1
    flag = 0

    count += IN/2
    if IN%2 == 1:
        flag = i

print count


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

using namespace std;

int n;

int main()
{
  cin >> n;

  map<int64_t, int> accum;
  accum[0] = 1;

  int64_t sum = 0;
  int64_t count = 0;
  int a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    sum += a;
    count += accum[sum];
    accum[sum]++;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 12800
# D - .. (Double Dots)

from collections import deque

N, M = map(int, input().split())
tree = [[] for _ in range(N)]
for i in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    tree[A].append(B)
    tree[B].append(A)

ans_arr = [-1] * (N)
q = deque()
ans_arr[0] = 0 
q.append(0)

while len(q)>0:
    n = q.popleft()
    for i in tree[n]:
        if ans_arr[i] == -1:
            ans_arr[i] = n+1
            q.append(i)

ans = 'Yes'
for i in ans_arr[1:]:
    if i == -1:
        ans = 'No'
        break

if ans == 'No':
    print(ans)
else:
    print(ans)
    for i in ans_arr[1:]:
        print(i)


Measured memory_bytes: 37772
x = int(input())

a = [0] * 400

for i in range(-200, 200):
    a[i+200] = i**5

for i in range(400):
    for j in range(400):
        if a[i] - a[j] == x:
            break
    else:
        continue
    break

i = i - 200
j = j - 200

print("{} {}".format(i, j))


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

int main() {
  int X, Y, Z, a=0;
  cin >> X >> Y >> Z;
  while (true) {
    if (X<Y+Z+Z) {
      break;
    } else {
      a+=1;
      X-=Y+Z;
    }
  }
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

def judge(x):
    print(x)
    sys.stdout.flush()
    ans = str(input())
    if ans == "0":
        exit()
    else:
        return ans



n = int(input())
left = 0
mid = n//2
right = n-1

l = judge(left)
m = judge(mid)
r = judge(right)

while True:
    if ((mid-left)%2 == 0 and l == m) or ((mid-right)%2 == 1 and r == m) or ((left-mid)%2 == 1 and l != m) or ((mid-right)% 2 == 0 and r != m):
        left = mid
        mid = (left + right)//2
        l = m
        m = judge(mid)
    else:
        right = mid
        mid = (left + right)//2
        r = m
        m = judge(mid)

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

using namespace std;

vector<int> v, neg, pos;

long long z;

long long num_pairs(vector<int>& v, long long lim) {
  long long res = 0;
  int last = (int)v.size() - 1;

  for (int i = 0; i < last; ++i) {
    while (last > i && (long long)v[last] * v[i] > lim)
      --last;
    res += last - i;
  }

  return res;
}

long long num_pairs(long long lim) {
  long long res = 0;
  
  if (lim >= 0) {
     res += z * (pos.size() + neg.size());
     res += z * (z - 1) / 2;
  }
  
  if (lim >= 0)
    res += (long long)pos.size() * neg.size();

  if (lim > 0) {
    res += num_pairs(pos, lim);
    res += num_pairs(neg, lim);
  }

  if (lim < 0) {
    int last = (int)pos.size();
    for (long long n : neg) {
      while (last && n * pos[last-1] >= -lim)
        --last;

      res += pos.size() - last;
    }
  }

  //cout << lim << " " << res << endl;
  
  return res;
}

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

  size_t n; cin >> n;
  long long k; cin >> k;
  v.resize(n);
  for (size_t i = 0; i < n; i++)
    cin >> v[i];

  sort(begin(v), end(v));
  for (int i : v) 
    if (i < 0) neg.push_back(-i);
    else if (i > 0) pos.push_back(i);
    else ++z;

  reverse(begin(neg), end(neg));
 
  long long lo = (long long)-1e18, hi = (long long)1e18;
  while (lo + 1 < hi) {
      long long mid = (lo + hi) / 2;
      if (num_pairs(mid) < k)
       lo = mid + 1;
      else
       hi = mid;
  }
  if (lo < hi && num_pairs(lo) < k) ++lo; 
  cout << lo << endl;
}


Measured memory_bytes: 2168
N = int(input())
s = input()

cand = ["S","W"]

ch = {"S":"W", "W":"S", "o":"x", "x":"o"}

def func(now_animal, pre_animal, mark):
    if now_animal == "W":
        mark = ch[mark]
    if mark == "o":
        return pre_animal
    else:
        return ch[pre_animal]

def judge(now_animal, pre_animal, next_animal, mark):
    if now_animal == "W":
        mark = ch[mark]
    if (mark == "o" and pre_animal == next_animal) or (mark == "x" and pre_animal != next_animal):
        return True
    else:
        return False

for a in cand:
    for b in cand:
        tmp = a + b
        # i番目を決める
        for i in range(2,N):
            tmp += func(tmp[i-1], tmp[i-2], s[i-1])
        if judge(tmp[-1], tmp[-2], tmp[0], s[-1]) and judge(tmp[0], tmp[-1], tmp[1], s[0]):
            print(tmp)
            exit()

print(-1)

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

int main() {
	int N, K;
	string S;
	cin >> N >> K;
	cin >> S;
	S[K - 1] = tolower(S[K - 1]);
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 3480
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main(){
    int k;
    cin >> k;
    string s;
    cin >> s;

    if(s.size() <= k) cout << s << endl;
    else {
        rep(i, k) cout << s[i];
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int k = scan.nextInt();
        int[] nums = new int[n];
        int[] dp = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = scan.nextInt();
            dp[i] = Integer.MAX_VALUE;
        }

        dp[0] = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j <= i + k; j++) {
                if(j < n) {
                    dp[j] = Math.min(dp[j], dp[i] + Math.abs(nums[j] - nums[i]));
                }
            }
        }
        System.out.println(dp[n - 1]);
    }

}


Measured memory_bytes: 61676
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
typedef long long ll;


ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
  string s, t, u;
  int a, b;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;

  (u == s) ? a-- : b--;
  cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;

#pragma endregion

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 




/*****************************************************************************/

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

	int n;
	cin >> n;
	vd p(n);
	f_vI(p, n);
	vvd dp(n + 1, vd(n + 1));
	dp[0][0] = 1.0;
	f(i, 0, n) {
		f(j, 0, i+1) {
			dp[i + 1][j + 1] += dp[i][j] * p[i];
			dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
		}
	}
	double ans = 0.0;
	f(i, (n + 1) / 2, n+1) {
		ans += dp[n][i];
	}
	cout << fixed << setprecision(10) << ans;
	return 0;
}

Measured memory_bytes: 70784
A = []
for _ in range(3):
    a = list(map(int,input().split()))
    A.append(a)
N = int(input())
Y = []
for _ in range(N):
    y = int(input())
    Y.append(y)
ans = 0
for i in range(3):
    if A[i][0] in Y and A[i][1] in Y and A[i][2] in Y :
        ans = 1
for i in range(3):
    if A[0][i] in Y and A[1][i] in Y and A[2][i] in Y :
        ans = 1
if A[0][0] in Y and A[1][1] in Y and A[2][2] in Y :
    ans = 1
if A[2][0] in Y and A[1][1] in Y and A[0][2] in Y :
    ans = 1
if ans == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>

#define p(a, b) pair<a, b>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int res = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                int q = 500 * i + 100 * j + 50 * k;
                if(q == x)
                    res++;
            }
        }
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
module Main where

import Control.Applicative

getInt :: IO Int
getInt = head <$> getInts

getInts :: IO [Int]
getInts = map read . words <$> getLine

main :: IO ()
main = do
  { [a, b] <- getInts
  ; if a < b then putStrLn "a < b"
    else if a == b then putStrLn "a == b"
         else putStrLn "a > b"
   }


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

#define For(i, j, k) for (int i = j; i <= k; i++)

using namespace std;

typedef long long LL;

const int N = 1e5 + 10;

int x[N];
LL w[N];
int S, n;

int main() {

	scanf("%d%d", &n, &S);
	For(i, 1, n) scanf("%d%lld", &x[i], &w[i]);

	int l = 1, r = n, nxt = 0;
	LL ans = 0;
	while (x[l] < S && x[r] > S) {
		if (w[l] >= w[r]) {
			w[l] += w[r];
			if (nxt != l) ans += x[r] - x[l];
			--r, nxt = l;
		} else {
			w[r] += w[l];
			if (nxt != r) ans += x[r] - x[l];
			++l, nxt = r;
		}
	}

	if (x[l] < S) ans += S - x[l];
	else ans += x[r] - S;
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 1408
from collections import deque
S=input()
deque_S=deque(S)
flag=0
ans=0
while True:
    if len(deque_S)<=1:
        break
    if deque_S[0] == deque_S[-1]:
        deque_S.pop()
        deque_S.popleft()
    else:
        if deque_S[0] == 'x':
            ans+=1
            deque_S.popleft()
        elif deque_S[-1] == 'x':
            ans+=1
            deque_S.pop()
        else:
            flag=1
            break
if flag==1:
    print(-1)
else:
    print(ans)


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

const int size = 22;

const int MOD = 1e9 + 7;

int n;

int a[size][size];
int dp[size][1 << 21];

int Solve(int ndx, int visited)
{
	if (ndx >= n)
	{
		return 1;
	}
	if (dp[ndx][visited] != -1)
	{
		return dp[ndx][visited];
	}
	int ans = 0;
	for (int i = 0; i < 21; ++i)
	{
		if (!(visited & (1 << i)) && a[ndx][i] == 1)
		{
			ans = (ans + Solve(ndx + 1, visited | (1 << i))) % MOD;
		}
	}
	return dp[ndx][visited] = ans;
}

int main()
{
	std::cin >> n;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < 1 << 21; ++j)
		{
			dp[i][j] = -1;
		}
	}
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			std::cin >> a[i][j];
		}
	}
	std::cout << Solve(0, 0) << '\n';
	return 0;
}

Measured memory_bytes: 175668
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

ll calc(long double A, long double B, long double C) {
  return (ceil(B / 2) - (ll)(B / 2)) * A * C;
}

void solve() {
  VAR(long double, A, B, C);
  print(min({calc(A, B, C), calc(B, C, A), calc(C, A, B)}));
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    string S; cin >> S;
    if(S=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep (i ,n) for(int i=0;i<(n);i++) 
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;} 
const int mod=1e9+7;
int main(){
		ll n,m;
		cin>>n>>m;
		int sum=0;
		for(int i=1;i<=m;i++){
			int a;
			cin>>a;
			sum+=a;
		}
		if(n==sum){
			cout<<0<<endl;
		}
		if(sum>n){
			cout<<-1<<endl;
		}
		if(n>sum){
			cout<<n-sum<<endl;
		}
		return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;
using Tree = vector<pair<int, int>>;

bool IsPrime(int num)
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a;
    for (int i = 0; i < 55555; i++)
    {
        if (i % 5 == 1 && IsPrime(i))
            a.push_back(i);
    }
    for (int i = 0; i < n; i++)
    {
        cout << a[i];
        if (i == n - 1)
            cout << "\n";
        else
            cout << " ";
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int n;
	cin>>n;
	vector<int> x(2*n);
	rep(i, 2*n) cin>>x[i];
	sort(all(x));
	ll res = 0;
	rep(i, n) res += x[2*i];
	cout<<res<<endl;
	return 0;
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

int main(){
  string s;
  cin >> s;
  int size = int(s.size());
  string keyence = "keyence";
  // int pos = 0;
  // bool used1 = false, used2 = false;
  // for (int i = 0; i < size; i++) {
  //   if(s[i] == keyence[pos]){
  //     if(used1) used2 = true;
  //     pos++;
  //   } else if(s[i] != keyence[pos]){
  //     if(!used1) used1 = true;
  //     if(used1 && used2){
  //       cout << "NO" << endl;
  //       return 0;
  //     }
  //   }
  //   if(pos == 7 && i == size-1) {
  //     cout << "YES" << endl;
  //     return 0;
  //   }
  // }
  //
  // cout << "NO" << endl;

  // cout << keyence.substr(0, 0) << endl;

  for (int i = 0; i < size-1; i++)
  {
    for (int j = 1; j < size; j++) {
      string tmp = s.substr(0, i) + s.substr(j);
      if(tmp == keyence){
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << 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 N=scan.nextInt();
		long total=0;
		for(int i=1;i<=N;i++){
			if(i%3!=0&&i%5!=0){
				total+=i;
			}
		}
		System.out.println(total);

	}

}

Measured memory_bytes: 35752
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll x,a,b,d;
    cin>>x>>a>>b;
    if(a>=b)
        cout<<"delicious"<<endl;
    else 
    {
        d=b-a;
        if(d>x)
            cout<<"dangerous"<<endl;
        else
            cout<<"safe"<<endl;
    }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

std::vector<int> eratosthenes_sieve(int n) {
	std::vector<int> ps(n + 1);
	std::iota(ps.begin() + 2, ps.end(), 2);
	for (int i = 2; i * i <= n; ++i)
		if (ps[i])
			for (int j = i * i; j <= n; j += i) ps[j] = 0;
	return ps;
}

std::vector<int> make_primes(int n) {
	std::vector<int> ps = eratosthenes_sieve(n);
	ps.erase(std::remove(ps.begin(), ps.end(), 0), ps.end());
	return ps;
}
int main() {
	int N;
	cin >> N;
	vector<int> vec = make_primes(55555);
	
	int count = 0;
	REP(i, vec.size()) {
		if (vec[i] % 5 == 1) {
			cout << vec[i] << " ";
			count++;
			if (count == N) break;
		}
	}
	system("pause");
	return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ll N; cin >> N;
  vector<ll> P(N); REP(i, N) cin >> P[i];

  int cnt = 1;
  ll min_num = pow(10, 8);
  REP(i, N - 1) {
    if(P[i] < min_num) min_num = P[i];
    if(P[i + 1] <= min_num) cnt++;
  }

  cout << cnt << endl;
}


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

#define LL long long

LL n,k,a[200100],ki,ka,mid,ans=0;
     
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    ki=1;
    ka=1e9;
	while(ki<=ka){
		mid=(ki+ka)/2;
		LL x=0;
		for(int i=1;i<=n;i++){
			x+=(a[i]-1)/mid;
		}
		if(x<=k){
			ka=mid-1;
			ans=mid;
		}else{
			ki=mid+1;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 5116
A, B, C, D, E, F = gets.split.map(&:to_i)

# 限界濃度ピッタリのパターンが出た場合に立てるフラグ
flag = false

# 暫定最大値を格納する変数
max_water = 0
max_sugar = 0

(0..(F/100/A)).each do |a|
  # 操作1を行った回数分、limitを減らす
  a_limit = F - 100*A*a
  (0..(F/100/B)).each do |b|
    # 操作2を行った回数分、limitを減らす
    b_limit = a_limit - 100*B*b
    (0..(F/C)).each do |c|
      # puts "#{a} #{b} #{c}" # for debug
      # 操作3を行った回数分、limitを減らす
      c_limit = b_limit - C*c
      # この時点で、ビーカーの水の量 current_water は以下の通り。
      current_water = 100*A*a + 100*B*b
      # この時点で、ビーカーの砂糖の量 current_sugar は以下の通り。
      current_sugar = C*c

      if current_sugar * 100 > E * current_water
        # この時点で砂糖が溶け残っていては話にならないので諦めてnext
        next
      end

      # 限界濃度に達するまで追加できる砂糖の量（少数注意！）を算出する
      addable_sugar = E * current_water / 100.to_f - current_sugar
      # 限界濃度ギリギリまで操作4を行うことができる回数を算出する
      d_temp1 = (addable_sugar / D).to_i
      # 重量の面から見てギリギリまで操作4を行うことができる回数を算出する
      d_temp2 = c_limit / D
      # 操作4は上記2つの回数のうち、少ない方である（※どちらも超えてはならないため）
      d = [d_temp1, d_temp2].min
      # ビーカーの砂糖の量 current_sugar を更新
      current_sugar += D*d

      if current_sugar.nonzero? && current_water.nonzero? && current_sugar * 100 == E * current_water
        # ちょうど限界濃度である場合にはこれが最大値となる
        max_water = current_water
        max_sugar = current_sugar
        # これ以上処理を続けても無意味なのでフラグを立ててブレークする
        flag = true
        break
      end

      if (max_sugar == 0 && max_water == 0) || \
        current_sugar / (current_sugar + current_water).to_f > max_sugar / (max_sugar + max_water).to_f
        # 暫定最大値がまだ無い、または暫定最大値の濃度よりも濃い濃度になった場合には暫定最大値を更新する
        max_water = current_water
        max_sugar = current_sugar
        # puts "#{max_water + max_sugar} #{max_sugar}" # for debug
      end
    end
    break if flag
  end
  break if flag
end

# puts "----"
# puts flag
puts "#{max_water + max_sugar} #{max_sugar}"


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
//DEFINE and TYPEDEF--------------------------------------------------------------
 
#define FORG(i,a,n) for(lld i=a;i<n;i++) //for - general
#define FORZ(i,n) for(lld i=0;i<n;i++) //for - zero
#define FORGI(i,a,n,inc) for(lld i=a;i<n;i+=inc) //for - general incremental
#define FORZI(i,n,inc) for(lld i=0;i<n;i+=inc) //for - zero incremental
#define DEBUG(x) cout<<(#x)<<" is "<<(x)<<endl //to debug values of variables
#define ZINDA cout<<"\nIdhar-ich hai apun!!\n"; //to debug if code reached that point
#define SPEEDUP ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
 
#define SORTall(m) sort(m.begin(),m.end());
 
#define st first
#define nd second
#define pb push_back
#define mod 1000000007
 
typedef long long int lld;
typedef unsigned long long int ulld;
 
lld power(lld b, lld e)
{
	if(e==0)
		return 1;
	if(e%2==1)
		return b*power(b*b,(e-1)/2);
	else
		return power(b*b,e/2);
}
 
int nDig(lld n)
{
	return floor(log10(n) + 1);
}

//--------------------------------------------------------------------------------
int main()
{
    SPEEDUP;
 	lld n,k;
 	cin>>n>>k;

 	lld hi[n];
 	FORZ(i,n) cin>>hi[i];

 	lld csts[n]={0};
 	csts[0]=0;
 	csts[1]=abs(hi[1]-hi[0]);

 	FORG(i,2,n)
 	{
 		lld c,min=INT_MAX;
 		FORG(j, max(0LL,i-k) ,i)
 		{
 			if(min>csts[j] + abs(hi[i]-hi[j]))
 			{
 				min=csts[j] + abs(hi[i]-hi[j]);
 				c=j;
 			}
 		}
 		
 		csts[i]=csts[c] + abs(hi[i]-hi[c]);
 	}

 	cout<<csts[n-1];
 	return 0;
}

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

int main() {
  int K;
  cin >> K;
  
  if (K % 2 == 0) cout << -1 << endl;
  else {
    int64_t sevens = 0;
    for (int i = 1; i <= 1e7; i++) {
      sevens = (10 * sevens + 7) % K;  // ここでmod Kしてしまえばオーバーフローを防げる
      if (sevens == 0) {
        cout << i << endl;
        // breakだとforスコープのみ抜けるが, return 0とすればelseスコープを抜ける
        // というかreturn以降の処理は実行されない
        return 0;
      }
    }
    cout << -1 << endl;  // 上限値までループしても見つからなかった場合
  }
}

Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<cmath>
#include<climits>

#define ll long long
#define deb(x) cout<<#x <<x<<" "
using namespace std;

ll knapsack(long w,long i,vector<long> &weight,vector<long> &values,vector<vector<ll>> &dp)
{
    if(i<0 || w<=0)
        return 0;
    
    if(dp[i][w] == -1)
    {
        if(weight[i] > w)
            dp[i][w] = knapsack(w,i-1,weight,values,dp);
    
        else 
        {
            dp[i][w] = max(values[i] + knapsack(w-weight[i],i-1,weight,values,dp),knapsack(w,i-1,weight,values,dp));
        } 
    }
    return dp[i][w];
}

int main()
{
    long n{},w{};
    cin>>n>>w;
    vector<long> wi(n),vi(n);
    for(int i=0;i<n;i++)
    {
        cin>>wi[i]>>vi[i];
    }
    
    vector<vector<ll>> dp(n,vector<ll>(w+1,-1));
    ll ans = knapsack(w,n-1,wi,vi,dp);
    cout<<ans;

    return 0;
}

Measured memory_bytes: 79488
import math
N = int(input())
a = math.ceil(N/(-2))
r = 0
s = ""
if N == 0:
    print(0)
else:
    while a != 1:
        r = N-a*(-2)
        s = str(r) + s
        N = a
        a = math.ceil(N/(-2))
    if a == 1:
        r = N-a*(-2)
        s = str(r) + s
        s = "1" + s   
    print(s)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
int r,c;
cin>>r>>c;
 int num[101][101]={};
 for(int i=0;i<r;i++)
  for(int j=0;j<c;j++) cin>>num[i][j];

 for(int i=0;i<r;i++)
  for(int j=0;j<c;j++) num[r][c] += num[i][j];

 for(int i=0;i<r;i++){
  int sum =0;
  for(int j=0;j<c;j++)sum += num[i][j];
  num[i][c] = sum;
}
for(int j=0;j<c;j++){
 int sum =0;
for(int i=0;i<r;i++) sum += num[i][j];
 num[r][j] = sum;
}
for(int i=0;i<=r;i++){
 for(int j=0;j<=c;j++){
  if(j) cout<<" ";
  cout<<num[i][j];
  }
  cout<<endl;
}
return 0;
}


Measured memory_bytes: 3120
from itertools import combinations
def dist(a, b):
	return sum((x - y) ** 2 for x, y in zip(a, b))
n, m = map(int, raw_input().split())
colors = [tuple(map(float, raw_input().split())) for i in xrange(n)]
dists = [[ dist(colors[i], colors[j]) for j in xrange(n)] for i in xrange(n)]
print max([sum(dists[a][b] for a, b in combinations(selected, 2)) for selected in combinations(xrange(n), m)])

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

using ll = long long;

int main() {
  ll n, t;
  cin >> n >> t;
  
  vector<ll> x(n);
  for(int i = 0; i < n; i++) cin >> x.at(i);
  
  ll ans = t;
  for(int i = 0; i < n - 1; i++) ans += min(t, x.at(i + 1) - x.at(i));
  
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = (int)1e3 +10;
 
int main()
{
    ll a, b;
    cin>>a>>b;
    if((a+b)%2 == 0)
        cout<<(a+b)/2;
    else
        cout<<"IMPOSSIBLE"<<endl;
 
    return 0;
}


Measured memory_bytes: 256