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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

vstr memo;
int n;

bool rec(int l, int r) {
  string ls, rs;
  if (memo[l] != "") {
    ls = memo[l];
  } else {
    cout << l << endl;
    cin >> ls;
    memo[l] = ls;
    if (ls[0] == 'V') return true;
  }
  if (memo[r] != "") {
    rs = memo[r];
  } else {
    cout << r << endl;
    cin >> rs;
    memo[r] = rs;
    if (rs[0] == 'V') return true;
  }
  if (((r - l) % 2 == 1) && ls != rs ||
      ((r - l) % 2 == 0) && ls == rs) {
    return false;
  }
  if (rec(l, (l + r) / 2)) return true;
  if (rec((l + r) / 2, r)) return true;
  return false;
}

void solve() {
  cin >> n;
  memo.assign(n, "");
  rec(0, n - 1);
}


Measured memory_bytes: 1620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    string n; cin>>n;
    if((n[0]==n[1] && n[1]==n[2]) || (n[1]==n[2] && n[2]==n[3])) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

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

int main() {
  int H,W;
  cin >> H >> W ;
  int h,w ;
  cin >> h >> w ;
  
  int A;
  A=H*W-H*w-W*h+h*w ;
    
  cout << A << endl;
  
  
  
}


Measured memory_bytes: 256
s = input()

while len(s) > 0:
    if s.startswith("dreamera"):
        s = s[5:]
        #print(s)
    elif s.startswith("eraser"):
        s = s[6:]
        #print(s)
    elif s.startswith("dreamer"):
        s = s[7:]
    elif s.startswith("dream"):
        s = s[5:]
    elif s.startswith("erase"):
      	s = s[5:]
    else:
        #print(s)
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

using Graph=vector<vector<int>>;
Graph G;

int main(){
  //input
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  rep(i,n) cin >> a[i] >> b[i] >> c[i];
  
  //initialization
  ll dp[100010][3]={};
  
  //compute
  rep(i,n){
    dp[i+1][0]=max(dp[i][1]+a[i],dp[i][2]+a[i]);
    dp[i+1][1]=max(dp[i][0]+b[i],dp[i][2]+b[i]);
    dp[i+1][2]=max(dp[i][1]+c[i],dp[i][0]+c[i]);
  }
  
  //output
  cout << max({dp[n][0],dp[n][1],dp[n][2]}) << endl;
  
  
}
    


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

using namespace std;

