akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll n;
    cin>>n;
    if(n==1){
        cout<<"Hello World"<<endl;
    }else{
        ll a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
    }
}

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  string s;cin>>s;
  int n=s.size();

  int x;
  for(int i=2;i<n;i+=2){
    x=s.size()-i;
    if(s.substr(0,x/2)==s.substr(x/2,x/2))break;
  }
  out(x);

  return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

ab = b-a
ac = c-a
ad = d-a
ae = e-a
bc = c-b
bd = d-b
be = e-b
cd = d-c
ce = e-c
de = e-d

if ab <= k and ac <= k and ad <= k and ae <= k and bc <= k and bd <= k and be <= k and cd <= k and ce <= k and de <= k:
    print("Yay!")
else:
    print(":(")


Measured memory_bytes: 3064
#include <cstdio>
int N, p[200001], O, f, E;
inline bool Order(int p1, int p2, int pf)
{
	return pf < p1 && p1 < p2 || p1 < p2 && p2 < pf || p2 < pf && pf < p1;
}
int main()
{
	scanf("%d", &N);
	for (int i = 1, x; i <= N; i++)
	{
		scanf("%d", &x);
		p[x] = i;
	}
	E = N;
	while (E > 1 && p[E - 1] < p[E])
		E--;
	if (E == 1)
	{
		puts("0");
		return 0;
	}
	int f = E--, O = 1;
	for (int i = E - 1; i; i--)
		if (!Order(p[i], p[i + 1], p[f]))
		{
			f = i + 1;
			O++;
		}
	printf("%d\n", O);
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
// LatexBegin
struct SCC { int stamp, scc_num;
  struct Node : vector<int> { 
    int dfn, low, scc; bool inS;
    Node() { dfn = low = scc = -1; inS = false; }
  };
  vector<Node> N; vector<int> stk;
  void init(int n) { 
    N.clear(); N.resize(n); stk.clear();
  }
  void addEdge(int u, int v) { N[u].push_back(v); }
  void Tarjan(int u) { N[u].low = N[u].dfn = stamp++;
    stk.push_back(u); N[u].inS = true;
    for (auto &v : N[u]) if (!~N[v].dfn) Tarjan(v),
      N[u].low = min(N[u].low, N[v].low);
    else if (N[v].inS)
      N[u].low = min(N[u].low, N[v].dfn);
    if (N[u].dfn == N[u].low) {
      int v; do { v = stk.back(); stk.pop_back();
        N[v].scc = scc_num; N[v].inS = false;
      } while (v != u); scc_num++;
    }
  }
  void run() { stamp = scc_num = 0;
    for (int i = 0 ; i < N.size() ; i++)
      if (!~N[i].dfn) Tarjan(i);
  }
} solver;
// LatexEnd
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m; cin >> n >> m;
    solver.init(n);
    while (m--) {
        int u, v; cin >> u >> v;
        solver.addEdge(u, v);
    }
    solver.run();
    auto N = solver.N;
    vector<vector<int>> ans(solver.scc_num);
    for (int i = 0 ; i < n ; i++) 
        ans[N[i].scc].push_back(i);
    reverse(ans.begin(), ans.end());
    cout << solver.scc_num << '\n';
    for (int i = 0 ; i < solver.scc_num ; i++) {
        cout << ans[i].size();
        for (auto &v : ans[i])
            cout << ' ' << v;
        cout << '\n';
    }
}

Measured memory_bytes: 91228
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
//#include<boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

//namespace mp = boost::multiprecision;
//using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(int n)
{
	int count = 0;
	while (n > 0)
	{
		n /= 10;
		count++;
	}
	return count;
}
ll combination(ll n, ll r)
{
	if (r * 2 > n)
		r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i)
	{
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}
vector<int> divisor(int n)
{
	vector<int> value;
	FOR(i, 1, pow(n, 0.5) + 1)
	{
		if (i <= sqrt(n))
		{
			if (n % i == 0)
			{
				value.push_back(i);
				if (i * i != n)
				{
					value.push_back(n / i);
				}
			}
		}
	}
	return value;
}

int main()
{
	int k, x;
	cin >> k >> x;
	FOR(i, x - k + 1, x)
	{
		if (i >= -1000000)
		{
			cout << i << " ";
		}
	}
	FOR(i, x, x+k)
	{
		if (i <=1000000)
		{
			cout << i ;
		}
		if(i!=x+k-1){
			cout<<" ";
		}else{
			cout<<endl;
		}
	}
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc158/tasks/abc158_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, A, B;
    cin >> N >> A >> B;
    int t = N / (A + B);
    int u = min(A, N - (A + B) * t);
    cout << A * t + u << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
As = list(map(int, input().split()))
As.sort()
from itertools import accumulate
cum = list(accumulate(As))
cnt = 0
for n in range(N-1):
    if cum[n]*2>=As[n+1]:
        cnt += 1
    else:
        cnt = 0
cnt += 1
print(cnt)

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

#define NMAX 1000000

int main() {
  int h[NMAX+1];
  int n[] = {2,3,5};
  int a, b, t;
  memset(h, 0, sizeof(h));
  h[1] = 1;
  for (int i=0; i<3; i++) {
    for (int j=1; j<=NMAX; j++) {
      if (!h[j]) continue;
      t = j * n[i];
      if (t <= NMAX) {
        h[t] = 1;
      }
    }
  }
  for (int i=1; i<=NMAX; i++) {
    h[i] += h[i-1];
  }
  while (1) {
    cin >> a;
    if (!a) break;
    cin >> b;
    cout << h[b]-h[a-1] << endl;
  }
  return 0;
}

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

signed main() {
  int x,y;
  cin >> x >> y;
  if(abs(x - y) <= 1) {
    cout << "Brown" << '\n';
  } else {
    cout << "Alice" << '\n';
  }
}

Measured memory_bytes: 3624
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int n;
	cin>>n;

	map<string,int>mp;

	while(n--)
	{
		string s;
		cin>>s;
		mp[s]++;
	}

	cout<<"AC "<<"x"<<" "<<mp["AC"]<<endl;
	cout<<"WA "<<"x"<<" "<<mp["WA"]<<endl;
	cout<<"TLE "<<"x"<<" "<<mp["TLE"]<<endl;
	cout<<"RE "<<"x"<<" "<<mp["RE"]<<endl;

}

