akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;

void solve()
{	
	int n; cin >> n;
	int odd = 0;
	rep(i, n)
	{
		int tmp; cin >> tmp;
		if(tmp % 2 == 1)odd++;
	}
	if(odd % 2 == 0)cout << "YES" << endl;
	else cout << "NO" << endl;
	return;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    cin >> str;
    int i,result=0,n;
    for(i=0;i<str.size();i++)
    {
        n=str[i]-48;
        result= result + n;
    }
    if(result%9==0)
    {
        cout << "Yes" << endl;
    }
    else
        cout << "No" <<endl;

}



Measured memory_bytes: 3724
#include<bits/stdc++.h>
#define ll long long 
#define P pair<ll, ll>
using namespace std;

int main(){
    ll n;
    cin >> n;
    vector<ll>v1(n);
    vector<ll>v2(n);
    vector<ll>v3(n);
    vector<ll>v4(n);
    for(int i=0;i<n;i++){
        ll x, y;
        cin >> x >> y;
        v1[i] = x+y;
        v2[i] = x-y;
        v3[i] = -x+y;
        v4[i] = -x-y;
    }

    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    sort(v3.begin(), v3.end());
    sort(v4.begin(), v4.end());


    ll ans = 0;
    for(int i=0;i<n;i++){
        ans = max(ans, v1[i]+v4[n-1]);
        ans = max(ans, v2[i]+v3[n-1]);
        ans = max(ans, v3[i]+v2[n-1]);
        ans = max(ans, v4[i]+v1[n-1]);
    }

    cout << ans << endl;

}

Measured memory_bytes: 9576
from itertools import accumulate

n = int(input())
s = input()
acc_cnt_a = [0] * (n + 1)
acc_cnt_b = [0] * (n + 1)
acc_cnt_ab = [0] * (n + 1)
c_loc = []
cnt_a = 0
for i, c in enumerate(s):
    if c == 'D':
        acc_cnt_a[i] += 1
        cnt_a += 1
    elif c == 'M':
        acc_cnt_b[i] += 1
        acc_cnt_ab[i] += cnt_a
    elif c == 'C':
        c_loc.append(i + 1)
acc_cnt_a = [0] + list(accumulate(acc_cnt_a))
acc_cnt_b = [0] + list(accumulate(acc_cnt_b))
acc_cnt_ab = [0] + list(accumulate(acc_cnt_ab))

q = int(input())
buf = []
for k in map(int, input().split()):
    ans = 0
    for r in c_loc:
        l = r - k
        if l > 0:
            rejected_a = acc_cnt_a[l]
            cnt_internal_b = acc_cnt_b[r] - acc_cnt_b[l]
            cnt_internal_ab = acc_cnt_ab[r] - acc_cnt_ab[l]
            ans += cnt_internal_ab - rejected_a * cnt_internal_b
        else:
            ans += acc_cnt_ab[r]
    buf.append(ans)
print('\n'.join(map(str, buf)))


Measured memory_bytes: 147172
def check (S):
    if S[0] != 'A':
        return False
    
    if S[len(S)-1] == 'C':
        return False;

    cnt = 0;
    for i in range(2, len(S)-1):
        if(S[i] == 'C'):
            cnt = cnt + 1
            
    if cnt != 1:
        return False

    for i in range(1, len(S)):
        if S[i] != 'C' and ('A' <= S[i] and S[i] <= 'Z'):
            return False

    
    return True

S = input()
ans = check(S)
if ans == True:
    print ("AC")
else:
    print ("WA")


Measured memory_bytes: 3064
S = input()

BW = "01" * (10**5)
WB = "10" * (10**5)

ans = 0
if S[0] == "0":
    for i in range(len(S)):
        if S[i] != BW[i]:
            ans += 1
else:
    for i in range(len(S)):
        if S[i] != WB[i]:
            ans += 1
            
print(ans)

Measured memory_bytes: 3504
class UnionFind:
    def __init__(self,n):
        self.n = n
        self.p = [i for i in range(n)]
        self.rank = [0]*n

    def same(self,x,y):
        return self.root(x)==self.root(y)

    def root(self,x):
        if x!=self.p[x]:self.p[x] = self.root(self.p[x])
        return self.p[x]

    def unite(self,x,y):
        x = self.root(x)
        y = self.root(y)
        if self.rank[y]<self.rank[x]:
            self.p[y] = x
        else:
            self.p[x] = y
            if self.rank[y]==self.rank[x]:
                self.rank[y]+=1

def main():
    n,q = map(int,input().split())
    UF = UnionFind(n)
    for _ in range(q):
        a,b,c = map(int,input().split())
        if a == 0:UF.unite(b,c)
        else:
            if UF.same(b,c):print(1)
            else           :print(0)


if __name__ == '__main__':
    main()




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

const int NMAX = 55;
int a[NMAX], n, b[NMAX];