int main(){
    int n;
    long long k;
    cin >> n >> k;
    vector<int> a(n);
    vector<int> f(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> f[i];
    sort(a.begin(), a.end(), greater<long long>());
    sort(f.begin(), f.end());
    long long l = -1, r = 1e12;
    while(l+1 < r){
        long long c = (l+r)/2;
        long long sum = 0;
        for(int i = 0; i < n; i++)sum += max(0ll, (a[i] - c/f[i]));
        if(sum <= k)r = c;
        else l = c;
    }
    cout << r << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }



// Saturday 1v1 match: twitch.tv/ecnerwala

int type[2][605][605];

int main() {
	int n;
	scanf("%d", &n);
	n *= 2;
	for(int rep = 0; rep < 2; ++rep) {
		int d;
		scanf("%d", &d);
		int memo_n = n;
		int divide = 1;
		while(d % 4 == 0) {
			d /= 4;
			n = (n + 1) / 2;
			divide *= 2;
		}
		vector<vector<int>> fake(n, vector<int>(n));
		if(d % 2 == 1) { // even + odd
			for(int x = 0; x < n; ++x) {
				for(int y = 0; y < n; ++y) {
					fake[x][y] = (x + y) % 2;
				}
			}
		}
		else if(d % 4 == 2) { // odd + odd
			for(int x = 0; x < n; ++x) {
				for(int y = 0; y < n; ++y) {
					fake[x][y] = x % 2;
				}
			}
		}
		else {
			assert(false);
		}
		n = memo_n;
		for(int x = 0; x < n; ++x) {
			for(int y = 0; y < n; ++y) {
				type[rep][x][y] = fake[x/divide][y/divide];
			}
		}
	}
	vector<pair<int,int>> g[4];
	for(int x = 0; x < n; ++x) {
		for(int y = 0; y < n; ++y) {
			int a = type[0][x][y];
			int b = type[1][x][y];
			g[2*a+b].emplace_back(x, y);
		}
	}
	for(int i = 0; i < 4; ++i) {
		if((int) g[i].size() >= n * n / 4) {
			g[i].resize(n * n / 4);
			for(pair<int,int> p : g[i]) {
				printf("%d %d\n", p.first, p.second);
			}
			return 0;
		}
	}
	assert(false);
}


Measured memory_bytes: 9772
import itertools
a=input().split()
cnt=0
ans=[]
while(True):
    a=[int(i) for i in a]
    b=input().split()
    b=[int(i) for i in b]
    c=list(itertools.combinations(b,2))
    for i in range(len(c)):
        if cnt<=c[i][0]+c[i][1] and c[i][0]+c[i][1]<=a[1]:
            cnt=c[i][0]+c[i][1]
    if cnt==0:
      ans.append("NONE")
    else:
      ans.append(cnt)
    a=input().split()
    if(a[0]=='0' and a[1]=='0'):
      break
    cnt=0
for i in range(len(ans)):
  print(ans[i])   


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

using namespace std;

int main()
{
  int n, tp = 0, hp = 0;
  string t, h;

  cin >> n;

  for (int i = 0; i < n; i++)
  {
    cin >> t >> h;
    if (t == h)
    {
      tp++;
      hp++;
    }
    else if (t > h)
    {
      tp += 3;
    }
    else
    {
      hp += 3;
    }
  }
  cout << tp << " " << hp << endl;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
int main() {
    ll ans = 1;
    ll a, b;
    cin >> a >> b;
    if (a > b) {
        swap(a, b);
    }
    vector<bool>v((int)sqrt(a) + 10,0);
    for (ll i = 2; i*i <= a; i++) {
        if (v[i] == 1) continue;
        for (ll j = i ; j*j <= a; j += i) {
            v[j] = 1;
        }
        if (a%i == 0 && b%i == 0) {
            ans++;
        }
        while (a%i == 0) {
            a /= i;
        }
    }
    if (a != 1 && b%a == 0) {
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int arr[n];
	for(int i =0;i<n;i++){
		cin>>arr[i];
	}
	int count = 0;
	for(int i = 0;i<n-2;i++){
		for(int j=i+1;j<n-1;j++){
			for(int k = j+1;k<n;k++){
				int b = max({arr[i], arr[j], arr[k]});
				if(arr[i] == arr[j] || arr[j] == arr[k] || arr[i] == arr[k])	continue;
				if(b == arr[i]){
					if(b<(arr[j]+arr[k])){
						count++;
					}
				}
				else if(b == arr[j]){
					if(b<(arr[i]+arr[k])){
						count++;
					}
				}
				else if(b == arr[k]){
					if(b<(arr[j]+arr[i])){
						count++;
					}
				}
			}
		}
	}
	cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 3652
#   include <stdio.h>
int main (void)
{
  int i,n,flag=0;
  int arr[1005];
  scanf("%d",&n);
  for(i=1;i<=n;i++)
  {
	  scanf("%d",&arr[i]);
	  if(arr[i]%2==0&&flag==0)
	  {
		  if(arr[i]%3==0||arr[i]%5==0)
			  flag=0;
		  else
		  {
			  flag=1;
			  continue;
		  }
	  }
	  else
		  continue;
  }
  if(flag==0)
	  printf("APPROVED\n");
  else
	  printf("DENIED\n");
  return 0;

}

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

int main(){
        int A,B,K;
        cin >> A >> B >> K;
        for (int i = A; i <= B; i++) {
                if(A+K-1 < i && i < B-K+1) continue;
                cout << i << endl;
        }
        return 0;

}


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

int main() {
    int N, Y;
    cin >> N >> Y;
    int res10000 = -1, res5000 = -1, res1000 = -1;
    for (int a = 0; a <= N; ++a) {
        for (int b = 0; a + b <= N; ++b) {
            int c = N - a - b;
            int total = 10000*a + 5000*b + 1000*c;
            if (total == Y) {
                res10000 = a;
                res5000 = b;
                res1000 = c;
            }
        }
    }
    cout << res10000 << " " << res5000 << " " << res1000 << endl;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;
use std::cmp::min;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_vec() -> Vec<i64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let n: i64 = input();
    let mut a_vec = input_vec();
    a_vec.sort();
    let mut diff = std::i64::MAX;
    let mut ans = 0;
    for i in 0..(n-1) as usize {
        if (a_vec[i] - (a_vec[n as usize - 1] + 1) / 2).abs() < diff {
            diff = (a_vec[i] - (a_vec[n as usize - 1] + 1) / 2).abs();
            ans = a_vec[i];
        }
    }
    println!("{} {}", a_vec[n as usize - 1], ans);
}


Measured memory_bytes: 3940
#define _CRT_SECURE_NO_WARNINGS

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

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

using namespace std;

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

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

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

	int length = s.size();
	int k_dash = length;
	REP(i, length - 1) {
		if (s[i] != s[i + 1]) {
			k_dash = min(max(i + 1, length - 1 - i), k_dash);
		}
	}
	cout << k_dash;
	system("pause");
	return 0;
}

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

using namespace std;

int N, M, K;
int A[100001];
long long dp[301][100001];

struct smax
{
    long long q[100001];
    int w[100001];
    int h, t;
    void clear()
    {
        h=t=0;
    }
    void append(long long a, int b)
    {
        while(h<t && q[t-1]<=a)
            t--;
        w[t]=b;
        q[t++]=a;
    }
    void filter(int x)
    {
        while(h<t && w[h]<x)
            h++;
    }
    long long getmax()
    {
        return q[h];
    }
} dq;

int main()
{
    scanf("%d%d%d", &N, &M, &K);
    for(int i=1; i<=N; i++)
        scanf("%d", A+i), dp[1][i]=A[i];
    for(int i=2; i<=K; i++)
    {
        dq.clear();
        dq.append(dp[i-1][i-1], i-1);
        for(int j=i; j<=N; j++)
        {
            dq.filter(j-M);
            dp[i][j]=dq.getmax()+1LL*A[j]*i;
            dq.append(dp[i-1][j], j);
        }
    }
    printf("%lld\n", *max_element(dp[K]+1, dp[K]+1+N));
    return 0;
}


Measured memory_bytes: 235648
N = int(input())						# 5
A = sorted(list( map(int, input().split()) ))	# 1 2 3 4 5 ...(ソート付き)

ANS=[]

a=A[0]
z=A[-1]

s=0
t=0

for i in A[1:-1]:
	if i>=0:
		ANS.append((a,i))
		a = a-i
	else:
		ANS.append((z,i))
		z = z-i


ANS.append((z,a))

print(z-a)
for a in ANS:
	print(*a)



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

int main(){
    int A, B, M; cin >> A >> B >> M;
    vector<int> a(A), b(B);
    for(int i = 0; i < A; ++i) {
        cin >> a[i];
    }

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

    vector<int> x(M), y(M), c(M);
    for(int i = 0; i < M; ++i) {
        cin >> x[i] >> y[i] >> c[i];
    }

    int min_res = 10000007;
    for(int i = 0; i < M; ++i) {
        int comp = a[x[i] - 1] + b[y[i] - 1] - c[i];
        if(min_res > comp) {
            min_res = comp;
        }

        if(i == M - 1) {
            int min_ele = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
            if(min_res > min_ele) {
                min_res = min_ele;
            }
        }
    }

    cout << min_res << endl;
}

Measured memory_bytes: 2176
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
left = [0]*n
right = [0]*n
left[0] = a[0]
right[n-1] = a[n-1]
for i in range(1,n):
  left[i] = gcd(left[i-1],a[i])
  right[n-1-i] = gcd(right[n-i],a[n-1-i])
ans = max(right[1],left[n-2])
for i in range(1,n-1):
  ans = max(ans,gcd(left[i-1],right[i+1]))
print(ans)

Measured memory_bytes: 16124
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String args[]) {
        BufferedReader br = null;
 
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            String line = br.readLine();
            String[] tmp = line.split(" ");
            int n = Integer.parseInt(tmp[0]);
            int m = Integer.parseInt(tmp[1]);
 
            String[] imageN = new String[n];
            for (int i = 0; i < n; i++) {
                line = br.readLine();
                imageN[i] = line;
            }
 
            String[] imageM = new String[m];
            for (int i = 0; i < m; i++) {
                line = br.readLine();
                imageM[i] = line;
            }
 
            boolean found = false;
            //image n
            for (int i = 0; i <= n - m; i++) {
                for (int j = 0; j <= n - m; j++) {
              
                    boolean exist = true;
                    for (int c = 0; c < m; c++) {
                         String s1 = imageN[i + c].substring(j);
                         if(s1.indexOf(imageM[c]) != 0) {
                             exist = false;
                         }
                    }
                    if(exist) {
                        found = true;
                        break;
                    }
                }
                if(found) {
                    break;
                }
            }
 
            if (found) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
 
        } catch (Exception ex) {
            System.out.println("wrong input");
        }
    }
}

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

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

  if (n == 2) {
    if (k == 0) {
      cout<<1<<endl;
      cout<<"1 2"<<endl;
    } else {
      cout<<-1<<endl;
    }
    return 0;
  }
  if ((n - 1) * (n - 2) < 2 * k) {
    cout<<-1<<endl;
    return 0;
  }
  int n_edge = n - 1 + (n - 1) * (n - 2) / 2 - k;
  cout<<n_edge<<endl;
  for (int i=2; i<=n; i++) {
    cout<<"1 "<<i<<endl;
  }
  n_edge -= n - 1;
  for (int j=2; j<=n; j++) {
    for (int k=j+1; k<=n && n_edge>0; k++) {
      cout<<j<<" "<<k<<endl;
      --n_edge;
    }
  }

}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	string S;
	cin >> S;
	int ans = 0;
	fx(S.size()) {
		if (S.at(x) == 'o') {
			ans++;
		}
	}
	if ((15 - S.size()) + ans >= 8) {
		ce("YES")
	}
	else {
		ce("NO")
	}
    return 0;
}



