akhauriyash/Code-Regression huggingface dataset:
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}
string s;
int main()
{
	cin>>s;
	if (s=="Sunny") puts("Cloudy");
	if (s=="Rainy") puts("Sunny");
	if (s=="Cloudy") puts("Rainy");
	return 0;
}









Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
long long a[200005];
map<long long ,long long>my;
int main()
{
    cin>>n;
    long long sum=0;
    long long cnt=0;
    my[0]=1;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
        cnt+=my[sum];
        my[sum]++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 14336
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <functional>
#include <numeric>
#include <cassert>
#include <algorithm>
#include <functional>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)

#define huge 1000000007
typedef long long int ll;
ll gcd(ll a, ll b);
ll bur(ll N, ll X);
bool IsPrime(int num);

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll D = 0;
	ll P = 0;
	//ll T = 0;
	//ll M = 0;
	ll h[1000] = {};
	//ll b[100] = {};
	//ll c[100] = {};
	//ll d[100] = {};

	//ll v[3] = {};
	//ll *c, *s, *n;
	string S[50],T[50],U[52];
	ll count = 0;
	ll count2 = 0;
	float sum = 0;
	ll min = 1000000000000;
	ll max = 1;
	ll smax = 0;
	ll max2 = 0;
	ll smax2 = 0;
	int tmax = 0;
	int tmax2 = 0;
	//int flag = 0;
	char temp,head;
	//int is = 0;
	bool flag = false;
	
	//char p;

	ll all = 0;
	ll niku = 0;
	ll state = 2;
	bool down = true;
	

	//cin >> S;
	
	vector<pair<int,int>> ch(1000);
	
	

	cin >> N;
	vector<int> c(N);


	rep(i, 0, N) {
		cin >> c[i];
	}

	rep(i, 0, N) {
		
		if (c[i] % 2 != 0) {
			cout << "first" << endl;
			return 0;
		}

	}


	cout <<"second"<< endl;
	

	//x = (ll *)malloc((N+1) * sizeof(ll));
	//c = (ll *)malloc((N) * sizeof(ll));
	//cin >> D >> G;
	//vector<pair<int,int>> tr(M);
	//vector<pair<int,int>> qes(Q);
	//sort(c.begin(), c.end());
	
	//cout << c[2] - c[1] << endl;

	
	/*A = N / 1000;
	N %= 1000;
	B = N / 100;
	N %= 100;
	C = N / 10;
	N %= 10;
	D = N;*/
	


	//cin >> N >> M;

	//vector<pair<int,int>> c(M);
	////vector<pair<int, int>> e(M);
	//vector<ll> d(M);

	//rep(i, 0, M) {
	//	cin >> c[i].first >> c[i].second;
	//	//e[i].first = c[i].first;
	//	//e[i].second = c[i].second;

	//}
	////sort(c.begin(), c.end());

	//

	//rep(i, 0, M) {

	//	
	//	
	//	rep(j, 0, M) {
	//		if (c[i].first == c[j].first && c[j].second < c[i].second) {
	//			d[i]++;
	//			//cout << j << endl;
	//		}
	//	}
	//	cout << std::setfill('0') << std::right << std::setw(6) << c[i].first;
	//	cout << std::setfill('0') << std::right << std::setw(6) << d[i]+1 << endl;
	//}

	return 0;

}

ll bur(ll N,ll X) {
	ll pan = 1;
	ll pat = 1;
	ll burg = 0;



	if (X > burg) {
		if (N == 0)
			return pat;


		burg += pan;
		burg += bur(N - 1, X);
		burg += pat;
		burg += bur(N - 1, X);
		burg += pan;


	}

	return burg;

}

ll gcd(ll a, ll b) {
	
	/* 自然数 a > b を確認・入替 */
	if (a<b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}
	ll x = b;
	ll y = a;
	/* ユークリッドの互除法 */
	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}


	return y/b*x;
}

bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int N=200000+5;
int main()
{
    int n,a[N],b[N];
    cin >> n;
    for(int i=0;i<n;i++) scanf("%d",&a[i]),b[i]=a[i];
    sort(b,b+n);
    int x,y;
    y=b[n/2],x=b[n/2-1];
    for(int i=0;i<n;i++)
    {
        if(a[i]<=x) printf("%d\n",y);
        else if(a[i]>=y) printf("%d\n",x);
    }
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#define rep(i, n) for (int i{ 0 }; i < n; ++i)
#define rep1(i, n) for (int i{ 1 }; i <= n; ++i)

using namespace std;

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

    vector<int> ans(N);
    rep1(i_x, sqrt(N - 1)) rep1(i_y, sqrt(N - 1)) rep1(i_z, sqrt(N - 1)) {
        n = i_x * i_x + i_y * i_y + i_z * i_z + i_x * i_y + i_y * i_z + i_z * i_x;
        if (n <= N) ans.at(n - 1)++;
    }

    for (const auto& a : ans) cout << a << endl;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
    int n, m, i, x, y, z;
    set<int> st;
    cin >> n >> m;
    UnionFind uf(n);
    for(i=0; i<m; i++){
        cin >> x >> y >> z;

            uf.unite(x-1, y-1);
        
    }
    for(i=0; i<n; i++){
        st.insert(uf.find(i));
    }
    cout << st.size() << "\n";
    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h> 
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define per(i,n) for(long long i = (long long)(n-1);i >= 0;--i)
#define REP(i,s,t) for(long long i=s;i<t;i++)
#define PER(i,s,t) for(long long i=s;i>t;--i)
#define all(x) x.begin(),x.end()
#define sp(n) setprecision(n)
typedef long long ll;
using namespace std;
ll p=1000000000+7;//substitute prime
ll e[60],q[60];
ll f(int k){
  q[0]=k;
  REP(i,1,60){
    q[i]=(q[i-1]*q[i-1])%p;}
  ll prime=p-2;  
  rep(i,60){
      if(prime%2==1){
          e[i]=1;
      }
      prime/=2;
  }
  ll t=1;
  rep(i,60){if(e[i]==1){t=(t*q[i])%p;}}
  return t;}
int main(){
  ll n,k;
  cin>>n>>k;
  ll a[2010]={0},b[2010];
  a[0]=1;
  REP(i,1,2010){
    a[i]=i*a[i-1]%p;
  }
  rep(i,2010){
    b[i]=a[i];
  }
  rep(i,2010){
    a[i]=f(a[i]);
  }
  REP(i,1,k+1){
    if(i<=n-k+1){
      cout<<((((a[i-1]*a[k-i]%p)*(a[i]*a[n-k+1-i]%p))%p)*
             (b[k-1]*b[n-k+1]%p))%p<<endl;
    }
    else{
      cout<<0<<endl;
    }
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();
        int a = scan.nextInt();
        int b = scan.nextInt();
        int ok = 0;

		for(int i=a; i<b+1; i++){
			if(i%k==0) {
				ok++;
			}
		}

		if (ok>0) {
			System.out.println("OK");
		} else {
			System.out.println("NG");
		}
	    scan.close();	
    }
}

Measured memory_bytes: 35768
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll N, K;
  cin >> N >> K;
  vector<ll> H(N);
  rep (i, N) cin >> H[i];

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

  ll ans = 0;

  rep (i, N) {
    if (i >= K) ans += H[i];
  }

  cout << ans << endl;
}

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define watch(x) cout << #x << " is " << x << endl;
#define print(a, l, r)          \
	for (int i = l; i < r; i++) \
		cout << a[i] << (i == (r - 1) ? endl : " ");
const long long M = 1000000007;
int main()
{

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

	int n;
	cin >> n;

	string s;
	cin >> s;

	stack<char> st;
	for (int i = 0; i < n; i++)
	{
		if (!st.empty())
		{
			if (st.top() != s[i])
				st.push(s[i]);
		}
		else
			st.push(s[i]);
	}
	cout << st.size() << endl;

	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s)
{
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}
template <class T>
inline string toString(T x)
{
	ostringstream sout;
	sout << x;
	return sout.str();
}

//math
//-------------------------------------------
template <class T>
inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

//repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0, sizeof(a))

//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
					  << " " << __FILE__ << endl;

