akhauriyash/Code-Regression huggingface dataset:
n = int(input())

s_list = [input() for i in range(n)]

prev = s_list[0][-1]
ans = "Yes"
tmp = [s_list[0]]
for s in s_list[1:]:

    if s in tmp:
        ans = "No"
        break

    if s[0] != prev:
        ans = "No"
        break

    tmp.append(s)
    prev = s[-1]
print(ans)


Measured memory_bytes: 9176
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);++i)
#define reps(i,n) for(int i = 1;i <= (n);++i)
using namespace std;
int main(){
  double t,x;
  cin >> t >> x;
  cout << fixed << t / x << '\n';
  return 0;
}


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

long long f(string S) {
    S.push_back('!');
    long long res = 0;
    for (int i = 1; i < S.length(); ++i) {
        if (S[i] == S[i - 1]) {
            res += 1;
            S[i] = S[i + 1] + 1;
        }
    }
    return res;
}

int main() {
    string S;
    int K;
    cin >> S >> K;
    long long a3 = f(S + S + S);
    long long a2 = f(S + S);
    long long a1 = f(S);
    cout << (a3 - a1) * ((K - 1) / 2) + (a2 - a1) * ((K - 1) % 2) + a1 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#include<string>
#include<vector>
#define ll long long
#include<cstring>
#define rep(i,n) for(int i=0;i<n;i++)
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>QUE;//きゅー

int length(char* str) {
	int len = strlen(str);
	return len;
}

ll LCM(ll a,ll b)
{

    ll r, x, tmp;
    ll i, j;
    ll lcm;
    i = a;
    j = b;

    /* 自然数 a > b を確認・入替 */
    if (a < b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    /* ユークリッドの互除法 */
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    lcm = (i / b) * j;

    return lcm;
}

int main()
{
    int N;
    int ans = 0;
    int a[100010];
    int count[100010] = { 0 };
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        if (a[i] > 100000) {
            ans ++;
        }
        else {
            count[a[i]]++;
            if (count[a[i]] > a[i]) {
                ans++;
            }
        }

    }
    for (int i = 0; i < N; i++) {

        if (a[i]<=100000&&a[i] > count[a[i]]) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk)
{
	var input = chunk.toString();
	var kazu = input.split(" ");
	var men = kazu[0] * kazu[1];
	var syu = kazu [0] * 2 + kazu[1] * 2;
	console.log(men+" "+syu);
});

Measured memory_bytes: 7644
# -*- coding: utf-8 -*-

import sys
import copy

sys.setrecursionlimit(1000000)

# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

X, A = map(int, input().split())

if X < A:
    print(0)
else:
    print(10)


Measured memory_bytes: 3444
#include <stdio.h>
#include <algorithm>

using namespace std;

int main()
{
	int sum = 0;
	int a[4], b[2];

	for (int i = 0; i < 4; i++)
	{
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < 2; i++)
	{
		scanf("%d", &b[i]);
	}
	sort(rbegin(a), rend(a));
	sum = max(b[0], b[1]);
	for (int i = 0; i < 3; i++)
	{
		sum += a[i];
	}

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

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


int main(){
  string S;
  int ans = 0;
  cin>>S;
  int i;
  for(i=0 ; i < S.size()-1 ; i++){
    if(S.at(i)==S.at(i+1)){
      ans++;
      int num = (S.at(i+1)-'0'+1)%2;
      char c = num+'0';
      S.at(i+1)=c;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <set>
#include <cmath>
using namespace std;

int main()
{
	char a[5];
	for (int i=1; i<=4; i++) cin>>a[i];
	if (a[1]==a[2]||a[2]==a[3]||a[3]==a[4])
	{
		cout <<"Bad";
		return 0;
	 } 
	else cout << "Good";
}

Measured memory_bytes: 256
#pragma optimize("unroll-loops,no-stack-protector")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
// using namespace __gnu_pbds;
// #include <ext/pb_ds/assoc_container.hpp>
// typedef tree<int,null_type,less<int>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define Max(a,b,c) max(a,max(b,c))
#define Min(a,b,c) min(a,min(b,c))
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define pc(x)  __builtin_popcount (x)
#define vl vector< ll >
#define sorts(v) sort(v.begin(),v.end())
#define sortg(v) sort(v.begin(),v.end(),greater<ll>())
#define ss second
#define ff first
#define ll long long
#define ld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod 1000000007
#define mem(x,y) memset(x,y,sizeof(x))
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define gcd __gcd
#define primeDEN 727999983
#define nx_pe next_permutation(s.begin(),s.end())
#define cl cout<<"\n"
#define sp(x) setprecision(x)

const ll N=4e5+5;
ll tree[N*4];
ll a[N];
ll n,k;
ll dp[N];

void build(ll node,ll st, ll end)
{
    if(st==end)
    {
        tree[node]=0;
        return ;
    }
    ll mid=(st+end)/2;
    build(2*node,st,mid);
    build(2*node+1,mid+1,end);
    tree[node]=max(tree[2*node],tree[2*node+1]);

}

void update(ll node,ll st, ll end, ll id,ll val)
{
    if(st==end)
    {
        tree[node]=val;
        dp[id]=val;
        return;
    }
    ll mid=(st+end)/2;
    if(st<=id&&id<=mid)
    {
        update(2*node,st,mid,id,val);
    }
    else
    {
        update(2*node+1,mid+1,end,id,val);
    }
    tree[node]=max(tree[2*node],tree[2*node+1]);

    
}


ll query(ll node,ll st,ll end,ll l,ll r)
{
    if(st>r||end<l)
    {
        return 0;
    }
    if(st>=l&&end<=r)
    {
        return tree[node];
    }
    ll mid=(st+end)/2;
    ll p=query(2*node,st,mid,l,r);
    ll q=query(2*node+1,mid+1,end,l,r);
    return max(p,q);
}


void solve()
{
   
   cin>>n>>k;
   rep(i,n)cin>>a[i];
   build(1,0,N);
   mem(dp,0);
//    f(i,0,N)dp[i]=1;
//    dp[a[0]]=1;
    update(1,0,N-1,a[0],1);
    ll ans=1;
   f(i,1,n)
   {
       ll num=a[i];
       ll l=max((ll)0,a[i]-k),r=min(a[i]+k,N-1);
       ll val=query(1,0,N-1,l,r);
       update(1,0,N-1,a[i],val+1);
    //    cout<<a[i]<<" "<<val<<" "<<dp[a[i]]<<"\n";
   }
  f(i,0,N)
  {
      ans=max(ans,dp[i]);
  }
   
   cout<<ans;

}


    
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("ouput.txt", "w", stdout) ;
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    std::ios::sync_with_stdio(false);
    ll te=1;
    // cin>>te;
    while(te--){
        solve();
    }
    
}


Measured memory_bytes: 17324
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
int main()
{
    int A, B, C, X, Y;
    std::cin >> A >> B >> C >> X >> Y;
    
    auto _1 = X*A + Y*B;
    auto _2 = std::min(X,Y) * C * 2 + ( X > Y ? (X-Y)*A : (Y-X)*B );
    auto _3 = std::max(X,Y) * C * 2;
    
    std::cout << std::min({_1,_2,_3}) << std::endl;
}

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


int main() {
  int N;
  cin >> N;
  float ans = 0;
  for(int i=0; i<N; ++i) {
    float x;
    string u;
    cin >> x >> u;
    if(u == "JPY") ans += x;
    else ans += (x * 380000);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

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

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 500005;

int n, m, Q, a[MAXN], b[MAXN];
LL c[MAXN];

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read(), b[0] = m = Read();
	for (int i = 1; i <= n; i ++)
		a[i] = Read(), b[i] = min(b[i - 1], abs(a[i] - b[i - 1]));
	c[n] = 1;
	for (int i = n - 1; i; i --)
		if (c[i + 1] <= a[i + 1] >> 1)
			c[i] = c[i + 1];
		else
			c[i] = c[i + 1] + a[i + 1];
	Q = Read();
	while (Q --)
	{
		int x = Read();
		puts(b[x - 1] >= c[x] ? "YES" : "NO");
	}
}


Measured memory_bytes: 9728
import sys
input = sys.stdin.readline

k = int(input())

list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(list[k-1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int c=0;
    cin>>n;
    c=n%10;
    if(c==3){
        cout<<"bon"<<endl;
    }else if(c==0||c==1||c==6||c==8){
        cout<<"pon"<<endl;
    }else{
        cout<<"hon"<<endl;
    }
}

Measured memory_bytes: 3624
#include <stdio.h>

int
main(void)
{
	char line[80];
	int d;

	while (fgets(line, sizeof line, stdin)) {
		if (sscanf(line, "%d", &d) == 1) {
			int s = 0;
			for (int i = 1; d*i <= 600 - d; i++) {
				s += (d*i)*(d*i) * d;
			}
			printf("%d\n", s);
		}
	}

	return 0;
}

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

#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

void initialize();
int isEmpty();
int isFull();
void enqueue(P x);
P dequeue();
int min(int a,int b);



P Q[LEN+1];
int head, tail, n;

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  head=1;  tail = n+1;

 while(head !=tail){
   u=dequeue();
   c=min(q,u.t);
   u.t -=c;
   elaps += c;
   if(u.t>0)enqueue(u);
   else{
     printf("%s %d\n",u.name,elaps);
   }
 }

  return 0;
}

void initialize(){
  head = tail = 0;
}

int isEmpty(){
    if(head == tail){
      return 1;
    }
    return 0;
  }

int isFull(){
    if(head == (tail + 1) % LEN){
    return 1;
  }
  return 0;
}

void enqueue(P x){
   if (isFull()){
     printf("errer");
   }
   Q[tail] = x;
   if(tail + 1 == LEN){
     tail = 0;
   }else{
        tail++;
      }
}

 P dequeue(){
   if(isEmpty()){
     printf("errer");
   }
   P x = Q[head];
   if(head + 1 == LEN){
     head = 0;
   }else{
     head++;
   }
   return x;
 }

 int min(int a,int b){
   return a<b ? a:b;
 }



Measured memory_bytes: 11868
#include <bits/stdc++.h>
using namespace std;
#define li long long int
#define pb push_back
#define rep(i,n) for(li i=0;i<n;i++)
void solve()
{
   li n,k;
   cin>>n>>k;
   li a[n];
   rep(i,n)
   cin>>a[i];
   li d=n-k,j=0;
   for(li i=k;i<n;i++)
   {
       //cout<<a[i]<<" "<<a[j]<<" ";
       if(a[i]>a[j])
       cout<<"Yes\n";
       else
       cout<<"No\n";
       j++;
   }
}

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    li t;
    t=1;
    while(t--)
    {
        solve();
        
    }
}

Measured memory_bytes: 5200
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int N=3e5+10;
int x,y,a,b,c;
ll r[N],g[N],w[N];
int main()
{
    scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
	rep(i,0,a){
		scanf("%lld",&r[i]);
	}
	rep(i,0,b){
		scanf("%lld",&g[i]);
	}
	rep(i,0,c){
		scanf("%lld",&w[i]);
	}
	sort(r,r+a);
	sort(g,g+b);
	int cnt=0;
	per(i,0,a){
		cnt++;
		w[c++]=r[i];
		if(cnt==x)break;
	}
	cnt=0;
	per(i,0,b){
		cnt++;
		w[c++]=g[i];
		if(cnt==y)break;
	}
	sort(w,w+c);
	cnt=0;
	ll sum=0;
	per(i,0,c){
		cnt++;
		sum+=w[i];
		if(cnt==x+y)break;
	}
	printf("%lld",sum);
    return 0;
}

Measured memory_bytes: 6400
# ALDS1_7_B Binary Tree
import sys


class Node:
    def __init__(self):
        self.parent = -1
        self.left = None
        self.right = None
        self.height = None
        self.depth = None
        self.sibling = -1
        self.type = 'internal node'
        self.deg = 0


def calc_depth(A, i):
    if A[i].depth:
        return A[i].depth

    if A[i].parent == -1:
        A[i].depth = 0
    else:
        A[i].depth = calc_depth(A, A[i].parent) + 1
    return A[i].depth


def calc_height(A, i):
    if A[i].height:
        return A[i].height

    if (A[i].left == -1) & (A[i].right == -1):
        A[i].height = 0
        return A[i].height

    if A[i].left == -1:
        A[i].height = calc_height(A, A[i].right) + 1
    elif A[i].right == -1:
        A[i].height = calc_height(A, A[i].left) + 1
    else:
        A[i].height = max(calc_height(A, A[i].left), calc_height(A, A[i].right)) + 1

    return A[i].height


n = int(input())

tree = []
for i in range(n):
    node = Node()
    tree.append(node)

for i in range(n):
    A = list(map(int, sys.stdin.readline().strip().split()))
    tree[A[0]].left = A[1]
    tree[A[0]].right = A[2]
    if A[1] != -1:
        tree[A[1]].parent = A[0]
        tree[A[1]].sibling = A[2]
        tree[A[0]].deg += 1
    if A[2] != -1:
        tree[A[2]].parent = A[0]
        tree[A[2]].sibling = A[1]
        tree[A[0]].deg += 1
    if (A[1] == -1) & (A[2] == -1):
        tree[A[0]].type = 'leaf'

for i in range(n):
    calc_depth(tree, i)
    height = calc_height(tree, i)
    if tree[i].parent == -1:
        node_type = 'root'
    else:
        node_type = tree[i].type

    print('node {}: parent = {}, sibling = {},'
          ' degree = {}, depth = {}, height = {}, {}'.format(i, tree[i].parent, tree[i].sibling,
                                                             tree[i].deg, tree[i].depth, height,
                                                             node_type))




Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin >> a;
    int count = 700;
    for(int i=0; i<3; i++){
        if(a[i]=='o'){
            count+=100;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
integer(16) N
integer(16) T,ans
read*,N
read*,ans
do i=2,N
  read*,T
  ans=ans*T/gcd(ans,T)
end do
print"(i0)",ans
contains
pure function gcd(a,b)
integer(16),intent(in)::a,b
integer(16) gcd
integer(16) s,t
s=a
gcd=b

t=mod(s,gcd)
do while(t/=0)
  s=gcd
  gcd=t
  t=mod(s,gcd)
end do
end function gcd
end

Measured memory_bytes: 256
N=input()
A=sorted(map(int,input().split()))
M=A[-1]+1
B=[True]*M
c=0
x=0
for i in A:
  if B[i]==True:
    if i!=c:
      for j in range(i*2,M,i):
        B[j]=False
      x+=1
      c=i
    else:
      B[i]=False
      x-=1
print(x)

Measured memory_bytes: 32208
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

void f(int n){
	if(n>3)f(n/4);
	cout<<n%4;
}

int main() {
	int n;
	while(n=in(),n>=0){
		f(n);
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<lu> vu;
typedef vector<v> vv;
typedef vector<vu> vvu;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<set<ll>> vsll;
typedef set<pair<ll, ll>> spll;
typedef vector<spll> vspll;
typedef vector<pll> vpll;
typedef pair<lu, lu> puu;
typedef vector<puu> vpuu;
const ll MOD = 1000000007;
const ld PI = 2 * acos(0.0);
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template <typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector<T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

template <typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}

void solve() {
    ll n, m;
    cin >> n >> m;

    vv adjList(n + 1, v(0));
    v indeg(n + 1, 0);
    vv inci(n + 1, v(0));
    for (ll i = 0; i < m; i++) {
        ll a, b;
        cin >> a >> b;
        adjList[a].push_back(b);
        inci[b].push_back(a);
        indeg[b]++;
    }

    queue<ll> degrees;
    for (ll i = 1; i <= n; i++)
        if (!indeg[i])
            degrees.push(i);
    v toposort = {};
    while (!degrees.empty()) {
        auto node = degrees.front();
        degrees.pop();
        toposort.push_back(node);
        for (auto neigh : adjList[node]) {
            indeg[neigh]--;
            if (!indeg[neigh])
                degrees.push(neigh);
        }
    }

    v dp(n + 1, 0);
    for (auto node : toposort) {
        for (auto neigh : inci[node]) {
            amax(dp[node], dp[neigh] + 1);
        }
    }

    ll len = 0;
    for (ll i = 1; i <= n; i++) {
        amax(len, dp[i]);
    }
    cout << len;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // freopen("file", "r", stdin);
    // freopen("file", "w", stdout);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long uLL;
typedef long double ldb;
typedef pair<int,int> pii;

vector<pii> G[100001];
bool vis[100001];
int X[100001];

pii f(int v, int x)
{
    if(vis[v])
    {
        if(x != X[v])
            return {-1e9, 1e9};
        return {x, x};
    }
    X[v] = x;
    vis[v] = true;
    pii ret(x,x);
    for(pii i:G[v])
    {
        pii res = f(i.first, x+i.second);
        ret.first = min(ret.first, res.first);
        ret.second = max(ret.second, res.second);
    }
    return ret;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, m;
    cin>>n>>m;
    for(int i = 0; i < m; ++i)
    {
        int l, r, d;
        cin>>l>>r>>d;
        G[l].emplace_back(r, d);
        G[r].emplace_back(l, -d);
    }
    for(int i = 1; i <= n; ++i)
    {
        if(!vis[i])
        {
            pii res = f(i, 0);
            if(res.second-res.first > 1e9)
                return cout<<"No"<<endl, 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h> //AtCoder
#include <atcoder/all> //AtCoder
#include <iostream> //Codeforces
#include <vector> //Codeforces

#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Vc vector<char>
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl

using namespace std;
using namespace atcoder;

/*int gcd(int a,int b){return b?gcd(b,a%b):a;}//最大公約数
int lcm(int a,int b){return a/gcd(a,b)*b;}//最小公倍数*/

/****************************** START ******************************/

signed main(){
  int N,M;
  cin >> N >> M;
  Vi a(N),b(M);
  rep(i,0,N){
    cin >> a.at(i);
  }
  rep(j,0,M){
    cin >> b.at(j);
  }
  vector<int> c = convolution<998244353>(a, b);
  rep(k,0,N+M-1){
    cout << c.at(k);
    cout << " ";
  }
}      

Measured memory_bytes: 27232
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * The Number of Area
 */
public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = Integer.parseInt(line);
			int sum = 1;
			for (int i = 1; i <= n; i++) {
				sum += i;
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 17792
/**
*	  Name: Ajay
*	  Institute: IIITH 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define ll long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<ppi>
#define vll vector<ll>
#define mp make_pair
#define fi first
#define se second
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void input()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}

double get_max_sum(vector<double> arr,int n) 
{ 
    int i;
    double sum=0; 
    priority_queue<double,vector<double>, greater<double>> pq;   
    for (i=0;i<n;i++) 
        pq.push(arr[i]);
    while(pq.size()>1)  
    { 
        double x=pq.top();   
        pq.pop(); 
  		double y=pq.top();  
        pq.pop();
        double newv=(x+y)/2;
        pq.push(newv); 
    }
    double ans=pq.top();
    return ans; 
}

int main()
{      
  fastio();
  int n,m,i,j,t;
  cin>>n;
  vector<double> v;
  for(i=0;i<n;i++)
  {
  	double x;
  	cin>>x;
  	v.pb(x);
  }
  double ans=get_max_sum(v,n);
  cout<<fixed<<setprecision(6)<<ans;
  return 0;
}

Measured memory_bytes: 256
import sys
from itertools import permutations
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LLI(n): return [[int(x) for x in input().split()] for _ in range(n)]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


N,M,R = LI()
RS=LI()
mp = [[10**10]*(N+1) for _ in range(N+1)]
for a,b,c in LLI(M):
    mp[a][b] = c
    mp[b][a] = c

for k in range(N+1):
    for i in range(N+1):
        for j in range(N+1):
            mp[i][j] = min(mp[i][j], mp[i][k] + mp[k][j])

res = INTMAX
for l in permutations(RS):
    sc = 0
    for i in range(R-1): 
        sc += mp[l[i]][l[i+1]]
    res = min(res,sc)
print(res)


Measured memory_bytes: 50520
n = int(input())
lm = list(map(int,input().split()))
s = 0
for x in range(1,n-1):
    if (lm[x] > lm[x+1] and lm[x]<lm[x-1]) or(lm[x] > lm[x-1] and lm[x]<lm[x+1]):
        s += 1
    else:
        continue
print('{}'.format(s))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <cctype>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

const ll INF = 100000000;
const ll MOD = 1000000007;

ll pow_mod(ll a,ll b,ll mod){
    if(b==0){
        return 1;
    }

    if(b%2){
        return (a*pow_mod(a,b-1,mod))%mod;
    }else{
        return (pow_mod(a,b/2,mod)*pow_mod(a,b/2,mod))%mod;
    }
}

int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    //問題文中の添え字が0-indexか1-indexか確認!

    std::string l;
    std::cin>>l;
    ll s=l.size();
    std::vector<std::vector<ll>> dp(s,std::vector<ll>(2));
    dp[0][0]=1;
    dp[0][1]=2;
    rep(i,1,s){
        if(l[i]=='1'){
            dp[i][1]=(dp[i-1][1]*2)%MOD;
            dp[i][0]=(dp[i-1][1]+(dp[i-1][0]*3)%MOD)%MOD;
        }else{
            dp[i][1]=dp[i-1][1];
            dp[i][0]=(dp[i-1][0]*3)%MOD;
        }
    }
    std::cout<<(dp[s-1][0]+dp[s-1][1])%MOD;
    return 0;
}

Measured memory_bytes: 5840
#include<bits/stdc++.h>
using namespace std;
int n,k; vector<int>v;
long long dp[100005];

int main() {
	cin >> n>>k; 
	v.resize(n + 1);
	for (int i = 1; i <= n;i++)cin >> v[i];
	fill(dp, dp + n + 1, 1e18);
	dp[1] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= k; j++) {
			if(i+j<=n)dp[i+j] = min(dp[i+j], dp[i] + abs(v[i] - v[i+j]));
		}
	}
	cout << dp[n];
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
  
int n, m;
vector<int> p1, p2;
int main()
{
  while(true){
    scanf("%d%d", &n, &m);
    if(!n && !m)
      break;
 
    p1.clear();
    p2.clear();
      
    //chap1
    p1.push_back(0);
    for(int i = 0; i < n; i++){
      int p;
      scanf("%d", &p);
      p1.push_back(p);
    }
  
    //chap2
    for(int i = 0; i <= n; i++)
      for(int j = i; j <= n; j++)
    p2.push_back(p1[i] + p1[j]);
  
    sort(p2.begin(), p2.begin() + p2.size());
  
    //chap3
    int ans = 0;
    for(int i = 0; i < p2.size(); i++){
      vector<int>::iterator count2 = upper_bound(p2.begin(), p2.end(), m - p2[i]);
      if(count2 != p2.begin())
    ans = max(ans, *(count2 - 1) + p2[i]);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll k;
  cin >> k;
  cout << k/2*((k+1)/2) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

// 1x1=1
// 1x2=2
// .
// .
// 9x8=72
// 9x9=81

int main(){
	int a, i, j;
	for(i=1;i<10;i++){
		for(j=1;j<10;j++){
			a = i * j;
			printf("%dx%d=%d\n",i,j,a);
		}
	}
    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
// int dx[4]    = {1, 0, -1, 0};
// int dy[4]    = {0, 1, 0, -1};
// ll pas[5001][5002];
ll n;
double dp[302][302][302];

double rec(int i, int j, int k) {
    if (dp[i][j][k] >= 0) return dp[i][j][k];
    if (i == 0 && j == 0 && k == 0) return 0.0;

    double &tmp = dp[i][j][k];

    tmp = 0;
    if (i > 0) tmp += rec(i - 1, j, k) * i;
    if (j > 0) tmp += rec(i + 1, j - 1, k) * j;
    if (k > 0) tmp += rec(i, j + 1, k - 1) * k;
    tmp += n;
    tmp *= 1.0 / (i + j + k);

    return tmp;
}

signed main() {
    IOS();
    int a[4] = {};
    memset(dp, -1, sizeof(dp));
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        a[x]++;
    }
    cout << setprecision(10) << fixed << rec(a[1], a[2], a[3]) << endl;
    return 0;
}

Measured memory_bytes: 215552
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
using namespace std;
#define ll long long
int main(){
	int A[9];
    int i,j;
    for(i=0;i<9;i++){
        cin >> A[i];
    }
    int N,b;
    cin >> N;
    for(i=0;i<N;i++){
        cin >> b;
        for(j=0;j<9;j++){
            if(A[j]==b)A[j]=0;
        }
    }
    bool flag=false;
    if(A[0]==0 && A[3]==0&&A[6]==0)flag=true;
    if(A[1]==0 && A[4]==0&&A[7]==0)flag=true;
    if(A[2]==0 && A[5]==0&&A[8]==0)flag=true;
    if(A[0]==0 && A[1]==0&&A[2]==0)flag=true;
    if(A[3]==0 && A[4]==0&&A[5]==0)flag=true;
    if(A[6]==0 && A[7]==0&&A[8]==0)flag=true;
    if(A[0]==0 && A[4]==0&&A[8]==0)flag=true;
    if(A[2]==0 && A[4]==0&&A[6]==0)flag=true;
    if(flag)cout << "Yes";else cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s, t;
  int a, b;
  string u;
  cin >> s >> t >> a >> b >> u;
  if(s == u) a -= 1;
  else if(t == u) b -= 1;
  cout << a << " " << b << endl;
  return 0;
}

Measured memory_bytes: 256
/*==============================================*\ 
ID:          shahidul_brur

Name:     Md. Shahidul Islam           
Study:      CSE, BRUR                 
Address:  Rangpur, Bangladesh
                
 mail: shahidul.cse.brur@gmail.com 
 FB  : fb.com/shahidul.brur        
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English) 
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

inline int Int(){int x; scanf("%d", &x);return x;}
inline long Long() {long x;scanf("%ld", &x);return x;}
inline ll LLong() {ll x;scanf("%lld", &x);return x;}
inline float Float() {float x;scanf("%f", &x);return x;}
inline double Double() {double x;scanf("%lf", &x);return x;}
inline ii Pair() {ii p; scanf("%d %d", &p.ff, &p.ss);return p;}
void Char(char *x) {scanf("%s", x);}

void pI(int x) {printf("%d", x);}
void pL(long x) {printf("%ld", x);}
void pLL(ll x) {printf("%lld", x);}
void pUL(ull x) {printf("%llu", x);}
void pF(float x) {printf("%f", x);}
void pD(double x) {printf("%f", x);}
void pS(char x[]) {printf("%s", x);}
#define pCas printf("Case %d:",cas)
#define NL printf("\n")
#define SP printf(" ")

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};

const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;
const int LOGN = 20;

int main()
{
    //ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n, a[105];
    cin>>n;
    f1(i,n)
    {
        cin>>a[i];
    }
    int cnt = 0;
    for(int i=1;i<=n;i++)
    {
        int c = 1;
        if(i+1<=n && a[i+1]==a[i]) 
            ++i, ++c;
        cnt+=c/2;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <ctime>
constexpr int MOD = 1000000007;
constexpr int INF = 2000000000;
using namespace std;

int ans[101][101] = {0};
int main() {
	int n;
	cin >> n;
	int a;
	int b;
	int c;
	for (int i = 1; i <= n; i++) {
		cin >> a >> b;
		for (int j = 0; j < b; j++) {
			cin >> c;
			ans[i][c] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cout << ans[i][j];
			if (j != n)cout << " ";
			else cout << endl;
		}
	}
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N;
  vector<long long int> abcde(5);
  cin >> N;
  for(int i=0;i<5;i++) {
    cin >> abcde[i];
  }

  long long int mini = *min_element(abcde.begin(), abcde.end());

  long long int longTime = 0;

  if(N % mini == 0) {
    longTime = N / mini; 
  } else {
    longTime = N / mini + 1;
  }

  cout << longTime + 4 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> > 
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int n, k;
	cin >> n >> k;
	int ans = 0;
	while(n){
		ans++;
		n /= k;
	}
	cout << ans;
}

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

#define pb push_back
#define ss second
#define ff first
#define N 100005
#define inf 1000000009
#define ll long long
#define all(a) a.begin(),a.end()
#define mid(a,b) (a+b)/2
#define pii pair<int,int>

using namespace std;

ll a,b;

int main()
{
	scanf("%lld%lld",&a,&b);
	a %= b;
	printf("%lld",min(b - a,a));
}

Measured memory_bytes: 256
import math
N, D = map(int, input().split())
points = [list(map(int, input().split())) for i in range(N)]
count = 0

for point in points:
    distance =  math.sqrt(point[0] ** 2 + point[1] ** 2)
    if distance <= D:
        count += 1
        
print(count)



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

vector<vector<ll> > g;
vector<ll> cnt;

void dfs(int x,ll k)
{
	ll num=2;
	for (int i = 0; i < g[x].size(); i++)
  	{
		int p = g[x][i];
		if(cnt[p]<0)
      	{
			cnt[p] = max(0LL,k-num);
			num++;
			dfs(p,k);
		}
	}
}

int main()
{
	ll n,k;
	cin>>n>>k;
	if(n==1)
		return cout<<k<<endl , 0;
	g.resize(n,vector<ll>());
	cnt.resize(n,-1LL);
	for (int i = 0; i < n-1; i++)
  	{
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	int s = -1;
	for (int i = 0; i < n; i++)
		if(g[i].size()==1)
      	{
			s=i;
			break;
		}
	cnt[s] = k;
	cnt[g[s][0]] = k-1;
	dfs(g[s][0],k);

	ll ans = 1;
	for (int i = 0; i < n; i++)
		ans *= cnt[i] , ans %= 1000000007;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define lson root<<1,l,midd
#define rson root<<1|1,midd+1,r
#define pb push_back
typedef long long ll;
const int M=1e6+6;
const int mod=1e9+7;
vector<int>g[M];
ll facn=1;
int n;
ll ans[M],sz[M],mul[M],fac[M];
ll ksm(ll a,ll b){
    a%=mod;
    ll t=1;
    while(b){
        if(b&1)
            t=t*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return t;
}
void dfs1(int u,int fa){
    sz[u]=mul[u]=1;
    for(auto v:g[u]){
        if(v!=fa){
            dfs1(v,u);
            sz[u]+=sz[v];
            mul[u]=mul[u]*mul[v]%mod;
        }
    }
    mul[u]=mul[u]*sz[u]%mod;
}
void dfs2(int u,int fa,ll last){
    ll tmp=last;
    for(auto v:g[u])
        if(v!=fa)
            tmp*=mul[v],tmp%=mod;
    ans[u]=facn*ksm(tmp,mod-2)%mod;
    for(auto v:g[u])
        if(v!=fa)
            last*=mul[v],last%=mod;
    for(auto v:g[u])
        if(v!=fa)
            dfs2(v,u,last*ksm(mul[v],mod-2)%mod*(n-sz[v])%mod);
}
int main(){
    scanf("%d",&n);
    for(ll i=2;i<n;i++)
        facn*=i,facn%=mod;
    for(int u,v,i=1;i<n;i++){
        scanf("%d%d",&u,&v);
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs1(1,0);
    dfs2(1,0,1);
    for(int i=1;i<=n;i++)
        printf("%lld\n",ans[i]);
    return 0;
}


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

int main() {
	int x[5];	int k;
	for (int i = 0; i < 5; i++) {
		cin >> x[i];
	}
	cin >> k;

	int ans = 0;	int sum = 0;
	for (int i = 1; i < 5; i++) {
		sum = x[i] - x[0];
		if (sum > k) {
			ans = 1;
		}
	}
	for (int i = 2; i < 5; i++) {
		sum = x[i] - x[1];
		if (sum > k) {
			ans = 1;
		}
	}
	for (int i = 3; i < 5; i++) {
		sum = x[i] - x[2];
		if (sum > k) {
			ans = 1;
		}
	}
	for (int i = 4; i < 5; i++) {
		sum = x[i] - x[3];
		if (sum > k) {
			ans = 1;
		}
	}
	if (ans == 1) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
   string a;
   cin>>a;
   if (a[0]==a[1] && a[2]==a[3] && a[0]!=a[2]){
     cout<<"Yes"<<endl;
   }
   else if (a[0]==a[2] && a[1]==a[3] && a[0]!=a[1]){
     cout<<"Yes"<<endl;
   }
   else if (a[0]==a[3] && a[1]==a[2] && a[0]!=a[1]){
     cout<<"Yes"<<endl;
   }
     else{
     cout<< "No"<<endl;
     }
   }
     
    

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>

using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}


int main(){
    int N,A,B;
    cin >> N >> A >> B;
    int res=B-A;
    if(res%2==0){
        cout << "Alice";
    }
    else{
        cout << "Borys";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    cin >> n;
    tuple<int,int,int> t[n - 1];
    for(int i = 0;i < n - 1;i++)
    {
        int c,s,f;
        cin >> c >> s >> f;
        t[i] = make_tuple(c,s,f);
    }
    for(int i = 0;i < n - 1;i++)
    {
        int ans = 0;
        for(int j = i;j < n - 1;j++)
        {
            ans = max(ans,get<1>(t[j]));
            ans = ceil(double(ans) / get<2>(t[j])) * get<2>(t[j]);
            ans += get<0>(t[j]);
        }
        cout << ans << "\n";
    }
    cout << "0\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 510
using namespace std;
int n,a[N*N],mi[N][N],ex[N][N],ans;
void trans(int x,int y){
	if (x-1>0&&mi[x-1][y]>mi[x][y]+ex[x][y]){mi[x-1][y]--;trans(x-1,y);}
	if (x<n&&mi[x+1][y]>mi[x][y]+ex[x][y]){mi[x+1][y]--;trans(x+1,y);}
	if (y-1>0&&mi[x][y-1]>mi[x][y]+ex[x][y]){mi[x][y-1]--;trans(x,y-1);}
	if (y<n&&mi[x][y+1]>mi[x][y]+ex[x][y]){mi[x][y+1]--;trans(x,y+1);}
}
int main(){
	cin>>n;
	for (int i=1;i<=n*n;i++)cin>>a[i];
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)mi[i][j]=min(i-1,min(j-1,min(n-i,n-j))),ex[i][j]=1;
	for (int i=1;i<=n*n;i++){
		int x=(a[i]+n-1)/n,y=(a[i]-1)%n+1;
		ans+=mi[x][y];
		ex[x][y]=0;
		trans(x,y);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 29292
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;

int main()
{
   int N;
   cin >> N;
   cout << 1-N << endl;   
   return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<queue>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

int n,m,rev;
char s[200009];
deque<int> q;

inline void throws()
{
	int c=q.front();
	q.pop_front();
	if(c^rev==0)
		q.push_front(1^rev);
	else
	{
		rev^=1;
		q.push_back(0^rev);
	}
}

int main()
{
	if(fopen("vj.in","r"))
	{
		freopen("vj.in","r",stdin);
		freopen("vj.out","w",stdout);
	}

	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	
	for(int i=1;i<=n;i++)
		q.push_back((s[i]=='A')?0:1);
	for(int i=1;i<=2*n && i<=m;i++)
		throws();

	if(2*n<m)
	{
		m-=2*n;
		m%=2;
		for(int i=1;i<=m;i++)
			throws();
	}
	while(!q.empty())
			putchar((q.front()^rev)+'A'),q.pop_front();
	putchar('\n');
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	vi a(n); cin >> a;
	int s = 0, ans = 0;
	FOR(i, 1, n)
	{
		if (a[i] == a[i - 1]) continue;
		else if (a[i] > a[i - 1])
		{
			if (s == 2)
			{
				ans++;
				s = 0;
			}
			else s = 1;
		}
		else if (a[i] < a[i - 1])
		{
			if (s == 1)
			{
				ans++;
				s = 0;
			}
			else s = 2;
		}
	}
	cout << ans + 1 << endl;
	return 0;
}

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

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    
    if (x >= r && x <= W - r && y >= r && y <= H - r) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3116
import collections
import sys
input=sys.stdin.readline

def calc():
  h,w,k=map(int,input().split())
  sy,sx,gy,gx=map(int,input().split())
  sy,sx,gy,gx=sy-1,sx-1,gy-1,gx-1
  board=[input() for _ in range(h)]
  q=collections.deque()
  q.append((sx,sy))
  checked=[[[0,0,0,0] for _ in range(w)] for _ in range(h)]
  checked[sy][sx][0]=1
  checked[sy][sx][1]=1
  checked[sy][sx][2]=1
  checked[sy][sx][3]=1
  cost=[[10**18]*w for _ in range(h)]
  cost[sy][sx]=0
  while len(q)!=0:
    x,y=q.popleft()
    c=cost[y][x]
    for i in range(1,k+1):
      if x+i<w and checked[y][x+i][0]==0 and board[y][x+i]=='.' and c<cost[y][x+i]:
        checked[y][x+i][0]=1
        cost[y][x+i]=c+1
        q.append((x+i,y))
      else:
        break
    for i in range(1,k+1):
      if x-i>=0 and checked[y][x-i][1]==0 and board[y][x-i]=='.' and c<cost[y][x-i]:
        checked[y][x-i][1]=1
        cost[y][x-i]=c+1
        q.append((x-i,y))
      else:
        break
    for i in range(1,k+1):
      if y+i<h and checked[y+i][x][2]==0 and board[y+i][x]=='.' and c<cost[y+i][x]:
        checked[y+i][x][2]=1
        cost[y+i][x]=c+1
        q.append((x,y+i))
      else:
        break
    for i in range(1,k+1):
      if y-i>=0 and checked[y-i][x][3]==0 and board[y-i][x]=='.' and c<cost[y-i][x]:
        checked[y-i][x][3]=1
        cost[y-i][x]=c+1
        q.append((x,y-i))
      else:
        break
  if cost[gy][gx]==10**18:
    print(-1)
  else:
    print(cost[gy][gx])
calc()

Measured memory_bytes: 213892
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n;
  cout << 360 / __gcd(360, n) << endl;
  return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    long long int n,p,q,r,cur,i,j,k,x,y,z,c1=0,c2=0,c3=0,f=0;
    //cin>>n>>k;
    //map<long long int,long long int>m;
    vector<long long int>v;
    //set<long long int>s;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>x;
        c1=0;
        while(x%2==0)
        {
            x=x/2;
            c1++;
        }
        v.push_back(c1);
    }
    sort(v.begin(),v.end());
    cout<<v[0]<<endl;



    return 0;
}




Measured memory_bytes: 256
import math


def sd(n, students, average):
    rlt = 0
    for i in students:
        rlt += (i - average) ** 2

    rlt = rlt / n
    return math.sqrt(rlt)


if __name__ == '__main__':
    while True:
        n = int(input())
        if not n:
            break
        students = list(map(int, input().split()))

        average = sum(students) / n
        ans = sd(n, students, average)
        print(round(ans, 8))

Measured memory_bytes: 7772
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  int a;
  cin >> a;
  rep(i,a){
    cout << "ACL";
  }
}


Measured memory_bytes: 3548