Measured memory_bytes: 256
N = int(input())
prime = [True] * 55556
prime[0] = False
prime[1] = False
for i in range(4,55556,2):
    prime[i] = False
for i in range(3,55556):
    if prime[i] == True:
        for j in range(i*2,55556,i):
            prime[j] = False
lis = []
for i in range(55556):
    if prime[i] == True and i % 5 == 1:
        lis.append(i)
    if len(lis) == N:
        break

print(' '.join(map(str,lis)))


Measured memory_bytes: 68156
#include<bits/stdc++.h>
#define int long long
#define INF 1<<25
using namespace std;

int N,W;
int ans;
int v[1010],w[1010];
int mem[10100][10100];

int dfs(int n,int h){
    if(n==0){
        ans=0;
    }
    else if(mem[n][h]!=0)ans=mem[n][h];
    else if(w[n]>h)ans=dfs(n-1,h);
    else {
        ans=max(dfs(n-1,h),dfs(n-1,h-w[n])+v[n]);
    }
    return mem[n][h]=ans;
}

signed main(){
    cin>>N>>W;
    for(int i=1;i<=N;i++){
        cin>>v[i]>>w[i];
    }
    cout<<dfs(N,W)<<endl;
}

Measured memory_bytes: 9356
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int ans1 = -1;
    int ans2 = -1;
    for(int i = 0; i < s.length() - 1; i++) {
      if(s.charAt(i) == s.charAt(i + 1)) {
        ans1 = (i + 1);
        ans2 = (i + 2);
      }
    }
    for(int i = 0; i < s.length() - 2; i++) {
      if(s.charAt(i) == s.charAt(i + 2)) {
        ans1 = (i + 1);
        ans2 = (i + 3);
      }
    }
    System.out.println(ans1 + " " + ans2);
  }
}

