akhauriyash/Code-Regression huggingface dataset:
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << (x) << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

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

    if (a >= b) {
        OUT("delicious");
    } else if (b - a <= x) {
        OUT("safe");
    } else {
        OUT("dangerous");
    }
    return 0;
}



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

#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)
#define fs first
#define sc second
#define pb push_back
#define mk make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

template<class S,class T>
ostream &operator<<(ostream &out, const pair<S,T> p){
	return out << "(" << p.fs << ", " << p.sc << ")";
}

template<class T>
ostream &operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()) out << v[i] << ", ";
	return out << "}" << endl;
}

int main(){
	int n,m,k;
	cin >> n >> m >> k;
	rep(i,n+1)rep(j,m+1){
		int ans = i * m + j * n - (2*i*j);
		if(ans == k){
			cout <<"Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}



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

int main() {
  int n, m;
  cin >> n >> m;
  int a[n];
  int all = 0;
  for ( int i = 0; i < n; i++ ) {
    cin >> a[i];
    all += a[i];
  }
  sort(a, a+n);
  string ans = "Yes";
  if ( a[n-m]*(4*m) < all ) {
    ans = "No";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
S1 = input()
T = input()
N = len(S1)
M = len(T)

#print(N,M)
ans = ""

for i in range(N-M+1):
    jdg = True
    for k in range(M):
        if not (T[k] == S1[i+k] or S1[i+k] == "?"):
            jdg = False
    if jdg:
        ans = S1[:i] + T + S1[i+M:]
        #print(S1[:i],T,S1[i+M:])
if ans == "":
    print("UNRESTORABLE")
else:
    print(ans.translate(str.maketrans({'?': 'a'})))

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
 int  n=0,i;
 string s;
    cin>>s;

    for(i=0;i<s.size();i++)
    {
        n+=s[i]-48;

    }

    if(n%9==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	cin >>n;
	VPi ab(n);
	VPi ba(n);
	int half=n/2;
	//clog<<half<<endl;
	rep(i,n){
		cin>>ab[i].F>>ab[i].S;
		ba[i].F=ab[i].S;
		ba[i].S = ab[i].F;
		}
	sort(all(ab));
	sort(all(ba),greater<pair<int,int>>());
	//clog<<endl;
	//repi(itr,ab){
		//clog<<(itr->F)<<" "<<(itr->S)<<endl;
	//}
	//clog<<endl;
	//repi(itr, ba)
	//{
		//clog << (itr->F) << " " << (itr->S) << endl;
	//}

	if(n%2==0){
		ans = 1+(ba[half].F + ba[half - 1].F) - (ab[half - 1].F + ab[half].F);
		//clog << (ab[half - 1].F + ab[half].F) << " " << (ba[half].F + ba[half - 1].F)<<endl;
	}else{
		ans=(ba[half].F-ab[half].F)+1;
	}
	cout<<ans<<endl;
}
//1 2 3 4
/*
1 2
  2 3

1       1e9
 10 1e4
  100

10= 100 = 1e4 (10000)

*/

Measured memory_bytes: 6428
#include <bits/stdc++.h>
using namespace std;
#define V(i) vector<i>
#define rep(i, n) for (__typeof(n) i = 0; i < n; i++)
#define crep(i,N,n) for (__typeof(n) i = N; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define P(i,j) pair<i,j>
#define MP make_pair
#define MOD 1000000007
typedef long long ll;
typedef long l;
#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ll n;
    cin>>n;
    cout<<(n%1000?(1000 - n%1000):n%1000);
    return 0;
}

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

typedef long long ll;
typedef int ii;
//typedef vector<ll> vi;

#define INF 1000000007

#define pi 3.141592654

#define T while(t--)
#define for2(i,a,b) for(i=a;i>=b;i--)
#define for3(i,a,b) for(i=a;i<=b;i=i+2)
#define for1(i,a,b) for(i=a;i<=b;i++)
#define pb push_back
#define mp make_pair

#include<sstream>

#define si set<ll>
#define se multiset<ll>

typedef long double ld;

typedef vector<int64_t> vi;

#define bb(arr,nn,xx) upper_bound(arr,arr+nn,xx)-arr
#define aa(arra,nna,xxa) lower_bound(arra,arra+nna,xxa)-arra

#define all(v) sort(v.begin(),v.end())
 
#define all1(v) sort(v.rbegin(),v.rend())

ii main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);

    int64_t n,i; cin>>n; vi v; ll x;
    
    for1(i,1,n)
    {
    
        cin>>x;
       
        v.pb(x);
        
    }
    
    ll sum1=0; ll sum=0;
    
    for2(i,n-1,1)
    {
    
        sum1+=v[i];
        
        sum+=(((v[i-1]%INF)*(sum1%INF))%INF)%INF;
        
    }
    
    
   
    cout<<sum%(INF)<<"\n";
    
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int solve(string s, string t, int os){
    int res = 0;
    rep(i, t.size()){
        if(s[i+os] != t[i]) res++;
    }
    return res;
}

int main(){
    string s,t; cin>>s>>t;
    int n = s.size(), m = t.size();
    int ans = MAX;
    rep(i, n-m+1){
        ans = min(ans, solve(s,t,i));
    }
    out(ans);
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}

int main()
{
	IOS;
	ll n,k;
	cin>>n>>k;
	ll ans=0;
	for(ll i=k;i<=n+1;i++)
	{
		ans+=(n*i-(i)*(i-1)+1)%M;
		ans%=M;
	}
	cout<<ans;

}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

int main(){
    int a, p;
    cin >> a >> p;
    cout << (3 * a + p) / 2 << endl;

}

Measured memory_bytes: 3640
#include <stdio.h>
int main(){
  int i,j,n[5][14],maisuu,num;
  char mark,dummy;
  scanf("%d",&maisuu);
 
  for(i=0; i < 5; i++){
    for(j=0; j < 14; j++){
      n[i][j]=0;
    }
  }
 
  for(i=0; i < maisuu; i++){
    
    scanf("%*c%c %d",&mark,&num);
 
    if(mark == 'S'){
      n[0][num] = 1;
    }
    if(mark == 'H'){
      n[1][num] = 1;
    }
    if(mark == 'C'){
      n[2][num] = 1;
    }
    if(mark == 'D'){
      n[3][num] = 1;
    }
  }
  for(i = 0; i < 4; i++){
    for(j=1; j < 14; j++){
       
      if(n[i][j]==0 && i == 0) printf("S %d\n",j);
      if(n[i][j]==0 && i == 1) printf("H %d\n",j);
      if(n[i][j]==0 && i==2) printf("C %d\n",j);
      if(n[i][j]==0 && i==3) printf("D %d\n",j);
    }
  }
   
  return 0;
}

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

typedef long long ll;

int main(){
  ll n;
  cin >> n;
  ll count=0,t=n;
  while(t>0){
    t/=10;
    count++;
  }
  ll ans=0;
  for(ll i=0;i<count;i++){
    ll m=n%10;
    n/=10;
    for(ll j=0;j<=i;j++){
      ll t;
      if(i==j) t=pow(2,count-1-j)*m*pow(10,j);
      else t=pow(2,count-2-j)*m*pow(10,j);
      ans+=t;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
N, X, Y = map(int, input().split())

memo = [0] *(N)

for i in range(1, N):
    for j in range(i, N + 1):
        min_dis = min((j - i), abs(X - i) + 1 + abs(j - Y))
        memo[min_dis] += 1

for k in range(1,N):
    print(memo[k])





Measured memory_bytes: 46300
#include <stdio.h>
#include <string.h>
int main()
{
	char s[100],t[100];
	gets(s);
	gets(t);
	int len=strlen(s);
	int k;
	if(len!=strlen(t))
	printf("No");
	for(k=0;k<len;k++)
	{
		int i=0;
	    while(t[i]!='\0')
	    {
		if(s[(i+k)%len]==t[i])
		i++;
		else 
		break;
	    }
	    if(i>len-1)
	  {  
	  printf("Yes");
	  break;
	  }
	}
	if(k>=len)
	printf("No");
	return 0;
}

Measured memory_bytes: 128
/*
  貪欲法に近い感じ
  けんちょんさんの解法1
*/

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <stack>
#include <queue>

typedef long long ll;
using namespace std;

int main(){
  ll n,k,i,j,d,e;
  cin >> n >> k;
  vector<ll> a(n);
  for(i=0;i<n;i++)cin >> a[i];
  ll ret = 0;
  for(d=45;d>=-1;d--){
    if(d != -1 && !(k & (1LL<<d))) continue;
    /*
      dはxとkが初めて異なる値になったbit
      k & (1LL<<d)になった時はkのdbit目が1
      d=-1はkとxがすべて一致した場合
    */
    ll tmp = 0;
    for(e=45;e>=0;e--){
      ll mask = 1LL<<e;
      ll cnt = 0LL;
      for(i=0;i<n;i++){
        if(mask & a[i])cnt++;
      }
      if(e>d){
        if(k & mask)tmp+=(n-cnt)*mask;
        else tmp+=cnt*mask;
      }else if(e==d){
        tmp += mask*cnt;
      }else{
        tmp += mask*max(cnt,n-cnt);
      }
    }
    ret = max(ret,tmp);
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll ng = 0, ok = inf;
	while (ok - ng > 1) {
		ll mid = (ng + ok) / 2;
		ll sum = -n;
		rep(i, n) sum += (a[i] + mid - 1) / mid;
		if (sum <= k) ok = mid;
		else ng = mid;
	}
	cout << ok << '\n';
}

Measured memory_bytes: 4780
a = int(input())
# スペース区切りの整数の入力
b = input().split()
b = [int(i) for i in b]

c = len(b)
d = 0


while c == len(b):
  c=0
  for i in b:
    if i %2 == 0:
      c +=1
  if(c == len(b)):
    d += 1
    b = [i/2 for i in b]
print (d)
   

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll n;
    cin >> n;
    ll ans = 0;
    repd(i, 1, n + 1) {
        if (i % 3 != 0 && i % 5 != 0) {
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;

int main(){
    int N;
    while(cin >> N){
        vector<vector<int>> g(N);
        for(int i=0;i<N-1;i++){
            int a, b; cin >> a >> b;
            g[a-1].push_back(b-1);
            g[b-1].push_back(a-1);
        }
        vector<int> mark(N, -1);
        mark[0] = 0;
        queue<int> qu; qu.push(0);
        while(!qu.empty()){
            int p = qu.front(); qu.pop();
            for(auto& t : g[p]){
                if(mark[t] != -1) continue;
                mark[t] = 1 - mark[p];
                qu.push(t);
            }
        }
        vector<int> cnt(2, 0);
        vector<vector<int>> d(3);
        vector<int> res(N);
        for(int i=1;i<=N;i++) d[i%3].push_back(i);
        for(int i=0;i<N;i++) cnt[mark[i]]++;
        if(cnt[0] > cnt[1]){
            swap(cnt[0], cnt[1]);
            for(auto& t : mark) t = 1 - t;
        }
        if(cnt[0] <= d[0].size()){
            for(int i=0;i<N;i++){
                if(mark[i] == 0){
                    res[i] = d[0].back();
                    d[0].pop_back();
                }
            }
            for(int i=0;i<N;i++){
                if(mark[i] == 0) continue;
                for(int j=0;j<3;j++){
                    if(d[j].empty()) continue;
                    res[i] = d[j].back();
                    d[j].pop_back();
                    break;
                }
            }
        } else {
            for(int i=0;i<N;i++){
                int f = mark[i] + 1;
                if(d[f].empty()) f = 0;
                res[i] = d[f].back();
                d[f].pop_back();
            }
        }
        cout << res[0];
        for(int i=1;i<N;i++) cout << " " << res[i];
        cout << endl;
    }
}

Measured memory_bytes: 16628
<?php

fscanf(STDIN,"%d %d %d\n",$a,$b,$c);
fscanf(STDIN,"%d",$k);
$mx=max($a,$b,$c);
$sum=$a+$b+$c-$mx;
while($k){
    $mx*=2;
    $k--;
}

$sum+=$mx;

echo $sum;
?>

Measured memory_bytes: 3828
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn = 100005;
struct IO{
	template<class T>
	IO operator >> (T &res) {
		char ch;
		bool flag=false;
		res=0;
		while ((ch=getchar())>'9'||ch<'0')	flag|=ch=='-';
		while (ch>='0'&&ch<='9')	res=(res<<3)+(res<<1)+(ch^'0'),ch=getchar();
		if (flag)	res=~res+1;
		return *this;
	}
}cin;
struct Ants{
	long long loc,last,dir,id;
	Ants (){loc=0,last=0,dir=0,id=0;}
}ant[maxn];
long long n,l,t,cnt;
long long aft[maxn];
int main ()
{
	cin>>n>>l>>t;
	for (int i=1;i<=n;++i)	cin>>ant[i].loc>>ant[i].dir,ant[i].id=i;
	for (int i=1;i<=n;++i){
		ant[i].dir=ant[i].dir==2?-1:1;
		aft[i]=(long long)ant[i].loc+(long long)t*(long long)ant[i].dir;
		if (aft[i]>=l)	(cnt+=aft[i]/l)%=n;
		if (aft[i]<0)	(cnt+=((aft[i]+1)/l-1))%=n;
		aft[i]=(aft[i]%l+l)%l;
	}
	cnt=(cnt+n)%n;
	sort(aft+1,aft+n+1);
	for (int i=1,j=1;j<=n;++i,++j)	ant[i].last=aft[(cnt+i-1)%n+1];
	for (int i=1;i<=n;++i)	printf("%lld\n",ant[i].last);
	return 0;
}


Measured memory_bytes: 4992
N, M = gets.chomp.split(" ").map(&:to_i)
AC = Array.new(N + 1, 0) 
WA = Array.new(N + 1, 0)
M.times do  
    p, s = gets.chomp.split(" ")
    if s == 'WA' && AC[p.to_i] == 0 
        WA[p.to_i] += 1
    elsif s == 'AC' && AC[p.to_i] == 0
        AC[p.to_i] += 1
    end
end

miss = 0
(N + 1).times do |i|
    if AC[i] != 0
        miss += WA[i]
    end
end
puts "#{AC.inject(:+)} #{miss}"


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

using namespace std;

int main() {
    int N, M;

    cin >> N >> M;

    int l_max = 0;
    int r_min = 100001;
    for (int i = 0; i < M; ++i) {
        int l, r;
        cin >> l >> r;
        l_max = max(l, l_max);
        r_min = min(r, r_min);
    }
    cout << max(0, r_min - l_max + 1) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
using static Prog;
using NX = System.Int64;

public class Solver
{
    public void Solve()
    {
        Console.WriteLine(NextInt() <= NextInt() ? "unsafe" : "safe");
    }
}

public class Prog
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    public struct Pair { public int x, y; public Pair(int a, int b) { x = a; y = b; } }
    static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        new Solver().Solve();
        Console.Out.Flush();
        return;
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


Measured memory_bytes: 27868
#include <iostream>
#include <stdlib.h>

int main()
{
	int num, *arr, max = 0, secmax = 0;

	scanf("%d", &num);

	arr = (int*)malloc(sizeof(int) * num);

	for(int i = 0 ; i < num; i++)
	{
		scanf("%d", &arr[i]);

		if (max < arr[i])
		{
			secmax = max;
			max = arr[i];
		}
		else if (secmax < arr[i])
			secmax = arr[i];
	}

	for (int i = 0; i < num; i++)
	{
		if (arr[i] == max)
			printf("%d\n", secmax);
		else
			printf("%d\n", max);
	}
	
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <queue>
#include <set>

using namespace std;
typedef pair<int, int> Point;
typedef pair<pair<Point, Point>, int> Node;
int main() {
	int x;
	int y;
	int dx[] = { 0, 1, 0, -1 };
	int dy[] = { 1, 0, -1, 0 };
	while (cin >> x >> y, x | y) {
		int sax;
		int say;
		int sbx;
		int sby;
		cin >> sax >> say >> sbx >> sby;
		sax--;
		say--;
		sbx--;
		sby--;
		int map[y][x];
		for (int i = 0; i < y; i++) {
			for (int j = 0; j < x; j++) {
				cin >> map[i][j];
			}
		}
		queue<Node> q;
		Point sa = make_pair(sax, say);
		Point sb = make_pair(sbx, sby);
		q.push(make_pair(make_pair(sa, sb), 0));
		set<pair<Point, Point> > visited;
		while (1) {
			if (q.empty()) {
				cout << "NA" << endl;
				break;
			}
			Node tmp = q.front();
			q.pop();
			pair<Point, Point> ps = tmp.first;
			int t = tmp.second;
			int size = visited.size();
			visited.insert(ps);
			if (size == visited.size()) {
				continue;
			}
			Point a = ps.first;
			Point b = ps.second;
			int ax = a.first;
			int ay = a.second;
			int bx = b.first;
			int by = b.second;
			if (t > 100) {
				cout << "NA" << endl;
				break;
			}
			if (ax == bx && ay == by) {
				cout << t << endl;
				break;
			}
			for (int i = 0; i < 4; i++) {
				int nax = ax + dx[i];
				int nay = ay + dy[i];
				int nbx = bx - dx[i];
				int nby = by - dy[i];
				if (nax < 0 || nay < 0 || nax >= x || nay >= y
						|| map[nay][nax]) {
					nax = ax;
					nay = ay;
				}
				if (nbx < 0 || nby < 0 || nbx >= x || nby >= y
						|| map[nby][nbx]) {
					nbx = bx;
					nby = by;
				}
				Point na = make_pair(nax, nay);
				Point nb = make_pair(nbx, nby);
				q.push(make_pair(make_pair(na, nb), t + 1));
			}
		}
	}
	return 0;
}

Measured memory_bytes: 12088
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
#define EPS 1e-6
 
 
 
int main(){
	fast;
	int n;
	cin>>n;
	vector<int> a(n-1);
	lli sum=0;
	for(int i=0; i<n-1; i++){
	    cin>>a[i];
	}
	for(int i=0; i<n-2; i++){
	    if(a[i]<=a[i+1]) sum+=a[i];
	    else sum+=a[i+1];
	}
	sum+=a[n-2];
	sum+=a[0];
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[4];
int main()
{
	int i,j,k;
	for (i=1;i<=3;i++) cin>>a[i];
	sort(a+1,a+4);
	cin>>k;
	for (i=1;i<=k;i++) a[3]=a[3]*2;
	k=a[1]+a[2]+a[3];
	cout<<k;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import itertools#これは色々使える組み込み関数みたいなやつ
import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
i=0
N=int(input())
#N, L=input().split()
#S=input()
#T=input()
#S_list=list(S)
h_list=  list(map(int, input().split(" ")))
#M=int(input())
#drink_list = [list(map(int, input().split(" ")))for i in range(M)]
#print(T_list[1])
#N=int(N)
#C=int(C)
#K=int(K)
#S_list=[]
#sentence_list=[]
#total=0
#mojiretu=""
#センテンスを暗記するのではなく、まずinput()を書いて、膨らます感じで記述する。すると#思考の流れ通りに書ける。素晴らしい！
#for i in range(K):
# ID_list.append(i+1)
#print(ID_list)
#for i in range(H)
#この下の行が二次元リストの読み込
#intを消して記号を読み込めるようにしたしかしこれでは文字列から読み込んでいるのと同じ
#sentence_list =  [list(input())for i in range(N)]#一文字づつばらして入れてしまう
#s = [input() for i in range(N)]
#複数行に複数の入力値を取得し、出力する
#sentence_list =  (list(input())for i in range(N))
#for i in range(H):
#  ppixel_list=list(input())
#  
#print(pixel_list)
i=0
j=0
#high_pixel_list =[['' for i in range(W)]for j in range(2*H)]
#print(high_pixel_list)
#print(pixel_list[0][1])#行　列の順番にかっこが並んでいる
a_list=[]
a_list.append(0)
if N >= 2 :
 a_list.append(abs(h_list[0]-h_list[1]))
#print(a_list)
first_term=0
second_term=0
#整数二次元配列を読み込む時のやり方
#gate_list =  [list(map(int, input().split(" ")))for i in range(M)]
#センテンスを暗記するのではなく、まずinput()を書いて、膨らます感じで記述する。すると#思考の流れ通りに書ける。素晴らしい！
#print(s)
#sentence_list=sorted(s)
#print(sentence_list)
#スペースでいれつつ値を取得
for i in range(len(h_list)):
    #print(i+2)
    #print(a_list)
    if i+3 >=N and N<=2:
        print(a_list[N-1])
        sys.exit()
    elif i+2 ==N:
        print(a_list[N-1])
        sys.exit()



    first_term=a_list[i+1]+abs(h_list[i+1]-h_list[i+2])
    second_term=a_list[i]+abs(h_list[i]-h_list[i+2])
    a_list.append(min(first_term, second_term))
    
    
    #if i+2 ==N:
    #    print(a_list[N-1])
    #    sys.exit()



Measured memory_bytes: 14480
# /usr/bin/python
# -*- coding: utf-8 -*-
import math
import sys


def main():
  Sn = list(str(input()))
  Tn = list(str(input()))
  ls = len(Sn)
  lt = len(Tn)

  if ls < lt:
    return 'UNRESTORABLE'

  ret = []
  for i in range(ls-lt+1):
    chk = True
    for j in range(lt):
      if Sn[i+j]!=Tn[j] and Sn[i+j]!='?':
        chk = False
    if chk:
      ret.append(''.join(Sn[:i]+Tn+Sn[i+lt:]).replace('?','a'))
  if len(ret)==0:
    return 'UNRESTORABLE'
  else:
    return min(ret)


if __name__ == "__main__":
  print(main())


Measured memory_bytes: 38384
N, M = map(int, input().split())
cnt = [0 for _ in range(M)]
for _ in range(N):
    K, *A = list(map(int, input().split()))
    for a in A:
        cnt[a - 1] += 1
ans = 0
for i in range(M):
    if cnt[i] == N:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int a[25];
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>a[i];
    int cnt=0;
    for(int i=1; i<n-1; i++)
    {
        //cout<<a[i]<<endl;
        if((a[i-1]<a[i] && a[i]<a[i+1]) || (a[i+1]<a[i]&& a[i]<a[i-1]))
            cnt++;
        //cout<<cnt <<" ";
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class B {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.ni(), k = in.ni();
            int[] h = in.na(n);
            int[] dp = new int[n];
            Arrays.fill(dp, Integer.MAX_VALUE);
            dp[0] = 0;
            for (int i = 0; i < n; i++) {
                for (int kk = 1; kk <= k && i + kk < n; kk++) {
                    dp[i + kk] = Math.min(dp[i + kk], dp[i] + Math.abs(h[i] - h[i + kk]));
                }
            }
            out.println(dp[n - 1]);
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String ns() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int ni() {
            return Integer.parseInt(ns());
        }

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

    }
}



Measured memory_bytes: 34340
n, q = map(int, input().split())
s = input()
ts, ds = [], []
for _ in range(q):
    t, d = input().split()
    ts.append(t)
    ds.append(d)

def reachable(n, dest):
    for t, d in zip(ts, ds):
        if s[n] == t:
            n = n - 1 if d == 'L' else n + 1
        if n == dest:
            return True
        elif not 0 <= n <= len(s) - 1:
            return False
    return False


l, r = -1, n
while r - l > 1:
    m = l + (r - l) // 2
    if reachable(m, -1):
        l = m
    else:
        r = m
ldel = l + 1

l, r = -1, n
while r - l > 1:
    m = l + (r - l) // 2
    if reachable(m, n):
        r = m
    else:
        l = m
rdel = n - r

print(max(n - (ldel + rdel), 0))


Measured memory_bytes: 87892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int n, k;
vector<vector<int> > v(100005);
vector<int> ptr(100005);

void dfs(int now) {
    for (int nxt : v[now]) {
        if (ptr[now] == nxt) continue;
        ptr[nxt] = now;
        dfs(nxt);
    }
}

ll ans = 1;
void dfs2(int now) {
    ll num = k - 1;
    if (ptr[now] != -1) num--;
    for (int nxt : v[now]) {
        if (ptr[now] == nxt) continue;
        (ans *= num--) %= inf;
        dfs2(nxt);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    cin >> n >> k;
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        v[a].eb(b);
        v[b].eb(a);
    }
    ptr[0] = -1;
    dfs(0);
    // rep(i, n) cout << ptr[i] << " "; cout << endl;
    ans *= k;
    dfs2(0);
    cout << ans << endl;
    
    
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI a(n);
	rep(i,n) cin>>a[i];
	a.push_back(-1);
	int ct =1, ans =0;
	rep(i,n){
		if(a[i] == a[i+1]) ct++;
		else{
			ans +=ct/2;
			ct =1;
		}
		//dbg(ct,ans);
	}
	
	cout << ans <<"\n";
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int A,B,C,D ;
 int main() {
  cin >> A >> B >> C >> D;
if ( A + B == C + D ) {
  cout << "Balanced" << endl;
}
else if ( A + B >= C + D ) {
  
cout << "Left" << endl;
}
 else if ( A + B <= C + D ) {
   cout << "Right" << endl;
}
return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{

// }}}


signed main()
{
    int n; cin >> n;
    int a[30];

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

    int ans = 0;
    for (int i = 1; i < n-1; ++i) {
        if ((a[i-1] < a[i] && a[i] < a[i+1]) || (a[i+1] < a[i] && a[i] < a[i-1])) {
            ++ans;
        }
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000010;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	string s;
	cin >> s;
	int n = s.size();
	int mod = 2019;
	vector<int> val(n + 1);
	rep(i, n) {
		int c = s[i] - '0';
		val[i + 1] = val[i] * 10 + c;
		val[i + 1] %= mod;
	}
	int coeff = 1;
	for (int i = n - 1; i >= 0; i--) {
		coeff *= 10; coeff %= mod;
		val[i] *= coeff; val[i] %= mod;
	}
	vector<ll> cnt(2019);
	rep(i, n + 1) cnt[val[i]]++;
	ll ans = 0;
	rep(i, 2019) ans += cnt[i] * (cnt[i] - 1) / 2;
	cout << ans << '\n';
}

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

const long long int MOD = 1e9 + 7;
int s;
const int MX_S = 2000;
const int MX_NUM = 667;
long long int dp[MX_NUM + 1][MX_S + 1];
long long int ans;

int main() {
    cin >> s;
    dp[0][0] = 1;
    for (int i = 0; i < MX_NUM; i++) {
        if (i != MX_NUM - 1) dp[i + 1][3 * (i + 1)] = 1;
        for (int j = 3; j <= MX_S; j++) {
            dp[i + 1][j] = (dp[i + 1][j - 1] + dp[i][j - 3]) % MOD;
        }
    }

    for (int i = 0; i <= MX_NUM; i++) {
        ans += dp[i][s];
        ans %= MOD;
    }

    // out -= 1;
    // if (out < 0) out = MOD - out;

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

Measured memory_bytes: 14060
def warizan(n):
    flag = True
    count = 0
    while flag == True:
        if n/2 == n//2:
            count += 1
            n = n/2
        else:
            flag = False
    return count

import math
n = int(input())
lis = list(map(int, input().split()))
new_lis = [warizan(l) for l in lis if l%2 == 0]
print(sum(new_lis))

Measured memory_bytes: 4148
import sys


q_size, g_score = map(int, input().split())
q_nums = [0] * q_size
bonus = [0] * q_size
for i in range(0, q_size):
    q_nums[i], bonus[i] = map(int, input().split())


def solve_q(score, q_cnt, q_solved, best_cnt):
    # ボーナスだけでGを突破していたら、そのまま返却する
    if score >= g_score: 
        return min(best_cnt, q_cnt)
    
    # 現状でどの問題が何問残っているかキャッシュし、配点の高い問題から先に解いていく
    q_remained = [0] * q_size
    for i in range(0, q_size):
        q_remained[i] = q_nums[i] - q_solved[i]
        
    for i in range(q_size - 1, -1, -1):
        while q_remained[i] > 0: # Gに達成するまで、あるだけ全部解く
#            print("while in score: ", score)
            score += 100 * (i + 1)
            q_cnt += 1
            q_remained[i] -= 1
            
            if score >= g_score:
                return min(best_cnt, q_cnt)
            
    # ボーナス未反映で、解なしの場合
    return min(best_cnt, q_cnt)

            
best_cnt = sum(q_nums)
# 各Qのボーナスを 使う or 使わない で分岐
for bi in range(0, 2 ** q_size):
    # 初期化
    score = 0
    q_cnt = 0
    q_solved = [0]*q_size

    for pos_i in range(0, q_size):
        if (bi >> pos_i) & 1: # True: ボーナスを使う
            score += 100 * (pos_i + 1) * q_nums[pos_i] + bonus[pos_i]
            q_cnt += q_nums[pos_i]
            q_solved[pos_i] += q_nums[pos_i]
            
    # スコアを引き継いで、得点の高い問題から解いていく
#    print(score, q_cnt, q_solved, best_cnt)
    best_cnt = solve_q(score, q_cnt, q_solved, best_cnt)
    

print(best_cnt)


Measured memory_bytes: 3064
import java.io.PrintWriter;
import java.util.*;

public class Main {
	static final long MOD =1000000007;
	
	static class Comb {
		int a;
		int b;
		long pre;

		public Comb(int a) {
			this.a = a;
		}
		
		public long get(int b) {
			if(b==0)
				pre = 1;
			else if(b==1)
				pre = a;
			
			this.b=b+1;
			return pre;
		}
		
		public long getNext() {
			long ans = (pre * (a-b+1))%MOD;
			ans = (ans * rev(b))%MOD;
			b++;
			pre = ans;
			return ans;
		}
		
		long rev(long a) {
			return pow(a, MOD-2);
		}
		
		long pow(long a, long b) {
			long ans = 1;
			while(b>0) {
				if((b&1)!=0) {
					ans = (ans * a)%MOD;
				}
				a = (a*a)%MOD;
				b>>=1;
			}
			return ans;
		}
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		int N = sc.nextInt();
		int[] ra = new int[N];
		int L=0;
		Arrays.fill(ra, -1);
		for(int i=0; i<N+1; i++) {
			int a = sc.nextInt()-1;
			if(ra[a]<0)
				ra[a] = i;
			else
				L = ra[a] + (N+1-i-1);
		}
		
		Comb comb1 = new Comb(N+1);
		Comb comb2 = new Comb(L);
		for(int i=0; i<N+1; i++) {
			if(i==0)
				pw.println((comb1.get(i+1) - comb2.get(i) + MOD)%MOD);
			else
				pw.println((comb1.getNext() - comb2.getNext() + MOD)%MOD);
		}
		
		sc.close();
		pw.close();
	}
}


Measured memory_bytes: 53664
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::queue;
using std::deque;
using std::priority_queue;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;

using lli = long long int;
using ulli = unsigned long long int;

#define INF 999999999;
#define MOD 1000000007;

#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

int N;
int C[21], V[21];
int ans;

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

	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> V[i];
	}
	for(int i = 0; i < N; i++){
		cin >> C[i];
		if(C[i] < V[i]) ans += V[i]-C[i];
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);

    unordered_map<ll, int> m;

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

    ll q;
    cin >> q;

    vector<ll> b(q);
    vector<ll> c(q);
    for (int i = 0; i < q; i++)
    {
        cin >> b[i] >> c[i];
    }

    ll res = 0;
    for (int j = 0; j < n; j++)
    {
        res += a[j];
    }

    for (int i = 0; i < q; i++)
    {

        if (m.count(b[i]))
        {
            ll d = c[i] - b[i];
            int count = m[b[i]];

            m[c[i]] += count;

            m[b[i]] = 0;

            res += d * count;
        }

        cout << res << endl;
    }
}

Measured memory_bytes: 9072
#include<stdio.h>

int main()
{
    int n;
    scanf("%d", &n);

    double l = n / 2;

    if(n % 2 == 0){
        printf("%f\n", l / n);
    }
    else{
        printf("%f\n", (l + 1) / n);
    }
  
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
    string s;
    cin>>s;
    for (int i = 0; i < s.size();i+=2){
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << - 1 << endl;}
void unhap() {cout << ":(" << endl;}

int main() {
  int d;
  cin >> d;
  cout << "Christmas";
  if (d == 24) cout << " Eve";
  else if (d == 23) cout << " Eve Eve";
  else if (d == 22) cout << " Eve Eve Eve";
  cout << endl;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define size_of(a) (int)(a).size()
#define allof(a) (a).begin(),(a).end()

typedef long long lint;

int N, M, R, z[1010];

lint cstL[222][222], cstS[222][222];
lint dp[1010][222];

void minUpdate(lint& a, lint b) {
	a = min(a, b);
}

void solve() {	
	for_(k,0,N) for_(i,0,N) for_(j,0,N) {
		minUpdate(cstL[i][j], cstL[i][k] + cstL[k][j]);
		minUpdate(cstS[i][j], cstS[i][k] + cstS[k][j]);
	}
	
	for_(i,0,1010) for_(j,0,222) dp[i][j] = 1LL << 60;
	dp[0][z[0]] = 0;
	
	for_(i,0,R-1) for_(j,0,N) {
		if (dp[i][j] >= 1LL << 60) continue;
		
		lint cc = cstL[z[i]][z[i + 1]];
		if (cc < 1LL << 60) minUpdate(dp[i + 1][j], dp[i][j] + cc);
		
		for_(v,0,N) {
			lint c1 = cstL[z[i]][j];
			lint c2 = cstS[j][v];
			lint c3 = cstL[v][z[i + 1]];
			
			cc = c1 + c2 + c3;
			if (cc < 1LL << 60) minUpdate(dp[i+1][v], dp[i][j] + cc);
		}
	}
	
	lint ans = 1LL << 60;
	for_(i,0,N) minUpdate(ans, dp[R-1][i]);
	cout << ans << endl;
}

int main() {
	while (cin >> N >> M, N) {		
		for_(i,0,N) for_(j,0,N) cstL[i][j] = cstS[i][j] = 1LL << 60;
		for_(i,0,N) cstS[i][i] = cstL[i][i] = 0;
		
		for_(i,0,M) {
			int x, y, t;
			char s;
			cin >> x >> y >> t >> s;
			--x; --y;
			if (s == 'L') cstL[x][y] = cstL[y][x] = t;
			else cstS[x][y] = cstS[y][x] = t;
		}
		
		cin >> R;
		
		for_(i,0,R) {
			cin >> z[i];
			--z[i];
		}
		
		solve();
	}
}

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

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

	unsigned long long cnt = 0;
	if(s.size()<2){
		cout << 0 << endl;
		return 0;
	}

	unsigned long long a_num = 0;
	unsigned long long bef = 0;
	bool consecute_abc = false;
	for(int i=0;i<s.size()-1;i++){
		if(s[i] == 'A'){
			a_num++;
		}else if(s[i]=='B' && s[i+1]=='C'){
			cnt+=a_num;
			i+=1;
		}else{
			a_num=0;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin >> A >> B;
  int ans;
  for(int i=max(0,(B-1)*10);i<=(B+1)*10;i++){
    if(floor(i*0.08) == A && floor(i*0.1) == B){
      ans = i;
      break;
    }
    ans = -1;
  }
  cout << ans << endl;
}

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

using namespace std;

const int MAX_N = 1e5;
int a[MAX_N];
int N;
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}

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

    int ans = a[0];
    for(int i=1; i<N; i++) {
        ans = gcd(ans, a[i]);
    }

    cout << ans;
}


Measured memory_bytes: 640
/*
 * 很神奇的一道题目
 * 求出k的倍数的正数x，使得x的位数和最小。
 * eg k = 6 x = 12(位数和为3) x = 30(位数和为3)
 * 
 * 考虑正数x 其变为 x+1 需要代价1.
 *    正数x 变成 x*10 需要代价0.
 * 由于我们只需要得到k的倍数，也就是说在 %k 意义下为0的点。
 * 所以只有[0,k-1]k点。对每个点建立两条边，分别为(x+1)%k 和 (x*10)%k
 */
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
const int inf = 0x3f3f3f3f;
struct Edge {
    int to,val;
    Edge(){}
    Edge(int _t,int _v){to = _t;val = _v;}
};
struct qNode {
    int u,val;
    qNode(){}
    qNode(int _u,int _v) {u = _u;val = _v;}
    bool operator < (const qNode &a) const{
        return val > a.val;
    }
};
vector<Edge> ways[maxn];
int dist[maxn];
bool vis[maxn];
int n;
inline void init() {
    for(int i=0;i<maxn;i++) ways[i].clear();
    memset(vis,0,sizeof(vis));
    memset(dist,inf,sizeof(dist));
}
inline void addedge(int from,int to,int val) {
    ways[from].push_back(Edge(to,val));
}
int solve(int from,int to) {
    priority_queue<qNode> qu;
    dist[from] = 1;
    qu.push(qNode(from,1));
    qNode now;
    while(!qu.empty()) {
        now = qu.top();qu.pop();
        int u = now.u;
        if(vis[u]) continue;
        vis[u] = true;
        for(auto tmp:ways[u]) {
            int v = tmp.to,cost = tmp.val;
            if(!vis[v] && dist[v] > dist[u]+cost) {
                dist[v] = dist[u] + cost;
                qu.push(qNode(v,dist[v]));
            }
        }
    }
    return dist[to];
}
int main()
{
    while(~scanf("%d",&n)){
        init();
        for(int i=1;i<n;i++) {
            addedge(i,(i+1)%n,1);
            addedge(i,(i*10)%n,0);
        }
        int ans = solve(1,0);
        printf("%d\n",ans);
    }
    return 0;
}

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

int main(){
  int a[10];
  bool j=false;
  cin>>a[0]>>a[1]>>a[2]>>a[3];
  if(a[0]==a[1] && a[2]==a[3]){j=true;}
  if(a[0]==a[2] && a[1]==a[3]){j=true;}
  if(a[0]==a[3] && a[2]==a[1]){j=true;}

  if(j){cout<<"yes"<<endl;}
  else{cout<<"no"<<endl;}
  return 0;
}



Measured memory_bytes: 3092
#include<iostream>
using namespace std;
#include<iomanip>
#define _USE_MATH_DEFINES
#include<cmath>

int main(){
    int a,b;
    char op;

    cin >> a >> op >> b;

    while( !( op == '?' )){
        if ( op == '+') {
            cout << a+b << endl;
        } else if (op == '-'){
            cout << a-b << endl;
        } else if (op == '*'){
            cout << a*b << endl;
        } else if (op == '/'){
            cout << a/b << endl;
        }

        cin >> a >> op >> b;

    }

    return 0;

}

Measured memory_bytes: 3096
main :: IO ()
main = interact $ format . solve . parse

parse :: String -> (Int, [Int])
parse input = (h, a) where
    h = read . head . words . head . lines $ input
    a = map read . words . head . tail . lines $ input

solve :: (Int, [Int]) -> Bool
solve (h, a) = h <= sum a

format :: Bool -> String
format True = "Yes\n"
format False = "No\n"


Measured memory_bytes: 37244
#include<bits/stdc++.h>
using namespace std;
const int maxn=200010;
int n,m,cnt;
struct edge{
    int from,to,next;
}edges[maxn*2];
int head[maxn],fa[maxn],dep[maxn];
void dfs1(int p,int f,int d){
    fa[p]=f;dep[p]=d;
    for(register int i=head[p];i>=0;i=edges[i].next) if(edges[i].to!=f) dfs1(edges[i].to,p,d+1);
}
int dfs2(int p){
    int sum=0;
    for(register int i=head[p];i>=0;i=edges[i].next) if(edges[i].to!=fa[p]) sum+=dfs2(edges[i].to);
    return sum+1;
}
int main(){
    scanf("%d",&n);int x,y;
    memset(head,-1,sizeof(head));
    for(register int i=1;i<n;i++){
        scanf("%d%d",&x,&y);
        edges[cnt]=(edge){x,y,head[x]};
        head[x]=cnt;cnt++;
        edges[cnt]=(edge){y,x,head[y]};
        head[y]=cnt;cnt++;
    }
    dfs1(1,0,0);
    int pp=n;
    while(dep[pp]!=(dep[n]/2+1)) pp=fa[pp];
    int snk=dfs2(pp);
    if(n&1){
        if(snk>(n/2)) printf("Snuke\n");
        else printf("Fennec\n");
    }
    else{
        if(snk>=(n/2)) printf("Snuke\n");
        else printf("Fennec\n");
    }
    return 0;
}

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

using namespace std;

bool isPrime(int n){
	for(int i=2;i<=sqrt(n);i++){
		if(n%i==0) return false;
	}
	return true;
}

int main(){
	int n;
	while(cin >> n,n){
		int x=n,y=n;
		while(!isPrime(x)) x++;
		while(!isPrime(y)) y--;
		cout << x-y << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2996