akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
//ここから書き始める

int main()
{
	cout <<setprecision(10);
	int n;
	cin >> n;
	ll ans = 0;
	For(i,1,n/2 + 1){
		int j = n - i;
		if(j>0 && i != j){
			ans ++;	
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    string s;
    cin >> s;
    stack<char> S;
    S.push(s[0]);
    repd(i, 1, s.size()){
        if(S.empty()){
            S.push(s[i]);
            continue;
        }
        char c = S.top();
        if(c == 'S' && s[i] == 'T'){
            S.pop();
            continue;
        }
        else{
            S.push(s[i]);
        }
    }
    
    output(S.size());
    
    return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mp make_pair
#define S second
#define F first
ll mod=1e9+7;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define input_from_file  freopen("input.txt", "r", stdin);
using namespace std::chrono; 

int main()
{ 
  // input_from_file
  fastIO
  ll n;cin>>n;
  vector<ll> vec(n+1,0);
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      for(int k=1;k<=n;k++){
        ll x=i*i+j*j+k*k+i*j+j*k+k*i;
        if(x>n) break;
        vec[x]++;
      }
    }
  }
  for(int i=1;i<=n;i++) cout<<vec[i]<<endl;
  return 0;
}  



Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int n, t; cin >> n >> t;
    long long ans=(long long)t*(long long)n;
    int prev_ti; cin >> prev_ti;
    for(int i=0; i<n-1; ++i){
        int ti; cin >> ti;
        ans-=max(t-(ti-prev_ti), 0);
        prev_ti=ti;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
  	ll N, K;
    cin >> N  >> K;
    
    ll ans = 0;
    if(K==0){
      cout << N*N <<endl;
      return 0;
    }

    for(ll b=K+1;b<=N;b++){
      ll q = (N-K)/b;
      ll gap = N-q*b - K;
      ll gap2 = min(gap+1, b-K);
      ans += (q+1)*(gap2) + q*(b-K-gap2);
      //cout << ans << endl;
    }	

    cout << ans <<endl;

  	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef int in;
#define int long long
#define pb push_back
#define f first
#define s second
const int MAX=1e5;
const int MAAX=1e9;
const int MOD=1e9+7;
in main()
{
int n,a[105];
cin>>n;
for(int i=0;i<n;i++)
{
    cin>>a[i];
}
int mn=INT_MAX;
for(int i=0;i<=101;i++)
{
    int cur=0;
    for(int j=0;j<n;j++)
    cur+=abs(i-a[j])*abs(i-a[j]);
    mn=min(cur,mn);
}
cout<<mn<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 200005
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int n,q,d[maxn],nxt[maxn],ans[maxn],pre[maxn];
struct node{int s,t,x;}p[maxn];
struct node2{int x,id;};
set <int> s,tmp;
set <int>::iterator it1,it2;
map <int,int> mp;
vector <int> vec;

inline bool cmp(node a,node b){return a.x<b.x;}

int main()
{
	n=read(); q=read();
	for(int i=1;i<=n;i++) p[i].s=read(),p[i].t=read()-1,p[i].x=read();
	sort(p+1,p+n+1,cmp);
	for(int i=1;i<=q;i++) d[i]=read(),ans[i]=-1,s.insert(d[i]),mp[d[i]]=i,tmp.insert(d[i]);
	sort(d+1,d+q+1);
	for(int i=1;i<=n;i++)
	{
		vec.clear();
		it1=s.lower_bound(max(0,p[i].s-p[i].x));
		it2=s.upper_bound(max(0,p[i].t-p[i].x));
		
		for(set <int>::iterator it=it1;it!=it2;it++)
		{
			ans[mp[*it]]=p[i].x;
			vec.push_back(*it);
		}
		for(int i=0;i<vec.size();i++) s.erase(vec[i]);
	}
	for(int i=1;i<=q;i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 34936
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<double> VD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1 << 17;
int n, m;
VI g[N];
VI ans[N];
int deg[N];
char used[N];
set<int> syny[N];
set<PII> bulo;

void dfs(int v, int p)
{
	used[v] = 1;
	if (p)
		syny[v].insert(p);
		
	for(auto i: g[v])
		if (i != p)
		{
			if (!used[i])
			{
				dfs(i, v);
				syny[v].insert(i);
			}
			else
			{
				if (bulo.count({i, v}))
					continue;
										
				deg[v] ^= 1;
				ans[v].PB(i);
				bulo.insert({v, i});
			}
		}
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);
	
	cin >> n >> m;
	if (m & 1)
	{
		cout << -1;
		return 0;
	}
	
	FOR(i, 0, m)
	{
		int u, v;
		cin >> u >> v;
		g[u].PB(v);
		g[v].PB(u);
	}
	
	dfs(1, 0);
	
	set<PII> s;
	FOR(i, 1, n + 1)
		s.insert({SZ(syny[i]), i});
	
	while(SZ(s))
	{
		PII bg = *s.begin();
		s.erase(bg);
		assert(bg.X == 1);
		
		int batya = *syny[bg.Y].begin();
		
		s.erase({SZ(syny[batya]), batya});
		syny[batya].erase(bg.Y);
		if (SZ(syny[batya]))
			s.insert({SZ(syny[batya]), batya});
		
		if (deg[bg.Y] == 0)
		{
			deg[batya] ^= 1;
			ans[batya].PB(bg.Y);
		}
		else
		{
			deg[bg.Y] ^= 1;
			ans[bg.Y].PB(batya);
		}
	}
	
	FOR(i, 1, n + 1)
		for(auto j: ans[i])
			cout << i << ' ' << j << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


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

int main()
{
  int N;
  cin >> N;
  vector<int> d(N);
  rep(i, N)
  {
    cin >> d[i];
  }
  long ans = 0;

  for (int i = 0; i < N; i++)
  {
    for (int j = i + 1; j < N; j++)
    {
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef unsigned long long ull;
int main()

{
    ull n,p,k=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>p;
        if(p!=i)    k++;
    }
    if(k<=2){
        cout<<"YES";
    }
    else{
        cout<<"NO";
    }
    return 0;

}


Measured memory_bytes: 256
# Problem B - Judge Status Summary

# input
N = int(input())

# initialization
ac = 0
wa = 0
tle = 0
re = 0

# count
for i in range(N):
    s = input()

    if s=='AC':
        ac += 1
    elif s=='WA':
        wa += 1
    elif s=='TLE':
        tle += 1
    else:
        re += 1

# output
print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))


Measured memory_bytes: 9204
#include <stdio.h>

int main(int argc, char const *argv[])
{
  int n;
  int m;
  if (scanf("%d %d", &n, &m) == -1) {
    printf("Failed to read integer.\n");
  }
  int lr[2][m];
  int i = 0;
  for(i = 0;i < m;i++) {
    if (scanf("%d %d", &lr[0][i], &lr[1][i]) == -1) {
      printf("Failed to read integer.\n");
    }
  }
  int left = 1;
  int right = 1000000;
  for(i = 0;i < m;i++) {
    if (left < lr[0][i]) {
      left = lr[0][i];
    }
    if (right > lr[1][i]) {
      right = lr[1][i];
    }
  }
  int ans = right - left + 1;
  printf("%d\n", ans < 0 ? 0 : ans);
  return 0;
}

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

int main(){
    int A,B,C,K;
    cin >> A >> B >> C >> K;

    vector<int> v;

    v.push_back(A);
    v.push_back(B);
    v.push_back(C);

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

    int max_num = v[0];
    int rest = v[1]+v[2];

    int sum = 0;
    sum += rest;
    for(int i = 0; i < K; i++){
        max_num = max_num * 2;
    }
        sum += max_num;
    cout << sum << endl;

    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    string S;
    cin >> S;
    vector<ll> cnt(4, 0);
    REP(i, S.size()){
    	if(S[i] == 'N') cnt[0]++;
    	if(S[i] == 'S') cnt[1]++;
    	if(S[i] == 'E') cnt[2]++;
    	if(S[i] == 'W') cnt[3]++;
    }
    bool ok = true;
    if(cnt[0]==0 && cnt[1]!=0) ok = false;
    if(cnt[0]!=0 && cnt[1]==0) ok = false;
    if(cnt[2]==0 && cnt[3]!=0) ok = false;
    if(cnt[2]!=0 && cnt[3]==0) ok = false;
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define ll long long int
#define mp make_pair

void solve()
{
  string x,y;
  cin>>x>>y;
  int n=x.length(),m=y.length();
  int dp[n+1][m+1];
  for(int i=0;i<=n;i++)
  {
    for(int j=0;j<=m;j++)
    {
      if(i==0 || j==0)
      dp[i][j]=0;
      else if(x[i-1]!=y[j-1])
      dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
      else
      {
        dp[i][j]=dp[i-1][j-1]+1;
      }
    }
  }
  //dp[n][m] contains the length of the longest common subsequence
  int l=dp[n][m];
  int cnt=0,i=n,j=m;
  string res="";
  while(cnt!=l)
  {
    if(x[i-1]==y[j-1])
    {
      res+=x[i-1];
      cnt++;
      i--;
      j--;
    }
    else
    {
      if(dp[i-1][j]>dp[i][j-1])
      i--;
      else
      j--;
    }
  }
  reverse(res.begin(),res.end());
  cout<<res<<endl;

}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int N=505;
int n,dis[N][N];
bool vis[N][N];
pair<int,int>opt[N*N];
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
struct node
{
    int x,y,v;
    node(int x=0,int y=0,int v=0):x(x),y(y),v(v){}
    bool operator<(const node&o)const{return v>o.v;}
};
queue<pair<int,int>>q;
void update(int i,int j)
{
    int mn=n*n;
    for(int k=0;k<4;k++)
    {
        int x=i+dx[k],y=j+dy[k];
        if(x<1||x>n||y<1||y>n){mn=0;break;}
        mn=min(mn,dis[x][y]+!vis[x][y]);
    }
    mn+=!vis[i][j];
    for(int k=0;k<4;k++)
    {
        int x=i+dx[k],y=j+dy[k];
        if(x<1||x>n||y<1||y>n) continue;
        if(dis[x][y]>mn)
        dis[x][y]=mn,q.push({x,y});
    }
}
void put()
{
    cout<<endl;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
        printf(j==n?"%d\n":"%d ",dis[i][j]);
    cout<<endl;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
        dis[i][j]=min(min(i-1,j-1),min(n-i,n-j));
    for(int i=1;i<=n*n;i++)
    {
        int x;scanf("%d",&x);
        opt[i]={(x-1)/n+1,(x-1)%n+1};
    }
    int ans=0;
    for(int i=1;i<=n*n;i++)
    {
        ans+=dis[opt[i].fi][opt[i].se];
        vis[opt[i].fi][opt[i].se]=true;
        update(opt[i].fi,opt[i].se);
        while(!q.empty())
        {
            int x=q.front().fi,y=q.front().se;q.pop();
            update(x,y);
        }
    }
    printf("%d\n",ans);
}


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

int main() {
	long long n, x, m;
	std::cin >> n >> x >> m;
	
	std::vector<bool> ap(100100, false);
	std::vector<long long> value;
	
	while (not ap[x]) {
		value.push_back(x);
		ap[x] = true;
		x = (x * x) % m;
	}
	
	std::vector<long long> first, loop;
	{
		int sz = (int)(value.size());
		int i = 0;
		for (; value[i] != x; i++) first.push_back(value[i]);
		for (; i < sz; i++) loop.push_back(value[i]);
	}
	
	long long ans = 0;
	long long fir = std::min<long long>(n, first.size());
	for (int i = 0; i < fir; i++) ans += first[i];
	n -= fir;
	
	long long ls = loop.size();
	long long d = n / ls, k = n % ls;
	for (int i = 0; i < ls; i++) {
		long long s = loop[i] * d;
		if (i < k) s += loop[i];
		ans += s;
	}
	
	std::cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 4312
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
  int N; string S;
  cin >> N >> S;
  int black=0,white=0;
  for(int i=0;i<N;i++){
    if(S[i]=='#');
    else white++;
  }
  int ans=INF;
  int b2=0,w2=0;
  for(int i=0;i<=N;i++){
    if(i==0);
    else if(i>=1){
      if(S[i-1]=='#') b2++;
      else white--;
    }
    chmin(ans,b2+white);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int w,h,n;cin>>w>>h>>n;
    int s=0;
    int t=0;
    rep(i,n){
        int x,y,a;cin>>x>>y>>a;
        if(a==2)w=min(w,x);
        if(a==1)s=max(s,x);
        if(a==4)h=min(h,y);
        if(a==3)t=max(t,y);
    }
    int ans = max((w-s)*(h-t),0);
    if((w-s)<=0 ||(h-t)<=0)ans=0;
    cout<<ans<<endl;
	return 0;
}

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

/*
  REMEMBER:
  1.Think TWICE, code ONCE!
  Are there any counterexamples to your algo?
	
  2.Be careful about the BOUNDARIES in your algo!
  N=1? P=1? Is P a prime? Something about 0?
	
  3.Never make STUPID MISTAKES!
  Integer overflow? Array size? Time complexity? Memory usage? Precition error?
*/

int main(){
	deque < int > q; int N; cin >> N;
	for(int i = 1 ; i <= 3 * N ; ++i){int x; cin >> x; q.push_back(x);}
	sort(q.begin() , q.end()); long long sum = 0;
	for(int i = 1 ; i <= N ; ++i){q.pop_front(); q.pop_back(); sum += q.back(); q.pop_back();}
	cout << sum;
	return 0;
}


Measured memory_bytes: 1536
import math
import sys

m=10**9 + 7 
sys.setrecursionlimit(1000010)
N = int(input())
A  = list(map(int,input().split()))
B  = list(map(int,input().split()))

ans = 0 
s  = min(A[0],B[0])
ans = s
A[0] = A[0] -s 
B[0] = B[0] -s 
for i in range(1,N):
    sa = min(A[i],B[i-1])
    ans = ans + sa
    A[i] = A[i] - sa
    B[i-1] = B[i-1] - sa

    sa = min(A[i],B[i])
    ans = ans + sa
    A[i] = A[i] - sa
    B[i] = B[i] - sa

sa = min(A[N],B[N-1])
ans = ans + sa
A[N] = A[N] - sa
B[N-1] = B[N-1] - sa
print(ans)



Measured memory_bytes: 82148
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

int main(){
  int N; cin >> N; ll a[N];
  rep(i, N){
    cin >> a[i];
  }
  ll dp[N+1][2] = {};
  dp[2][0] = a[0], dp[2][1] = a[1];
  dp[3][0] = max({a[0], a[1], a[2]});
  dp[3][1] = dp[3][0];
  for(int i=4; i<=N; i++){
    if(i%2==0){
      dp[i][1] = max({dp[i-2][0], dp[i-2][1]}) + a[i-1];
      dp[i][0] = dp[i-2][0] + a[i-2];
    }
    else{
      dp[i][1] = max({dp[i-1][1], dp[i-1][0], dp[i-2][0]+a[i-1]});
      dp[i][0] = dp[i][1];
    }
  }
  cout << max(dp[N][0], dp[N][1]) << endl;
}

Measured memory_bytes: 8264
/*
    B - Echo
    https://atcoder.jp/contests/abc145/tasks/abc145_b
*/
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    string s;

    cin >> n;
    cin >> s;

    if (n % 2 == 1) {
        cout << "No" << endl;
    } else {
        int mid = n / 2;
        string right = s.substr(0, mid);
        string left = s.substr(mid);
        if (right == left) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]

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

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False

    def subsetall(self):
        a = []
        for i in range(len(self.table)):
            if self.table[i] < 0:
                a.append((i, -self.table[i]))
        return a

N,W = map(int,input().split())
Graph = UnionFind(N)
P = [int(i) for i in input().split()]
for i in range(W):
    a ,b = map(int,input().split())
    Graph.union(a-1,b-1)
ans = 0 
for i in range(N):
    if Graph.find(P[i]-1) == Graph.find(i):
        ans += 1
print(ans)

Measured memory_bytes: 15148
import sys
from collections import Counter

input = sys.stdin.readline


def main():
    N = int(input())
    s = [""] * N
    for i in range(N):
        s[i] = input().rstrip()
    M = int(input())
    t = [""] * M
    for i in range(M):
        t[i] = input().rstrip()

    c_s = Counter(s)
    c_t = Counter(t)
    t_keys = c_t.keys()
    t_items = dict(c_t.items())
    ans = 0
    for k, v in c_s.items():
        money = v
        if k in t_keys:
            money -= t_items[k]
        if money > ans:
            ans = money

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include<stdio.h>

int main(void){

    long int x,ans=0;

    scanf("%ld",&x);

    ans = (x / 11)*2;

    if(x % 11 == 0){
        ans = ans;
    }else if(x % 11 <= 6){
        ans += 1;
    }else if(x % 11 > 6){
        ans += 2;
    }

    printf("%ld",ans);
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

class Main{
	public static void main(String[]args){
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		double d, r, f;{
			d = a / b;
			r = a % b;
			f = (double) a / b;
		}

		System.out.println(String.format("%.0f", d) + " " + String.format("%.0f", r) + " " + String.format("%.5f", f));
	}
}


Measured memory_bytes: 26536
# AOJ 0026 Dropping Ink

class Paper
  WIDTH = 10
  HEIGHT = 10

  module DropSize
    SMALL = 1
    MEDIUM = 2
    LARGE = 3
  end

  def initialize
    @density = Array.new(HEIGHT) {Array.new(WIDTH, 0)}
  end

  def drop_ink(xc, yc, size)
    cells = []

    case size
    when DropSize::SMALL
      cells << [xc - 1, yc]
      cells << [xc, yc - 1]
      cells << [xc, yc]
      cells << [xc, yc + 1]
      cells << [xc + 1, yc]
    when DropSize::MEDIUM
      ((xc - 1)..(xc + 1)).each do |x|
        ((yc - 1)..(yc + 1)).each do |y|
          cells << [x, y]
        end
      end
    when DropSize::LARGE
      ((xc - 1)..(xc + 1)).each do |x|
        ((yc - 1)..(yc + 1)).each do |y|
          cells << [x, y]
        end
      end
      cells << [xc - 2, yc]
      cells << [xc, yc - 2]
      cells << [xc, yc + 2]
      cells << [xc + 2, yc]
    end

    cells.each {|x, y| inc_density(x, y)}
  end

  def n_white_cells
    @density.map {|row| row.select {|d| d.zero?}.length}.reduce(0, :+)
  end

  def max_density
    @density.map {|row| row.max}.max
  end

  private
  def inc_density(x, y)
    if x >= 0 && x < WIDTH && y >= 0 && y < HEIGHT
      @density[y][x] += 1
    end
  end
end

paper = Paper.new
while line = gets
  xc, yc, size = line.split(",").map {|v| v.to_i}
  paper.drop_ink(xc, yc, size)
end

puts paper.n_white_cells
puts paper.max_density

Measured memory_bytes: 6124
#include <iostream>
#include <sstream>
#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>
using namespace std;

int main()
{
    for(;;){
        vector<int> card(5);
        if(!(cin >> card[0]))
            return 0;

        for(int i=1; i<5; ++i){
            char c;
            cin >> c >> card[i];
        }
        sort(card.begin(), card.end());

        vector<int> num(5, 0);
        for(int i=0; i<5; ++i){
            int j = i+1;
            while(j < 5 && card[j] == card[i])
                ++ j;
            ++ num[j-i];
            i = j-1;
        }

        if(num[4] == 1)
            cout << "four card" << endl;
        else if(num[3] == 1 && num[2] == 1)
            cout << "full house" << endl;
        else if(num[3] == 1)
            cout << "three card" << endl;
        else if(num[2] == 2)
            cout << "two pair" << endl;
        else if(num[2] == 1)
            cout << "one pair" << endl;
        else if(card[0] == 1 && card[1] + 3 == card[4])
            cout << "straight" << endl;
        else if(card[0] + 4 == card[4])
            cout << "straight" << endl;
        else
            cout << "null" << endl;
    }
}

Measured memory_bytes: 0
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  s=chomp(readline())
  println(minimum([abs(753-pI(s[i-2:i])) for i=3:length(s)]))
end
main()
if isdefined(Base, :mystdin);close(mystdin);end


Measured memory_bytes: 167780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
int n ;
cin>>n;
vector<int> d1(n),d2(n);
for(int i = 0;i<n;i++) cin>>d1[i]>>d2[i];
for(int i =0;i<n;i++)
{
	if(i<n-2 && d1[i]==d2[i] && d1[i+1]==d2[i+1] && d1[i+2]==d2[i+2] )
               {
               	cout<<"Yes\n";
               	return 0;
			   }

}
cout<<"No\n";
return 0;
}

Measured memory_bytes: 3628
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

struct RRange {
	int l, r;
	long long int num;
	RRange(const int a, const int b, const long long int c) {
		l = a, r = b, num = c;
		return;
	}
	bool operator<(const RRange& rr)const {
		return r < rr.r;
	}
};

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

	cin >> N >> K;
	set<RRange>sr;
	sr.insert(RRange(1, N, 0));
	for (int i = 0; i < K; i++) {
		cin >> L >> R;
		auto bag = sr.lower_bound(RRange(1, L, 0));
		if (bag->r != L) {
			int l = bag->l;
			int r = bag->r;
			long long int num = bag->num;
			sr.erase(bag);
			sr.insert(RRange(l, L, num));
			sr.insert(RRange(L + 1, r, num));
		}
		while (R) {
			auto box = sr.lower_bound(RRange(1, L, 0));
			if (box == sr.begin()) {
				int l = box->l;
				int r = box->r;
				long long int num = box->num;
				sr.erase(box);
				if (R%r) {
					sr.insert(RRange(l, l + (R%r) - 1, num + R / r + 1));
					sr.insert(RRange(l + (R%r), r, num + R / r));
				}
				else {
					num += R / r;
					sr.insert(RRange(l, r, num));
				}
				R = 0;
			}
			else {
				//cout << "Hi";
				auto bag = prev(box);
				int l = box->l;
				int r = box->r;
				long long int num = box->num;
				sr.erase(box);
				long long int dif = (bag->num) - num;
				dif *= r - l + 1;
				//cout <<"dif "<< dif << endl;
				if (dif-(r-l+1) >= R) {
					if (R%(r-l+1)) {
						sr.insert(RRange(l, l + (R%(r-l+1)) - 1, num + R / (r-l+1) + 1));
						sr.insert(RRange(l + (R%(r-l+1)), r, num + R / (r-l+1)));
					}
					else {
						num += R / (r-l+1);
						sr.insert(RRange(l, r, num));
					}
					R = 0;
				}
				else if (dif <= R) {
					int ll = bag->l;
					long long int nnum = bag->num;
					sr.erase(bag);
					sr.insert(RRange(ll, r, nnum));
					R -= dif;
				}
				else {
					int m = R % (r - l + 1);
					int ll = bag->l;
					int rr = bag->r;
					long long int nnum = bag->num;
					sr.erase(bag);
					sr.insert(RRange(ll, rr + m, nnum));
					sr.insert(RRange(rr + m + 1, r, nnum - 1));
					R = 0;
				}
			}
			//cout << "R " << R << endl;

		}
	}
	for (auto i : sr) {
		for (int j = i.l; j <= i.r; j++) {
			cout << i.num << endl;
		}
		//cout << i.l << " " << i.r << " " << i.num << endl;
	}
}


Measured memory_bytes: 7680
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	var n int
	n = nextInt()

	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	ans := -10000000000
	// O(n^2)
	// for buy := 0; buy < n-1; buy++ {
	// 	for sell := buy + 1; sell < n; sell++ {
	// 		tmp := r[sell] - r[buy]
	// 		if ans < tmp {
	// 			ans = tmp
	// 		}
	// 	}
	// }

	// O(n)
	minv := r[0]
	for j := 1; j < n; j++ {
		ans = Max(ans, r[j]-minv)
		minv = Min(minv, r[j])
	}

	fmt.Println(ans)
	return
}

func Max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func Min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}



Measured memory_bytes: 5412
using System;
using System.Collections.Generic;
using System.Linq;

class E
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var a = read();

		var s = a.Sum();
		foreach (int d in Divisors(s).Reverse())
		{
			var m = a.Select(x => x % d).OrderBy(x => -x).ToArray();
			if (m.Skip(m.Sum() / d).Sum() <= h[1]) { Console.WriteLine(d); return; }
		}
	}

	static long[] Divisors(long n)
	{
		var r = new List<long>();
		for (long x = 1; x * x <= n; ++x) if (n % x == 0) r.Add(x);
		var i = r.Count - 1;
		if (r[i] * r[i] == n) --i;
		for (; i >= 0; --i) r.Add(n / r[i]);
		return r.ToArray();
	}
}


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

vector<int> adj[100005], dp(100005, -1);
int n, m, u, v, visited[100005];

void dfs(int node) {
	visited[node] = 1;
	for (int i = 0; i < adj[node].size(); i++) {
		if (!visited[adj[node][i]])
			dfs(adj[node][i]);
		dp[node] = max(dp[node], dp[adj[node][i]] + 1);
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	
	for (int i = 0; i < m; i++) {
		cin >> u >> v;
		u--; v--;
		adj[u].push_back(v);
	}
	for (int i = 0; i < n; i++) {
		if (!visited[i])
			dfs(i);
	}
	int ans = 0;	
	for (int e : dp) {
		ans = max(ans, e);
	}
	cout << ans + 1;
}

Measured memory_bytes: 8576
using System;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string ans = "";

        while (n != 0)
        {
            if (n % 2 != 0)
            {
                n--;
                ans = "1" + ans;
            }
            else
                ans = "0" + ans;

            n /= -2;
        }

        if (ans == "") ans = "0";
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
line = list(map(str,input().split()))
 
#数字スタック
S = []
 
for tmp_ch in line:
 
    if tmp_ch in ['+','-','*']:
        b = int(S.pop())
        a = int(S.pop())
 
        if tmp_ch == '+':
            S.append(a+b)
        elif tmp_ch == '-':
            S.append(a-b)
        else:
            S.append(a*b)
    else:
        S.append(tmp_ch)
 
print("%d"%(S[0]))


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

using namespace std;

int main(){
        int res=0;
        int N;
        cin>>N;
        for(int i=0;i<N;i++){
                int l, r;
                cin>>l>>r;
                res+=abs(r-l)+1;
        }
        cout<<res<<endl;
        return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)

ll moddiv(ll a,ll b){
    a %= MOD;
    b %= MOD;
    for(ll m=MOD-2;m>0;m/=2){
        if(m&1){
            a=a*b%MOD;
        }
        b=b*b%MOD;
    }
    return a;
}

ll H,W,A,B;

ll Fa[202020];
ll mk[101010];
ll i, j, k, ans;

int main(){
    scanf("%lld%lld%lld%lld",&H,&W,&A,&B);
    Fa[0] = 1;
    fornum(i,0,H+W){
        Fa[i + 1] = Fa[i] * (i + 1) % MOD;
    }
    fornum(i,0,H-A){
        mk[i] = moddiv(Fa[i + B - 1], Fa[i] * Fa[B - 1]) % MOD;
        //printf("%lld:%lld ", i, mk[i]);
    }
    fornum(i,0,H){
        ans = (ans + mk[H - i - 1] * moddiv(Fa[i + W - B - 1], Fa[i] * Fa[W - B - 1])) % MOD;
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		long n=stdIn.nextLong(),s=1,i;
		for(i=2;i<=n;i++) {
			s*=i;
			s%=1000000007;
		}
		System.out.print(s);
	}
}

Measured memory_bytes: 23764
#include <stdio.h>

int main(void){
  int N, D;
  scanf("%d %d", &N, &D);
  if(N % (2 * D + 1) != 0) printf("%d\n", N / (2 * D + 1) + 1);
  else printf("%d\n", N / (2 * D + 1));
  return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] NM = Console.ReadLine().Split(' ');
            int N = int.Parse(NM[0]);
            int M = int.Parse(NM[1]);

            string[] h = Console.ReadLine().Split(' ');
            int[] H = new int[N];

            for(int i = 0; i < h.Length; i++)
            {
                H[i] = int.Parse(h[i]);
            }

            bool[] isBad = new bool[N];

            for(int i = 0; i < M; i++)
            {
                string[] A = Console.ReadLine().Split(' ');
                int a = int.Parse(A[0]);
                int b = int.Parse(A[1]);

                if (H[a - 1] > H[b - 1])
                {
                    isBad[b - 1] = true;
                }
                else if(H[a - 1] < H[b - 1])
                {
                    isBad[a - 1] = true;
                }
                else
                {
                    isBad[a - 1] = true;
                    isBad[b - 1] = true;
                }
            }

            Console.WriteLine(isBad.Count(value => value == false));
        }
    }
}