Measured memory_bytes: 3660
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
string s;
bool dp[2][21050];
bool cop[21050];
int main(){
  cin>>s;
  s.push_back('T');
  int h,w;cin>>w>>h;
  lol(i,2)lol(j,20010)dp[i][j]=false;
  dp[1][9010]=true;
  int dis=0,cnt=0;
  bool first=true;
  for(int i=0;i<s.size();i++){
    if(s[i]=='T'){
      if(first){
	dp[dis][9010+cnt]=true;
	first=false;
	cnt=0;
	dis=1-dis;
	continue;
      }
      for(int j=0;j<20050;j++)cop[j]=false;
      for(int j=0;j<20050;j++){
	if(j+cnt<20050)cop[j+cnt]|=dp[dis][j];
	if(j-cnt>0)cop[j-cnt]|=dp[dis][j];
      }
      for(int j=0;j<20050;j++)dp[dis][j]=cop[j];
      cnt=0;
      dis=1-dis;
    }
    else{
      cnt++;
    }
  }
  bool ok=false;
  if(dp[0][w+9010]&&dp[1][h+9010])ok=true;
  //if(dp[0][w+8010]&&dp[1][h+8010])ok=true;
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lld long long int
#define vec vector<lld>
#define pll pair<lld,lld>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define mod 1000000007
#define answer(x) cout<<endl<<"answer : "<<x<<endl<<endl;
#define op(x) cout<<x<<endl;
#define maxn 500005
#define messi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main() {messi lld t=1;//cin>>t;
    while(t--)
    {
        lld n=0,m=0,k=0,i=0,j=0,p=0,q=0,x=0,y=0,z=0,ans=0,cnt=0,l=0,r=0,mid=0,lo=0,hi=0;string s;bool flag=false;
        string str; cin>>s>>str;
        n = s.length(); m = str.length(); ans = m;
        for(i=0;i<=n-m;i++)
        {
            cnt=0;
            for(j=i;j<i+m;j++)
                if(str[j-i]!=s[j]) cnt++;
            ans= min(ans,cnt);
        }
        op(ans);
    }
	return 0;
}
/*  CODED BY:-
 ________________________________________
|            __        __                |
|  /\   /\  |__)  /\  |  \ |__| \ /  /\  |
| /~~\ /~~\ |  \ /~~\ |__/ |  |  |  /~~\ |
|________________________________________|

*/


Measured memory_bytes: 3644
N = int(input())
S = []
for i in range(N):
  S.append(input())
ac = 0
wa = 0
tle = 0
re = 0

for x in S:
  if x == 'AC':
    ac += 1
  elif x == 'WA':
    wa += 1
  elif x == 'TLE':
    tle += 1
  else:
    re += 1
    
print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))

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

#define ll long long
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define MOD 1000000007

int main(){
	ios::sync_with_stdio(0); 
	cin.tie(0); 
	int n, m, k;
	cin >> n >> m >> k;
	int a[n], b[m];
	ll prefix_suma[n+1] = {0}, prefix_sumb[m+1] = {0};
	ll total = MIN;
	for(int i=0; i<n; i++)
	    cin >> a[i];
	for(int i=0; i<m; i++)
	    cin >> b[i];
	for(int i=0; i<n; i++)
	    prefix_suma[i+1] = prefix_suma[i] + a[i];
	for(int i=0; i<m; i++)
	    prefix_sumb[i+1] = prefix_sumb[i] + b[i];
	for(ll i=0; i<=n; i++){
	    ll other = k - prefix_suma[i];
	    if(other < 0)
		continue;
	    int l = lower_bound(prefix_sumb, prefix_sumb+m+1, other) - prefix_sumb;
	    if(l > m || prefix_sumb[l] > other)
		l--;
	    total = max(total, i+l);
	}
	cout << total << "\n";
	return 0;
}


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

int main() {
  int A , B , C;
  cin >> A >> B >> C;
  
  int D;
  
  D = C - (A - B);
  if (D >= 0) {
    cout << D << endl;
  }
  
  else {
    cout << 0 << endl;
  }
  
}

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

# define ll long long

bool allZero(vector<int> numbers){
  for(int num : numbers){
    if(num != 0) return false;
  }
  return true;
}

