akhauriyash/Code-Regression huggingface dataset:
// RAKSHIT KADAM

 #include <bits/stdc++.h>
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define MAX 500005
 #include<iomanip>
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define x first
 #define y second
using namespace std;
int gcd(int a, int b);
  
//int power(int x, unsigned int y, unsigned int m)
//{
//    if (y == 0)
//        return 1;
//    int p = power(x, y/2, m) % m;
//    p = (p * p) % m;
//
//    return (y%2 == 0)? p : (x * p) % m;
//}
//ll modInverse(int a, int m)
//{
//    int g = gcd(a, m);
//
//    {
//        // If a and m are relatively prime, then modulo inverse
//        // is a^(m-2) mode m
//
//             return power(a, m-2, m);
//    }
//}
//int gcd(int a, int b)
//{
//    if (b == 0)
//        return a;
//    return gcd(b, a % b);
//
//}
//vector<ll>v[200080];
//ll vis[200080];
//
//void dfs(ll root)
//{
//    vis[root]=1;
//    for(auto it:v[root])
//    {
//        if(vis[it]==0)
//        {
//            dfs(it);
//        }
//    }
//}
void solve()
{
    
}

 int32_t main()
{
    Need_for_speed(activated);
//    satisfy
//    {
//        solve();
//    }
    string a;ll ans;cin>>ans;
    cin>>a;
    for(ll i=0;i<a.length();i++)
    {
        a[i]=char((a[i]-'A'+ans)%26+'A');
    }
    cout<<a;
    return 0;
    }




Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define INF (1000000007)
using namespace std;
typedef long long ll;
struct data{
	int a,b;
	int c;
	data(){}
	data(int aa,int bb,int cc){
		a=aa;
		b=bb;
		c=cc;
	}
	bool operator<(const data& d)const{
		if(a==d.a)return d.b<b;
		return a<d.a;
	}
};

int n;
data dri[200001];
int dp[200001];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&dri[i].a,&dri[i].b);
		dri[i+n].a=dri[i].b;
		dri[i+n].b=dri[i].a;
		dri[i+n].c=1;
	}
	sort(dri,dri+2*n);
	for(int i=0;i<2*n;i++){
		dp[i]=INF;
	}
	for(int i=0;i<2*n;i++){
		int val=dri[i].b,flag=dri[i].c;
		int num=lower_bound(dp,dp+2*n,val)-dp;
		if(num%2==flag)dp[num]=val;
	}
	printf("%d\n",(lower_bound(dp,dp+2*n,INF)-dp));
	return 0;
}

Measured memory_bytes: 6348
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
#define Max 1000001
#define inf INT_MAX
#define llinf LONG_LONG_MAX
#define rep(i,a,b) for(i=a;i<=b;i++)
#define rrep(i,a,b) for(i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pb push_back
#define pf push_front
#define F first
#define S second
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979311599796346854418516159057617187500
const ll N=5e2+1,mod=1000000007;
ll a[N],n,k;
bool check(ll x)
{
	vector<ll> v;
	for(int i=1;i<=n;i++)
	{
		v.pb(a[i]%x);
	}
	sort(all(v));
	ll l=0,r=n-1,moves=0,left=0;
	while(l<=r)
	{
		if(left<=0)
		{
			left+=v[l];
			moves+=v[l++];
		}
		else
		{
			left-=(x-v[r]);
			moves+=(x-v[r--]);
		}
	}
	if(left || moves>2*k)
	{
		return false;
	}
	return true;
}
signed main()
{
    fast;
    ll pro=1,temp,t,m,i,j,l,r,mid,x,y,z,rem,carry=0,ind,ans=0,mx=-llinf,mn=llinf,cnt=0,curr=0,prev,sum=0,flag=1,i1=-1,i2=-1;
    cin>>n>>k;
    rep(i,1,n)
    {
    	cin>>a[i];
    	sum+=a[i];
    }
    for(i=1;i<=sqrt(sum);i++)
    {
    	if(sum%i==0)
    	{
    		if(check(i))
    		{
    			ans=max(ans,i);
    		}
    		if(check(sum/i))
    		{
    			ans=max(ans,sum/i);
    		}
    	}
    }
    cout<<ans<<endl;
	return 0;
} 

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

