akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	double a, b, x;
	cin >> a >> b >> x;
	b /= a, x /= a*a*a;
	
	double theta = x >= b/2 ? atan(2*(b-x)) : M_PI/2 - atan(2*x/b/b);
	theta *= 180/M_PI;
	cout << fixed << setprecision(20) << theta << endl;
}



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

int main()
{
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    string s;
    s.push_back(s1[0]);
    s.push_back(s2[1]);
    s.push_back(s3[2]);
    cout << s << endl;
}

Measured memory_bytes: 256
use std::io::{BufRead, Write};
use std::io;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    let s = buf.trim_right().to_owned();
    buf.clear();
    input.read_line(&mut buf).unwrap();
    let t = buf.trim_right().to_owned();
    let pos = s.as_bytes().windows(t.len()).rposition(|x| x.into_iter()
        .zip(t.as_bytes())
        .all(|(&a, &b)| a == b'?' || a == b));
    if let Some(pos) = pos {
        let replaced: String = s[..pos].chars().chain(t.chars()).chain(s[pos + t.len()..].chars()).collect();
        let result = replaced.replace("?", "a");
        writeln!(output, "{}", result).unwrap();
    } else {
        writeln!(output, "UNRESTORABLE").unwrap();
    }
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "?tc????
coder\n",
            "atcoder\n",
        );
    }

    #[test]
    fn case2() {
        test(
            "??p??d??
abc\n",
            "UNRESTORABLE\n",
        );
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;
typedef long long ll;

int main()
{
    ll n;
    string s;
    cin >> n >> s;

    int e = 0;
    rep(i, 1, n)
    {
        if (s[i] == 'E')
        {
            e++;
        }
    }
    int ans = e;
    //端から移動する人数を数える.
    for (ll i = 1; i < n; i++)
    {
        if (s[i - 1] == 'W')
        {
            e++;
        }
        if (s[i] == 'E')
        {
            e--;
        }

        ans = min(ans, e);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 900
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

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

    var(i64, N, K);

    unordered_set<i64> used;
    i64 ans = N;
    used.insert(N);

    i64 x = N;
    while (true) {
        x = abs(x - max<i64>(1, x / K) * K);
        if (used.count(x)) break;
        chmin(ans, x);
        used.insert(x);
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main () {
    long X;
    std::cin >> X;

    long A, B;
    long Y = 0;
    for (A=1; A<=X; A++) {
        for (B=-A; B<A; B++) {
            Y = A*A*A*A*A - B*B*B*B*B;
//            std::cout << "testing " << A << " " << B << " " << Y << std::endl;
            if (Y==X) {
                break;
            }
        }
        if (X == Y) {
            std::cout << A << " " << B << std::endl;
            return 0;
        }
    }
    std::cout << "error! " << X << " " << Y << " " << A << " " << B << std::endl;
    return 1;
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

const int N = 105;
char s[N][N];

bool ok(int x, int y, char c) {
    for (int i = -1; i <= 1; i++)
        for (int j = -1; j <= 1; ++j) {
            if (i == 0 and j == 0) continue;
            int a = x + i;
            int b = y + j;
            if (a < 0 or b < 0 or a >= 100 or b >= 100) continue;
            if (s[a][b] == c) return false;
        }
    return true;
}

int main() {
    int a, b;
    cin >> a >> b;
    a--, b--;

    for (int i = 0; i < 100; ++i) {
        for (int j = 0; j < 100; ++j) {
            if (i < 50) s[i][j] = '#';
            else s[i][j] = '.';
        }
        s[i][100] = '\0';
    }

    for (int i = 0; i < 50 and a > 0; ++i) {
        for (int j = 0; j < 100 and a > 0; ++j) {
            if (ok(i, j, '.')) {
                s[i][j] = '.';
                a--;
            }
        }
    }

    for (int i = 50; i < 100 and b > 0; ++i) {
        for (int j = 0; j < 100 and b > 0; ++j) {
            if (ok(i, j, '#')) {
                s[i][j] = '#';
                b--;
            }
        }
    }

    printf("100 100\n");
    for (int i = 0; i < 100; ++i) printf("%s\n", s[i]);
}

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

using namespace std;

typedef long long ll;

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

	string s;
	cin >> s;

	int n = s.size();

	int mcnt = 1;
	int t = 1;
	rep(i, n - 1){
		if(s[i+1] == s[i]){
			t++;
			mcnt = max(mcnt, t);
		}else{
			t = 1;
		}
	}

	if(mcnt >= 3){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


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

int main(){
    int n = 10000;
    int N = 0;
    int H[n];
    int W[n];
    int h, w;

    for(int i = 0; i < n; i++){
        cin >> H[i] >> W[i];
        N++;
        if(H[i] == 0 and W[i] == 0){
            break;
        }
    }

    for(int i = 0; i < N - 1; i++){
            for(int y = 0; y < H[i]; y++){
                for(int x = 0; x < W[i]; x++){
                    printf("#");
                }
                printf("\n");
            }
            printf("\n");
        
       
    }
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 214748360

int main(){
  int n;
  while(cin>>n, n){
    vector<pair<int,int>> vec[20];
    vector<vector<int>> d(n, vector<int>(n, INF));
    bool isleaf[20];
    rep(i,n-1){
      int a,b,c;
      cin>>a>>b>>c;
      a--;b--;
      vec[a].pb(mp(b,c));
      vec[b].pb(mp(a,c));
      d[a][b] = d[b][a] = c;
    }
    rep(i,n) isleaf[i] = vec[i].size()==1;
    isleaf[0]=false;

    int total = 0;
    rep(i,n) if(!isleaf[i]) for(auto p : vec[i]){
      if(!isleaf[p.fi]) total += p.se;
    }

    rep(i,n) d[i][i]=0;
    rep(k,n)rep(i,n)rep(j,n) d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
    int mx = 0;
    rep(i,n) if(!isleaf[i]) mx = max(mx, d[0][i]);

    cout << total - mx << endl;
  }
  return 0;
}

Measured memory_bytes: 3104
# -*- coding: utf-8 -*-
import sys
from fractions import gcd
from string import ascii_uppercase as ABC
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

N = int(input())
min_ = 10**9
P = inpl()
ans = 0
for i in range(N):
    if min_ > P[i]:
        ans += 1
    min_ = min(min_, P[i])
print(ans)

Measured memory_bytes: 101376
#include<stdio.h>
 
 main(){
   
  int i;
  int j;
  int n;
  int m;
  int c;
  int key;
  int NUM[100001];
  
   
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&NUM[i]);
     }
   scanf("%d",&m);
   
  for(i=0;i<m;i++){
    scanf("%d",&key);
 int left=0;
int right=n;
int mid;
    
   while(left<right){
      mid=(left+right)/2;
      if(NUM[mid]==key){
	c = c + 1;
    break;
      }
      else if(key<NUM[mid])right=mid;
   else left = mid + 1;   
      
    }
  }
  printf("%d\n",c);  
  return 0;
}

Measured memory_bytes: 992
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    map<int,int> m;
    vector<int> v;
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        m[a]++;
        m[a+1]++;
        m[a-1]++;
    }
    map<int,int>::iterator it;
    for(it=m.begin();it!=m.end();it++){
        v.push_back(it->second);
    }
    sort(v.begin(),v.end());
    cout << v.back() << endl;
}

Measured memory_bytes: 5372
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int M=3e5+5;
int a[M];
int b[M];
map<pair<int,int>,bool>mp;
int main()
{
    int n,m,q;
    scanf("%d%d%d",&n,&m,&q);
    while(q--)
    {
       int x,y;
       scanf("%d%d",&x,&y);
       a[x]++;
       b[y]++;
       mp[make_pair(x,y)]=1;
    }
    int ma=0,mb=0;
    for(int i=1;i<=n;i++)
    {
        ma=max(ma,a[i]);
    }
    for(int i=1;i<=m;i++)
    {
        //printf("%d ",b[i]);
        mb=max(mb,b[i]);
    }
    vector<int>aa,bb;
    for(int i=1;i<=n;i++)
    {
       if(a[i]==ma) aa.push_back(i);
    }
    for(int i=1;i<=m;i++)
    {
        if(b[i]==mb) bb.push_back(i);
    }
    //int cnt=0;
    for(auto i:aa)
    {
        for(auto j:bb)
        {
              if(mp.count(make_pair(i,j))==0)
            {
                printf("%d\n",ma+mb);
                return 0;
            }

        }
    }

    //printf("+");
      //printf("%d %d\n",ma,mb);
    printf("%d\n",ma+mb-1);
    return 0;
}


Measured memory_bytes: 28496
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

void fastIO() {
	std::ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
}

#define FOR(i,f,t) for(int i=f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=f; i>(int)t; i--)
#define FORE(i,c) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

template<typename T, typename U> inline void mnze(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void mxze(T &x, U y) { if(x < y) x = y; }

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(_i, (x)) cerr <<*_i <<", "; cerr <<"\n"; }}
#define debuga(x, sz) {{cerr <<#x <<" = "; FOR(_i, 0, sz) cerr << x[_i] <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////

const int MAXN = 2e5+5;

int N, M;
vi G[MAXN];
bool d1[MAXN];

int main(){
	scan(N,M);
	FOR(i,0,M){
		int a,b; scan(a,b); a--; b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	for(auto u : G[0]){
		d1[u] = true;
	}
	int ans = 0;
	FOR(v,0,N) if(d1[v]) for(auto u : G[v]){
		if(u==N-1) ans=1;
	}
	printf(ans?"POSSIBLE\n":"IMPOSSIBLE\n");
}

Measured memory_bytes: 12272
#include <stdio.h>

#define N 100

int main (void){

    int i,n,A[N];
    float ans = 0;

    if(scanf("%d",&n)==1);

    for (i = 0; i < n;i++){
        if(scanf("%d",&A[i])==1);
        ans += 1.0 / A[i];
    }

    printf("%f",1 / ans);


    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
  
#define MAX 500000
  
int a[MAX],n,ntc=0,pet[MAX];
  
void mg(int x[],int ll,int ri){
  int i,j,k;
  if(ll>=ri) return;
  
  mg(x,ll,(ll+ri)/2);
  mg(x,((ll+ri)/2+1),ri);
  
  for(i=ll;i<=(ll+ri)/2;i++){
    pet[i]=x[i];
  }
  for(i=((ll+ri)/2+1),j=ri;i<=ri;i++,j--){
    pet[i]=x[j];
  }
  i=ll;
  j=ri;
  for(k=ll;k<=ri;k++){
    if(pet[i]<=pet[j]) x[k]=pet[i++];
    else x[k]=pet[j--];
    ntc++;
  }
}
int main(){
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  mg(a,0,n-1);
  for(i=0;i<n-1;i++) printf("%d ",a[i]);
  printf("%d\n%d\n",a[n-1],ntc);
  return 0;
}



Measured memory_bytes: 5596
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>

int main (void) {
    int i;
    int n;
    if ( scanf("%d", &n) != 1 )
        return EXIT_FAILURE;
    long long a[n];
    long long ans=LLONG_MAX;
    for ( i=0; i<n; i++ ) {
        if ( scanf("%lld", &a[i]) != 1 )
            return EXIT_FAILURE;
        if ( ans > a[i] )
            ans = a[i];
    }

    long long mod, min_mod;
    while (1) {
        for ( i=0; i<n; i++ ) {
            mod = a[i] % ans;
            if ( mod != 0 && mod < min_mod )
                min_mod = mod;
        }
        if ( ans == min_mod )
            goto END;
        ans = min_mod;
    }
END:
    printf("%lld\n", ans);
    return EXIT_SUCCESS;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define INF 1e15
#define MOD 1e9+7
char c;
signed main() {
	cin >> c;
	if (c == 'A')puts("T");
	if (c == 'T')puts("A");
	if (c == 'C')puts("G");
	if (c == 'G')puts("C");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int f(int a, int r) {
	return (int)((double)a*(100.0+r)/100.0);
}

signed main() {
	int x, y, s;
	while (1) {
		cin >> x >> y >> s;
		if (x + y + s == 0) break;
		int MAX = 0;
		rep(i, 1, 1000) {
			rep(j, 1, 1000) {
				int tmp = f(i,x) + f(j,x);
				if(tmp==s){
					MAX = max(MAX, f(i, y) + f(j, y));
				}
				else if (tmp > s) break;
			}
		}
		cout << MAX << endl;
	}
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}

//vc alp(26) ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  ll N;cin>>N; vs S(N);rep(i,N)cin>>S[i]; 
  sort(all(S));
  ll cm=0,ca=0,cr=0,cc=0,ch=0;
  rep(i,N){
    if(S[i][0]=='M')cm++;
    if(S[i][0]=='A')ca++;
    if(S[i][0]=='R')cr++;
    if(S[i][0]=='C')cc++;
    if(S[i][0]=='H')ch++;
  }
  ll tot= ca*cc*ch +cm*cr*cc + cm*cr*ch + cm*cc*ch +cm*ca*cr + cm*ca*cc + cm*ca*ch + ca*cr*cc + ca*cr*ch + cr*cc*ch;
  cout<<tot<<endl;
}







Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
void solve(){
	int n,k;
	cin >> n >> k;
	long long a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	long long  b[n];
	b[0] = 0;
	for(int i = 1; i < n; i++){
		long long minn = INT_MAX;
		int index;
		for(int j = max(i - k, 0); j < i; j++){
			if(abs(a[j] - a[i]) + b[j] < minn)
			{
				minn =abs(a[j] - a[i]) + b[j];
			}
		}
		b[i] =  minn;
	}	
	cout<<b[n - 1];
}
int main(){
	
	solve();
	
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;

int main() {
	int N;
	cin >> N;
	cout << "ABC" << N << endl;
	
	return 0;
}

Measured memory_bytes: 256
main = do
  let f n = let x = read n::Int in
              if x > 36 then show 0
                else
                  let i = if x >= 19 then 36-x else x in
                  show $ (i+3)*(i+2)*(i+1) `div` 6 - max (2*(i-9)*(i-8)*(i-7) `div` 3) 0

  putStr . unlines . map f . lines =<< getContents

Measured memory_bytes: 3912
#include <vector>
#include <iostream>
#include <string>

using namespace std;

int N,Q;
string S;

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

    vector< vector<int> > char_to_BIT(97+26+1);
    for(char c = 'a'; c <= 'z'; c++) {
        vector<int> BIT(N+1);
        char_to_BIT[c] = BIT;
    }

    auto update = [&](vector<int>& BIT, int index, int val) {
        index++;
        while(index <= N) {
            BIT[index] += val;
            index += index & (-index);
        }
    };

    auto cum_sum = [&](vector<int>& BIT, int index) {
        index++;
        int sum = 0;
        while(index > 0) {
            sum += BIT[index];
            index -= index&(-index);
        }
        return sum;
    };

    auto get_cum_sum = [&](vector<int>& BIT, int l, int r) {
        if(l == 0) { return cum_sum(BIT,r);}
        return cum_sum(BIT,r) - cum_sum(BIT,l-1);
    };

    int type;
    int indexq;
    char charq;

    int left_q;
    int right_q;

    for(int i = 0; i < N; i++) {
        update(char_to_BIT[S[i]],i,1);
    }

    for(int q = 0; q < Q; q++) {
        cin >> type;
//        cout << "S is now " << S << endl;
        if(type == 1) {
            cin >> indexq >> charq;
            indexq--;

            update(char_to_BIT[S[indexq]], indexq, -1);
            update(char_to_BIT[charq], indexq, 1);
            S[indexq] = charq;

        } else {
            cin >> left_q >> right_q;
            left_q--;right_q--;
            int count_unique = 0;
            for(char c = 'a'; c <= 'z'; c++) {
                auto count = get_cum_sum(char_to_BIT[c], left_q,right_q);
         //      cout << " count of " << c << " in range " << "[" << left_q << "," << right_q << "] is " << count << endl;
                if(count != 0) {
                    count_unique++;
                }
            }
            cout << count_unique << endl;
        }
    }

}


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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define FOR(i, a, b) for (ll i = (a), i < (N): i++)
#define all(A) (A).begin(), (A).end()

int main(){
    int A, B;
    cin >> A >> B;
    rep(i, 200000) {
        if (i * 8 / 100 == A and i * 10 / 100 == B) {
            cout << i << endl;
            return 0;
        }

    }
    cout << -1 << endl;


    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  GCJ
//
//  Created by shitian.ni on 2018/06/19.
//  Copyright © 2018 shitian.ni. All rights reserved.
//

#include <iostream>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

typedef long long ll;

int main() {
    int N;
    cin>>N;
    vector<int>vec(N);
    vector<int>sorted(N);
    for(int i=0;i<N;i++){
        cin>>vec[i];
        sorted[i] = vec[i];
    }
    sort(sorted.begin(),sorted.end());
    int left = sorted[N/2 - 1], right = sorted[N/2];
    for(int i=0;i<N;i++){
        if(vec[i]>=right){
            cout<<left<<endl;
        } else {
            cout<<right<<endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3712
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <stack>
#include <climits>

using namespace std;

#define rep(i,n,m) for(int i=n; i<=m; i++)
#define per(i,n,m) for(int i=n; i>=m; i--)
#define printi(x) printf("%d ", x)
#define printiln(x) printf("%d\n", x)
#define printiarray(a,n) for(int i=0; i<n-1; i++){printf("%d ", a[i]);} printf("%d\n", a[n-1])
#define scani(x) scanf("%d", &x)
#define scaniarray(a,n) for(int i=0; i<n; i++){scanf("%d", &a[i]);}
#define scans(str) scanf("%s",str)
#define scanc(ch) scanf("%c", &ch)


const int NMax = 20;
int A[NMax];
int EndK;

int dfs(int k, int sum, int goal) {
    // printi(k);
    // printi(sum);
    // printiln(goal);
    if(sum > goal) {
        // printf("read 1st if\n");
        return 0;
    }
    if(sum == goal) {
        // printf("read 2nd if\n");
        return 1;
    }

    if(k+1 <= EndK && dfs(k+1, sum+A[k], goal) + dfs(k+1, sum, goal) >= 1) {
        // printf("read 3rd if\n");
        return 1;
    }
    // printf("unread if\n");
    return 0;
}

int main() {
    int n;
    scani(n);
    scaniarray(A,n);
    int q;
    scani(q);
    int m[q];
    scaniarray(m,q);

    EndK = n;


    rep(i,0,q-1) {
        if(dfs(0,0,m[i]) == 1) printf("yes\n");
        else printf("no\n");

    }



    return 0;
}



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

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

vector<int> A(N);
for (int i = 0; i < N; i++) {
  cin >> A.at(i);
}

int saidaikyori = max(A.at(0), A.at(1) - A.at(0) );
int hashi = A.at(0) + K - A.at(N - 1);
  
for (int i = 2; i < N; i++) {
 saidaikyori = max( A.at(i) - A.at(i - 1), saidaikyori );
}
  
 int answer = max(hashi, saidaikyori);
 int x = K - answer;

 cout << x << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include<string>
using namespace std;
#define ll long long int
#define maxn 100005
#define mod 1e9+7

void _init() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}



int main() {
	_init();

	int h, w;
	cin >> h >> w;
	ll dp[h][w];
	char arr[h][w];
	for (int i = 0; i < h; i++) {
		cin >> arr[i];
	}

	dp[0][0] = 1;
	for (int i = 1; i < w; i++) {
		if (arr[0][i] == '#')dp[0][i] = 0;
		else dp[0][i] = dp[0][i - 1];
	}

	for (int i = 1; i < h; ++i)
	{
		if (arr[i][0] == '#') dp[i][0] = 0;
		else dp[i][0] = dp[i - 1][0];
	}

	for (int i = 1; i < h; ++i)
	{
		for (int j = 1; j < w; ++j)
		{
			if (arr[i][j] == '#')
			{
				dp[i][j] = 0;
			} else {
				dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
				dp[i][j] %= (int)mod;
			}
		}
	}

	cout << dp[h - 1][w - 1] << endl;

	return 0;
}









Measured memory_bytes: 12372
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#include<cstdio>
#define curr(P, i) P[(i) % P.size()]
#define next(P, i) P[(i+1) % P.size()]
#define prev(P, i) P[(i+P.size()-1) % P.size()]

using namespace std;

long double EPS = 1e-8;
const double PI = acos(-1);

long double add(long double a,long double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  long double x, y;
  point(){}
  point(long double x,long double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  point operator * (double d){
    return point(x*d,y*d);
  }
};

typedef point Vector;

long double dot(point a, point b) {
  return (a.x * b.x + a.y * b.y);
}

long double cross(point a, point b) {
  return (a.x * b.y - a.y * b.x);
}

long double norm(point a){
  return sqrt(a.x*a.x+a.y*a.y);
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

int ccw( point p0, point p1, point p2 ){
  Vector a=p1-p0;
  Vector b=p2-p0;
  if (cross(a,b)>EPS) return COUNTER_CLOCKWISE;
  if (cross(a,b)<-EPS) return CLOCKWISE;
  if (dot(a, b)<-EPS) return ONLINE_BACK;
  if (norm(a)<norm(b)) return ONLINE_FRONT;
  return ON_SEGMENT;
}

bool is_convex(vector<point> pol){
  for(int i=0;i<pol.size();i++){
    if(ccw(prev(pol,i),curr(pol,i),next(pol,i))==-1)return false;
  }
  return true;
}
int main(void){
  int n;
  cin >> n;
  vector<point>pol(n);

  for(int i=0;i<n;i++)cin >> pol[i].x >> pol[i].y;

  cout << is_convex(pol) << endl;

  return 0;
}

Measured memory_bytes: 1244
require 'pp'
     
h, w = gets.chomp!.split.map(&:to_i)
s = []
 
h.times do |i|
    s1 = gets.chomp!.chars
    s << s1
end
 
max_t = 0
 
h.times do |i|
    w.times do |j|
        next if s[i][j] == '#'

        path = [[i, j, 0]]
        memo = Array.new(h)
        h.times do |t|
            memo[t] = Array.new(w, -1)
        end
        memo[i][j] = 0
 
        while path.empty?.!
            y, x, d = path.shift
 
            if y - 1 >= 0 && memo[y-1][x] == -1 && s[y-1][x] == '.'
                memo[y-1][x] = d+1
                path.push([y-1, x  , d+1])
            end
            if y + 1 <  h && memo[y+1][x] == -1 && s[y+1][x] == '.'
                memo[y+1][x] = d+1
                path.push([y+1, x  , d+1])
            end
            if x - 1 >= 0 && memo[y][x-1] == -1 && s[y][x-1] == '.'
                memo[y][x-1] = d+1
                path.push([y  , x-1, d+1])
            end
            if x + 1 <  w && memo[y][x+1] == -1 && s[y][x+1] == '.'
                memo[y][x+1] = d+1
                path.push([y  , x+1, d+1])
            end
        end
 
        sub_max = memo.flatten.max
        if sub_max >= max_t
            max_t = sub_max
        end
    end
end
 
puts max_t


Measured memory_bytes: 2556
a,b,c,x = 4.times.map { gets.to_i }

cnt = 0

(0..a).each do |i|
  (0..b).each do |j|
    (0..c).each do |k|
      cnt += 1 if i * 500 + j * 100 + k * 50 == x
    end
  end
end

puts cnt

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(ll i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const int INF=2*1e9;
int main()
{
    double n;
    cin>>n;
    cout<<fixed<<setprecision(10)<<(n/3)*(n/3)*(n/3);
}


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

int r, c;
bool a[10][10000];
int max = 0;

void count() {
  int x, y;
  int sum = 0;
  for (int i=0; i<c; i++) {
    x = y = 0;
    for (int j=0; j<r; j++) {
      if (a[j][i]) x++;
      else y++;
    }
    sum += (x > y) ? x : y;
  }
  if (sum > max) max = sum;
}


void dfs(int n) {
  if (n == r) {
    count();
    return;
  }

  dfs(n+1);
  for (int i=0; i<c; i++) {
    a[n][i] = !a[n][i];
  }
  dfs(n+1);
}

int main() {
  int tmp;
  while (1) {
    scanf("%d %d", &r, &c);
    if (!r && !c) break;
    for (int i=0; i<r; i++) {
      for (int j=0; j<c; j++) {
        scanf("%d", &tmp);
        a[i][j] = tmp;
      }
    }
    dfs(0);
    printf("%d\n", max);
  }
  return 0;
}

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

int main() {
  int n; cin >> n;
  int k; cin >> k;
  vector<int> h(n);
  rep (i, n) cin >> h.at(i);
  sort(h.begin(), h.end());
  int min = h.at(k-1+0) - h.at(0);
  for (int i = 1; k-1+i < n; i++) {
    if (min > h.at(k-1+i)-h.at(i)) {
      min = h.at(k-1+i)-h.at(i);
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 640
a = [[int(i) for i in input().split()] for j in range(3)]
c = [0,0,0,0]
for i in range(3):
    for j in range(2):
        c[a[i][j]-1] += 1
r = "YES"
for i in range(4):
    if c[i]>=3:
        r="NO"
        break
print(r)


Measured memory_bytes: 3060
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int count = 0;
            for(int i = 0; i < 3; i++)
            {
                if (s[i] == '1')
                {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 11092
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll d, n;
  scanf("%lld%lld", &d, &n);
  ll ans = pow(100, d) * n;
  if (n == 100)
    ans += pow(100, d);
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a,b,c;
    int d;
    int x,y;

    while(scanf("%d%d",&a,&b)!=EOF){
    x=a;
    y=b;
    if(a>b)
    {
        for(;;)
        {
            c=a/b;
            d=a%b;
            if(d==0) break;
            a=b;
            b=d;
        }
        d=x/b*y;
        printf("%d %d\n",b,d);
    }
    else
    {
                for(;;)
        {
            c=b/a;
            d=b%a;
            if(d==0) break;
            b=a;
            a=d;
        }
        d=x/a*y;
        printf("%d %d\n",a,d);
    }
    }
    return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while (s.hasNextInt()) {
			int a = s.nextInt();
			int b = s.nextInt();
			if (a == 0 && b == 0) break;
			if (a > b) {
				int t = a;
				a = b;
				b = t;
			}
			System.out.printf("%d %d\n", a, b);
		}
	}
}

Measured memory_bytes: 32952
#include <stdio.h>

int p[1005], p2[1005];
char c[1005];

int main(void)
{
	int n, m, cost;
	int i, i2, max, ind;
	
	while (1){
		scanf("%d %d", &n, &m);
		
		cost = 0;
		max = 0;
		
		if (n == 0 && m == 0){
			break;
		}
		for (i = 0; i < n; i++){
			scanf("%d", &p[i]);
			c[i] = 1;
		}
		
		for (i = 0; i < n; i++){
			max = 0;
			for (i2 = 0; i2 < n; i2++){
				
				if (max < p[i2] && c[i2] == 1){
					max = p[i2];
					ind = i2;
					
				}
			}
			p2[i] = max;
			c[ind] = 3;
		}
		
		for (i = 0; i < n / m + 1; i++){
			for (i2 = 0; i2 < m - 1; i2++){
				if (i2 + i * m < n){
					cost += p2[i2 + i * m];
				}
			
			}
		}
		printf ("%d\n", cost);
	}
	return (0);
}
				
		
	
		
	

Measured memory_bytes: 608
#include <stdio.h>

int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if (a <= 0 && 0 <= b)
	{
		printf("Zero\n");
	}
	else if (b < 0 && (b - a) % 2 == 0)
	{
		printf("Negative\n");
	}
	else
	{
		printf("Positive\n");
	}
	return 0;
}

Measured memory_bytes: 128
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if (a + b == c){
        cout << b + c << endl;
    } else if (a + b < c){
        cout << b * 2 + a + 1 << endl;
    } else if (a + b > c){
        cout << b + c << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<list>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod = 1000000007;
const long long INF = 1LL << 55;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n, m;
int a[33];

int main()
{
	cin >> n >> m;
	for (int i = 0;i < n;i++) {
		int k;
		cin >> k;
		for (int j = 0;j < k;j++) {
			int t;
			cin >> t;
			a[t]++;
		}
	}

	int ans = 0;
	for (int i = 0;i <= m;i++) {
		if (a[i] == n) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
package main
 
import "fmt"
 
func main() {
	var s, t string
	fmt.Scan(&s, &t)
 
	for i := 0; i < len(s); i++ {
		if s == t {
			fmt.Println("Yes")
			return
		}
		s = s[1:] + s[:1]
	}
	fmt.Println("No")
}

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

int main(){
    int a;
    cin >> a;
    string s;
    cin >> s;
    string t;
    cin >> t;
    string b = "";
    for(int i = 0; i < a; i++){
        b = b + s[i] + t[i];
    }


    cout << b << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
li = [0]*(10**5+10)
 
for i in A:#出現する個数の管理
    li[i] += 1
 
ans = sum(A)#
 
for i in range(Q):
    B,C = map(int,input().split())
    ans += li[B]*C - li[B]*B
    print(ans)
    li[C] += li[B]#個数を追加する
    li[B] = 0#置換されたAnは必ず0となる

Measured memory_bytes: 20972
#include<cstdio>
const int N=1e5+3;
struct edge{int v,nxt;}g[N+N];
int n,head[N],k,f[N];
inline void Insert(int u,int v){g[++k]=(edge){v,head[u]};head[u]=k;}
void Dfs(int u,int fa){
	int v;
	for(int i=head[u];i;i=g[i].nxt)if((v=g[i].v)!=fa)
	  Dfs(v,u),f[u]^=f[v]+1;
}
int main(){
	int u,v;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	  scanf("%d%d",&u,&v),Insert(u,v),Insert(v,u);
	Dfs(1,0);
	puts(f[1]?"Alice":"Bob");
	return 0;
}

Measured memory_bytes: 11756
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

#define mod 1000000007

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

int x,a,b;

int main(){
    cin>>x>>a>>b;
    a-=x;
    b-=x;
    if(abs(a)>abs(b))out("B");
    else out("A");
}

Measured memory_bytes: 256
A=input().split()
l=len(A)
x=[]

for i in range(l):
    
    if A[i]=="+":
        a=x.pop() #先頭の文字を消して返す
        b=x.pop()
        x.append(int(b)+int(a))

    elif A[i]=="-":
        a=x.pop()
        b=x.pop()
        x.append(int(b)-int(a))

    elif A[i]=="*":
        a=x.pop()
        b=x.pop()
        x.append(int(b)*int(a))

    else:
        x.append(A[i])

print(x[0])


Measured memory_bytes: 5600
/*
AizuOnline A1172
Title Chebyshev's Theorem
*/
#include <stdio.h>
#define MAXVAL 123456*2
#define TOCHUU 50000
int cnt;

int prime_f[MAXVAL];

int prime_table[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,
		   53,59,61,67,71,73,79,83,89,97,
		   101,103,107,109,113,127,131,137,139,149,151,157,163,
		   167,173,179,181,191,193,197,199,211,223};
//
int next_prime(int n)
{
  int i;

  for(i=n+1;i<MAXVAL;i++)
    if(prime_f[i])
      return(i);
}
void make_furui()
{
  int i,j,p;

  prime_f[0]=prime_f[1]=0;
  for(i=2;i<=MAXVAL;i++)
    prime_f[i]=1;
  for(i=0;i<sizeof(prime_table)/sizeof(int);i++)
    {
      p = prime_table[i];
      for(j=2;p*j<=MAXVAL;j++)
	prime_f[p*j]=0;
    }
  
  for(i=223;i*i<MAXVAL;)
    {
      i=next_prime(i);
      for(j=2;i*j<=MAXVAL;j++)
	prime_f[i*j]=0;
	}
}
int prime_n2n(int n)
{
  return(prime_f[2*n]-prime_f[n]);
}
void make_runsum()
{
  int i;

  for(i=1;i<=MAXVAL;i++)
    prime_f[i] += prime_f[i-1];
}
void show_runsum()
{
  int i;

  for(i=1;i<30;i++)
    printf("%d:",prime_f[i]);
  printf("\n");
}

main()
{
  int N;

  make_furui();
  make_runsum();

  
  while(EOF != scanf("%d",&N) && N)
    {
      printf("%d\n",prime_n2n(N));
      //printf("%d\n",prime_f[N]);
      //printf("%d\n",prime_f[2*N]);
    }
return(0);
}

Measured memory_bytes: 1564
n, m = map(int, input().split())
memo = [False] * n

possible = False
for _ in range(m):
    s, e = map(int, input().split())

    if s == 1:
        if memo[e]:
            possible = True
            break

        memo[e] = True

    elif e == n:
        if memo[s]:
            possible = True
            break

        memo[s] = True

print('POSSIBLE' if possible else 'IMPOSSIBLE')



Measured memory_bytes: 4596
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n,m; cin >> n >> m;
    vector<int> k; k.resize(m);
    vector< vector<int> > s_ij; s_ij.resize(m);
    for(int i=0; i<m; i++){
        s_ij[i].resize(n);
        cin >> k[i];
        for(int im=0; im<k[i]; im++){
            int j; cin >> j;
            s_ij[i][j-1] = 1;
        }
    }
    vector<int> p; p.resize(m);
    for(int i=0; i<m; i++) cin >> p[i];
    
    int ans=0;
    for(int bit=0; bit<(1<<n); bit++){
        vector<int> vec_ans; vec_ans.resize(m);
        for(int j=0; j<n; j++){
            if(bit & 1<<j){
                for(int i=0; i<m; i++){
                    vec_ans[i] += s_ij[i][j];
                }
            }
        }
        bool flg=true;
        for(int i=0; i<m; i++){
            if(vec_ans[i]%2 == p[i]){
                continue;
            }else{
                flg=false; break;
            }
        }
        if(flg) ans++;
    }
    
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
typedef int64_t ll;
typedef uint64_t ull;

constexpr ll INF = 1000000000;/* 1e+9a */

void solve(istream &cin) {
    ll N;
    if (!(cin >> N)) { return; }
    vector<ll> a, b, c;
    for (int i = 0; i < N; ++i) {
        ll ta, tb, tc;
        cin >> ta >> tb >> tc;
        a.push_back(ta);
        b.push_back(tb);
        c.push_back(tc);
    }
    ll pa, pb, pc;
    pa = pb = pc = 0;
    for (int i = 0; i < N; ++i) {
        ll na, nb, nc;
        na = max(pb, pc) + a[i];
        nb = max(pa, pc) + b[i];
        nc = max(pa, pb) + c[i];
        pa = na; pb = nb; pc = nc;
    }
    cout << max({pa, pb, pc}) << endl;
}

int main(int argc, char *argv[]) {
    string FileName("EDPC"), Modifier("MEPH_");
    string ExecutionName = Modifier + FileName;
    string sub(argv[0]);
    // /home/USER/.../MEPH_X -> MEPH_X
    if (sub.size() > ExecutionName.size())
        sub = sub.substr(sub.size() - ExecutionName.size(), ExecutionName.size());

    cout << setprecision(16) << scientific;
    if (sub != ExecutionName) {
        cin.tie(0);
        ios::sync_with_stdio(false);
        while (cin) { solve(cin); }
    } else {
        cerr << sub << " test" << endl;
        string inFile = FileName + ".txt";
        auto fs = fstream(inFile, fstream::in);
        while (fs) { solve(fs); }
    }
}


Measured memory_bytes: 2908
#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	if(a>b){
		c=a-b;
		printf("%d\n",c);
	}
	else{
		c=b-a;
		printf("%d\n",c);
	}
	return 0;
}



Measured memory_bytes: 2112
from collections import defaultdict
import sys
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    return int(input())


def inpl():
    return list(map(int, input().split()))


N, a, b, c = inpl()
ss = [input() for _ in range(N)] + ["AB"]

abc = [a, b, c]
ans = []
abc_str = ["A", "B", "C"]


def calc(s_ij, ns_ij):
    global ans
    global abc

    (i, j) = s_ij

    if abc[i] == 0 and abc[j] == 0:
        print("No")
        sys.exit()
    elif abc[i] == 0:
        ans.append(abc_str[i])
        abc[i] += 1
        abc[j] -= 1
    elif abc[j] == 0:
        ans.append(abc_str[j])
        abc[j] += 1
        abc[i] -= 1
    elif abc[i] == 1 and abc[j] == 1:
        if i in ns_ij:
            ans.append(abc_str[i])
            abc[i] += 1
            abc[j] -= 1
        else:
            ans.append(abc_str[j])
            abc[j] += 1
            abc[i] -= 1
    else:
        if abc[i] < abc[j]:
            ans.append(abc_str[i])
            abc[i] += 1
            abc[j] -= 1
        else:
            ans.append(abc_str[j])
            abc[i] -= 1
            abc[j] += 1


def conv(s):
    if s == "AB":
        return (0, 1)
    elif s == "BC":
        return (1, 2)
    elif s == "AC":
        return (0, 2)


for i, s in enumerate(ss[:-1]):
    ns = ss[i + 1]

    s_ij = conv(s)
    ns_ij = conv(ns)

    calc(s_ij, ns_ij)

print("Yes")
print("\n".join(ans))


Measured memory_bytes: 18204
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s, t;
    cin>>s>>t;
    int mx=0;
    for(int i=0; i<=s.size()-t.size(); i++){
        int k=i, cnt=0;
        for(int j=0; j<t.size(); j++){
            if(s[k]==t[j]) cnt++;
            k++;
        }
        mx = max(mx, cnt);
    }
    int ans = t.size() - mx;
    cout<<ans;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>
#include <complex>

using namespace std;

#define mod 1000000007

int main()
{
	string s, t;
	cin >> s >> t;
	vector<vector<int> > indexList(26);
	for(int i = 0; i < s.length(); i++){
		indexList[s[i] - 'a'].push_back(i);
	}
	long long int ans = 0;
	for(int i = 0; i < t.length(); i++){
		int tmp = t[i] - 'a';
		if(indexList[tmp].size() == 0){
			cout << -1 << endl;
			return 0;
		}
		// 今sのうち，(ans % s.length()) - 1 まで利用されている
		auto nextIndexIter = lower_bound(indexList[tmp].begin(), indexList[tmp].end(), (ans % s.length()));
		if(nextIndexIter == indexList[tmp].end()){
			ans += s.length() - (ans % s.length());
			nextIndexIter = indexList[tmp].begin();
		}
		ans += *(nextIndexIter) - (ans % s.length()) + 1;
		// cout << ans << " " << *(nextIndexIter) << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1216
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
        l: usize,
        mut s: [Chars;n],
    }
    s.sort();
    for i in 0..n {
        for j in 0..l {
            print!("{}",s[i][j]);
        }
    }
    print!("\n");
}


Measured memory_bytes: 2184
package main

import "fmt"

func getMin(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	x := getMin(a, b)
	y := getMin(c, d)
	fmt.Println(x + y)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

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

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

int main()
{
    string a;
    bool s = false,n = false,w = false,e = false;
    cin >> a;
    if (a.find('S') != std::string::npos) {
        s = true;
    }
    if (a.find('N') != std::string::npos) {
        n = true;
    }
    if (a.find('W') != std::string::npos) {
        w = true;
    }
    if (a.find('E') != std::string::npos) {
        e = true;
    }
    
    if (s && n && w && e) {
        Yes;
    }else if (s && n && !w && !e){
        Yes;
    }else if (!s && !n && w && e){
        Yes;
    }else{
        No;
    }
    
    return 0;
}


Measured memory_bytes: 256