Measured memory_bytes: 24912
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int nodeSize = 4;
        int edgeSize = 3;
        List<Integer[]> edgeList = new ArrayList<>();
        for (int i = 0; i < edgeSize; i++) {
            int nodeFrom = Integer.parseInt(sc.next());
            int nodeTo = Integer.parseInt(sc.next());
            edgeList.add(new Integer[] { nodeFrom, nodeTo });
        }
        sc.close();

        Map<Integer, HashSet<Integer>> graph = createGraph(nodeSize, edgeList, false);
        int start = 1;
        int target = 4;
        int distance = getDistance(nodeSize, graph, start, target);

        boolean judge = distance == 3;
        String result = judge ? "YES" : "NO";

        // 出力
        System.out.println(result);
    }

    public static Map<Integer, HashSet<Integer>> createGraph(int nodeSize, List<Integer[]> edgeList,
            boolean isDirected) {
        Map<Integer, HashSet<Integer>> graph = new HashMap<>();
        for (int i = 1; i <= nodeSize; i++) {
            graph.put(i, new HashSet<>());
        }
        if (isDirected) {
            for (Integer[] edge : edgeList) {
                graph.get(edge[0]).add(edge[1]);
            }
        } else {
            for (Integer[] edge : edgeList) {
                graph.get(edge[0]).add(edge[1]);
                graph.get(edge[1]).add(edge[0]);
            }
        }
        return graph;
    }

    public static int getDistance(int nodeSize, Map<Integer, HashSet<Integer>> graph, int start, int target) {
        Deque<Integer> deque = new ArrayDeque<>();
        deque.add(start);

        int[] distance = new int[nodeSize + 1];
        distance[start]++;

        int dist = 0;
        while (!deque.isEmpty()) {
            int point = deque.poll();
            if (point == target) {
                dist = distance[point] - 1;
                break;
            }
            for (int nextPoint : graph.get(point)) {
                if (distance[nextPoint] == 0) {
                    deque.add(nextPoint);
                    distance[nextPoint] = distance[point] + 1;
                }
            }
        }

        return dist;
    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
const int mod =1e9+7;
const int maxn=1e3+10;
long long int dp[maxn][maxn];
int n;
int m;
char p[maxn][maxn];
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>n>>m;
for(int i=0;i<n;i++){
	for(int j=0;j<m;j++){
		cin>>p[i][j];
	}
}
dp[0][0]=1;
for(int i=0;i<n;i++){
	for(int j=0;j<m;j++){
		if(p[i][j]=='.'){
			if(i>0){
				dp[i][j]+=dp[i-1][j];
			}
			if(j>0){
				dp[i][j]+=dp[i][j-1];
			}
			dp[i][j]%=mod;
		}
	}
}
cout<<dp[n-1][m-1];
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int n,m,a[1010],tot=0;
int main() {
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) {
		cin>>a[i];
		tot+=a[i];
	}
	sort(a+1,a+1+n);
	tot=ceil(tot/4.0/m);
	for(int i=n;i>=n-m+1;i--)
		if(a[i]<tot) {
			cout<<"No";
			exit(0);
		}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  string s;
  cin>>s;
  int n=s.size();
  ll c=0;
  for(int i=0;i<1<<(n-1);i++){
    ll num=s[0]-'0';
    for(int j=0;j<n-1;j++){
      if(i&1<<j){
        c+=num;
        num=0;
      }
      num=num*10+(s[j+1]-'0');
    }
    c+=num;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
#include <stack>
#include <queue>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <tuple>
#include <cmath>
#include <random>
#include <algorithm>
#include <vector>
#include <iostream>
#include <fstream>
#include <chrono>

#define fio ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

#define ri(x) i64 x; cin >> x
#define rii(x, y) i64 x, y; cin >> x >> y
#define ri3(x, y, z) i64 x, y, z; cin >> x >> y >> z
#define ri4(x, y, z, u) i64 x, y, z, u; cin >> x >> y >> z >> u
#define rvi(x, n) vi x(n); cin >> x
#define rvvi(x, n, m) vvi x(n, vi(m)); cin >> x
#define rx(x, t) t x; cin >> x

#define ws(x) cout << x << ' '
#define wl(x) cout << x << '\n'
#define wln cout << '\n'

#define dbg(x) cerr << '[' << #x << "]: " << x << '\n'

#define fa(x, v) for (auto &x : v)
#define fi(i, n) for (i32 i = 0; i < n; i++)
#define fp(i, n) for (i32 i = 1; i < n; i++)
#define fr(i, n) for (i32 i = n - 1; i >= 0; i--)
#define fu(x) ri(_x); fi(x, _x)

#define l first
#define r second
#define all(x) x.begin(), x.end()
#define bit(x) ((u64) 1 << (u32) (x))

using namespace std;

typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t i32;
typedef int64_t i64;
typedef vector<i64> vi;
typedef vector<vi> vvi;
typedef pair<i64, i64> pi;

template<typename T>
inline istream &operator>>(istream &in, vector<T> &v) {
    fa(x, v) in >> x;
    return in;
}

template<typename T>
inline ostream &operator<<(ostream &out, const vector<T> &v) {
    fa(x, v) ws(x);
    wln;
    return out;
}


int main() {
    fio;

    rii(n, k);
    rvi(a, n);
    fi(i, n - k) {
        if (a[i + k] > a[i]) wl("Yes"); else wl("No");
    }

    return 0;
}


Measured memory_bytes: 4784
#include <bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define lol        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define SIZE        1000005
#define debug(x)        cerr << #x << " = " << x << endl;

using namespace std;

void MOD(ll &x)
{
	if (x >= lol) x -= lol;
	if (x < 0) x += lol;
}


void solve()
{
	int n;
	cin>>n;
	int arr[2][n];
	rep(i,0,2)
	{
	    rep(j,0,n)
	    {
	        cin>>arr[i][j];
	    }
	}
	int dp[2][n];
	dp[0][0] = arr[0][0];
	dp[1][0] = dp[0][0] + arr[1][0];
	rep(i,1,n)
	{
	    dp[0][i] = dp[0][i-1] + arr[0][i];
	}
	rep(i,1,2)
	{
	    rep(j,1,n)
	    {
	        dp[i][j] = max(dp[i-1][j], dp[i][j-1]) + arr[i][j];
	    }
	}
	cout<<dp[1][n-1]<<endl;
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

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

int main(){
  
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  string ans = ((a+b) < (c+d)) ? "Right" :
               ((a+b) > (c+d)) ? "Left" : "Balanced";
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  int x;
  cin >> x;
  if(x == 3 || x == 5 || x == 7) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using ld = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

VB is_prime(100001, true);
VI table(100001, 0);

void Eratosthenes(auto limit)
{
  for (int i = 0; i*i <= limit; ++i)
  {
    if (i == 0 || i == 1) is_prime[i] = false;
    else if (is_prime[i]) for (int j = 2; i*j <= limit; ++j) is_prime[i*j] = false;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int Q;
  cin >> Q;
  Eratosthenes(100000);
  REP2(i, 1, 100001)
  {
    if (i % 2 == 0)
    {
      table[i] = table[i-1];
      continue;
    }
    if (is_prime[i] && is_prime[(i+1)/2]) table[i] = table[i-1] + 1;
    else table[i] = table[i-1];
  }
  REP(query, Q)
  {
    int l, r;
    cin >> l >> r;
    cout << table[r] - table[l-1] << endl;
  }

  return 0;
}

Measured memory_bytes: 1024
n = int(input())

c = []
for i in range(n):
    c.append(input())

ac = c.count("AC")
wa = c.count("WA")
tle = c.count("TLE")
re = c.count("RE")

print("AC x", ac)
print("WA x", wa)
print("TLE x", tle)
print("RE x", re)


Measured memory_bytes: 82568
#include <cstdio>
int main(void){
int n=0;
scanf("%d",&n);
int i=0;
int k=3;
for(i=1;i<20;i++){

if(n<=k)break;
if(i!=19)k*=3; 
else {i++;break;}
}
printf("%d\n",i);
return 0;
}

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

using namespace std;

typedef pair<int, int> P;

const int MAX = 2123456;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long sum(int x, int y)
{
    if ((long long)x * y == 0)
        return 0;
    long long res = 0;
    for (int i = 1; i <= y; i++)
    {
        res += COM(i + 1 + x, x);
        res += MOD - COM(i, 0);
        res %= MOD;
    }
    return res;
}

int main()
{
    COMinit();

    int r1, r2, c1, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    long long res = sum(r2, c2);
    res += MOD - sum(r1 - 1, c2);
    res += MOD - sum(r2, c1 - 1);
    res += sum(r1 - 1, c1 - 1);
    res %= MOD;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 50048
#include <iostream>
#include <string>

int main() {
	std::string S, T;

	std::cin >> S;
	std::cin >> T;

	int len_s = S.length();
	int len_t = T.length();

	// std::cout << len_s << ", " << len_t << std::endl;


	T.erase(len_t - 1, len_t);
	// std::cout << T << std::endl;

	if (len_t - len_s != 1) {
		std::cout << "No" << std::endl;
	}
	else if (S != T) {
		std::cout << "No" << std::endl;
	}
	else {
		std::cout << "Yes" << std::endl;
	}

	

	return 0;
}

Measured memory_bytes: 3628
H, W = map(int, input().split())
s = [[i for i in input()]for i in range(H)]
maze = [[False for i in range(W)] for i in range(H)]
bknum = 0
for i in range(H):
    for j in range(W):
        if s[i][j]==".":
            maze[i][j]=True
        else:
            maze[i][j]=False
            bknum += 1


def ncell(i, j):
    tmp = [[i-1,j],[i+1,j],[i,j-1],[i,j+1]]
    out = []
    for p in tmp:
        if 0<=p[0]<H and 0<=p[1]<W and maze[i][j]:
            out.append(p)
    return out

d = [[1000 for j in range(W)] for i in range(H)]
prev = [[-1 for j in range(W)] for i in range(H)]
d[0][0]=0
Q = set()
for i in range(H):
    for j in range(W):
        if maze[i][j]:
            Q.add(i*W+j)
while(len(Q)!=0):
    u = list(Q)[0]
    du = d[u//W][u%W]
    for v in Q:
        if d[v//W][v%W]<du:
            du = d[v//W][v%W]
            u=v
    Q -=set([u])
    for v in ncell(u//W, u%W):
        if d[v[0]][v[1]]>d[u//W][u%W]+1:
            d[v[0]][v[1]]=d[u//W][u%W]+1
            prev[v[0]][v[1]]=u
length=d[H-1][W-1]
if length != 1000:
    print(H*W-length-1-bknum)
else:
    print(-1)


Measured memory_bytes: 44508
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

int main() {
    int N;
    cin >> N;
    long long ans = 0, min_ = 1e10, cnt = 0;
    bool zero = false;
    for (int i = 0; i < N; i++) {
        long long A;
        cin >> A;
        if (A < 0)cnt++;
        else if (A == 0)zero = true;
        ans += abs(A);
        min_ = min(min_, abs(A));
    }
    
    
    if (zero)cout << ans << endl;
    else if (cnt % 2 == 0)cout << ans << endl;
    else cout <<ans - 2*min_ << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	double a, b, h, m;
	const double pi = 3.14159265358979;
	cin >> a >> b >> h >> m;
	double gosa  = (m/60.0)*30.0;
	double kakudo = (double)abs(30*h+gosa - 6*m);
	double sita = (kakudo / 180.000)*pi;
	double ans = powl(a*a+b*b-2*a*b*cos(sita), 0.5);
	cout << fixed << setprecision(15) << ans << endl;
	return 0;
}


Measured memory_bytes: 4256
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    import bisect
    n=int(input())
    la=list(map(int,input().split()))
    lb=list(map(int,input().split()))
    lc=list(map(int,input().split()))
    la.sort()
    lb.sort()
    lc.sort()
    ans=0
    for i in lb:
        ans1=bisect.bisect_left(la,i)
        ans2=len(lc)+-bisect.bisect_right(lc,i)
        ans+=ans1*ans2
    print(ans)
resolve()

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

using namespace std;

int main(void)
{
	int n;
	double x[11];
	string u[11];
	double sum = 0;

	cin >> n;

	for (int i = 0;i < n;i++)
	{
		cin >> x[i];
		cin >> u[i];
		if (u[i] == "BTC")
			x[i] = x[i] * 380000.0;

		sum += x[i];

	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
const ll MD = 1000000007;

/* sample input

*/

int main()
{
	ll x, y;

	cin >> x >> y;

	if (x%y == 0) {
		cout << -1;
	}
	else {
		for (ll i = 1; i < 1000000; i++) {
			if (x * i % y != 0) {
				cout << x*i;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

int N,K,X,Y;

signed main(){

    in(N,K,X,Y);
    out(X*min(K,N)+Y*max(0LL,(N-K)));

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int[] change_input = new int[input.Length];
            change(input, change_input);
            string[] date = Console.ReadLine().Split();
            int[] change_date = new int[date.Length];
            change(date, change_date);
            int sum = change_date.Sum();
            if(change_input[0] >= sum)
            {
                sum = change_input[0] - sum;
            }
            else
            {
                sum = -1;
            }
            Console.WriteLine(sum);
            Console.Read();
        }
        public static void change(string[] x, int[] y)
        {
            for(int i = 0; i < x.Length; i++)
            {
                y[i] = int.Parse(x[i]);
            }
        }
    }
}


Measured memory_bytes: 28748
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  int n; cin>>n;
  string s; cin>>s;
  const int len = s.size();
  vector<int> acc_w(len+1); // W の累積和
  vector<int> acc_e(len+1); // E の累積和
  acc_w[0] = 0; acc_e[len] = 0;
  for(int i=0; i<len; i++) {
    acc_w[i+1] = acc_w[i] + (s[i] == 'W' ? 1 : 0);
  }

  for(int i=len; i>=1; i--) {
    acc_e[i-1] = acc_e[i] + (s[i-1] == 'E' ? 1 : 0);
  }

  int ans = INF;
  for(int i=0; i<=len; i++) {
    ans = min(ans, acc_w[i] + acc_e[i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2964
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class D { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		var S = GetString().ToCharArray();

		long cnt = 0;
		for(long i = 0; i < S.Length; i++)
		{
			if(S[i] == 'g')
			{
				if(i % 2 == 1)
					cnt++;
			}
			else
			{
				if(i % 2 == 0)
					cnt--;
			}
		}
		WriteLine(cnt);
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 26460
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

// const int dx[4] = { 1, 0, -1, 0 };
// const int dy[4] = { 0, 1, 0, -1 };

const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  string s;cin>>s;
  int ans = 0;
  int cnt = 0;
  rep(i,s.size()){
    if(s[i] == 'R')cnt++;
    else{
      ans = max(ans,cnt);
      cnt = 0;
    }
  }
  ans = max(ans,cnt);
  print(ans);
  return 0;
}

Measured memory_bytes: 3528
n = gets.to_i
arr = gets.split(' ').map(&:to_i).sort.reverse

alice = arr.select.with_index { |_, i| i % 2 == 0 }
bob = arr.select.with_index { |_, i| i % 2 == 1 }

puts alice.inject(:+) - bob.inject(:+)


Measured memory_bytes: 1788
#include <iostream>
#include <numeric>

using namespace std;
 
int main() {
  int K;
  int sum = 0;
  
  cin >> K;
  for (int i = 1; i <= K; i++) {
    for (int j = 1; j <= K; j++) {
      for (int k = 1; k <= K; k++) {
        sum += gcd(gcd(i, j), k);
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3636
<?php
 
function input($func = null)
{
    if ($func === null) {
        return trim(fgets(STDIN));
    } else {
        return $func(trim(fgets(STDIN)));
    }
}

function input_array($func = null)
{
    if ($func === null) {
        return explode(' ', input());
    } else {
        return array_map(function ($v) use ($func) {
            return $func($v);
        }, explode(' ', input()));
    }
}

list($X, $Y, $Z) = input_array('intval');

echo sprintf(
    "%d %d %d\n",
    $Z,
    $X,
    $Y
);


Measured memory_bytes: 4728