int main() {

	ll n, a, b; cin >> n >> a >> b;
	ll c = a + b;
	ll quo = n / c;
	ll mod = n % c;
	ll ans;
	if (mod == 0) {
		ans = quo * a;
	}
	else if (mod <= a) {
		ans = quo * a + mod;
	}
	else {
		ans = (quo + 1) * a;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#pragma GCC optimize "trapv"
#include<bits/stdc++.h>

#define ll long long int
#define pb push_back
#define ppb pop_back
#define ff first
#define ss second
#define sz(s) (ll)(s.size())
#define vvi vector<vector<ll>>
#define vi vector<ll>
#define all(a) (a).begin(),(a).end()
#define pii pair<ll,ll>
#define dbg(x,y) cout<<x<<" "<<y<<endl
#define endl '\n'
#define M 1000000007
const ll INF = 1ll<<60;

using namespace std;
//-----------------------------------------//


void solve(){
	ll n;
	cin>>n;
	cout<<(n>=30 ? "Yes" : "No")<<endl;
}



int main(){

	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
	
	int t=1;
	// cin>>t;
	while(t--){
        solve();
	}
}


Measured memory_bytes: 3572
#include "bits/stdc++.h"

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	int a;
	cin >> a;
	P(48 - a);
}

int main() {
    solve();
    return 0;
}


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

int main(){
	int a,b,c,d,e,mn1,mn2;
	cin>>a>>b>>c>>d>>e;
	if(a<=b && a<=c) mn1=a;
	if(b<=a && b<=c) mn1=b;
	if(c<=b && c<=a) mn1=c;
	if(d<=e) mn2=d;
	else{ mn2=e;}

	cout<<mn1+mn2-50<<endl;
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <regex>
#include <cmath>
#include <vector>
#include <queue>
#include <functional>
#include <numeric>
#include <iomanip>
#include <stack>
#include <string>
#include <map>
#include <set>
#define REP(i, n) for(int i = 0;i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
const long long INF = INT64_MAX;

// 重み付きUnionFind
class WeightedUF {
public:
    ll tsize;
    ll mode;
    vector<ll> par;
    vector<ll> rank;
    vector<ll> w;
    WeightedUF() {}
    WeightedUF(const WeightedUF &wuft) {}
    WeightedUF(ll n, ll m = 0) {
        tsize = n;
        mode = m;
        par.resize(n, -1);
        if(!mode) rank.resize(n, 0);
        w.resize(n, 0);
    }
    ll root(ll x) {
        if(par[x] < 0) {
            return x;
        }else {
            ll r = root(par[x]);
            w[x] += w[par[x]];
            return par[x] = r;
        }
    }
    ll weight(ll x) {
        root(x);
        return w[x];
    }
    ll diff(ll x, ll y) {
        return weight(y) - weight(x);
    }
    bool isRoot(ll x) {
        return root(x) == x;
    }
    bool isSame(ll x, ll y) {
        return root(x) == root(y);
    }
    void unite(ll x, ll y, ll _w) {
        _w += weight(x);
        _w -= weight(y);
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(mode) {
            par[x] += par[y];
            par[y] = x;
        }else {
            if(rank[x] < rank[y]) {
                par[y] += par[x];
                par[x] = y;
                w[x] = -_w;
            }else {
                par[x] += par[y];
                par[y] = x;
                if(rank[x] == rank[y]) rank[x]++;
                w[y] = _w;
            }
        }
    }
    ll size(ll x) {
        return -par[root(x)];
    }
};

int main() {
    ll N, M;
    cin >> N >> M;
    vll L(M), R(M), D(M);
    for(int i = 0; i < M; i++)
    {
        cin >> L[i] >> R[i] >> D[i];
    }
    WeightedUF uf(N);
    for(int i = 0; i < M; i++)
    {
        if(uf.isSame(L[i]-1, R[i]-1)) {
            if(uf.diff(L[i]-1, R[i]-1) != D[i]) {
                cout << "No" << endl;
                return 0;
            }
        }else {
            uf.unite(L[i]-1, R[i]-1, D[i]);
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=100003,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    while(N--){
        string S,T;cin>>S>>T;
        int sum=0;
        for(int i=0;i<S.size();i++){
            if(S[i]=='m'){
                if(i>=1&&'2'<=S[i-1]&&S[i-1]<='9'){
                    sum+=(S[i-1]-'0')*1000;
                }else sum+=1000;
            }
            if(S[i]=='c'){
                if(i>=1&&'2'<=S[i-1]&&S[i-1]<='9'){
                    sum+=(S[i-1]-'0')*100;
                }else sum+=100;
            }
            if(S[i]=='x'){
                if(i>=1&&'2'<=S[i-1]&&S[i-1]<='9'){
                    sum+=(S[i-1]-'0')*10;
                }else sum+=10;
            }
            if(S[i]=='i'){
                if(i>=1&&'2'<=S[i-1]&&S[i-1]<='9'){
                    sum+=(S[i-1]-'0')*1;
                }else sum+=1;
            }
        }
        swap(S,T);
        for(int i=0;i<S.size();i++){
            if(S[i]=='m'){
                if(i>=1&&'2'<=S[i-1]&&S[i-1]<='9'){
                    sum+=(S[i-1]-'0')*1000;
                }else sum+=1000;
            }
            if(S[i]=='c'){
                if(i>=1&&'2'<=S[i-1]&&S[i-1]<='9'){
                    sum+=(S[i-1]-'0')*100;
                }else sum+=100;
            }
            if(S[i]=='x'){
                if(i>=1&&'2'<=S[i-1]&&S[i-1]<='9'){
                    sum+=(S[i-1]-'0')*10;
                }else sum+=10;
            }
            if(S[i]=='i'){
                if(i>=1&&'2'<=S[i-1]&&S[i-1]<='9'){
                    sum+=(S[i-1]-'0')*1;
                }else sum+=1;
            }
        }
        swap(S,T);
        
        if(sum>=1000){
            if(sum>=2000){
                cout<<sum/1000;
                cout<<'m';
            }else cout<<'m';
            sum%=1000;
        }
        if(sum>=100){
            if(sum>=200){
                cout<<sum/100;
                cout<<'c';
            }else cout<<'c';
            sum%=100;
        }
        if(sum>=10){
            if(sum>=20){
                cout<<sum/10;
                cout<<'x';
            }else cout<<'x';
            sum%=10;
        }
        if(sum>=1){
            if(sum>=2){
                cout<<sum/1;
                cout<<'i';
            }else cout<<'i';
            sum%=1;
        }
        
        cout<<endl;
    }
}




Measured memory_bytes: 3188
N = int(input())
[*h] = map(int, input().split())
dp = [0 for _ in range(N)]
dp[1] = abs(h[0]-h[1])
for i in range(2, N):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
 
print(dp[N-1])

Measured memory_bytes: 13900
# 新聞Xを購読しているか？ A
# 「はい」A人

# 新聞Yを購読しているか？ B
# 「はい」B人

# 1 <= N < 100
# 0 <= A <= N
# 0 <= B <= N

# 標準入力
inputstr = input()
inputary = inputstr.split(" ")

N = int(inputary[0])
A = int(inputary[1])
B = int(inputary[2])

suball = N - A - B
if suball > 0:
    suball = 0
else:
    suball = abs(suball)

if A >= B:
    print(str(B) + " " + str(suball))
elif A < B:
    print(str(A) + " " + str(suball))


Measured memory_bytes: 3060
# 解説

def main():
    from math import log10

    N, K = map(int, input().split())
    *A, = map(int, input().split())

    def accumulate(a):
        s = 0
        for x in a:
            s += log10(x)
            yield s

    *acc, = accumulate(A)
    for i in range(N - 1, K - 1, -1):
        acc[i] -= acc[i - K]

    for i in range(K, N):
        if acc[i] > acc[i - 1] + 1e-10:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 33016
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define lli long long int
#define all(x) x.begin(),x.end()
#define siz(x) x.size()
#define prs(x,y) x.find(y)!=x.end()
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res;}
inline int level(int n){int ans=0;while(n%2==0){n/=2;ans++;}return ans;}
int main()
{
	cout<<fixed<<setprecision(0);
	long double a,b;
	cin>>a>>b;
	cout<<floor(a*b);
}



Measured memory_bytes: 3796
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0] * n
for i in range(1, n):
  dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]) for j in range(1, k + 1) if i - j >= 0)
