akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n,x,y;
template <typename T>
vector<T> dijkstra(int s,vector<vector<pair<T,int>>> & G){
    const T inf=numeric_limits<T>::max();
    using edge=pair<T,int>;
    priority_queue<edge, vector<edge>, greater<edge> > que;
    int n=G.size();
    vector<T> d(n,inf);
    vector<int> b(n,-1);
    d[s]=0;
    que.emplace(d[s],s);
    while (!que.empty()){
        edge p = que.top(); que.pop();
        int v = p.second;
        if (d[v]<p.first) continue;
        for(auto& e:G[v]){
            int u=e.second;
            T c=e.first;
            if (d[u]>d[v]+c){
                d[u]=d[v]+c;
                b[u]=v;
                que.emplace(d[u],u);
            }
        }
    }
    return d;
}

int ans[2010];

void solve(){
  cin >> n >> x >> y;
  x--;y--;
  vector<vector<P>> G(n);
  rep(i,n-1){
    G[i].push_back(P(1,i+1));
    G[i+1].push_back(P(1,i));
  }
  G[x].push_back(P(1,y));G[y].push_back(P(1,x));
  rep(i,n){
    vector<int> d=dijkstra(i,G);
    rep(j,n){
      ans[d[j]]+=1;
    }
  }
  Rep(i,1,n){
    cout << ans[i]/2 << endl;
  }
}

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

Measured memory_bytes: 384
#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--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    vector<ll> dp(n, -1);
    rep(i, n) {
        auto it = lower_bound(dp.begin(), dp.end(), a[i]);
        it--;
        *it = a[i];
    }
    ll ans = dp.end() - lower_bound(dp.begin(), dp.end(), 0);
    cout << ans << endl;
}


Measured memory_bytes: 1792
import java.util.*;

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;
	int[] dij;
	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];
		dij = new int[totalVertex];
		ifSettled = new Boolean[totalVertex];
		int i, j;
		for(i = 0; i < totalVertex; i ++) {
			ifSettled[i] = false;
			dij[i] = Integer.MAX_VALUE;
			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) {
		dij[s] = 0;
		for(int i = 0; i < totalVertex - 1; i++) {
			int min = getUnsettledNearest(dij);
			ifSettled[min] = true;
			for(int j = 0; j < totalVertex; j++) {
				if(ifSettled[j] == false && getWeight(min, j) != 0 && dij[min] != Integer.MAX_VALUE && dij[min] + getWeight(min, j) < dij[j]) {
					dij[j] = dij[min] + getWeight(min, j);
				}
			}
		}
		
		return dij;
	}
}

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: 40540
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std ;

