akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h> 
#define WHITE 0
#define GRAY 1
#define BLACK 2

void DFS_init(void);
void DFS(int id);

int n,Adj[100][100];
int color[100],d[100],f[100],time;

int main()
{
  int i,j,id,k,v;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      Adj[i][j]=0;
  
  for(i=0;i<n;i++){
    scanf("%d%d",&id,&k);
    id--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      Adj[id][v]=1;
    }
  }
  DFS_init();

  return 0;
}

void DFS_init(void)
{
  int id;

  for(id=0;id<n;id++) color[id]=WHITE;  
  time=0;
  
  for(id=0;id<n;id++)
    if(color[id]==WHITE) DFS(id);
  
  for(id=0;id<n;id++) printf("%d %d %d\n",id+1,d[id],f[id]);
}

void DFS(int id)
{
  int v;

  color[id]=GRAY;
  d[id]=++time;

  for(v=0;v<n;v++){
    if(Adj[id][v]==0) continue;
    if(color[v]==WHITE) DFS(v);
  }
  color[id]=BLACK;
  f[id]=++time;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl

struct Penaruty {
  int count = 0;
  bool didAC = false;
};
// penaruty 綴り


signed main(){
  int N, M; cin >> N >> M;
  vector<bool> isACs(100005);
  vector<Penaruty> WACounts(100005);

  REP(i, M) {
    int p; cin >> p;
    string s; cin >> s;

    if (s == "AC") {
      isACs.at(p) = true;
      WACounts.at(p).didAC = true;
    } else if (s == "WA") {
      if (WACounts.at(p).didAC == false) {
        WACounts.at(p).count += 1;
      }
    }
  }

  int amountOfAC = 0;
  int amountOfPenaruty = 0;
  FOR1(x, 100000) {
    if (isACs.at(x)) {
      ++amountOfAC;
      amountOfPenaruty += WACounts.at(x).count;
    }
  }

  cout << amountOfAC << ' ' << amountOfPenaruty << endl;
}


Measured memory_bytes: 1920
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <time.h>
#include <random>
using namespace std;

int64_t comb(int n, int k){
    static int64_t memo[51][51];
    if(k==0||k==n) return 1;
    if(memo[n][k]) return memo[n][k];
    return memo[n][k]=comb(n-1,k-1)+comb(n-1,k);
}

int main(){
    int64_t N,A,B;
    cin>>N>>A>>B;
    vector<int64_t> V(N);
    for(auto &v:V) cin>>v;
    sort(V.begin(), V.end(), greater<int64_t>());
    double sum=0;
    for(int i=0;i<A;i++) sum+=V[i];
    printf("%.10f\n",sum/A);
    int64_t cnt = 0;
    int n=0,k=0;
    if(V[0]!=V[A-1]){
        for(int i=0;i<N;i++)n+=V[i]==V[A-1];
        for(int i=0;i<A;i++)k+=V[i]==V[A-1];
        cnt=comb(n,k);
    }else{
        for(int i=0;i<N;i++)n+=V[i]==V[0];
        for(int k=A;k<=n&&k<=B;k++)cnt+=comb(n,k);
    }
    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    string S1;
    string S2;
    io.read(S1, S2);
    string ans = "YES";
    for(int i = 0; i < S1.size(); i++){
        if(S1[i] != S2[S1.size() - i - 1]){
            ans = "NO";
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
using System;
class TEST
{
    public static void Main()
    {
        string S = Console.ReadLine();
        string T = Console.ReadLine();

    Console.WriteLine(  T.Length-  Atteru(T,S));
     //   Console.ReadKey();
    }

    static int Atteru(string t, string s)
    {
        int bestcount = -1;
        //int pointer=0;

        for (int i = 0; i < s.Length - t.Length+1; i++)
        {
            int count = 0;
            for (int j = 0; j < t.Length; j++)
            {
                if (s[i+j] == t[j])
                {
                    count++;
                }

                
            }

            if (bestcount < count)
                bestcount = count;
        }

        return bestcount;
    }

}

Measured memory_bytes: 25852
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;

vector<ii> vec;

bool ord(const pair<int,int> &a, const pair<int,int> &b){
    if(a.first == b.second) return (a.second > b.second);
    return (a.first > b.second);
}

int main(){
    int n, m; cin >> n >> m;
    for(int i = 0; i < n; i++){
        int x, y; cin >> x >> y;
        vec.push_back({y, x});
    }
    
    sort(vec.rbegin(), vec.rend());
    set<int> s;
    for(int i = 1; i <= m; i++)
        s.insert(i);
    long long res = 0;
    for(ii par : vec){
        int val = par.first, tempo = par.second;
        auto it = s.lower_bound(tempo);
        if(it != s.end())
            res += val, s.erase(it);
    }
    cout << res << endl;
	return 0;
}

Measured memory_bytes: 5748
#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)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    int N,M,tmp;
    cin >> N >> M;
    priority_queue<int> pq;
    rep(i,N) cin >> tmp, pq.push(tmp);
    
    rep(i,M){
        tmp = pq.top();
        pq.pop();
        pq.push(tmp/2);
    }
    
    ll sum = 0;
    rep(i,N){
        tmp = pq.top();
        pq.pop();
        sum += tmp;
    }
    
    pr(sum);
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int Q,L,R,v[100100],cnt[100100];
vector<int> pr;
void Linear(int nn){
	memset(v,0,sizeof(v));
	pr.clear();
	for(int i=2;i<=nn;i++){
		if(v[i]==0){v[i]=i,pr.push_back(i);}
		for(int j=0;j<pr.size();j++){
			if(pr[j]>v[i]||pr[j]>nn/i) break;
			v[i*pr[j]]=pr[j];
		}
	}
	for(int i=1;i<=nn;i++){
		cnt[i]=cnt[i-1];
		if((i%2==1))
			if((v[i]==i)&&(v[(i+1)/2]==((i+1)/2))) cnt[i]++;
	}
}
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	Linear(100000);
	cin>>Q;
	while(Q--){
		cin>>L>>R;
		cout<<cnt[R]-cnt[L-1]<<endl;
	}
	return 0;
}



Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

string s, t;
int q, y[100001], h[100001];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> s >> t >> q;
    s = ';' + s;
    t = ';' + t;
    for(int i = 1 ; i < (int)s.size() ; i++)
        y[i] = y[i - 1] + s[i] - 'A';
    for(int i = 1 ; i < (int)t.size() ; i++)
        h[i] = h[i - 1] + t[i] - 'A';
    while(q--){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int n[2], m[2];
        n[0] = y[b] - y[a - 1];
        n[1] = b - a + 1 - n[0];
        m[0] = h[d] - h[c - 1];
        m[1] = d - c + 1 - m[0];
        n[1] += m[0] - n[0];
        if(n[1] > 0 && (n[1] - m[1]) % 3 == 0){
            cout << "YES" << endl;
            continue;
        }
        n[0] = y[b] - y[a - 1];
        n[1] = b - a + 1 - n[0];
        m[0] = h[d] - h[c - 1];
        m[1] = d - c + 1 - m[0];
        n[0] += m[1] - n[1];
        if(n[0] > 0 && (n[0] - m[0]) % 3 == 0){
            cout << "YES" << endl;
            continue;
        }
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 1644
#include<bits/stdc++.h>
using namespace std;
long long fun(long long x,long long y)
{
     long long pow = 10;
    while(y >= pow)
        pow *= 10;
    return x * pow + y;
}
int main()
{
    long long a,b,c,k;
    cin>>a>>b;
    k=fun(a,b);
    c=sqrt(k);
    double r;
    r=sqrt(k);
    if(c==r){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;

}


Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String args[]){
    	Scanner sc=new Scanner(System.in);
      	int n=sc.nextInt();
      	HashMap<String,Integer> hm=new HashMap<>();
      	while(n--!=0){
        String str=sc.next();
          if(hm.containsKey(str)){
          	
          }else{
          	hm.put(str,1);
          }
        }
      System.out.println(hm.size());
    }
}


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

int main()
{
	string s1,ans="";
	cin>>s1;
	for (int i=0;i<=s1.size()-1;i++)
	{
		if (s1[i]=='0')  ans=ans+'0';
		if (s1[i]=='1')  ans=ans+'1';
		if (s1[i]=='B')
		{
			if (ans.size()==0)  continue;
			if (ans.size()==1)
			{
				ans="";
				continue;
			}
			ans=ans.substr(0,ans.size()-1);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

const long long r = 1e9 + 7;

long long d[100001][13];

int main() {
	string str;
	cin >> str;
	str += '!';
	reverse(str.begin(), str.end());

	d[0][0] = 1;
	long long p = 1;
	for (int i = 1; i < str.length(); ++i) {
		if (str[i] != '?')
			for (int j = 0; j < 13; ++j) {
				d[i][(j + p * (str[i] - '0')) % 13] += d[i - 1][j];
				d[i][(j + p * (str[i] - '0')) % 13] %= r;
			}
		else
			for (int j = 0; j < 13; ++j)
				for (int k = 0; k < 10; ++k) {
					d[i][(j + p * k) % 13] += d[i - 1][j];
					d[i][(j + p * k) % 13] %= r;
				}

		p = p * 10 % 13;
	}

	printf("%lld", d[str.length() - 1][5]);

	return 0;
}

Measured memory_bytes: 10624
L = input()
n = len(L)

onecnt = 0
ans = 0

MOD = 10 ** 9 + 7

for i in range(n):
    if L[i] == '0':continue
    onecnt += 1
    rest = n - i - 1
    ans += pow(2, onecnt - 1, MOD) * pow(3, rest, MOD) % MOD
    ans %= MOD
ans += pow(2, onecnt, MOD)
print(ans % MOD)


Measured memory_bytes: 3188
#include"bits/stdc++.h"
using namespace std;

int main(){
    int n; cin >> n;
    vector<int> a; a.resize(n);
    vector<int> b; b.resize(n);
    vector<int> c; c.resize(n-1);

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

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <fstream>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef map<int, int> mii;
typedef map<int, string> mis;
typedef map<string, int> msi;
typedef set<int> si;
typedef set<ll> sl;
typedef map<ll, ll> mll;
typedef queue<int> qi;
typedef queue<ii> qii;
typedef vector<string> vs;
typedef pair<ll, ll> iil;
typedef vector<iil> viil;

#define pb push_back
#define mp make_pair
#define rep(i, n) for (int i = 0 ; i < n ; i++)
#define INF 1000000000

void solve() {
    ll x;
    cin >> x;
    ll prec[405];
    for (int i = -200 ; i <= 200 ; i++) {
        prec[i + 200] = pow(i, 5);
    }
    for (int i = 0 ; i < 400 ; i++) {
        for (int j = 0 ; j < 400 ; j++) {
            if (prec[i] - prec[j] == x) {
                cout << i - 200 << " " << j - 200 << endl;
                return;
            }
        }
    }
}

void querySolve() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    solve();
    //querySolve();
}


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

#define ll long long
#define loop(i,a,b) for(int i = a ; i < b; i++)
#define loop2(i,a,b) for(int i = a; i >= b ; i--)
#define fi first
#define se second
#define VI vector<int>

using namespace std;

int INF = 1e9 + 7;
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a; 
	}
	a %= b;
	return gcd(b, a);
}

ll sum_of_digits(ll x) {
	ll s = 0;
	while (x) {
		s += x % 10;
		x /= 10;
	}
	return s;
}

bool check_prime(ll x) {
	if (x == 1) {
		return false;
	}
	else {
		for (int i = 2; i * i <= x; i++) {
			if (x % i == 0) {
				return false;
			}
		}
		return true;
	}
}

ll binpow(ll x, ll n) {
	if (n == 0) {
		return 1;
	}
	else {
		if (n % 2 == 0) {
			ll z = binpow(x, n >> 1);
			return z * z;
		}
		else {
			return (x * binpow(x, n - 1));
		}
	}
}

bool desc(int a, int b) {
	return (a > b);
}

int main() {
	string s, t;
	cin >> s >> t;
	int n = s.length();
	int cnt = 0;
	loop(i, 0, n) {
		if (s[i] != t[i]) {
			cnt++;
		}
	}
	cout << cnt;
}

Measured memory_bytes: 3844
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n;
vector<int> vec[100005];
int visited[100005];
long long int ans[100005][2];
void dfs(int u){
    visited[u] = 1;
    long long int pro1 = 1, pro2 = 1;
        for(int v:vec[u]){
            if(!visited[v]){
                dfs(v);
                long long int a = (ans[v][0] + ans[v][1])%mod;
                long long int b = ans[v][0];
                pro1 = (pro1 *a)%mod;
                pro2 = (pro2 *b)%mod;
            }
        }
        ans[u][0] = pro1;
        ans[u][1] = pro2;
        // cout << u << " " << ans[u][0] << " " << ans[u][1] << "\n";
}
int main(){
    cin >> n;
    for(int i=1;i<n;i++){
        int u, v;
        cin >> u >> v;
        vec[u].push_back(v);
        vec[v].push_back(u);
    }    
    dfs(1);
    cout << (ans[1][0] + ans[1][1])%mod;
}

Measured memory_bytes: 17936
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	lli x;
	cin >> x;
		
	int m = x%11ll;
		
	if     (m == 0) cout << (x/11ll)*2ll << endl;
	else if(m >= 7) cout << (x/11ll)*2ll+2ll << endl;
	else            cout << (x/11ll)*2ll+1ll << endl;
	return 0;
}

Measured memory_bytes: 256
program main
implicit none
integer :: sx, sy, tx, ty
integer :: ix, iy, i, j, k
character :: res*20000

read(*,*) sx, sy, tx, ty

i = tx -sx
j = ty -sy
k = 1
do ix = k, k+i-1
   res(ix:ix) = 'R'
end do
k = k+i
do iy = k, k+j-1
   res(iy:iy) = 'U'
end do
k = k+j
do ix = k, k+i-1
   res(ix:ix) = 'L'
end do
k = k+i
do iy = k, k+j-1 
   res(iy:iy) = 'D'
end do
k = k+j
res(k:k) = 'D'
k = k+1
do ix = k, k+i
   res(ix:ix) = 'R'
end do
k = k+i+1
do iy = k, k+j
   res(iy:iy) = 'U'
end do
k = k+j+1
res(k:k+1) = 'LU'
k = k+2
do ix = k, k+i
   res(ix:ix) = 'L'
end do
k = k+i+1
do iy = k, k+j
   res(iy:iy) = 'D'
end do
k = k +j+1
res(k:k) = 'R'
write(*,*) res(1:k)


end program main


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

int main() {
  int n;
  cin >> n;
  double total = 0;
  vector<int> a(n);
  for(int i=0;i<n;i++) {
    cin >> a[i];
    total += a[i];
  }

  double average = total / n;

  int ans = 0;
  double minD = 1000000.0;

  for(int i=0;i<n;i++) {
    if(abs(average-a[i]) < minD) {
      minD = abs(average-a[i]);
      ans = i;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque
from sys import stdin
input = stdin.readline

class Element:
    def __init__(self, node):
        self.node = node
        self.parent = -1
        self.depth = 0
        self.status = "internal node"
        self.children = None
    
    def display(self):
        print("node %d: parent = %d, depth = %d, %s, %s"
        %(self.node, self.parent, self.depth, self.status, str(self.children)))
        
N = int(input())

NODE_DICT = {}
ROOT_SEARCH = [True]*N

for loop in range(N):
    DATA = list(map(int, input().split()))
    node = DATA[0]    
    tmp = Element(node)
    tmp.children = DATA[2:]
    NODE_DICT[node] = tmp
    for i in tmp.children:
        ROOT_SEARCH[i] = False
    
#for node in NODE_DICT.keys():
#    for child in NODE_DICT[node].children:
#        ROOT_SEARCH[child] = False


for key in range(len(ROOT_SEARCH)):
    if ROOT_SEARCH[key]:
        root = key

def Process(parent):
    for child in parent.children:
        NODE_DICT[child].parent = parent.node
        NODE_DICT[child].depth = parent.depth + 1
    if parent.children == []:
        parent.status = "leaf"
    else:
        for child in parent.children:
            Process(NODE_DICT[child])
    

Process(NODE_DICT[root])
NODE_DICT[root].status = "root"

for i in range(N):
    NODE_DICT[i].display()

#for node in range(len(NODE_DICT)):
#    print("node %d: parent = %d, depth = %d, %s, %s"%(NODE_DICT[node].node, 
#    NODE_DICT[node].parent, NODE_DICT[node].depth, NODE_DICT[node].status, 
#   str(NODE_DICT[node].children)))


Measured memory_bytes: 44604
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		long a = scn.nextLong();
		long b = scn.nextLong();
      	long x = scn.nextLong();
      	long aa = a/x;
      	long bb = b/x;
      	if(a%x==0) System.out.println(bb-aa+1);
      	else System.out.println(bb-aa);
	}
}


Measured memory_bytes: 35628
import math

N, D = [int(x) for x in input().split()]
x = []

for _ in range(N):
    x.append([int(x) for x in input().split()])

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        sum = 0
        for k in range(D):
            sum += (x[i][k] - x[j][k]) ** 2
        if math.sqrt(sum).is_integer():
            ans += 1


print(ans)




Measured memory_bytes: 38512
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <typeinfo>
#include <list>
#include <queue>
#include <stack>
#include <limits.h>
#include <set>
#include <map>
#include <cstring>

using namespace std;

vector<int> ACNum(string S, vector<pair<int, int> > Q) {
    int n = S.size(), n_q = Q.size();
    vector<int> record(n, 0);
    vector<int> res(n_q);
    for (int i = 0; i < n; i++) {
        if (i < n - 1 && S.substr(i, 2) == "AC") {
            record.push_back(i + 1);
        }
    }
    
    for (int i = 0; i < n_q; i++) {
        vector<int>::iterator left = lower_bound(record.begin(), record.end(), Q[i].first);
        vector<int>::iterator right = lower_bound(record.begin(), record.end(), Q[i].second);
        res[i] = right - left;
    }
    return res;
}


int main() {
    ios::sync_with_stdio(false);
    int N, Q;
    string S;
    cin >> N >> Q;
    cin >> S;
    vector<pair<int, int> > q;
    for (int i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;
        q.push_back({l, r});
    }
    vector<int> res = ACNum(S, q);
    for (int i = 0; i < Q; i++) {
        cout << res[i] << endl;
    }
    return 0;
}


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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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; }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}
const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		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] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
signed main(){
	int n,m;
	cin>>n>>m;
	int s[2010],t[2010];
	rep(i,n)cin>>s[i];
	rep(i,m)cin>>t[i];
	int dp[2010][2010];
	rep(i,n+1){
		rep(j,m+1){
			if(i==0||j==0){
				dp[i][j]=1;
				continue;
			}
			dp[i][j]=(dp[i][j-1]+dp[i-1][j]-dp[i-1][j-1])%MOD;
			if(s[i-1]==t[j-1])dp[i][j]+=dp[i-1][j-1];
			dp[i][j]%=MOD;
		}
	}
	cout<<(dp[n][m]+MOD)%MOD<<endl;
}


Measured memory_bytes: 31744
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define re register int
#define db double
#define in inline
namespace fast_io
{
	char buf[1<<12],*p1=buf,*p2=buf,sr[1<<23],z[23],nc;int C=-1,Z=0,Bi=0;
	in char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
	in ll read()
	{
		ll x=0,y=1;while(nc=gc(),(nc<48||nc>57)&&nc!=-1)if(nc==45)y=-1;Bi=1;
		x=nc-48;while(nc=gc(),47<nc&&nc<58)x=(x<<3)+(x<<1)+(nc^48),Bi++;return x*y;
	}
	in db gf() {re a=read(),b=(nc!='.')?0:read();return (b?a+(db)b/pow(10,Bi):a);}
	in int gs(char *s) {char c,*t=s;while(c=gc(),c<32);*s++=c;while(c=gc(),c>32)*s++=c;return s-t;}
	in void ot() {fwrite(sr,1,C+1,stdout);C=-1;}
	in void flush() {if(C>1<<22) ot();}
	template <typename T>
	in void write(T x,char t)
	{
		re y=0;if(x<0)y=1,x=-x;while(z[++Z]=x%10+48,x/=10);
		if(y)z[++Z]='-';while(sr[++C]=z[Z],--Z);sr[++C]=t;flush();
	}
	in void write(char *s) {re l=strlen(s);for(re i=0;i<l;i++)sr[++C]=*s++;sr[++C]='\n';flush();}
}
using namespace fast_io;
const int N=1e5+5;
#define int ll
int n,m,v,p,a[N],P;ll b[N];
signed main()
{
	n=read();m=read();v=read();p=read();
	for(int i=1;i<=n;i++) a[i]=read();sort(a+1,a+n+1);
	int l=1,r=n-p+1,mid,ans=p;
	while(l<=r)
	{
		mid=(l+r)>>1;ll nw=a[mid]+m,op=1,sum=0;
		for(int i=mid+1;i<=n-p+1;i++) sum+=nw-a[i],op&=(nw-a[i]>=0);
		if(sum>=(ll)(v-p-mid+1)*m&&op) ans=mid,r=mid-1;
		else l=mid+1;
	}
	cout<<n-ans+1; 
	return ot(),0;
}
//Author: disangan233
//In my dream's scene,I can see the everything that in Cyaegha.

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

long long x, y, a, b, c, ans=0, aa[100003], bb[100003];
vector<long long>v;

int main(){
	cin >> x >> y >> a >> b >> c;
	v.resize(c);
	for (int i=0;i<a;i++) cin >> aa[i];
	for (int i=0;i<b;i++) cin >> bb[i];
	for (int i=0;i<c;i++) cin >> v[i];
	sort(aa,aa+a,greater<long long>());
	sort(bb,bb+b,greater<long long>());
	for (int i=0;i<x;i++) v.push_back(aa[i]);
	for (int i=0;i<y;i++) v.push_back(bb[i]);
	sort(v.begin(),v.end(),greater<long long>());
	for (int i=0;i<x+y;i++) ans+=v[i];
	cout << ans << "\n";
}

Measured memory_bytes: 6384
n,t = map(int,input().split())
arr = []
for i in range(n):
    arr.append(list(map(int,input().split())))
arr.sort(key = lambda x:x[0])
dp = [[0]*(t+1) for _ in range(n + 1)]
for i in range(n):
    for j in range(t + 1):
        if j > 0:
            if j - arr[i][0] > 0.5: dp[i + 1][j-arr[i][0]] = max(dp[i + 1][j-arr[i][0]],dp[i][j] + arr[i][1])
            else:
                dp[i + 1][0] = max(dp[i + 1][0],dp[i][j] + arr[i][1])
        dp[i + 1][j] = max(dp[i + 1][j],dp[i][j])
print(max(dp[n]))


Measured memory_bytes: 118744
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
  int N;
  cin >> N;
  int S=0,n=N;
  for(int i=0;i<10;i++){
    S+=n%10;
    n/=10;
  }
  if(N%S==0)  cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}


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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  string first_s, second_s;
  int first_n, second_n;
  cin >> first_s >> second_s;
  cin >> first_n >> second_n;
  string tmp;
  cin >> tmp;
  if(tmp == first_s) {
    first_n--;
  } else {
    second_n--;
  }
  cout << first_n << " " << second_n;

  
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