print(dp[-1])


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

namespace AtCoderContestScheduling
{
    class Program
    {
        static void Main(string[] args)
        {
            const int n_contest = 26;
            int D = GetInt();
            var c = GetIntArray();
            var s = new int[D][];
            for(int i = 0; i < D; i++)
            {
                s[i] = GetIntArray();
            }

            var decrement = new int[n_contest];
            int[] contest = new int[D];
            //int score = 0;
            for(int i = 0; i < D; i++)
            {
                int max_eval = int.MinValue;
                for (int j = 0; j < n_contest; j++)
                {
                    decrement[j] += c[j];
                    if (max_eval < decrement[j] + s[i][j])
                    {
                        max_eval = decrement[j] + s[i][j];
                        contest[i] = j;
                        decrement[j] = 0;
                    }
                }
                
            }
            //Console.WriteLine(score);
            foreach (var item in contest)
            {
                Console.WriteLine(item + 1);
            }

        }
        public static int GetInt() => int.Parse(Console.ReadLine());
        public static int[] GetIntArray() => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static double GetDouble() => double.Parse(Console.ReadLine());
        public static double[] GetDoubleArray() => Console.ReadLine().Split().Select(double.Parse).ToArray();
        public static long GetLong() => long.Parse(Console.ReadLine());
        public static long[] GetLongArray() => Console.ReadLine().Split().Select(long.Parse).ToArray();

    }
}


Measured memory_bytes: 28916
#include <iostream>
using namespace std;
const int MAXN = 2e5 + 5;
int a[MAXN];

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

    for (int i = 1; i <= n; i++)
    {
        cout << a[i] << endl;
    }
}

Measured memory_bytes: 4412
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    string s,t;
    cin>>s>>t;
    vector<vector<int> > dp(s.length()+10,vector<int> (t.length()+10));
    rep(i,s.length()+10)rep(j,t.length()+10)dp[i][j]=0;
    for(int i=0;i<s.length();i++){
        for(int j=0;j<t.length();j++){
            if (s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j] + 1);
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1], dp[i][j+1]);
        }
    }

    string res="";
    int i=s.length(),j=t.length();
    while (i > 0 && j > 0)
    {
        // (i-1, j) -> (i, j) と更新されていた場合
        if (dp[i][j] == dp[i-1][j]) {
            --i; // DP の遷移を遡る
        }

        // (i, j-1) -> (i, j) と更新されていた場合
        else if (dp[i][j] == dp[i][j-1]) {
            --j; // DP の遷移を遡る
        }

        // (i-1, j-1) -> (i, j) と更新されていた場合
        else {
            res = s[i-1] + res; // このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK
            --i, --j; // DP の遷移を遡る
        }
    }
    cout<<res<<endl;
//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 35840
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 = map(int,input().split())
p = list(map(int,input().split()))
uf = UnionFind(n)
for i in range(m):
    x,y = map(int,input().split())
    uf.union(x-1, y-1)
