akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pair<int,int>> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

#define ri(a) scanf("%d", &a)
#define rii(a,b) scanf("%d %d", &a, &b)
#define riii(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define rl(a) scanf("%lld", &a)
#define rll(a,b) scanf("%lld %lld", &a, &b)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define ROF(i,n,m) for(int i=n; i>m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second

const int INF = 0x3f3f3f3f;
const ll LLINF = 1e18;
const int maxN = 2e5 + 10; // CAMBIAR ESTE

// GJNM
int n, cycle_size;
ll k;
ll A[maxN];
bool vis[maxN], cyc[maxN];
vi cycle, ord;

void dfs(int x){
	if ( cyc[x] )
		return;

	if ( vis[x] == false ){
		vis[x] = true;
		ord.pb(x);
	}
	else{
		cyc[x] = true;
		cycle.pb(x);
	}

	dfs(A[x]);
}

int main(){
	ri(n);
	rl(k);
	FOR(i,0,n){
		rl(A[i]);
		A[i]--;
	}
	dfs(0);
	int O = ord.size()-1;
	int C = cycle.size();
	//for(int x : ord)
	//	printf("%d ",x+1 );
	//printf("\n");
	//for(int x : cycle)
	//	printf("%d ",x+1 );
	//printf("\n");
	if ( k <= O ){
		printf("%d\n", ord[k]+1);
	}
	else{
		if ( O == C-1 ){
			printf("%d\n", cycle[k%C]+1);
		}
		else{
			k -= (O-C);
			k--;
			//printf("%lld %d %d\n",k,O,C );
			printf("%d\n",cycle[k%C]+1 );
		}
	}
	return 0;
}

Measured memory_bytes: 18092
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
#include <cctype>

using namespace std;

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

int partition(vector<int> &A, vector<int> &I, vector<string> &S, int p, int r)
{
	int x = A[r];
	int i = p - 1;
	for(int j = p; j < r; ++j) {
		if(A[j] <= x) {
			++i;
			swap(A[i], A[j]);
			swap(S[i], S[j]);
			swap(I[i], I[j]);
		}
	}
	swap(A[i + 1], A[r]);
	swap(S[i + 1], S[r]);
	swap(I[i + 1], I[r]);
	return i + 1;
}

void QuickSort(vector<int> &A, vector<int> &I, vector<string> &S, int p, int r)
{
	if(p < r) {
		int q = partition(A, I, S, p, r);
			QuickSort(A, I, S, p, q - 1);
			QuickSort(A, I, S, q + 1, r);
	}
}

bool isStable(vector<int> &A, vector<int> &I, int n)
{
	REP(i, n - 1) {
		if(A[i] == A[i + 1] && I[i] > I[i + 1])
			return false;
	}

	return true;
}

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

	vector<int> A(n);
	vector<string> S(n);
	vector<int> I(n);
	REP(i, n) {
		cin >> S[i] >> A[i];
		I[i] = i;
	}
	QuickSort(A, I, S, 0, n - 1);

	(isStable(A, I, n))? cout << "Stable" : cout << "Not stable";
	cout << endl;

	REP(i, n) {
		cout << S[i]  << ' ' << A[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 7340
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	vector<ll> A(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> A[i];
	}

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

	auto func = [&](bool flag)
	{
		deque<ll> q;
		auto left = 0;
		auto right = (int)A.size() - 1;
		if (flag)
		{
			q.push_back(A[left]);
			++left;
		}
		else
		{
			q.push_back(A[right]);
			--right;
		}

		flag = !flag;
		while (left <= right)
		{
			if (flag)
			{
				q.push_back(A[left]);
				++left;
				if (left <= right)
				{
					q.push_front(A[left]);
					++left;
				}
			}
			else
			{
				q.push_back(A[right]);
				--right;
				if (left <= right)
				{
					q.push_front(A[right]);
					--right;
				}
			}
			flag = !flag;
		}

		auto prev = q.front();
		q.pop_front();
		auto result = 0ll;
		while (!q.empty())
		{
			auto next = q.front();
			q.pop_front();
			result += abs(next - prev);
			prev = next;
		}

		return result;
	};

	auto res = func(true);
	res = max(res, func(false));

	cout << res << endl;

	return 0;
}

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

int main() {

  int n;
  std::cin >> n;

  if (n & 1)
    return puts("No"), 0;

  std::string str;
  std::cin >> str;

  puts(str.substr(0, n/2) == str.substr(n/2, n/2) ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 3010;
#define qmax(a,b) ((a)>(b)?(a):(b))
#define qmin(a,b) ((a)<(b)?(a):(b))

int a[N], n;
long long dp[N][N];
long long sum;

long long dfs(int l, int r) {
    if (l > r) return 0;
    if (dp[l][r] != -1) return 1LL * dp[l][r];
    if (l == r) return 1LL * a[l];
    return dp[l][r] = 1LL * qmax(a[r] + 1LL * qmin(dfs(l, r-2), dfs(l+1, r-1)), a[l] + 1LL * qmin(dfs(l+2, r), dfs(l+1, r-1)));
}

int main() {
    scanf("%d", &n);
    sum = 0;
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]), sum = sum + 1LL * a[i];
    memset(dp, 0, sizeof dp);
    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j++) {
            if (i == j) dp[i][j] = a[i];
            else dp[i][j] = -1;
        }
    }
    dp[1][n] = dfs(1, n);
   // cout << dp[1][n] << " " << sum - dp[1][n] << endl;
    printf("%lld\n", 1LL * 2 * dp[1][n] - 1LL * sum);
    return 0;
}

