akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 2e5 + 10;

VI G[MAX];
int ans[MAX];
void calc_dist() {
    fill(ans, ans + MAX, -1);
    queue<int> que;
    que.emplace(0);
    while (!que.empty()) {
        const auto el = que.front();
        que.pop();
        FORE(e, G[el]) if (ans[e] == -1) {
            ans[e] = el;
            que.emplace(e);
        }
    }
}

int main(void) {
    int N, M;
    cin >> N >> M;
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].EB(b);
        G[b].EB(a);
    }
    calc_dist();

    REP(i, N - 1) if (ans[i + 1] == -1) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    REP(i, N - 1) {
        cout << ans[i + 1] + 1 << endl;
    }
}


Measured memory_bytes: 13024
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b) {
    return b?gcd(b,a%b):a;
}
int main() {
    string s;
    while(cin>>s,s!="#") {
        vector<int> dir;
        int pos=0;
        while(pos<s.size()) {
            if(s[pos]=='n') pos+=5,dir.push_back(0);
            else if(s[pos]=='w') pos+=4,dir.push_back(1);
        }
        int a,b=1;
        if(dir[dir.size()-1]==0) a=0; else a=90;
        if(dir.size()>=2) {
            for(int i=dir.size()-2;i>=0;i--) {
                b*=2;
                a*=2;
                if(dir[i]==0) a-=90; else a+=90;
            }
            int g=gcd(a,b);
            a/=g;
            b/=g;
        }
        if(b>1) printf("%d/%d\n",a,b); else printf("%d\n",a);
    }
}

Measured memory_bytes: 3152
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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

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

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

void debug(VS &board){
	int h = board.size();
	rep(i,h){
		cout<<board.at(i)<<endl;
	}
	return;
}

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

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

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	LL n;
	string s;
	cin>>n>>s;
	LL r=0,g=0,b=0;
	for(int i=0;i<n;i++){
		if(s[i]=='R')r++;
		if(s[i]=='G')g++;
		if(s[i]=='B')b++;
	}
	LL ans = r*g*b;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int k=2*j-i;
			if(n<=k)continue;
			if(s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]){
				ans--;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) REP(i,0,n)
#define REP(i,l,r) for(int i=l;i<r;++i)
#define int long long
#ifdef DEBUG
#define dout cout
#else
std::stringstream dout;
#endif
using namespace std;
typedef pair<int,int> P;
//other libs

signed main(int argc, char * argv[]) {
	int n,q;
	cin>>n>>q;
	vector<vector<int>> edge(n+1);
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	vector<int> memo(n+1);
	fill(memo.begin(),memo.end(),0);
	rep(i,q){
		int p,x;
		cin>>p>>x;
		memo[p]+=x;
	}
	vector<bool> bo(n+1);
	fill(bo.begin(),bo.end(),false);
	queue<int> que;
	que.push(1);
	bo[1]=true;
	while(!que.empty()){
		int now=que.front();que.pop();
		rep(i,edge[now].size()){
			int ne = edge[now][i];
			if(!bo[ne]){
				memo[ne]+=memo[now];
				que.push(ne);
				bo[ne]=true;
			}
		}
	}
	rep(i,n){
		cout<<memo[i+1];
		if(i+1!=n)cout<<" ";
		else cout<<endl;
	}
}


Measured memory_bytes: 17904
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <set>

using namespace std;

// a >= b
int64_t gcd(int64_t a, int64_t b) { return !b ? a : gcd(b, a % b); }