ans = 0
for i in range(n):
    if uf.find(i) == uf.find(p[i]-1):
        ans += 1
print(ans)

Measured memory_bytes: 20252
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
   ll n,m;cin>>n>>m;
   vector<ll>v[n+1];
   for(ll i=0;i<m;i++)
   {
       ll a,b;cin>>a>>b;
       v[a].push_back(b);
       v[b].push_back(a);
   }
   ll arr[n+1],cnt=0;
   memset(arr,0,sizeof(arr));
   bool vis[n+1];
   memset(vis,0,sizeof(vis));
   queue<ll>q;
   q.push(1);
   vis[1]=1;
   arr[1]=0;
   while(!q.empty())
   {
       ll x=q.front();
       q.pop();
       for(ll i=0;i<v[x].size();i++)
       {
           if(!vis[v[x][i]])
           {
               vis[v[x][i]]=1;
               arr[v[x][i]]=x;
               q.push(v[x][i]);
               cnt++;
           }
       }
   }
   if(cnt!=n-1)
   {
       cout<<"No"<<endl;
   }
   else
   {
       cout<<"Yes"<<endl;
       for(int i=2;i<=n;i++)
        cout<<arr[i]<<endl;
   }

}


Measured memory_bytes: 13060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

// *left_string + S + *right_string
// T = 1の時、swap(left_string, right_string) <- ポインタだけスワップ
// T = 2, F = 1の時、 left_string += C
// T = 2, F = 2の時、 right_string += C

int main()
{
    string S;
    cin >> S;
    string Left_S, Right_S;
    auto l = &Left_S;
    auto r = &Right_S;
    int Q;
    cin >> Q;
    bool rev = false;
    for(int i = 0; i < Q; ++i) {
        int T, F; char C;
        cin >> T;
        if(T == 1) { rev = !rev; swap(l,r); continue; }
        cin >> F >> C;
        if(F == 1) { l->push_back(C); }
        else { r->push_back(C); }
    }
    
    for(int i = l->size()-1; i >= 0; --i) {
        cout << (l->operator[](i));
    }
    if(rev) {
        for(int i = S.size()-1; i >= 0; --i) {
            cout << S[i];
        }
    }
    else {
        cout << S;
    }
    cout << *r;
    cout << endl;
    return 0;
}

Measured memory_bytes: 1088
#include <bits/stdc++.h>
using namespace std;
#define long long long
#define read cin >>
#define echo cout <<
#define fin << '\n'
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  int n, m, x;
  int ac_count = 0;
  int wa_count = 0;
  string s;
  read n >> m;
  vector<string> data(n, "-");
  vector<int> wa_count_vec(n, 0);

  REP(i, m) {
    read x >> s;
    if (s == "WA") {
      if (data[x - 1] != "AC") {
        wa_count_vec[x - 1] += 1;
      }
    } else {
      if (data[x - 1] != "AC") {
        ac_count++;
        wa_count += wa_count_vec[x - 1];
      }
      data[x - 1] = "AC";
    }
  }
  cout << ac_count << " " << wa_count << endl;
}

Measured memory_bytes: 6144
#include <stdio.h>
#include <stdlib.h>

