akhauriyash/Code-Regression huggingface dataset:
// WIP

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

// Utility
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, X, Y) for (int I = (X); I < (Y); I++)
using ll = int64_t;
using ull = uint64_t;
template<typename T> struct is_container {
template<typename C> static char test(typename C::const_iterator*); template<typename> static int test(...);
static bool const value = sizeof(test<T>(nullptr)) == sizeof(char) && !std::is_same<std::string, T>::value;
};
namespace std {
template<class ...Ts>        istream& operator>>(istream& i, tuple<Ts...>& x) { apply([&](auto&&... ys){ ((i >> ys), ...); }, x); return i; }
template<class T1, class T2> istream& operator>>(istream& i, pair<T1, T2>& x) { i >> x.first >> x.second; return i; }
template<class T, enable_if_t<is_container<T>::value, int> = 0>
istream& operator>>(istream& i, T& x) { for (auto& y : x) { i >> y; } return i; }
}

// Debugging
#ifndef DEBUG
#define DEBUG 0
#endif
#define dbg(X) do { if (DEBUG) { cout << #X ": " << (X) << endl << flush; } } while (0)
#define dbg2(X) do { if (DEBUG) { cout << #X ":" << endl; for (auto& __x : (X)) { cout << __x << endl << flush; } } } while (0)
#define dbgv(...) do { if (DEBUG) { cout << "(" #__VA_ARGS__ "): " << make_tuple(__VA_ARGS__) << endl << flush; } } while (0)
namespace std {
template<class ...Ts>        ostream& operator<<(ostream& o, const tuple<Ts...>& x) { o << "("; apply([&](auto&& y, auto&&... ys){ o << y; ((o << ", " << ys), ...); }, x); o << ")"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const pair<T1, T2>& x) { o << tie(x.first, x.second); return o; }
template<class T, enable_if_t<is_container<T>::value, int> = 0>
ostream& operator<<(ostream& o, const T& x) { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
}

// DSU
struct Dsu {
  int n;
  vector<int> ps;
  Dsu(int _n) { n = _n; ps.resize(n); iota(ALL(ps), 0); }
  int find(int a) {
    if (a == ps[a]) { return a; }
    return ps[a] = find(ps[a]);
  }
  void merge(int dst, int src) {
    ps[find(src)] = find(dst);
  }
};

// Main
void mainCase() {
  int n, m;
  cin >> n >> m;
  vector<array<int, 2>> edges(m);
  cin >> edges;

  Dsu dsu(n);
  for (auto [x, y] : edges) {
    x--; y--;
    dsu.merge(x, y);
  }

  set<int> compos;
  FOR(v, 0, n) { compos.insert(dsu.find(v)); }

  int res = compos.size() - 1;
  cout << res << endl;
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  mainCase();
  return 0;
}

/*
python misc/run.py atcoder/abl0/c/main.cpp --check

%%%% begin
3 1
1 2
%%%%
1
%%%% end
*/


Measured memory_bytes: 7636
#include <iostream>

int main() {
  int x, y;
  std::cin >> x >> y;
  int a[] = { 1, 3, 5, 7, 8, 10 };
  int b[] = { 4, 6, 9, 11 };

  bool flag = (x == y);
  if ( flag ) {
    std::cout << "Yes" << std::endl;
    return 0;
  }

  for (int i = 0; i < 6; ++i) {
    if ( a[i] == x ) {
      for (int j = 0; j < 6; ++j) {
        if ( a[j] != y ) continue;
        flag = true;
        break;
      }
      break;
    }
  }
  if ( flag ) {
    std::cout << "Yes" << std::endl;
    return 0;
  }

  for (int i = 0; i < 4; ++i) {
    if ( b[i] == x ) {
      for (int j = 0; j < 4; ++j) {
        if ( b[j] != y ) continue;
        flag = true;
        break;
      }
      break;
    }
  }
  if ( flag ) {
    std::cout << "Yes" << std::endl;
    return 0;
  }

  std::cout << "No" << std::endl;

  return 0;
}


Measured memory_bytes: 256
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-12 21:04:34
*/

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

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int k;
    cin >> k;
    LL ans = 0;
    for (int a = 1; a <= k; a++) {
        for (int b = 1; b <= k; b++) {
            for (int c = 1; c <= k; c++) {
                ans += gcd(a, gcd(b, c));
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define ll long long
#define ull unsigned ll
#define all(x) x.begin(), x.end()
const int M = 1e9 + 7;


int main() {
    int n, x;
    cin >> n >> x;
    int l[n];
    for (int i = 0; i < n; ++i) {
        cin >> l[i];
    }
    int p = 0, ans = 1;
    for (int j = 0; j < n; ++j) {
        int y = p + l[j];
        if (y <= x)
            ans++;
        p = y;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,m,x[200001],y[200001],z[200001],val[200001],ans=0;
int d[2]={1,-1};
signed main(){
	scanf("%lld%lld",&n,&m);
	for(int i=0;i<n;i++)	scanf("%lld%lld%lld",x+i,y+i,z+i);
	for(int p=0;p<2;p++)
		for(int q=0;q<2;q++)
			for(int r=0;r<2;r++){
				memset(val,0,sizeof(val));
				for(int i=0;i<n;i++)
					val[i]=d[p]*x[i]+d[q]*y[i]+d[r]*z[i];
				sort(val,val+n);
				int sum=0;
				for(int i=0;i<m;i++)
					sum+=val[n-i-1];
				ans=max(ans,sum);
			}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5888
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
class ParseError {};
struct Result{
  ll value;
  int p;
  Result(ll value, int p) : value(value), p(p) {}
};
void skip(const string& s, Result& r, char expected){
  if(s[r.p] == expected){
    r.p++;
  }else {
    cerr << "try to skip'" << expected << "' but this char is '" << s[r.p] << "'." << endl;
    assert(false);
  }
}
Result expression(const string& s, int p, const int MOD);
Result term(const string& s, int p, const int MOD);
Result factor(const string& s, int p, const int MOD);
int inverse(int x, const int MOD){
  int res = 1;
  int pow = MOD - 2;
  while(pow != 0){
    if(pow & 1) res = (res * x) % MOD;
    pow >>= 1;
    x = (x * x) % MOD;
  }
  return res;
}
Result expression(const string& s, int p, const int MOD){
  Result r = term(s, p, MOD);
  while(s[r.p] == '+' || s[r.p] == '-'){
    Result r_ = term(s, r.p + 1, MOD);
    if(s[r.p] == '+'){
      r.value = (r.value + r_.value) % MOD;
    }else{
      r.value = (r.value - r_.value + MOD) % MOD;
    }
    r.p = r_.p;
  }
  return r;
}
Result term(const string& s, int p, const int MOD){
  Result r = factor(s, p, MOD);
  while(s[r.p] == '*' || s[r.p] == '/'){
    Result r_ = factor(s, r.p + 1, MOD);
    if(s[r.p] == '*'){
      r.value = (r.value * r_.value) % MOD;
    }else{
      if(r_.value == 0) throw ParseError();
      r.value = (r.value * inverse(r_.value, MOD)) % MOD;
    }
    r.p = r_.p;
  }
  return r;
}
Result factor(const string& s, int p, const int MOD){
  if(s[p] == '('){
    Result r = expression(s, p + 1, MOD);
    skip(s, r, ')');
    return r;
  }else{
    int val = 0;
    while(isdigit(s[p])){
      val = val * 10 + s[p++] - '0';
    }
    return Result(val, p);
  }
}
int main(){
  string line;
  while(getline(cin, line)){
    if(line == "0:") break;
    REP(i, line.size()) if(line[i] == ':') line[i] = ' ';
    stringstream ss(line);
    string mod_str;
    ss >> mod_str;
    string expr, s;
    while(ss >> s) expr += s;
    int mod;
    sscanf(mod_str.c_str(), "%d", &mod);
    try{
      int val = expression(expr, 0, mod).value;
      printf("%s = %d (mod %d)\n", expr.c_str(), val, mod);
    }catch(...){
      cout << "NG" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,count,error=0;
  cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
  cin>>vec.at(i);
  }
  while(error<1){
    for(int i=0;i<N;i++){
    if(vec.at(i)%2==1){error++;}
    vec.at(i)/=2;
    }
    count++;
  }
  cout<<count-1<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner t=new Scanner(System.in);
		int X=t.nextInt(), A=t.nextInt();
		if(X<A) {
			System.out.println(0);
		}else {
			System.out.println(10);
		}
	}
}

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

int64_t gcd(int64_t a,int64_t b)
{
	if (a%b==0)return(b);
    else return(gcd(b,a%b));
}


int64_t lcm(int64_t m, int64_t n)
{
	return m * n / gcd(m,n); 
}

int main() {
  int64_t A,B,C,D;
  cin >> A >> B >> C >> D;
  
  int64_t N = B - A + 1;
  A--;
  int64_t divC = (B / C) - (A / C);
  int64_t divD = (B / D) - (A / D);
  
  int64_t tmpLCM = lcm(C,D);
  
  int64_t divCD = (B / tmpLCM) - (A / tmpLCM);    
  
  cout << N - (divC + divD - divCD) << endl;
  return 0;
}



Measured memory_bytes: 256
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n, u, v;
vector<vector<int> > a(100000);
vector<bool> used(100000,false);
vector<bool> usedt(100000,false);
int depa[100000];
int dept[100000];
void dfsa(int node,int d){
    depa[node]=d;
    used[node]=true;
    for(int i=0;i<a[node].size();i++){
        if(used[a[node][i]])continue;
        dfsa(a[node][i],d+1);
    }
}
void dfst(int node,int d){
    dept[node]=d;
    usedt[node]=true;
    for(int i=0;i<a[node].size();i++){
        if(usedt[a[node][i]])continue;
        dfst(a[node][i],d+1);
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>u>>v;
    u--;
    v--;
    for (int i = 0; i < n-1; i++)
    {
        int temp, temp1;
        cin >> temp>>temp1;
        temp--;
        temp1--;
        a[temp].push_back(temp1);
        a[temp1].push_back(temp);
    }
    dfsa(v,0);
    dfst(u,0);
    int ans=-1;
    int ansi=0;
    for(int i=0;i<n;i++){
        if(depa[i]>dept[i]){
            if(ans<depa[i]){
                ansi=i;
                ans=depa[i];
            }
        }
    }
    cout <<depa[ansi]-1<< "\n";
}



Measured memory_bytes: 9088
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
b = int(input())

print(a[b-1])

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

int main() {
    int a, b;
    cin >> a >> b;
    if (b % a  == 0)
    cout << a + b << endl;
    else cout << b - a << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
	int n;
	scanf("%d",&n);
	int x[n];
	int y[n];
	int i;
	for(i=0;i<n;i++){
		scanf("%d %d",&x[i],&y[i]);
	}
	double a,b;
	double sum=0;
	int j;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			a = x[i]-x[j];
			b = y[i]-y[j];
			sum = sum + sqrt(a*a + b*b);
		}
	}
	printf("%f",sum*(n-1)/n/(n-1));
	
return(0);
}

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

int main(){
  int n;
  int k;
  cin >> n >> k;
  k -= 1;
  
  vector<int> H;
  for (int i=0;i<n;i++){
    int h;
    cin >> h;
    H.push_back(h);
  }
  std::sort(H.begin(),H.end());
  
  int ans = std::pow(10,9);

  for (int i=0;i<n-k;i++){
    //cout << H[i] << H[i+k] << endl;
    ans = min(ans,H[i+k]-H[i]);  
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 892
import Foundation

func main(){
   let n = Int(readLine()!)!
   let aArray = (readLine()!).split(separator: " ").map({ Int($0)! }).sorted(by: { $0 > $1})
   
   guard aArray.count > 1 else { print(0); return}
   var answer = aArray[0]
   
   var count = 0
   var j = 1
   var i = 1
   while i < n - 1 {
      if count < 2 {
         answer += aArray[j]
         count += 1
      } else {
         j += 1
         count = 1
         answer += aArray[j]
      }
      i += 1
   }
   
   print(answer)
}
main()

Measured memory_bytes: 26496
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
using namespace __gnu_pbds;

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

typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)
const int N = 104;

long long memo[N][2][4];
string s;
long long solve(int indx , bool gr , int rem){
   if(indx == s.size())
      return (rem == 0);
   long long &ret = memo[indx][gr][rem];
   if(~ret)
      return ret;
   ret = 0;
   int num = s[indx] - '0' , theOne = (gr ? 9 : num);
   for(int i = 0 ; i <= theOne ; ++i){
      if(!i || (i && rem))ret += solve(indx + 1 , gr || (i < num) , rem - (i > 0));
   }
   return ret;
}
int main() {
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   cin >> s;
   int k;
   cin >> k;
   memset(memo , -1 , sizeof(memo));
   cout << solve(0 , 0 , k) << "\n";
}

Measured memory_bytes: 256
package main
 
import (
    "fmt"
    "math"
)
 
func main() {
    var x1, x2, y1, y2 float64
    fmt.Scan(&x1, &y1, &x2, &y2)
    fmt.Println(math.Sqrt(math.Pow(x1 - x2, 2) + math.Pow(y1 - y2, 2)))
}


Measured memory_bytes: 1184
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args){
		try(Scanner sc=new Scanner(System.in)){
			while(sc.hasNextLine()) {
				String str=sc.nextLine();
				String[] tokens=str.split(" ");
				int W=0;
				int[] r=new int[13];
				int n=0;
				for(String s:tokens) {
					if(W==0) W=Integer.parseInt(s);
					else r[n-1]=Integer.parseInt(s);
					n++;
				}
				n--;
				//dp[今までの頂点][現在地]=左からどこにいるか
				double[][] dp=new double[1<<n][n];
				double INF=1<<28;
				for(int i=0; i<(1<<n); i++) {
					for(int j=0; j<n; j++) {
						dp[i][j]=INF;
					}
				}
				for(int i=0; i<n; i++) {
					dp[1<<i][i]=2*r[i];
				}
				for(int i=0; i<(1<<n); i++) {
					for(int j=0; j<n; j++) {
						if(dp[i][j]==INF)	continue;
						for(int k=0; k<n; k++) {
							if((1&i>>k)==1)	continue;
							int nexti=i|(1<<k);
							double nextdp=dp[i][j]-r[j]+Math.sqrt((r[j]+r[k])*(r[j]+r[k])-(r[j]-r[k])*(r[j]-r[k]))+r[k];
							dp[nexti][k]=Math.min(dp[nexti][k], nextdp);
						}
					}
				}
				double min=INF;
				for(int i=0; i<n; i++) {
					min=Math.min(min, dp[(1<<n)-1][i]);
				}
				System.out.println(min<=W? "OK":"NA");
			}
		}
	}	
}


Measured memory_bytes: 35088
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v){
    if(v.empty()){
        os<<"{ }";
        return os;
    }
    os<<"{"<<v.front();
    for(auto itr=++v.begin();itr!=v.end();itr++){
        os<<", "<<*itr;
    }
    os<<"}";
    return os;
}

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll R,C,k; cin>>R>>C>>k;
    vector<vector<ll>> m(R,vector<ll>(C,-1));
    rep(i,k){
        ll r,c,v; cin>>r>>c>>v;
        r--; c--;
        m[r][c]=v;
    }
    vector<vector<vector<ll>>> dp(4,vector<vector<ll>>(R+1,vector<ll>(C,-1)));
    dp[0][0][0]=0;
    rep(i,R)rep(j,C)for(int K=3;K>=0;K--){
        if(K>0 && m[i][j]>-1){
            if(dp[K-1][i][j]>-1)
            dp[K][i][j]=max(dp[K][i][j],dp[K-1][i][j]+m[i][j]);
        }
        if(j!=C-1) dp[K][i][j+1]=max(dp[K][i][j+1],dp[K][i][j]);
         dp[0][i+1][j]=max(dp[0][i+1][j],dp[K][i][j]);
    }
    ll ans=0;
    rep(i,4)rep(j,C) ans=max(ans,dp[i][R][j]);
    cout<<ans<<endl;
}


Measured memory_bytes: 425016
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for i in range(A+1):
    for j in range(B+1):
        now = X - 500 * i - 100 * j
        if now >= 0 and now // 50 <= C:
            ans += 1

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(ll i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll N,K;
    cin>>N>>K;
    ll sum;
    sum = 0;
    rep(i,K,N+2){
        sum += ((2*N-i+1)*i/2)-((i-1)*i/2) +1;
        sum %= MOD;
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;

long long int solve(vector<long long int> a,int n,int k) {
    sort(a.begin(),a.end());
//    case 1
    if(a[n-1]==0 && k&1) {
        return 0;
    }

    //case 2
    if(a[n-1]<0 && k%2!=0) {
        long long int prod = 1;
        for(int i=n-1;i>=(n-k);i--) {
            prod = (a[i]*prod)%MOD;
        }
        return ((prod%MOD)+MOD)%MOD;
    }
    long long int prod=1;
    int i=0;
    int j=n-1;
    if(a[n-1]>0 && k%2!=0) {
        prod = (prod*a[n-1])%MOD;
        k--;
        j--;
    }

    k = k/2;

    for(int p=0;p<k;p++) {
        long long int left = a[i]*a[i+1];
        long long int right = a[j]*a[j-1];
        if(left>right) {
            prod=prod * a[i]%MOD * a[i+1]%MOD;
            i+=2;
        }
        else {
            prod = prod * a[j]%MOD * a[j-1]%MOD;
            j-=2;
        }
    }
    if(prod<0)
        return ((prod%MOD)+MOD)%MOD;
    else
        return prod%MOD;
}
int main() {
    int n;
    cin>>n;
    int k;
    cin>>k;
    vector<long long int> a(n);
    for(int i=0;i<n;i++) {
        cin>>a[i];
    }
    cout<<solve(a,n,k)%MOD<<'\n';
    return 0;
}

Measured memory_bytes: 6392
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
	"strings"
)

const (
	TooLarge = math.MaxInt64
	TooSmall = math.MinInt64
)

func main() {
	scanner := makeWordScanner()
	s := eGetLine(scanner)
	r := s[0]
	for i := 1; i < len(s); i++ {
		if s[i] != r {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func pow(a, n int) int {
	if n == 0 {
		return 1
	}
	if n == 1 {
		return a
	}
	if n%2 == 1 {
		return pow((a*a), n/2) * a
	}
	return pow((a * a), n/2)
}
func powMod(a, n, mod int) int {
	if n == 0 {
		return 1 % mod
	}
	if n == 1 {
		return a % mod
	}
	if n%2 == 1 {
		return powMod((a*a)%mod, n/2, mod) * a % mod
	}
	return powMod((a*a)%mod, n/2, mod)
}

func factoricalMod(n, count, mod int) int {
	if count == 1 {
		return n % mod
	}
	return (n % mod) * (factoricalMod(n-1, count-1, mod)) % mod
}

func combinationMod(n, a, mod int) int {
	x := factoricalMod(n, a, mod)
	y := factoricalMod(a, a, mod)
	y = powMod(y, mod-2, mod)
	return ((x % mod) * (y % mod)) % mod
}
func countBitOfOn(i, numbits int) int {
	count := 0
	var bit uint64
	for bit = 0; bit < uint64(numbits); bit++ {
		t := 1 << bit
		if i&t > 0 {
			count++
		}
	}
	return count
}


Measured memory_bytes: 640
#include<bits/stdc++.h> 
using namespace std;
int main() {
 string S,T;
 string temp;
 cin >> S >> T;
 if(S.length() <= 10) {
	 temp = T;
	 temp = T.substr(0,T.length()-1);
	 if( (S.compare(temp) == 0) && T.length() == (S.length() + 1)) {
		 cout << "Yes";
	 }else 
	 	cout << "No";
 }else
	cout << "No";
 return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <queue>

using namespace std;

#define MAX_H 30
#define MAX_W 30
#define INF (1<<29)

struct State{
  int cost,x,y,dir;
  State(int cost,int x,int y,int dir) :
    cost(cost),x(x),y(y),dir(dir) {}

  bool operator < (const State &s)const{
    return cost > s.cost;
  }
};

int H,W,c[4];
int s[MAX_H][MAX_W];
int dx[] = {-1,0,1,0};
int dy[] = {0,-1,0,1};

bool inField(int x,int y){
  return (0 <= x && x < W && 0 <= y && y < H);
}

int dijkstra(){
  int d[MAX_H][MAX_W][4];
  fill(d[0][0],d[0][0]+MAX_H*MAX_W*4,INF);
  d[0][0][2] = 0;
  priority_queue<State> Q;
  Q.push(State(0,0,0,2));
  while(!Q.empty()){
    State cur = Q.top(); Q.pop();
    int x = cur.x,y = cur.y,dir = cur.dir;
    if(d[y][x][dir] < cur.cost) continue;
    if(x == W-1 && y == H-1) return d[y][x][dir];
    for(int i = 0 ; i < 4 ; i++){
      int ndir = (dir+i)%4;
      int nx = x + dx[ndir];
      int ny = y + dy[ndir];
      if(!inField(nx,ny)) continue;
      if(s[y][x] == i){
	if(d[y][x][dir] < d[ny][nx][ndir]){
	  d[ny][nx][ndir] = d[y][x][dir];
	  Q.push(State(d[ny][nx][ndir],nx,ny,ndir));
	}
      }else{
	if(d[y][x][dir] + c[i] < d[ny][nx][ndir]){
	  d[ny][nx][ndir] = d[y][x][dir] + c[i];
	  Q.push(State(d[ny][nx][ndir],nx,ny,ndir));
	}
      }
    }
  }
  return -1;
}

int main(){
  while(true){
    cin >> W >> H;
    if(W == 0 && H == 0) break;
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
	cin >> s[i][j];
      }
    }
    for(int i = 0 ; i < 4 ; i++){
      cin >> c[i];
    }
    cout << dijkstra() << endl;
  }
  return 0;
}

Measured memory_bytes: 1328
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint N, M, Q, L, R, p, q;
lint sums[501][501];
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N >> M >> Q;
	REP(i, M) {
		cin >> L >> R; 
		sums[L][R]++; L--;
	}
	REP(i, N) {
		REP(j, N) {
			sums[i][j + 1] += sums[i][j];
		}
	}

	vector<lint> ans;
	REP(i, Q) {
		cin >> p >> q;
		lint sum = 0;
		REP(i, q - p + 1) {
			sum += (sums[p + i][q] - sums[p + i][p - 1]);
		}
		ans.push_back(sum);
	}
	REP(i, Q) {
		cout << ans[i] << endl;
	}
}


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

int main() {
int q,a[100001]={0};
bool p[100001];
for(bool &x:p){
    x=true;
}
p[0]=p[1]=false;
for(int i=2;i<317;i++){
    if(p[i]){
        for(int j=2;j*i<=100000;j++){
            p[j*i]=false;
        }
    }
}

for(int i=3;i<=100000;i+=2){
    a[i]=a[i-1]=a[i-2];
    if(p[i]&&p[(i+1)/2]){
        a[i]++;
    }
}
cin>>q;
for(int i=0;i<q;i++){
    int l,r;
    cin>>l>>r;
    cout<<a[r]-a[l-1]<<endl;
}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>

using namespace std;

#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)

int main() {
    string S;
    cin >> S;
    long long sum_ = 0;

    repp(bit, 0, 1 << ((S.size() - 1))) {
        long long d = S[0] - '0';
        repp(i, 1, S.size()) {
            if (bit & (1 << (i - 1)))
                d = d * 10 + (S[i] - '0');
            else {
                sum_ += d;
                d = S[i] - '0';
            }
        }
        sum_ += d;
    }
    cout << sum_ << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<math.h>

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string w; 
  string check = "abcdefghijklmnopqrstuvwxyz";
  int count = 0, found = -1, flag = 0;

  cin >> w;

  if(w.length()%2 == 0){

    for(int i=0; i<check.length(); i++){
      while(1){
	found = w.find_first_of(check[i], found+1);
	if(found >= 0 && found <= w.length()){
	  count++;
	}
	else{
	  break;
	}
      }
      if(count%2 != 0){
	flag = 0;
	break;
      }
      count = 0;
      flag = 1;
    }

  }
    
  if(flag == 1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}
  


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

int main() {
  string S;
  cin >> S;
  if(S == "SUN"){
    cout << 7 << endl;
  }
    if(S == "SAT"){
    cout << 1 << endl;
  }
    if(S == "MON"){
    cout << 6 << endl;
  }
    if(S == "TUE"){
    cout << 5 << endl;
  }
    if(S == "WED"){
    cout << 4 << endl;
  }
    if(S == "THU"){
    cout << 3 << endl;
  }
    if(S == "FRI"){
    cout << 2 << endl;
  }
  
}

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

//繰り返し2乗法
ll power(ll x, ll y){//繰り返し2乗法
  if(y < 0){
    return 0;
  }else if(y == 0){
    return 1LL;
  }else if(y%2 == 0){//偶数
    return power(x,y/2)*power(x,y/2);
  }else{//奇数
    return power(x,y-1)*x;
  }
}

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N; cin >> N;
  //各々の証言の数。
  vector<ll> a(N,0);
  //N人が最大N-1個のfirstはsecondであるという証言をした。
  vector<vector<pair<ll,ll>>> test(N,vector<pair<ll,ll>>(N-1,mp(-1,-1)));
  FOR(i,N){ cin >> a[i]; FOR(j,a[i]){ cin >> test[i][j].fi >> test[i][j].se; test[i][j].fi --; }}
  vector<ll> table(N,-1);
  
  //main
  //組み合わせについてbit全探索
  ll ans = 0;
  for(int i=0; i<power(2,N); i++){//bit列。
    ll count = 0;
    bool contra = false;
    
    for(int j=0; j<N; j++){//j(0...N-1)人目を検証。
      if((i>>j)%2){//j(0...N-1)人目が正直者の時。
        for(int k=0; k<a[j]; k++){//j(0...N-1)人目のk個の証言を検証
          if((i>>(test[j][k].fi))%2 != test[j][k].se){ 
            contra = true;
            goto endloop;//多重ループを抜けるため...
          }
        }
        count ++;
      }
    }
    endloop:
    if(!contra){ ans = max(ans,count); }//矛盾しなかった時のみ最大値を更新。
  }
  
  // output
  cout << ans << endl;

  return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
int V[101];
ll S[101];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) {
		cin>>V[i];
	}
	
	ll ret=-1LL<<60;
	FOR(x,K+1) FOR(y,K+1) {
		if(x+y>N) continue;
		if(x+y>K) continue;
		
		multiset<int> M;
		ll sum=0;
		FOR(i,x) {
			sum+=V[i];
			M.insert(V[i]);
		}
		FOR(i,y) {
			sum+=V[N-1-i];
			M.insert(V[N-1-i]);
		}
		
		int lef=K-x-y;
		while(lef&&M.size()&&*M.begin()<0) {
			lef--;
			sum-=*M.begin();
			M.erase(M.begin());
		}
		ret=max(ret,sum);
		
	}
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;


int main(void){
	int N, M, X, Y;cin >> N >> M >> X >> Y;
	int a, b;

	for (int i = 0; i < N; i++) {
		cin >> a;
		X = max(X, a);
	}
	for (int i = 0; i < M; i++) {
		cin >> b;
		Y = min(b, Y);
	}
	if (X < Y) {
		cout << "No War" << endl; 
	}
	else { cout << "War" << endl; }

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

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

constexpr ll INF = 1'000'000'000'000'000'000;
namespace utils{
#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
    using V_Set = unordered_set<int>;
    using E_Set = unordered_map<int, V_Set>;

    ll operator"" _64(unsigned long long x){ return ll(x); }
    ull operator"" _64u(unsigned long long x){ return ull(x); }

    template<class T>
    vector<T> make_vector(int n, T t){
        return vector<T>(n, t);
    }
    template<class ...Ts>
    auto make_vector(int n, Ts ... ts){
        return vector<decltype(make_vector(ts...))>(n, make_vector(ts...));
    }

    template<class T>
    ostream& operator<<(ostream& os, const vector<T>& v){
        for (auto &&x : v) { os << x << ' '; } cout << endl; return os ;
    }
}
using namespace utils;

class solver{
    istream& is;
    ostream& os;

public:
    solver(istream& I, ostream& O) :is(I), os(O) {}
    void run(){
        ll A, B;
        is >> A >> B;
        if(!is) return;
        ll ans = max(0ll, A-B*2);
        os << ans << endl;

    }
};

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_A.txt";
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int loop = 0;
    while(fs) {
        loop++;
        cout << '#' << loop << "#------\n";
        solver(fs, cout).run();
    }
    if(loop <= 1) {
        cout << "===" << endl;
        while(cin) solver(cin, cout).run();
    }
#else
    solver(cin, cout).run();
#endif
    return 0;
}


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

int main(){
int b;
string a;
cin>>b;
cin>>a;

for(int i=0;a[i];i++){
    int d=(int)a[i];
    if(d+b>90)
        d-=26;
    cout<<(char)(d+b);
}
cout<<endl;


}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    string s = "";
    cin >> s;
    string a = "erase", b = "eraser", c = "dream", d = "dreamer";
    int now = (int)s.size()-1;
    bool flag = true;
    while (flag && now >= 0) {
        if (s.at(now) == 'r') {
            if (now-5 < 0) {
                flag = false;
                break;
            }
            if (s.at(now-5) == 'e') {
                for (int i=now-4; i<now; i++) {
                    if (b.at(i-now+5) != s.at(i)) {
                        flag = false;
                        break;
                    }
                }
                now -= 6;
            }
            else if (s.at(now-5) == 'r') {
                if (now-6 < 0) {
                    flag = false;
                    break;
                }
                if (s.at(now-6) == 'd') {
                    for (int i=now-4; i<now; i++) {
                        if (d.at(i-now+6) != s.at(i)) {
                            flag = false;
                            break;
                        }
                    }
                }
                else {
                    flag = false;
                    break;
                }
                now -= 7;
            }
            else {
                flag = false;
                break;
            }
        }
        else if (s.at(now) == 'e') {
            if (now-4 < 0) {
                flag = false;
                break;
            }
            for (int i=now-4; i<now; i++) {
                if (a.at(i-now+4) != s.at(i)) {
                    flag = false;
                    break;
                }
            }
            now -= 5;
        }
        else if (s.at(now) == 'm') {
            if (now-4 < 0) {
                flag = false;
                break;
            }
            for (int i=now-4; i<now; i++) {
                if (c.at(i-now+4) != s.at(i)) {
                    flag = false;
                    break;
                }
            }
            now -= 5;
        }
        else {
            flag = false;
            break;
        }
    }
    if (flag) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char[] a = in.next().toCharArray();
            int[] occur = new int[26];
            for (char x : a) ++occur[x - 'a'];
            long res = 0;
            for (int i = 0; i < 26; ++i) {
                if (occur[i] == 0) continue;
                for (int j = i + 1; j < 26; ++j) {
                    res += 1L * occur[i] * occur[j];
                }
            }
            out.println(res + 1);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

    }
}



Measured memory_bytes: 25172
def resolve():
    N = int(input())
    temp = 0
    for count in range(N + 1):
        if count % 3 == 0 and count % 5 == 0:
            pass
        elif count % 3 == 0:
            pass
        elif count % 5 == 0:
            pass
        else:
            temp += count
    print(temp)


resolve()

Measured memory_bytes: 67352
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<pair<int,int>> v;
  rep(i,N){
    int a;
    cin >> a;
    v.emplace_back(a,i+1);
  }
  sort(ALLOF(v));

  rep(i,N){
    if(i>0) cout << " ";
    cout << v[i].second;
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 1780
#include<iostream>
using namespace std;
int main(){
    int N,X,total=0;
    cin >> N >> X;
    int m[N];
    
    for(int i=0;i<N;i++){
        cin >> m[i];
        total+=m[i];
    }
    
    X = X-total;
    
    int co[N];
    
    for(int i=0;i<N;i++){
        co[i]=X/m[i];
    }
    int ans=co[0];
    for(int i=1;i<N;i++){
        if(ans<co[i]){
            ans=co[i];
        }
    }
    cout << N+ans << endl;
    return 0;
    
}

Measured memory_bytes: 256
import java.util.Scanner
import scala.collection.mutable.ArrayBuffer

object Main extends App {
  val sc = new Scanner(System.in)
  def next(): String = sc.next()
  def nextInt(): Int = next().toInt
  def nextLong(): Long = next().toLong

  def taskA(): Unit = {
    val n = next()
    println(n.count(_ == '2'))
  }

  def taskB(): Unit = {
    val n, h, w = nextInt()
    val ans = 1.to(n).count { _ =>
      val a, b = nextInt()
      a >= h && b >= w
    }
    println(ans)
  }

  def taskC(): Unit = {
    val n, p = nextLong()
    val ps = factorize(p)
    var res = 1L
    for ((p, e) <- ps) {
      for (_ <- 1L to e / n)
        res *= p
    }
    println(res)
  }

  def factorize(x: Long): Seq[(Long, Int)] = {
    val res = new ArrayBuffer[(Long, Int)]()
    var p = 2L
    var tmp = x
    while (p * p <= tmp) {
      var exp = 0
      while (tmp % p == 0) {
        exp += 1
        tmp /= p
      }
      if (exp != 0) res.append((p, exp))
      p += 1
    }
    if (tmp != 1) res.append((tmp, 1))
    res
  }

  def test(): Unit = {
    require(factorize(2) == Seq((2, 1)))
    require(factorize(3) == Seq((3, 1)))
    require(factorize(4) == Seq((2, 2)))
    require(factorize(6) == Seq((2, 1), (3, 1)))
    require(factorize(1024) == Seq((2, 10)))
  }

  taskC()
}


Measured memory_bytes: 27592
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define forn(i, n) for (int i = 0; i < (int) (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

using namespace std;

int main() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   string s;
   cin >> s;
   vector <char> v;
   string result = "";
   forn(i,s.size()){
       if(s[i] == '0'){
           v.pb('0');
       }else if(s[i] == '1'){
           v.pb('1');
       }else if(!v.empty()){
           v.pop_back();
       }
   }
   forn(j,v.size()){
       result+=v[j];
   }    
   cout << result;
   return 0;
}



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

int main() {
	
	int n;
	cin >> n;
	int cnt2=0;
	for(int i=1; i<=n; i+=2){
		int cnt = 0;
		for(int j=1; j<=i; j++){
			if(i%j==0) cnt++;
		}
		if(cnt==8) cnt2++;
	}
	cout << cnt2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N = 1<<17;

ll mod;
class BIT2{
public:
  int n;
  ll bit0[MAX_N+1],bit1[MAX_N+1];//1????????????

  BIT2(){n = MAX_N;memset(bit0,0,sizeof(bit0));memset(bit1,0,sizeof(bit1));}
  BIT2(int n){this->n=n;memset(bit0,0,sizeof(bit0));memset(bit1,0,sizeof(bit1));}
  
  ll sum(ll *b,int i){
    ll s=0;
    while(i>0){
      s=(s+b[i])%mod;
      i-=i&-i;
    }
    return s;
  }

  void add(ll *b,int i,ll v){
    while(i<=n){
      b[i]=(b[i]+v)%mod;
      i+=i&-i;
    }
  }

  //[a,b]???x?????????(1<=a)
  void add (int a,int b,ll x){
    add(bit0,a,-x*(a-1));
    add(bit1,a,x);
    add(bit0,b+1,x*b);
    add(bit1,b+1,-x);
  }

  //[a,b]???sum?????????(1<=a)
  ll sum(int a,int b){
    ll res=0;
    res+=sum(bit0,b)+sum(bit1,b)*b;
    res-=sum(bit0,a-1)+sum(bit1,a-1)*(a-1);
    return (res+mod)%mod;    
  }
};

string i2S(ll num){
  string res;
  if(num==0)return "0";
  while(num) res+=(char)(num%10+'0'),num/=10;
  reverse(res.begin(),res.end());
  return res;
}

int main(){
  while(1){
    ll A,B;
    cin>>A>>B>>mod;
    if(!A&&!B&&!mod)return 0;
    vector<string> num;
    for(ll i=A;i<=B;i++)num.push_back(i2S(i));
    sort(num.begin(),num.end());
  
    ll ans = 0, n = B-A+2;
    BIT2 T(n);
    T.add(1,n,1);
    
    for(ll i=A;i<=B;i++){
      int idx = lower_bound(num.begin(),num.end(),i2S(i))-num.begin()+1;
      ll val = T.sum(idx,idx);
      ans=(ans+val)%mod;
      T.add(idx,n,val);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 11800
N = int(input())
A = list(map(int,input().split()))

plus_len = len(list(filter(lambda x:x>0,A)))
minus_len = len(list(filter(lambda x:x<0,A)))

if plus_len==N: #単一の符号のみで構成されている場合
    A = sorted(A,reverse=True)
    OUT = []
    for j in range(1,N):
        x = A.pop()
        y = A.pop()
        if j==N-1:
            OUT.append([y,x])
            A.append(y-x)
        else:
            OUT.append([x,y])
            A.append(x-y)
    print(A[0])
    for o in OUT:
        print("{} {}".format(o[0],o[1]))
        
elif minus_len==N:
    A = sorted(A)
    OUT = []
    for j in range(1,N):
        x = A.pop()
        y = A.pop()
        OUT.append([x,y])
        A.append(x-y)
    print(A[0])
    for o in OUT:
        print("{} {}".format(o[0],o[1]))
    
else: #0を含むか，2つの符号が存在すればsum(abs)でOK
    A = sorted(A)
    OUT = []
    max_side = A.pop(N-1)
    min_side = A.pop(0)
    for i in range(len(A)):
        if A[i]<0:
            OUT.append([max_side,A[i]])
            max_side -= A[i]
        else:
            OUT.append([min_side,A[i]])
            min_side -= A[i]
    OUT.append([max_side,min_side])
    print(max_side-min_side)
    for o in OUT:
        print("{} {}".format(o[0],o[1]))

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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0)
#define MFOR(i, m) for(auto i=m.begin();i!=m.end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;

void printv(vector<auto> const& s) {
  REP(i, s.size()) {
    cout << s[i] << endl;
  }
}

void print(auto const s) {
  cout << s << endl;
}

ll c[51][51];

void comb_table(int n) {
  REP(i, n+1) {
    REP(j, i+1) {
      if(j == 0 || j == i) {
        c[i][j] = 1;
      } else {
        c[i][j] = (c[i-1][j-1] + c[i-1][j]);
      }
    }
  }
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n, a, b; cin >> n >> a >> b;
  comb_table(n);
  vector<ll> v(n);
  REP(i, n) {
    cin >> v[i];
  }

  sort(ALL(v));
  reverse(ALL(v));
  double mean = 0;
  REP(i, a) mean += v[i];
  mean /= (double)a;
  cout << mean << endl;

  ll ans = 0;

  if(v[0] == v[a-1]) {
    int x = 0;
    REP(i, n) {
      if(v[0] == v[i]) {
        x++;
      } else {
        break;
      }
    }
    FOR(i, a, b+1) {
      ans += c[x][i];
    }
  } else {
    int x = 0, y = 0;
    REP(i, n) {
      if(v[a-1] == v[i]) {
        x++;
        if(i<a) {
          y++;
        }
      }
    }
    ans = c[x][y];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256