akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n - 1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
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; }
ll MOD = 1000000007;
int INF = 1001001001;

bool nabeatsu(int n)
{
	if(n % 3 == 0)return true;
	string s = to_string(n);
	rep(i,sz(s))if(s[i]=='3')return true;
	return false;
}

void solve()
{
	int n; cin >> n;
	reps(i, n)
	{
		if(nabeatsu(i))
		{
			cout <<" "<<i;
		}
	}
	cout << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}



Measured memory_bytes: 3300
#include <iostream>
#include <algorithm>
#include <string>

int main(){
  std::string S;
  std::cin>>S;
  std::reverse(S.begin(),S.end());
  
  std::string data[]={
    "dreamer",
    "dream",
    "eraser",
    "erase"
  };
  for(int i = 0;i<4;++i)
    std::reverse(data[i].begin(),data[i].end());
  
  bool check=false;
  for(size_t i = 0; i<S.size();++i){
    check=false;
    for(size_t j = 0;j<4;++j)
      if(S.substr(i,data[j].length())==data[j]){
        check=true;
        i+=data[j].length()-1;
        break;
      }
    if(!check)
      break;
  }
  if(check)
     std::cout<<"YES"<<'\n';
  else
     std::cout<<"NO"<<'\n';
  
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>

using namespace std;
using int64 = long long;

int main() {
    int64 n,c;
    cin >> n >> c;
    const int64 LIM = 1e6;
    vector<vector<int64>> imos(c+1, vector<int64>(LIM + 10, 0));
    for (int64 i=0; i<n; i++) {
        int64 s,t,ci;
        cin >> s >> t >> ci;
        imos[ci][s-1]++;
        imos[ci][t]--;
    }

    int64 ans = 0;
    for (int64 i=0; i<LIM; i++) {
        int64 cnt = 0;
        for (int j=1; j<=c; j++) {
            imos[j][i + 1] += imos[j][i];
            cnt += (imos[j][i] >= 1);
        }
        ans = max(ans, cnt);
    }


    cout << ans << endl;
}

Measured memory_bytes: 250368
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        string[] input = Console.ReadLine().Split();
        int[] D = new int[N];
        var r = 1L;
        for (int i = 0; i < N; i++)
        {
            D[i] = int.Parse(input[i]);
            if (D[0] > 0) { r = 0; }
            if (i!=0&&D[i] == 0) { r = 0; }
        }
        Array.Sort(D);
        var c = D.GroupBy(x => x).ToDictionary(g => g.Key, g => g.Count());
        var max = c.Keys.Max();
        if (c.Count <= max) { Console.WriteLine(0); return; }
        for (int i = 0; i < max; i++) r = MMul(r, MPow(c[i], c[i + 1]));
        Console.WriteLine(r);
    }
    const int M = 998244353;
    static long MPow(long b, int i)
    {
        for (var r = 1L; ; b = b * b % M)
        {
            if (i % 2 > 0) r = r * b % M;
            if ((i /= 2) < 1) return r;
        }
    }
    static long MMul(long x, long y) => x * y % M;
}


Measured memory_bytes: 37012
using System;

namespace ARC099C
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int n = input[0];
            int k = input[1];
            
            int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            int count = 1;
            int rest = n - k;
            
            while (rest > 0)
            {
                rest -= k - 1;
                count++;
            }

            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 16864
#include <stdio.h>

int main(void){
  int i,j,k,l;
  char str[10000];
  
  scanf("%s",str);

  l=strlen(str);

  for(i=0;i<l;i++){
    if(str[i]>'C'){
      str[i]=str[i]-0x03;
    }else{
      str[i]=str[i]+0x17;
    }
  }
  printf("%s\n",str);
  return(0);
}

Measured memory_bytes: 528
#include <iostream>
#include <map>

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int H, W, N;
  in(H); in(W); in(N);

  map<pii, int> m;
  rep(i, N) {
    int a; in(a);
    int b; in(b);
    rep(x, 3) {
      if (a - x <= 0 || a - x > H - 2)
        continue;
      rep(y, 3) {
        if (b - y <= 0 || b - y > W - 2)
          continue;
        ++m[pii(a - x, b - y)];
      }
    }
  }
  ll res[10];
  rep(i, 10) res[i] = 0;
  iter(it, m) {
    ++res[it->second];
  }
  res[0] = (ll)(W-2) * (H-2) - m.size();
  rep(i, 10) {
    out(res[i]);
  }

  return 0;
}