int main(){
  int n;cin >> n;
  int a[n/2],b[n/2];
  rep(i,n){
      if(i%2 == 0) cin >> a[i/2];
      else cin >> b[i/2];
  }
  sort(a,a+n/2); sort(b,b+n/2);
  int af,bf,as,bs,Anum = a[0],Bnum = b[0];
  af = bf = as = bs = 0;
  int i = 1;
  while(i<(n/2)){
    int l = 1;
    while(a[i-1]==a[i]) {
      l++;i++;
    }
    if(l>af){
        as = af;af = l;Anum = a[i-1];
    }else if(l > as) as = l;
    
    i++;
  }
  i = 1;
  while(i<(n/2)){
    int l = 1;
    while(b[i-1]==b[i]){
        l++;i++;
    }
    if(l>bf){
        bs = bf; bf = l;Bnum = b[i-1];
    }else if(l>bs) bs = l;

    i++;
  }
  if(Anum == Bnum){
      cout << min(n-af-bs, n-as-bf) << endl;
  }else{
      cout << n-af-bf << endl;
  }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 1<<19;

int n,dat[2][2*MAX_N-1],idx;

//?????????
void init(int n_){
  //????´???°n???2???????????????
  n=1;
  while(n<n_)n*=2;
  for(int i=0;i<2*n-1;i++)
    dat[0][i]=dat[1][i]=INT_MAX;
}

//k???????????????a????????´
void update(int k,int a){
  k+=n-1;
  dat[idx][k]=a;
  while(k>0){
    k=(k-1)/2;
    dat[idx][k]=min(dat[idx][k*2+1],dat[idx][k*2+2]);
  }
}

//[a,b)???????°????????±???????
//query(a,b,0,0,n)
int query(int a,int b,int k=0,int l=0,int r=n){
  if(r<=a||b<=l)return INT_MAX;
  if(a<=l&&r<=b)return dat[idx][k];
  else{
    int v1=query(a,b,k*2+1,l,(l+r)/2);
    int vr=query(a,b,k*2+2,(l+r)/2,r);
    return min(v1,vr);
  }
}

//Suffix_Array
//O(|T|log|S|) S??????????????????T????????????????????????????´¢
#define rank A
int Len;
int rank[MAX_N+1];
int tmp[MAX_N+1];

//(rank[i],rank[i+k])??¨(rank[j],rank[j+k])?????????
bool compare_sa(int i,int j){
  if(rank[i]!=rank[j])return rank[i]<rank[j];
  int ri=i+Len<=n?rank[i+Len]:-1;
  int rj=j+Len<=n?rank[j+Len]:-1;
  return ri<rj;
}

//?????????S?????\?°??????????????§????
void construct_sa(string S,int *sa){
  n=S.length();
  //?????????????????????????????????????????????????????????
  for(int i=0;i<=n;i++){
    sa[i]=i;
    rank[i]=i<n?S[i]:-1;
  }
  //k????????????????????????????????????????????¨???????????????2k????????§?????????
  for(Len=1;Len<=n;Len*=2){
    sort(sa,sa+n+1,compare_sa);
    //?????£??????tmp????¬?????????????????¨?????????????rank?????£??\
    tmp[sa[0]]=0;
    for(int i=1;i<=n;i++)
      tmp[sa[i]]=tmp[sa[i-1]]+(compare_sa(sa[i-1],sa[i])?1:0);
    for(int i=0;i<=n;i++)rank[i]=tmp[i];
  }
}

//S??????????????????T????????????????????????????´¢??????
int contain(string S,int *sa,string T){
  int left=0,right=S.length();
  while(left<right){
    int mid=(left+right)/2;
    if(S.compare(sa[mid],T.length(),T)<0)left=mid+1;
    else right=mid;
  }
  return left;
}

string t,rt;
int q,sa[MAX_N],rsa[MAX_N];

int main(){
  cin>>t;
  t='{'+t+'{';
  construct_sa(t,sa);
  /*while(1){
    string check;
    cin>>check;
    cout<<contain(t,sa,check)<<endl;
    }*/
  rt=t;
  reverse(rt.begin(),rt.end());
  construct_sa(rt,rsa);
  
  init(n);
  
  idx=0;
  for(int i=0;i<n;i++)update(i,sa[i]);
  idx=1;
  for(int i=0;i<n;i++)update(i,rsa[i]);
  
  string l,r;
  cin>>q;
  while(q--){
    cin>>l>>r;

    reverse(r.begin(),r.end());
    string cpl=l,cpr=r;
    
    int minl=contain(t,sa,l);
    l[l.size()-1]++;
    int maxl=contain(t,sa,l);
    
    int minr=contain(rt,rsa,r);
    r[r.size()-1]++;
    int maxr=contain(rt,rsa,r);
    
    if(minl==maxl)maxl++;
    if(minr==maxr)maxr++;
    
    idx=0;
    int r1=query(minl,maxl);
    idx=1;
    int r2=query(minr,maxr);
    
    if(r1==INT_MAX||r2==INT_MAX){
      cout<<0<<endl;
      continue;
    }
    
    r2=t.size()-r2-1;
    
    if(t.substr(sa[minl],cpl.size())!=cpl||rt.substr(rsa[minr],cpr.size())!=cpr){
      cout<<0<<endl;
      continue;
    }
    
    if(r1+l.size()-1<=r2)cout<<r2-r1+1<<endl;
    else cout<<0<<endl;;
  }
  return 0;
}

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


int main(){

  long long N, i, a;
  bool flag = false;
  cin >> N;
  vector<long long> A(N);
  
  for (i = 0; i < N; i++){
    
    cin >> A.at(i);
    
    if(A.at(i) == 0){
      cout << 0 << endl;
      return 0;
    }
  }
  
  long long Asum = A.at(0);
  
  for (i = 1; i < N; i++){
    
    //if(Asum > 1000000000000000000ll || Asum < 0 || A || Asum > 1000000000000000000ll/A.at(i)){
    if(Asum > 1000000000000000000ll/A.at(i)){
      cout << -1 << endl;
      return 0;
    }
    Asum = Asum * A.at(i);
  }
  
  cout << Asum << endl;
  return 0;
}

Measured memory_bytes: 4052
def main():
    from collections import deque

    h, w = map(int, input().split())
    q = deque([])
    buffer = ["." for _ in range(w + 2)]
    for _ in range(h):
        r = ["."] + list(input()) + ["."]
        while q:
            i = q.pop()
            if r[i] == '.':
                print("No")
                exit()

        for i, (x, y, z) in enumerate(zip(r, r[1:], r[2:])):
            if (x, y, z) == (".", "#", ".") and buffer[i + 1] == ".":
                q.append(i + 1)

        buffer = r
    else:
        if q:
            print("No")
        else:
            print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#define _GLIBCXX_DEBUG

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

int main(){
    int N;
    vector<int> vec(N);
    cin >> N;

    int A = 0;
    int B = 0;

    rep(i, N)
    {
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end(), greater<int>());

    rep(i, N)
    {
        if(i % 2 == 0){
            A += vec.at(i);
        }else{
            B += vec.at(i);
        }
    }

    cout << A - B << endl;
    return 0;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
int solve(int h[],int n,int k,vector<int>&dp)
{
  if(n==1)
    return 0;
  if(dp[n]!=-1)
    return dp[n];
  int m=INT_MAX;
  for(int i=1;i<=k;i++)
  {
    if(n-i>0)
    {
      int temp=solve(h,n-i,k,dp)+abs(h[n-1]-h[n-1-i]);
      m=min(m,temp);
    }
  }
  return dp[n]=m;
}
int main()
{
  int n,k;
  cin>>n;
  cin>>k;
  int h[n];
  for(int i=0;i<n;i++)
    cin>>h[i];
  int ans;
  vector<int>dp(n+1,-1);
  ans=solve(h,n,k,dp);
  cout<<ans;
}


Measured memory_bytes: 8832
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        var count = 0;
        for (int i = 0; i < N; i++)
        {
            if (i % 2 == 0 && a[i] % 2 != 0)
            {
                count++;
            }
        }

        Console.WriteLine(count);
    }
}