bool checkTypeOne(vector<int> numbers){
  if(numbers.size() % 3 != 0) return false;
  int zero = 0;
  for(int num : numbers)
    if(num == 0) zero++;
  
  if(zero == numbers.size()/3) return true;
  else return false;
}

bool checkTypeTwo(vector<int> numbers){
  if(numbers.size() % 3 != 0) return false;
  map<int,int> frequency;
  for(int num : numbers) frequency[num]++;
  if(frequency.size() != 3) return false;
  
  int result = 0;
  for(auto keyValue : frequency){
    int key = keyValue.first;
    int value = keyValue.second;
    if(value != numbers.size()/3) return false;
    result ^= key;
  }
  
  if(result == 0) return true;
  else return false;
}

int main(){
  int n;
  cin >> n;
  
  vector<int> numbers(n);
  for(int i=0; i<n; i++) cin >> numbers[i];
  
  bool possible;
  if(allZero(numbers) || checkTypeOne(numbers) || checkTypeTwo(numbers)) possible = true; 
  else possible = false;
  
  cout << (possible ? "Yes" : "No") << endl;
  
  return 0;
} 



Measured memory_bytes: 7872
#include <stdio.h>


int main()
{
   int a,b,c,ans;
   ans = 3;
   scanf("%d %d %d", &a, &b, &c);
   int d[3] = { a-b, b-c, c-a };
   for(int i = 0; i < 3; i++){
       if(d[i] == 0) ans --;
       }
   if(ans == 0) ans ++;
   printf("%d\n", ans);
   return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
bool ex[13][1<<(12*2)];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    string s,t;
    cin>>s>>t;
    int k=t.size(),tmp=0;
    for(int j=0;j<k;j++){
      tmp*=4;
      if(t[j]=='A') tmp+=0;
      if(t[j]=='C') tmp+=1;
      if(t[j]=='G') tmp+=2;
      if(t[j]=='T') tmp+=3;
    }
    if(s=="insert") ex[k][tmp]=1;
    else cout<<(ex[k][tmp]?"yes":"no")<<endl;
  }
  return 0;
}


Measured memory_bytes: 4548
n = gets.to_i
a = gets.split.collect(&:to_i)

puts a.join(" ")

for j in 1...n
  key = a[j]
  i = j - 1
  while i >= 0 and a[i] > key
    a[i+1] = a[i]
    i -= 1
  end
  a[i+1] = key
  puts a.join(" ")
end

Measured memory_bytes: 6108
class BIT:
    """Binary Indexed Tree (Fenwick Tree)
    Range Sum QueryにO(log N)時間で答える
    1-indexed
    """
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
        self.depth = n.bit_length()
 
    def sum(self, i):
        """a[1]~a[i]の区間和を取得"""
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        """a[i]にxを足す"""
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def lower_bound(self, x):
        """ 累積和がx以上になる最小のindexと、その直前までの累積和 """
        sum_ = 0
        pos = 0
        for i in range(self.depth, -1, -1):
            k = pos + (1 << i)
            if k <= self.size and sum_ + self.tree[k] < x:
                sum_ += self.tree[k]
                pos += 1 << i
        return pos + 1, sum_
 
def main():
    N = int(input())
    S = list(input())
    Q = int(input())
    alphabets = list("abcdefghijklmnopqrstuvwxyz")
    c2n = {c: i for i, c in enumerate(alphabets)}
    
    Trees = [BIT(N+2) for _ in range(26)]

    for i in range(N):
        Trees[c2n[S[i]]].add(i+1, 1)
    
    for _ in range(Q):
        tmp = list(input().split())
        if tmp[0] == "1":
            _, i, c = tmp
            i = int(i)
            Trees[c2n[S[i-1]]].add(i, -1)
            Trees[c2n[c]].add(i, 1)
            S[i-1] = c
        else:
            ans = 0
            _, l, r = tmp
            l = int(l)
            r = int(r)
            for char in range(26):
                if Trees[char].sum(r) - Trees[char].sum(l-1) > 0:
                    ans += 1
            print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 203264
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

string nn;
int n;
int pw9[4];
ll choose(ll n, int r) {
  if (n < r) return 0;
  if (r == 0) return 1;
  if (r == 1) return n;
  if (r == 2) return (n * (n - 1)) / 2;
  if (r == 3) return (n * (n - 1) * (n - 2)) / 6;
  return 0;
}
ll get(int i, int nz) {
  if (nz < 0) return 0;
  if (i == (int) nn.size()) {
    return nz == 0;
  }
  ll res = 0;
  for (char d = '0'; d < nn[i]; d++) {
    int rem = nz - (d != '0');
    if (rem >= 0) res += pw9[rem] * choose(n - i - 1, rem);
  }
  res += get(i + 1, nz - (nn[i] != '0'));
  return res;
}

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  cin >> nn;
  int k; cin >> k;
  n = nn.size();
  pw9[0] = 1;
  pw9[1] = 9;
  pw9[2] = 9*9;
  pw9[3] = 9*9*9;
  cout << get(0, k) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int main()
{
	int n=gi();
	string a,b,out;cin>>a>>b;
	if (a+b>b+a) swap(a,b);
	int A=a.size(),B=b.size();
	while (n%A) out+=b,n-=B;
	for (n/=A;n--;) cout<<a;
	cout<<out;
	return 0;
}


