akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    int n;
    cin >> n;
    vector<ll> sum(n+1);
    sum[0] = 0;
    rep(i,n) {
        ll a;
        cin >> a;
        sum[i+1] = sum[i]+a;
    }
    ll ans = 0;
    map<ll,ll> m;
    rep(i,n+1) {
        ll l = sum[i];
        if(m.count(l)) ans += m[l];
        m[l]++;
    }
    cout << ans << endl;
}

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

int main() {

  long long N,A,B;
  cin >> N >> A >> B;

  vector<long long> X(N);
  for(int i = 0;i < N;i++) {
    cin >> X.at(i);
  }

  long long sum = 0;
  for(int i = 0;i < N-1;i++) {
    int dis = X.at(i+1) - X.at(i);
    if(dis * A > B) sum += B;
    else sum += dis * A;
  } 

  cout << sum << endl;
  

}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#include <iomanip>
#include <tuple>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;


int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n);
	ll ans=0;
	rep(i,0,n){
		cin >> a[i];
		ans+=a[i]-1;
	}
	cout << ans << endl;

}


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

int main() {
	int N;
	cin >> N;

	int a;
	bool res = true;
	for (int i = 0; i < N; i++) {
		cin >> a;
		if (a % 2 == 0) {
			if (a % 3 != 0 && a % 5 != 0) {
				res = false;
				break;
			}
		}
	}

	if (res) {
		cout << "APPROVED" << endl;
	}
	else {
		cout << "DENIED" << endl;
	}

}

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

struct ModInt {
  using M = ModInt;
  long long v;
  ModInt(long long _v = 0) : v(_v % MOD + MOD) { norm(); }
  M& norm() {
    v = (v < MOD) ? v : v - MOD;
    return *this;
  }
  M operator+(const M& x) const { return M(v + x.v); }
  M operator-(const M& x) const { return M(v + MOD - x.v); }
  M operator*(const M& x) const { return M(v * x.v % MOD); }
  M operator/(const M& x) const { return M(v * x.inv().v); }
  M& operator+=(const M& x) { return *this = *this + x; }
  M& operator-=(const M& x) { return *this = *this - x; }
  M& operator*=(const M& x) { return *this = *this * x; }
  M& operator/=(const M& x) { return *this = *this / x; }
  friend istream& operator>>(istream& input, M& x) {
    return input >> x.v, x.norm(), input;
  }
  friend ostream& operator<<(ostream& output, const M& x) {
    return output << x.v;
  }
  M pow(long long n) const {
    M x(v), res(1);
    while (n) {
      if (n & 1) res *= x;
      x *= x;
      n >>= 1;
    }
    return res;
  }
  M inv() const { return this->pow(MOD - 2); }

  static long long MOD;
  static vector<M> fact, finv;
  static void build(int n) {
    fact.assign(n + 1, M(1));
    finv.assign(n + 1, M(1));
    for (int i = 1; i < n + 1; i++) fact[i] = fact[i - 1] * M(i);
    for (int i = 0; i < n + 1; i++) finv[i] = fact[i].inv();
  }
  static M comb(int n, int k) {
    if (n < k || k < 0) return M(0);
    return fact[n] * finv[n - k] * finv[k];
  }
};
vector<ModInt> ModInt::fact = vector<ModInt>();
vector<ModInt> ModInt::finv = vector<ModInt>();
long long ModInt::MOD = 1e9 + 7;

