akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define _int64 long long
 
_int64 a[60];
 
int main()
{
  _int64 i,j,n,tmp,ans,b1;
  scanf("%lld",&n);
  for (i=0;i<n;i++)
    scanf("%lld",&a[i]);
  ans=0;
  b1=1;
  while (b1==1)
  {
    b1=0;
    for (i=0;i<n;i++)
      if (a[i]>=n)
      {
        b1=1;
        tmp=a[i]/n;
        a[i]%=n;
        ans+=tmp;
        for (j=0;j<n;j++)
          if (i!=j) a[j]+=tmp;
      }
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;
int main(){
	int i,n,a,b,x;
	cin >> x >> a >> b >> n;
	int now = x;
	for(i=0;i<n;i++){
		string s; cin >> s;
		if(s[0]=='n'){
			now += a;
			if(now<0) now = 0;
		}
		if(s[0]=='t'){
			now += b;
			if(now<0) now = 0;
		}
		if(s[0]=='k'){
			now = 0;
		}
	}
	cout << now << endl;
}


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

string a,b,c;

int main(){
	cin>>a>>b>>c;
	if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main(){
    ll n;
    cin>>n;
    V vec(n);
    rep(i,n)cin>>vec[i];
    sort(all(vec),greater<ll>());
    priority_queue<ll> q;
    q.push(vec[0]);
    ll res=0;
    rep3(i,1,n){
        ll k=q.top();
        q.pop();
        res+=k;
        q.push(vec[i]);
        q.push(vec[i]);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 6928
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int (i)=(a);(i)<(int)(b);(i)++)
#define RREP(i,a,b) for(int (i)=(a);(i)>=(int)(b);(i)--)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;



int main(){
    int n, T;
    cin >> n >> T;
    vector<int> t(n);
    REP(i,0,n){
        cin >> t[i];
    }

    int sum = T;
    REP(i,0,n - 1){
        sum += min(t[i + 1] - t[i], T);
    }

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

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef double db;

#define mp make_pair
#define pb push_back
#define pt(i) printf("%lld\n",(ll)i)
#define mp make_pair
#define ff first
#define ss second
#define pi acos(-1.0)
ll md=1000000007;

ll in() { ll a;scanf("%lld",&a); return a;}
db din(){ db a;scanf("%lf",&a); return a; }
ll bigmod(ll b, ll p,ll md){if(p==0) return 1;if(p%2==1){ return ((b%md)*bigmod(b,p-1,md))%md;} else {ll y=bigmod(b,p/2,md);return (y*y)%md;}}
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b);}

long long getRandom(long long a,long long b){
    long long ret = (long long)rand()*(long long)rand();
    ret %= (b - a + 1);
    ret += a;
    return ret;
}

char s[1005][1005];

ll dp[1005][1005];

int main()
{
	//freopen("in.c","r",stdin);
	//freopen("out.c","w",stdout);
	int n=in(),m=in();
	for(int i=0;i<n;i++)
		scanf("%s",s[i]);
	dp[n-1][m-1]=1;
	for(int i=n-1;i>=0;i--)
	{
		for(int j=m-1;j>=0;j--)
		{
			if(s[i][j]=='#')
				continue;
			if(s[i][j+1]=='.')
				dp[i][j]=(dp[i][j]+dp[i][j+1])%md;
			if(s[i+1][j]=='.')
				dp[i][j]=(dp[i][j]+dp[i+1][j])%md;
		}
	}
	pt(dp[0][0]);
}



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

int main(){
  string s;
  cin>>s;
  
  int tmp;
  tmp=(s.at(0)=='o')+(s.at(1)=='o')+(s.at(2)=='o');
  
  cout<<700+100*tmp<<endl;
  
    
  
}

  













Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin >> a;
    for(int i = 1;i < 6;i++) if(a == pow(10, i)){// pow(a, b) はaのb乗を返します
        cout << 10;
        return 0;
    }
    cout << a / 100000 + a / 10000 % 10 + a / 1000 % 10 + a / 100 % 10  + a / 10 % 10 + a % 10;// 各桁の和を出力
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    map<int,int> mp;
    rep(i,0,N){
        int x;
        cin >> x;
        mp[x]++;
    }
    ll ans = 0;
    for(auto p:mp){
        if(p.first <= p.second)ans += p.second - p.first;
        else                   ans += p.second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4736
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    int x;
    cin >> x;
    int h = x / 3600;
    int m = (x % 3600) / 60;
    int s = (x % 3600) % 60;
    printf("%d:%d:%d\n", h, m, s);
    return 0;
}



Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
int MOD[4000100];
int main()
{
	int K;
	cin>>K;
	MOD[0]=7%K;
	for(int i=1;i<4000100;i++)
		MOD[i]=MOD[i-1]*10%K;
	int Sum=0;
	for(int i=0;i<4000100;i++)
	{
		Sum+=MOD[i];
		Sum%=K;
		if(!Sum)
		{
			cout<<i+1<<endl;
			return 0;
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 19184
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll n,m,res=0,ten[19],b[19];
vl a;

ll f(ll id,ll S,ll L,ll R){
	if(id==m) return S==n;
	L+=a[id]*9;
	R-=a[id]*9;
	ll tmp=0;
	for(int i=-9;i<=9;i++){
		ll S_=S+a[id]*i;
		if(S_+L<=n&&n<=S_+R) tmp+=(b[i+9]+(!id&&i>=0?-1:0))*f(id+1,S_,L,R);
	}
	return tmp;
}

int main(){
	cin>>n;
	ten[0]=1;
	for(int i=1;i<19;i++) ten[i]=ten[i-1]*10;
	for(int i=0;i<10;i++) for(int j=0;j<10;j++) b[i-j+9]++;
	for(int i=1;i<=18;i++){
		a=vl(i/2);
		ll L=0,R=0;
		for(int j=0;j<i/2;j++){
			a[j]=ten[i-j-1]-ten[j];
			L-=a[j]*9;
			R+=a[j]*9;
		}
		m=a.size();
		ll t=f(0,0,L,R);
		if(i%2==1) t*=10;
		res+=t;
	}
	cout<<res<<endl;
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*
*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

template<class T>
struct BIT
{
  int n;
  vector<T> data;

  BIT(int n) : n(n) {
    data.resize(n+1, 0);
  }

  T sum(int i) {
    i++; // to convert 0-indexed
    T res = 0;
    for(; i > 0; i -= i&-i){
      res += data[i];
    }
    return res;
  }

  void add(int i, T v){
    i++; // to convert 0-indexed
    for(; i <= n; i += i&-i){
      data[i] += v;
    }
  }

  T query(int l, int r)
  {
    return sum(r-1)-sum(l-1);
  }

  T lower_bound(int v){
    if(v <= 0) return 0;
    int x = 0, i = 1;
    while(i<<1 <= n) i <<= 1;
    for(; i > 0; i >>= 1){
      if(x+i <= n and data[x+i] < v){
        v -= data[x+i];
        x += i;
      }
    }
    return x;
  }
};

signed main() {
  int n, d, a;
  cin >> n >> d >> a;

  vi x(n), h(n);
  rep(i, 0, n) cin >> x[i] >> h[i];

  vector<P> v;
  rep(i, 0, n) v.emplace_back(x[i], h[i]);
  sort(all(v));
  rep(i, 0, n){
    x[i] = v[i].first;
    h[i] = v[i].second;
  }

  vi X;
  rep(i, 0, n) X.emplace_back(x[i]);
  X.emplace_back(1LL<<60);
  X.emplace_back(0);

  sort(all(X));
  X.erase(unique(all(X)), X.end());

  int L = sz(X);
  BIT<int> bit(L+10);

  int ans = 0;
  rep(i, 0, n){
    int l = lower_bound(all(X), x[i]-d-d) - X.begin();
    int t = lower_bound(all(X), x[i]) - X.begin();
    int s = a*bit.query(l, t+1);
    if(h[i] > s){
      int u = (h[i]-s+a-1)/a;
      bit.add(t, u);
      ans += u;
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;
#define ll long long int


int main()
{
    ll n;
    cin >> n;
    ll s = 0;
    for(ll i=1;i<=n;i++){
        if(i%3==0 && i%5==0){
            continue;
        }
        else if(i%3==0) continue;
        else if(i%5==0) continue;
        else s+=i;
    }
    cout << s << endl;
}


Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[4][13];
int main(void) {
	int n;
	cin >> n;
	char c;
	int k;
	for (int i = 0; i < n; i++)
	{
		cin >> c >> k;
		if (c == 'S') {
			a[0][k-1] = 1;
		}
		else if (c == 'H') {
			a[1][k-1] = 1;
		}
		else if (c == 'C') {
			a[2][k-1] = 1;
		}
		else {
			a[3][k-1] = 1;
		}
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			if (a[i][j] == 0) {
				if (i == 0) {
					cout << "S" << " " << j + 1;
				}
				else if (i == 1) {
					cout << "H " << j + 1;
				}
				else if (i == 2) {
					cout << "C " << j + 1;
				}
				else {
					cout << "D " << j + 1;
				}
				cout << endl;
			}
		}
	}
}


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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(d==1)cout<<1<<endl;
  else cout<< 0<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args)
    {
      Scanner sc=new Scanner(System.in);
     
      	String s=sc.next();
      	String t=sc.next();
      	int a=0;
      	for(int i=0;i<s.length();i++)
        {
          if(s.charAt(i)!=t.charAt(i))
            a++;
        }
      System.out.println(a);
    }
}

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

int main() {
    int N, r=0, b=0; scanf("%d",&N);
    while(N--) {
        char c; scanf(" %c",&c);
        if(c == 'R') ++r;
        if(c == 'B') ++b;
    }
    if(r>b) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int gcd(int A,int B){
  if(B==0) return A;
  return gcd(B,A%B);
}

int main(){
  int X;
  cin>>X;
  cout<<360/gcd(360,X)<<endl;
}


Measured memory_bytes: 3620
n = int(input())

a = list(map(int,input().split()))
a.sort()
d = {}
for i in range(n):
    if(a[i] not in d):d[a[i]] = 1
    else:d[a[i]] += 1
if(len(d) == 1):
    if(a[0] == 0):
        print('Yes')
        exit()
elif(n%3 == 0):
    if(len(d) == 2):
        if(0 in d):
            if(d[0] == n // 3):
                print('Yes')
                exit()
    elif(len(d) == 3):
        k = list(d.keys())
        if(k[0]^k[1]^k[2] == 0):
            if(d[k[0]] == n // 3 and d[k[1]] == n // 3 and d[k[2]] == n // 3):
                print('Yes')
                exit()
print('No')

Measured memory_bytes: 14116
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M=1000000007;
const ll MM=998244353;
ll begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}



const ll N=2e5+5;


int main()
{ 

IOS;

ll n;cin>>n;
ll d;cin>>d;
ll c=0;
FOR(i,n){
  ll a,b;cin>>a>>b;
  ll t=a*a+b*b;
  if(t<=d*d)c++;
}
cout<<c;
//end_routine();

return 0;
 
 }


Measured memory_bytes: 3652
import itertools

n = int(input())
xy = []
for i in range(n):
    xy.append(list(map(int, input().split())))

R = []
if n >= 3:
    for i, j, k in itertools.combinations(xy, 3):
        if (j[0] - i[0]) * (k[0] - i[0]) + (j[1] - i[1]) * (k[1] - i[1]) <= 0:
            r = ((j[0] - k[0]) ** 2 + (j[1] - k[1]) ** 2) ** 0.5 / 2
            R.append(r)
        elif (i[0] - j[0]) * (k[0] - j[0]) + (i[1] - j[1]) * (k[1] - j[1]) <= 0:
            r = ((i[0] - k[0]) ** 2 + (i[1] - k[1]) ** 2) ** 0.5 / 2
            R.append(r)
        elif (i[0] - k[0]) * (j[0] - k[0]) + (i[1] - k[1]) * (j[1] - k[1]) <= 0:
            r = ((i[0] - j[0]) ** 2 + (i[1] - j[1]) ** 2) ** 0.5 / 2
            R.append(r)
        else:
            x1 = j[0] - i[0]
            x2 = k[0] - i[0]
            y1 = j[1] - i[1]
            y2 = k[1] - i[1]
            cos = (x1 * x2 + y1 * y2) /(((x1 ** 2 + y1 ** 2) ** 0.5) * ((x2 ** 2 + y2 ** 2) ** 0.5))
            sin = (1 - cos ** 2) ** 0.5
            if sin != 0:
                r = (((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5) / 2 / sin
                R.append(r)
            else:
                x = [i[0], j[0], k[0]]
                y = [i[1], j[1], k[1]]
                r = ((max(x) - min(x)) ** 2 + (max(y) - min(y)) ** 2) ** 0.5
                R.append(r / 2)
else:
    r = ((xy[0][0] - xy[1][0]) ** 2 + (xy[0][1] - xy[1][1]) ** 2) ** 0.5 / 2
    R.append(r)
print(max(R))

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
#define go(u) for(int i = head[u], v = e[i].to; i; i=e[i].lst, v=e[i].to)
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define pb push_back
#define re(x) memset(x, 0, sizeof x)
inline int gi() {
    int x = 0,f = 1;
    char ch = getchar();
    while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar();}
    while(isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
    return x * f;
}
template <typename T> inline bool Max(T &a, T b){return a < b ? a = b, 1 : 0;}
template <typename T> inline bool Min(T &a, T b){return a > b ? a = b, 1 : 0;}
const int N = 1e5 + 7;
int n, now;
int a[N], b[N];
LL ans;
vector<int>G[N];
void dfs(int u, int fa) {
	b[u] = a[now--];
	for(auto v:G[u]) if(v ^ fa) dfs(v, u);
}
int main() {
#ifdef fwat
#endif
	now = n = gi();
	rep(i, 1, n - 1) {
		int x = gi(), y = gi();
		G[x].pb(y);
		G[y].pb(x);
	}
	rep(i, 1, n) a[i] = gi();
	sort(a + 1, a + 1 + n);
	rep(i, 1, n - 1) ans += a[i];
	printf("%lld\n", ans);
	dfs(1, 0);
	rep(i, 1, n) printf("%d%c", b[i], i == n ? '\n':' ');
	return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
int BinarySearch(int key,int n,int S[]){
  int l=0,r=n;
  while(r-l>1){
    int mid=(l+r)/2;
    if(S[mid]>key)r=mid;
    else l=mid;
  }
  return S[l]==(key?1:0);
}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

ll C[100007];

int main() {
    ll N,M,X,A[1007],k1=0,k2=0;cin >> N >> M >> X;
    rep(i,M){
        cin >> A[i];
        if(A[i]<X) k1++;
        if(A[i]>X) k2++;
    }
    cout << min(k1,k2) << endl; 
}

Measured memory_bytes: 888
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b, c) = scan!(i64, i64, i64);
    for i in 1..b {
        if (a * i - c) % b == 0 {
            println!("YES");
            return;
        }
    }
    println!("NO")
}


Measured memory_bytes: 4352
#include<iostream>

using namespace std;

struct Card{
	char mark;
	int value;
};

bool isStable(struct Card C1[],struct Card C2[], int n){
	for (int i = 0; i < n; i++){
		if ( C1[i].mark != C2[i].mark) return false;
	}
	return true;
}


void printary(struct Card A[],int n){

	for (int i = 0; i < n; i++){
		cout << A[i].mark << A[i].value;
		if ( i != n-1){
			cout << " ";
		}
	}
	cout << endl;
}


void bubblesort(struct Card B[], int n){
	bool flag = false;
	int j = 0;
	while (!flag){
		flag = true;
		for (int i = n-1; i > j; i--){
			if (B[i].value < B[i-1].value){
				struct Card tmp = B[i];
				B[i] = B[i-1];
				B[i-1] = tmp;
				flag = false;
			}
		}
		j++;
	}
	printary(B,n);
	cout << "Stable" << endl;

}

void selectsort(struct Card C[],int n){
	for ( int i = 0; i < n; i++){
		int min = C[i].value;
		int minj = i;
		for ( int j = i+1; j < n; j++){
			if (min > C[j].value){
				min = C[j].value;
				minj = j;
			}
		}	
		struct Card tmp = C[i];
		C[i] = C[minj];
		C[minj] = tmp;
	}
	printary(C,n);
}

int main(){
	int n; cin >> n;
	struct Card card1[40];	
	struct Card card2[40];	
	for (int i = 0; i < n; i++){
		cin >> card1[i].mark >> card1[i].value;
		card2[i] = card1[i];
	}

	bubblesort(card1,n);
	selectsort(card2,n);

	if (isStable(card1,card2,n)){
		cout << "Stable" << endl;
	}else{
		cout << "Not stable" << endl;
	}


	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define en '\n'
const int MAXN = 1e6+69;
const int INF = 1e18;
const int mod = 1e9+7;
struct vl{
    int x,y;
    bool operator<(vl t)const{
        if(x==t.x)return (y<t.y);
        return x<t.x;
    }
};
map<int,int>mp;
int q;
int m,p,n,k;
int x,y,z;
int a[MAXN],b[MAXN];
int cnt;
set<int> s;
int luythua(int x, int y){
    if(y==0)return 1;
    if(y==1)return x%mod;
    int k = luythua(x,y/2);
    if(y%2==0)return k*k%mod;
    return k*k%mod*x%mod;
}
int fact[MAXN];
int comb(int k, int n){
    return fact[n]*luythua(fact[k],mod-2)%mod*luythua(fact[n-k],mod-2)%mod;
}
signed main(){                                                                                                                                                                                                                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>x>>y;
    if((x+y)%3!=0){
        cout<<0;
        return 0;
    }
    int k = (x+y)/3;
    fact[0]=1;
    for(int i=1;i<=1000000;i++){
        fact[i]=fact[i-1]*i%mod;
    }
    if(min(x,y)<k){
        cout<<0;
        return 0;
    }
    cout<<comb(min(x,y)-k,k)%mod;
}

Measured memory_bytes: 11444
#include <cstring>
#include <cstdio>
#include <map>
#define MOD 998244353
typedef long long ll;
typedef __int128 LL;
std::map<LL, int> ans[105];
int work(int n, LL mask)
{
	if (!n)
		return 1;
	if (ans[n].count(mask))
		return ans[n][mask];
	int &res = ans[n][mask];
	res = work(n - 1, mask >> 1) * ((mask & 1) + 1) % MOD;
	LL all = 0;
	for (int i = 1; i <= n; i++)
	{
		all = all << 1 | 1;
		LL x = mask & all;
		for (int j = i << 1; j <= n; j += i)
		{
			x &= mask >> j - i;
			res = (res + (ll)work(i, x) * work(n - j, mask >> j)) % MOD;
		}
	}
	return res;
}
char str[105];
int main()
{
	// freopen("AGC020-E.in", "r", stdin);
	scanf("%s", str);
	int n = strlen(str);
	LL mask = 0;
	for (int i = n - 1; i >= 0; i--)
		mask = mask << 1 | str[i] - '0';
	printf("%d\n", work(n, mask));
	return 0;
}


Measured memory_bytes: 3840
// すべてが奇数になってしまったら終了
// 毎回どれか偶数1つだけを2で割る -> 素因数2の数

package main
import "fmt"
func main(){
	var N int
	fmt.Scan(&N)
	ans := 0
	for i:=0; i<N; i++{
		var V int
		fmt.Scan(&V)
		for V>0 && V%2==0{
			V/=2
			ans++
		}
	}
	fmt.Println(ans)
}

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

int asc(const void *a, const void *b) {
  long long *A = (long long *)a;
  long long *B = (long long *)b;
  if (*A > *B) return 1;
  if (*A < *B) return -1;
  return 0;
}

int main(void){
    long long int i, j, k, n, x, d, ans=0, po=0;
    scanf("%lld %lld %lld", &n, &k, &d);
    if(n<0) n = -n;
    if(n/d>k) printf("%lld", n-(d*k));
    else{
        k = k - (n/d);
        n = n%d;
        if(k%2==0) printf("%lld", n);
        else printf("%lld", d-n);

    }

    
}

Measured memory_bytes: 1724
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
void dfs(int &n, vector<list<int>>&g, vector<ll>&a, vector<bool>&chd, int &treenum, int node, vector < list<pair<ll, int>>> &t) {
	if (chd[node] == false) {
		chd[node] = true;
		t[treenum].push_back(make_pair(a[node], node));
		for (auto v : g[node]) {
			dfs(n, g, a, chd, treenum, v, t);
		}

	}
}
int main() {
	ll lim = 1e9 + 1;
	int n, m;
	cin >> n >> m;
	if (m == n - 1) {
		cout << 0;
		return 0;
	}
	vector<ll>a(n);
	rep(i, n)cin >> a[i];
	vector<list<int>>g(n);
	rep(i, m) {
		int x, y;
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	vector < list<pair<ll, int>>> t;
	t.reserve(1e5);
	vector<bool>chd(n, false);
	int treenum = 0;
	rep(i, n) {
		if (chd[i] == false) {
			t.push_back({});
			dfs(n, g, a, chd, treenum, i, t);
			t[treenum].sort();
			treenum++;
		}
	}
	ll ans = 0;
	int usedNum = 0;
	rep(i, treenum) {
		ans += t[i].front().first;
		t[i].pop_front();
		usedNum++;
	}
	priority_queue<ll, vector<ll>, greater<ll> >costbox;
	rep(i, treenum) {
		auto it = t[i].begin();
		while (it != t[i].end()) {
			costbox.push(it->first);
			it++;
		}
	}
	while (usedNum < 2 * (n - m - 1) && !costbox.empty()) {
		auto combiningNode = costbox.top();
		costbox.pop();
		ans += combiningNode;
		usedNum++;

	}
	if (usedNum != 2 * (n - m - 1) )cout << "Impossible";
	else cout << ans;
	return 0;
}





Measured memory_bytes: 14712
import math
import itertools

INF = 10**9+7
PRIME_NUM = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]

def main():
	n,m = map(int,input().split())
	ab = []
	for i in range(m):
		ab.append(list(map(int,input().split())))
	link = []
	for i in range(n+1):
		link.append([])
	for i in ab:
		link[i[0]].append(i[1])
		link[i[1]].append(i[0])
	tmp = [i for i in range(2,n+1)]
	ans=0
	for i in itertools.permutations(tmp):
		flag =  True
		array = [1] + list(i)
		for j in range(0,n-1):
			if(link[array[j]].count(array[j+1])==0): flag = False
		if flag:
			ans+=1
	print(ans)

main()


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

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<string> a(n), b(m);
	for (auto&& ai : a) cin >> ai;
	for (auto&& bi : b) cin >> bi;
	bool found = false;
	for (int r = 0; r < n-m+1; r++)
	{
		for (int c = 0; c < n-m+1; c++)
		{
			found = true;
			for (int i = 0; i < m; i++)
				if (a[i+r].substr(c, m) != b[i])
				{
					found = false;
					break;
				}
			if (found) break;
		}
		if (found) break;
	}
	cout << (found ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long lli;
lli n;
vector<lli> p;
int main(int argc, char const *argv[]) {
    cin >> n;
    p = vector<lli> (n+1);
    for(lli i = 1;i <= n;i++){
        for(lli x = i,y = 2;x != 1;y++){
            while(x%y == 0){
                x /= y;
                p[y]++;
            }
        }
    }
    lli ans = 1;
    for(lli i = 0;i <= n;i++){
        ans *= p[i]+1;
        ans %= 1000000007;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }



signed main(){

    string S; cin >> S;
    string T = "CODEFESTIVAL2016";
    int ans = 0;
    REP(i, 16) if(S[i] != T[i]) ans++;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8


def main():
    X = int(input())
    #  B < 119

    for b in range(119):
        a = b+1
        
        while a**5 - b**5 < X:
            a += 1
        
        if a**5 - b**5 == X:
            print(a, b)
            exit()
    
    for b in range(-1, -120, -1):
        a = 0
        
        while a**5 - b**5 < X:
            a += 1
        
        if a**5 - b**5 == X:
            print(a, b)
            exit()


main()
# print(main())


Measured memory_bytes: 9136
n = gets.to_i
s = gets.chomp.gsub(' ', '')
a = s.split(/(?<=0)(?=0)/).map {|x| x.split(/(?<=1)(?=1)/)}.flatten.map(&:size)
if a.size < 3
    p a.inject(:+)
else
    p a.each_cons(3).map{|t| t.inject(:+)}.max
end

Measured memory_bytes: 17340
// 今いるところより右側にある得点, 左側にある得点、あと上下
// のデータがあればうまくいきそう うまく構築する
// TLEをくらったのでたぶん入出力のせいだということで対策
// 馬鹿みたいなバグをして1WA 丁寧にやれ

package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	H, W := nextInt(), nextInt()
	Table := make([][]string, H)
	pointR, pointL, pointU, pointD := make([][]int, H), make([][]int, H), make([][]int, H), make([][]int, H)
	for i := 0; i < H; i++ {
		pointR[i], pointL[i], pointU[i], pointD[i] = make([]int, W), make([]int, W), make([]int, W), make([]int, W)
		Table[i] = chars(next())
	}
	// 構築フェーズ
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if Table[i][j] != "#" {
				if j == 0 {
					pointL[i][j] = 1
				} else {
					pointL[i][j] = pointL[i][j-1] + 1
				}
			} else {
				pointL[i][j] = 0
			}

			if Table[i][W-j-1] != "#" {
				if j == 0 {
					pointR[i][W-1] = 1
				} else {
					pointR[i][W-1-j] = pointR[i][W-j] + 1
				}
			} else {
				pointR[i][W-1-j] = 0
			}
		}
	}
	for j := 0; j < W; j++ {
		for i := 0; i < H; i++ {
			if Table[i][j] != "#" {
				if i == 0 {
					pointU[i][j] = 1
				} else {
					pointU[i][j] = pointU[i-1][j] + 1
				}
			} else {
				pointU[i][j] = 0
			}
			if Table[H-1-i][j] != "#" {
				if i == 0 {
					pointD[H-1][j] = 1
				} else {
					pointD[H-1-i][j] = pointD[H-i][j] + 1
				}
			} else {
				pointD[H-1-i][j] = 0
			}
		}
	}

	// 探索フェーズ
	ans := 0
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			tmp := pointD[i][j] + pointL[i][j] + pointR[i][j] + pointU[i][j] - 3
			ans = max(ans, tmp)
		}
	}
	fmt.Fprintln(out, ans)
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


Measured memory_bytes: 234848
#include<iostream>
using namespace std;
const int MAX_N = 1e5 + 5;
const int NIL = -1;
struct node{
    int p, l, r;
};
node T[MAX_N];
int n, D[MAX_N];

void print(int u){
    int i, c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";
    if(T[u].p==NIL)
        cout << "root, ";
    else if(T[u].l==NIL)
        cout << "leaf, ";
    else
        cout << "internal node, ";
    cout << "[";
    for (i = 0,c = T[u].l; c != NIL;i++,c=T[c].r){
        if(i)
            cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}
void rec(int u,int p){
    D[u] = p;
    if(T[u].r!=NIL)
        rec(T[u].r, p);
    if(T[u].l!=NIL)
        rec(T[u].l, p + 1);

}
int main()
{
    int i, j, d, v, c, l, r;
    cin >> n;
    for (i = 0; i < n;i++){
        T[i].p = T[i].l = T[i].r = NIL;
    }
        for (i = 0; i < n; i++)
        {
            cin >> v >> d;
            for (j = 0; j < d; j++)
            {
                cin >> c;
                if (j == 0)
                    T[v].l = c;
                else
                    T[l].r = c;
                l = c; //????
                T[c].p = v;
            }
        }
    for (i = 0; i < n;i++){
        if(T[i].p==NIL)
            r = i;
    }
    rec(r, 0);
    for (i = 0; i < n;i++)
        print(i);

        return 0;
}


Measured memory_bytes: 7772
def count_balls(n, a, b):
    if(a==0): return 0
    if(n<a): return n
    end = n % (a+b)
    if(end > a):
        return a*(n//(a+b))+a
    else:
        return a*(n//(a+b))+end
n,a,b=map(int, input().strip().split())
print(count_balls(n,a,b))

Measured memory_bytes: 3060
x,y=map(int, input().split())

if x<=y:
    if abs(x)<=abs(y):
        ans=min(y-x, y-(-x)+1)
    else:
        ans=min(y-x, 1+abs(-y-x))

else:
    #xの方が大きい
    ans=1+abs(abs(x)-abs(y))
    if x*y>0:
        ans+=1
print(ans)





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

int main()
{
     int a,b,c;
     scanf("%d %d %d",&a,&b,&c);
     if(( a==5&&b==5&&c==7)||( a==5&&b==7&&c==5)||(a==7&&b==5&&c==5))
        printf("YES\n");
     else  printf("NO\n");
     return 0;
}

Measured memory_bytes: 128
n, m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
a = sorted(a, key=lambda x:x[0])
money = 0
drink = 0
for i in range(n):
  for j in range(a[i][1]):
    drink += 1
    money += a[i][0]
    if drink == m:
      print(money)
      exit()

Measured memory_bytes: 29448
{-# LANGUAGE BangPatterns #-}

module Main where

import Data.Char
import Control.Monad
import Control.Applicative


readInt :: IO Int
readInt = read <$> (input `seq` input)
    where input = do
            !c <- getChar
            if isDigit c || c == '-'
                then (c :) <$> input
                else return []

main = putStrLn . f =<< replicateM 3 readInt
  where f [a,b,c] = if a < b && b < c then "Yes" else "No"


Measured memory_bytes: 3564
/* Priyansh Agarwal*/
#include<bits/stdc++.h>
#include<algorithm>
#include<unordered_map>
#include<vector>
#include<unordered_set>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define nline "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define debug(x) cout << #x << " " << x <<endl;
#define set_bits __builtin_popcount
typedef long long ll;
typedef unsigned long long ull;
/*---------------------------------------------------------------------------------------------------------------------------*/
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll expo(ll a, ll b, ll mod)
{ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
vector<int> sieve(int n) {int*arr = new int[n + 1](); vector<int> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
void extendgcd(ll a, ll b, ll*v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); ll x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;} //pass an arry of size 3
ll mminv(ll a, ll b) {ll arr[3]; extendgcd(a, b, arr); return arr[0];} //for non prime b
ll mminvprime(ll a, ll b) {return expo(a, b - 2, b);}
bool revsort(ll a, ll b) {return a > b;}
void swap(int &x, int &y) {int temp = x; x = y; y = temp;}
ll combination(ll n, ll r, ll m, ll* fact) {ll val1 = fact[n]; ll val2 = mminvprime(fact[r], m); ll val3 = mminvprime(fact[n - r], m); return ((val1 * val2) % m * val3) % m;}
/*--------------------------------------------------------------------------------------------------------------------------*/
int main()
{
	fastio();
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
	freopen("Error.txt", "w", stderr);
#endif
	int n;
	cin >> n;
	ll xor1 = 0;
	ll arr[n];
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
		xor1 ^= arr[i];
	}
	for (int i = 0; i < n; i++)
		cout << (xor1 ^ arr[i]) << " ";
	cout << endl;
	return 0;
}

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

int main()
{
	int a,b[40][40],c[40],d,sum[40]={0},cnt=0;

    cin>>a>>d;
    for(int i=0;i<a;i++)
    {
        cin>>c[i];
        for(int n=0;n<c[i];n++)
        {
            cin>>b[i][n];
            for(int m=1;m<=d;m++)
            {
                if(m==b[i][n])
                    sum[m]++;
            }
        }
    }

	for(int i=1;i<=d;i++)
    {
        if(sum[i]==a)
            cnt++;

    }
	cout<<cnt<<endl;
	return 0;
}
	

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

int main() {
int N,M;
  cin>>N>>M;
  
 vector<int>vect(N);
  for(int i=0;i<M;i++){
   int a,b;
    cin>>a>>b;
    vect.at(a-1)++;
    vect.at(b-1)++;
  }
  for(int i=0;i<N;i++){
   cout<<vect.at(i)<<endl;
  }
 
}


Measured memory_bytes: 256
#include <cstdio>
#include <numeric>
#include <algorithm>

const int MaxN = 200005;

int n, A[MaxN];

bool trans() {
	static int B[MaxN];
	std::fill(B, B + n, 0);
	for (int i = 0; i < n; ++i) {
		int l = std::max(0, i - A[i]);
		int r = std::min(n - 1, i + A[i]);
		B[l] += 1;
		B[r + 1] -= 1;
	}
	bool flag = true;
	for (int i = 0; i < n; ++i) {
		flag &= A[i] == B[i];
		A[i] = B[i];
		B[i + 1] += B[i];
	}
	return flag;
}

int main() {
	int q;
	scanf("%d%d", &n, &q);
	for (int i = 0; i < n; ++i) scanf("%d", A + i);
	while (q--) {
		if (trans()) break;
	}
	for (int i = 0; i < n; ++i) printf("%d ", A[i]);
	puts("");
	return 0;
}

Measured memory_bytes: 4752
package main

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

func pa() int {
	reader:=bufio.NewReader(os.Stdin)
	var n,m,k int
	fmt.Fscan(reader, &n,&m,&k)
	A:=make([]int, n)
	for i:=0;i<n;i++{
		fmt.Fscan(reader,&A[i])
	}
	B:=make([]int, m)
	lastKj:=0
	for i:=0;i<m;i++{
		fmt.Fscan(reader,&B[i])
		lastKj+=B[i]
	}


	ans:=0
	ki:=0
	j:=m
	for i:=0;i<=n;i++{
		if ki>k{
			break
		}
		kj:=k-ki
		for lastKj>kj && j>0{
			j--
			lastKj-=B[j]
		}
		if i+j>ans{
			ans=i+j
		}
		if i<n{
			ki+=A[i]
		}
	}

	return ans
}

func main() {
	fmt.Printf("%d\n",pa())

}

Measured memory_bytes: 7932
n, W = map(int, input().split())
w0, v0 = map(int, input().split())
zero = [v0]
one = []
two = []
three = []

lzero, lone, ltwo, lthree = 1, 0, 0, 0

for _ in range(n - 1):
	w, v = map(int, input().split())
	if w == w0:
		zero.append(v)
		lzero += 1
	elif w == w0 + 1:
		one.append(v)
		lone += 1
	elif w == w0 + 2:
		two.append(v)
		ltwo += 1
	else:
		three.append(v)
		lthree += 1

zero.sort(reverse=True)
one.sort(reverse=True)
two.sort(reverse=True)
three.sort(reverse=True)

zero_sum = [0]
for i in range(len(zero)):
	zero_sum.append(zero_sum[-1] + zero[i])

one_sum = [0]
for i in range(len(one)):
	one_sum.append(one_sum[-1] + one[i])

two_sum = [0]
for i in range(len(two)):
	two_sum.append(two_sum[-1] + two[i])

three_sum = [0]
for i in range(len(three)):
	three_sum.append(three_sum[-1] + three[i])

ans = 0
for i in range(lzero + 1):
	for j in range(lone + 1):
		for k in range(ltwo + 1):
			for l in range(lthree + 1):
				wei = w0 * i + (w0 + 1) * j + (w0 + 2) * k + (w0 + 3) * l
				val = zero_sum[i] + one_sum[j] + two_sum[k] + three_sum[l]
				if wei <= W and val > ans:
					ans = val

print(ans)

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

int main(void)
{
  char s1[11],s2[11],s3[11];
  int l1,l2,l3;
  scanf("%s%s%s",s1,s2,s3);
  l1=strlen(s1);
  l2=strlen(s2);
  if(s1[l1-1]==s2[0]&&s2[l2-1]==s3[0])
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>

using lint = long long;

void solve() {
    lint x;
    std::cin >> x;

    lint ans = x / 500 * 1000;
    x %= 500;
    ans += x / 5 * 5;
    std::cout << ans << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,k,v[55],ma = -INF;
	cin >> n >> k;
	for(int i = 0;i < n;i++) cin >> v[i];
	for(int i = 0;i < n;i++){
		for(int j = 0;i + j <= n;j++){
			if(i + j <= k){
				int ans = 0;
				vector<int> vec;
				for(int a = 0;a < i;a++) vec.pb(v[a]);
				for(int a = 0;a < j;a++) vec.pb(v[n - a - 1]);
				sort(all(vec));
				for(int a = 0;a < vec.size();a++){
					if(a < k - i - j && vec[a] < 0) ans = ans;
					else ans += vec[a];
				}
				chmax(ma,ans);
			}
		}
	}
	cout << ma << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

const int MOD = 1000000007;

ll lcm(ll a, ll b) { return a * b / __gcd(a, b); }

int main() {
  ll a, b;
  scanf("%lld %lld", &a, &b);

  ll r = lcm(a, b);

  cout << r << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  ll n,k;
  cin>>n>>k;
  vector<int> a(n);
  for(auto&& e: a) 
  {
    cin>>e;
  }
  vector<int> dp={1};
  bool flag=true;
  ll bius,term;
  set<int> st={1};
  while(flag)
  {
    if(st.find(a[dp.back()-1])!=st.end())
    {
      for (int i = 0; i < dp.size(); ++i)
      {
        if(dp[i]==a[dp.back()-1])
        {
          flag=false;
          bius=i;
          term=dp.size()-i;
        }
      }
    }
    int next=a[dp.back()-1];
    dp.push_back(next);
    st.insert(next);
  }
  if(k<=bius) cout<<dp[k];
  else{
    k-=bius;
    k%=term;
    k+=bius;
    cout<<dp[k];
  }
}

Measured memory_bytes: 13908
import Foundation

let values = readLine()!.components(separatedBy: " ").map({Int($0)!})
let X = values[0]
let N = values[1]

if N == 0 {
    print(X)
    exit(0)
}

let numbers = readLine()!.components(separatedBy: " ").map({Int($0)!}).sorted()

for i in 0...X+1 {
    for d in [-1, 1] {
        let val = X + d * i
        if numbers.contains(val) == false {
            print(val)
            exit(0)
        }
    }
}



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

int main() {
  int N; cin >> N;
  vector<vector<pair<int ,int>>> G(N);

  rep(i,N-1) {
    int u,v,w; cin >> u >> v >> w;
    u--; v--;
    G[u].push_back(make_pair(v,w));
    G[v].push_back(make_pair(u,w));
  }

  vector<int> d(N,-1);
  d[0] = 0;
  queue<int> que;
  que.push(0);
  while (!que.empty()) {
    int p = que.front(); que.pop();
    for (int i = 0; i < G[p].size(); i++) {
      if (d[G[p][i].first] != -1) continue;
      d[G[p][i].first] = (d[p] + G[p][i].second) % 2;
      que.push(G[p][i].first);
    }
  }

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

Measured memory_bytes: 6784
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    r = int(input())
    if r<1200:
        print('ABC')
    elif r<2800:
        print('ARC')
    else:
        print('AGC')
if __name__ == '__main__':
    main()

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n;cin >> n;
    lint ans=0;
    vector<vector<int>> v(2, vector<int>(n));
    REP(j,2)REP(i,n){
        cin >> v[j][i];
    }
    REP(i,n){
        lint x = 0;
        REP(j,i+1){
            x += v[0][j];
        }
        FOR(j,i,n){
            x += v[1][j];
        }
        ans = max(ans, x);
    }
    cout << ans << "\n";
    return 0;
}

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

int main() {
	string S;
	cin >> S;
	int N = S.length();
	string T = S;
	reverse(T.begin(), T.end());
	string U = S.substr(0, (N - 1) / 2);
	string UU = U;
	reverse(UU.begin(), UU.end());
	string V = T.substr(0, (N - 1) / 2);
	string VV = V;
	reverse(VV.begin(), VV.end());
	cout << (S==T && U==UU && V==VV ? "Yes" : "No") << endl; 
}


Measured memory_bytes: 256