Measured memory_bytes: 71168
#include <iostream>
#include <string>
#include <map>
#include <utility>
#include <vector>

using namespace std;
typedef pair<int, int> facePair;

class Dice{
public:
    Dice(int labels[]);
    void rotate(char);
    void rotate(string);
    void spinClockwise();
    int getTop(){return t;};
    int getFront(){return s;};
    int getRight(){return e;};
    friend bool operator==(Dice &lhs, const Dice &rhs);

private:
    int t, s, e, w, n, b;
    void rotate(int &direction, int &opposite);
};

Dice::Dice(int labels[]){
    t = labels[0];
    s = labels[1];
    e = labels[2];
    w = labels[3];
    n = labels[4];
    b = labels[5];
}

void Dice::rotate(char direction){
    if(direction == 'N') rotate(n, s);
    if(direction == 'E') rotate(e, w);
    if(direction == 'S') rotate(s, n);
    if(direction == 'W') rotate(w, e);
}

void Dice::rotate(int &direction, int &opposite){
    int old = direction;
    direction = t;
    t = opposite;
    opposite = b;
    b = old;
}

void Dice::rotate(string directions){
    for(auto ch : directions) rotate(ch);
}

void Dice::spinClockwise(){
    int old = n;
    n = w;
    w = s;
    s = e;
    e = old;
}

bool operator==(Dice &lhs, const Dice &rhs){
    string directions("EEESEE");
    int t = rhs.t;
    int b = rhs.b;
    int n = rhs.n;
    int e = rhs.e;
    int s = rhs.s;
    int w = rhs.w;
    for(auto dir : directions){
        lhs.rotate(dir);
        if(lhs.t != t || lhs.b != b) continue;
        for(int i = 0; i < 4; ++i){
            lhs.spinClockwise();
            if(lhs.n == n && lhs.e == e && lhs.s == s && lhs.w == w){
                return true;
            }
        }
    }
    return false;
}

class DiceFaceFinder{
public:
    DiceFaceFinder(Dice &diceref);
    int queryTopFrontToRight(int top, int south);
private:
    map<facePair, int> map_topfront2right;
    Dice &dice;
    void initMap();
};

DiceFaceFinder::DiceFaceFinder(Dice &diceref):dice(diceref){
    initMap();
}

void DiceFaceFinder::initMap(){
    string directions("EEESEE");
    for(auto dir : directions){
        dice.rotate(dir);
        for(int i = 0; i < 4; ++i){
            dice.spinClockwise();
            facePair key (dice.getTop(), dice.getFront());
            map_topfront2right[key] = dice.getRight();
        }
    }
}

int DiceFaceFinder::queryTopFrontToRight(int top, int south){
    facePair key (top, south);
    return map_topfront2right[key];
}

bool allUnique(vector<Dice>& dice){
    size_t n = dice.size();
    for(size_t i = 0; i < n - 1; ++i){
        for(size_t j = i + 1; j < n; ++j){
            if(dice[i] == dice[j]){
                return false;
            }
        }
    }
    return true;
}