int main() {
  int p;
  cin >> p;
  vector<int> a(p);
  for (int i = 0; i < p; i++) cin >> a[i];
  ModInt::MOD = p;
  ModInt::build(p);
  vector<ModInt> b(p, 0);
  for (int i = 0; i < p; i++) {
    if (a[i] == 0) continue;
    b[0] += ModInt(1);
    ModInt pw = ModInt(1);
    for (int j = p - 1; j >= 0; j--) {
      b[j] -= pw * ModInt::comb(p - 1, j);
      pw *= ModInt(-i);
    }
  }
  for (int i = 0; i < b.size(); i++) {
    if (i > 0) cout << ' ';
    cout << b[i];
  }
  cout << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"
 
 
int pow1(int n, int p)
{
	if(p==0)	return 1;
	int x=pow1(n, p/2);
	x=(x*x)%mod;
	if(p%2==0)
		return x;
	else
		return (x*n)%mod;
}
 
int32_t main()
{
	fast;

	int n, k;
	cin>>n>>k;
	vector<int> v(n);
	for(int i=0;i<n;i++)
	{
		cin>>v[i];
	}

	sort(v.begin(), v.end(), greater<int>());

	int x=0;

	for(int i=k;i<n;i++)
	{
		x+=v[i];
	}

	cout<<x<<endl;

	return 0;
}

Measured memory_bytes: 1792
N=int(input())
s=[]
if N==0:
    print(0)
else:
    while N!=1:
        if N%2==0:
            s.append(0)
            N=-N//2
        else:
            s.append(1)
            N=(1-N)//2
    s.append(1)
    print(*reversed(s),sep='')

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

int check_c(char *s, int len) {
    int check = -1;
    for (int i=2; i<len-1; i++) {
        if (s[i] == 'C') check = i;
    }
    return check;
}

int check_small(char *s, int ple_c, int len) {
    int check = 1;
    for (int i=1; i<len; i++) {
        if (i == ple_c) continue;
        else {
            if (s[i] < 'a' || s[i] > 'z') check = 0;
        }
    }
    return check;
}

int main() {
    char s[12];
    fgets(s, 12, stdin);
    int len = strlen(s);
    s[len] = '\0';
    len--;
    if (s[0] != 'A') {
        printf("WA\n");
        return 0;
    }
    int ple_c = check_c(s, len);
    if (ple_c < 0) {
        printf("WA\n");
        return 0;
    }
    if (!check_small(s, ple_c, len)) {
        printf("WA\n");
        return 0;
    }
    printf("AC\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
#include <stack>
#include <cassert>
#include <forward_list>
#include <chrono>
#include <deque>
#include <list>
#include <random>
#include <cstdio>
#include <sstream>

int main()
{
	int n, l;
	
	std::cin >> n >> l;
	
	std::vector<int> num(n);
	
	for (int i = 0; i < n; i++)
	{
		num[i] = l + (i + 1) - 1;
	}

	std::sort(num.begin(), num.end(), [](int a, int b) {return std::abs(a) > std::abs(b); });

	std::cout << std::accumulate(num.begin(), num.end() - 1, 0) << std::endl;

	return 0;
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

LL P = 1000000007LL;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	LL N;
	vector<LL> A;
	LL S = 0;
	cin >> N;
	for(int i=0; i<N; i++){
		LL a;
		cin >> a;
		A.push_back(a);
		S += a;
	}

	LL ans = 0;
	for(int i=0; i<N-1; i++){
		S = S - A[i];
		S %= P;
		if(S < 0){
			S += P;
		}
		ans += (A[i] * S);
		ans %= P;
		if(ans < 0){
			ans += P;
		}
	}
	ans %= P;
	if(ans < 0){
		ans += P;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 5320
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;


int main() {
  int n, k;
  cin >> n >> k;
  vector<int> c(n), p(n);
  rep(i,n) {
    cin >> p[i];
    p[i]--;
  }
  rep(i,n) cin >> c[i];
  ll ans = -1e18;
  rep(si,n) {
    int x = si;
    vector<int> s;
    ll tol  = 0;
    while(1) {
      x = p[x];
      tol += c[x];
      s.push_back(c[x]);
      if(x==si) break;
    }
    int l = s.size();
    ll t = 0;
    rep(i,l) {
      if(i+1>k) break;
      t += s[i];
      ll now = t;
      if(tol>0) {
        ll e = (k-i-1)/l;
        now += tol*e;
      }
      ans = max(ans,now);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
int main(){
  long N;
  cin >> N;
  long long sum = 0;
  for(long i = 1; i < N+1; i++){
    if(i%3 != 0 && i%5 != 0){
      sum = sum+i;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3604
from math import sqrt
from itertools import permutations
N = int(input())
roots = permutations(range(N))
points = [[int(i) for i in input().split()] for _ in range(N)]


def calc_distance(a, b):
    return sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)


distance_sum = 0
cnt = 0
for root in roots:
    cnt += 1
    _d = 0
    for i in range(1, N):
        prev = root[i-1]
        current = root[i]
        _d += calc_distance(points[prev], points[current])
    distance_sum += _d
print(distance_sum / cnt)


Measured memory_bytes: 3064
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
print(math.factorial(N)%(10**9+7))

Measured memory_bytes: 42992
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
       Scanner scan = new Scanner(System.in);
       int t = scan.nextInt();
       int a = t / 500;
       int b = (t - a*500) / 5;
       System.out.println(a*1000+b*5);
    }
}

Measured memory_bytes: 21588
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 400000;

double f(int n) {
	if (n == 0) { return 1; }
	
}




int main() {
	
	double N;
	cin >> N;

	double x[10], y[10];

	rep(i, N) cin >> x[i] >> y[i];

	double dis[10][10];

	rep(i, N) {
		rep(j, N) {
			dis[i][j] = sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
		}
	}

	double ans = 0;

	rep(i, N) {
		rep(j, N) {
			ans += dis[i][j] / N;

		}
	}

	cout << fixed << setprecision(10);
	cout << ans;
	


	system("PAUSE");

}

Measured memory_bytes: 504
class Lake
  attr_reader :left, :right, :area

  def initialize(left, right)
    @left = left
    @right = right
    @area = right - left
  end

  def under_layer?(lake)
    lake.left < left && right < lake.right
  end

  def sum(lake)
    @area += lake.area
  end
end

sections = gets.chomp.split('')
lakes = []

down_hill_pos = []

sections.each_with_index do |section, i|
  case section
  when '_'
  when '\\'
    down_hill_pos << i
  when '/'
    unless down_hill_pos.empty?
      lake = Lake.new(down_hill_pos.pop, i)
      while !lakes.empty? && lakes.last.under_layer?(lake)
        under_lake = lakes.pop
        lake.sum(under_lake)
      end
      lakes << lake
    end
  end
end

puts lakes.sum(0, &:area)
puts ([lakes.count] + lakes.map(&:area)).join("\s")


Measured memory_bytes: 9604
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.DataInputStream;
import java.util.Arrays;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.InputStream;

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

    static class BFrog2 {
        public void solve(int testNumber, Reader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] a = new int[n];
            int[] dp = new int[n];
            Arrays.fill(dp, Integer.MAX_VALUE);
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
            }
            dp[0] = 0;
            dp[1] = Math.abs(a[1] - a[0]);
            for (int i = 2; i < n; ++i) {
                for (int j = 1; j <= Math.min(i, k); ++j) {
                    int x = Math.abs(a[i] - a[i - j]) + dp[i - j];
                    dp[i] = Math.min(dp[i], x);
                }
            }
            out.println(dp[n - 1]);
        }

    }

    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer;
        private int bytesRead;

        public Reader(InputStream in) {
            din = new DataInputStream(in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) {
            try {
                din = new DataInputStream(new FileInputStream(file_name));
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public int nextInt() {
            int ret = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            boolean neg = (c == '-');
            if (neg) {
                c = read();
            }
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (neg) {
                return -ret;
            }
            return ret;
        }

        private void fillBuffer() {
            try {
                bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
                if (bytesRead == -1) {
                    buffer[0] = -1;
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        private byte read() {
            if (bufferPointer == bytesRead) {
                fillBuffer();
            }
            return buffer[bufferPointer++];
        }

    }
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
    using namespace std;
 
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define mod 1000000007
    #define qmod 998244353
    #define M 1000001
    #define endl "\n"
    #define all(a) (a).begin(),(a).end()
    #define rep(i,a,b) for(int i=a;i<b;++i)
    #define repr(i,a,b) for(int i=a;i>=b;--i)
    #define F first
    #define S second
    #define pb push_back
    #define mp make_pair
 
    typedef long long ll;
    typedef pair<int,int> pii;
    typedef vector<ll> vi;
    typedef vector<string> vs;
    typedef vector<pii> vii;
    typedef vector<vi> vvi; 
    
    int main(){
        
   /* #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin); 
    freopen("output.txt","w",stdout);   
    #endif */
 
        fast;
        int n;
        ll ans=0;
        cin>>n;
        vi a(n);
        rep(i,0,n) cin>>a[i];
        if(!(n&1)){
            ll sum=0;
            rep(i,0,n) if(i&1) sum+=a[i];
            ans=sum;
            rep(i,0,n/2){
              sum+=a[i*2]-a[i*2+1];
              ans=max(ans,sum);
            }
        }
        else{
            vvi v(n+1,vi(3,0));
            rep(i,0,n){
                  if(i&1){
                    v[i+1][0]=v[i][0];
                    v[i+1][1]=max(v[i][0],v[i][1]+a[i]);
                    v[i+1][2]=v[i][2];
                  }
                  else{
                    v[i+1][0]=v[i][0]+a[i];
                    v[i+1][1]=v[i][1];
                    v[i+1][2]=max(v[i][1],v[i][2]+a[i]);
                  }
            }
            ans=max({v[n][0],v[n][1],v[n][2]});
        }
        cout<<ans;
        return 0;  
    }       
 
 
    //keep it simple stupid

Measured memory_bytes: 15604
def main():
    N = int(input())
    xyh = [[int(i) for i in input().split()] for _ in range(N)]
    sx, sy, sh = [(x, y, h) for x, y, h in xyh if h != 0][0]
    for cx in range(101):
        for cy in range(101):
            H = sh + abs(sx - cx) + abs(sy - cy)
            if all(max(H-abs(x - cx)-abs(y - cy), 0) == h for x, y, h in xyh):
                return print(cx, cy, H)


if __name__ == '__main__':
    main()


Measured memory_bytes: 48988
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	ll N;
	cin >> N;
	string S;
	cin >> S;
	ll ans=1;
	for(ll i=1;i<N;i++){
		if(S[i]!=S[i-1])ans++;
	}
	cout << ans;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
using namespace std;
int ch[2][1 << 22], id[22][1 << 22], cnt, a[22][1 << 22], siz[22], c[22][1 << 22], num[22][1 << 22], ans[22], n, k;
char s[1 << 22];
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
void get()
{
	id[0][0] = (cnt ++); ch[0][id[0][0]] = ch[1][id[0][0]] = -1;
	for(int i = 1; i <= 20; i ++)
	{
		int t = (1 << i), k = (t >> 1);
		for(int s = 0; s < t; s ++)
		{
			id[i][s] = (cnt ++); int p = (s & k), q = (p ? 1 : 0);
			ch[q][id[i][s]] = id[i - 1][s ^ p];
			ch[!q][id[i][s]] = ch[!q][id[i - 1][s ^ p]];
		}
	}
}
void dfs(int d, int s)
{
	if(ans[d] == -1) ans[d] = s;
	for(int p = 0; p <= 1; p ++)
	{
		int tot = 0;
		for(int i = 0; i < siz[d]; i ++)
		{
			int to = ch[p][a[d][i]]; if(to == -1) continue;
			if(num[d + 1][to] == -1) num[d + 1][a[d + 1][siz[d + 1]] = to] = siz[d + 1], siz[d + 1] ++;
			tot += c[d][i]; c[d + 1][num[d + 1][to]] += c[d][i];
		}
		if(tot >= k) dfs(d + 1, (s << 1) | p);
		for(int i = 0; i < siz[d + 1]; i ++) num[d + 1][a[d + 1][i]] = -1, c[d + 1][i] = 0;
		siz[d + 1] = 0;
	}
}
int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read(); k = read(); get();
	for(int i = 0; i <= n; i ++) for(int j = 0; j < cnt; j ++) num[i][j] = -1;
	for(int i = 0; i <= n; i ++)
	{
		scanf("%s", s); int t = (1 << i);
		for(int j = 0; j < t; j ++) if(s[j] == '1') num[0][a[0][siz[0]] = id[i][j]] = siz[0], c[0][num[0][id[i][j]]] ++, siz[0] ++;
		ans[i] = -1;
	}
	dfs(0, 0);
	for(int i = n; i >= 0; i --)
		if(ans[i] != -1)
		{
			for(int j = i - 1; j >= 0; j --)
			putchar(((ans[i] >> j) & 1) + '0');
			puts(""); return 0;
		}
	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 388352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m;
ll x[100010];
vector<ll> v;
int main(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++) scanf("%lld",&x[i]);
    sort(x,x+m);
    for(int i=1;i<m;i++) v.push_back(x[i]-x[i-1]);
    sort(v.begin(),v.end());
    ll ans=0;
    for(int i=1;i<m;i++) ans+=(x[i]-x[i-1]);
    int cnt=0;
    for(int i=v.size()-1;i>=0;i--){
        if(cnt==(n-1)) break;
        ans-=v[i];cnt++;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),m=nxt();
    bool f=0;
    vector <string> a(n);
    vector <string> b(m);
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<m;i++)
        cin>>b[i];
    for(int i=0;i<=n-m;i++){
        for(int j=0;j<=n-m;j++)
        {
            bool temp=1;
            for(int x=0;x<m;x++)
                for(int y=0;y<m;y++)
                    if(b[x][y]!=a[x+i][y+j])
                    {
                        temp=0;
                        break;
                    }
                if(temp)
                {
                    f=1;
                    break;
                }
        }
        if(f)
            break;
    }
    if(f)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    
    
    
    return 0;   
}




 
 


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

using namespace std;

typedef long long ll;
#define INF (int)1e9

int main(){
    int T = 1;
    //cin >> T;
    while (T--){
        int a,b;
        cin >> a >> b;
        cout << (long long) a*b << endl;
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;

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

    int a, b;
    cin >> a >> b;

    int res = 0;

    for (int i = a; i <= b; i++)
    {
        int i_ = i;
        int n[5];
        REP(j, 5)
        {
            n[j] = i_ % 10;
            i_ /= 10;
        }

        if (n[0] == n[4] && n[1] == n[3])
            res++;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
s = input().rstrip()
t = input().rstrip()

if s == t:
    print(N)
    exit()

tmp = s + t
for i in range(N):
    if s[i:] == t[:N-i]:
        tmp = s + t[N-i:]
        if len(tmp) < N:
            continue
print(len(tmp))


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

int main() {
    vector<int> num(3);
    for (int i = 0; i < 3; i++) {
        cin >> num.at(i);
    }
    swap(num.at(0), num.at(1));
    swap(num.at(0), num.at(2));

    for (int i = 0; i < 3; i++) {
        cout << num.at(i);
        if (i != 2) {
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}

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

typedef long long ll;
#define mod 1000000007

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

void solve() {
    int n;
    cin>>n;
    if(n >= 30){
        cout<<"Yes\n";
        return;
    }
    cout<<"No\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    // pre();
    while (t--)
        solve();

    return 0;
}

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

int main(){
	long n, m, p, d[10000];
	long ans=15000000;
	
	scanf(" %ld %ld %ld", &n, &m, &p);
	for(long i=0; i<m; ++i){
		scanf(" %ld", &d[i]);
		d[i] = ( d[i]+n-p )%n;
		//printf(" %ld\n", d[i]);
	}
	p=0; //出発する駅を0に平行移動
	sort(d, d+m);
	
	long cost;
	//時計回り
	cost=d[m-1]*100;
	if(cost<ans) ans=cost;
	//反時計回り
	cost=(n-d[0])*100;
	if(cost<ans) ans=cost;
	//駅d[i]で折り返す
	for(long i=0; i<m-1; ++i){
		cost=0;	
		cost+=2*d[i]*100; //まず駅d[i]まで行って戻る
		cost+=(n-d[i+1])*100; //いってない駅まで反対周りで
		if(cost<ans) ans=cost;
		
		cost=0;
		cost+=2*(n-d[i+1])*100; //まず駅d[i+1]まで行って戻る
		cost+=d[i]*100; //いってない駅まで時計回り
		if(cost<ans) ans=cost;
	}
	
	printf("%ld\n", ans);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

void dfs(int n, string s, int prev) {
    if(n == 0) {
        cout << s << endl;
    }
    for(int i=min(n, prev); i>=1; --i) {
        string next = s;
        if(s.size() == 0) {
            next += to_string(i);
        } else {
            next += ' ';
            next += to_string(i);
        }
        dfs(n-i, next, i);
    }
}

int main() {
    int n;
    while(cin >> n, n) {
        dfs(n, "", 100);
    }
}


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

int is_prime(int n){
    
    int i;
    i = 2;
    
    if (n == 1){
        return 0;
        
    } else if (n == 2){
        return 1;
        
    } else {
        while(1){
            if (n % i == 0){
                return 0;
                
            } else if (n < i * i){
                return 1;
                
            } else {
                i++;
            }
        }
    }
    
    return 0;
}

int gcd(int m, int n){
    
    if (m % n == 0){
        return n;
    } else {
        return gcd(n, m % n);
    }
}

int is_set(int b[1000001], int n){
    
    int i;
    i = 2;
    
    if (n == 1) return 0;
    
    if (is_prime(n) == 1){
        if (b[n] == 1) {
            return 1;
        } else {
            b[n] = 1;
        }
        
    } else {
        while(n % i > 0){
            i++;
        }
        
        if (b[i] == 1) {
            return 1;
            
        } else {
            b[i] = 1;
            
            while (n % i == 0){
                n /= i;
            }
            
            return is_set(b, n);
        }
        
    }
    
    return 0;
}

int main(){
    
    int i, N, GCD, D, set;
    cin >> N;
    
    int a[N];
    int b[1000001];
    
    for (i = 0; i < N; i++){
        cin >> a[i];
    }
    
    for (i = 0; i < 1000001; i++){
        b[i] = 0;
    }
    
    for (i = 0; i < N; i++){
        if (i == 0){
            GCD = a[i];
            
        } else {
            D = gcd(GCD, a[i]);
            GCD = D;
        }
        
        if (GCD == 1) break;
    }
    
    if (GCD > 1){
        cout << "not coprime\n";
        return 0;
    }
    
    for (i = 0; i < N; i++){
        set = is_set(b, a[i]);
        if (set == 1){
            cout << "setwise coprime\n";
            return 0;
        }
    }
    
    cout << "pairwise coprime\n";
    
    return 0;
}



Measured memory_bytes: 11408
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
using namespace  std;

struct StCst
{
  int m_nNo;
  int m_nSeq;
  bool m_bDone;

  static bool AsdNo(const StCst &cnroLeft, const StCst &cnroRight) 
  { return cnroLeft.m_nNo < cnroRight.m_nNo; }
};

void fnInput(int &rnMaxSiz, vector<StCst> &rvoSort, int &rnMinNo)
{
  int nCnt = 0;
  cin >> rnMaxSiz;

  rvoSort.resize(rnMaxSiz);
  for (int i = 0; i < rnMaxSiz; i++)
  {
    cin >> rvoSort[i].m_nNo;
    rnMinNo = min(rnMinNo, rvoSort[i].m_nNo);
    rvoSort[i].m_nSeq = nCnt++;
  }
}

void fnMinCostSort(vector<StCst> &rvoSort, int nMinNo, int &rnSwpCnt)
{
  sort(begin(rvoSort), end(rvoSort), StCst::AsdNo);

  int nCost;
  for (int i = 0; i < rvoSort.size(); i++)
  {
    if (rvoSort[i].m_bDone)  continue;

    int nTotal = rvoSort[i].m_nNo;
    int nCurSize = 1;
    int nCurMin = rvoSort[i].m_nNo; 
    rvoSort[i].m_bDone = true;

    int j = rvoSort[i].m_nSeq;
    while  (rvoSort[j].m_nNo != rvoSort[i].m_nNo)
    {
      nTotal += rvoSort[j].m_nNo;
      nCurSize++;
      nCurMin = min(nCurMin, rvoSort[j].m_nNo);
      rvoSort[j].m_bDone = true;
      j = rvoSort[j].m_nSeq;
    }

    if (nCurSize == 1)
        nCost = 0;
    else
      if (nMinNo == nCurMin)
        nCost = nTotal + (nCurSize - 2) * nCurMin;
      else
        nCost = min(nTotal + (nCurSize - 2) * nCurMin, 
                    nTotal + nCurMin + (nCurSize + 1) * nMinNo);
    rnSwpCnt += nCost;
  }
}

void fnResult(int nSwpCnt)
{
  cout << nSwpCnt << endl;
}

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

  int nMaxSiz;
  vector<StCst> voSort;
  int nMinNo = INT_MAX;

  fnInput(nMaxSiz, voSort, nMinNo);

  int nSwpCnt = 0;
  fnMinCostSort(voSort, nMinNo, nSwpCnt);

  fnResult(nSwpCnt);
  return 0;
}

Measured memory_bytes: 1224
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string[] cin = Console.ReadLine().Split();
        int t = int.Parse(cin[0]);
        int a = int.Parse(cin[1]);
        int[] h = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();

        int id = 0;
        double ans = double.MaxValue;

        for (int i = 0; i < n; i++)
        {
            double tmp = t - h[i] * 0.006;
            if (Math.Abs(ans - a) > Math.Abs(tmp - a))
            {
                ans = tmp;
                id = i;
            }
        }

        Console.WriteLine(id + 1);
    }
}

Measured memory_bytes: 11292
#include <stdio.h>

int main(void)
{
        int n,x=0,max=0;
        char s[101];
        scanf("%d%s",&n,s);
        for(int i=0;i<n;i++){
                if(s[i]=='I')x++;
                else x--;
                if(max<x)max=x;
        }
        printf("%d\n",max);
        return 0;
}


Measured memory_bytes: 1712
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
//typedef pair<ll, ll> P;
//typedef pair<double, P> T;

const ll mod = 1000000007;
const ll INF = 100000010000;

ll N, C[200010];

ll ans;

ll pow_mod(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2 == 1)
	{
		return x * pow_mod(x, y - 1) % mod;
	}
	else
	{
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x)
{
	return pow_mod(x, mod - 2);
}

/*ll sum_bit(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add_bit(ll i, ll x)
{
	while (i <= 2 * N + 10)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

void init()
{
	ll K, X;
	cin >> K >> X;
	if (500 * K >= X)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

void output()
{
	//cout << ans << endl;
}



void solve()
{
	
}

int main()
{
	init();
	
	solve();

	

	output();
	ll N;
	cin >> N;
}

Measured memory_bytes: 256
import sys
cin = lambda: sys.stdin.readline().strip()
cout = sys.stdout.write

s = cin()

s = s.replace("eraser",'')
s = s.replace("erase",'')
s = s.replace("dreamer",'')
s = s.replace("dream",'')

if(s == ''):
	cout(f"YES"+'\n')
else:
	cout(f"NO"+'\n')

Measured memory_bytes: 9128
#include<bits/stdc++.h>
#define ll long long
#define testfor(T) ll T; cin>>T; while(T--)
using namespace std;
int main(){
	int x,y;
	cin>>x>>y;
	int rem=0;
	int found=0;
	for(int i=0;i<x+1;i++){
		rem = x-i;
		if(i*2+rem*4==y){
			cout<<"Yes"<<endl;
			found=1;
			break;
		}
	}
	if(!found){
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define lli long long int  
#define ll  long long 
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(),v.rend() //reverse
#define vl   vector<lli>
#define mii unordered_map<ll,ll>
#define pb push_back
double pi = 2*acos(0.0);
const int INF = 1e9 + 7;
//ull power(ull a,ull b){ ull res=1;while(b){if(b&1)res=res*a;b=b/2; a=(a*a); }return res;}
bool sortinrev(const pair<int,int> &a,   const pair<int,int> &b) {  if(a.second==b.second) return a.first>b.first;  return (a.second > b.second);} 

void WetPitch()
{
    
	lli n;
	cin>>n;
	vl a(n);
	for(int i=0;i<n;i++)
		cin>>a[i];
    lli ans=0;
	for(int i=0;i<n-2;i++)
	{
		for(int j=i+1;j<n-1;j++)
		{
			if(a[i]!=a[j])
			{
				for(int k=j+1;k<n;k++)
				{

					if(a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i]&&a[i]!=a[k]&&a[j]!=a[k])
						ans++;
				}
			}
		}
	}
	cout<<ans<<endl;
 

}     
signed main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	lli tst;
    tst=1; 
    //cin>>tst;
    while(tst--)
    WetPitch();
    return 0;
 } 

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif

signed main() {

    int a, b, k;
    cin >> a >> b >> k;
    
    set<int> s;
    for(int i=a; i<a+k && i<=b; i++) s.insert(i);
    for(int i=b; i>b-k && i>=a; i--) s.insert(i);
    
    for(int v:s) cout << v << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (){
 int A,B;
 cin>>A>>B;
 if(A>=13){
    cout<<B;
 } else if(A>=6 && A<=12){
    cout<<B/2;}
    else if (A<6){
        cout<<0;
    } return 0;
}

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

int n;
int a;


int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);

  cin >> n;
  cin >> a;

  while (n >= 500) n-= 500;

  if (n > a) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    cout<<n*n*n;
    return 0;
}

Measured memory_bytes: 256
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

K = int(input())

SUM = 0
for i in range(1,K+1):
    for j in range(i,K+1):
        tmp = math.gcd(i,j)
        for k in range(1,K+1):
            if not i == j:
                SUM += math.gcd(tmp,k) * 2
            else:
                SUM += math.gcd(tmp,k)


print(SUM)


Measured memory_bytes: 9564
// unihernandez22
// https://atcoder.jp/contests/abc150/tasks/abc150_b
// implementation

import std.stdio: readln, writeln;
import std.string: chomp;
import std.algorithm: count;

void main() {
	readln;
	string s = readln.chomp;
	s.count("ABC").writeln;
}


Measured memory_bytes: 3204
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const n = parseInt(args[0][0], 10)
	const a = args[1].map(arg => parseInt(arg, 10))
	const b = args[2].map(arg => parseInt(arg, 10))
	let sum = 0

	for (let i = 0; i < n; i++) {
		const current = Math.min(a[i], b[i])
		sum += current
		a[i] -= current
		b[i] -= current
		const next = Math.min(a[i + 1], b[i])
		sum += next 
		a[i + 1] -= next
		b[i] -= next
	}

	console.log(sum)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

using namespace std;

int main()
{
    char s[4];
    cin >> s;
    sort(s,s+4);
    if(s[0]==s[1] && s[1]!=s[2] && s[2]==s[3]) {
        cout << "Yes" << endl;
    }
    else { cout << "No" << endl;}
    return 0;
}

Measured memory_bytes: 256
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

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

    int n;cin>>n;
    string s; cin>>s;
    ll r=0,g=0,b=0;
    rep(i,n){
        if(s[i]=='R') r++;
        if(s[i]=='G') g++;
        if(s[i]=='B') b++;
    }

    ll ans=r*b*g;
    ll sub=0;
    rep(i,n)for(int j=i; j<n; j++){
        if(s[i]==s[j])continue;
        int k = j*2 - i;
        if(k>=n || s[j]==s[k] || s[k]==s[i])continue;
        sub++;
    }

    cout<<ans - sub<<endl;
    return 0;

}

Measured memory_bytes: 3596
#include <iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		int c = a%b;
		if (c == 0) {
			c = b;
		}
		cout << c << endl;
	}
	return 0;
}

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

int main(){
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  if(x<y) cout<<min({a*x+b*y,y*c*2,c*x*2+b*(y-x)})<<endl;
  else cout<<min({a*x+b*y,x*c*2,c*y*2+a*(x-y)})<<endl;
 
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static final long mod = 1000000007;

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			long n = sc.nextInt();
			long ans = modPow(10L, n) + modPow(8L, n) - 2 * modPow(9L, n);
			System.out.println((ans + mod * 2) % mod);
		}
	}

	static long modPow(long n, long r) {
		if (r == 1) {
			return n % mod;
		}
		long div = r / 2;
		long retVal = modPow(n, div);
		retVal = retVal * retVal % mod;
		if (r % 2 == 0) {
			return retVal;
		} else {
			return retVal * n % mod;
		}
	}
}

Measured memory_bytes: 35796
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

#define NMAX 500010

struct QUARR{
    int l;
    int r;
    int index;
    int type;
    int ans;
    bool operator<(QUARR q) const{
        if(type==1){
            if(q.r==r) return q.l>l;
            return q.r>r;
        }
        else{
            return q.index>index;
        }
    }
};

int ft_bit[NMAX];
void ft_add(int a,int w,int N){
    for(int x=a;x<=N;x+=x&-x){
        ft_bit[x]+=w;
    }
}

int ft_sum(int a){
    int ret=0;
    for(int x=a;x>0;x-=x&-x){
        ret+=ft_bit[x];
    }
    return ret;
}

signed main(){
    ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    QUARR qu[NMAX];
    int last[NMAX];
    int c[NMAX];
    int N,Q;

    cin>>N>>Q;
    for(int i=1;i<=N;i++){
        cin>>c[i];
        last[i]=-1;
    }

    for(int i=1;i<=Q;i++){
        int l,r;
        cin>>l>>r;
        qu[i].l=l;
        qu[i].r=r;
        qu[i].index=i;
        qu[i].type=1;
        qu[i].ans=0;
    }

    sort(qu+1,qu+Q+1);

    for(int i=1;i<=qu[1].r;i++){
        if(last[c[i]]==-1){
            ft_add(i,1,N);
            last[c[i]]=i;
        }
        else{
            ft_add(last[c[i]],-1,N);
            ft_add(i,1,N);
            last[c[i]]=i;
        }
    }

    qu[1].ans=ft_sum(qu[1].r)-ft_sum(qu[1].l-1);
    qu[1].type=2;
    for(int i=2;i<=Q;i++){
        for(int j=qu[i-1].r+1;j<=qu[i].r;j++){
            if(last[c[j]]==-1){
                ft_add(j,1,N);
                last[c[j]]=j;
            }
            else{
                ft_add(last[c[j]],-1,N);
                ft_add(j,1,N);
                last[c[j]]=j;
            }
        }
        qu[i].ans=ft_sum(qu[i].r)-ft_sum(qu[i].l-1);
        qu[i].type=2;
    }

    sort(qu+1,qu+Q+1);

    for(int i=1;i<=Q;i++){
        cout<<qu[i].ans<<"\n";
    }
}


Measured memory_bytes: 35000
from collections import deque
 
 
def main():
    N, M, *AB = map(int, open(0).read().split())
 
    graph = [[] for _ in range(N + 1)]
    for a, b in zip(*[iter(AB)] * 2):
        graph[a].append(b)
        graph[b].append(a)
 
    # bfs
    queue = deque([1])
    sign = [0] * (N + 1)
    sign[1] = 1
    while queue:
        u = queue.popleft()
        for v in graph[u]:
            if not sign[v]:
                sign[v] = u
                queue.append(v)
 
    if all(sign[2:]):
        print("Yes")
        print("\n".join(map(str, sign[2:])))
    else:
        print("No")
 
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 56696
n = gets.to_i
hmin = Hash.new(50)
n.times do |i|
    hash = Hash.new(0)
    gets.chomp.split('').each do |c|
        hash[c] += 1
    end
    ('a'..'z').each do |c|
        hmin[c] = [hmin[c], hash[c]].min
    end
end

('a'..'z').each do |c|
    print c*hmin[c]
end

print "\n"

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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}
ll n,a,b;
ll now,ne;
ll sum = 0;
int main(){
  cin >> n>>a>>b>>now;
  REP(i,n-1){
    cin >> ne;
    sum += min(b,(ne-now)*a);
    //printf("%d,%d\n",b,(ne-now)*a);
    now = ne;
  }
  cout << sum<<endl;
}


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

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> p(n);
    for(int i = 0; i < n; i++)
    {
        cin >> p[i];
    }

    sort(p.begin(), p.end());

    ll sum = 0;
    for(int i = 0; i < k; i++)
    {
        sum += p[i];
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3636