Measured memory_bytes: 56576
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    int m, d;
    cin>>m>>d;

    int ans = 0;
    rep(i, m) rep(j, d) {
        if (j < 10) continue;
        int m1 = i + 1;
        int d1 = (j + 1) % 10;
        int d2 = (j + 1) / 10;
        if (d1  >= 2 && d2 >= 2 && d1 * d2 == m1) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  vector<Int> A(5);
  cin>>A;

  for(Int i=0;i<5;i++){
    if(A[i] == 0) cout<<i+1<<endl;
  }

  return 0;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
const long double PI =(acos(-1));

int main(){
    vector<char> G(50);
    int cnt=0;
    int n=1;
    int i=0;
    while(n){
        int a=0,b=0,c=0;
        cin >> a >> b >> c;
        if(a==-1 || b==-1){
            G.at(i)='F';
        }else if(a+b>=80){
            G.at(i)='A';
        }else if(a+b>=65){
            G.at(i)='B';
        }else if(a+b>=50){
            G.at(i)='C';
        }else if(a+b>=30){
            if(c>=50){
                G.at(i)='C';
            }else{
                G.at(i)='D';
            }
        }else{
            G.at(i)='F';
        }
        cnt++;
        if(a==-1 && b==-1 && c==-1){
            n=0;
            cnt--;
        }
        i++;
    }

    for(int i=0;i<cnt;++i){
        cout << G.at(i) << endl;
    }


    return 0;
}


Measured memory_bytes: 3044
#include <iostream>
using namespace std;
 
int main()
{
    int y,m,d,num,k,kk;
    cin >> num;
    for (int i=0; i<num; i++) {
        int days,days_y=0,days_m=0,days_d=0;
        cin >> y >> m >> d;
        k = y;
        kk = m;
        while(y<999)
        {
            if(y%3 == 0)
            {
                days_y += 200;
            }else{
                days_y += 195;
            }
            y++;
        }
        if(k%3==0)
        {
            days_d += (21-d);
            kk++;
            for (int i =kk; i<11; i++)
            {
                days_d += 20;
            }
        }else{
            days_d += 5;
            if (kk%2==0) {
                days_d += (20-d);
            }else{
                days_d += (21-d);
            }
            kk++;
            while(kk < 11)
            {
                if (kk%2 == 0) {
                    days_m +=19;
                }else{
                    days_m +=20;
                }
                kk++;
            }
        }
        days = days_y + days_m + days_d;
        cout << days << endl;
    }
}

Measured memory_bytes: 1160
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    M, m = max(a), min(a)
    c = a.count(m)
    C = a.count(M)
    
    if M == m:
        if n//2 >= m or m == n-1:
            judge = True
        else:
            judge = False
    else:
        if M - m > 1:
            judge = False
        elif M - c <= 0:
            judge = False
        elif n-c >= (M-c)*2:
            judge = True
        else:
            judge = False
        
    
    print("Yes" if judge else "No")
    
    
    
if __name__ == "__main__":
    main()


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

using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double eps = 1e-7;
#define Loop(i, n) for(int i = 0; i < int(n); i++)
#define Loopll(i, n) for(ll i = 0; i < ll(n); i++)
#define Loop1(i, n) for(int i = 1; i <= int(n); i++)
#define Loopll1(i, n) for(ll i = 1; i <= ll(n); i++)
#define Loopr(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = ll(n) - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = int(n); i >= 1; i--)
#define Looprll1(i, n) for(ll i = ll(n); i >= 1; i--)
#define Foreach(buf, container) for(auto buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
#define INF INFINITY
bool feq(double x, double y) { return abs(x - y) <= eps; }
bool inrange(ll x, ll t) { return x >= 0 && x < t; }
bool inrange(vll xs, ll t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
int ceillog2(ll x) { int ret = 0;	x--; while (x > 0) { ret++; x >>= 1; } return ret; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

//========================================================================//

int main() {
	ll n; cin >> n;
	ll m = floorsqrt(n);
	Looprll1(i, m) {
		if (n % i == 0) {
			ll j = n / i;
			cout << i + j - 2 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN
#define INF         100000000000000000
#define PI          3.1415926535897932384626433832795l



#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)






// struct mycomp {
//     bool operator() (const pair<int,int> &a, const pair<int,int> &b) const{
//         if (a.second-a.first != b.second-b.first)
//         return (a.second-a.first > b.second-b.first);
//         return a.first < b.first;
//     }
// };



/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}	
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}


///////////////////////////BFS//////////////////////////////////
void bfs(vector<int>& distance, vector<int> a[], vector<bool>& visited, int u, vector<int>& parent)
{
	visited[u]=true;
	parent[u]=-1;
	distance[u]=0;
	queue<int> q;

	q.push(u); 
    while (!q.empty()) { 
  
        int f = q.front(); 
        q.pop(); 
  		for(int i =0; i < a[f].size(); i++)
  		{
  			if(visited[a[f][i]]==false)
  			{
  				distance[a[f][i]]=distance[f]+1;
  				parent[a[f][i]]=f;
  				visited[a[f][i]]=true;
  				q.push(a[f][i]);
  			}
  		}
    } 

}

void solve()
{

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

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	int n;
	cin>>n;
	vector<ll> a(n);
	for(int i = 0; i < n; i++) cin>>a[i];

	sort(a.rbegin(), a.rend());
ll sum = a[0];
	if(a.size()==2)
	{
	cout<<a[0]; return 0;}
	int i;
	for( i = 1; i <= (n-1)/2; i++)
		sum+=2*a[i];
	if(n%2!=0) sum-=a[i-1];
	// for(int i = 2; i < n-1; i++)
	// {
		// sum+=a[1];
	// }
	p(sum);
	return 0;
}

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

using LL = long long;
using Graph = vector<vector<int>>;

const LL M = 1e9+7;
int N;
LL K;
Graph G;

LL dfs(auto pre, auto cur, auto k) {
  LL res = k;
  k = max(k - 1, K - 2);
  for(auto nex: G[cur]) if(nex != pre) (res *= dfs(cur, nex, k--)) %= M;
  return res;
}

int main() {
  cin >> N >> K;
  G.resize(N);
  for(auto i = 1; i < N; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  cout << dfs(0, 0, K) << endl;
}


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

int main(){
    std::string str,ken;
    std::cin >> str;
    std::cin >> ken;
    str+=str;
    //std::cout << str << std::endl;
    if((int)str.find(ken)!=-1){std::cout << "Yes" << std::endl;}else{std::cout << "No" << std::endl;}
    return 0;
}

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

int main() {
  ll n,x;
  cin>>n>>x;
  ll a[n];
  ll sum =0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum +=a[i];
  }
  sort(a,a+n);
  if(sum==x) cout<<n<<endl;
  else {
    ll sum1=0;
    for(int i=0;i<n;i++){
      sum1+=a[i];
      if(sum1>x){
        cout<<i<<endl;
        break;
      }
      else if(sum1==x){
        cout<<i+1<<endl;
        break;
      }
      else if(sum1<x && i==n-1){
        cout<<n-1<<endl;
      }
    }
  }  
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{




	public static void main(String[] args){

		String array[];

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));

		try{
		String str=reader.readLine();
		array=str.split(" ");
		int num=Integer.parseInt(array[0]);
		int q=Integer.parseInt(array[1]);
		int sum=0;
		Queue queue=new Queue(num);

		String x;
		int y;



		for(int i=0;i<num;i++){
			str=reader.readLine();
			queue.enqueue(str);
		}

		while(queue.num!=0){
			str=queue.dequeue();
			 array=str.split(" ");
			    x=array[0];
				y=Integer.parseInt(array[1]);

			    if(y>q){
			    	y=y-q;
			    	sum+=q;
			    	queue.enqueue(x+" "+y);
			    	} else{

			    	sum+=y;
			          System.out.println(x+" "+sum);
			    }
		}






		}catch(IOException e){

		}

	}//main
}

class Queue{
	int max;
	int num;
	String[] array;
	int front, rear;

	Queue(int capacity){//?????????????????????
		max=capacity;
		num=rear=front=0;
		array=new String[max];
	}
	public void enqueue(String str){
		array[rear++]=str;
		num++;
		if(rear==max)rear=0;
	}

	public String dequeue(){
		String str=array[front++];
		num--;
		if(front==max)front=0;

		return str;
	}

}//stack?????????

Measured memory_bytes: 69928
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

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

    return 0;
}

Measured memory_bytes: 3636
import java.util.*;
public class Main{
	
	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		char[] s = sc.next().toCharArray(); //charで読んで格納
		int count=0;
		for(int i=0;i<s.length/2;i++) {
			if(s[i]!=s[s.length-1-i]) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 23504
x, y = gets.split(" ").map(&:to_i)

if x == 1
    ans = 300000
    if y == 1
        puts 1000000
    elsif y == 2
        ans += 200000
        puts ans
    elsif y == 3
        ans += 100000
        puts ans
    else
        puts ans
    end
elsif x == 2
    ans = 200000
    if y == 1
        ans += 300000
        puts ans
    elsif y == 2
        ans += 200000
        puts ans
    elsif y == 3
        ans += 100000
        puts ans
    else
        puts ans
    end
elsif x == 3
    ans = 100000
    if y == 1
        ans += 300000
        puts ans
    elsif y == 2
        ans += 200000
        puts ans
    elsif y == 3
        ans += 100000
        puts ans
    else
        puts ans
    end
else
    ans = 0
    if y == 1
        ans += 300000
        puts ans
    elsif y == 2
        ans += 200000
        puts ans
    elsif y == 3
        ans += 100000
        puts ans
    else
        puts ans
    end
end

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, m;
	cin>>n>>m;
	int a[n], vis[n];
	memset(vis, 1, sizeof(vis)); 
	for (int i = 0; i < n; i++) cin>>a[i];
	for (int i = 0; i < m; i++) {
		int x, y;
		cin>>x>>y;
		if (a[x - 1] >= a[y - 1]) vis[y - 1] = 0;
		if (a[x - 1] <= a[y - 1]) vis[x - 1] = 0;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) 
	if (vis[i]) ans++;
	cout<<ans;
} 

Measured memory_bytes: 4424
from itertools import permutations as perm

N = int(input())
test = list(perm(range(1, N+1), N))
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

for i in range(len(test)):
    if test[i] == P:
        a = i
    if test[i] == Q:
        b = i

print(abs(a-b))

Measured memory_bytes: 8052
<?php

$seconds = fgets(STDIN);

$time = timeConversion($seconds);

echo $time;

function timeConversion($seconds){
    $hours = floor($seconds / 3600);
    $minutes = floor(($seconds / 60) % 60);
    $seconds = $seconds % 60;
    
    $hms = sprintf("%d:%d:%d", $hours, $minutes, $seconds);
    
    return $hms;
}
?>

Measured memory_bytes: 15256
//hinagata.cpp
/*includes*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>
#include <iomanip>
#include <limits>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPi(i,a,b) for(int i=(a);i<(b);i++)
#define REPRi(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    int N,M;
    cin>>N>>M;
    vector<int> A(M);
    REP(i,M){cin>>A[i];}
    //input end
    vector<int> C(N+2,0);
    REP(i,M){C[A[i]+1]=-1;}
    //init condition
    C[0]=0;
    C[1]=1;
    REPi(i,2,N+2){
        if(C[i]!=-1){
            C[i-1]!=-1?C[i]+=C[i-1]:0;
            C[i-2]!=-1?C[i]+=C[i-2]:0;
            C[i]%=int(1e9+7);
        }
    }
    cout<<C[N+1]<<endl;    
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
    int n;
    int d, x;

    int a;

    cin >> n;
    cin >> d >> x;

    int sum = 0;

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

        if (d % a == 0) {
            sum += d / a;
        }
        else {
            sum += (d / a + 1);
        }
    } 

    cout << sum + x << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<double,double> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const LL INF=1<<30;


int color[100001];

bool check(vector<vector<int>> G,int v,int c){
    color[v]=c;
    for(int i=0;i<G[v].size();i++){
        if(color[G[v][i]]==c) return false;
        if(color[G[v][i]]==0&&!check(G,G[v][i],-c)) return false;
    }
    return true;
}


int main() {
    int N,M;
    while(cin >> N >> M){
        if(N==0&&M==0) break;
        vector<vector<int>> G(1001);
        memset(color,0,sizeof(color));
        for(int i=0;i<M;i++) {
            int a,b;
            cin>>a>>b;
            a--;b--;
            G[a].push_back(b);
            G[b].push_back(a);
        }
        if(!check(G,0,1)) puts("0");
        else{
            int a=0,b=0;
            for(int i=0;i<N;i++){
                if(color[i]==1) a++;
                else b++;
            }
            if(a%2&&b%2) puts("0");
            else if(a%2==0&&b%2==0){
                if(a>b) swap(a,b);
                if(a/2==b/2){
                    puts("1");
                    cout << a/2 << endl;
                }
                else{
                    puts("2");
                    cout << a/2 << endl;
                    cout << b/2 << endl;
                }
            }
            else{
                puts("1");
                if(a%2) cout << b/2 << endl;
                else cout << a/2 << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 16548
n, w_max = gets.split.map(&:to_i)
items = Array.new(n){gets.split.map(&:to_i)}
dp = Array.new(w_max+1, 0)
items.each do |wi, vi|
  prev = dp.dup
  (wi..w_max).each do |w|
    v = vi + prev[w-wi]
    dp[w] = v if v > prev[w]
  end
end
puts dp.last


Measured memory_bytes: 68220
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let x = get!();
    let a = get!();
    
    if x < a {
        println!("0");
    } else {
        println!("10");
    }
}

Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

bool check(int x, int A, int B) {
    int digSum = 0;
    while(x > 0) {
        digSum += x % 10;
        x /= 10;
    }
    return (digSum >= A && digSum <= B);
}

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int res = 0;
    for(int i = 1; i <= N; i++) {
        if(check(i, A, B))
            res += i;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define rg register
#define ll long long
int gcd(int a,int b)
{
    return b?gcd(b,a%b):a;
}
int main()
{
    int a,b,k;
    while(cin>>a>>b>>k)
    {
        int ans=gcd(a,b);
        int t=1;
        while(t<k)
        {
            ans--;
            if(a%ans==0&&b%ans==0)
                t++;
        }
        cout<<ans;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n, x;
	bool b[301];
	int cnt[1000];
	int c = 0;
	while (true)
	{
		cin >> n >> x;
		if (n == 0 && x == 0)
		{
			break;
		}
		for (int i = 0; i <= n; i++)
		{
			b[i] = false;
		}
		int count = 0;
		for (int x1 = 1; x1 <= n; x1++)
		{
			for (int x2 = 1; x2 <= n; x2++)
			{
				for(int x3 = 1; x3 <= n; x3++)
				{
					if (x1 == x2 || x1 == x3 || x2 == x3)
					{
						continue;
					}

					int result = x1 + x2 + x3;
					if (result == x)
					{

						count++;

					}
				}
			}
		}
		cnt[c] = count;
		c++;
	}
	for (int i = 0; i < c; i++)
	{
		cout << cnt[i] / 6 << endl;
	}
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int H, W, M; cin >> H >> W >> M;
  vector<int> h(M), w(M);
  rep(i, M) cin >> h[i] >> w[i];
  
  unordered_map<int,int> hh, ww;
  rep(i, M) {
    hh[h[i]]++;
    ww[w[i]]++;
  }
  set<pair<int,int>> m;
  rep(i, M) m.insert(make_pair(h[i],w[i]));
  
  
  vector<pair<int,int>> Xh(0), Xw(0);
  
  for(auto p : hh) {
    Xh.push_back(make_pair(p.second, p.first));
  }
  for(auto p : ww) {
    Xw.push_back(make_pair(p.second, p.first));
  }
  sort(all(Xh));
  reverse(all(Xh));
  sort(all(Xw));
  reverse(all(Xw));
  
  vector<int> xh = {Xh[0].second}, xw = {Xw[0].second};
  rep(i, Xh.size()-1) {
    if(Xh[i+1].first == Xh[i].first) xh.push_back(Xh[i+1].second);
    else break;
  }
  rep(i, Xw.size()-1) {
    if(Xw[i+1].first == Xw[i].first) xw.push_back(Xw[i+1].second);
    else break;
  }

  
  //rep(i, xh.size()) cout << xh[i] << " ";
  //cout << endl;
  //rep(i, xw.size()) cout << xw[i] << " ";
  //cout << endl;
  
  rep(i, xh.size()) rep(j, xw.size()) {
    if(!m.count(make_pair(xh[i], xw[j]))) {
      cout << Xh[0].first + Xw[0].first << endl;
      //cout << xh[i] << " " << xw[j] << endl;
      return 0;
    }
  }
  cout << Xh[0].first + Xw[0].first - 1 << endl;
  
}

Measured memory_bytes: 71772
import math

def is_prime(n):
	if n == 2:
		return True
	z = math.floor(n**0.5)
	for i in range(2, z + 1):
		if n % i == 0:
			return False
	return True

x = int(input())
while not is_prime(x):
	x += 1
print(x)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define REV(v) reverse(v.begin(), v.end());
#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, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define REMOVE(v,n) remove(vector<int> v,v+v.size(),int n)
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

//vector< vector<int> > v (size1, vector<int>(size2) );

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,W;
    cin>>N>>W;
    vector<ll> w(N),v(N);
    FOR(i,0,N) cin>>w[i]>>v[i];
    ll dp[N+1][W+1];
    //↓注意
    FOR(j,0,W+1){
        dp[0][j]=0;
    }
    dp[0][0]=0;
    FOR(i,0,N){
        FOR(j,0,W+1){
            if(j-w[i]>=0)dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
            else dp[i+1][j]=dp[i][j];
            //cout<<"i "<<i<<" j "<<j<<' '<<dp[i][j]<<endl;
        }
    }
    cout<<dp[N][W]<<endl;
}
//初期値調整

Measured memory_bytes: 79232
# D 解き直し
# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
n,m,k = map(int, input().split())
not_ans = [1 for i in range(n)]
ans = [0 for i in range(n)]
unions = UnionFind(n)
for i in range(m):
    a,b = map(int, input().split())
    not_ans[a-1] += 1
    not_ans[b-1] += 1
    unions.union(a-1, b-1)
for i in range(k):
    a,b = map(int, input().split())
    if unions.same(a-1, b-1):
        not_ans[a-1] += 1
        not_ans[b-1] += 1
for i in range(n):
    ans[i] = unions.size(i) - not_ans[i]
print(*ans)

Measured memory_bytes: 93472
import bisect

N = int(input())
L = list(map(int, input().split()))
L = sorted(L)

count = 0
for n in range(N-2):
    for m in range(n+1,N-1):
        count += bisect.bisect_left(L,L[m]+L[n]) - (m + 1)

print(count)


Measured memory_bytes: 3188
#include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
typedef unordered_map<string, int> Map;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main(void) {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
  }
  Map map;
  ll ans = 0;
  rep(i, n) {
    if(map.count(s[i]) == 0) {
      map[s[i]] = 1;
    } else {
      ans += map[s[i]];
      map[s[i]]++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 17700
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

long long int connect(long long int a[], long long int b, long long int m, long long int e){
    long long int s = b;
    long long int i = b;
    long long int j = m + 1;
    long long int cnt = 0;
    long long int tmpa[200000];


    while (i <= m && j <= e){
        if(a[i] <= a[j]){
            tmpa[s++] = a[i++];
        }
        else{
            tmpa[s++] = a[j++];
            cnt += (m - i + 1);
        }
    }
    if(i > m){
        while(j <= e){
            tmpa[s++] = a[j++]; 
        }
    }
    if(j > e){
        while(i <= m){
            tmpa[s++] = a[i++]; 
        }
    }

    for (long long int k = b; k <= e; k++){
        a[k] = tmpa[k];
    }
    
    return cnt;
}

long long int merge(long long int a[],long long  int b, long long int e){
    if(b == e){
        return 0;
    }

    long long int m = (b + e) / 2;
    long long int cnt = 0;
    if(b + 1 , e){
        cnt += merge(a, b, m);
        cnt += merge(a, m + 1, e);
    }
    cnt += connect(a, b, m, e);
    return cnt;
}

int main()
{
    long long int n;
    scanf("%lld", &n);
    long long int cnt = 0;
    long long int a[n];
    for (long long int i = 0; i < n; i++){
        scanf("%lld",&a[i]);
    }

    cnt = merge(a, 0, n - 1);

    printf("%lld\n", cnt);


    return 0;
  
    
}


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

int main(){
	int n;
	cin >> n;
	int64_t a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	int64_t b = a[0], c = accumulate(a + 1, a + n, 0ll);
	int64_t ans = abs(b - c);
	for(int i = 1; i < n - 1; i++){
		b += a[i];
		c -= a[i];
		ans = min(ans, abs(b - c));
	}
	cout << ans << endl;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod = 1e9 + 7;
const ll MAXX = 1e18;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("INP.txt", "r", stdin);
	//freopen("OUT.txt", "w", stdout);
  	ll a;
  	cin >> a;
  	string s;
  	cin >> s;
  	if (a < 3200) {
      cout << "red" << '\n'; 
    }
  	else {
      cout << s << "\n";
    }
	return 0;
}

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

int n;
long hoge(long k){
  if(k>n) return 0;
  k*=10;
  return 1+hoge(k+3)+hoge(k+5)+hoge(k+7);
}
long hoge2(long k,int a,int b){
  if(k>n) return 0;
  k*=10;
  return 1+hoge2(k+a,a,b)+hoge2(k+b,a,b);
}
long hoge1(long k,int a){
  if(k>n) return 0;
  k*=10;
  return 1+hoge1(k+a,a);
}

int main() {
  cin>>n;
  cout<<hoge(0)-hoge2(0,7,3)-hoge2(0,5,3)-hoge2(0,7,5)+hoge1(0,7)+hoge1(0,5)+hoge1(0,3)-1;
}

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

#define pii pair<int, pair<int, int>> 

using ll = long long;
using ld = long double;

const int N = 1e5 + 69;

priority_queue<pii, vector<pii>, greater<pii>> edges;
vector<pair<int,int>> a, b;
ll ans;
int n, cnt;
int par[N], sz[N];

int fpar(int a) {
  return (a == par[a] ? a : par[a] = fpar(par[a]));
}

void merge(int a, int b) {
  int pa, pb;
  pa = fpar(a);
  pb = fpar(b);
  if(pa == pb)
    return;
  if(sz[a] > sz[b])
    swap(a, b);
  par[pa] = pb;
  sz[pb] += sz[pa];
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  
  cin >> n;
  for(int i = 1; i <= n; i++)
    par[i] = i, sz[i] = 1;
  for(int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    a.emplace_back(x, i);
    b.emplace_back(y, i);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  for(int i = 1; i < n; i++) {
    edges.emplace(a[i].first - a[i - 1].first, make_pair(a[i].second, a[i - 1].second));
    edges.emplace(b[i].first - b[i - 1].first, make_pair(b[i].second, b[i - 1].second));
  }
  while(cnt < n - 1) {
    pii cur = edges.top();
    edges.pop();
    if(fpar(cur.second.first) == fpar(cur.second.second))
      continue;
    merge(cur.second.first, cur.second.second);
    ans += cur.first;
    cnt++;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 9388
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
long long  n,W,i,w;
  cin>>n>>W;
  long long val[n],wt[n];
  for(int i=0;i<n;i++)
    cin>>wt[i]>>val[i];
  
	long long K[n+1][W+1];
for (i = 0; i <= n; i++) 
   { 
       for (w =0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
 
  cout<< K[n][W]; 
  return 0;
 
}

Measured memory_bytes: 79104
#include<iostream>
#include<algorithm>
int main()
{
	int a=0,b=0,num=0;
	std::cin >> a>>b;
	if (b == 100) 
	{
		num = a * 1000 + b;
	}
	else if (b < 10) {
		num = a * 10 + b;
	}
	else 
	{
		num = a * 100 + b;
	}
	bool okada = false;
	for(int i=1;i<=1145;i++)
	{
		if (i*i == num) 
		{
			okada = true;
		}
	}
	if (okada)
	{
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
inline int rd(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 5e3+5, P = 1e9+7, I2 = (P+1)/2;
int n, m, a[N], f[N][N], ans, S; void fix(int &x) { x<P?0:x-=P; }
int main()
{
    n = rd(), m = rd(), S = 1;
    for(int i = 1; i <= n; ++i) a[i] = rd();
    for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) f[i][j] = a[i] > a[j];
    for(int i = 1; i <= m; ++i) 
    {
        int x = rd(), y = rd();
        for(int j = 1; j <= n; ++j) if(x != j&&y != j)
            f[j][x] = f[j][y] = (i64)I2*(f[j][x]+f[j][y])%P,
            f[x][j] = f[y][j] = (i64)I2*(f[x][j]+f[y][j])%P;
        f[x][y] = f[y][x] = (i64)I2*(f[x][y]+f[y][x])%P, fix(S<<=1);
    }
    for(int i = 1; i <= n; ++i) for(int j = i+1; j <= n; ++j) fix(ans += f[i][j]);
    printf("%lld\n", (i64)ans*S%P);
    return 0;
}

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

bool p[10010];

int era(){
	fill(p, p+10010, true);
	p[0] = p[1] = false;

	for(int i=0; i < 10010; i++){
		if(!p[i]) continue;

		for(int j=i+i; j < 10010; j+=i){
			p[j] = false;
		}
	}
}

int main(){
	era();
	int input;

	while(cin >> input, input){
		for(int i= input; 0 < i; i--){
			if(p[i] && p[i-2]){
				cout << i-2 << " " << i << endl;
				break;
			}
		}
	}
}

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

int main(){
  ios::sync_with_stdio(0); cin.tie(0);
  int n; string s; cin >> n >> s; 
  set<string> str; 
  set<char> c0, c1, c2; 
  for(int i=0;i<n-2;i++) {
    if(c0.size() == 10) break;
    else if(c0.count(s[i])) continue;
    else {
      for(int j=i+1;j<n-1;j++) {
        if(c1.size() == 10) break;
        else if(c1.count(s[j])) continue;
        for(int k=j+1;k<n;k++) {
          if(c2.size() == 10) break;
          else if(c2.count(k)) continue;
          string tmp = ""; 
          tmp = s.substr(i, 1)+s.substr(j, 1)+s.substr(k, 1);
          str.insert(tmp);
          c0.insert(s[i]);
          c1.insert(s[j]);
          c2.insert(s[k]);   
        }
        c2.clear();
      }
      c1.clear();
    }
  }
  cout << str.size() << endl;
  return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  ll N; cin >> N;
  vector<ll> leaf(N+1); rep(i,N+1) cin >> leaf[i];
  if(N==0){
    cout << (leaf[0]!=1?-1:1) << endl;
    return 0;
  }
  if(leaf[0]!=0 || leaf[N]==0){
    cout << -1 << endl;
    return 0;
  }
  vector<ll> leaves(N+2,0);
  rep(i,N+1) leaves[i+1] = leaves[i] + leaf[i];
  vector<ll> node(N+1,0);
  node[0]=1;
  for(ll i=1;i<N+1;i++){
    node[i] = min(node[i-1]*2-leaf[i], leaves[N+1]-leaves[i+1]);
    if(i!=N && node[i]<=0){
      cout << -1 << endl;
      return 0;
    }
  }
  if(node[N]!=0){
    cout << -1 << endl;
    return 0;
  }
  ll ans = 0;
  rep(i,N+1) ans += (leaf[i]+node[i]);
  cout << ans << endl;
  return 0;
}


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

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int K, A, B;
    cin >> K >> A >> B;

    bool ok = false;
    for(int x=A; x<=B; x++){
        if(x%K == 0){
            ok = true;
            break;
        }
    }
    if(ok){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }
    return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

// B - Stone Monument
int main(){
    int a, b;
    cin >> a >> b;
    
    int pillar[999];
    pillar[0] = 1;
    for (int i=1;i<1000;++i){
        pillar[i] = pillar[i-1] + (i+1);
    }
    int ans=-1;
    for(int i=1;i<=499500;++i){
        for(int j=0;j<999;++j){
            if(i+a == pillar[j] && i+b == pillar[j+1]){
                ans = i;
                break;
            }
        }
        if(ans != -1) break;
    }

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




Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int S,h,m,s;
  scanf("%d",&S);
  h = S / 3600;
  m=(S-h*3600)/60;
  s = S-h*3600-m*60;
  printf("%d:%d:%d\n",h,m,s );
  return 0;
}

Measured memory_bytes: 592
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <vector>
#include <string>
#include <cctype>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef stringstream strstm;
#define pb push_back
#define PI acos(-1.0)
#define CLR(a) MST(a,0);
#define E 2.718281829459
#define lowbit(x) (x & (-x))
#define DBG(x) cout << (x) << " ";
#define MST(a,b) memset(a,b,sizeof(a));
#define _for(i,a,b) for(int i = (a); i < (b); ++i)
#define _rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define _ech(x,z) for(auto x = z.begin(); x != z.end(); ++x)

const int maxn = 100 + 11;
int a[maxn];

int main(int argc, char const *argv[])
{	
	int n; cin >> n;
	_for(i,0,n) cin >> a[i];
	sort(a,a+n);
	int sa = 0, sb = 0;
	if(n&1){
		for(int i = n-1; i >= 0; i--){
			if(i&1) sa += a[i];
			else sb += a[i];
		}
	}else{
		for(int i = n-1; i >= 0; i--){
			if(i&1) sb += a[i];
			else sa += a[i];
		}
	}

	cout << abs(sa-sb) << endl;



	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int>d(n);
  rep(i,n) cin >> d[i];
  
  int ans = 0;
  
  rep(i,n){
    for (int j = i+1; j < (n); ++j){
      ans += d[i]*d[j];
    }
  }
  
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np

n, k = map(int, input().split())
al_pr = list(map(int, input().split()))

al_pr = sorted(al_pr)

al = al_pr

al_pr = np.array(al_pr)

neg_num = int(np.sum(al_pr < 0))
pos_num = int(np.sum(al_pr > 0))
zero_num = int(np.sum(al_pr == 0))

mod = 10**9+7

f1 = (k % 2 == 1 and max((k-1 - (neg_num // 2)*2), 0) + 1 <= pos_num)
f2 = (k % 2 == 0 and max(k - (neg_num // 2)*2, 0) <= pos_num)

if f1 or f2:
    done = 0
    right = -1
    left = 0
    ans = 1
    while done < k:
        if k - done == 1:
            ans *= al[right]
            ans %= mod
            done += 1
        else:
            if al[right-1] > 0:
                cand1 = al[right] * al[right-1]
            else:
                cand1 = 0
            if al[left+1] < 0:
                cand2 = al[left] * al[left+1]
            else:
                cand2 = 0
            if cand1 > cand2:
                ans *= cand1
                ans %= mod
                right -= 2
            else:
                ans *= cand2
                ans %= mod
                left += 2
            done += 2
elif zero_num > 0:
    ans = 0
elif pos_num == 0:
    ans = 1
    for i in range(k):
        ans *= al[neg_num-1-i]
        ans %= mod
else:
    ans = 1
    for i in range(k):
        ans *= al[i]
        ans %= mod

print(ans)


Measured memory_bytes: 49936
#include<iostream>

int main()
{
    int N, M, X, Y;
    std::cin >> N >> M >> X >> Y;
    int x[N], y[M];
    for (int i = 0; i < N; ++i) {
        std::cin >> x[i];
    }
    for (int i = 0; i < M; ++i) {
        std::cin >> y[i];
    }
/*
    for (int i = 0; i < N; ++i) {
        std::cout << ' ' << x[i] << ' ';
    }
    std::cout << '\n';
    for (int i = 0; i < M; ++i) {
        std::cout << ' ' << y[i] << ' '; 
    }
    std::cout << '\n';
    return(0);
*/
    int min = y[0]; //yの最小値

    int max = x[0]; //xの最大値

    for (int i = 0; i < N; ++i) {
        if (max < x[i]){max = x[i];}
    }

    for (int i = 0; i < M; ++i) {
        if (min > y[i]){min = y[i];}
    }

    if((max < min) && (max > X) && (min <= Y)) {
        std::cout << "No War" << '\n';
    } else {
        std::cout << "War" << '\n';
    }
    return(0);
}

Measured memory_bytes: 256