Measured memory_bytes: 28096
#include<iostream>
#include<string>
#include<sstream>
#include<vector>
#include<algorithm>
#include<math.h>


using namespace std;
//typedef
struct t{
	int param;
	int yet;
};
int main(){


	struct t target[4];
	target[0].yet = 0;
	target[1].yet = 0;
	target[2].yet = 0;
	target[3].yet = 0;
	target[0].param = 1;
	target[1].param = 9;
	target[2].param = 7;
	target[3].param = 4;


	/*Q1*/
	int ret = 0;
	int in[4] = {0};

	
	cin >> in[0] >> in[1] >> in[2] >> in[3];

	//roop
	for (int i = 0; i < 4; ++i){

		//探索
		for (int j = 0; j < 4; ++j)
			if (target[j].param == in[i]){
				target[j].yet = 1;
			}
	}


	if (target[0].yet == 1
		&& target[1].yet == 1
		&& target[2].yet == 1
		&& target[3].yet == 1){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;

	}

	

	/*Q2*/

	/*Q3*/

		/*Q4*/

		return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
yen = 1000
kabu = 0

for i in range(1,n):
    if a[i-1] < a[i]:
        kabu += yen // a[i-1]
        yen %= a[i-1]
        
        yen += kabu * a[i]
        kabu = 0
        
print(yen)

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

int main(){
  string x;
  cin >> x;
  if(x=="abc"||x=="acb"||x=="bac"||x=="bca"||x=="cab"||x=="cba"){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod=1e9+7;
static const ll INF=1LL<<50;
using namespace std;

int main() {
	int n;cin>>n;
  cout<<(n-2)*180<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int D = 1;
    for(int i=0;i<N;i++){
        int A;
        cin >> A;
        if(A % 2){
            D *= 1;
        }else{
            D *= 2;
        }
    }
    cout << pow(3, N) - D << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;


int main(){
  
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  
  ll ans=0;
  
  if(a>=k){
   cout << k << endl; 
   return 0;
  }
  
  else{
   k-=a;
   ans+=a;
  }
  
  if(b>=k){
   cout << ans << endl; 
   return 0;
  }
  
  else{
   k-=b; 
  }
  
  ans-=k;
  
  cout << ans << endl;
  
  
  return 0;
  
  
  
  
}
  
  


Measured memory_bytes: 3600
H, W = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            C[i][j] = min(C[i][j], C[i][k] + C[k][j])

answer = 0
for i in range(H):
    for j in range(W):
        if A[i][j] == -1:
            continue
        answer += C[A[i][j]][1]

print(answer)

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

int main()
{
    int n, i, j, sum=0;
    cin>>n;
    int arr[n];

    for(i=0; i<n; i++)
    {
        cin>>arr[i];
    }

    for(i=0; i<n-1; i++)
    {
        for(j=i+1; j<n; j++)
        {
            sum = sum + arr[i]*arr[j];
        }
    }

    cout<<sum;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define INF 1000000009
#define LINF 1000000000000000009
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmax(T &a, const T&b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T&b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }
ll mod = 1000000007;

ll fac[2000010];

ll modinv(ll a) {
	ll b = mod, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}

void modfac() {
	fac[0] = 1;
	for (ll i = 1; i < 2000010; i++) {
		fac[i] = (fac[i - 1] * i) % mod;
	}
}

ll modperm(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	else return (fac[n] * modinv(fac[n - k])) % mod;
}

ll modcomb(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	else return ((fac[n] * modinv(fac[k])) % mod*modinv(fac[n - k])) % mod;
}

int main() {
	string s;
	cin >> s;
	for (char c : s) cout << 'x';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const ll INF = +10010010000;

const int mod = 1e9+7;

struct mint{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a){
        (x+=a.x)%=mod;
        return *this;
    }
    mint& operator-=(const mint a){
        (x-=mod-a.x)%=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x)%= mod;
        return *this;
    }
    mint operator+(const mint a)const{
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a)const{
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a)const{
        mint res(*this);
        return res*=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{
      mint res(*this);
      return res/=a;
    }
};

struct combination{
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i<n;++i)fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i>=1;--i) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k){
    if(k<0 || k>n)return 0;
    return fact[n] * ifact[k] + ifact[n-k]; 
  }
};


int main(){
    int x;
    cin >> x;
    
    rrep(i,sqrt(x)*2){
        int t=i/2.0*(i+1);
        if(t>=x){
            cout<<i<<endl;
            return 0;
        }
    }
}

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

bool revp2(const pair<ll,ll>&a,const pair<ll,ll>&b){return a.first>b.first;}
bool revp3(const pair<ll,ll>&a,const pair<ll,ll>&b){if(a.first==b.first)return a.second<b.second;
return a.first>b.first;}

int main()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    ll n,m,x,s=0,s2=0;
    cin>>n>>m>>x;
    map<ll,ll>m2;
    ll l1[m+1];
    for(int i=1;i<=m;i++){
        cin>>l1[i];
        m2[l1[i]]=1;
    }
    ll a,b;
    a=abs(x);
    b=abs(x-n);
    //if(a<=b){
        for(int i=1;i<x;i++){
            if(m2[i])s++;
        }
        //cout<<s;
    //}
    //else{
        for(int i=x+1;i<n;i++){
            if(m2[i])s2++;
        }
        cout<<min(s,s2);
    //}
}


Measured memory_bytes: 3584
#include <cstdio>
#include <vector>

typedef long long LL;
const int MN = 100005;

int N, M;
std::vector<int> G[MN];

int w, o[2], vis[MN], col[MN];
void DFS(int u, int c) {
	vis[u] = 1, ++o[col[u] = c];
	for (int v : G[u])
		if (!vis[v]) DFS(v, c ^ 1);
		else if (col[u] == col[v]) w = 1;
}

int main() {
	scanf("%d%d", &N, &M);
	for (int i = 1, x, y; i <= M; ++i) {
		scanf("%d%d", &x, &y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	int a = 0, b = 0, c = 0;
	for (int i = 1; i <= N; ++i) if (!vis[i]) {
		w = o[0] = o[1] = 0, DFS(i, 0);
		++(w ? c : o[1] ? b : a);
	}
	printf("%lld\n", 2ll * a * N - (LL)a * a + 2ll * b * b + 2ll * b * c + (LL)c * c);
	return 0;
}

Measured memory_bytes: 14244
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>

using namespace std;

#define FOR(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define REP(i,n) FOR((i),0,(n))
#define FORCLS(i,a,b) for(int (i) = (a); i <= (b); (i)++)
#define REPCLS(i,n) FORCLS((i),1,(n))

using Int = long long;
const Int mod = 1000000007ll;

Int fact(Int n) {
    Int ret = 1;
    for (Int i = 1; i <= n; i++){
        ret *= i;
        ret %= mod;
    }
    return ret;
}
void solve() {
    Int n, m;
    Int ans = 0;
    cin >> n >> m ;
    Int d = abs(n - m);
    switch (d) {
        case 0:
            ans = fact(n) * fact(m);
            ans %= mod;
            ans *= 2;
            ans %= mod;
            break;
        case 1:
            ans = fact(n) * fact(m);
            ans %= mod;
            break;
        default:
            ans = 0;
            break;
    }
    cout << ans << endl;
}

#ifdef DEBUG
#define MAIN hoge
#else
#define MAIN main
#endif

int MAIN() {
    solve();
    
    return 0;
}


Measured memory_bytes: 256
n,m,l = gets.chomp.split.map(&:to_i)
a = []
b = []

n.times do
  a.push(gets.chomp.split.map(&:to_i))
end
m.times do
  b.push(gets.chomp.split.map(&:to_i))
end

c = Array.new(n){Array.new(l, 0)}
b = b.transpose

a.each_with_index do |an, ia|
  b.each_with_index do |bn, ib|
    an.each_index do |i|
      c[ia][ib] += an[i] * bn[i]
    end
  end
end

c.each do |item| puts item*" " end

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

bool Jud[10][10];
int dfs(int z, int n, bool judge[10]) {
  bool jud = true;

  rep(i, 0, n) if (judge[i] == false) jud = false;

  if (jud == true) return 1;

  int cnt = 0;
  rep(i, 0, n) {
    if (Jud[z][i] == false)
      continue;
    else if (judge[i] == true)
      continue;

    judge[i] = true;
    cnt += dfs(i, n, judge);
    judge[i] = false;
  }

  return cnt;
}

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, m;
  int ans = 0;
  cin >> n >> m;

  rep(i, 0, m) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    Jud[a][b] = true;
    Jud[b][a] = true;
  }

  bool jud[10] = {false};
  jud[0] = true;
  cout << dfs(0, n, jud) << '\n';
  return 0;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <cstdlib>

using namespace std;
const int Max_N(100050);
const int Max_M(100050);

namespace io
{
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush (){fwrite (obuf, 1, oS - obuf, stdout);oS = obuf;}
	inline void putc (char x){*oS ++ = x;if (oS == oT) flush ();}
	template <class I>
	inline void gi (I &x) {for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;}
	template <class I>
	inline void print (I x){
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;while(x) qu[++ qr] = x % 10 + '0',  x /= 10;while (qr) putc (qu[qr--]);}
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io::gi;
using io::putc;
using io::print;

int N, M, Deg[Max_M], U[Max_M], V[Max_M], A, B;

inline bool Yes()
{
	putc('Y'), putc('e'), putc('s'), exit(0);
}

inline bool No()
{
	putc('N'), putc('o'), exit(0);
}

int Father[Max_N];
bool Circle[Max_N];

int Get_Father(int x)
{
	return Father[x] == x ? x : Father[x] = Get_Father(Father[x]);
}

bool check(int A, int B)
{
	if (!A || !B)
		return false;
	for (int i = 1;i <= N;++i)
		Father[i] = i, Circle[i] = false;
	for (int i = 1, x, y;i <= M;++i)
		if (U[i] != B && V[i] != B)
			if ((x = Get_Father(U[i])) != (y = Get_Father(V[i])))
				Father[x] = y;
			else
				Circle[x] = true;
	return Circle[Get_Father(A)];
}

int main()
{
	gi(N), gi(M);
	for (int i = 1;i <= M;++i)
		gi(U[i]), gi(V[i]), ++Deg[U[i]], ++Deg[V[i]];
	for (int i = 1;i <= N;++i)
		if (Deg[i] & 1)
			No();
	for (int i = 1;i <= N;++i)
		if (Deg[i] >= 6)
			Yes();
	for (int i = 1;i <= N;++i)
	{
		if (Deg[i] != 4)
			continue;
		if (B)
			Yes();
		if (A == 0)
			A = i;
		else
			B = i;
	}
	if (check(A, B) || check(B, A))
		Yes();
	No();
	return 0;
}

Measured memory_bytes: 4736