int main(){
    int n ; cin >> n ;
    vector<int> a(n) ;
    for(int i=0;i<n;i++) cin >> a.at(i) ;
    reverse(a.begin(),a.end()) ;
    cout << a.at(0) ;
    for(int i=1;i<n;i++) cout << " " << a.at(i) ;
    cout << endl ;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define N 31
#define TOP 0
#define FRONT 1
#define LEFT 2
#define RIGHT 3
#define BACK 4
#define BOTTOM 5
using namespace std;
int w,h;
string mp[N];

void rotN(vector<char> &dice){
  swap(dice[TOP],dice[FRONT]);
  swap(dice[FRONT],dice[BOTTOM]);
  swap(dice[BOTTOM],dice[BACK]);  
  
}

void rotS(vector<char> &dice){rotN(dice),rotN(dice),rotN(dice);}

void rotE(vector<char> &dice){
  swap(dice[TOP],dice[LEFT]);
  swap(dice[LEFT],dice[BOTTOM]);
  swap(dice[BOTTOM],dice[RIGHT]);
}

void rotW(vector<char> &dice){rotE(dice),rotE(dice),rotE(dice);}

void rotCW(vector<char> &dice){
  swap(dice[FRONT],dice[RIGHT]);
  swap(dice[RIGHT],dice[BACK]);
  swap(dice[BACK],dice[LEFT]);
}

typedef pair<int,int> P;
typedef pair<vector<char>,P> PP;

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

P getStart(char ch){
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(mp[i][j]==ch){
	mp[i][j]='w';
	return P(j,i);
      }
}

int C[1<<8];

int bfs(int sx,int sy,int gx,int gy,vector<char> dice,int dep){
  char gch = ord[dep];
  
  int D[10][10][31][31];
  memset(D,-1,sizeof(D));
  
  D[C[dice[TOP]]][C[dice[FRONT]]][sx][sy] = 0;
  queue<PP> Q;
  Q.push(PP(dice,P(sx,sy)));
  
  int res = 1e9;
  while(!Q.empty()){
    PP t = Q.front();Q.pop();
    dice = t.first;
    int x = t.second.first;
    int y = t.second.second;
    int cost = D[C[dice[TOP]]][C[dice[FRONT]]][x][y];
        
    if(x==gx&&y==gy){
      if(dice[TOP]!=gch)continue;
      if(dep+1==(int)ord.size()) return cost;
      P st = getStart(ord[dep+1]);
      mp[gy][gx] = 'k';
      res =min(res,cost+bfs(gx,gy,st.first,st.second,dice,dep+1));
      mp[st.second][st.first] = ord[dep+1];
      mp[gy][gx] = 'w';
      continue;
    }
    
    for(int i=0;i<4;i++){
      int nx = x+dx[i];
      int ny = y+dy[i];
      vector<char> ndice = dice;
      if(i==0)rotS(ndice);
      if(i==1)rotN(ndice);
      if(i==2)rotE(ndice);
      if(i==3)rotW(ndice);
      PP sta = PP(ndice,P(nx,ny));
      if(nx<0||ny<0||nx>=w||ny>=h||mp[ny][nx]!='w')continue;
      if(D[C[ndice[TOP]]][C[ndice[FRONT]]][nx][ny]!=-1) continue;
      Q.push(sta);
      D[C[ndice[TOP]]][C[ndice[FRONT]]][nx][ny]=cost+1;
    }
  }
  return res;
}

int main(){
  while(1){
    cin>>w>>h;
    if(!w&&!h)break;
    for(int i=0;i<h;i++)cin>>mp[i];
    cin>>ord;
    vector<char> dice(6);
    dice[TOP]   ='r';
    dice[BOTTOM]='c';
    dice[BACK]  ='g';
    dice[FRONT] ='m';
    dice[RIGHT] ='b';
    dice[LEFT]  ='y';
    C['r'] = 0;
    C['c'] = 1;
    C['g'] = 2;
    C['m'] = 3;
    C['b'] = 4;
    C['y'] = 5;
    
    P s = getStart('#');
    P g = getStart(ord[0]);
    int ans = bfs(s.first,s.second,g.first,g.second,dice,0);
	
    if(ans<1e9) cout<<ans<<endl;
    else cout<<"unreachable"<<endl;
  }
  return 0;
}

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

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var nm = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            var n = nm[0];
            var m = nm[1];
            /*
            var cards = new bool[n + 2, m + 2];
            for (int mm = 1; mm < m + 1; mm++) {
                for (int nn = 1; nn < n + 1; nn++) {
                    for (int y = -1; y < 2; y++) {
                        for (int x = -1; x < 2; x++) {
                            cards[nn + x, mm + y] = !cards[nn + x, mm + y];
                        }
                    }
                }
            }

            for (int mm = 1; mm < m + 1; mm++) {
                for (int nn = 1; nn < n + 1; nn++) {
                    Console.Write(cards[nn, mm] ? "1" : "0");
                }
                Console.WriteLine();
            }
            */
            if(n == 2 || m == 2) {
                Console.WriteLine(0);
                Console.Out.Flush();
                return;
            }

            if(n== 1 && m == 1) {
                Console.WriteLine(1);
                Console.Out.Flush();
                return;
            }

            if(n == 1 || m == 1) {
                Console.WriteLine((n * m) - 2);
                Console.Out.Flush();
                return;
            }

            Console.WriteLine(((long)n - 2) * (m - 2));
            Console.Out.Flush();
        }
    }
}


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

using namespace std;
using ll = long long;

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

  int n;
  cin >> n;
  string s;
  cin >> s;

  int ans = n;
  {
    // 全部R
    int sum = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == 'W')
        sum++;
    }
    ans = min(ans, sum);
  }
  {
    // 全部W
    int sum = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == 'R')
        sum++;
    }
    ans = min(ans, sum);
  }
  {
    // RRRRWWWW
    int i = 0;
    int j = n - 1;
    int sum = 0;
    string t = s;
    // 入れ替え
    while (true) {
      while (i < n && t[i] == 'R')
        i++;
      while (j >= 0 && t[j] == 'W')
        j--;
      if (i >= j)
        break;
      char tmp = t[i];
      t[i] = t[j];
      t[j] = tmp;
      i++;
      j--;
      sum++;
    }
    for (int k = i; k < n; k++) {
      if (t[k] == 'R')
        sum++;
    }
    ans = min(ans, sum);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3844
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int N;
    double cost = 0.0;
    cin >> N;
    vector<string> x(N);
    vector<double> v(N);
    
    for (int i = 0; i < N; i++){
        cin >> v[i] >> x[i];
        
    
        if (x[i] == "JPY")
            cost += v[i];
        else
            cost += 380000.0 * v[i];
    }
    
    cout << cost;
    
}


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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);
    int a,b,c; cin>>a>>b>>c;
    if (a==b&&b==c)
        ANS(1);
    else if (a==b||b==c||c==a)
        ANS(2);
    else
        ANS(3);
}


Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

    vector <int> a(n);
    map <int, ll> mp;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        mp[a[i]]++;
    }

    ll ans = 0;
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        ans += itr->second * (itr->second - 1) / 2;
    }

    for (int i = 0; i < n; i++) {
        cout << ans - mp[a[i]] + 1 << '\n';
    }

    return 0;
}

Measured memory_bytes: 10240
#include<stdio.h>
#define k 10001
//typedef long int li;

int A[2000005];
int B[2000005];