int main() {
  int64_t a, b;
  cin >> a >> b;
  int ans = 1;
  auto g = gcd(a, b);
  set<int64_t> set;
  for (int64_t i = 2; i * i <= g; ++i) {
    while (g % i == 0) {
      if (set.find(i) == set.end()) ++ans;
      set.insert(i);
      g /= i;
    }
  }
  if (g != 1) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
typedef vector<int> Node;
typedef vector<Node> Graph;
int min_ans;
int N, M;
Graph G;
int dfs(int k, int cur, vector<bool> adj){
  if(min_ans <= cur) return INF;
  if(k == N){
    REP(i, N) if(!adj[i]) return INF;
    return min_ans = cur;
  }
  int res = INF;
  res = min(res, dfs(k + 1, cur, adj));
  REP(i, G[k].size()){
    int u = G[k][i];
    adj[u] = true;
  }
  adj[k] = true;
  res = min(res, dfs(k + 1, cur + 1, adj));
  return res;
}
int main(){
  while(cin >> N >> M && N){
    G = Graph(N);
    vector<int> perm(N);
    REP(i, N) perm[i] = i;
    random_shuffle(perm.begin(), perm.end());
    REP(i, M){
      int a, b;
      cin >> a >> b;
      a = perm[a];
      b = perm[b];
      G[a].push_back(b);
      G[b].push_back(a);
    }
    min_ans = INF;
    vector<bool> adj(N, false);
    cout << dfs(0, 0, adj) << endl;
  }
  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if (S == "Sunny") {
    cout << "Cloudy" << endl;
  }else if (S == "Cloudy") {
    cout << "Rainy" << endl;
  }else{
    cout << "Sunny" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define int long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<ll, ll> pii;
typedef vector<vector<ll>> mat;
const ll mod = 1e9+7;
const int MAXN = 1*1e5+5;

int32_t main() {
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++)
		cout << 'x';
	cout << endl;
}


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

int main (void){

    int N,M;
    cin >> N;
    int T[N+1];
    T[0] = 0;
    for (int i=1; i<N+1; i++ ){
        cin >> T[i];
    }
    cin >> M;

    int p;
    int sum ;
    int x ;
    for (int i=0; i<M; i++){
        cin >> p;
        cin >> x;
        sum = 0;
        for (int j=1 ;j<N+1; j++){

            if (j == p) sum += x;
            else sum += T[j];
        }
        cout << sum << endl;
    }


}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <string.h>
using namespace std;
int h[8][2]={{-1,-1},{-1,0},{-1,1},{0,1},{0,-1},{1,-1},{1,0},{1,1}};
int main()
{
    int a,b;
    int k,i,j;
    char c[52][52],s[52][52];
    while(scanf("%d%d",&a,&b)==2)
        {
            for(i=0;i<a;i++)
                {
                    memset(s[i],'0',sizeof(s[i]));
                    scanf("%s",c[i]);
                }
            for(i=0;i<a;i++)
            {
                for(j=0;j<b;j++)
                {
                    if(c[i][j]=='#')
                    {
                        s[i][j]='#';
                        for(k=0;k<8;k++)
                        {
                            if(i+h[k][0]>=0&&i+h[k][0]<a&&j+h[k][1]>=0&&j+h[k][1]<b&&c[i+h[k][0]][j+h[k][1]]!='#')
                                s[i+h[k][0]][j+h[k][1]]++;
                        }
                    }
                }
                s[i][j]='\0';
            }
            for(i=0;i<a;i++)
                printf("%s\n",s[i]);
        }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    string a, b;
    cin >> a >> b;
    
    int N = stoi(a + b);
    int s = sqrt(N);
    if (s * s == N) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

type unionFind struct {
	count   int
	parents []int
}

func NewUnionFind(n int) *unionFind {
	p := make([]int, n)
	for i := 0; i < n; i++ {
		p[i] = i
	}
	return &unionFind{
		count:   n,
		parents: p,
	}
}

func (u *unionFind) Root(x int) int {
	if u.parents[x] == x {
		return x
	}
	u.parents[x] = u.Root(u.parents[x])
	return u.parents[x]
}

func (u *unionFind) Unite(x, y int) {
	rx, ry := u.Root(x), u.Root(y)
	switch {
	case rx == ry:
		return
	case rx < ry:
		u.parents[rx] = ry
	case rx > ry:
		u.parents[ry] = rx
	}
}

func (u *unionFind) Same(x, y int) bool {
	return u.Root(x) == u.Root(y)
}

func main() {
	var n, m, a, b int
	fmt.Scan(&n, &m)
	var cnt = n
	u := NewUnionFind(n)
	for i := 0; i < m; i++ {
		fmt.Scan(&a, &b)
		if u.Same(a-1, b-1) {
			continue
		} else {
			u.Unite(a-1, b-1)
			cnt--
		}
	}
	if cnt > 0 {
		fmt.Println(cnt - 1)
	} else {
		fmt.Println(cnt)
	}
}


Measured memory_bytes: 6320
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#define ll long long
#define out(a) printf("%d",a)
#define ln printf("\n")
const int N=1e5+50;
const int MOD=1e9+7;
using namespace std;
int x,y;
int main()
{
	scanf("%d%d",&x,&y);
	out(x+(y>>1));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long llong;

bool prime(int x){
    if (x == 2) return true;

    if (x < 2 || x % 2 == 0) return false;

    int i = 3;
    double z = sqrt(x);
    while (i <= z){
        if (x % i == 0) return false;
        i += 2;
    }
    return true;
}

int main(){
    int x;
    cin >> x;

    int ans = x;
    while (1){
        if (prime(ans)) break;
        ans++;
    }

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

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    string s; cin >> s;
    int Q; cin >> Q;

    int flip = 0;

    string A = "", B = "";
    while(Q--) {
        int t; cin >> t;
        if(t == 1) {
            flip ^= 1;
        }
        if(t == 2) {
            int f; cin >> f; f--;
            char c; cin >> c;
            if((flip ^ f) == 0) {
                A += c;
            }
            else {
                B += c;
            }
        }
    }

    reverse(A.begin(), A.end());
    s = A + s + B;
    if(flip) reverse(s.begin(), s.end());
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 1348
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#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 ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;



int main(void) {
  int n;
  cin >> n;
  vi a(n);
  vll b;
  rep(i,n) cin >> a[i];
  sort(ALL(a));
  rep(i,n-1){
    if(a[i]==a[i+1]){
      b.push_back(a[i]);
      i++;
    }
  }
  if(b.size()<2){
    cout << 0 << endl;
    return 0;
  }
  //rep(i,b.size()) cout << b[i] << endl;
  cout << b[b.size()-1]*b[b.size()-2] << endl;

}




Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    string s,t;
    cin >> s >> t;
    int size = t.size();
    queue<string> ans;
    rep(i,0,s.size()-t.size()+1){
        int out = 0;
        rep(j,0,size){
            if(s[i+j]==t[j]||s[i+j]=='?'){
                continue;
            }else{
                out = 1;
                break;
            }
        }
        if(out==0){
            string kouho = s;

            rep(j,0,size){
                kouho[i+j]=t[j];
            }
            rep(j,0,s.size()){
                if(kouho[j]=='?'){
                    kouho[j]='a';
                }
            }
            ans.push(kouho);
        }
    }
    if(ans.empty()){
        cout<<"UNRESTORABLE"<<endl;
    }else{
        string final = ans.front();
        while(!ans.empty()){
            if(final>ans.front()){
                final = ans.front();
            }
            ans.pop();
        }
        cout<<final<<endl;
    }

    return 0;
}


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

using namespace std;

int main() {
  int n,m; cin >> n >> m;
  vector<vector<int> > graph(n);
  int u,v,s,t;
  for(int i=0;i<m;++i){
    cin >> u >> v;
    graph[u-1].push_back(v-1);
  }
  cin >> s >> t;
  s--,t--;
  
  vector<vector<long long> > dist(n,vector<long long>(3,-1));
  dist[s][0]=0;
  queue<pair<int,int> > q;
  q.push(make_pair(s,0));
  while(!q.empty()){
    pair<int,int> now=q.front(); q.pop();
    for(auto to : graph[now.first]){
      if(dist[to][(now.second+1)%3]!=-1) continue;
      dist[to][(now.second+1)%3]=dist[now.first][now.second]+1;
      q.push(make_pair(to,(now.second+1)%3));
    }
  }
  if(dist[t][0]==-1) cout << -1 << endl;
  else cout << dist[t][0]/3 << endl; 
  
  return 0;
}


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

int main(void)
{
int a[3];
int n;

for (n = 1; n <= 2; n++){
	scanf("%d",&a[n]);
}

if (a[1] == a[2]) printf("Yes");
else printf("No");

return 0;
}



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

namespace AtCoder
{
    public class Solver
    {
        private readonly IInputReader _inputReader;
        private readonly IOutputWriter _outputWriter;

        public Solver(IInputReader inputReader, IOutputWriter outputWriter)
        {
            _inputReader = inputReader;
            _outputWriter = outputWriter;
        }

        public void Solve()
        {
            var N = _inputReader.ReadLine().ToInt();
            var numbers = _inputReader.ReadLine().ToLongArray();

            var oddCount = numbers.Count(n => n % 2 == 1);
            var evenCount = numbers.Count(n => n % 2 == 0);

            while (true)
            {
                if (oddCount >= 2)
                {
                    oddCount -= 2;
                    evenCount += 1;
                }
                else if (evenCount >= 2)
                {
                    evenCount -= 2;
                    evenCount += 1;
                }
                else
                {
                    break;
                }
            }

            var result = (oddCount + evenCount) == 1;

            _outputWriter.WriteLine(result ? "YES" : "NO");
        }
    }


    internal class Program
    {
        static void Main(string[] args)
        {
            var reader = new ConsoleInputReader();
            var writer = new ConsoleOutputWriter();
            new Solver(reader, writer).Solve();
        }
    }

    public interface IInputReader
    {
        string ReadLine();
    }

    public interface IOutputWriter
    {
        void WriteLine(string output);
    }

    internal class ConsoleInputReader : IInputReader
    {
        public string ReadLine() => Console.ReadLine();
    }

    internal class ConsoleOutputWriter : IOutputWriter
    {
        public void WriteLine(string output) => Console.WriteLine(output);
    }

    public static class StringExtensions
    {
        public static char ToChar(this string text) => text[0];
        public static long ToInt(this string text) => int.Parse(text);
        public static long ToLong(this string text) => long.Parse(text);
        public static long[] ToLongArray(this string text) => text.Split(' ').Select(txt => txt.ToLong()).ToArray();
    }
}

Measured memory_bytes: 38568
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

const ll maxN = 1e7;
const ll INF = 1e17;

ll xs[] = {-1, 1, 0, 0};
ll ys[] = {0, 0, -1, 1};

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll t;
	cin >> t;
	if(t == 5 or t == 3 or t == 7)
		puts("YES");
	else
		puts("NO");
	return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S,T;cin>>S>>T;
  string SS=S+S;
  //みぎにいくつ進めばたどり着けるか
  vector<vector<long>>N(SS.length(),vector<long>(26,-1));
  for(long c=0;c<26;c++){
    long l=-1;
    for(long i=SS.length()-1;i>=0;i--){
      if(l!=-1)N[i][c]=l-i;
      if(SS[i]-97==c)l=i;
    }
  }
  long l=S.find(T[0]);//何番目のindexを見てるか
  if(l==string::npos){cout<<-1;return 0;}
  long ans=1+l;//進んだ総和
  for(long i=1;i<T.length();i++){
    if(N[l][T[i]-97]==-1){cout<<-1;return 0;} 
    ans+=N[l][T[i]-97];
    l=(l+N[l][T[i]-97])%S.length();
  }
  cout<<ans;
}

Measured memory_bytes: 49024
#include<iostream>
#include<vector>
using namespace std;
int main(){
    string s;
    vector<bool>v(26,false);
    cin>>s;
    bool no=false;
    for(int i=0;i<s.length();i++)
    {
        if(!v[s[i]-'a']){
            v[s[i]-'a']=true;
        }
        else{
            no=true;
            break;
        }
    }
    if(!no){
        cout<<"yes"<<endl;
    }
    else{
        cout<<"no"<<endl;
    }
}

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

A, B = map(int, input().rstrip().split())
sum = 0

if A > B:
    sum += A
    A -= 1
else:
    sum += B
    B -= 1

if A > B:
    sum += A
    A -= 1
else:
    sum += B
    B -= 1

print(sum)


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

string N;

int main(){
  cin >> N;
  ll sum = 0;
  rep(i, N.size()){
    sum += N[i] - '0';
  }
  if (sum % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3716
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define min(x,y) ((x)<(y)?(x):(y))
int cmp(const void *a,const void*b){return *(int*)a-*(int*)b;}
int main(){
    int n,i;
    scanf("%d",&n);
    int x[n];
    for(i=0;i<n;i++)
        scanf("%d",&x[i]);
    qsort(x,n,sizeof(int),cmp);
    int ans=0,ave=0;
    for(i=0;i<n;i++)
        ave+=x[i];
    ave/=n;
    int ans1=0;
    int av1=ave+1;
    for(i=0;i<n;i++){
        ans+=(x[i]-ave)*(x[i]-ave);
        ans1+=(x[i]-av1)*(x[i]-av1);
    }
    printf("%d\n",min(ans,ans1));
    return 0;
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#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>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    deque<char>que;
    string s;
    cin >> s;
    int n = s.size();
    for (int i=0; i<n; i++){
        if (s[i] == 'B'){
            if (!que.empty())que.pop_back();
        }
        else que.push_back(s[i]);
    }
    string ans;
    while (que.size()){
        ans += que.front(); que.pop_front();
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	if (!(k * 2 - 1 <= n)) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,L;
int ans,an1;
int main()
{
	scanf("%d%d",&n,&L);
	L--;
	an1=0x3f3f3f3f;
	for(int i=1;i<=n;i++)
	{
		ans+=i+L;
		if(abs(i+L)<abs(an1))
			an1=i+L;
	}
	printf("%d",ans-an1);
}


Measured memory_bytes: 256
X, Y = map(int, input().split())
if (X+Y) % 3 != 0:
    print(0)
    
else:
    # 経路
    def C(n, r, mod):
        num = 1
        den = 1
        for i in range(r):
            num *= n-i
            num %= mod
            den *= i+1
            den %= mod
        return (num * pow(den, mod-2, mod)) % mod
    mod = 10**9 + 7
    minimun = (X+Y)/3
    if X >= minimun and Y >= minimun:
        X -= minimun 
        Y -= minimun
        print(C(int(X+Y), int(X), mod))
    else:
        print(0)

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

struct DATA
{
	int i;
	int num;
	bool operator<(const DATA &another) const
	{
		return num < another.num;//年齢を比較
	};
};

int main()
{
	int n;
	int i, j;

	cin >> n;
	vector<DATA> a(n);

	for (i = 0; i < n; i++) {
		cin >> a[i].num;
		a[i].i = i + 1;
	}

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

	cout << a[0].i;
	for (i = 1; i < n; i++) {
		cout << " "<<a[i].i;
	}
	cout << endl;
	return 0;
}



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

#define int long long 
#define pb push_back
#define sz size()
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define pii pair<int,int>
#define bg being()
#define ed end()
#define pf(x) cout << x << endl;
#define for0(n) for(int i=0;i<n;i++)
#define ln length()
#define disp(x) for(auto y:x)cout << y << ' ';cout << endl;


int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);

    int n;
    cin >> n;
    vi a(n);
    for0(n){
        cin >> a[i];
    }
	
    int last=a[0];
    int res=0;
    for(int i=1;i<n;i++){
        if(a[i]<last){
            res+=(last-a[i]);
            a[i]=last;
        }
        last=a[i];
    }
    cout << res << endl;
	return 0;
} 

Measured memory_bytes: 4764
n = int(input())
all = 1<<n
statement = []
for i in range(n):
    A = int(input())
    statement.append([])
    for j in range(A):
        x, y = map(int, input().split())
        statement[i].append([x-1, y])
ans = 0
for i in range(all):
    ok = True
    num = 0
    for j in range(n):
        if i & 1<<j:
            num += 1
            for s in statement[j]:
                if (i & 1<<s[0]) != (s[1]<<s[0]):
                    ok = False
    if ok:
        ans = max(ans, num)
print(ans)


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;

typedef long long ll;

const long long MOD = 1000000000 + 7;

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


int main(){
    int n;
    cin >> n;
    map<ll,ll> L{};
    map<ll,ll> R{};
    
    ll h;
    rep(i,n) {
        cin >> h;
        ll LL,RR;
        LL = L[i+1+h];
        RR = R[i+1-h];
        L[i+1+h] =  LL + 1;
        R[i+1-h] =  RR + 1;
    }
    ll cnt = 0;
    for(auto itr = L.begin(); itr != L.end(); ++itr ) {
        cnt += itr->second * R[itr->first];
    }
    cout << cnt << endl;


    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

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

int main() {
    int k;
    cin >> k;
    int ans = 0;
    int temp = 0;

    for (int a = 1; a <= k; a++) {
        for (int b = 1; b <= k; b++) {
            for (int c = 1; c <= k; c++) {
                temp = gcd(a, b);
                ans += gcd(temp, c);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// leave to tomorrow anything that can be done today
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    bool isa=0,isb=0;
    rep(i,0,sz(s)){
        if(s[i]=='A')isa=1;
        else isb=1;
    }
    if(isa && isb) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;   
}   

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

using ll = long long;

int X, Y, Z, K;
vector<ll> A, B, C;

void solve1() {
    vector<ll> E(X*Y);
    int e = 0;
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++) {
            E[e++] = A[i] + B[j];
        }
    }
    sort(E.begin(), E.end(), greater<ll>());
    int lim = min((int)E.size(), K);
    vector<ll> EC(lim*Z);
    int ec = 0;
    for (int i = 0; i < lim; i++) {
        for (int j = 0; j < Z; j++) {
            EC[ec++] = E[i] + C[j];
        }
    }
    sort(EC.begin(), EC.end(), greater<ll>());
    for (int i = 0; i < K; i++) {
        cout << EC[i] << endl;
    }
}

void solve1a() {
    if (X > K) {
        sort(A.begin(), A.end(), greater<ll>());
    }
    if (Y > K) {
        sort(B.begin(), B.end(), greater<ll>());
    }
    int lim_a = min(K, X);
    int lim_b = min(K, Y);
    vector<ll> E(lim_a * lim_b);
    int e = 0;
    for (int i = 0; i < lim_a; i++) {
        for (int j = 0; j < lim_b; j++) {
            E[e++] = A[i] + B[j];
        }
    }
    sort(E.begin(), E.end(), greater<ll>());
    int lim_e = min((int)E.size(), K);
    vector<ll> EC(lim_e*Z);
    int ec = 0;
    for (int i = 0; i < lim_e; i++) {
        for (int j = 0; j < Z; j++) {
            EC[ec++] = E[i] + C[j];
        }
    }
    sort(EC.begin(), EC.end(), greater<ll>());
    for (int i = 0; i < K; i++) {
        cout << EC[i] << endl;
    }

}

void solve2() {
    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());

    vector<ll> E;
    for (int i = 0; i < X; i++) {
        int j_lim = min(Y, K / (i+1));
        for (int j = 0; j < j_lim; j++) {
            int k_lim = min(Z, K / ((i+1) * (j+1)));
            for (int k = 0; k < k_lim; k++) {
                E.push_back(A[i] + B[j] + C[k]);
            }
        }
    }

    sort(E.begin(), E.end(), greater<ll>());
    for (int i = 0; i < K; i++) {
        cout << E[i] << endl;
    }
}

void solve2a() {
    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());

    vector<ll> E;
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++) {
            for (int k = 0; k < Z; k++) {
                if ((i+1) * (j+1) * (k+1) <= K) {
                    E.push_back(A[i] + B[j] + C[k]);
                }
            }
        }
    }

    sort(E.begin(), E.end(), greater<ll>());
    for (int i = 0; i < K; i++) {
        cout << E[i] << endl;
    }
}

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    
    cin >> X >> Y >> Z >> K;
    A.resize(X); for (auto& a : A) cin >> a;
    B.resize(Y); for (auto& b : B) cin >> b;
    C.resize(Z); for (auto& c : C) cin >> c;

    solve2a();
}


Measured memory_bytes: 1404
inf = 10**9 + 7
s = input()
r = [[(j-k)*9%13 for j in range(10)] for k in range(13)]
d = [1] + [0]*12
for c in s:
    d = [sum(d[j] for j in k)%inf for k in r] if c > '9' else [d[(int(c)-k)*9%13] for k in range(13)]
print(d[5])


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(a,n) for (int a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

// auto mod int
// depends on Template

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

/*累積和
query(l,r)=引数に渡したvectorにおける[l,r)の和(0-indexed)
verified : https://judge.yosupo.jp/problem/static_range_sum
*/

template<typename T>
struct CumulativeSum{
    vector<T> res;
    CumulativeSum(const vector<T> vec){//初期化
        int sz = vec.size();
        res.resize(sz+1,0);
        for(int i=0;i<=sz;i++){
            res[i+1] = res[i]+vec[i];
        }
    }

    T query(int l, int r){
        return res[r]-res[l];
    }
};

int main(){
    ll n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<mint>r(n+1,0);
    rep(i,n){
        r[i+1]=r[i]+a[i];
    }
    mint ans = 0;
    rep(i,n){
        mint tmp = a[i];
        tmp *= r[n]-r[i+1];
        ans += tmp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6424
#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
//#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define int long long
using namespace std;
using namespace __gnu_pbds;



typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
ordered_set;
// ordered_set x;
// x.insert(a)
// *(x.find_by_order(k)) -> k th largest element in the set
// x.order_of_key(k) -> number of elements < k

const ll N = 3e5+100;
const ll MOD = 1e9+7;
const ll INF = 1e18;


long long binpow(long long a, long long b, long long m=MOD) {
     a %= m;
     long long res = 1;
     while (b > 0) {
         if (b & 1)
             res = res * a % m;
         a = a * a % m;
         b >>= 1;
     }
     return res;
 }


signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);
    int n ,m;
    cin>>n>>m;
    bool ac[n+1];
    ll wa[n+1];
    for(int i =1;i<=n;i++)ac[i]=false,wa[i]=0;
    int ans = 0;
    int pen = 0;
    for(int i=1;i<=m;i++){
        int p;
        string s;
        cin>>p>>s;
        if(ac[p]==true) continue;
        if(s=="AC"){
            ac[p]=true;
            ans++;
        }
        else if(ac[p]==false){
            wa[p]++;
        }
    }
    for(int i =1;i<=n;i++)if(ac[i])pen+=wa[i];
    cout<<ans<<" "<<pen<<endl;
     
}   

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25


int main() {
    string s;
    cin >> s;
    if(s[0] == s[1] && s[1] == s[2]){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}




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

import sys


def main():
    h,w = map(int, sys.stdin.readline().rstrip().split(' '))
    s = []
    for _ in range(h):
        s.append(sys.stdin.readline().rstrip())

    taboo = set()
    flg = True
    c = 0
    while flg:
        flg = True
        for i in range(h*w):
            x, y = i%h, i//h
            if (x,y) in taboo:
                continue
            flg = False
            q = [(x,y)]
            taboo.add((x,y))
            #print(q, s[x][y])
            white, black = 0,0
            while len(q) > 0:
                x, y = q.pop()
                color = s[x][y]
                if color == ".":
                    white +=1
                else:
                    black += 1
                for v in ((x+1, y), (x-1, y), (x, y+1), (x, y-1)):
                    if v[0] >= 0 and v[0] < h and v[1] >= 0 and v[1] < w:
                        newcolor = s[v[0]][v[1]]
                        if color == newcolor or (v[0], v[1]) in taboo:
                            continue
                        q.append((v[0], v[1]))
                        taboo.add((v[0], v[1]))
                        #print(v, newcolor)
            #print(white, black)
            c += white * black
    print(c)



    
if __name__=="__main__":
    main()


Measured memory_bytes: 24920
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<=55555;i++)
	{
		int aft = (i*108)/100;
		if(aft==n)
		{
			cout<<i<<'\n'; return 0;
		}
	}
	cout<<":(\n";
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;


unsigned long long f(unsigned long long x)
{
    return x*x;
}

int main()
{
    int d;
    while(cin >> d) {
        unsigned long long s = 0;
        for(int i = d; i <= 600 - d; i += d) s += d * f(i);
        cout << s << endl;
    }
    return 0;
}

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

int main(){
    string S; cin>>S;
    int size=S.size();
    for(int i=0;i<size;i=i+2){
        if(S[i]=='h'&&S[i+1]=='i'){
        }
        else{
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <regex>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include  <cassert>
#include <fstream>
#include <codecvt>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define int ll
const int INF = (1LL << 32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

static const int MAX = 100000;
int n, A[MAX + 1], L[MAX + 1];

int lis() {
	int length = 1;
	L[0] = A[0];
	FOR(i, 1, n) {
		if (L[length-1] < A[i])
			L[length++] = A[i];
		else
			*lower_bound(L, L + length, A[i]) = A[i];
	}
	return length;
}

signed main() {
	ios::sync_with_stdio(true);
	cin >> n;
	rep(i, n) cin >> A[i];
	cout << lis() << endl;
	return 0;
}


Measured memory_bytes: 4640
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;

int main(){
	int x, y, z;
	cin >> x >> y >> z;
	if(x>y&&x>z) cout << y*z/2 << endl;
	else if(y>x&&y>z) cout << x*z/2 << endl;
	else cout << x*y/2 << endl;

	return 0;
}


Measured memory_bytes: 256
all_list = []
for i in range(12):
    a = [0] * 10
    all_list.append(a)

n = int(input())
num_list = []

for i in range(n):
    b, f, r, v = map(int, input().split())
    
    if b == 1:
        all_list[f-1][r-1] += v
    elif b == 2:
        all_list[f+2][r-1] += v
    elif b == 3:
        all_list[f+5][r-1] += v
    elif b == 4:
        all_list[f+8][r-1] += v
 
tmp = 0   
for i in all_list:
    print(" ", end="")
    print(*i)
    tmp +=1
    if tmp  == 3 or tmp == 6 or tmp == 9:
        print("####################")
    


Measured memory_bytes: 5620
import java.util.*;
import java.lang.*;


class Graph {
	private int totalVertex;
	//adjMatrix[u][v] = 1 if there is an edge from u to v, otherwise 0
	private int[][] adjMatrix;
	//adjWeight[u][v] -- the weight of the edge from u to v if there is one
	private int[][] adjWeight;
	//if a node is settled (e.g., processed in the Dijkstra's algorithm)
	private Boolean[] ifSettled;
	public Graph() { totalVertex = 0; }
	public int getTotalVertex() { return totalVertex; }
	//load graph from standard input
	public void loadAdjMatrix() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjMatrix = new int[totalVertex][totalVertex];
		adjWeight = new int[totalVertex][totalVertex];
		ifSettled = new Boolean[totalVertex];
		int i, j;
		for(i = 0; i < totalVertex; i ++) {
			ifSettled[i] = false;
			for(j = 0; j < totalVertex; j ++) {
				adjMatrix[i][j] = adjWeight[i][j] = 0;
			}
		}
		int u, v;
		for(i = 0; i < totalVertex; i ++) {
			u = in.nextInt();
			int degree = in.nextInt();
			for(j = 0; j < degree; j ++) {
				v = in.nextInt(); 
				adjMatrix[u][v] = 1;
				adjWeight[u][v] = in.nextInt();
			}	
		}
		in.close();
	}
	//return weight of the edge from u to v if there is one
	public int getWeight(int u, int v) {
		return adjWeight[u][v];
	}
	//return neighbors of u as a LinkedList
	public LinkedList<Integer> getNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if(adjMatrix[u][v] == 1) tmp.add(v);
		}
		return tmp;
	}
	//return unsettled neighbors of u as a LinkedList
	public LinkedList<Integer> getUnsettledNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if((adjMatrix[u][v] == 1) && (ifSettled[v] == false)) tmp.add(v);
		}
		return tmp;
	}
	//return the unsettled node that has the smallest dist
	public int getUnsettledNearest(int[] dist) {
		int md = Integer.MAX_VALUE;
		int mv = -1;
		int v;
		for(v = 0; v < totalVertex; v ++) {
			if((ifSettled[v] == false) && (dist[v] < md)) {
				md = dist[v];
				mv = v;
			}
		}
		return mv;
	}
	//implement the following	
	public int[] Dijkstra(int s) {
		int[] dist = new int[totalVertex];
		boolean[] visited = new boolean[totalVertex];
		dist[0] = 0;
		for (int i = 1; i< dist.length; i++) {
			dist[i] = Integer.MAX_VALUE;
		}
		/*visited[0] = true;
		for (int i = 1; i< visited.length; i++) {
			visited[i] = false;
		}*/
		for(int i = 0 ; i < totalVertex; i++) {
			int node = getUnsettledNearest(dist);
			ifSettled[node] = true;
			LinkedList<Integer> nb = getUnsettledNeighbors(node);
			for(Integer n : nb) {
				dist[n] = Math.min(dist[n], dist[node] + getWeight(node,n));
			}
		}
		return dist;	
	}
}

public class Main {
	public static void main(String[] argv) {
		Graph g = new Graph();
		g.loadAdjMatrix();
		int[] dist = g.Dijkstra(0);
		for(int i = 0; i < g.getTotalVertex(); i ++) {
			System.out.println(i + " " + dist[i]);
		}
	}
}


Measured memory_bytes: 40292
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
bool ok[maxn],tmp[maxn];
string ss;
int n;
bool check(int left,int end)
{
	memset(ok,0,sizeof(ok));
	ok[left]=true;
	for(int i=left+1;i<=end;i++)
		if((ok[i-1]||ok[i-2])&&ss[i]=='.')
			ok[i]=true;
	return ok[end];
}
void fl()
{
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
int main()
{
	ios::sync_with_stdio(0);
//  fl();
	int a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	cin>>ss;
	ss='#'+ss;
	if(c<d)
	{
		if(!check(b,d))
		{
			cout<<"No"<<endl;
			return 0;
		}
		if(!check(a,c))
		{
			cout<<"No"<<endl;
			return 0;
		}
		cout<<"Yes"<<endl;
		return 0;
	}
	else
	{
		if(!check(b,d))
		{
			cout<<"No"<<endl;
			return 0;
		}
		for(int i=1;i<=n;i++)
			tmp[i]=ok[i];
		for(int i=b;i<=d;i++)
			if(tmp[i])
				if(ss[i-1]=='.'&&ss[i+1]=='.')
				{
					cout<<"Yes"<<endl;
					return 0;
				}
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 1020
# -*- coding: utf-8 -*-
def solve():
    N = int(input())
    D = map(int, input().split())
    E = [[] for i in range(N)]
    for i,d in enumerate(D):
        E[d].append(i)

    if [0] != E[0]:
        return '0'
    res = 1
    e_ = E[0]
    for i,e in enumerate(E[1:], start=1):
        if e:
            res *= len(e_)**len(e)
            e_ = e
        else:
            if any(E[i+1:]):
                return '0'
            else:
                return str(res%998244353)
    return str(res%998244353)

if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 24308
#include <stdio.h>
int main(void)
{
	int n,i,j,temp,a,b,c,d,e[100],f[100],g[100];
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		e[i]=0;
		f[i]=i;
	}
	for(i=0;i<n*(n-1)/2;i++){
		scanf("%d %d %d %d",&a,&b,&c,&d);
		if(c>d){
			e[a]=e[a]+3;
		}
		else if(c<d){
			e[b]=e[b]+3;
		}
		else if(c==d){
			e[a]=e[a]+1;
			e[b]=e[b]+1;
		}
	}
	for(i=1;i<=n;i++){
		g[i]=e[i];
	}
	for(i=0;i<n;i++){
		for(j=n;j>i+1;j--){
			if(e[j]>e[j-1]){
				temp=e[j];
				e[j]=e[j-1];
				e[j-1]=temp;
			}
		}
	}
	for(j=2;j<=n;j++){
		if(e[j]==e[j-1]){
			f[j]=f[j-1];
		}
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(g[i]==e[j]){
				printf("%d\n",f[j]);
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  cin >> n;
  vector<ll> d(n);
  for(ll i = 0; i < n; ++i) cin >> d[i];
  sort(begin(d),end(d));
  ll m = (n>>1);
  cout << d[m]-d[m-1];
  return 0;
}

Measured memory_bytes: 1024
#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(){
    int n, t;
    cin >> n >> t;
    int cmin = 1001;
    rep(i, n){
        int c, ti;
        cin >> c >> ti;
        if(ti <= t && cmin > c) cmin = c;
    }
    if(cmin == 1001){
        cout << "TLE" << endl;
    }else{
        cout << cmin << endl;
    }
    return 0;
}

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

int main(){
    int n ,k;
    long long dist,mini = -1;
    cin >> n >> k;
    vector<long long>a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }

    for(int i = 0;i <= n - k;i++){
        dist = min(abs(a[i]),abs(a[i + k - 1]));
        if(mini != -1)mini = min(mini,dist + abs(a[i + k - 1] - a[i]));
        else mini = dist + abs(a[i + k - 1] - a[i]);
    }
    cout << mini << endl;
}


Measured memory_bytes: 1024
<?php
$n = (int)trim(fgets(STDIN));

$input = explode(' ', trim(fgets(STDIN)));
$hs = [];
foreach ($input as $v) {
	$hs[] = (int)$v;
}

$max = 0;
$tmp = 0;
for ($i=0; $i < $n-1; $i++) { 
	if ($hs[$i+1] <= $hs[$i]) {
		$tmp += 1;
	}else{
		$max = max($max, $tmp);
		$tmp = 0;
	}
}
$max = max($max, $tmp);

echo $max;

Measured memory_bytes: 19060