Measured memory_bytes: 49060
import sys

a,b,m = map(int, input().split())

ref = list(map(int, input().split()))

mic = list(map(int, input().split()))

cheapest = 2000001

for i in range(m):
  cou = list(map(int, input().split()))
  tmp = ref[cou[0] - 1] + mic[cou[1] - 1] - cou[2]
  if(cheapest > tmp):
    cheapest = tmp

refMin = min(ref)
micMin = min(mic)
if(cheapest > refMin + micMin):
  cheapest = refMin + micMin

print(cheapest)

Measured memory_bytes: 18612
x, k, d = map(int, input().split())
ans = 0
if abs(x) <= k * d:
  if (abs(x) // d) % 2 == k % 2:
    ans = abs(x) % d
  else:
    ans = d - abs(x) % d
else:
  ans = abs(x) - k * d
print(ans)

Measured memory_bytes: 61888
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

int main() {
    string s; cin >> s;
    ll k; cin >> k;
    dump(k);

    for(int i=0; i<s.size(); i++){
        if(s.at(i)!='1'){
            dump(s.at(i));
            cout << s.at(i) << endl;
            return 0;
        }
        else if(i+1>=k){
            cout << s.at(i) << endl;
            return 0;
        }
    }
}

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

#define MAX(X,Y) ((X)>(Y)?(X):(Y))

int main(void){
  int n, t, ans;
  double angMax = 0;

  cin >> n >> t;
  for (int i=0; i<n; i++){
    int x,h;
    cin >> x >> h;
    angMax = MAX(angMax, 1.*h/x);
  }
  cout << fixed << angMax*t << endl;
  return 0;
}


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

using namespace std;


void solve() {
    int n,m;
    cin >> n >> m;
    priority_queue<int> pq;
    for (int _ = 0; _ < n; _++) {
        int x; cin >> x;
        pq.push(x);
    }
    while (m--) {
        int x = pq.top(); pq.pop();
        x/=2; pq.push(x);
    }
    long long sum = 0;
    while (!pq.empty()) {
        sum += pq.top();
        pq.pop();
    }
    cout << sum;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 892
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {

	int A, B;
	scanf("%d%d", &A, &B);

	int ans = 0;
	for (int i = A; i <= B; i++) {
		int n1 = i % 10;
		int n2 = (i % 100) / 10;
		int n3 = (i % 1000) / 100;
		int n4 = (i % 10000) / 1000;
		int n5 = i / 10000;
		if (n1 == n5 && n2 == n4) {
			//printf("%d%d%d%d%d\n", n1, n2, n3, n4, n5);
			ans++;
		}

	}


	printf("%d", ans);




}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long L;
using namespace std;
 
#define N 100005
#define U [N]={}
map<L,L> path[N];
L par U,dep U,siz U,hev U,cst U,add U,pos U,hl_par U,bit U,
k,n,q,a,b,c,cnt;
void dfs(L a){
    siz[a]=1;
    for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();I++){
        L d=I->first;
        if(d==par[a]) continue;
        par[d]=a;
        dep[d]=dep[a]+1;
        cst[d]=I->second;
        dfs(d);
        siz[a]+=siz[d];
        if(!hev[a] || siz[hev[a]]<siz[d])
            hev[a]=d;
    }
}
   
L edgecost(L a){
    L ret=add[a]+add[par[a]]+cst[a];
    return ret%k ? ret : 0;
}
   
L sum(L i){
    L ret=0;
    while(i){
        ret+=bit[i];
        i-=i&-i;
    }
    return ret;
}
void S(L i, L x){
    x-=sum(i+1)-sum(i);
    i++;
    while(i<N){
        bit[i]+=x;
        i+=i&-i;
    }
}
   
L cost(L a, L b){
    L p=hl_par[a], q=hl_par[b];
    if(p==q) return abs(sum(pos[a])-sum(pos[b]));
    if(dep[p]<dep[q]){
        swap(p, q);
        swap(a, b);
    }
    return sum(pos[a]) - sum(pos[p])
        + edgecost(p) + cost(par[p], b);
}
 
main(){
    cin >> n >> k;
    for(L i=0; i<n-1; i++){
        cin >> a >> b >> c;
        path[a][b]=c;
        path[b][a]=c;
    }
    dfs(0);
   
    for(L i=0; i<n; i++){
        if(i && hev[par[i]]==i) continue;
        L j=i;
        do{
            pos[j]=cnt++;
            hl_par[j]=i;
        }while(j=hev[j]);
    }
    
    for(L i=0; i<n; i++)
        S(pos[i], edgecost(hev[i]));
    
    cin >> q;
    for(L i=0; i<q; i++){
        string s;
        cin>>s>>a>>b;
        if(s[0]=='a'){
            add[a]+=b;
            S(pos[a], edgecost(hev[a]));
            if(a) S(pos[a]-1, edgecost(a));
        }else{
            cout << cost(a, b) << endl;
        }
    }
}

Measured memory_bytes: 31944
#include <stdio.h>
#include <string.h>

int main (void){
     
     int n;
     int buf[128];
     int min;
     int max;
     
     scanf("%d", &n);

     for(int i = 0; i < n; i++){
        
        scanf("%d", buf+i);

     }

     min = buf[0];
     max = buf[0];

     for(int i = 1; i < n; i++){

        if(min > buf[i])
          min = buf[i];

        if(max < buf[i])
          max = buf[i];

     }


     printf("%d", max-min);

     return 0;    
}


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

int main() {
    int n, m, temp, count = 0, wrong = 0;
    cin >> n >> m;
    vector<int> question(n, 0);
    vector<bool> flag(n, false);
    rep(i, m) {
        cin >> temp;
        string str;
        cin >> str;
        if(str == "WA" && !flag.at(temp - 1)) question.at(temp - 1) += 1;
        if(str == "AC" && !flag.at(temp - 1)) {
            count++;
            wrong += question.at(temp - 1);
            flag.at(temp - 1) = true;
        }
    }
    cout << count << " " << wrong << endl;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

    ll A, B;
    cin >> A >> B;

    if (B == 1) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    B -= A;
    while (B > 0) {
        ans++;
        B -= (A-1);
    }

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();

        int result = 0;
        for (int i = 1; i < n + 1; i++) {
            if (i <= k) {
                result += x;
                continue;
            }
            result += y;
        }
        System.out.println(result);
    }

}


Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int N;
vector<int> G[202020];