int main(void)
{
	int n, a, b;
	cin >> n >> a >> b;
	if ((b - a) % 2 == 0)
	{
		cout << "Alice" << endl;
	}
	else
	{
		cout << "Borys" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
m = 2 ** 150 - 1
N = int(input())
X = sorted([input()[::-1] for _ in range(N)], key = len)

D = {}
ans = 0
for x in X:
    L = [0] * 26
    T, a = x[:-1], ord(x[-1]) - 97
    h = 0
    for t in T:
        if h in D:
            for i in range(26):
                L[i] += D[h][i]
        b = ord(t) - 97
        ans += L[b]
        L[b] = 0
        
        h = (h + b + 135 + (h << 11)) & m
    ans += L[a]
    if h in D:
        D[h][a] += 1
    else:
        D[h] = [0] * 26
        D[h][a] = 1
    
print(ans)

Measured memory_bytes: 186608
import math
import fractions
from functools import reduce

def loop1(i, k, ans):
  global arr, result
  for ai in range(int(math.floor(k/arr[i])+1)):
    if (i+1<len(arr)):
      loop1(i+1, k-arr[i]*ai, ans+[ai])
    else:
      if arr[i]*ai==k:
        result=ans+[ai]
        break
  return result

def gcd(*arr):
  return reduce(fractions.gcd, arr)

def loop2(i, k, ans):
  global arr, result
  if k%gcd(*arr[i:len(arr)])==0:
    for ai in range(int(math.floor(k/arr[i])+1)):
      if i+1<len(arr):
        loop2(i+1, k-arr[i]*ai, ans+[ai])
      else:
        result=(ans+[ai])
        break
  return result


arr=[100, 101, 102, 103, 104, 105]
k=int(input())
result=""
if k>=2200:
  print(1)
else:
  loop2(0, k, [])
  if result=="":
    print(0)
  else:
    print(1)


Measured memory_bytes: 82900
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
 
#define mod 1000000007

ll ebob(ll a, ll b){
	if(a == 0) return b;
	return ebob(b%a, a);
}
bool prime(int n){
	if(n == 0 || n == 1) return 0;
	if(n == 2 || n == 3) return 1;
	for(int i = 2; i*i <= n; i++){
		if(n%i == 0) return 0;
	}
	return 1;
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, k; cin>>n>>k;
	int r,s,p; cin>>r>>s>>p;
	string ss; cin>>ss;
	vector<pair<char, int>> vec(k);
	ll res = 0;
	for(int i = 0; i < ss.size(); i++){
		if(i > k-1){
			int temp = i%k;
			if(ss[i] == 'p'){
				if(vec[temp].first == 's'){
					if(vec[temp].second == 0){
						vec[temp].second = 1;
						res += s;
					}else{
						vec[temp] = make_pair('p', 0);
					}	
				}else{
					vec[temp] = make_pair('s', 1);
					res += s;
				}
			}else if(ss[i] == 'r'){
				if(vec[temp].first == 'p'){
					if(vec[temp].second == 0){
						vec[temp].second = 1;
						res += p;
					}else{
						vec[temp] = make_pair('r', 0);
					}	
				}else{
					vec[temp] = make_pair('p', 1);
					res += p;
				}
			}else if(ss[i] == 's'){
				if(vec[temp].first == 'r'){
					if(vec[temp].second == 0){
						vec[temp].second = 1;
						res += r;
					}else{
						vec[temp] = make_pair('s', 0);
					}	
				}else{
					vec[temp] = make_pair('r', 1);
					res += r;
				}
			}
		}else{
			if(ss[i] == 'p'){
				vec[i] = make_pair('s', 1);
				res += s;
			}else if(ss[i] == 'r'){
				vec[i] = make_pair('p', 1);
				res += p;
			}else if(ss[i] == 's'){
				vec[i] = make_pair('r', 1);
				res += r;
			}
		}
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 1232
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {

		final Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int X = Integer.parseInt(sc.next());
		int[] l = new int[N];
		for (int i = 0; i < N; i++) {
			l[i] = Integer.parseInt(sc.next());
		}
		sc.close();

		int d = 0;
		int ans = 1;
		for (int i = 0; i < N; i++) {
			d += l[i];
			if (d <= X) {
				ans++;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21844
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

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

struct Dinic {
	struct edge {
		int to;
		ll cap;
		int rev;
		bool isrev;
		int idx;
		edge(int _to, ll _cap, int _rev, bool _isrev, int _idx) :to(_to), cap(_cap), rev(_rev), isrev(_isrev), idx(_idx) {}
	};
	vector<vector<edge>> g;
	vector<int> min_cost, iter;
	Dinic(int n) :g(n) {}

	void add_edge(int from, int to, ll cap, int idx = -1) {
		g[from].emplace_back(to, cap, (int)g[to].size(), false, idx);
		g[to].emplace_back(from, 0, (int)g[from].size() - 1, true, idx );
	}

	bool bfs(int s, int t) {
		min_cost.assign(g.size(), -1);
		queue<int> q;
		q.emplace(s);
		min_cost[s] = 0;
		while (!q.empty() && min_cost[t] == -1) {
			int cur = q.front();
			q.pop();
			for (auto& e : g[cur]) {
				if (e.cap > 0 && min_cost[e.to] == -1) {
					min_cost[e.to] = min_cost[cur] + 1;
					q.push(e.to);
				}
			}
		}
		return min_cost[t] != -1;
	}

	ll dfs(int idx, const int t, ll flow) {
		if (idx == t) return flow;
		for (int& i = iter[idx]; i < g[idx].size(); i++) {
			edge& e = g[idx][i];
			if (e.cap > 0 && min_cost[idx] < min_cost[e.to]) {
				ll d = dfs(e.to, t, min(flow, e.cap));
				if (d > 0) {
					e.cap -= d;
					g[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

	ll max_flow(int s, int t) {
		ll flow = 0;
		while (bfs(s, t)) {
			iter.assign(g.size(), 0);
			ll f = 0;
			if ((f = dfs(s, t, INF)) > 0) flow += f;
		}
		return flow;
	}
};
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	int V, E; scanf("%d %d", &V, &E);
	Dinic g(V);
	for (int i = 0; i < E; i++) {
		int from, to, cap; scanf("%d %d %d", &from, &to, &cap);
		g.add_edge(from, to, cap);
	}
	cout << g.max_flow(0, V - 1) << endl;
	return 0;
	/*
		おまじないを使ったらscanfとprintf関連注意！！！！！！！！！！！！
	*/
}



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

int main()
{
  int n, ans=0, flag=0;
  cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  string x;

  for(int i=0; i<n; i++){
    cin >> s[i] >> t[i];
  }

  cin >> x;
  for(int i=0; i<n; i++){
    if(flag){
      ans += t[i];
    }
    else if(x==s[i]){
      flag=1;
    }
  }

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
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 MOD = 1000000007;
ll INF =1<<30;
ll dp[110][100100];
 
 
int main(){
    int n;
    cin >> n;
    bool ok  = true;
    int s = 0;
    int sx=0,sy=0;
    rep(i,n){
         int t,x,y;
         cin >> t >>x >>y;
         if(t-s<abs((x-sx)+(y-sy))) {
              cout <<"No" <<endl;
              return 0;
         }
         if((t-s)%2!=abs((x-sx)+(y-sy))%2){
              cout << "No" <<endl;
              return 0;
         }
         s = t;
         sx = x;
         sy = y;
    }
    if(ok) cout << "Yes" <<endl;
}

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

const int nax = 55;

int main()
{
	using ll = long long;
	int n, a;
	cin >> n >> a;
	vector<int> x(n);
	for(int& i: x) cin >> i;
		
	vector<vector<ll>> dp(nax, vector<ll>(nax*nax));
	// dp[i][j] = #of ways to get sum 'j' by taking 'i' elements from the array
	dp[0][0] = 1;
	for(int i = 0; i < n; i++) {
		for(int j = i; j >= 0; j--) {
			for(int k = 0; k < nax*nax; k++) {
				if(k + x[i] < nax*nax) {
					dp[j+1][k+x[i]] += dp[j][k];
				}
			}
		}
	}
	
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += dp[i][i * a];
	}
	cout << ans << endl;
}


Measured memory_bytes: 4584
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n,m;
  cin>>n>>m;
  vvll s(m,vll(0));
  rep(i,m){
    int k;
    cin>>k;
    for(int g=0;g<k;g++){
      ll j;
      cin>>j;
      s[i].pb(j);
    }
  }
  ll ans=0;
  vll p(m);
  rep(i,m) cin>>p[i];
  for(int bit=0;bit<(1<<n);bit++){
    for(int i=0;i<m;i++){
      ll h=0;
      ll cu=0;
      for(int j=0;j<s[i].size();j++){
        if(bit&(1<<s[i][j]-1))cu++;
      }
      if(cu%2==p[i]) h++;
      else break;
      if(i==m-1)ans++;
    }
  }
  COUT(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main(){
    int N; cin >> N;
    vector<int> V(N);
    for(int &v:V){
        cin >> v;
    }
    
    sort(V.begin(), V.end());
    double kimera = V[0];
    
    for(int i=1; i<N; i++){
        kimera = (kimera + V[i])/2;
    }
    
    cout <<  fixed << setprecision(20) <<  kimera << endl;
    return 0;
}





Measured memory_bytes: 256
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


using namespace std;

template<class T>
using vec = std::vector<T>;

template<class T>
using vec2d = std::vector<std::vector<T>>;


template<class T>
vec2d<T> makeVec2d(const int n1) {
  return vec2d<T>(n1);
}


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


#define all(c) c.begin(), c.end()


// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}


void dfs(int v, const vec2d<int>& g, vec<int>&u, vec<int>& topo) {
  u[v] = true;
  for (auto to : g[v]) {
    if (!u[to]) {
      dfs(to, g, u, topo);
    }
  }
  topo.push_back(v);
}

void solve(istream& in, ostream& out) {
  auto n = next<int>(in);
  auto m = next<int>(in);
  vec2d<int> g = makeVec2d<int>(n);
  FOR(i, m) {
    auto a = next<int>(in) - 1;
    auto b = next<int>(in) - 1;
    g[a].push_back(b);
  }
  vec<int> u(n, 0);
  vec<int> topo;
  FOR(i, n) {
    if (!u[i]) {
      dfs(i, g, u, topo);
    }
  }
  reverse(all(topo));
  vec<int> f(n, 1);
  FOR(i, n) {
    for (auto to : g[topo[i]]) {
      f[to] = max(f[to], f[topo[i]] + 1);
    }
  }
  int res = 0;
  FOR(i, n) {
    res = max(res, f[i]);
  }
  out << res - 1 << "\n";
}

//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



Measured memory_bytes: 9720
S = input()

for i in range(8):
    ops = list(format(i, "03b"))
    ret = int(S[0])
    ans = S[0]
    for j, op in enumerate(ops):
        if op == "0":
            ret += int(S[j + 1])
            ans += "+" + S[j + 1]
        else:
            ret -= int(S[j + 1])
            ans += "-" + S[j + 1]
    # print(ops, ret)

    if ret == 7:
        print(ans + "=7")
        exit()


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

using namespace std;

#define pq priority_queue
#define MZ 1000000007


int main()
{
    int a,b,c;
    int x,y,z;
    cin>>a>>b>>c;
    x=min(a,min(b,c));
    z=max(a,max(b,c));
    y=a+b+c-x-z;
    if((y-x)%2)
        printf("%d\n",((z+1)*3-a-b-c)/2);
    else
        printf("%d\n",(y-x)/2+z-y);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
  string s; cin >> s;
  map<char,int> C;
  string ans="yes";
  for(int i=0;i<s.length();i++){
  	C[s[i]]++;
    if(C[s[i]]>1) {ans="no"; break;}
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <queue>
#include <assert.h>
#include <cmath>
#include <stack>
#include <deque>
#include <set>
#include <unordered_map>
#include <complex>
#include <fstream>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
const int mxn = 310;
char matrix[mxn][mxn];

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

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

	int ans = 0, A = 0;
	for(int B=0; B<n; B++) {
		bool good = 1;
		for(int i=0; i<n; i++) {
			for(int j=i; j<n; j++) {
				if(matrix[(i+A)%n][(j+B)%n]!=matrix[(j+A)%n][(i+B)%n]) {
					good = 0; break;
				}
			}
			if(good==0) break;
		}
		ans+=good;
	}

	cout << ans*n << '\n';


	return 0;
}
//comparator function in sorting
//swapping arguments
//missing cases in dp
//dividing in modulo
//Beware of overflow and modulo
//Be mindful of overflow
//s is a matrix but forget
//length of ranges
//working with bit using ull

Measured memory_bytes: 3732
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    cin>>n;
    if(n<15) cout<<n*800<<endl;
    else{
        cout<<n*800-n/15*200<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
//function area

//main area
int main(){
    string s;
    cin >> s;
    if(s == "RSR"){
        cout << 1 << endl;
    }
    else{
        int ans = 0;
        rep(i,3){
            if(s[i] == 'R'){
                ans++;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3624
#include <stdio.h>

int main() {
  int x;
  int b = 1;
  int p = 1;
  int max = -1;
  scanf("%d", &x);
  
  while (p*p <= x) {
    while (b*p <= x) {
      b *= p;
      if (b == 1) break;
    }
    if (b > max) {
      max = b;
    }
    b = 1;
    p++;
  }

  printf("%d\n", max);
  
  return 0;
}


Measured memory_bytes: 128
N = int(input())
red = []
blue = []
for i in range(N):
    x, y = map(int, input().split())
    red.append((x, y))
for i in range(N):
    x, y = map(int, input().split())
    blue.append((x, y))
red.sort(key=lambda x: x[0])
blue.sort(key=lambda x: x[0])
ans = 0
for j in range(N):
    index = -1
    for i in range(len(red)):
        if red[i][0] >= blue[j][0]:
            break
        elif red[i][1] < blue[j][1]:
            if index == -1 or red[index][1] < red[i][1]:
                index = i
    if index != -1:
        red.remove(red[index])
        ans += 1
print(ans)


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

public class Program
{
	public static void Main()
	{
		int N = int.Parse(Console.ReadLine());
		int[] arr = Console.ReadLine().Split().Select(i => int.Parse(i))
			.ToArray();
		int ans = int.MaxValue;
		for (int i = -100; i <= 100; i++)
		{
			int sum = 0;
			foreach (int elem in arr)
			{
				sum += (int)Math.Pow(elem - i, 2);
			}
			ans = Math.Min(ans, sum);
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 3032
n = int(input())
a_lis = list(map(int,input().split()))
a_lis.sort()

for i in range(n-1):
      x = a_lis[0]
      y = a_lis[1]
      z = (x+y)/2
      del a_lis[:2]
      a_lis.insert(0,z)
print(a_lis[0])

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int L[11];
    rep(i, N) cin >> L[i];
    int sum = 0;
    sort(L, L + N);
    rep(i, N - 1) sum += L[i];
    if (sum > L[N - 1]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
countup = [0 for x in range(n + 1)]
for i in a:
  countup[i] += 1

countup.sort()
result = 0
f = list(filter(lambda x: x != 0, countup))

for i, v in enumerate(f):
 if i >= len(f) - k:
    print(result)
    break
 result += v


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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'

int n;

int main()
{
	IOS;
	cin >> n;
	int cnt, ans = 0;
	for (int i = 1; i <= n; i+=2) {
		cnt = 0;
		for (int j = 1; j <= i; j++) {
			if (i % j == 0) {
				cnt++;
				//db(i, j, cnt);
			}
		}
		if (cnt == 8) ans++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
N,M=map(int,input().split())
PS = [input().split() for i in range(M)]
Flag = [0 for i in range(N)]
WA_count = [0 for i in range(N)]

for i in range(M):
  p = int(PS[i][0])-1
  s = PS[i][1]
  
  if s =="AC":
    Flag[p]=1
  else:
    if Flag[p]==0:
      WA_count[p]+=1
a=0
for i in range(N):
  if Flag[i]==1:
    a+=WA_count[i]

print(sum(Flag),a)

Measured memory_bytes: 74192
N, M = map(int, input().split())
H = list(map(int, input().split()))
count = [0]*N
ans = 0
for _ in range(M):
    a, b = map(int, input().split())
    if H[a-1] > count[b-1]:
        count[b-1] = H[a-1]
    if H[b-1] > count[a-1]:
        count[a-1] = H[b-1]
for i in range(N):
    if H[i] > count[i]:
        ans += 1
print(ans)

Measured memory_bytes: 20012
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



int main(){
    ll x;
    cin >> x;
    ll a = 100;
    ll ans = 0;
    while(a < x){
	a *= 1.01;
	ans++;
    }
    P(ans);
    return  0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  string x,y,z;
  cin>>x>>y>>z;
  int l=x.length(),m=y.length();
  if(x.at(l-1)==y.at(0)&&y.at(m-1)==z.at(0)) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 3580
#include <iostream>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  if(n&1){cout<<"No";return 0;}
  string s;
  cin >> s;
  for(int i=0; i<n/2; i++){
    if(s[i]!=s[i+n/2]){
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}

Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

############################################
# しゃくとり法
############################################
# 区間において単調増加となるものの個数　ABC038_c
############################################

def main():
    N = int(input())
    A = list(map(int, input().split()))
##
    ret = 0
    right = 0
    tot = 0
    for left in range(0,N):
        while (right < N and ((tot ^ A[right] == tot + A[right]) or left == right)):   #####条件
            tot += A[right]
            right += 1
#        print(ret, left, right)
        ret += right - left                  #####値の更新
        tot = tot ^ A[left]
    print(ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 24840
#include<stdio.h>

int main(void){
	char str[21],c;
	int n;
	scanf("%s",str);
	for(int i=0;i<21;i++){
		if(str[i]=='\0'){
			n=i;
			break;
		}
	}
	for(int i=0;i<n/2;i++){
		c=str[i];
		str[i]=str[n-i-1];
		str[n-i-1]=c;
	}
	printf("%s\n",str);
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    int N;
    cin >> N;
    cout << N*(N+1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

class Program
    {
        static void Main(string[] args)
        {
            // get string
            string str = Console.ReadLine();
            int strike = 0;
            int last_strike = 0;
            for (int i = 0; i < str.Length; i++)
            {
                if (str[i] == 'A' || str[i] == 'T' || str[i] == 'C' || str[i] == 'G')
                {
                    strike++;
                }
                else
                {
                    if (strike > 0) // canceled string
                    {
                        if (last_strike < strike)
                        {
                            last_strike = strike;
                        }
                        strike = 0;
                    }
                }
            }

            if (strike > 0) // canceled string
            {
                if (last_strike < strike)
                {
                    last_strike = strike;
                }
                strike = 0;
            }
            //output
            Console.WriteLine(last_strike);
        }
    }

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

int main(){
    int64_t n,k;
    cin>>n>>k;
    int64_t ans=0;
    if(k%2==0){
        //全部偶数->全部kの倍数
        ans += (n/k)*(n/k)*(n/k);
        //全部奇数->全部(kの倍数+k/2)
        ans += ((n+(k/2))/k)*((n+(k/2))/k)*((n+(k/2))/k);
    }
    else{//kが奇数 
    //条件を満たすa,b,cは全部kの倍数の時だけ
        ans += (n/k)*(n/k)*(n/k);

    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

ll t[101],p[101],x[101];
ll sum;

int main(){
	ll n,m;
	cin >> n;
	cinf(t,n);
	rep(i,n){
		sum+=t[i];
	}
	cin >> m;
	rep(i,m){
		cin >> p[i] >> x[i];
	}
	rep(i,m){
		cout << sum-t[p[i]-1]+x[i] << endl;
	}
}

Measured memory_bytes: 3604
# -*- coding: utf-8 -*-
import math

n = int(input())
dic = {}

for x in range(1,int(math.sqrt(n/6)+1)):
  y = x
  while x**2+3*y**2+2*x*y <= n:
    z = y
    while x**2+y**2+z**2+x*y+y*z+z*x <= n:
      if x**2+y**2+z**2+x*y+y*z+z*x not in dic:
        dic[x**2+y**2+z**2+x*y+y*z+z*x] = [[x,y,z]]
      else:
        dic[x**2+y**2+z**2+x*y+y*z+z*x].append([x,y,z])
      z += 1
      
    y += 1
    
for i in range(1,n+1):
  if i not in dic:
    print(0)
  else:
    count = 0
    for xyz in dic[i]:
      if xyz[0] == xyz[1] and xyz[1] == xyz[2]:
        count += 1
      elif xyz[0] == xyz[1] or xyz[1] == xyz[2]:
        count += 3
      else:
        count += 6
    print(count)

Measured memory_bytes: 14764
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;

int main(int argc, char* argv[])
{
  int N;
  std::cin >> N;

  std::vector< ll > va(N, 0);
  for (int i = 0; i < N; i++) {
    std::cin >> va[i];
  }

  int cnt = 0;
  int idx = 1;
  for (int i = 0; i < N; i++) {
    idx = va[idx - 1];
    cnt++;
    if (idx == 2) {
      break;
    }
  }

  std::cout << (idx == 2 ? cnt : -1) << std::endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define each(i, mp) for (auto &i : mp)
#define sz(x) int(x.size())
#define INF 1000000000000

// vector<ll> heiro;
// vector<ll> to;

// void f(ll now, ll last)
// {
//   ll next = to[now];
//   if (next >= last)
//   {
//     return;
//   }
//   heiro.push_back(now);
//   f(next, last);
// }

// int main()
// {
//   ll n, k;
//   cin >> n >> k;
//   to.resize(n);
//   vector<ll> steps;
//   rep(i, n)
//   {
//     ll in;
//     cin >> in;
//     to[i] = in;
//   }
//   vector<ll> visitedStep(n, -1);
//   visitedStep[0] = 0;
//   ll step = 0;
//   ll now = 0;
//   ll heirofirst = 0;
//   while (1)
//   {
//     steps.push_back(now);
//     ll next = to[now];
//     if (visitedStep[next] != -1)
//     {
//       heirofirst = visitedStep[next];

//       f(visitedStep[next], next);
//       break;
//     }
//     if (step == k)
//     {
//       break;
//     }
//     visitedStep[now] = step;
//     now = next;
//     step++;
//   }
//   if (heiro.size() == 0)
//   {
//     cout << now + 1 << endl;
//   }
//   else
//   {
//     ll tmpk = k - now;
//     ll idx = tmpk % heiro.size();
//     cout << heiro[idx] + 1 << endl;
//   }
//   return 0;
// }

int main()
{
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<int> s;
  vector<int> ord(n + 1, -1);
  int c = 1;
  int l = 0;
  {
    int v = 1;
    while (ord[v] == -1)
    {
      ord[v] = s.size();
      s.push_back(v);
      v = a[v - 1];
    }
    c = s.size() - ord[v];
    l = ord[v];
  }
  if (k < l)
  {
    cout << s[k] << endl;
  }
  else
  {
    k -= l;
    k %= c;
    cout << s[l + k] << endl;
  }
  return 0;
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;

#define MAX_N 200010

class UnionFind {
private:
    // 親と木の深さ
    int par[MAX_N];
    int rank[MAX_N];
public:
    void init(int n);
    int find(int x);
    void unite(int x, int y);
};

// 要素数nで初期化
void UnionFind::init (int n) {
    for(int i=0; i<n; i++) {
        par[i] = i;
        rank[i] = 0;
    }
}

// 要素xの親を求める
int UnionFind::find(int x) {
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
}

// xとyの属する集合を併合
void UnionFind::unite(int x, int y) {
    // xとyの親
    x = find(x);
    y = find(y);
    if(x == y) return;

    // yのほうが深さが深い　xの親はyの親
    if(rank[x] < rank[y]) par[x] = y;
    else {
        par[y] = x;
        if( rank[x] == rank[y] ) rank[x]++;
    }
}

UnionFind a;

int main(){
    int n, q, com[100000], x[100000], y[100000];
    cin >> n >> q;
    a.init(n);
    for(int i = 0;i < q;i++){
        cin >> com[i] >> x[i] >> y[i];
    }
    for(int i = 0;i < q;i++){
        if(!com[i]) a.unite(x[i], y[i]);
        else{
            if(a.find(x[i])==a.find(y[i])) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int64_t> L(3);
  L.at(0) = 0;
  L.at(1) = 2;
  L.at(2) = 1;
  for (int i = 0; i < N - 1; i++) {
    L.at(0) = L.at(1);
    L.at(1) = L.at(2);
    L.at(2) = L.at(0) + L.at(1);
  }
  
  cout << L.at(2) << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
          
using namespace std;
          
typedef long long ll;
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define db long double

int n;
int a[200007];
map<ll, int> was;

int main(){
  //  freopen("input.txt", "r", stdin);
    //freopen("output1.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    ll gg = 0;
	was[0] = 1;
	ll ans = 0;
	for (int i = 0; i < n; i++){
		gg += a[i];
		ans += was[gg];
		was[gg]++;
	}
	cout << ans;
}

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

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

    int N, Q;
    cin >> N >> Q;
    vector<ll> a(N);
    for (int i = 0; i < N; ++i) {
        cin >> a.at(i);
    }
    for (int cnt = 0; cnt < Q; ++cnt) {
        ll x;
        cin >> x;
        ll ans = 0;
        ll sum = 0;
        int right = 0;
        for (int left = 0; left < N; ++left) {
            while (right < N && sum + a.at(right) <= x) {
                sum += a.at(right++);
            }
            ans += right - left;
            if (right == left) {
                ++right;
            } else {
                sum -= a.at(left);
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3548
#include <iostream>
using namespace std;
//B - TAKOYAKI FESTIVAL 2019
//C - Slimes

const int MaxinumNum=100000+5;

int main(int argc, const char * argv[]) {
    int N=0, cnt=0;
    char D[MaxinumNum], ch;
    long long sum = 0;
    
    cin >> N;

    scanf("%s", D);
    D[N] = '\0';

    for(;;){
        ch = D[cnt];
        while(cnt<N && ch == D[++cnt]);
        sum += 1;
        if(cnt==N)break;
    }

    cout << sum <<endl;
    
    return 0;
}


Measured memory_bytes: 384
#include <cstdlib>
#include <iterator>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <functional>
using namespace std;

int main() {
    int n, i;
    cin >> n >> i;
    cout << n - i + 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

int N,W,S,E;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string str;cin>>str;
    for(auto a : str){
        if(a=='N') N++;
        if(a=='S') S++;
        if(a=='W') W++;
        if(a=='E') E++;
    }
    if(((N>0&&S>0) && (W>0&&E>0)) || ((N>0&&S>0) && (W==0&&E==0)) || ((N==0&&S==0) && (W>0&&E>0))) {
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 256