bool sorted(int v[]) {
    for(int i = 1; i < n; i++) {
        if(v[i] > v[i + 1]) {
            return 0;
        }
    }
    return 1;
}
int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    bool ok = 0;
    if(sorted(a)) {
        ok = 1;
    }
    for(int i = 1; i <= n && ok == 0; i++) {
        for(int j = i + 1; j <= n && ok == 0; j++) {
            for(int k = 1; k <= n; k++) {
                b[k] = a[k];
            }
            swap(b[i], b[j]);
            if(sorted(b)) {
                ok = 1;
            }
        }
    }
    if(ok) {
        cout << "YES";
    } else {
        cout << "NO";
    }
    return 0;
}


Measured memory_bytes: 3552
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main(void){
    int i,j;
    int m,h,len;
    char S[250]={0},X[250]={0};

    while(1){
        char S[250]={0},X[250]={0};
        scanf("%s",S);
        if(S[0]=='-') break;

        scanf("%d",&m);
        len=strlen(S);
        for(i=0;i<m;i++){
            scanf("%d",&h);
            for(j=h;j<len;j++){
                X[j-h]=S[j];
            }
            for(j=0;j<h;j++){
                X[j+len-h]=S[j];
            }
            strcpy(S,X);
        }
        printf("%s\n",S);
    }

    return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n,ans = 0,c;
    cin >> n;
    int v[n];
    rep(i, n)cin >> v[i];
    rep(i, n){
        cin >> c;
        if (v[i] - c > 0) {
            ans += v[i] - c;
        }
    }
    cout << ans << endl;
    return 0;
}


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

class D{
    public:
    int f[6];
    D(){}
    void rollx(){
        roll(0,2,5,3);
    }
    void rolly(){
        roll(0,1,5,4);
    }
    void rollz(){
        roll(1,2,4,3);
    }
    void roll(int a,int b,int c,int d){
        int t=f[a];
        f[a]=f[b];
        f[b]=f[c];
        f[c]=f[d];
        f[d]=t;
    }
};

bool same(D c,D d){
    for(int i=0;i<6;i++){
        if(c.f[i]!=d.f[i])return false;
        
    }
    return true;
}

bool same1(D c,D d){
    for(int i=0;i<6;i++){
        for(int j=0;j<4;j++){
            if(same(c,d))return true;
            c.rollz();
        }
        if(i%2==0)c.rolly();
        else c.rollx();
    }
    return false;
}

bool same2(D c[],int n){
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            if(same1(c[i],c[j]))return false;
        }
    }
    return true;
}

int main(){
    D c[100];
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<6;j++)cin>>c[i].f[j];
    }
    if(same2(c,n))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

ll re[10000002]={0,1};

int main()
{
	ios::sync_with_stdio(false);
	ll n,w=0;
	cin>>n;
	for(ll i=2;i<=n;i++)
	{
		re[i]++;
		for(ll j=i;j<=n;j+=i)
		{
			re[j]++;
		}
	}
	for(ll i=1;i<=n;i++)
	w+=i*re[i];
	cout<<w;
	return 0;
}




Measured memory_bytes: 81772
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=1e5+10;
int n,v,p;
ll A[maxn],m;
ll B[maxn];
bool check(int x)
{
//	cout<<"c "<<x<<endl;
	ll all=m*v;
	all-=min(v,(n-x))*1ll*m;
	ll val=A[x]+m;
	for(int i=x-1;i>=0;i--)
	{
		B[i]=max(0ll,min(m,min(all,val-A[i])));
		all-=B[i];
	}
	for(int i=0;i<x;i++)
	{
		ll dif=min(all,m-B[i]);
		all-=dif;
		B[i]+=dif;
	}
	int cnt=0;
	for(int i=0;i<x;i++)cnt+=(A[i]+B[i])>val;
	return cnt<p;
}
int main()
{
	scanf("%d%lld%d%d",&n,&m,&v,&p);
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&A[i]);
	}
	sort(A,A+n);
	reverse(A,A+n);
	int l=p-1,r=n;
	while(l+1<r)
	{
		int mid=(l+r)>>1;
		if(check(mid))l=mid;
		else r=mid;
	//	cout<<mid<<" "<<l<<' '<<r<<endl;
	}
	r=l;
	while(r<n&&A[r]==A[l])r++;
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

class Main{

	public static void main(String[] args) {



		Scanner scanner = new Scanner(System.in);

		String string = scanner.next();
		int l = string.length();
		StringBuilder sb = new StringBuilder();
		for(int i = 0;i <l-1;i++){
			if(i % 2 == 0){
				sb.append(string.substring(i, i+1));
			}
			
			
		}
		if(l % 2 == 1){
			sb.append(string.substring(l-1));
		}
		System.out.println(sb.toString());
	}


}

class Pair implements Comparable{
	int from;
	int middle;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}





Measured memory_bytes: 28056
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