double per[202020];

void dfs1(int v,int f = -1){
  int cnt = 0;
  for(int to : G[v]){
    if(to == f) continue;
    dfs1(to,v);
    cnt++;
    per[v] += per[to];
  }
  if(cnt != 0){
    per[v] /= cnt;
    per[v]++;
  }
}

double ans[202020];

void dfs2(int v,int f = -1,double f_per = 0){
  int cnt = G[v].size();
  double sum = 0;
  for(int to : G[v]){
    if(to == f){
      sum += f_per;
    }
    else{
      sum += per[to];
    }
  }
  ans[v] = sum / cnt + 1;

  for(int to : G[v]){
    if(to == f) continue;
    double t = sum - per[to];
    if(cnt > 1) t = t / (cnt - 1) + 1;
    dfs2(to,v,t);
  }
}

int main(){
  cin >> N;
  for(int i = 0;i < N - 1;i++){
    int u,v;
    cin >> u >> v;
    u--;
    v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs1(0);
  dfs2(0);
  cout << fixed << setprecision(10);
  for(int i = 0;i < N;i++){
    cout << ans[i] <<endl;
  }
}


Measured memory_bytes: 20224
while True:
    n,p = map(int, input().split())
    if n==0: break

    holding = [0]*n
    ctr = 0
    wan = p
    for _ in range(1000000):
        if wan>=n:
            dist = wan//n
            wan -= dist*n
            for i in range(n):
                holding[i] += dist

        if wan != 0:
            holding[ctr] += 1
            wan -= 1
            if wan == 0 and holding[ctr] == p:
                print(ctr)
                break
        else:
            wan = holding[ctr]
            holding[ctr] = 0
        ctr += 1
        if ctr >= n: ctr -= n

Measured memory_bytes: 7560
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcd(long long a,long long b){return a*b / gcd(a,b) / gcd(a,b);}
int main()
{
	string s;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5])
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}

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