int main(){
  int n;
  int i,j;
  
  scanf("%d",&n);
  
  for(i=0;i < n;i++) scanf("%d",&A[i]);

  int C[k];

  for(i = 0;i < k;i++) C[i]=0;

  for(j = 0;j < n;j++) C[A[j]]++;

  for(i = 1;i < k;i++) C[i]=C[i]+C[i-1];

  for(j = n-1;j >= 0;j--){
    B[C[A[j]]-1]=A[j];
    C[A[j]]--;
  }
  for(i=0;i<n;i++){
    if(i) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  return 0;
}



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

int main() {

    int x;
    cin >> x;
    int res = 1;
    for (int i = 2; i <= x; ++i) {
        int power = i * i;
        for (int j = 2; ; ++j) {
            if (power > x) break;
            res = max(res, power);
            power *= i;
        }
    }
    cout << res << endl;
    return 0;
}

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

struct drink {
	long long int A;
	int B;
};

int judge(const void *a, const void *b) {
	struct drink *x = (struct drink *)a;
	struct drink *y = (struct drink *)b;
	if (x->A > y->A) return 1;
	if (x->A < y->A) return -1;
	return 0;
}

int main() {
	int N, m, i;
	long long int sum = 0;
	struct drink DATA[100000];

	scanf("%d %d", &N, &m);
	for (i = 0; i < N; i++) {
		scanf("%lld %d", &DATA[i].A, &DATA[i].B);
	}

	qsort(DATA, N, sizeof(struct drink), judge);

	for (i = 0; m > 0; i++) {
		if (m >= DATA[i].B) {
			m = m - DATA[i].B;
			sum = sum + DATA[i].A * DATA[i].B;
		}
		else {
			sum = sum + m * DATA[i].A;
			m = 0;
		}
	}

	printf("%lld", sum);

	return 0;
}


Measured memory_bytes: 3324
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int main()
{
    int n; cin>>n;
    ll a, b, s=0;
    cin>>a>>b;
    for(int i=2; i<n; i++){
        ll x; cin>>x; s^=x;
    }
    if((a^b^s)==0){
        cout<<0<<endl;
        return 0;
    }
    if(a+b<s || (a+b-s)%2!=0){
        cout<<-1<<endl;
        return 0;
    }
    ll t=(a+b-s)/2;
    for(int i=0; i<40; i++){
        if(s&(1ll<<i) && t&(1ll<<i)){
            cout<<-1<<endl;
            return 0;
        }
    }
    for(int i=0; i<40; i++){
        if(!(a&(1ll<<i))) continue;
        ll x=0, y=0;
        bool dame=0;
        for(int j=0; j<40; j++){
            if(j<i){
                if(s&(1ll<<j)){
                    x^=(1ll<<j);
                }else if(t&(1ll<<j)){
                    x^=(1ll<<j);
                }
            }else if(j==i){
                if(!(s&(1ll<<j)) && (t&(1ll<<j))){
                    dame=1;break;
                }
            }else if(a&(1ll<<j)){
                if(!(s&(1ll<<j)) && !(t&(1ll<<j))){
                    dame=1;break;
                }
                x^=(1ll<<j);
            }else{
                if(!(s&(1ll<<j)) && (t&(1ll<<j))){
                    dame=1;break;
                }
            }
        }
        if(!dame && x>0){
            cout<<a-x<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3616
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <deque>
#include <stack>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define DEBUG(x) cout << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)            \
    cerr << #v << ": ";         \
    REP(__i, (v).size())        \
    cerr << ((v)[__i]) << ", "; \
    cerr << endl

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

int main()
{
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;

    vector<pll> pairs;
    REP(i, N) {
        int A, B;
        cin >> A >> B;
        pairs.emplace_back(A, B);
    }
    sort(pairs.begin(), pairs.end());

    ll ans = 0LL;
    int cnt = 0;
    REP(i, N) {
        auto p = pairs[i];
        for (int j = 0; j < p.second; j++) {
            ans += p.first;
            cnt ++;

            if (cnt == M) {
                cout << ans << endl;
                return 0;
            }
        }
    }
}


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

int main() {
  char C;
  cin >> C;

  cout << (char)(C + 1) << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double K;
typedef pair<int, int> pii;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()

const int inf = 2000000000;

main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    cout << (n % 10 == 9 || n / 10 == 9 ? "Yes" : "No");
}


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

using namespace std;

int main(void) {
	int D;
	cin >> D;
	long long G;
	cin >> G;
	int LIM = (D*100)+1;
	vector<int> nop(D);
	vector< vector<int> > score(D,vector<int>(LIM,-1));
	for (int i = 0; i < D; ++i) {
		int p,c;
		cin >> p >> c;
		nop[i] = p;
		score[i][0] = 0;
		for (int j = 0; j < p; ++j) {
			score[i][j+1] = (i+1)*(j+1)*100;
		}
		score[i][p] += c;
	}
	int nind = nop[0];
	vector<int> dp = score[0];
	for (int i = 1; i < D; ++i) {
		vector<int> prev = dp;
		for (int j = nop[i]; j > 0; --j) {
			for (int k = nind; k >= 0; --k) {
				dp[k+j] = max(dp[k+j],prev[k]+score[i][j]);
			}
		}
		nind += nop[i];
	}

	bool find = false;
	for (int i = 0; !find && i < LIM; ++i) {
		if (dp[i] >= G) {
			cout << i << endl;
			find = true;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <string.h>
#include <math.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険

#define rep(i,l,r)for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r)for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k)for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す
/*
   upll : (a<b)なら-1, (a=b)なら0, (a>b)なら1
 downll : (a<b)なら1, (a=b)なら0, (a>b)なら-1

 const void* a : 型を縛らずにconstをつける(=変数aが読み込み専用の変数であることを明示する)
        (ll*)a : 変数aがconst long long *型であると明示する
*/
// int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
// int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
// void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
// void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)



int main(){
    string s; cin >> s;
    bool flag = true;
    rep(i,0,3) if(s[i+1] == s[i]) flag = false;
    cout << (flag ? "Good" : "Bad") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N;
  cin >> N;
  int h[N];
  int max_cost[N];
  for(int i=0;i<N;i++){
    cin >> h[i];
    max_cost[i] = -1;
  }
  max_cost[0]=0;
  for(int frog=0;frog<N-1;frog++){
    if(max_cost[frog+1] >= max_cost[frog] + abs(h[frog+1]-h[frog]) || max_cost[frog+1] == -1)
      max_cost[frog+1] = max_cost[frog] + abs(h[frog+1]-h[frog]);
    if(frog<N-2 && (max_cost[frog+2] >= max_cost[frog] + abs(h[frog+2]-h[frog]) || max_cost[frog+2] == -1))
      max_cost[frog+2] = max_cost[frog] + abs(h[frog+2]-h[frog]);
  }
  cout << max_cost[N-1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main(void){
string S; cin >> S;
set<char> s;
for(int i=0;i<S.size();++i){
if(! s.insert(S[i]).second){
cout << "no" << endl;
return 0;
}
}
cout << "yes" << endl;
return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
D=[list(map(int, input().split())) for _ in range(M)]
C=D[::-1]
par=[i for i in range(N)]
rank=[0]*(N)
size=[1]*N

def find(x):
  if par[x]==x:
    return x
  else:
    par[x]=find(par[x])
    return par[x]

def same(x,y):
  return find(x)==find(y)

def union(x,y):
  x=find(x)
  y=find(y)
  if x==y:
    return 
  if rank[x]>rank[y]:
    par[y]=x
    size[x]+=size[y]
  else:
    par[x]=y
    size[y]+=size[x]
    if rank[x]==rank[y]:
      rank[y]+=1

A=[]
d=0
for a,b in C:
  a-=1
  b-=1
  x=find(a)
  y=find(b)
  if x!=y:
    d+=size[x]*size[y]
  union(a,b)
  A.append(d) 
A=A[::-1]
A.append(0)
a=N*(N-1)//2
for i in range(1,M+1):
  print(a-A[i])

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




public class Main 
{
	
	public static void main(String[] args) throws IOException 
	{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		StringTokenizer s = new StringTokenizer(br.readLine());
		
		int n=Integer.parseInt(s.nextToken());
		HashMap<Integer,Integer>hm=new HashMap<>();
		s = new StringTokenizer(br.readLine());
		for(int i=0;i<n;i++) {
			int val=Integer.parseInt(s.nextToken());
			hm.put(val, hm.getOrDefault(val, 0)+1);
		}
		int ans=0;
		for(int val:hm.keySet()) {
			int num=hm.get(val);
			if(num>val)
				ans+=num-val;
			else if(num<val)
				ans+=num;
		}
		pw.println(ans);
		pw.close();
		

	}
}

Measured memory_bytes: 56648
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>

using namespace std;

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

    vector<double> vs(N);
    double v;
    for (int i = 0; i < N; i++)
    {
        cin >> v;
        vs[i] = v;
    }

    sort(vs.begin(), vs.end());
    reverse(vs.begin(), vs.end());

    double ans;
    double a, b;
    for (int i = N - 1; i >= 1; i--)
    {
        a = vs[i];
        b = vs[i - 1];
        vs.pop_back();
        vs.pop_back();
        vs.push_back((a + b) / 2);
    }
    cout << setprecision(20) << vs[0] << endl;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int K, Q;
ll d[5100], e[5100];

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

  std::cin >> K >> Q;

  for(int i=0;i<K;++i){
      std::cin >> d[i];
  }

  for(int i=0;i<Q;++i){
      int N, X, M;
      std::cin >> N >> X >> M;

      std::copy(d, d + K, e);
      
      for(int i=0;i<K;++i){
          e[i] %= M;
          if(e[i] == 0){
              e[i] = M;
          }
      }

      ll q = X / M, r = X % M;
      
      {
          ll S = std::accumulate(e, e + K, 0ll), q1 = S / M, r1 = S % M;
          q += 1ll * (N - 1) / K * q1;
          r += 1ll * (N - 1) / K * r1;
          q += r / M;
          r %= M;
      }
      
      {
          ll s = std::accumulate(e, e + (N - 1) % K, 0ll), q2 = s / M, r2 = s % M;
          q += q2;
          r += r2;
          q += r / M;
      }

      q -= X / M;

      ll res = (N - 1) - q;
      std::cout << res << std::endl;
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    int X;
    cin>>X;
    int M=1;
    int n;
    for(int i=2;i<=sqrt(X);i++){
        for(int j=2;1*pow(i,j)<=X;j++){
            n=pow(i,j);
            M=max(M,n);
        }
    }
    cout<<M<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
int dp[102][500005];
int main() {
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++)
    cin>>a[i];
    memset(dp,0,sizeof dp);
    dp[n][0]=1;
    int pre = 0;
    for(int i=n-1;i>=0;i--)
    {
        ll tem=0;
        for(int q = 0;q<=a[i];q++)
        tem+=dp[i+1][k-q];
        dp[i][k] = (tem+mod)%mod;
        for(int j=k-1;j>=0;j--)
        {
            ll ans;
            if(j>=a[i])
            ans = (dp[i][j+1]-dp[i+1][j+1]+dp[i+1][j-a[i]]);
            else
            ans = (dp[i][j+1]-dp[i+1][j+1]);
            dp[i][j] = (ans+mod)%mod;
        }
    }
    cout<<dp[0][k];
}


Measured memory_bytes: 202784
S = input()
T = input()

def count_common(a,b):
    cnt = 0
    for i in range(len(a)):
        if a[i] == b[i]:
            cnt += 1
    return cnt

cnt = 0

for i in range(len(S) - len(T) + 1):
    cnt = max(cnt, count_common(S[i:i+len(T)],T))

print(len(T)-cnt)

Measured memory_bytes: 9128
#include<stdio.h>
int main(void)
{
	int a[100000], i = 2;
	int s, count[100000];
	scanf("%d", &s);
	a[1] = s;
	count[a[1]]=1;
	while (true) {
		if (a[i - 1] % 2 == 0) {
			a[i] = a[i - 1] / 2;
			if (count[a[i]] == 1) {
				printf("%d", i);
				return 0;
			}
			else {
				count[a[i]] = 1;
			}
		}
		else {
			a[i] = a[i - 1] * 3 + 1;
			if (count[a[i]] == 1) {
				printf("%d", i);
				return 0;
			}
			else {
				count[a[i]] = 1;
			}
		}
		i++;
	}
}

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

int main(void){
	int n,x;
	cin>>n;
	for(int i=1;i<=n;i++){
		x=i;
		if(i%3==0)cout<<" "<<i;
		else{
			while(x>0){
				if(x%10==3){
					cout<<" "<<i;
					break;
				}
				x=x/10;
			}
		}
	}
	cout<<endl;
}


Measured memory_bytes: 3072
arr = Array.new(4, 0)

while line = gets
  a, b = line.chomp.split(",")
  case b
  when "A"
    arr[0] += 1
  when "B"
    arr[1] += 1
  when "AB"
    arr[2] += 1
  when "O"
    arr[3] += 1
  end
end

puts arr

Measured memory_bytes: 6100
#include <stdio.h>
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1154&lang=jp
int caluculate(int ruu, int water, int noudo,int ruug){
    int ruu_count = 0;
    int ruu_sum = ruu;
    int water_sum = water;
    while(1){
        if(((double)ruu_sum / (double)water_sum) < (double)noudo){
            ruu_sum += ruug;
            ruu_count++;
        }
        if(((double)ruu_sum / (double)water_sum) > (double)noudo){
            if((double)ruu_sum / (double)water_sum > (double)noudo && (double)ruu_sum / (double)(water_sum + 1) <= (double)noudo){
                printf("%d\n",ruu_count);
                break;
            }
            else{
                water_sum++;
            }
        }
        if(((double)ruu_sum / (double)water_sum) == (double)noudo){
            printf("%d\n",ruu_count);
            break;
        }
    }
    return 0;
}
int main() {
    int water = 0;
    int ruu = 0;
    int noudo = 0;
    int ruug = 0;
    while(1){
        scanf("%d %d %d %d", &ruu, &water, &noudo, &ruug);
        if(water == 0 && ruu == 0 && noudo == 0 && ruug == 0){
            break;
        }
        caluculate(ruu, water, noudo, ruug);
    }  
    return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(int argc, char const *argv[])
{
	map<string, vector<int> > index;
	string s;
	int n;
	while(cin>>s>>n){
		index[s].push_back(n);
		sort(index[s].begin(),index[s].end());
	}

	map<string,vector<int> >::const_iterator it;
	vector<int>::const_iterator it2;
	for(it=index.begin(); it!=index.end();it++){
		cout<<(*it).first<<endl;
		for(it2=(*it).second.begin();it2!=(*it).second.end()-1;it2++){
			cout<<(*it2)<<" ";
		}
		cout<<(*it2)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <map>
#include <string>
#include <sstream>
#include <queue>
#include <vector>
using namespace std;

map< int, pair< int, int > > nodes;
map< int, pair< int, int > > parentsAndDepths;
int root = 0;

string nodeType(int id) {
  if (id == root)
    return "root";
  else if (nodes[id].first == -1)
    return "leaf";
  else
    return "internal node";
}

void getParentsAndDepths(void) {
  queue< int > fringe;
  fringe.push(root);
  parentsAndDepths[root] = pair< int, int > (-1, 0);
  while (!fringe.empty()) {
    int currentParent = fringe.front();
    fringe.pop();
    int currentNode = nodes[currentParent].first;
    while (currentNode != -1) {
      parentsAndDepths[currentNode] =
	pair< int, int > (currentParent, parentsAndDepths[currentParent].second+1);
      fringe.push(currentNode);
      currentNode = nodes[currentNode].second;
    }
  }
}

string children(int id) {
  ostringstream result;
  result << "[";
  int currentSibling = nodes[id].first;
  if (currentSibling != -1) {
    result << currentSibling;
    currentSibling = nodes[currentSibling].second;
    while (currentSibling != -1) {
      result << ", ";
      result << currentSibling;
      currentSibling = nodes[currentSibling].second;
    }
  }
  result << "]";
  return result.str();
}

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    nodes[i] = pair< int, int > (-1, -1);
  }
  vector< bool > isChild (n, false);
  for (int i = 0; i < n; i++) {
    int id, k, holder, sibling;
    cin >> id >> k;
    if (k) {
      cin >> holder;
      isChild[holder] = true;
      nodes[id].first = holder;
    }
    for (int j = 1; j < k; j++) {
      sibling = holder;
      cin >> holder;
      isChild[holder] = true;
      nodes[sibling].second = holder;
    }
  }
  for (int i = 0; i < n; i++)
    if (!isChild[i]) {
      root = i;
      break;
    }
  getParentsAndDepths();
  for (int i = 0; i < n; i++) {
    cout << "node " << i << ": ";
    cout << "parent = " << parentsAndDepths[i].first << ", ";
    cout << "depth = " << parentsAndDepths[i].second << ", ";
    cout << nodeType(i) << ", ";
    cout << children(i);
    cout << endl;
  }
  return 0;
}



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

int main() {
    int N;
    int t[110000], x[110000], y[110000];
    cin >> N;
    t[0] = x[0] = y[0] = 0;
    for (int i=0; i<N; ++i) cin >> t[i+1] >> x[i+1] >> y[i+1];

    bool can = true;
    for (int i=0; i<N; ++i){
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist) can = false;
        if (dist % 2 != dt % 2) can = false;
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <cstdlib>
 
int main(){
 int n;
 int ans = 0;
 while(true){
 n = 0;
 scanf("%d\n",&n);
 if(n == 0) break;
 ans = 0;
 for(int a = 9;a >= 0;a--){
   for(int b = 9;b >= 0;b--){
     for(int c = 9;c >= 0;c--){
       for(int d = 9;d >= 0;d--){
        if(a+b+c+d == n){ans++; break;}
        if(a+b+c+d < n) break;
       }
     }
   }
 }
 printf("%d\n",ans);
 }
}

Measured memory_bytes: 2572
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

int main()
{
    ll n=in(),k=in();
    vector<ll>h(n);for(ll i=0;i<n;++i)h[i]=in();
    cout<<count_if(h.begin(),h.end(),[k](int x){return x>=k;})<<endl;    
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int k;cin >> k;
  int res = 0;
  rep1(i,k) rep1(j,k) rep1(l,k) {
    res += gcd(i,gcd(j,l));
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        
        int cnt = 0;
        if (x >= z)
            x -= z;
        
        while (x >= y+z) {
            cnt++;
            x -= (y + z);
        }

        System.out.println(cnt);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a;
    string str;
    cin >> a;
    cin >> str;

    bool ret = false;

    if (str.size() % 2 == 1)
    {
        
    }
    else
    {
        ret = true;

        for (int i = 0; i < str.size() / 2; i++)
        {
            if (str.at(i) != str.at(str.size() / 2 + i)){
                ret = false;
            }
        }
    }

    if (ret){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

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

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll int ara[100002],cost[100002];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>ara[i];
    cost[0]=cost[1]=0;
    for(int i=2;i<=n;i++)
    {
        cost[i]=cost[i-1]+abs(ara[i]-ara[i-1]);
        if(i!=2)
        {
            cost[i]=min(cost[i],cost[i-2]+abs(ara[i]-ara[i-2]));
        }
    }
    cout<<cost[n]<<endl;
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M=map(int,input().split())
    p=list(map(int1,input().split()))
    class UnionFind:
        def __init__(self,n):
            self.par=[i for i in range(n)]
            self.siz=[1]*n
            
        def root(self,x):
            while self.par[x]!=x:
                self.par[x]=self.par[self.par[x]]
                x=self.par[x]
            return x
        
        def unite(self,x,y):
            x=self.root(x)
            y=self.root(y)
            if x==y:
                return False
            if self.siz[x]<self.siz[y]:
                x,y=y,x
            self.siz[x]+=self.siz[y]
            self.par[y]=x
            return True
        
        def is_same(self,x,y):
            return self.root(x)==self.root(y)
        
        def size(self,x):
            return self.siz[self.root(x)]
    
    u=UnionFind(N)
    for _ in range(M):
        x,y=map(int1,input().split())
        u.unite(x,y)
    ans=0
    for i in range(N):
        if u.is_same(i,p[i]):
            ans+=1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61036
#include<stdio.h>
int main(void)
{
	int p[15][15];
	int x,y,z;
	int i,j;
	int max,cnt;
	max=0;
	cnt=0;
	
	for(i=0;i<14;i++){
		for(j=0;j<14;j++){
			p[i][j]=0;
		}
	}
	while(scanf("%d,%d,%d",&x,&y,&z)!=EOF){
		p[x+2][y+2]++;
		p[x+3][y+2]++;
		p[x+1][y+2]++;
		p[x+2][y+3]++;
		p[x+2][y+1]++;
		if(z==2){
			p[x+3][y+3]++;
			p[x+3][y+1]++;
			p[x+1][y+3]++;
			p[x+1][y+1]++;
		}
		else if(z==3){
			p[x+3][y+3]++;
			p[x+3][y+1]++;
			p[x+1][y+3]++;
			p[x+1][y+1]++;
			p[x+4][y+2]++;
			p[x][y+2]++;
			p[x+2][y+4]++;
			p[x+2][y]++;
		}
	/*	for(i=2;i<12;i++){
			for(j=2;j<12;j++){
				printf("%d ",p[i][j]);
			}
			printf("\n");
		}
		printf("\n");
	*/}
	for(i=2;i<12;i++){
		for(j=2;j<12;j++){
			if(p[i][j]==0){
				cnt++;
			}
			else if(max<p[i][j]){
				max=p[i][j];
			}
		}
	}
	printf("%d\n%d\n",cnt,max);
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    char rez;
    cin >> a >> b;
    if (a * b == 15)
        rez = '*';
    else if(a + b == 15)
        rez = '+';
    else
        rez = 'x';
    cout << rez;
    return 0;
}


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

using namespace std;

int main(void) {
    string s1;
    cin >> s1;
    int n = s1.size() - 1;
    long ans = 0;
    for (int bit = 0; bit < (1 << n); bit++) {
        string s2 = "";
        s2 += s1[0];
        for (int i = 0; i < n; i++) {
            if (bit & (1 << i)) {
                ans += stoi(s2);
                s2 = "";
            }
            s2 += s1[i + 1];
        }
        ans += stoll(s2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define ll long long
#define pai 3.1415926535897932384626433832795028841971693

int main(){
 int a,b;
 scanf("%d %d",&a,&b);
 if(a<=b){
   printf("%d",a);
 }
  else{
    printf("%d",a-1);
  }
  return 0;
}
 

Measured memory_bytes: 1692
#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);

	int n, m, l;
	cin >> n >> m >> l;
	vector<vector<ll>> A(n, vector<ll>(m));
	vector<vector<ll>> B(m, vector<ll>(l));
	rep(i, n) rep(j, m) cin >> A[i][j];
	rep(i, m) rep(j, l) cin >> B[i][j];
	rep(i, n) {
		rep(j, l) {
			ll ans = 0; 
			rep(k, m) {
				ans += A[i][k] * B[k][j];
			}
			printf("%lld%c", ans, j == l - 1 ? '\n' : ' ');
		}
	}
}



Measured memory_bytes: 3372
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const int MAX = 510000;
const ll mod = 1e9+7;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i-1] * (ll)i % mod;
    inv[i] = mod - inv[mod%i] * (mod/(ll)i) % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}

ll COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

ll Pow(ll x, ll n){
  if(n == 0) return 1;
  if(n % 2 == 0) return Pow(x*x % mod,n/2);
  else return x * Pow(x,n-1) % mod;
}

int main(){
  ll n, k;
  cin >> n >> k;
  COMinit();
  if(n < k) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0;
  rep(i,k) {
    if(i % 2 == 0) (ans += Pow(k-i,n) * COM(k,k-i)) %= mod;
    else (ans -= Pow(k-i,n) * COM(k,k-i)) %= mod;
  }
  for(ll i = 1; i <= k; i++) ans = ans * inv[i] % mod;
  if(ans < 0) ans += mod;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 15040
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	long long int sum = 0;
	int temp = n;

	while(temp!=0)
	{
		sum+=(temp%10);
		temp/=10;
	}

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

	return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int n;
	cin >> n;
	map<string,int> mp;
	for(int i = 0;i < n;i++){
		string s;
		cin >> s;
		mp[s]++;
	}

	printf("AC x %d\n",mp["AC"]);
	printf("WA x %d\n",mp["WA"]);
	printf("TLE x %d\n",mp["TLE"]);
	printf("RE x %d\n",mp["RE"]);
}


Measured memory_bytes: 3724
#include <iostream>
#include <cmath>

using namespace std;
typedef long long ll;

const int MAXN=2e5+5;

int N;
ll a[MAXN], pref[MAXN];

int main()
{
        cin >> N;
        for (int i=0; i<N; i++)
                cin >> a[i];

        pref[0]=0;
        for (int i=1; i<=N; i++)
                pref[i] = pref[i-1]+a[i-1];

        ll mn=abs(2*pref[1]-pref[N]);
        for (int i=1; i<=N-1; i++) {
                ll x = abs(2*pref[i]-pref[N]);
                mn = min(mn,x);
        }

        cout << mn << "\n";

}

Measured memory_bytes: 3328
package main

import "fmt"

var popcntCache [256]byte

func popcntInit() {
	for i := range popcntCache {
		popcntCache[i] = popcntCache[i>>1] + byte(i&1)
	}
}

func popcnt(mask uint) byte {
	// mask < (1<<21) so we need to check only 3 bytes
	return popcntCache[byte(mask)] + popcntCache[byte(mask>>8)] + popcntCache[byte(mask>>16)]
}

func matching(n uint, m [21][21]uint) uint32 {
	const mod = 1e9 + 7
	maxmask := uint(1) << n
	d := make([]uint32, maxmask)
	d[0] = 1

	for mask := uint(1); mask < maxmask; mask++ {
		x := popcnt(mask) - 1
		for y := uint(0); y < n; y++ {
			ymask := uint(1) << y
			if ymask&mask != 0 && m[x][y] == 1 {
				d[mask] = (d[mask] + d[mask&^ymask]) % mod
			}
		}
	}
	return d[maxmask-1]
}

func main() {
	popcntInit()
	var n, x uint
	fmt.Scan(&n)
	var m [21][21]uint
	for i := uint(0); i < n; i++ {
		for j := uint(0); j < n; j++ {
			fmt.Scan(&x)
			m[i][j] = x
		}
	}
	fmt.Println(matching(n, m))
}


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

int main() {

  string S;
  int N;
  cin >> S;
  N=S.size();
//  cout<<N<<endl;
 
// cout<<S<<endl;
  
  for (int i=0;i<N;i++){
    S.at(i) ='x';
  }
  
  cout<<S<<endl;
}


Measured memory_bytes: 256
a, b, k = map(int, input().split())
m = 0
ans = []

if a < b:
    m = b
    n = a
else:
    m = a
    n = b

for i in range(1, n+1):
    if m % i == 0 and n % i == 0:
        ans.append(i)

if ans:
    print(ans[-k])
else:
    print("1")


Measured memory_bytes: 3060
# coding:utf-8

import sys


input = sys.stdin.readline
INF = float('inf')
MOD = 10 ** 9 + 7


def inpl(): return list(map(int, input().split()))


S = input().rstrip()

dp = [[0] * 4 for _ in range(len(S) + 1)]
dp[0][0] = 1
for i in range(len(S)):
    if S[i] == '?':
        dp[i + 1][0] = (dp[i][0] * 3) % MOD
        dp[i + 1][1] = (dp[i][1] * 3 + dp[i][0]) % MOD
        dp[i + 1][2] = (dp[i][2] * 3 + dp[i][1]) % MOD
        dp[i + 1][3] = (dp[i][3] * 3 + dp[i][2]) % MOD
    else:
        for j in range(4):
            dp[i + 1][j] = dp[i][j]

        if S[i] == 'A':
            dp[i + 1][1] = (dp[i + 1][1] + dp[i][0]) % MOD
        if S[i] == 'B':
            dp[i + 1][2] = (dp[i + 1][2] + dp[i][1]) % MOD
        if S[i] == 'C':
            dp[i + 1][3] = (dp[i + 1][3] + dp[i][2]) % MOD

print(dp[-1][-1])


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

int my_max(int c,int d, int e){
    if(c >= d && c >= e){
      return c;
    }
  else if(d >= c && d >= e){
    return d;
  }
 else if(e >= d && e >= c){
    return e;
 }
}

int main(){
    int a,b;
      cin >> a >> b;
   int c,d,e;
    c = a + b;
    d = a - b;
    e = a * b;
 int answer = my_max(c,d,e);
   cout << answer << endl;
}
 

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

char A[N],B[N];
set <int> V[27];
set <int> ::iterator it;
int Cnt[330];
int main() {
	scanf("%s",A+1);
	scanf("%s",B+1);
	int l1 = strlen(A+1),l2 = strlen(B+1);
	for(int i=1; i<=l1; i++) {
		Cnt[(int)A[i]] ++;
		V[A[i]-'a'].insert(i);
	}
	for(int i=1; i<=l2; i++) {
		if(Cnt[(int)B[i]] == 0) {
			puts("-1");
			return 0;
		}
	}
	int cnt = 0,la = 1;
	for(int i=1; i<=l2; i++) {
		int c = B[i]-'a';
		it = V[c].lower_bound(la);
		if(it == V[c].end()) {
			cnt ++;
			la = 1;
			it = V[c].lower_bound(la);
		}
		la = *it+1;
	}
	cout<<1LL*cnt*l1+la-1;
	return 0;
}

Measured memory_bytes: 5248
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> connect(m, vector<int>());
    vector<int> type(m); 
    rep(i, m){
        int k; cin >> k;
        rep(j, k){
            int s; cin >> s; s--;
            connect[i].push_back(s);
        }
    }
    rep(i, m) cin >> type[i];

    int res = 0;
    for(int bit = 0; bit < (1 << n); bit++){
        bool f = true;
        rep(i, m){
            int number = 0;
            for(int denkyu: connect[i]){
                int on_off = bit & (1 << denkyu);
                if(on_off) number++;
            } 
            if(type[i] != number % 2){
                f = false;
                break;
            }
        }
        if(f) res++;
    }
    cout << res << ln;

}


Measured memory_bytes: 256