int main(){
  vector<vector<int>> s;
  int n[100]={};
  int ma[100]={};
  vector<int> mi(100,1000);
  int tmp,c = 0;
  for(int i=0;i<100;i++){
    cin >> n[i];
    if(!n[i])break;
    s.push_back(vector<int>());

    for(int j=0;j<n[i];j++){
      cin >> tmp;
      s[i].push_back(tmp);
      ma[i] = max(ma[i],tmp);
      mi[i] = min(mi[i],tmp);
    }
    c++;
  }
  int ans;
  for(int i=0;i<c;i++){
    ans = floor((accumulate(s[i].begin(),s[i].end(),0) - ma[i] - mi[i])/(s[i].size()-2));
    cout << ans << endl;
  }


  return 0;
}

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

int Euler_phi(int n) {
    int ret = n;
    for(int i=2; i*i <= n; i++) {
        if(n % i == 0) {
            ret -= ret / i;
            while(n % i == 0) n /= i;
        }
    }
    if(n != 1) ret -= ret / n;
    return ret;
}

int main(void){
    int n; cin >> n;
    cout << Euler_phi(n) << endl;
}

Measured memory_bytes: 3096
#include <iostream>
using namespace std;
int main()
{	int n,m,t;
	cin>>n>>m;
	if(m-n<10000000)
	{
		while(m%n) n++;
		cout<<m/n;
	}
	else
	{
		t=m/n;
		while(m%t) t--;
		cout<<t;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<deque>
using namespace std;
const int maxn=1e3+5;
bool is[maxn][maxn];
typedef pair<int,int>Node;
Node s,e;
int h,w,dx[]={0,0,1,-1},dy[]={-1,1,0,0},d[maxn][maxn];
char mp[maxn][maxn];
void bfs(){
    memset(d,0x3f,sizeof(d));
    deque<Node>q;
    d[s.first][s.second]=0;
    q.push_front(s);
    while(!q.empty()){
        Node n1=q.front();
        q.pop_front();
        if(is[n1.first][n1.second])continue;
        is[n1.first][n1.second]=1;
        for(int i=0;i<4;++i){
            int xx=n1.first+dx[i],yy=n1.second+dy[i];
            if(xx<1||yy<1||xx>h||yy>w||mp[xx][yy]=='#'||d[xx][yy]<=d[n1.first][n1.second])continue;
            d[xx][yy]=d[n1.first][n1.second];
            q.push_front({xx,yy});
        }
        for(int i=n1.first-2;i<=n1.first+2;++i){
            if(i<1||i>h)continue;
            for(int j=n1.second-2;j<=n1.second+2;++j){
                if(j<1||j>w||mp[i][j]=='#'||d[i][j]<=d[n1.first][n1.second]+1)continue;
                d[i][j]=d[n1.first][n1.second]+1;
                q.push_back({i,j});
            }
        }
    }   
}
int main(){
    scanf("%d%d",&h,&w);
    scanf("%d%d%d%d",&s.first,&s.second,&e.first,&e.second);
    for(int i=1;i<=h;++i)
        scanf("%s",mp[i]+1);
    bfs();
    if(d[e.first][e.second]==0x3f3f3f3f)puts("-1");
    else cout<<d[e.first][e.second]<<endl;      
    return 0;
}

Measured memory_bytes: 9212
N,K = map(int,input().split())
P = list(map(int,input().split()))

N0 = 2**(N-1).bit_length()
INF = 2**31-1
data_m = [INF]*(2*N0)
data_M = [INF]*(2*N0)

def update(k, x, data):
    k += N0-1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = min(data[2*k+1], data[2*k+2])

def query(l, r, data):
    L = l + N0; R = r + N0
    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = min(s, data[R-1])

        if L & 1:
            s = min(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s

for i in range(N):
    update(i, P[i], data_m)
    update(i, -P[i], data_M)

s = [1]*N
r = 0
for l in range(N):
    r = max(l,r)
    while r < N-1:
        if P[r]<P[r+1]:
            r += 1
        else:
            break
    s[l] = r-l+1
    
ans = 0
if s[0]<K:
    ans += 1

for i in range(1,N-K+1):
    if query(i-1,i+K,data_m)!=P[i-1] or query(i-1,i+K,data_M)!=-P[i+K-1]:
        if s[i]<K:
            ans += 1

if max(s) >= K:
    ans += 1

print(ans)

Measured memory_bytes: 93136
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define mod 1000000007
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes printf("Yes\n")
#define no printf("No\n")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using ull=unsigned long long;
using vi=vector<int>;
using pint=pair<int,int>;

const int INF=1LL<<55;

int n;
string s;

int maxans = 0;
int ans;

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

    cin>>n;
    cin>>s;

    REP(i,1,n-1){
        set<char>x;
        set<char>y;
        rep(j,n){
            if(j<i){
                x.insert(s[j]);
            }else{
                y.insert(s[j]);
            }
        }
        ans = 0;
        for(auto c : x){
            if(y.find(c) != y.end()) ans++;
        }
        maxans = max(ans, maxans);
    }

    cout<<maxans<<endl;

    return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int a[n+1];
	int b[n];
	b[0] = 1e9;
	for(int i=1; i<=n-1; i++) cin >> b[i];
	for(int i=1; i<=n-1; i++){
		a[i] = min(b[i-1], b[i]);
		a[i+1] = b[i];
	}
	ll ans = 0;
	for(int i=1; i<=n; i++) ans += a[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iterator>
#include<algorithm>
#include<math.h>
#include<vector>
#include<stack>
#include<string.h>
#include<map>
#include<bitset>
#include<set>
#include<deque>
#include<sstream>
#include<queue>
#include<list>
#include <fstream>
#include <iomanip>
#define ln 1000005
#define pi acos(-1.0)
#define pb push_back
#define mp nake_pair
using namespace std;
int main()
{
    //std::ofstream outfile;
    //outfile.open("acm", std::ios_base::app);
    //outfile<<"write here"<<endl
    //outfile.close();
    
    int n,m;
    cin>>n>>m;
    
    double arr[n];
    
    double count1=0,sum=0,akash=1.0/(4.0*(double)m);
    
    for(int i=0;i<n;i++){
        cin>>arr[i];
        sum+=arr[i];
    }
    double at_list=(sum*akash);
    for(int i=0;i<n;i++){
        if(arr[i]>=at_list){
            count1++;
        }
    }
    if(count1>=m){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
    return 0;
}



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

#define fast ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define fl(i,a,n) for(int i=a; i<=n; i++)
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define test()  int tt;  cin>>tt;  while(tt--)
#define nl  cout<<"\n"
#define pii pair<int,int>
#define sz(v) ((int)(v).size())
#define get(a,st,en)  fl(i,st,en)       cin>>a[i]
#define pr(a,st,en)     fl(i,st,en)     cout<<a[i]<<" \n"[i==en]
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)    {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}
const int mod = 998244353;
// credits @Benq
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do smth instead of nothing and stay organized
*/
ll inf = 1e18;
void solve()    {
        ll n;  cin>>n;
        ll arr[n];
        ll ans = 1;
        for(int i=0; i<n; i++)  {
                cin>>arr[i];
                if(arr[i] == 0) {
                        ans = 0;
                }
        }
        if(ans == 0)    {
                cout<<ans;
                return;
        }
        for(int i=0; i<n; i++)  {
                if(arr[i] <= inf/ans)     {
                        ans *= arr[i];
                }
                else    {
                        cout<<-1;
                        return;
                }
        }
        cout<<ans;
        
}
int main()  {
    fast;
    //test()
        solve();
}


Measured memory_bytes: 4436
#include <bits/stdc++.h>
//一括include
using namespace std;
int main()
{
    int n;
    int x;
    int m[100010] = {};
    int num = 0;
    cin >> n >> x;
    for (int i = 0; i < n; i++)
    {
        cin >> m[i];
        num += m[i];
    }
    x -= num;
    sort(m, m + n);
    cout << x / m[0] + n << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define Rep(i, N) for(int i = 0; i < N; i++)
#define F first
#define S second
typedef pair<int,int> Pi;
#define INF 1 << 28

int mx[] = {-1,0,1,1,1,0,-1,-1};
int my[] = {1,1,1,0,-1,-1,-1,0};

int main()
{
  int H, W;
  char mas[1005][1005];
  int cnt[1005][1005];
  int mc[1005][1005];
  int maxv = 0;
  queue<Pi>que;
  fill_n(*mas, 1005 * 1005, '.');
  fill_n(*mc, 1005 * 1005, INF);
  cin >> H >> W;
  Rep(i, H) Rep(j, W) cin >> mas[i + 1][j + 1];

  for(int i = 1; i <= H; i++) {
    for(int j = 1; j <= W; j++) {
      int cnt = 0;
      Rep(k, 8) {
	int ny = i + my[k], nx = j + mx[k];
	if(mas[ny][nx] == '.') cnt++;
      }
      if(cnt >= mas[i][j] - '0') {
	que.push(Pi(i, j));
	mc[i][j] = 1;
      }
    }
  }
  while(!que.empty()) {
    int y = que.front().F, x = que.front().S; que.pop();
    Rep(i,8) {
      int ny = y + my[i], nx = x + mx[i];
      if(mas[ny][nx] == '.' || mc[ny][nx] != INF || ++cnt[ny][nx] < mas[ny][nx] - '0')continue;
      que.push(Pi(ny, nx)); mc[ny][nx] = mc[y][x] + 1;
      maxv = max(maxv, mc[ny][nx]);
    }
  }
  cout << maxv << endl;

  return 0;
}

Measured memory_bytes: 12100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll X,Y;
    cin >>X>>Y;
    
    cout << X + Y/2 << endl;


    return 0;
    

}

Measured memory_bytes: 3588
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	auto N=in(),S=in();
	vector<ll> A=vecin<ll>(N);
	map<int,int> M;

	int ans = 1<<30;
	int left = 0,right = 0,find = 0;
	while(true){
		while(right<N && find<S){
			if(A[right]<=S && !(M[A[right]]++)){
				find++;
			}
			right++;
		}
		if(find==S){
			while(left<right && find==S){
				if(A[left]<=S && !(--M[A[left]])){
					find--;
				}
				ans = min(ans,right-left);
				left++;
			}
		}
		else break;
	}
	
	out(ans==1<<30 ? 0 : ans);
	return 0;
}



Measured memory_bytes: 8252
while True:
 m,f,r=map(int,input().split())
 if m==f==r==-1 : break

 if m==-1 or f==-1 :
   print('F')

 elif (m+f)>=80 :
   print('A')

 elif 65<= (m+f) and (m+f)<80 :
   print('B')

 elif 50<= (m+f) and (m+f)<65 :
   print('C')

 elif 30<=(m+f) and (m+f)<50 :
   if 50<=r :
    print('C')
   else:
    print('D')

 elif (m+f)<30 :
   print('F')

Measured memory_bytes: 6724
#include <cstdio>
#include <cstring>
const int N = 400 + 10;
typedef long long ll;
int n, a[N];
ll f[N][N], sum[N];
ll mi(ll a, ll b)
{
	return a > b ? b : a;
}
ll dp(int l, int r)
{
	if (l == r) return 0;
	if (~f[l][r]) return f[l][r];
	f[l][r] = 1e18;
	for (int i = l; i < r; i++)
		f[l][r] = mi(f[l][r], dp(l, i) + dp(i + 1, r) + sum[r] - sum[l - 1]);
	return f[l][r];
}
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		sum[i] = sum[i - 1] + a[i];
	}
	memset(f, -1, sizeof(f));
	printf("%lld", dp(1, n));
}

Measured memory_bytes: 1536
const lines=readlines()
state=0
input()=lines[global state+=1]
int(s::String)=parse(Int,s)
intSub(s::SubString{String})=parse(Int,s)
intLine(s::Array{SubString{String},1})=map(intSub,s)
function main()
    const INF=2^60
    a,b,q=input()|>split|>intLine
    s=Array{Int}(a+2)
    s[1],s[a+2]=-INF,INF
    for i in 2:a+1
        s[i]=int(input())
    end
    t=Array{Int}(b+2)
    t[1],t[b+2]=-INF,INF
    for i in 2:b+1
        t[i]=int(input())
    end
    for _ in 1:q
        x=int(input())
        m=INF
        i=searchsortedlast(s,x)
        j=searchsortedlast(t,x)
        for v in view(s,i:i+1)
            for w in view(t,j:j+1)
                m=min(m,abs(x-v)+abs(v-w),abs(x-w)+abs(w-v))
            end
        end
        println(m)
    end
end
main()

Measured memory_bytes: 174496
#include <stdio.h>

int main(void){
  int N;
  int A[200],B[200];
  int i,k;
  for(i=0;i<200;i++){
    A[i]=0;
    B[i]=0;
  }
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<N;i++){
    scanf("%d",&B[i]);
  }
  long int sumA=0,sumB=0;
  long int max=0;

  for(k=0;k<N;k++){
    sumA=0;sumB=0;
    for(i=0;i<=k;i++){
      sumA += A[i];
    }
    for(i=0;i<=N-k;i++){
      sumB += B[N-i];
    }

    if((sumA+sumB) > max)
      max = sumA+sumB;
  }
  
  printf("%d",max);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

long long n;
int main() {
    cin >> n;
    vector<long long> a(n, 0);
    vector<long long> b(n, 0);
    vector<long long> c(n, 0);
    for(int i = 0; i < n; ++i) cin >> a.at(i);
    for(int i = 0; i < n; ++i) cin >> b.at(i);
    for(int i = 0; i < n; ++i) cin >> c.at(i);

    sort(a.begin(), a.end());
    sort(c.begin(), c.end());

    long long ans = 0;
    for(int i = 0; i < n; ++i) {
        int center = b.at(i);
        long long ano = lower_bound(a.begin(), a.end(), center) - a.begin();
        long long cno = upper_bound(c.begin(), c.end(), center) - c.begin();
        long long total = ano*(n-cno);
        ans += total;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	vector<int> v(3);
	rep(i, 3) cin >> v[i];
	sort(all(v));
	rep(i, 3)
		printf("%d%c", v[i], i == 2 ? '\n' : ' ');
}




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

int main(int argc, char const* argv[])
{
  while (true) {
    int n, r;
    std::cin >> n >> r;
    if (n == 0 && r == 0) {
      break;
    }
    std::vector<int> deck(n);
    for (int i = 0; i < n; ++i) {
      deck[i] = n - i;
    }
    for (int i = 0; i < r; ++i) {
      int p, c;
      std::cin >> p >> c;
      std::vector<int> tmp(c);
      for (int j = 0; j < c; ++j) {
        int x = deck[p - 1];
        deck.erase(deck.begin() + p - 1);
        tmp[j] = x;
      }
      deck.insert(deck.begin(), tmp.begin(), tmp.end());
    }
    std::cout << deck[0] << std::endl;
  }
  return 0;
}

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

 

int main() {
    char X, Y;
    cin >> X >> Y;
    if (X - Y > 0) cout << ">" << endl;
    else if (X - Y == 0) cout << "=" << endl;
    else cout << "<" << endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const int MAX = 100010;
static const ll INFTY = 1e12;
static const int NUMMAX = 300;


int main(){

  int A, B;
  int ans;

  cin >> A >> B;

  if( B < 10 && A < 10 ){
    ans = A * B;
  } else {
    ans = -1;
  }

  cout << ans << endl;

  return 0;
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
flag=0
for i in range(N):
  if A[i]==0:
    flag=1
sflag=0
ans=1
for i in range(N):
  ans*=A[i]
  if ans>10**18:
    sflag=1
    break
  if sflag==1:
    break
if sflag==0:
  print(ans)
elif sflag==1 and flag==1:
  print("0")
else:
  print("-1")

Measured memory_bytes: 21784
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll              long long
#define pi              pair<int,int>
#define pll             pair<ll,ll>
#define pb              push_back
#define F               first
#define S               second
#define vi              vector<int>
#define vll             vector<ll>
#define endl            '\n'
#define all(v)          (v).begin(),(v).end()
#define FOR(i,a,b)      for(int i=a;i<b;i++)
#define MP(a,b)         make_pair(a,b)
#define debug(x)        cerr<< #x << " : " << x << endl;
#define debugp(p)       cerr<< #p << " : " << "(" << (p).first << "," << (p).second << ")\n";
#define debugv(v)       cerr<< #v << " : " << "["; for(int i = 0; i < (v).size(); i++) cerr << v[i] << " "; cerr<<"]\n";
#define debugs(m)       cerr<< #m << " : [ "; for(auto itr = m.begin(); itr != m.end(); itr++) cerr <<*itr << " "; cerr << "]\n";
#define debugm(m)       cerr<< #m << " : [ "; for(auto itr = m.begin(); itr != m.end(); itr++) cerr <<"(" << itr->first << "," << itr->second << ") "; cerr << "]\n";

/* ordered set: 
tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
member functions :
1. order_of_key(k) : number of elements strictly lesser than k
2. find_by_order(k) : k-th element in the set
*/

inline ll modexp(ll x, ll ex , ll md) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}

const int inf = 1e9 + 7;

const ll mod = 1e9 + 7;
void solve(){
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<ll> suff (n + 1);
    suff[n] = 0;
    for (int i = n - 1; i >= 0; i--){
        suff[i] = (a[i] + suff[i + 1]) % mod;
    }
    ll ans = 0;
    for (int i = 0; i < n; i++){
        ans += (a[i] * suff[i + 1]) % mod;
        ans %= mod;
    }
    cout << ans << endl;
}
int main(){
    ios :: sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr);
    
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    #ifdef LOCAL
    cerr << "Time elapsed\t: " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";       
    #endif
}



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

//#define int long long
#define reps(i,s,n) for(ll (i)=(s);(i)<(ll)(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,n+1)
#define repst(i,s,n) reps(i,s,n+1)
#define reprt(i,n,t) for(ll (i)=(n);(i)>=t;--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) cout<<#x" : "<<ln,for(int (i)=0;i<n;++i){cout<<x[i]<<(i==n-1?'\n':' ');}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// 予定d[i-1]を終えた後の目的地までの距離をa[i]とする
// d[i]を好きな数字に変えられる <=> a[i]を[0,a[i-1]]の範囲で好きな値に変えられる
// d[i]以降の予定を全て終えても目的地に辿り着けない最小の距離b[i]が求まればクエリの答えはa[q-1]>=b[q]?でわかる
// まずb[n]=1で後ろから埋めていく
// i) b[i+1] <= d[i]/2 のとき b[i] = b[i+1]
// 	b[i+1]の距離からd[i]を入力しても動かないからd[i+1]〜を入力しても目的地に着けない
// 	これより近い場合d[i]を入力しても動かないのは同じだけどd[i+1]を入力する時点でb[i+1]より近い場所にいるから目的地に行けちゃう
// ii) それ以外のとき b[i] = b[i+1] + d[i]

int n, a[500500], d[500500], b[500500], q, t;

signed main() {
	cin >> n >> a[0];
	rep(i,n) {
		cin >> d[i];
		t = abs(a[i] - d[i]);
		a[i+1] = min(t,a[i]);
	}
	b[n] = 1;
	repr(i,n-1) {
		if (b[i+1]<=d[i]/2) b[i] = b[i+1];
		else b[i] = b[i+1] + d[i];
	}
	cin >> q;
	while (q--) {
		cin >> t;
		cout << (a[t-1]>=b[t] ? "YES" : "NO") << ln;
	}
}

Measured memory_bytes: 7808
#include <cstdio>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;
int main(void) {
  ll x, y, z;
  scanf("%lld%lld%lld", &x, &y, &z);
  for(int i = 0; ; ++i) {
    if(y*i+z*(i+1) > x) {
      printf("%d\n", i-1);
      break;
    }
  }
  return 0;
}


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

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        ConsoleInput ci=new ConsoleInput();
        long l=ci.nextLong();
        out.println(l*l*l);
        out.flush();
    }
}
class ConsoleInput{
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int cnt = 0;
    private int buffers = 0;
    private boolean hasNextByte() {
        if (cnt < buffers) {
            return true;
        }else{
            cnt = 0;
            try {
                buffers = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buffers <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[cnt++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[cnt])) cnt++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        if (!hasNext()) throw new NoSuchElementException();
        int n = 0;
        boolean bo = false;
        int b = readByte();
        if (b == '-') {
            bo = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return bo ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}



Measured memory_bytes: 24152
MOD = 998244353


def main():
    import sys
    input = sys.stdin.buffer.readline
    N, S = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    dp = [[0]*(S+1) for _ in range(N+1)]
    dp[0][0] = 1
    for i in range(N):
        dp[i+1][0] += 1
        for j in range(S+1):
            dp[i+1][j] += dp[i][j]
            dp[i+1][j] %= MOD
            if j + A[i] <= S:
                dp[i+1][j+A[i]] += dp[i][j]
                dp[i+1][j+A[i]] %= MOD
    ans = sum(dp[i][S] for i in range(N+1)) % MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 113116
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		int d = stdIn.nextInt();
		int cnt = 0;
		
		for(int i = 0; i < n; i++) {
			int x = stdIn.nextInt();
			int y = stdIn.nextInt();
			
			if(d >= Math.sqrt(x*(long)x + y * (long)y)) {
				cnt++;
			}
			
		}
		System.out.println(cnt);
	}

}


Measured memory_bytes: 59128
#include <stdio.h>

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

int lcm(int a, int b){
  if(a < b)
    return a*b/gcd(b,a);
  else
    return a*b/gcd(a,b);
}

int main(){
  int i,n,gcd1;
  scanf("%d",&n);
  int a[n];

  for(i=0; i<n; i++)
    scanf("%d",&a[i]);
  
  gcd1 = lcm(a[0],a[1]);
  
  for(i=2; i<n; i++)
    gcd1 = lcm(gcd1,a[i]);
    
  printf("%d\n",gcd1);
  return 0;
}

Measured memory_bytes: 596
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;

int main(){
  string str;
  cin >> str;
  bool easy = true;
  REP(i, str.size()){
    if(i % 2 == 0){
      if(str[i] == 'L'){
        easy = false;
        break;
      }
    }else{
      if(str[i] == 'R'){
        easy = false;
        break;
      }
    }
  }

  if(easy) printf("Yes\n");
  else printf("No\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v){
  const char* dlm = "";
  for(const auto& x:v) cout << exchange(dlm, " ") << x;
  return os;
}
int32_t main(){
  size_t n; cin>>n;
  vector<vector<size_t>> adj(n);
  for(size_t i=0; i<n; ++i){
    size_t u,k; cin>>u>>k;
    adj[u-1].resize(k);
    for(auto&& x:adj[u-1]) cin>>x;
  }
  vector<vector<size_t>> m(n,vector<size_t>(n,0));
  for(size_t i=0; i<n; ++i){
    for(const auto& x:adj[i]) m[i][x-1]=1;
  }
  for(const auto& x:m) cout<<x<<endl;
}


Measured memory_bytes: 3236
/*
    coder:xxjAc
    name:Jury Marks
    time：2017/7/13 
*/
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
int a[200007];
int main(){
	int n;
	cin>>n;
	long long nw=0;
	for (int i=0;i<n;i++){
		cin>>a[i];
		nw+=a[i];
	}
	long long ans=76891462189;
	int i=n-1;
	while (i>=1){
		nw-=a[i]*2;
		i--;
		if (nw>=0){
			ans=min(ans,nw);
		}
		else{
			ans=min(ans,0-nw);
		}
	}
	cout<<ans<<endl;
	return 0;
} 

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

typedef long long ll;

int n;
int m;
int MAX_N=100001;
int MAX_M=100001;
int p[100001];
string s[100001];
int ac[100001];
int count[100001];

void solve();
int main(){
  scanf("%d",&n);
  scanf("%d",&m);
  for(int i=0;i<m;i++){
    scanf("%d",&p[i]);
    cin >> s[i];
  }
  for(int i=0;i<MAX_N;i++){
    ac[i]=0;
  }
  for(int i=0;i<MAX_N;i++){
    count[i]=0;
  }
  solve();
  return 0;
}

void solve(){
  for(int i=0;i<m;i++){
    int num = p[i];
    if(ac[num-1]==0){
      if(s[i]=="AC"){
        ac[num-1]=1;
      }
      else{
        count[num-1]=count[num-1]+1;
      }
    }
  }
  int total_ac=0;
  int total_penalty=0;
  for(int i=0;i<n;i++){
    if(ac[i]==1){
      total_ac+=1;
    }
  }
  for(int i=0;i<n;i++){
    if(ac[i]){
      total_penalty=total_penalty+count[i];
    }
  }
  printf("%d %d\n",total_ac,total_penalty);
}

Measured memory_bytes: 6912
#include <stdio.h>

int main(){
  int N;
  char S[100+1];
  int i=0;
  
  scanf("%d %s",&N,S);
  
  while(i < N && S[i] != 0){
    printf("%c",S[i]);
    i++;
  }
  if(S[i] != 0) printf("...");
  
  return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  cout << abs(a[2] - a[1]) + abs(a[1] - a[0]) << endl;
  return 0;
}

Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int m;
	cin>>m;
	cout<<48-m;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3576
class Array
  def cget(i)
    self[i % self.size]
  end
end

readlines.each do |l|
  n = l.to_i
  break if n==0
  table = Array.new(n){ Array.new(n) }
  x,y = n/2 + 1, n/2
  table[x][y] = 1
  (2..(n*n)).each do |i|
    x,y = x+1,y+1
    while table.cget(x).cget(y)
      x,y = x+1,y-1
    end
    table[x%n][y%n] = i
  end
  puts table.map{|i| i.map{|j| sprintf("%4d", j)}.join }
end

Measured memory_bytes: 6116
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll calc(int x, int y)
{
    ll ans = INF;

    reple(i, 1, x - 1)
    {
        //3枚にスライス
        {
            vll v(3);
            v[0] = (ll)y * i;
            v[1] = (ll)y * ((x - i) / 2);
            v[2] = (ll)y * (((x - i) / 2) + ((x - i) % 2));
            chmin(ans, *max_element(all(v)) - *min_element(all(v)));
        }

        //T字
        {
            vll v(3);
            v[0] = (ll)i * y;
            v[1] = (ll)(x - i) * (y / 2);
            v[2] = (ll)(x - i) * ((y / 2) + (y % 2));
            chmin(ans, *max_element(all(v)) - *min_element(all(v)));
        }
    }

    return ans;
}

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

    int H, W;
    cin >> H >> W;

    ll ans = INF;
    chmin(ans, calc(H, W));
    chmin(ans, calc(W, H));

    cout << ans << endl;

    return 0;
}

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

int main() {
    map<string, int> words;
    string word;
    while (cin >> word) {
        words[word]++;
    }
    pair<string, int> mode = make_pair("", 0);
    string maxLength = "";
    for (map<string, int>::iterator it = words.begin(); it != words.end(); it++) {
        if (it->second > mode.second) {
            mode = *it;
        }
        if (it->first.length() > maxLength.length()) {
            maxLength = it->first;
        }
    }
    cout << mode.first << " " << maxLength << endl;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>

using namespace std;

int main(int argc, char* argv[]){
  string a,b,c;
  cin >> a >> b >> c;
  if(a[a.length()-1]==b[0] && b[b.length()-1]==c[0]){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N),B(N,0);
  for(int i=1;i<N;++i){
    cin >> A[i];
    B[A[i]-1]++;
  }
  for(int i=0;i<N;++i){
    cout<<B[i]<<endl;
  }
 
    
}

Measured memory_bytes: 4792
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
const int MAXN = 2e5+7;
const int Inf = 0x3f3f3f3f;
 
int pre1[MAXN],pre2[MAXN];
 
int finds(int x,int *pre)
{
    return pre[x] == x? pre[x]:pre[x] = finds(pre[x],pre);
}
 
void join(int x,int y,int *pre)
{
    int px = finds(x,pre);
    int py = finds(y,pre);
    if( px!=py)
    {
        pre[px] = py;
    }
}
int main()
{
    int n,k,l;
    cin>>n>>k>>l;
    for(int i = 1;i<=n;i++)
        pre1[i] = i,pre2[i] = i;
    for(int i = 1;i<=k;i++)
    {
        int x,y;
        cin>>x>>y;
        join(x,y,pre1);
    }
    for(int i = 1;i<=l;i++)
    {
        int x,y;
        cin>>x>>y;
        join(x,y,pre2);
    }
    for(int i = 1;i<=n;i++)
    {
        finds(i,pre1);
        finds(i,pre2);
    }
    map<pair<int,int>,int> mp;
    for(int i = 1;i<=n;i++)
    {
        mp[make_pair(pre1[i],pre2[i])] ++;
    }
    for(int i = 1;i<=n;i++)
    {
        cout<<mp[make_pair(pre1[i],pre2[i])]<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 13568
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
ll n,m,i,j,k,l,t,arr[sz],brr[sz],crr[sz];
vector<ll>v;
int main()
{
    scanf("%lld %lld",&t,&n);
    while(t--)
    {
     scanf("%lld %lld",&j,&k);
    if((j*j)+(k*k)<=(n*n))
        l++;
    }
    printf("%lld\n",l);
    return 0;
}


Measured memory_bytes: 3824