int main(){
    int N;
    cin>>N;
    int n=N;
    int sum=0;

    while(n){
        sum+=n%10;
        n=n/10;
    }

    if(N%sum==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

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

int main() {
	long n;
	cin >> n;
	string num = to_string(n);
	int harshad = 0;
	for (auto elem : num) {
		harshad += elem - '0';
	}

	if (n % harshad == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long a[200001];
int main()
{
	int n;
	long long x=0,j=0,i,s;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%lld",&a[i]);
	for(i=0;i<n;i++)
	{
		while((x^a[j])==x+a[j]&&j<n)
		{
            x+=a[j];
            j++;
        }
        s+=j-i;
        x=x^a[i];
	}
	printf("%lld",s);
	return 0;
}

Measured memory_bytes: 1792
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数
static FILE *szpFpI;											// 入力

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 長さ - 取得
	double ldLen;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%lf", &ldLen);
	ldLen /= 3.0;

	// 体積
	double ldSum = 1.0;
	for (i = 0; i < 3; i++) {
		ldSum *= ldLen;
	}

	// 出力
	sprintf(lc1Buf, "%.7lf\n", ldSum);
	fOutLine(lc1Buf);

	return 0;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 128
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr)
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as BS
import Data.Monoid
import qualified Data.IntMap.Strict as IntMap

main = do
  n <- readLn
  xs <- U.replicateM n $ do
    Just (x, _) <- BS.readInt <$> BS.getLine
    return x
  let s = U.foldl (\ !s !y ->
                     case IntMap.lookupLT y s of
                       Nothing -> IntMap.insertWith (+) y 1 s
                       Just (x,k) -> if k == 1 then IntMap.insertWith (+) y 1 $ IntMap.delete x s else IntMap.insertWith (+) y 1 $ IntMap.insert x (k-1) s
                  ) IntMap.empty xs
  print $ getSum $ IntMap.foldMapWithKey (\_ -> Sum) s


Measured memory_bytes: 8444
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
    int i,j;
    int n,m;
    cin >> n >> m;
    vi a(n);
    vi p(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> p[i];
    int ans = INF;
    rep(f,2){
        vi b(n);
        int x = f;
        int k = 0;
        int left = p[k];
        rep(i,n){
            b[i] = x;
            left--;
            if(left == 0){
                k++;
                left = p[k];
                x = 1-x;
            }
        }
        int tmp = 0;
        rep(i,n)if(a[i] != b[i]){
            j=i;
            while(a[i] != b[j] && j < n)j++;
            if(j == n){
                tmp = INF;
                break;
            }
            tmp += j-i;
            b[j] = b[i];
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}



Measured memory_bytes: 3140