int main(){
    int n;
    cin >> n;
    vector<Dice> dice;
    for(int i = 0; i < n; ++i){
        int labels[6] = {};
        for(auto &face : labels) cin >> face;
        dice.emplace_back(labels);
    }

    if(allUnique(dice)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 1212
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 __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n,m=map(int,input().split())
t=n*(n-1)//2
x=[t]
gr=[]
for i in range(m):
  a,b=map(int,input().split())
  gr.append((a-1,b-1))
gr=gr[::-1]
uf=UnionFind(n)
for a,b in gr:
  if uf.same(a,b)==False:
    t-=(uf.size(a)*uf.size(b))
  x.append(t)
  uf.union(a,b)
x=x[:m]
print(*x[::-1])

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

using namespace std;

struct edge{
	int to;
	int id;
};

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<vector<edge>> g(N);
	rep(i,N-1){
		int a,b;
		cin >> a >> b;
		a--;b--;
		edge x,y;
		x.to = a;
		x.id = i;
		y.to = b;
		y.id = i;
		g[a].push_back(y);
		g[b].push_back(x);
	}
	queue<int> q;
	vector<bool> used(N);//訪れた点は1にする
	used[0] = 1;//点0は訪れた
	vector<int> ans(N-1);//最後に出力する 辺の色を保存しておく
	q.push(0);
	while(!q.empty()){
		int v = q.front();q.pop();
		//vは現在見ている点
		int color = 1;
		//次に塗る色
		int prev = -1;
		//最後に塗った色
		for(int i=0;i<g[v].size();i++){
			edge e = g[v][i];
			if(ans[e.id]){
				prev = ans[e.id];
				break;
			}
		}
		//現在の点から各辺について
		//その辺が塗られていた場合はprev = ans[e.id];
		
		//現在の点からすべての辺に対して
		//if(used[e.to])continue;これはすでにぬった辺を表す
		//今回は木なので2辺以上塗られている場合はありえないのでこれでよい
		
		for(int i=0;i<g[v].size();i++){
			edge e = g[v][i];
			if(used[e.to])continue;
			if(color == prev)color++;
			ans[e.id] = color;
			color++;
			q.push(e.to);
			used[e.to] = 1;
		}
		//edge e は次に行く辺
		//もしもその辺がすでに使われていた場合はcontinue;
		//
	}
	int mx=0;
	rep(i,N-1) mx = max(mx,ans[i]);
	cout << mx << endl;
	rep(i,N-1)cout << ans[i] << endl;
}


Measured memory_bytes: 7040
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define MAX_N 100000
typedef long long ll;
ll A[MAX_N],B[MAX_N];
int main(){
    int N;
    ll ans = 0;
    cin >> N;
    REP(i,N) cin >> A[i] >> B[i];
    REPm(i,N){
        if((A[i]+ans)%B[i] != 0) ans += B[i]-(A[i]+ans)%B[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
//vvi(n, vector<int>(m, -1))
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(a) (a).begin(), (a).end()
#define out(x) cout << (x) << endl;

int gcd(int x, int y) {
	if(y == 0) return x;
	return gcd(y, x % y);
}

int main(){
	int i,j,k,n,m,f,x,y,z; string s;
	cin >> n;
	int a[100005];

	rep(i, n) cin >> a[i];

	int l[100005], r[100005];
	l[0] = 0;
	r[n] = 0;

	rep(i, n){
		l[i+1] = gcd(a[i], l[i]);
		
	}
	for(i=n-1;i>=0;i--){
		r[i] = gcd(a[i], r[i+1]);
	}

	int ans = 0;
	rep(i, n){
		ans = max(ans, gcd(l[i], r[i+1]));
	}
	cout << ans << endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
//#define TEST


int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\stdout", "w", stdout);
    }

    ll r, D, x;
    cin >> r >> D >> x;
    for(int i=2001; i<=2010; i++){
        x = r*x - D;
        cout << x << '\n';
    }

    if (argc == 2 && atoi(argv[1]) == 123456789)
        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define ldouble long double
#define vin vector<int>
#define rep(a,n) for(int i=(a);i<(n);i++)
#define INF (int)1000000007

//setprecision()<<

using namespace std;

void fin(int n,vin &a){
    rep(0,n){
        cin>>a.at(i);
    }
}

signed main(){
    char c;
    cin>>c;
    cout<<(char)(c+1)<<endl;

    return 0;
}

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

using namespace std;

int main()
{int N; cin >> N;
 vector<int> D(N); for(int i = 0; i < N; i++){cin >> D[i];}
 
 sort(D.begin(),D.end());
 
 int k = 0; int cnt = 0;
 
 while( k < N - 1){
   if( k < N - 1 && D[k] != D[k+1]){ cnt++;}
   k++;
   
 }
 
 cout << cnt + 1 << endl;
 
 return 0;
}


Measured memory_bytes: 256
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():

    A = []
    for i in range(3):
        A += list(map(int, input().split()))

    N = int(input())
    s = [False for _ in range(9)]
    for i in range(N):
        b = int(input())
        if b in A:
            s[A.index(b)] = True

    bingo = \
        (s[0] and s[1] and s[2]) or \
        (s[3] and s[4] and s[5]) or \
        (s[6] and s[7] and s[8]) or \
        (s[0] and s[3] and s[6]) or \
        (s[1] and s[4] and s[7]) or \
        (s[2] and s[5] and s[8]) or \
        (s[0] and s[4] and s[8]) or \
        (s[2] and s[4] and s[6])

    if bingo:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    solve()


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

using namespace std;

int dp[1005][1005];
char s[1005][1005];
int main()
{
    //freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);

    int n,m;
    cin >> n >> m;

    for (int i=0;i<n;i++)
        for (int j=0;j<m;j++)
        cin >> s[i][j];

    for (int i=0;i<n;i++)
        if (s[i][0]=='#')
        break;
    else
        dp[i][0]=1;

    for (int i=0;i<m;i++)
        if (s[0][i]=='#')
        break;
    else
        dp[0][i]=1;

    for (int i=1;i<n;i++)
        for (int j=1;j<m;j++)
    {
        if (s[i][j]=='#') continue;
        dp[i][j]=(0LL+dp[i-1][j]+dp[i][j-1])%((int)(1e9+7));
    }

    cout << dp[n-1][m-1];


}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k&1)cout<<(b-a)<<"\n";
    else cout<<(a-b)<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=20,K=N*N,M=1e5,mo=1e9+7;

int d[N],g[N],bit[M];
int r[N];
int n,m,j,k,l,i;
ll f[M],way[K];

inline int read()
{
	int o=0; char ch=' ';
	for(;ch<'0'||ch>'9';ch=getchar());
	for(;ch>='0'&&ch<='9';ch=getchar())o=o*10+ch-48;
	return o;
}

int main()
{
	cin>>n>>m;
	d[1]=1;	fo(i,2,n+1)d[i]=d[i-1]<<1;
	way[0]=1;
	fo(i,1,m+10)way[i]=(way[i-1]<<1)%mo;
	int T=d[n+1]-1;
	fo(i,1,T)bit[i]=bit[i>>1]+(i&1);
	fo(i,1,m){
		int x=read(),y=read();
		g[x]|=d[y];
	}
	f[0]=1;
	fo(i,3,T)if((i&1)==((i&2)>>1)){
		int u=0;
		fo(l,1,n)if(i&d[l])r[++u]=l;
		fo(l,0,d[u+1]-2){
			int o=0;
			fo(j,1,u)(l&d[j])?o|=d[r[j]]:0;
			if((o&1)!=((o&2)>>1))continue;
			int p=i^o,ok=0;
			ll choose=1;
			fo(j,1,n)if((o&d[j])>0&&(g[j]&p)==0){
				ok=1; break;
			}else (o&d[j])?choose=choose*(way[bit[g[j]&p]]-1)%mo:0;
			if(ok)continue;
			fo(j,1,n)(p&d[j])?choose=choose*way[bit[g[j]&o]]%mo:0;
			f[i]=(f[i]+choose*f[o])%mo;
		}
	}
	ll ans=(way[m]-f[T]+mo)%mo;
	cout<<ans;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int get(LL x,int v){
    return (x>>v)&1;
}
void solve(LL x,LL y,int it){
    LL yy=y|(1LL<<it);
    int it2=it-1;
    while(it2>=0&&!get(x,it2))it2--;
    for(;it2>=0;it2--)x|=1LL<<it2;
    if(yy<=x){
        cout<<(x|((1LL<<it)-1))-y+1;
    }
    else{
        cout<<(x|((1LL<<it)-1))-yy+1+(x-y+1);
    }
}
int main(){
    LL x,y;
    cin>>y>>x;
    if(x==y){
        cout<<1;
        return 0;
    }
    for(int i=59;i>=0;i--)
        if(get(x,i)!=get(y,i)){
            solve(x,y,i);
            return 0;
        }
    return 0;
}

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

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

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

    vector<int> num(N + 1, 0);
    for (int i = 0; i < N; i++) {
        num.at(A.at(i))++;
    }

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

    int res = 0;
    for (int i = K; i < N; i++) {
        res += num.at(i);
    }

    cout << res << endl;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)

using namespace std;


int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<char>> a(h+1, vector<char>(w+1, '.'));
    rep(hx, h){
        rep(wx, w)  cin >> a[hx][wx];
    }

    set<pair<int, int>> closed;
    queue<pair<int, int>> que;
    que.push({0, 0});

    bool flag = false;

    vector<vector<char>> b(h+1, vector<char>(w+1, '.'));

    while(!que.empty()){
        pair<int, int> p = que.front();   que.pop();
        if(0 == closed.count(p)){
            int hx = p.first;
            int wx = p.second;
            b[hx][wx] = '#';
            if(hx == h-1 && wx == w-1){
                flag = true;
                break;
            }
            if(a[hx+1][wx] == '#' && a[hx][wx+1] == '#'){
                break;
            }
            if(a[hx+1][wx] == '#')  que.push({hx+1, wx});
            if(a[hx][wx+1] == '#')  que.push({hx, wx+1});
        }
        closed.insert(p);
    }

    [&]{
        rep(hx, h){
            rep(wx, w){
                if(a[hx][wx] != b[hx][wx]){
                    flag = false;
                    return;
                }
            }
        }
    }();

    if(flag)    cout << "Possible" << endl;
    else        cout << "Impossible" << endl;
    

    return 0;
}



Measured memory_bytes: 256
n = int(input())
buf = ["AC","WA","TLE","RE"]
num = [0 for i in range(4)]

for i in range(n):
    s = input()

    for j in range(4):
        if s == buf[j]:
            num[j] += 1

for i in range(4):
    print(buf[i]+" x "+str(num[i]))

Measured memory_bytes: 69680
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<62;

int main(){
    string str;
    cin>>str;
    if(str == "Sunny")cout << "Cloudy" << endl;
    else if(str == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
    return 0;
}



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

int main() {
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= 3; i++) {
        if (i != a && i != b) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

template<typename T>
struct BIT{
  int n;
  vector<T> bit[2];
  BIT(int n_=0):n(n_){
    bit[0].resize(n+1,0);
    bit[1].resize(n+1,0);
  }
  void add_sub(int p,int i,T x){
    for(i++;i<=n;i+=i&-i){
      bit[p][i]+=x;
    }
  }
  void add(int l,int r,T x){
    add_sub(0,l,-x*(l-1));
    add_sub(0,r,x*(r-1));
    add_sub(1,l,x);
    add_sub(1,r,-x);
  }
  T sum_sub(int p,int i){
    T s=0;
    for(i++;i;i-=i&-i){
      s+=bit[p][i];
    }
    return s;
  }
  T sum(int i){
    return sum_sub(0,i)+sum_sub(1,i)*i;
  }
  T sum(int l, int r){
    return sum(r-1) - sum(l-1);
  }
};

int main(){
  int N,Q;cin>>N>>Q;
  BIT<int> b(N);
  rep(q,Q){
    int c; cin >> c;
    if(c==0){
      int s,t,x; cin>>s>>t>>x; s--;
      b.add(s,t,x);
    }
    else{
      int i;cin>>i; i--;
      cout << b.sum(i)-b.sum(i-1) << '\n';
    }
  }
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    string s;
    cin >> s;
    ll n = s.length();

    map<char, ll> mp;
    rep(i, n) {
        mp[s[i]]++;
    }

    ll ans = n * (n-1) / 2 + 1;
    for (auto x : mp) {
        ans -= x.se * (x.se-1) / 2;
    }

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

Measured memory_bytes: 640
#include<vector>
#include<cstdio>
#include<cstring> 
#include<algorithm>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int maxn=3e5+5;
int n,x,y,da,db,dc;
//vector<int> e[maxn];
pair<int,int> a[maxn];
ll ans;
int main(){
	scanf("%d %d %d %d %d",&x,&y,&da,&db,&dc);
	for(int i=1;i<=da+db+dc;i++){
		scanf("%d",&a[i].first);
		if(i<=da){
			a[i].second=1;
		}else if(i<=da+db){
			a[i].second=2;
		}else if(i<=da+db+dc){
			a[i].second=3;
		}
	}
	int n=da+db+dc,cnt[4]={0,0,0,0};
	sort(a+1,a+1+n);
	for(int i=n;i>=1;i--){
		if(cnt[1]==x&&a[i].second==1){
			continue;
		}else if(cnt[2]==y&&a[i].second==2){
			continue;
		}
		ans=ans+a[i].first;
		cnt[a[i].second]++;
		if(cnt[1]+cnt[2]+cnt[3]==x+y){
			break;
		}
	} 
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 2560
package main

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

var sc = bufio.NewScanner(os.Stdin)

type kakko struct {
	str string
	min int
	max int
}

func main() {
	N := getStdinInt()
	F := make([]kakko, 0, N)
	L := make([]kakko, 0, N)
	for i := 0; i < N; i++ {
		s := getStdin()
		min, max := minmaxKakko(s)
		if min >= 0 {
			F = append(F, kakko{s, min, max})
		} else {
			L = append(L, kakko{s, min, max})
		}
	}
	sort.Slice(F, func(i, j int) bool { return F[i].max-F[i].min < F[j].max-F[j].min })
	sort.Slice(L, func(i, j int) bool { return L[i].max > L[j].max })

	K := make([]kakko, N)
	for i := 0; i < len(F); i++ {
		K[i] = F[i]
	}
	for i := 0; i < len(L); i++ {
		K[i+len(F)] = L[i]
	}

	first := -1
	last := -1
	for i := 0; i < len(K); i++ {
		if K[i].str[0] == '(' {
			first = i
			break
		}
	}
	for i := len(K) - 1; i >= 0; i-- {
		if first != i && K[i].str[len(K[i].str)-1] == ')' {
			last = i
			break
		}
	}

	if first == -1 || last == -1 {
		fmt.Printf("No\n")
		return
	}

	stack := 0
	stack = okKakko(K[first].str, stack)
	if stack < 0 {
		fmt.Printf("No\n")
		return
	}
	for i := 0; i < len(K); i++ {
		if first == i || last == i {
			continue
		}
		stack = okKakko(K[i].str, stack)
		if stack < 0 {
			fmt.Printf("No\n")
			return
		}
	}
	stack = okKakko(K[last].str, stack)
	if stack < 0 {
		fmt.Printf("No\n")
		return
	}

	if stack == 0 {
		fmt.Printf("Yes\n")
	} else {
		fmt.Printf("No\n")
	}
}

func minmaxKakko(s string) (int, int) {
	stack := 0
	max := math.MinInt32
	min := math.MaxInt32
	for i := 0; i < len(s); i++ {
		if s[i] == '(' {
			stack++
			if stack > max {
				max = stack
			}
		}
		if s[i] == ')' {
			stack--
			if stack < min {
				min = stack
			}
		}
	}
	return min, max
}

func okKakko(s string, stack int) int {
	for i := 0; i < len(s); i++ {
		if s[i] == '(' {
			stack++
		}
		if s[i] == ')' {
			stack--
		}
		if stack < 0 {
			return -1
		}
	}
	return stack
}

func getStdin() string {
	sc.Scan()
	return sc.Text()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}


Measured memory_bytes: 67376
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>> 
#define vi vector<int>
#define vpii vector<pair<int,int>> 
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>> 
#define pii pair<int,int> 
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>

ld pie=3.141592653589793238462643383279;
int mod=1e9+7;

struct point{
  ld x,y;
};

vvi mat_mul(vvi mat1,vvi mat2){
  vvi ret;
  f(i,0,2){
    vi xx;
    f(j,0,2){
      int r=0;
      f(k,0,2) r=(r+(mat1[i][k]*mat2[k][j])%mod)%mod;
      xx.pb(r%mod);
    }
    ret.pb(xx);
  }
  return ret;
}

vvi mat_exp(vvi mat,int p){
  vvi iden={{1,0},{0,1}};
  while(p!=0){
    if(p&1) iden=mat_mul(iden,mat);
    p/=2; 
    mat=mat_mul(mat,mat);
  }
  return iden;
}


int myexp(int p){
  p++;
  int r=1;
  int val=2;
  while(p!=0){
    if(p&1){
      r*=val;
    }
    val*=val;
    p/=2;
  }
  r-=2;
  return r;
}


int fact[2000005];
int infact[2000005];
 
int inv(int a){
  int y=mod-2;
  int r=1;
  while(y!=0){
    if(y&1){
      r*=a; r%=mod;
    }
    y/=2; a*=a; a%=mod;
  }
  return r;
}
 
int po(int a,int y){
  int r=1;
  while(y!=0){
    if(y&1){
      r*=a; r%=mod;
    }
    y/=2; a*=a; a%=mod;
  }
  return r; 
}
 
void facto(){
  fact[0]=1;
  f(i,1,2000005) {fact[i]=i*fact[i-1]; fact[i]%=mod;}
  f(i,0,2000005) infact[i]=inv(fact[i]); 
}
 
int nck (int n,int k){
  if(k<0 || k>n) return 0;
  int ret=fact[n]; ret*=infact[k]; ret%=mod;
  ret*=infact[n-k]; ret%=mod;
  return ret;
}
  
void mymul(int arr[],int num){
  int carry=0;
  f(i,0,100){
    arr[i]=arr[i]*num+carry;
    carry=arr[i]/10;
    arr[i]%=10;
  }
}

map<int,int> mp;

int myfun(int val){
  auto it = mp.lower_bound(val);
  if(it==mp.begin()) return 0;
  --it; 
  return it->second;
}

void myerase(int val,int key){
 
}

  
int32_t main(){ 
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  int n; cin>>n;
  map<int,int> mp;
  f(i,0,n){
    int x; cin>>x;
    ++mp[x]; ++mp[x-1]; ++mp[x+1];
  } 
  int mx=0;
  for(auto it : mp) mx=max(mx,it.ss);
  cout<<mx;
  return 0; 
}
// check for overflows dummy !!!

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

using namespace std;

using ll = long long;

#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rep(i, a) for (int i = 0; i < (int) (a); i++)

int n, k;
vector<vector<int>> g;

const ll mod = 1000000007;

ll dfs(int n, int p = -1, int s = 0, int t = 0) {
	ll res = k - s - t;
	res %= mod;
	for (auto x: g[n]) {
		if (x == p) continue;
		res *= dfs(x, n, 1, s++);
		res %= mod;
	}
	return res;
}

int main() {
	cin >> n >> k;
	g.resize(n);
	rep(i, n-1) {
		int a, b;
		cin >> a >> b;
		a--;b--;
		g[b].push_back(a);
		g[a].push_back(b);
	}
	cout << dfs(0) << endl;
}

Measured memory_bytes: 11520
#include<stdio.h>
#define N 100005
int maxn(int x, int y)
{
	return (x > y) ? x : y;
}
int main()
{
	int dp[N][3];
	int a[N], b[N], c[N];
	int n;
	int ans;
	while (scanf("%d", &n) != EOF)
	{
		for (int i = 1; i <= n; i++)
			scanf("%d %d %d", &a[i], &b[i], &c[i]);
		dp[1][1] = a[1], dp[1][2] = b[1], dp[1][3] = c[1];
		for (int i = 2; i <= n; i++)
		{
			dp[i][1] = maxn(dp[i - 1][2], dp[i - 1][3]) + a[i];
			dp[i][2] = maxn(dp[i - 1][1], dp[i - 1][3]) + b[i];
			dp[i][3] = maxn(dp[i - 1][1], dp[i - 1][2]) + c[i];
		}
		ans = maxn(dp[n][1], maxn(dp[n][2], dp[n][3]));
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2560
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//

struct Edge {
	int u, v;
	lint Y;
	bool operator < (const Edge& obj) const { return Y < obj.Y; }
};

int N, M;
lint X[100005];
vector< Edge > edge;
vector< vector< pii > > adj;
bool use[100005];



void dfs(int v, lint maxY) {
	for (pii p : adj[v]) {
		int u = p.first;
		int i = p.second;
		if (use[i]) continue;
		if (edge[i].Y > maxY) continue;
		use[i] = true;
		dfs(u, maxY);
	}
}

void detect(vector< int > base) {
	for (int i : base) {
		if (use[i]) continue;
		dfs(edge[i].u, edge[i].Y);
	}
}

vector< int > findBase() {
	vector< int > par(N, -1);
	vector< lint > w(N, -1), ew(N, -1);
	vector< vector< int > > group(N, vector< int >());
	
	//
	for (int v=0; v<N; ++v) {
		par[v] = v;
		w[v] = X[v];
		group[v] = {v};
	}
	
	vector< int > ret;
	for (int i=0; i<M; ++i) {
		Edge e = edge[i];
		
		int pu = par[e.u];
		int pv = par[e.v];
		
		if (pu != pv) {
			if (group[pu].size() > group[pv].size()) swap(pu, pv);
			w[pv] += w[pu];
			for (int v : group[pu]) {
				par[v] = pv;
				group[pv].push_back(v);
			}
		}
		
		if (w[pv] >= e.Y) ret.push_back(i);
	}
	reverse(allof(ret));
	return ret;
}

void solve() {
	sort(allof(edge));
	memset(use, 0, sizeof(use));
	
	adj.assign(N, vector< pii >());
	for (int i=0; i<M; ++i) {
		Edge e = edge[i];
		adj[e.u].push_back(pii(e.v, i));
		adj[e.v].push_back(pii(e.u, i));
	}
	
	vector< int > base = findBase();
	detect(base);
	
	int ans = 0;
	for (int i=0; i<M; ++i) if (!use[i]) ++ans;
	cout << ans << endl;
}



int main() {
	cin >> N >> M;
	for (int i=0; i<N; ++i) cin >> X[i];
	for (int i=0; i<M; ++i) {
		int a, b;
		lint y;
		cin >> a >> b >> y;
		--a; --b;
		edge.push_back(Edge{a,b,y});
	}
	solve();
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 19312
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll m = sz(s);
  ll ans = 0;
  for (ll i = 1; i < m; i++){
    ll count = 0;
    string x = s;
    string y = s;
    string a = x.erase(i);
    string b = y.substr(i);
    for (char t = 'a'; t <= 'z'; t++)
    {
      bool judge_a = false;
      bool judge_b = false;
      for (ll j = 0; j < sz(a); j++){
        if(a[j]==t){
          judge_a = true;
        }
      }
      if(judge_a){
        for (ll j = 0; j < sz(b);j++){
          if(b[j]==t){
            judge_b = true;
          }
        }
      }
      if(judge_a&&judge_b){
        count++;
      }
    }
    chmax(ans, count);
  }
  print(ans);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
#include <queue>
using namespace std;
#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--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
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;}
// head

const int N=101000;
int n,q;
ll w[N],ret[N];
map<ll,ll> cnt;
int main() {
	scanf("%d%d",&n,&q);
	rep(i,1,q+1) scanf("%lld",w+i);
	w[0]=n;
	ll W=w[q];
	cnt[W]++;
	per(i,0,q) {
		if (w[i]>=W) continue;
		W=w[i];
		while (1) {
			auto it=cnt.upper_bound(W);
			if (it==cnt.end()) break;
			cnt[W]+=it->se*(it->fi/W);
			if (it->fi%W!=0) cnt[it->fi%W]+=it->se;
			cnt.erase(it);
		}
	}
	per(i,1,n+1) ret[i]=ret[i+1]+cnt[i];
	rep(i,1,n+1) printf("%lld\n",ret[i]);
}

Measured memory_bytes: 9472
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

fn main() {
    input! {
        n: usize,
        mut l: [i64; n]
    }
    assert!(n <= 100);
    l.sort();l.reverse();
    
    let mut ans = 0i64;

    for i in 0..n {
        for j in i+1..n {
            for k in j+1..n {
                if l[i] >= l[j] + l[k] {
                    break;
                }
                if l[i] != l[j] && l[j] != l[k] {
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2168
#include <stdio.h>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, a, b, m, ans, now = 1e8, x, y, z;
  scanf("%lld%lld%lld", &a, &b, &m);
  ll c[a], d[b];
  for(i = 0; i < a; ++i) {
    scanf("%lld", &c[i]);
    if(now > c[i]) now = c[i];
  }
  ans = now;
  for(i = 0; i < b; ++i) {
    scanf("%lld", &d[i]);
    if(now > d[i]) now = d[i];
  }
  ans += now;
  for(i = 0; i < m; ++i) {
    scanf("%lld%lld%lld", &x, &y, &z);
    if(c[--x] + d[--y] - z < ans) ans = c[x] + d[y] - z;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    vector<P> d;
    rep(i, 0, m){
        cin >> a[i] >> b[i];
        d.push_back({b[i], a[i]});
    }
    sort(d.begin(), d.end());
    int last = 0, ans = 0;
    rep(i, 0, m){
        if(d[i].second <= last && last < d[i].first) continue;
        last = d[i].first - 1;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4980
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String N = sc.next(); sc.nextLine();
    String Ast = sc.nextLine();
    String As[] = Ast.split(" ",0);
    int A[] = new int[As.length];
    for (int i=0;i<As.length;i++){
       A[i] = Integer.parseInt(As[i]);
    }
    Arrays.sort(A);
    String ans = "YES";
    for (int i=0;i<A.length-1;i++){
      if (A[i] == A[i+1]){
        ans = "NO";
        break;
      }
    }
    System.out.println(ans);
  }
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}
vector<ll> a(300001,inf),sum(300001,0);
vector<ll> b(300001,inf),  c(300001,inf);

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  rep(i,n){
    cin >> a[i];
  }
  sort(a.begin(),a.begin()+n);
  REP(i,0,n){
    sum[i+1] = a[i] + sum[i];
  }
  ll m;
  cin >> m;
  rep(i,m){
    cin >> b[i];
  }
  rep(i,m){
    cin >> c[i];
  }
  rep(j,m){
    ll p = 0;
    auto it = upper_bound(a.begin(),a.begin()+n,b[j]);
    auto dis = distance(a.begin(),it);
    p += sum[dis];
    if( p >= c[j]){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 12224
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <limits>
typedef unsigned long long ull;
using namespace std;
const int oo = 1 << 30;

void solve(){
    string one, two;
    cin >> one >> two;
    vector<vector<int>> dp(one.length() + 1, vector<int>(two.length() + 1, -oo));
    // dp[i][j] => the longest subsequence with i characters of string one and j characters of string two   
    for(int i = 0; i <= one.length(); ++i){
        dp[i][0] = 0;
    }
    for(int i = 0; i <= two.length(); ++i){
        dp[0][i] = 0;
    }
    vector<vector<pair<int,int>>> path(one.length() + 1, vector<pair<int,int>>(two.length() + 1, make_pair(0, 0)));
    for(int i = 0; i < one.length(); ++i){
        for(int j = 0; j < two.length(); ++j){
            if(one[i] == two[j]){
                dp[i + 1][j + 1] = 1 + dp[i][j];
                path[i + 1][j + 1] = make_pair(i, j);
            }
            else {
                if(dp[i + 1][j] > dp[i][j + 1]){
                    path[i + 1][j + 1] = make_pair(i + 1, j);
                    dp[i + 1][j + 1] = dp[i + 1][j];
                }
                else {
                    dp[i + 1][j + 1] = dp[i][j + 1];
                    path[i + 1][j + 1] = make_pair(i, j + 1);
                }
            }
        }
    }
    string answer = "";
    int i = one.length();
    int j = two.length();
    while(i > 0 && j > 0){
        if(one[i - 1] == two[j - 1]){
            assert(one[i - 1] == two[j - 1]);
            answer = one[i - 1] + answer;
            i--;
            j--;
        }
        else if(dp[i][j] == dp[i - 1][j]){
            i--;
        }
        else {
            j--;
        }
    }
    cout << answer << "\n";
}
int main(){
    // freopen("/Users/deepsajeda/Documents/FIRST/in", "r", stdin);
    // freopen("/Users/deepsajeda/Documents/FIRST/out", "w", stdout);
    for(int i = 0; i < 1; ++i){
        solve();
    }
}
//printf("%.5f\n", clock() / (float)CLOCKS_PER_SEC); time in seconds


Measured memory_bytes: 105984
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n=sc.nextInt();
			int k=sc.nextInt();
			int[] a=new int[n+1];
			for(int i=0; i<n; i++) {
				a[i]=sc.nextInt();
			}
			n--;
			k--;
			if(n%k>0) {
				System.out.println(n/k+1);
			}
			else {
				System.out.println(n/k);
			}
			
		}
	}
}



Measured memory_bytes: 50300
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 1000000007

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

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
//#include <string>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int vec[n][m];
    int vec2[m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>vec[i][j];
        }
    }
    
    for(int i=0;i<m;i++){
        cin>>vec2[i];
    }
    
    for(int i=0;i<n;i++){
        int ans=0;
        
        for(int j=0;j<m;j++){
            //cout<<vec[i][j]<<vec2[j]<<endl;
            ans+=vec[i][j]*vec2[j];
            //cout<<ans<<endl;
        }
        
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 3144
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(){
    int N,D,ans=0,count=0;
    cin>>N>>D;
    int X[N][D];
    for(int i=0;i<N;i++){
        for(int j=0;j<D;j++){
            cin >>X[i][j];
        }
    }
    for(int i=0;i<N-1;i++){
        for(int k=i+1;k<N;k++){
            int  check=0;
            for(int j=0;j<D;j++){
                int  a=abs(X[i][j]-X[k][j]);
                check+=a*a;
            }
            for(int l=0;l<=check;l++){
                if(check==l*l){
                    count++;
                    break;
                }
            }
        }
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    //static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        char[] str = sc.next().toCharArray();
        if(str[0]=='7'||str[1]=='7'||str[2]=='7'){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
    }    
}







Measured memory_bytes: 35608
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

        int a = in.nextInt(), b = in.nextInt(), c = in.nextInt(), n = in.nextInt();

        int count = 0;
        for (int i = 0; i <= a; i++) {
            int x = 500 * i;
            for (int j = 0; j <= b; j++) {
                int y = 100 * j;
                if (n - x - y >= 0 && (n - x - y) % 50 == 0 && (n - x - y) / 50 <= c)
                    count++;
            }
        }
        System.out.println(count);

    }
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long n; cin >> n;
    long long ans = -1;
    for(long long i = 1LL; i <= n; i++){
        if((double)(n) <= (double)(i)*1.08 && (double)(i)*1.08 < (double)(n+1)) ans = i;
    }
    if(ans != -1) cout << ans << endl;
    else cout << ":(" << endl;
    return 0;
}


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

using namespace std;

#define ll long long
#define pb push_back

const int mod = 1e9 + 7;
const int INF = 1e9;
const int N = 2e5 + 5;

int main(){
	int x;
  cin >> x;
  cout << x + x * x + x * x * x << endl;
}

Measured memory_bytes: 3632