Measured memory_bytes: 1544
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define dame {cout<< "0" <<"\n"; return;}
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    if(N==0) dame;
    ll S[36]={};
    rep(i,36){
        if(N%(1LL<<(i+1))!=0) {
            S[i]=1;
            N-=pow(-2LL,i);
        }
    }
    bool ok=false;
    repr(i,36,0){
        if(S[i]==1) ok=true;
        if(ok) cout<<S[i];
    }
    cout<<"\n";
    
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;

#define MAX_N 100001

signed main() {
	ll n, m, l; cin >> n >> m >> l;
	vector<vector<ll>> b1(n, vector<ll>(m));
	vector<vector<ll>> b2(m, vector<ll>(l));
	vector<vector<ll>> ans(n, vector<ll>(l,0));
	rep(i, n)
		rep(j, m)
		cin >> b1[i][j];
	rep(i,m)
		rep(j, l) {
		cin >> b2[i][j];
	}
	rep(i,n)
		rep(j,l)
		rep(k, m) {
		ans[i][j] += b1[i][k] * b2[k][j];
	}
	rep(i, n) {
		rep(j, l) {
			cout << ans[i][j];
			if (j < l - 1) cout << " ";
			else cout << endl;
		}
	}
}


Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;cin>>s;
    ll k;cin>>k;
    ll n = s.size();
    ll ans = 0;
    ll cnt1 = 1;
    ll idx = 1;
    while(idx<n&&s[idx]==s[0]){
        cnt1++;
        idx++;
    }
    ll cnt = 1;
    for(;idx<n;idx++){
        if(s[idx]==s[idx-1])cnt++;
        else{
            ans+=cnt/2;
            cnt=1;
        }
    }
    ll cnt2 = cnt;
    if(cnt1 == n) ans = k*n/2;
    else if(s[0]==s[n-1])ans=(cnt1+cnt2)/2*(k-1)+cnt1/2+cnt2/2+ans*k;
    else ans=(cnt1/2+cnt2/2+ans)*k;
    cout<<ans;
    return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    Graph G(n);
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    vector<int> dist(n, -1);
    queue<int> que;
    vector<int> fromwhere(n, -1);

    dist[0] = 0;
    que.push(0);

    while(!que.empty()) {
        int v = que.front();
        que.pop();

        for (int nv : G[v]) {
            if (dist[nv] != -1) continue;

            dist[nv] = dist[v] + 1;
            que.push(nv);
            fromwhere[nv] = v;
        }
    }

    //for (int v = 0; v < n; ++v) cout << v << ": " << dist[v] << endl;
    
    cout << "Yes" << endl;
    rep(i,n) {
        if (i != 0) {
            cout << fromwhere[i]+1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 10656
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define ll long long int
#define fab(a,b,i) for(int i=a;i<b;i++)
#define pb push_back
#define db double
#define mp make_pair
#define endl "\n"
#define f first
#define se second
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
int n,m,dp[100005],vis[100005];
vector<int> v[100005];
int dfs(int src)
{
	vis[src]=true;
	for(auto i:v[src])
	{
		if(!vis[i])
			dfs(i);
		dp[src]=max(dp[src],dp[i]+1);
	}
	return dp[src];
}
void longpath()
{
	int ans=0;
	fab(1,n+1,i)
	{
		if(!vis[i])
			dfs(i);
		ans=max(ans,dp[i]);
	}
	cout<<ans<<endl;
}



int main()
{ quick;

    cin>>n>>m;
    fab(0,m,i)
    {
    	int a,b;

    	cin>>a>>b;
    	//cout<<a<<" "<<b<<endl;
    	v[a].pb(b);}
	longpath();

	return 0;
}

Measured memory_bytes: 8576
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderD
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();
        int n = s.Length;

        int[] modSum = new int[n + 1];
        int tenMod = 1;
        for (int i = n - 1; i >= 0; i--)
        {
            int num = int.Parse(s[i].ToString());
            modSum[i] = ((num * tenMod % 2019) + modSum[i + 1]) % 2019;
            tenMod = (tenMod * 10) % 2019;
        }

        long answer = 0;
        int[] counts = new int[2019];
        for (int i = 0; i <= n; i++)
        {
            answer += counts[modSum[i]];
            counts[modSum[i]]++;
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

using LL = long long;
using LD = long double;
 
LL mod = 998244353;

int main()
{
	LL k;
	string s;
	cin >> k >> s;

	if (s.size() > k) {
		s = s.substr(0, k);
		s += "...";
	}
	cout << s << "\n";
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int a,b;
string x;
int rez;
int main(){
    cin >> a >> b;
    cin >> x;
    for(int i=0;i<x.size();i++){
        if(i!=a){ if(x[i]=='0' ||x[i]=='1' ||x[i]=='2' ||x[i]=='3' ||x[i]=='4' ||x[i]=='5' ||x[i]=='6' ||x[i]=='7' ||x[i]=='8' ||x[i]=='9' ){ rez++; continue;}}
        if(i==a && x[i]=='-') rez++;
    }
    if(rez==x.size()) { cout<<"Yes"; return 0;}
    cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
using namespace std;
typedef long long ll;

int main(){
	ios::sync_with_stdio(false);
	char tab[100][100];
	int a,b,tmp=0;
	cin>>a>>b;
	for(int i=0;i<100;i++){
		for(int j=0;j<100;j++){
			tab[i][j]=( i<50 ? '.' : '#');
		}
	}
	for(int i=1;i<50;i+=2){
		for(int j=1;j<100;j+=2){
			if(tmp+1==b){
				i=50;
				j=100;
			}
			tmp++;
			tab[i][j]='#';
		}
	}
	tmp=0;
	for(int i=51;i<100;i+=2){
		for(int j=1;j<100;j+=2){
			if(tmp+1==a){
				i=100;
				j=100;
			}
			tab[i][j]='.';
			tmp++;
		}
	}
	cout<<100<<" "<<100<<endl;
	for(int i=0;i<100;i++){
		for(int j=0;j<100;j++){
			cout<<tab[i][j];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n,m,aranj,fact[1000006],suma,invers[1000006];
ll inv(ll a)
{
    ll rez=1;
    ll b=mod-2;
    while(b)
    {
        if(b%2)
            rez=(rez*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return rez;
}
ll combi(ll a, ll b)
{
    if(a<b)
        return 0;
    ll r=fact[a];
    r=(r*invers[b])%mod;
    r=(r*invers[a-b])%mod;
    return r;
}
ll arj(ll a, ll b)
{
    if(a<b)
        return 0;
    ll r=(fact[a]*invers[a-b])%mod;
    return r;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    fact[0]=1;
    invers[0]=inv(fact[0]);
    for(ll i=1;i<=m;i++)
    {
        fact[i]=(fact[i-1]*i)%mod;
        invers[i]=inv(fact[i]);
    }
    aranj=(combi(m,n)*fact[n])%mod;
    ll ansb=0;
    for(ll i=0;i<=n;i++)
    {
        ll rez=(combi(n,i)*arj(m-i,n-i))%mod;
        if(i%2)
        {
            ansb-=rez;
            if(ansb<0)
                ansb+=mod;
        }
        else
            ansb=(ansb+rez)%mod;
    }
    cout<<(aranj*ansb)%mod;
    return 0;
}


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

int binary_search(int start, int end, long int *s, int key){
    //cout << "binary_search with " << start << " " << end << " " << key << endl;
    int match = 0;
    if (start!=end){
        int x;
        x = start + floor((end-start)/2);
        if (s[x] == key){
            match = 1;
        }else if (s[x] > key){
            match = binary_search(start, max(x-1, start), s, key);
        }else{
            match = binary_search(min(x+1, end), end, s, key);
        }
    }else{
        if (s[start] == key) match = 1;
    }
    //cout << "return " << match << endl;
    return match;
}

int main(){
    int n, q;
    cin >> n;
    long int s[n];
    for(int i=0; i<n; ++i){
        cin >> s[i];
    }
    cin >> q;
    long int t[q];
    for(int i=0; i<q; ++i){
        cin >> t[i];
    }
    
    int count=0;
    for(int i=0; i<q; ++i){
        count += binary_search(0, n-1, s, t[i]);
        //cout << "count is " << count << endl;
    }
    
    cout << count << endl;
}

Measured memory_bytes: 2332
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
vector<i64> c;
int main() {
  cin >> n;
  init_n(c, n);
  for (i64 i = 0; i < n; ++i) {
    i64 x; cin >> x;
    c[x]++;
  }

  bool f = true;
  if (n % 2 == 0) {
    for (i64 x = 1; x < n; x += 2) {
      if (c[x] != 2) f = false;
    }
  } else {
    if (c[0] != 1) f = false;
    for (i64 x = 2; x < n; x += 2) {
      if (c[x] != 2) f = false;
    }
  }

  if (f) {
    i64 y = 1;
    for (i64 i = 0; i < n / 2; ++i) y = y * 2 % i64(1000000007);
    cout << y << '\n';
  }
  else cout << 0 << '\n';
  return 0;
}


Measured memory_bytes: 1024
import java.math.BigInteger;
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n  = sc.nextInt();
        long[] t = new long[n];
        for(int i = 0; i < n; i++){
            t[i] = sc.nextLong();
        }
        long ans = 1L;
        if(n > 1) {
            ans = lcm(t[0], t[1]);
        }else {
            ans = t[0];
        }
        for(int i = 2; i < n; i++){
            ans = lcm(ans,t[i]);
        }
        System.out.println(ans);
    }

    static long lcm(long a, long b){
        BigInteger b1 = BigInteger.valueOf(a);
        BigInteger b2 = BigInteger.valueOf(b);
        return a / b1.gcd(b2).longValue() * b;
    }
}

Measured memory_bytes: 21840
n = int(input())
s = list(map(int, input().split()))

q = int(input())
t = list(map(int, input().split()))

count = 0

for i in range(q):
    left = 0
    right = n
    while left < right:
        mid = (right + left) // 2
        if t[i] == s[mid]:
            count += 1
            break
        elif t[i] < s[mid]:
            right = mid
        elif t[i] > s[mid]:
            left = mid+1
print(count)



Measured memory_bytes: 16708
// Problem: A - Not
// Contest: AtCoder - AtCoder Beginner Contest 178
// URL: https://atcoder.jp/contests/abc178/tasks/abc178_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define ll long long int
#define ii int
#define du double
#define jmp "\n"
#define vl vector<ll>
#define vvl vector<vl>
#define pb push_back
#define printv(v)     \
  for (auto x : v)    \
    cout << x << " "; \
  cout << jmp;
#define vi vector<int>
#define vb vector<bool>
#define ump unordered_map
#define SORT(v) sort(v.begin(), v.end())
#define REV(x) reverse(x.begin(), x.end())
#define all(x) x.begin(), x.end()
#define SET(x, a) memset(x, a, sizeof(x))
#define si(x) x.size()
#define ff first
#define ss second
#define iin insert
#define deb(x) cout << "test " << #x << "=" << x << jmp
#define deb2(x, y) cout << "test " << #x << "=" << x << "," << #y << "=" << y << jmp
using namespace std;
const ll nax = 1e5 + 5;
void solve()
{
	bool b;
	cin>>b;
	cout<<!b;
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  //cin >> t;
  while (t--)
    solve();
  return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}



struct UnionFind{

	std::vector<int> data;
	// dataの各要素について
	// 負の値:その集合のルートであること示す。また、その絶対値は集合の要素数となっている。
	// 正の値:親ノードの番号(dataのインデックス)。root()を呼び出すたびに集合のルートを指すように書きなおされるので木はそんなに深くならない

	//初期化 size:最大要素数
	UnionFind(int size): data(size, -1) {}
	// 集合を併合する
	// すでに同じ集合だった場合は、falseが返る
	bool unite(int x, int y){
		x=root(x);
		y=root(y);
		if( x != y ){
			// 要素数の大きな方へ合併するためのswap
			if( data[y] < data[x] ) std::swap(x, y);
			// 要素数を加算する
			data[x] += data[y];
			// yの属する集合のルートをxに変更
			data[y] = x;
		}
		return x!=y;
	}
	// 同じ集合かどうか判定
	bool find(int x, int y){
		return root(x) == root(y);
	}

	// 集合の識別番号を返す
	int root(int x){
		// 負の値を持つものがその集合のルート
		// 正の値は同じ集合に属するものを指す(辿ればいずれルートへ着く)
		return (data[x] < 0)? x : data[x]=root(data[x]);
	}
	// 集合の要素数を返す
	int size(int x){
		return -data[ root(x) ];
	}
};

int main()
{
    int n, m;
    cin >> n >> m;

    vector<int> data[m];
    rep(i, n){
        int k; cin >> k;
        rep(j, k){
            int tmp; cin >> tmp; tmp--;
            data[tmp].push_back(i);
        }
    }

    UnionFind uf(n);

    rep(i, m){
        rep(j, data[i].size()-1){
            uf.unite(data[i][j], data[i][j+1]);
        }
    }
    if (uf.size(0) == n) cout << "YES" << endl;
    else cout << "NO" << endl;
}



Measured memory_bytes: 4608
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<tuple>
#include<utility>
#include<map>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(){
	int N, k, ans = 0;
	cin >> N;
	string S;
	cin >> S;
	S = '0' + S;
	k = N - 1;
	vector<vector<int>> dp(N + 1, vector<int>(N + 1, 0));
	
	FOR(i, 1, N)	if (S.at(i) == S.at(N)) dp.at(N).at(i)++;

	for (int i = k; i > 0;--i){
		for (int j = i-1; j > 0;--j){
			if(S.at(i)==S.at(j)){
				dp.at(i).at(j) = min(abs(i - j), dp.at(i + 1).at(j + 1) + 1);
				ans = max(ans, dp.at(i).at(j));
			}else{
				dp.at(i).at(j) = 0;
			}
		}
		k--;
	}

	cout << ans << endl;
	/*
	FOR(i,2,N+1){
		FOR(j,1,i){
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}
	*/
	

	return 0;
}


Measured memory_bytes: 101208
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

int main() {
  int n; cin >> n;
  vector<int> a(3), l(n);
  REP(i, 3) cin >> a[i];
  REP(i, n) cin >> l[i];
  
  vector<string> v;
  function<void(int, string)> rec = [&](int x, string s){
    if(x == 0) v.emplace_back(s);
    else {
      REP(i, 4) rec(x-1, s + to_string(i));
    }
  };

  rec(n, "");

  int ans = numeric_limits<int>::max();
  for(const auto& s: v){
    vector<int> cost(4, 0), sum(4, 0), cnt(4, 0);
    REP(i, (int)s.length()){
      sum[s[i] - '0'] += l[i];
      cnt[s[i] - '0'] += 1;
    }
  
    if(cnt[0] == 0 || cnt[1] == 0 || cnt[2] == 0) continue;

    REP(i, 3) cost[i] = abs(sum[i] - a[i]) + 10 * (cnt[i] - 1);
  
    ans = min(ans, accumulate(cost.begin(), cost.end(), 0));
  }

  cout << ans << endl;

  return 0;
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;


int main() {
    ll n;cin>>n;
    vector<ll>d(n),cnt(101000);
    ll MAX=0,MOD=998244353;

    rep(i,n){
        cin>>d[i];
        cnt[d[i]]++;
        MAX=max(MAX,d[i]);
    }

    if(d[0]!=0||cnt[0]!=1){
        cout<<0<<endl;
        return 0;
    }

    ll ans=1;
    for (ll i=1;i<=MAX;i++) {
        for(ll j=0;j<cnt[i];j++){
            ans*=cnt[i-1];
            ans%=MOD;
        }
    }

    cout<<ans<<endl;

}


Measured memory_bytes: 1792
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,m=LI()

  l=[]
  for _ in range(m):
    a,b=LI()

    if a==1:
      l.append(b)
    elif b==n:
      l.append(a)

  x=len(l)
  y=len(list(set(l)))

  if x!=y:
    return 'POSSIBLE'
  return 'IMPOSSIBLE'

print(main())


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

int main() {
  int n, s;
  cin >> n;
  int m = n;
  
  for (int i = 8; i >= 0; i--) {
    int d = 1;
    for (int j = i; j > 0; j--)
		d *= 10;
    s += n / d;
    n -= (n / d) * d;
  }
  
  if (m % s == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl; 
}

Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let (w, h, n): (i64, i64, i64) = (sc.input(), sc.input(), sc.input());
    let points: Vec<(i64, i64, i64)> = (0..n)
        .map(|_| (sc.input(), sc.input(), sc.input()) )
        .collect();

    let mut rectangle = vec![vec![0; w as usize]; h as usize];

    for (x, y, a)  in points {
        let x = x - 1;
        let y = y - 1;

        if a == 1 {
            for ix in 0..x + 1 {
                for y in 0..h {
                    rectangle[y as usize][ix as usize] = 1;
                }
            }
        } else if a == 2 {
            for ix in x + 1..w {
                for y in 0..h {
                    rectangle[y as usize][ix as usize] = 1;
                }
            }
        } else if a == 3 {
            for iy in 0..y + 1 {
                for x in 0..w {
                    rectangle[iy as usize][x as usize] = 1;
                }
            }
        } else if a == 4 {
            for iy in y + 1..h {
                for x in 0..w {
                    rectangle[iy as usize][x as usize] = 1;
                }
            }
        }

    }

    let mut ans = 0;
    for i in 0..h as usize {
        for j in 0..w as usize {
            if rectangle[i][j] == 0 {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


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

using namespace std;


int main() {
	int n,q;
	cin >> n >> q;

	int a, b,c;
	vector<queue<int>> aa(n,queue<int>());
	for (int i = 0; i <q; i++) {
		cin >> a >> b  ;
		if (a == 0) {
			cin >> c;
			aa[b].push(c);
		}
		if (a == 1) {
			if (!aa[b].empty()) {
				cout << aa[b].front() << endl;
			}
		}
		if (a == 2) {
			if (!aa[b].empty()) {
				aa[b].pop();
			}
		}
	}

}


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

typedef long long ll;

int ans=0;

void dfs(ll x,int n,int a,int b,int c){
  if(x<=n){
    if(a==1&&b==1&&c==1){
      ans++;
    }
    dfs(10*x+3,n,1,b,c); 
    dfs(10*x+5,n,a,1,c); 
    dfs(10*x+7,n,a,b,1); 
  }
}

int main(){
  int n;
  cin >> n;
  dfs(0,n,0,0,0);
  cout << ans << endl;
}

Measured memory_bytes: 256
/* Author:bhagatsunny96
         JGEC*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long int 
#define ld long double
#define fi first
#define se second
#define mod 1000000007
#define endl "\n"
#define test long long int t; scanf("%lld",&t); while(t-->0)
#define fIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define loop(n) for(long long int i=0;i<n;i++)
using namespace std;
ll gcd(ll a, ll b)
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);
}
ll lcm(ll a, ll b)  
 {  
    return (a*b)/__gcd(a, b);  
 }
 ll power(ll x, unsigned ll y) 
 { 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2); 
    if (y%2 == 0) 
        return temp*temp; 
    else
        return x*temp*temp; 
 }
 bool isPrime(ll num)
 {
    bool flag=true;
    for(ll i =2;i<=num/2;i++) 
    {
       if(num%i==0) 
       {
          flag=false;
          break;
       }
    }
    return flag;
}
bool isPalin(ll num)
{
    bool flag=false;
    ll digit,rev=0,n=num;
    do
     {
         digit = num % 10;
         rev = (rev * 10) + digit;
         num = num / 10;
     } while (num != 0);
     if(rev==n)
     flag=true;
     return flag;
}
ll sumofdigits(ll n)
{
    ll c=0;
    while(n>0)
    {
        c++;
        n/=10;
    }
    return c;
}
bool sortinrev(const pair<int,int>&a,const pair<int,int>&b) 
{ 
    return (a.first > b.first); 
}
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
string sortString(string &str) 
{ 
   sort(str.begin(), str.end()); 
   return str;
} 
void countSort(ll arr[], ll n, ll exp) 
{ 
	ll output[n];
	ll i, count[10] = {0}; 
	for (i = 0; i < n; i++) 
		count[ (arr[i]/exp)%10 ]++; 
	for (i = 1; i < 10; i++) 
		count[i] += count[i - 1]; 
	for (i = n - 1; i >= 0; i--) 
	{ 
		output[count[ (arr[i]/exp)%10 ] - 1] = arr[i]; 
		count[ (arr[i]/exp)%10 ]--; 
	} 
	for (i = 0; i < n; i++) 
		arr[i] = output[i]; 
} 
void radixsort(ll arr[], ll n) 
{
    ll mx = arr[0]; 
	for (ll i = 1; i < n; i++) 
		if (arr[i] > mx) 
			mx = arr[i];
	ll m =mx;
	for (ll exp = 1; m/exp > 0; exp *= 10) 
		countSort(arr, n, exp); 
} 
void print(ll arr[], ll n) 
{ 
    for (ll i = 0; i < n; i++) 
        cout << arr[i] << " "; 
} 
int main() 
{
    fIO
    ll n,m;
    cin>>n>>m;
    char w[n]={'0'};
    int l[m];
    char cd[m];
    bool flag=true;
    loop(n)
    {
        w[i]='0';
    }
    w[0]='1';
    if(n==1)
    {
        w[0]='0';
    }
    loop(m)
    {
        cin>>l[i]>>cd[i];
        w[l[i]-1]=cd[i];
    }
    loop(m)
    {
        if(w[l[i]-1]!=cd[i])
        {
            flag=false;
            break;
        }
    }
    if(flag==true)
    {
        if(w[0]=='0' && n>1)
        flag=false;
    }
    if(flag==true)
    {
        loop(n)
        {
            cout<<w[i];
        }
        cout<<endl;
    }
    else
    cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    int num = 0;
    num = a * pow(10, int (log10(b) + 1)) + b;
    if (float (sqrt(num)) == float (int (float (sqrt(num))))) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3888
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e6+5;
int main() {
    int n;
    cin>>n;
    ll k=0;
    int ret = -1;
    for(int i = 1;i < 1000000;i++) {
        k*=10;
        k+=7;
        if((k%=n)==0) {
            ret = i;
            break;
        }
    }
    cout<<ret<<endl;
}

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

int main() {
	int N,M;
  	cin >> N;
  	
  	vector<string> blue(N);
    for(int i = 0; i < N; i++) {
    	cin >> blue.at(i);
    }
  
  	cin >> M;
  	
   vector<string> red(M);
  	for(int i = 0; i < M; i++) {
    	cin >> red.at(i);
    }
  
	int ans = 0;
  	
  	for(int i = 0; i < N; i++) {
    	int score = 0;
      
      	for(int j = 0; j < N; j++) {
        	if(blue.at(i) == blue.at(j)) score++;
        }
      
      	for(int j = 0; j < M; j++) {
        	if(blue.at(i) == red.at(j)) score--;
        }
      
      	ans = max(ans,score);
    }
  
  	cout << ans << endl;
  	
  
}

Measured memory_bytes: 256
import java.util.Scanner;
		
public class Main {
		
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter("\\s");
		int a;
		a= sc.nextInt();
		int b;
		b= sc.nextInt();
		System.out.println(a * b + " " + 2 * ( a + b));
	}
}

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

using namespace std;

int main()
{
    int N,D; // N個のD次元上の点
    cin >> N >> D;

    vector<vector<int>> X(N,vector<int>(D)); // 座標
    for(int i=0;i<N;i++)
    {
        for(int j=0;j<D;j++)
        {
            cin >> X.at(i).at(j);
        }
    }

    int answer = 0;

    /*    0          N-1  N
    0     0  1  2  3  4       
             1  2  3  4
                2  3  4
    N-2            3  4
    N-1


        0   1   2
            1   2
    */

    for(int i=0;i<N-1;i++)
    {
        for(int j=i+1;j<N;j++) // iとj
        {
            double dis = 0.0;
            int total = 0;
            for(int k=0;k<D;k++)
            {
                total += (X.at(i).at(k) - X.at(j).at(k)) * (X.at(i).at(k) - X.at(j).at(k)); // i+1番目とj+1番目のk次元上の差
            }
            dis = sqrt((double)total);
            if(floor(dis) == dis)
            {
                answer++;
            }
        }
    }

    cout << answer << endl;

    return 0;
}

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

ll n;
vector<pair<ll, ll> > g[100005];

ll dist[100005];

void dfs(ll u){
  for(auto &kv : g[u]){
    auto v = kv.first;
    auto w = kv.second;
    if(dist[v])continue;
    dist[v] = dist[u] + w;
    dfs(v);
  }
}

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  cin>>n;
  for(ll i=0;i<n-1;i++){
    ll u,v,w;cin>>u>>v>>w;u--,v--;
    g[u].push_back({v,w});
    g[v].push_back({u,w});
  }
  dist[0]=1;
  dfs(0);
  for(int i=0;i<n;i++){
    if(dist[i]%2==0)cout<<0<<endl;
    else cout<<1<<endl;
  }
  
  return 0;
}


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

int main() {
    vector<pair<double,int> > t;
    for (int i=0; i<3; ++i) {
        vector<pair<double,int> > tt(8);
        for (int j=0; j<8; ++j) {
            cin >> tt[j].second >> tt[j].first;
        }
        sort(tt.begin(), tt.end());
        cout.precision(2);
        cout << fixed;
        cout << tt[0].second << " " << tt[0].first << endl;
        cout << tt[1].second << " " << tt[1].first << endl;
        for (int j=2; j<8; ++j) {
            t.push_back(tt[j]);
        }
    }
    sort(t.begin(), t.end());
    cout.precision(2);
    cout << fixed;
    cout << t[0].second << " " << t[0].first << endl;
    cout << t[1].second << " " << t[1].first << endl;
    return 0;
}

Measured memory_bytes: 1304
#include <stdio.h>

int main() {
    int h, a;
    scanf("%d %d", &h,&a);
    int count;
    count = 0;
    for (int i=0; i<11000;i++){
        h -=a;
        count++;
        if (h==0 || h<0)break;
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 128