int main (void)
{
	int n;
	scanf("%d",&n);
	int *d;
	d = (int *)malloc(sizeof(int)*(n));
	int i = 0;
	while (i < n)
	{
		scanf("%d",&d[i]);
		i++;
	}
	i = 0;
	int j = 0;
	int sum = 0;
	while (i < n)
	{
		j = i;
		while (j < n)
		{
			if(j != i)
			{
				sum+=d[i]*d[j];
			}
			j++;
		}
		i++;
	}
	printf("%d\n",sum);
	return(0);
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    int K;
    cin >> K;
    int A, B;
    cin >> A >> B;
    for (int i = A; i <= B; i++)
    {
        if (i % K == 0)
        {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll mod=1000000007;
int main()
{
    string s;
    cin>>s;
    ll k;
    cin>>k;
    string pre,post;
    pre.push_back(s[0]);
    for(ll i=1;i<s.size();i++)
    {
        if(s[i]==s[i-1])
            pre.push_back(s[i]);
        else
            break;
    }
    for(ll i=s.size()-1;i>=0;i--)
    {
        if(s[i]==s[0])
            post.push_back(s[i]);
        else
            break;
    }
    ll x=s.size()-post.size();
    ll precount=0,postcount=0,midcount=0;
    /*if(pre.size()+post.size()>1)
    {*/
        for(ll i=pre.size()+1;i<s.size();i++)
        {
            if(s[i]==s[i-1])
            {
                precount++;
                i++;
            }
        }
        for(ll i=1;i<s.size()-post.size();i++)
        {
            if(s[i]==s[i-1])
            {
                postcount++;
                i++;
            }
        }
        for(ll i=pre.size()+1;i<x;i++)
        {
            if(s[i]==s[i-1])
            {
                midcount++;
                i++;
            }
        }
        if(pre.size()==s.size())
        {
            if(k%2)
                cout<<(pre.size()*(k/2))+(s.size()/2)<<endl;
            else
                cout<<pre.size()*(k/2)<<endl;
        }
        else
            cout<<precount+postcount+(midcount*(k-2))+(((pre.size()+post.size())/2)*(k-1))<<endl;
    /*}
    else
    {
        ll count=0;
        for(ll i=1;i<s.size();i++)
        {
            if(s[i]==s[i-1])
            {
                count++;
                i++;
            }
        }
        cout<<count<<endl;
    }*/
}


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

#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int mod = (int)1e7+9;
#define REP0(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<=n;i++)
#define F first
#define S second
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define setbits(x) __builtin_popcountll(x)
#define inf (int)(1e18)
#define prec(x) fixed<<setprecision(x)<<x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(x) x.begin(),x.end()

const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};

void solve(){
   int n;
   cin>>n;
   bool ans = false;
   int count = 0;
   REP0(i,n){
       int x,y;
       cin>>x>>y;
       if(x == y){
           count++;
       }
       else{
           count = 0;
       }

       if(count >= 3){
           ans = true;
           break;
       }
   }
   cout<<(ans == true ?"Yes":"No")<<endl;
  
}


int main(){
    fastio;
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif
    int tc = 1;
    // cin>>tc;
    for(int i=1;i<=tc;i++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    vector<int>A(3);
    REP(i,3)cin>>A[i];
    sort(A.rbegin(),A.rend());
    cout<<(A[0]==A[1]+A[2]?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]
a.sort()

def check():
  ans = 1
  for i in range(n):
    ans *= a[i]
    if ans == 0:
      return 0
    if ans > 10 ** 18:
      return -1
  return ans
p = check()
print(p)

Measured memory_bytes: 21608
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n, x, t;
  cin >> n >> x >> t;

  int ans = 0;
  for (int i = 0; i < n; i += x) ans += t;

  cout << ans << endl;

  return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define pb push_back
#define pf push_front
#define sz(obj) ((int)(obj).size())

int main()
{
  int n, cnt = 0;
  bool flg = 1;

  scanf("%d", &n);
  int a[n];

  for (int i = 0; i < n; i++) scanf("%d", &a[i]);

  while (flg){
    flg = 0;
    for (int i = n - 1; i > 0; i--){
      if (a[i] < a[i - 1]){
        swap(a[i], a[i - 1]);
        flg = 1;
        cnt++;
      }
    }
  }

  printf("%d", a[0]);
  for (int i = 1; i < n; i++){
    printf(" %d", a[i]);
  }
  printf("\n%d\n", cnt);

}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  string s;
  cin >> s;
  
  int countc =0;
  for(int i=2; i<s.size()-1; i++){
  	if(s[i]=='C') countc++;
  }
  int countm=0;
  string t="abcdefghijklmnopqrstuvwxyz";
  for(int i=0; i<s.size(); i++){
  	for(int j=0; j<26; j++){
    	if(s[i]==t[j]) countm++;
    }
  }
  
  if(s[0]=='A' && countc==1 && countm==s.size()-2) cout << "AC" << endl;
  else cout << "WA" << endl;
  
}

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

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
      cin.tie(0);
      ios::sync_with_stdio(false);
      int N;
      cin >> N;
      vector<int> hentati (N);
      for(int i = 0;i < N;i++){
      	cin >> hentati[i];
      }
      SORT(hentati);
      REV(hentati);
      for(int i = 1;i < N;i++){
      	hentati[0] -= hentati[i];
      }
      if(hentati[0] < 0){
      	cout << "Yes" << endl;
      }
      else{
      	cout << "No" << endl;
      }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	int ans = 0, now = 1;
	while (now < b)
	{
		ans++;
		now += a - 1;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

dis = INF
ans = None
for i, h in enumerate(H):
    avg = T - h * 0.006
    if abs(avg - A) < dis:
        dis = abs(avg - A)
        ans = i + 1
print(ans)

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
const int N=100010;
int f[N],n,ans=1,b[N<<1],tot;//f[i]表示i必选的最大价值. 
struct node{int x,y;}a[N];
struct Tree
{
	int l,r,dat;
	#define l(x) t[x].l
	#define r(x) t[x].r
	#define dat(x) t[x].dat
}t[N<<3]; 
inline bool cmp(node x,node y){return x.x<y.x;}
inline int raw(int x) {return lower_bound(b+1,b+tot+1,x)-b;}
inline void build(int p,int l,int r)
{
	l(p)=l,r(p)=r;
	if(l==r) return;
	int mid=l+r>>1;
	build(p<<1,l,mid);
	build(p<<1|1,mid+1,r);
}
inline void alter(int p,int x,int k)
{
	if(l(p)==r(p)) {dat(p)=max(dat(p),k);return;}
	int mid=l(p)+r(p)>>1;
	if(x<=mid) alter(p<<1,x,k);
	else       alter(p<<1|1,x,k);
	dat(p)=max(dat(p<<1),dat(p<<1|1));
}
inline int ask(int p,int l,int r)
{
	if(l<=l(p)&&r>=r(p)) return dat(p);
	int mid=l(p)+r(p)>>1;
	int ans=0;
	if(l<=mid) ans=max(ans,ask(p<<1,l,r));
	if(r>=mid+1) ans=max(ans,ask(p<<1|1,l,r));
	return ans; 
}
int main()
{
	//freopen("1.in","r",stdin);
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		int x,l;cin>>x>>l;
		b[i<<1]=a[i].x=x-l;b[i<<1|1]=a[i].y=x+l;
	}
	sort(b+1,b+(n<<1)+1);
	tot=unique(b+1,b+(n<<1)+1)-b-1;
	build(1,1,tot);
	sort(a+1,a+n+1,cmp);
	f[1]=1;
	alter(1,raw(a[1].y),1);
	for(int i=2;i<=n;++i)
	{
		f[i]=ask(1,1,raw(a[i].x))+1;
		alter(1,raw(a[i].y),f[i]);
//		for(int j=1;j<i;++j) if(a[j].y<=a[i].x) f[i]=max(f[i],f[j]);
//		f[i]++; 
		ans=max(ans,f[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 11520
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl;
#define pno cout << "no" << endl;
#define pYe cout << "Yes" << endl;
#define pNo cout << "No" << endl;
#define pYE cout << "YES" << endl;
#define pNO cout << "NO" << endl;
#define prin(num) cout << num << endl;
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 10000000000
#define MOD 1000000007LL
#define MAX_V 100005
#define MAX_E 100005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef priority_queue<P> PQ;

class Edge {
public:
    ll t, w;
    Edge (ll t, ll w): t(t), w(w) {}
};

ll N;
P x[100000], y[100000];
vector<Edge> G[200000];
ll d[100000], color[100000];

void prim() {
    ll i, u;
    for(i=0; i<N; i++) {
        d[i]=INF;
        color[i]=WHITE;
    }
    priority_queue<P> PQ;
    PQ.push(P(0, 0));
    d[0]=0;
    
    while(PQ.size()) {
        P f=PQ.top(); PQ.pop();
        u=f.second;
        
        color[u]=BLACK;
        if(d[u]<f.first*(-1)) continue;
        
        for(i=0; i<G[u].size(); i++) {
            Edge e=G[u][i];
            if(color[e.t]!=BLACK && d[e.t]>e.w) {
                d[e.t]=e.w;
                PQ.push(P(-d[e.t], e.t));
            }
            
        }
        
    }
    ll ans=0;
    for(i=0; i<N; i++) {
        ans+=d[i];
    }
    
    prin(ans);
}


void add_edge(ll s, ll t, ll w) {
    G[s].push_back(Edge(t, w));
    G[t].push_back(Edge(s, w));
}

int main(void) {
    ll i;
    cin >> N;
    for(i=0; i<N; i++) {
        cin >> x[i].first >> y[i].first;
        x[i].second=i;
        y[i].second=i;
    }
    sort(x, x+N);
    sort(y, y+N);
    
    for(i=0; i<N-1; i++) {
        add_edge(x[i].second, x[i+1].second, x[i+1].first-x[i].first);
        add_edge(y[i].second, y[i+1].second, y[i+1].first-y[i].first);
    }
    
    prim();
}

Measured memory_bytes: 20340
//日野茜★担当
//的場梨沙★担当
//結城晴★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>

using namespace std;

int main(void) {
    string S,T;
    cin>>S>>T;

    int N=S.length();
    int ans=0;


    for(int i=0;i<N;i++){
        if(S[i]!=T[i]){
            ans++;
        }
    }


    cout<<ans<<endl;

}

Measured memory_bytes: 3840
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[]$) {
        Scanner c=new Scanner(System.in);
        int n=c.nextInt(),m=c.nextInt(),gcd=BigInteger.valueOf(n).gcd(BigInteger.valueOf(m)).intValue();
        String s=c.next(),t=c.next();
        System.out.println(java.util.stream.IntStream.range(0,gcd).filter(k->s.charAt(k*n/gcd)!=t.charAt(k*m/gcd)).mapToLong(k->-1).findAny().orElse((long)n*m/gcd));
    }
}

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

int main() {
    ll n,m;
    std::cin >> n>>m;
    if(m%2==0){
        for (int i = 0; i < m/2; i++) {
            std::cout << i+1<<" "<<m-i << std::endl;
        }
        for (int i = 0; i < m/2; i++) {
            std::cout << m+i+1<<" "<<m+m+1-i << std::endl;
        }
    }else{
        for (int i = 0; i < m/2; i++) {
            std::cout << i+1<<" "<<m-i << std::endl;
        }
        for (int i = 0; i < m/2+1; i++) {
            std::cout << m+i+1<<" "<<m+m+1-i << std::endl;
        }
    }
}


Measured memory_bytes: 3640
//run: g++ -std=c++14 -o run_sol.exe solution.cpp -DLOCAL_JUDGE
#include<bits/stdc++.h>
#define INF 0x7fffffff
#define INFLL 1e17
#define PI 2*acos(0.0)
#define show(x) cout<< #x <<" is "<< x <<"\n"
using namespace std;

#define FS first
#define SC second
#define PB(t) push_back(t)
#define LEN(t) ((int)t.size())
#define ALL(t) t.begin(),t.end()
#define MP(x, y) make_pair((x), (y))
#define Fill(a,c) memset(&a, c, sizeof(a))
#define POPCOUNT __builtin_popcount

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<PII> VPII;

int main() {
    #ifdef LOCAL_JUDGE
        freopen("../input.txt", "rt", stdin);
        freopen("../output.txt", "wt", stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(NULL);

    for (LL n; cin >> n;) {
        LL res = n + n;
        for (LL i = 1; i*i <= n; i++) {
            if (n % i == 0) {
                res = min(res, i + n / i);
            }
        }

        cout << res - 2 << "\n";
    }
return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define SZ(x) ((int)(x).size())
#define MEM(x,a) memset(x,a,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
const ll mod=1000000007,N=1e5+5,M=1e5+5,INF=0x3f3f3f3f;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//head

int main(void){
    int n;
    cin>>n;
    VI a(n+1);
    VL dp(n+1),sum(n+1);
    rep(i,1,n+1){
        cin>>a[i];
    }
    sum[1]=a[1];
    rep(i,2,n+1)sum[i]=a[i]+sum[i-2];
    rep(i,2,n+1){
        if(i&1)dp[i]=max(dp[i-1],dp[i-2]+a[i]);
        else dp[i]=max(a[i]+dp[i-2],sum[i-1]);
    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 7212
#include<bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<vector<int> >  vec2int;
typedef vector<ll >     vecll;
typedef vector<string > vecstr;
typedef vector<bool > vecbool;
typedef vector<bool > vecbool;
////////////////////////////////////////////////
int main()
{
  int n; cin >> n;
  unordered_map<int, int >mp;
  vecint a(n,0);
  int tmp;
  int num = 0;
  REP(i,n){
    cin >> tmp;
    a[i] = tmp;
    mp[tmp]++;
    if(mp[tmp] > 1){
      num ++;
    }
  }
  // sort(all(a));
  // REP(i,n){
  //   cout << a[i] << endl;
  // }
  // cout << num << endl;
  cout << n - 2*((num + 1)/2) << endl;

}

Measured memory_bytes: 4772
s=input()
res=[0]*26
for i in range(len(s)):
    res[ord(s[i])-97]=1
ans="-1"
for i in range(26):
    if res[i]==0:
        ans=s+chr(i+97)
        break
if ans=="-1":
    for i in range(26):
        for j in range(ord(s[25-i])-96,26):
            if res[j]==0:
                ans=s[:25-i]+chr(j+97)
                break
        if ans!="-1":
            break
        res[ord(s[25-i])-97]=0
print(ans)

Measured memory_bytes: 3064
// Author : Cyrus 

#include <bits/stdc++.h>

using namespace std;

int a[100005];

int main()
{
    int n;
    
    long long int x=0;
    
    cin >> n;
    
    for(int i=0; i<n; i++)
    {
        cin >> a[i];
        
        x ^= a[i];
        
    }
    
    if(x) cout << "No" << endl;
    
    else cout << "Yes" << endl;
    
    return 0;
}


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

#pragma GCC optimize("O3")

long long dp[1000005];

const long long MOD = 1e9+7;

int main(){
    int N, H, D;
    scanf("%d%d%d", &N, &H, &D);

    long long retainWays = 0;
    long long fact = 1;
    for(int i = 1; i <= N; i ++){
        fact = fact*i%MOD;
        retainWays += fact;
    }
    retainWays %= MOD;

    //printf("retainWays=%lld\n", retainWays);

    dp[0] = fact;
    long long slidingWindowSum = dp[0];
    for(int i = 1; i <= H; i ++){
        dp[i] = slidingWindowSum;

        if(i == H){break;}

        dp[i] = dp[i]*retainWays%MOD;
        slidingWindowSum += dp[i];
        if(i >= D){slidingWindowSum -= dp[i-D];}

        slidingWindowSum = slidingWindowSum%MOD;
        if(slidingWindowSum < 0){slidingWindowSum += MOD;}

        //printf("dp[%d]=%lld\n", i, dp[i]);
    }

    printf("%lld", dp[H]);
    return 0;
}


Measured memory_bytes: 8064
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int64_t sum=0;
    for(int64_t i=1;i<=n;i++){
        if(i%3!=0 && i%5!=0) sum += i;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3584
#include "bits/stdc++.h"


using namespace  std;

int main(){
  int n;cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
sort(v.begin(),v.end());
  
cout<<v[n/2]-v[n/2-1]<<endl;

}

Measured memory_bytes: 640
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

const int64 mod = 998244353;

// End of template.

int64 modpow(int64 base, int64 e) {
    base %= mod;
    int64 res = 1;
    while (e > 0) {
        if (e & 1) res  = (res * base) % mod;
        base = (base * base) % mod;
        e >>= 1;
    }
    return res;
}

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

    int n;
    int d[100100];
    int t[100100];
    int m = 0;
    scanf("%d", &n);
    rep(i, n) scanf("%d", &d[i]);
    memset(t, 0, sizeof t);

    rep(i, n) {
        if (m < d[i]) m = d[i];
        t[d[i]] += 1;
    }

    int64 ans = 1;
    if (d[0] != 0 || t[0] != 1) {
        print(0);
        return 0;
    }


    for (int i = 1; i <= m; ++i) {
        if (t[i] == 0) ans = 0;
        ans *= modpow(t[i - 1], t[i]);
        ans %= mod;
    }


    print(ans);



    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
  int N; cin >> N;
  Graph G(N);
  rep(i,N-1) {
    int a,b; cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int> c(N);
  rep(i,N) cin >> c[i];

  vector<int> d(N);
  vector<pair <int, int>> num(N);

  rep(i,N) num[i] = make_pair(G[i].size(),i);

  sort(num.begin(),num.end());
  sort(c.begin(),c.end());
  reverse(c.begin(),c.end());

  queue<int> que;
  que.push(num[N-1].second);
  d[num[N-1].second] = c[0];
  int j = 1;
  int M = 0;
  while(!que.empty()) {
    int v = que.front();
    que.pop();
    rep(i,G[v].size()) {
      if (d[G[v][i]] != 0) continue;
      d[G[v][i]] = c[j];
      j++;
      que.push(G[v][i]);
      M += min(d[v],d[G[v][i]]);
    }
  }

  cout << M << endl;
  rep(i,N) cout << d[i] << " ";
  cout << endl;
  }

Measured memory_bytes: 1152
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<cmath>
#include<functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void sort(int &a,int &b)
{
    if(a>b)
        swap(a,b);
}
void open(const char *s)
{
#ifndef ONLINE_JUDGE
    char str[100];
    sprintf(str,"%s.in",s);
    freopen(str,"r",stdin);
    sprintf(str,"%s.out",s);
    freopen(str,"w",stdout);
#endif
}
int rd()
{
    int s=0,c;
    while((c=getchar())<'0'||c>'9');
    do
    {
        s=s*10+c-'0';
    }
    while((c=getchar())>='0'&&c<='9');
    return s;
}
int upmin(int &a,int b)
{
    if(b<a)
    {
        a=b;
        return 1;
    }
    return 0;
}
int upmax(int &a,int b)
{
    if(b>a)
    {
        a=b;
        return 1;
    }
    return 0;
}
struct graph
{
    int v[200010];
    int t[200010];
    int h[100010];
    int n;
    graph()
    {
        n=0;
    }
    void add(int x,int y)
    {
        v[++n]=y;
        t[n]=h[x];
        h[x]=n;
    }
};
graph g1,g2,g;
int fa[100010];
int fb[100010];
int a1[100010];
int a2[100010];
int st[100010];
int top;
int b[100010];
int c[100010];
void dfs1(int x)
{
    int i;
    for(i=g1.h[x];i;i=g1.t[i])
        dfs1(g1.v[i]);
    if(a1[x])
        st[++top]=x;
    while(top>=2)
    {
        g.add(st[top],st[top-1]);
        g.add(st[top-1],st[top]);
        top-=2;
    }
}
void dfs2(int x)
{
    int i;
    for(i=g2.h[x];i;i=g2.t[i])
        dfs2(g2.v[i]);
    if(a2[x])
        st[++top]=x;
    while(top>=2)
    {
        g.add(st[top],st[top-1]);
        g.add(st[top-1],st[top]);
        top-=2;
    }
}
void dfs(int x,int v)
{
    c[x]=v;
    b[x]=1;
    int i;
    for(i=g.h[x];i;i=g.t[i])
        if(!b[g.v[i]])
            dfs(g.v[i],-v);
}
int main()
{
//  open("agc018f");
    int n;
    scanf("%d",&n);
    int i;
    int rt1,rt2;
    for(i=1;i<=n;i++)
        a1[i]=a2[i]=1;
    for(i=1;i<=n;i++)
    {
        scanf("%d",&fa[i]);
        if(fa[i]==-1)
            rt1=i;
        else
        {
            g1.add(fa[i],i);
            a1[fa[i]]^=1;
        }
    }
    for(i=1;i<=n;i++)
    {
        scanf("%d",&fb[i]);
        if(fb[i]==-1)
            rt2=i;
        else
        {
            g2.add(fb[i],i);
            a2[fb[i]]^=1;
        }
    }
    for(i=1;i<=n;i++)
        if(a1[i]!=a2[i])
        {
            printf("IMPOSSIBLE\n");
            return 0;
        }
    printf("POSSIBLE\n");
    top=0;
    dfs1(rt1);
    top=0;
    dfs2(rt2);
    for(i=1;i<=n;i++)
        if(!b[i])
            dfs(i,1);
    for(i=1;i<=n;i++)
        if(!a1[i])
            printf("0 ");
        else
            printf("%d ",c[i]);
    return 0;
}


Measured memory_bytes: 10752
import sys
# N,M = [int(n) for n in input().split()]
# S = str(input())
# T = str(input())
# a,b,c = [int(n) for n in input().split()]
# ←W, E→
# EEELWWWWにしたい
N = int(input())
S = str(input())
cusum = [0]*N
cusum[0] = 1 if S[0] == 'E' else 0

for i in range(1,N):
    cusum[i] = cusum[i-1]
    if S[i] == 'E':
        cusum[i]+=1
ans = 999999999999
for i in range(N):
    if i == 0:
        tmp = cusum[N-1] - cusum[0]
    elif i == N-1:
        tmp = N-1 - cusum[N-2]
    else:
        tmp = i - cusum[i-1]
        tmp += cusum[N-1] - cusum[i]
    ans = min(tmp, ans)
print(ans)


Measured memory_bytes: 15264