akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

int main(){
    using namespace std;
    using tuplis = array<int, 3>;
    const int sq = 1600;
    
    int n, q;
    cin >> n >> q;
    vector<int> c(n);
    for(int& i : c){
        cin >> i;
        i--;
    }
    vector<tuplis> query(q);
    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        l--;
        query[i] = {l, r, i};
    }
    sort(query.begin(), query.end(), [&](const tuplis& a, const tuplis& b){ if(a[0] / sq == b[0] / sq) return a[1] < b[1]; return a[0] < b[0]; });
    vector<int> ans(q);
    vector<int> cnt(n);
    int types = 0, L = 0, R = 0;
    for(auto [l, r, i] : query){
        while(L < l){
            cnt[c[L]]--;
            types -= !cnt[c[L]];
            L++;
        }
        while(L > l){
            L--;
            types += !cnt[c[L]];
            cnt[c[L]]++;
        }
        while(R > r){
            R--;
            cnt[c[R]]--;
            types -= !cnt[c[R]];
        }
        while(R < r){
            types += !cnt[c[R]];
            cnt[c[R]]++;
            R++;
        }
        ans[i] = types;
    }
    for(int i : ans) cout << i << ' ';
}

Measured memory_bytes: 15392
a=[s for s in input()]*2
b=input()
w=False
for j in range(len(a)):
    if a[j]==b[0]:
        total=1
        if len(b)==1:
            print("Yes")
            w=True
            break
        for i in range(1,len(b)):
            if j+i==len(a):
                print("No")
                w=True
                break
            else:
                if a[j+i]==b[i]:
                    total+=1
                    if total==len(b):
                        print("Yes")
                        w=True
                        break
                else:
                    break
    if w==True:
        break
if w==False:
    print("No")


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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))
#define int long long

signed main(){
    string s, t;
    cin >> s >> t;
    bool ans = s[0]==t[2] && s[1]==t[1] && s[2]==t[0];
    cout << (ans ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define show(x) std::cerr << #x << " = " << x << std::endl
using ll = long long;
using ld = long double;
constexpr ll MOD = 1000000007LL;
template <typename T>
constexpr T INF = std::numeric_limits<T>::max() / 10;
std::mt19937 mt{std::random_device{}()};
int main()
{
    int H, W, K;
    std::cin >> H >> W >> K, K--;
    constexpr int t[] = {1, 1, 2, 3, 5, 8, 13, 21, 34};
    std::vector<int> dp(W, 0);
    dp[0] = 1;
    for (int i = 0; i < H; i++) {
        std::vector<int> tmp(W, 0);
        for (int i = 0; i < W; i++) {
            (tmp[i] += (t[i] * t[W - 1 - i] % MOD) * dp[i] % MOD) %= MOD;
            if (i != W - 1) {
                (tmp[i + 1] += (t[i] * t[W - 2 - i] % MOD) * dp[i] % MOD) %= MOD;
            }
            if (i != 0) {
                (tmp[i - 1] += (t[i - 1] * t[W - 1 - i] % MOD) * dp[i] % MOD) %= MOD;
            }
        }
        dp = tmp;
    }
    std::cout << dp[K] << std::endl;
    return 0;
}


Measured memory_bytes: 256
//*/

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <cctype>
#include <complex>

using namespace std;

typedef long long int lld;

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

	for (int i = 1; i <= 5; i++) {
		int val;
		cin >> val;
		if (val == 0)
			cout << i << endl;
	}

	return 0;
}

//*/ 

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <numeric>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <stack>

using namespace std;

#define rep(i,n) for(int i = 0; i<n ; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)
#define REPSTR(i,s) for(int i=0; (s)[i]; i++)
#define REPITR(i,s) for(auto i=(s).begin(); i!=(s).end();i++)

#define RANGE(a,i,b) ((a)<=(i)&&(i)<=(b))

#define pb push_back
#define mp make_pair

#define ALL(a) (a).begin(), (a).end()

#define EXIST(s,x) ((s).find(x)!=(s).end())

#define SET(a,c) memset(a,c,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))

#ifdef _DEBUG
#define DEBUG(x) cerr<<#x<<":"<<x<<endl
#else
#define DEBUG(x)
#endif

#define PRINTJOIN(x,n) rep(i,n){if(i)cout<<" ";cout<<x[i];}cout<<endl 

#define INF 1001001001
#define LLINF 1001001001001001001LL

typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef stringstream SS;

#define PQ priority_queue

#define FST first
#define SEC second

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

/*
AOJ 1347: Problem C: Shopping
https://onlinejudge.u-aizu.ac.jp/problems/1347

所要時間
    考察 10分くらい
    コーディング 10分くらい
    座席 左中央

学んだこと
    貪欲だと知って解くとすぐに解けた。
    バグりそうなところは手で解くことであらかじめ把握できたので，一発で通った。

参考資料
なし

指針
    [a, b)の間を一度戻ると，最初から最後まで突っ走るのと比べて余計に2(b-a)だけ歩かなければならない
    →戻る距離を最小化したい
    →戻らなければならない範囲が重なっていたら，和集合をとって戻るのが得
    戻らなければならない範囲だけ進むのに3距離単位だけかかると考えると実装が楽
*/


int l[212345]; // 戻らなければならない範囲ならtrue



int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
    stack<int> s;
    string c;
    while ( cin >> c ) {
        int a,b;
        if ( c == "+" ) {
            a = s.top(); s.pop();
            b = s.top(); s.pop();
            s.push( b + a );
        }
        else if ( c == "-" ) {
            a = s.top(); s.pop();
            b = s.top(); s.pop();
            s.push( b - a );            
        }
        else if ( c == "*" ) {
            a = s.top(); s.pop();
            b = s.top(); s.pop();
            s.push( b * a );
        }
        else {
            s.push(atoi(c.c_str()));
        }
    }
    cout << s.top() << endl;
	return 0;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	int r; 
	cin >> r ;
	cout <<r *r << endl;
	
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  cout << (1900 * m + 100 * (n - m)) * pow(2, m) << endl;
  return 0;
}


Measured memory_bytes: 512
import java.util.*;
 
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    
    if(S.equals("Sunny")) {
      System.out.println("Cloudy");
    } else if (S.equals("Cloudy")) {
      System.out.println("Rainy");
    } else if (S.equals("Rainy")) {
      System.out.println("Sunny");
    }
  }
}

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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define m_p make_pair

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n,d,ans=0;
  cin >> n >> d;
  vector<vector<ll>> x(n,vector<ll>(d));
  rep(i,n) rep(j,d) cin >> x[i][j];
  rep(i,n-1){
    REP(j,i+1,n){
      ll num = 0;
      rep(k,d){
        num += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      }
      rep(l,130){
        if(l*l==num) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define loop(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }


vint v,mable;
int ans=0;

void solve(){
  //交互bitと入力列をXOR
  rep(i,v.size()){
    v[i]=v[i]^mable[i];
    if(v[i]) ans++;//1の数を数える
  }
}

int main(){
  string s;
  cin >> s;v.resize(s.length());mable.resize(s.length());
  rep(i,s.size()){
    v[i]=ctoi(s[i]);
  }

  //交互bitの生成
  rep(i,s.size()){
    if(v[0]){
     if(i%2==0) mable[i]=1;
     else mable[i]=0;
    }
    else{
     if(i%2==0) mable[i]=0;
     else mable[i]=1;
    }
  }
  
  solve();
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1280
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] al = new long[n+1];
        for(int i = 1; i <= n; i++){
            al[i] = al[i-1] + sc.nextLong();
        }
        long ans = Long.MAX_VALUE;
        for(int i = 1; i <= n; i++){
            ans = Math.min(ans,Math.abs(al[n]-al[i]*2));
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 86936
N, M = map(int, input().split())
P = []
Y = []
for i in range(M):
    p, y = map(int, input().split())
    P.append(p)
    Y.append(y)

A = [[] for i in range(N)]

for i in range(M):
    A[P[i]-1].append([i, Y[i]])
    
for i in range(N):
    A[i] = sorted(A[i], key=lambda x:x[1])

R = [[] for i in range(M)]

cc = 0
for i in range(N):
    c = 1
    for j in A[i]:
        R[j[0]] = str(10**12 + (i+1) * (10**6) + c)[1:]
        c += 1
        cc += 1
for r in R:
    print(r)

Measured memory_bytes: 43868
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int sum1[20];
	int sum2[20];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> sum1[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> sum2[i];
	}
	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		if (sum1[i] - sum2[i] > 0)
			sum += sum1[i] - sum2[i];
	}
	cout << sum;
	return 0;
}

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

int main() {
 int N;
  cin >>N;
  vector<int> P(N);
  vector<int>  Q(N);
  vector<int> S(N);
  vector<int> M(N);
  for(int i=0;i<N;i++) cin >> P[i];
  for(int i=0;i<N;i++) cin >> Q[i];
  S = min(P,Q);
  M = max(P,Q);
  int ans =0;
  while(S != M){
   next_permutation(S.begin(),S.end());
    ans++;
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 256
//Code by Mukul Totla
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void sublime(){ 
	  #ifndef ONLINE_JUDGE 
    freopen ("input.txt", "r", stdin);
    freopen ("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
      }
	
int main()
{   
  // sublime();
  
	  ll n,i;
	   cin>>n;
	   ll arr[n+1];
	   for(i=1; i<=n; i++)
	   	cin>>arr[i];

	   ll dp[n+1];
	   memset(dp,0,sizeof(dp));
	   dp[1]=0;
	   dp[2]=abs(arr[1]-arr[2]);
	   for(i=3; i<=n; i++)
	   {
	   	 ll a= abs(arr[i]-arr[i-1])+dp[i-1];
	   	 ll b=abs(arr[i]-arr[i-2])+dp[i-2];
	   	 dp[i]+=min(a,b);
	   }
       cout<<dp[n]<<'\n';
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  
  map<int, int> data;
  for (int i = 0; i < N; i++) data[A.at(i)]++;
  int count = 0;
  for (auto p : data){
    int v = p.second;
    if (v % 2 == 1) count++;
  }
  
  cout << count << endl;
}


Measured memory_bytes: 8284
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

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


Measured memory_bytes: 3636
N=int(input())

list1=list(map(int,input().split()))
list2=list(map(int,input().split()))

t=sum(list2)
M=list1[0]+t
s=list1[0]

for i in range(1,N):
  s=s+list1[i]
  t=t-list2[i-1]
  M=max(M,s+t)
  
print(M)

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

int main() {
  int n;
  cin>>n;
  map<pair<int, int>, long long> m;
  for (int i=1; i<=n; i++) {
    if (i % 10 == 0) {
      continue;
    }
    int j = i;
    while (j >= 10)  {
      j /= 10;
    }
    ++m[make_pair(j, i % 10)];
  }
  long long ans = 0;
  for (auto i: m) {
    auto p = i.first;
    // if (p.first > p.second) {
    //   continue;
    // }
    if (m.find(make_pair(p.second, p.first)) != m.end()) {
      ans += i.second * m[make_pair(p.second, p.first)];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
MOD = 1000000007


def main():
    N, *A = map(int, read().split())
    M = 60

    ans = 0
    p = 1
    for d in range(M):
        n = 0
        for i in range(N):
            if A[i] & (1 << d):
                n += 1
        ans = (ans + n * (N - n) * p) % MOD
        p = p * 2 % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 126032
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  while(1){
    int n,m;
    cin>>n>>m;
    if(n==0 && m==0) break;
    int flag[20000]={0};
    pair<int,pair<int,int> > p[20000];
    rep(i,m){
      int t,s,d;
      cin>>t>>s>>d;
      s--;d--;
      p[i]=make_pair(t,make_pair(s,d));
    }
    sort(p,p+m);
    flag[0]++;
    int ans=1;
    rep(i,m){
      if(flag[p[i].scd.fst]){
	if(flag[p[i].scd.scd]==0){
	  flag[p[i].scd.scd]=1;
	  ans++;
	}
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3712
import numpy as np

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
S = np.array([[int(t == ".") for t in s] for s in S])

L = np.zeros((H, W), dtype=int)
R = np.zeros((H, W), dtype=int)
U = np.zeros((H, W), dtype=int)
D = np.zeros((H, W), dtype=int)

best_count = 0

for w in range(W):
    if w == 0:
        L[:, w] = S[:, w]
    else:
        L[:, w] = (L[:, w-1] + 1) * S[:, w]

for w in range(W-1, -1, -1):
    if w == W-1:
        R[:, w] = S[:, w]
    else:
        R[:, w] = (R[:, w+1] + 1) * S[:, w]

for h in range(H):
    if h == 0:
        U[h, :] = S[h, :]
    else:
        U[h, :] = (U[h-1] + 1) * S[h, :]

for h in range(H-1, -1, -1):
    if h == H-1:
        D[h, :] = S[h, :]
    else:
        D[h, :] = (D[h+1, :] + 1) * S[h, :]

print(np.max(L + R + U + D - 3))

Measured memory_bytes: 251080
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,i,c=0;
    string s,t;
    cin>>s>>t;
    a=s.size();
    for(i=0;i<a;i++)
    {
        if(s[i]!=t[i])c++;

    }cout<<c;
}


Measured memory_bytes: 3912
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define mod 1000000007
using namespace std;

int main(){
    int n;
    long long total = 0L,sub = 0L;
    cin >> n;
    vector<long long> a(n);
    rep(i,0,n-1){
        cin >> a[i];
        total += a[i];
    }
    int index;
    for(index=0;index<n;index++){
        sub += a[index];
        if(sub >= total/2)break;
    }
    //long long r = sub-total/2, l = total/2 - (sub-a[index]);
    long long l1 = sub,r1 = total - sub;
    long long l2 = sub-a[index],r2 = total - sub+a[index];

    long long ans = min(abs(l1-r1),abs(l2-r2));
    //if(total%2==1)++ans;

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

////////////////////////////////////////////////////////////////

int main(void) {
	ll N;
	cin >> N;
	vector<ll> ans(N+1, 0);

	for(ll x=1; x<=100; x++){
		for(ll y=1; y<=100; y++){
			for(ll z=1; z<=100; z++){
				ll tmp = x*x + y*y + z*z + x*y + y*z + z*x;
				if(tmp <= N) ans[tmp]++;
				
			}
		}
	}

	for(int i=1; i<=N; i++){
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 3640
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

int m,a[7],b[7],g,n;

int f(int r,int c){
	if(c==m)return r==0;
	int res=0;
	rep(i,b[c]+1)res+=f(r-a[c]*i,c+1);
	return res;
}

int main(){
	while(cin>>m&&m){
		rep(i,m)cin>>a[i]>>b[i];
		cin>>g;
		rep(i,g){
			cin>>n;
			cout<<f(n,0)<<endl;
		}
	}
}

Measured memory_bytes: 868
from sys import stdout
import bisect
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split()) 
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
l = inl()
acc = 0
l.sort()
for i in range(n-2):
  a = l[i]
  for j in range(i+1,n-1):
    b = l[j]
    e = bisect.bisect_left(l[j+1:],a+b)
    #ddprint("a {} b {} i {} j {} e {}".format(a,b,i,j,e))
    acc += e  #-j-1
print(acc)


Measured memory_bytes: 51716
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<time.h>
#include<list>
#include<iomanip>
#include<cstring>
#define h 10000
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	if(n>=30)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
  return 0;
} 



Measured memory_bytes: 3604
import java.util.HashSet;
import java.util.Set;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int a = Integer.parseInt(line[0]);
        int b = Integer.parseInt(line[1]);
        
        if (a*b%2== 0) {
            System.out.println("No");
        }
        else System.out.println("Yes");
        
        
    }
}


Measured memory_bytes: 21204
# # import math
N = int(input())
# # count = 0
# # flag = False
# # # n = int(math.sqrt(N))
n = 105

# # for i in range(1, N + 1):
    
# #     for j in range(1, n):
# #         for l in range(1, n):
# #             for r in range(1, n):
# #                 if j + l + r > N // 2:
# #                     continue
# #                 if j ** 2 + l ** 2 + r ** 2 + j * l + j * r + l * r == i:
# #                     if j == l == r:
# #                         flag = True
# #                         count = 1
# #                         break
# #                     else:
# #                         flag = True
# #                         count = 3
# #                         break
# #             if flag:
# #                 break
# #         if flag:
# #             break            
# #     print(count)
# #     count = 0
# #     flag = False
ans = [0] * 10050
for j in range(1, n):
    for l in range(1, n):
        for r in range(1, n):
            value = j * j  + l * l + r * r + j * l + j * r + l * r
            if value < 10050:
                ans[value] += 1

for i in range(N):
    print(ans[i + 1])
# n = int(input())
# ans = [0 for _ in range(10050)]
# for i in range(1,105):
#     for j in range(1,105):
#         for k in range(1,105):
#             v = i*i+j*j+k*k+i*j+j*k+k*i;
#             if v<10050:
#                 ans[v]+=1   
# for i in range(n):
#     print(ans[i+1])

Measured memory_bytes: 9264
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
//#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
int main() {
  int r;
  cin >> r;
  print10(2 * r * M_PI);
  return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int AB,BC,AC;
    AB=a+b;BC=b+c;AC=a+c;
    cout<<min(AB,min(BC,AC))<<endl;
    return 0; 
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <utility>

using namespace std;

#define INF 0xc0c0c0c0
#define NINF 0x3f3f3f3f

#define FOR(i, a, b) for((i)=a; i<b; ++(i))
#define EFOR(i, a, b) for((i)=a; i>b; --(i))

#define MLC(n, type) (type*)malloc(n*sizeof(type))
#define CLC(n, type) (type*)calloc(n, sizeof(type))

#define MAXN 100001

bool cmp(pair<long long int, int > a, pair<long long int, int > b) {
	return a.first < b.first;
}

void solver(int nTatolCans, int nStoresNum, pair<long long int, int > *data) {
	int i = 0;
	int nCount = nTatolCans;
	long long int nSum = 0;

	sort(data, data+nStoresNum, cmp);

	while (i < nStoresNum && data[i].second < nCount) {
		nSum += data[i].second * data[i].first;
		nCount -= data[i].second;
		++i;
	}

	if (i < nStoresNum && nCount != 0) {
		nSum += nCount * data[i].first;
	}

	printf("%lld\n", nSum);
}

int main() {
	int i,n,m;
	long long int a;
	int b;
	pair<long long int, int> data[MAXN];

	scanf("%d %d", &n, &m);

	FOR(i, 0, n) {
		scanf("%lld %d", &a, &b);
		data[i] = make_pair(a, b);
	}

	solver(m, n, data);

	return 0;
}


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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

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, _eof;
	#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 gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll k; gi(k);
	iter(a, -2000, 2001) {
		iter(b, -2000, 2001) {
			if(a*a*a*a*a - b*b*b*b*b == k) {
				print(a), pc(' '), print(b);
				return 0;
			}
		}
	}
}


Measured memory_bytes: 3664
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

use std::cmp::max;
use std::cmp::Reverse;

fn opposite(xyd: &[(i64, i64, i64)]) -> Option<Reverse<i64>> {
    let mut s = std::collections::BTreeMap::new();
    for &(x, y, d) in xyd {
        if d == 0 || d == 2 {
            s.entry(y).or_insert(vec![]).push((x, d));
        }
    }
    let mut res = None;
    for (_, mut v) in s {
        v.sort();
        for i in 0..v.len() - 1 {
            if v[i].1 == 0 && v[i + 1].1 == 2 {
                res = max(res, Some(Reverse((v[i + 1].0 - v[i].0) * 5)));
            }
        }
    }
    res
}
fn vertical(xyd: &[(i64, i64, i64)]) -> Option<Reverse<i64>> {
    let mut s = std::collections::BTreeMap::new();
    for &(x, y, d) in xyd {
        if d == 0 || d == 1 {
            s.entry(x + y).or_insert(vec![]).push((x, d));
        }
    }
    let mut res = None;
    for (_, mut v) in s {
        v.sort();
        for i in 0..v.len() - 1 {
            if v[i].1 == 0 && v[i + 1].1 == 1 {
                res = max(res, Some(Reverse((v[i + 1].0 - v[i].0) * 10)));
            }
        }
    }
    res
}

fn main() {
    input! {
        n: usize,
        xyd: [(i64, i64, char); n],
    }
    let mut xyd = xyd
        .iter()
        .map(|(x, y, d)| {
            (
                *x,
                *y,
                match d {
                    'R' => 0,
                    'U' => 1,
                    'L' => 2,
                    _ => 3,
                },
            )
        })
        .collect_vec();

    let mut mn = None;
    for _ in 0..4 {
        mn = max(mn, opposite(&xyd));
        mn = max(mn, vertical(&xyd));
        for (x, y, d) in &mut xyd {
            std::mem::swap(x, y);
            *x = -*x;
            *d = (*d + 1) % 4;
        }
    }
    if let Some(Reverse(t)) = mn {
        println!("{}", t);
    } else {
        println!("SAFE");
    }
}


Measured memory_bytes: 39900
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

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

    int n, w;
    while (cin >> n >> w, n) {
        vector<int> v(n);
        rep(i, n) cin >> v[i];
        int ma_value = *max_element(all(v));

        int num_bar = 0;
        int ma_width = 0;
        while (ma_width <= ma_value) {
            ma_width += w;
            num_bar++;
        }

        vector<int> hist(num_bar, 0);
        rep(i, n) {
            hist[v[i] / w]++;
        }

        double ans = 0;
        int ma_height = *max_element(all(hist));
        rep(i, num_bar) {
            ans += (num_bar - i - 1) * hist[i];
        }
        ans /= (num_bar - 1) * ma_height;
        ans += 0.01;

        printf("%.10f\n", ans);

    }
}

Measured memory_bytes: 3216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;
const int N=1000;
int n,m,q;
ll a[N],b[N],c[N],d[N];
ll ans=0,cur;
void solve(vector<int> v,int last){
    if(v.size()<n){
        for(int i=last;i<=m;i++){
            v.push_back(i);
            solve(v,i);
            v.pop_back();
        }
    }
   else if(v.size()==n){
        cur=0;
        for(int i=0;i<q;i++){
            if(v[b[i]-1]-v[a[i]-1]==c[i])cur+=d[i];
        }
        ans=max(ans,cur);
    }
    return ;
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
   // freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin>>n>>m>>q;
    for(int i=0;i<q;i++)cin>>a[i]>>b[i]>>c[i]>>d[i];
    solve({},1);
    cout<<ans;
    
}

Measured memory_bytes: 3660
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   char[] c = sc.next().toCharArray();
 
   for(int i =0; i<c.length;i++)
   {
     c[i] = 'x';
   }
   String ans = new  String (c);
   System.out.println(ans);
 }
}

Measured memory_bytes: 23636
#include <iostream>

using namespace std;
constexpr int64_t MOD = 1'000'000'007;

int main(void) {
    int N, K;
    cin >> N >> K;

    int64_t ans = 0;
    for(int64_t k=K; k<=N+1; k++) {
        ans += k*(N-k+1)+1;
        ans %= MOD;
    }

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


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

int main()
{
	int n , y;
	cin>>n;
	cin>>y;
	int mx = y/1000;
	if(n > y)
	{
		cout<<-1<<" "<<-1<<" "<<-1<<endl;
	}
	else if(n==mx)
	{
		cout<<0<<" "<<0<<" "<<n<<endl;
	}
	else
	{
		int x10 = -1 , x5 = -1, x1 = -1;
		bool flag = false;
		for(int i = 0; i*10000 <= y; i++)
		{
			for(int j = 0; j*5000 + i*10000 <= y; j++)
			{
				int tmp = j*5000 + i*10000;
				tmp = y - tmp;
				int cnt = tmp/1000;
				if(i+j+cnt==n)
				{
					flag = true;
					x10 = i , x5 = j , x1 = cnt;
					break;
				}
			}
			if(flag)
			break;
		}
		cout<<x10<<" "<<x5<<" "<<x1<<endl;
	}
	return 0;
}


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

int main()
{
  int num, k;
  cin >> num >> k;

  vector<int> vec(num);
  for(int i = 0; i < num; ++i) cin >> vec.at(i);

  // 大きい順にソートして, 前からk個とる
  sort(vec.begin(), vec.end(), greater<int>());

  int sum = 0;
  for(int i = 0; i < k; ++i) sum += vec.at(i);

  cout << sum << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<stack>
using namespace std;
 
int div(int A, int B, int mod_p) {
  stack<int> q_stack;
  int a = B, b = mod_p, r;
  while (b) {
    q_stack.push(a / b);
    r = a % b; a = b; b = r;
  }
  long u = 1, v = 0;
  while (!q_stack.empty()) {
    int q = q_stack.top(); q_stack.pop();
    long u1 = v, v1 = u-q*v; u = u1 % mod_p; v = v1 % mod_p;
  }
  return (long)A * (u + mod_p) % mod_p;
}

int main() {
  int DIV = 1e+9 + 7;
  int N, K; cin >> N >> K;
  int A[K+1], B[K];
  A[0] = 0; A[1] = N - K + 1; B[0] = 1;
  for (int i = 1; i < K; i++) {
    A[i+1] = div((long)A[i] * (N-K+1-i) % DIV, i+1, DIV);
    B[i] = div((long)B[i-1] * (K-i) % DIV, i, DIV);
  }
  for (int i = 0; i < K; i++) {
    cout << (long)(A[i+1]+DIV) * B[i] % DIV << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 200005
using namespace std;
using P = pair<int,int>;
using T = tuple<int,int,int>;
int n,q,dd[M],ans[M];
T in[M];
void init() {
    int s,t,x;
    REP(i,1,n) {
        scanf("%d %d %d",&s,&t,&x);
        in[i] = make_tuple(s-x, t-x-1, x);
    }
    sort(in+1, in+n+1);

    REP(i,1,q) scanf("%d", &dd[i]);
}
int main()
{
    while (~scanf("%d %d", &n,&q)) {
        init();

        int d,pos = 1;
        int l,r,x;
        multiset<P> valid;
        multiset<int> xs;
        for (int i=1; i<=q; i++) {
            d = dd[i];
            while (pos<=n) {
                tie(l,r,x) = in[pos];
                if (l>d) break;
                valid.insert( P(r,x) );
                xs.insert( x );
                pos++;
            }
            while (valid.size() && (*valid.begin()).first<d) {
                auto p = *valid.begin();
                valid.erase( valid.find(p) );
                xs.erase( xs.find(p.second) );
            }

            if (!xs.size()) ans[i] = -1;
            else ans[i] = *xs.begin();
        }
        REP(i,1,q) printf("%d\n", ans[i]);
    }
    return 0;
}



Measured memory_bytes: 23936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define ms memset
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define lower_bound lb
#define upper_bound ub

int main()
{
    int a,b,c,k; cin >> a >> b >> c >> k;
    while (a >= b && k > 0){
        b *= 2; k--;
    }
    while (b >= c && k > 0){
        c *= 2; k--;
    }
    if (a < b && b < c){
        cout << "Yes" << '\n';
    }
    else{
        cout << "No" << '\n';
    }
    return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define INF 1000000000000
#define MOD 1000000007
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3)                                                 \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << endl
#define debug_4(x1, x2, x3, x4)                                             \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5)                                         \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

using namespace std;
using ll = long long;

int main() {
    ll n, q = 0, sum = 0;
    cin >> n;
    map<ll, ll> a;
    rep(i, n) {
        ll index;
        cin >> index;
        sum += index;
        a[index]++;
    }

    cin >> q;
    rep(i, q) {
        ll b, c;
        cin >> b >> c;
        sum -= b * a[b];
        sum += c * a[b];
        a[c] += a[b];
        a[b] -= a[b];
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 9028
#include <algorithm>
#include <bits/stdc++.h>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define PB push_back
#define MP make_pair
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>())

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
using ll = long long;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


void Main() {
  int N;
  cin >> N;
  vector<int> X(N);
  ll ans=0;
  
  REP(i,N) IN(X[i]);
  REP(i,N-1){
    int j=i;
    while(j<N-1){
      j += 1;
	  ans += X[i] * X[j];
    }
  }
  OUT(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();

  return 0;
}

Measured memory_bytes: 256
/*=======================
Author    : Shounak Dey
Filename  : a.cpp
=======================	*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define PB push_back
#define MK make_pair 
#define SZ(a) (int)(sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define read(n) scanf("%d",&n)
#define readl(n) scanf("%lld",&n)
#define readul(n) scanf("%llu",&n);


#define SORTV(a) sort(a.begin(),a.end())
#define TEST int Test;cin >> Test;while(Test--)
#define gcd(a,b) __gcd(a,b)
#define ffs(a) __builtin_ffs(a) // find first set
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)


#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c))
		v.emplace_back(x);
	return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

int main()
{
	fast_io;
	string a,b,c;
	cin >> a >> b >> c;
	cout << "A" << b[0] << "C" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        if(s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

using namespace std;
const long long INF = 1LL <<60;  

int main(void){
  long long  tmp,res;
  long long i,j,k;
  string s,t;
  long long s_l,t_l;

  cin>>s;
  cin>>t;
  
  res=0;
  s_l=s.length();
  t_l=t.length();
  
  for(i=0;i<s_l-t_l+1;i++){
    tmp=0;
    for(j=0;j<t_l;j++){
      if(s[i+j]==t[j]){
        tmp++;
      }
    }
    res=max(tmp,res);
  }
  res=t_l-res;
  
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	int nn;
	cin>>nn;
	for(int l = 0; l < nn; l++){
		int nums[8];
		int nums2[8];
		char n;
		cin>>n;
		if(cin.eof())
			break;
		nums[0]=n-'0';
		nums2[0]=nums[0];
		
		for(int i = 1; i < 8; i++){
			char n;
			cin>>n;
			nums[i]=n-'0';
			nums2[i]=nums[i];
		}
		sort(nums,nums+8);
		sort(nums2,nums2+8,greater<int>());
		int s[2];
		s[0]=s[1]=0;
		for(int i = 0; i < 8; i++){
			s[0]+=nums[i];
			s[1]+=nums2[i];
			
			s[0]*=10,s[1]*=10;
		}
		s[0]/=10,s[1]/=10;
		
		cout<<s[1]-s[0]<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 0
from collections import deque

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

g = [[] for _ in range(n)]
for a, b in ab:
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)

q = deque()
q.append(0)
b = [0] * n
while q:
    r = q.popleft()
    for i in g[r]:
        if b[i] != 0:
            continue
        if i == 0:
            continue
        b[i] = r + 1
        q.append(i)

for i in b[1:]:
    if i == 0:
        print("No")
        exit()
print("Yes")
print(*b[1:], sep="\n")


Measured memory_bytes: 74368
_, _, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
xyc = [tuple(map(int, input().split())) for i in range(M)]
print(min([min(A)+min(B)]+[A[x-1]+B[y-1]-c for x, y, c in xyc]))


Measured memory_bytes: 38816
#include<cstdio>
#include<cmath>
#include<algorithm>
#define MAXN 2000+5

typedef long long ll;

using namespace std;

int main() {
	char a1,b1,c1,d1;
	scanf("%c%c%c%c",&a1,&b1,&c1,&d1);
	int  a=a1-'0',b=b1-'0',c=c1-'0',d=d1-'0';
	//printf("%d %d %d %d",a,b,c,d);
	if(a+b+c+d==7){
		printf("%d+%d+%d+%d=7",a,b,c,d);
	}
	else if(a+b+c-d==7){
		printf("%d+%d+%d-%d=7",a,b,c,d);
	}
	else if(a+b-c+d==7){
		printf("%d+%d-%d+%d=7",a,b,c,d);
	}
	else if(a-b+c+d==7){
		printf("%d-%d+%d+%d=7",a,b,c,d);
	}
	else if(a+b-c-d==7){
		printf("%d+%d-%d-%d=7",a,b,c,d);
	}
	else if(a-b+c-d==7){
		printf("%d-%d+%d-%d=7",a,b,c,d);
	}
	else if(a-b-c+d==7){
		printf("%d-%d-%d+%d=7",a,b,c,d);
	}
	else if(a-b-c-d==7){
		printf("%d-%d-%d-%d=7",a,b,c,d);
	}
	return 0;
}

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

int main() {
    int A,B,C;
    cin>>A>>B>>C;
    int mx=max(A,max(B,C));
    int ans =10*mx+A+B+C-mx;
    cout <<ans<<endl;
}

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

template <typename T>
struct UnionFind {
  vector<int> par, rank;
  vector<T> wSum;

  UnionFind(int n = 1, T init = 0) : par(n), rank(n, 0), wSum(n, init) {
    iota(begin(par), end(par), 0);
  }
  int root(int x) {
    if (par[x] == x) {
      return x;
    } else {
      int r = root(par[x]);
      wSum[x] += wSum[par[x]];
      return par[x] = r;
    }
  }
  T weight(int x) {
    root(x);
    return wSum[x];
  }
  bool isSame(int x, int y) { return root(x) == root(y); }
  void unite(int x, int y, T w = 0) {
    w += weight(x) - weight(y);
    x = root(x);
    y = root(y);
    if (x == y) return;

    if (rank[x] < rank[y]) swap(x, y), w = negate<T>()(w);
    rank[x] += rank[y];
    par[y] = x;
    wSum[y] = w;
  }
  T getDiff(int x, int y) { return weight(y) - weight(x); }
};

const int V = 1e5;

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

  vector<int> x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    y[i] += V;
  }

  UnionFind<int> uf(2 * V + 1);
  for (int i = 0; i < n; i++) uf.unite(x[i], y[i]);

  vector<bool> used(2 * V + 1, false);
  vector<int> cx(2 * V + 1, 0), cy(2 * V + 1, 0);
  for (int i = 0; i < n; i++) {
    int rx = uf.root(x[i]);
    int ry = uf.root(y[i]);
    if (!used[x[i]]) cx[rx]++;
    if (!used[y[i]]) cy[ry]++;
    used[x[i]] = true;
    used[y[i]] = true;
  }

  ll sum = 0;
  for (int i = 0; i < 2 * V + 1; i++) {
    if (!cx[i] || !cy[i]) continue;
    sum += 1LL * cx[i] * cy[i];
  }
  cout << sum - n << endl;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#pragma warning(disable:4996)
using namespace std;
using ll = long long;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
bool used[1000];
int perm[1000];
int N, M;
int ans;
vector<vector<int>>edge(N, vector<int>(N));
void permutation1(int pos, int n) {
	if (pos == n) {
		
		if (perm[0] == 0) {
			bool ok = true;
			for (int i = 0; i < N-1; i++) {
				if (!edge[perm[i]][perm[i + 1]]) {
					ok = false;
				}
			}
			if (ok) {
				ans ++;
			}
		}
		return;
	}
	for (int i = 0; i < n; i++) {
		if (!used[i]) {
			perm[pos] = i;
			used[i] = true;
			permutation1(pos + 1, n);
			used[i] = false;
		}
	}
	return;
}
int main() {
	cin >> N >> M;
	edge.resize(N);
	for (int i = 0; i < N; i++) {
		edge[i].resize(N);
	}
	
		for (int j = 0; j < M; j++) {
			int a, b;
			cin >> a >> b;
			a--; b--;
			edge[a][b] = true;
			edge[b][a] = true;
		}
	

	permutation1(0, N);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N, K;
  cin >> N >> K;
  ll keta = 0;
  while (N > 0) {
    N /= K;
    keta++;
  }

  cout << keta << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){    
  string S;
  int K;
  cin >> K >> S;
  if(S.size() <= K) cout << S << endl;
  else{
    for(int i = 0; i < K; i++){
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}


Measured memory_bytes: 3608
#include<cstdio>
#include<cstring>
using namespace std;
char s[100005];
char t[100005];
int ind[100005][27];
bool vis1[27],vis2[27];
int main(){
	scanf("%s",s+1);
	scanf("%s",t+1);
	int lens=strlen(s+1);
	int lent=strlen(t+1);
	for(int i=1;i<=lens;i++)
		vis1[s[i]-'a']=1;
	for(int i=1;i<=lent;i++)
		vis2[t[i]-'a']=1;
	for(int i=0;i<26;i++)
		if(vis2[i]&&(!vis1[i])){
			printf("-1\n");
			return 0;
		}
	
	for(int i=lens;i>=1;i--){
		for(int j=0;j<26;j++)
			ind[i][j]=ind[i+1][j];
		ind[i][s[i]-'a']=i;
	}
	int num=0,now=1;
	for(int i=1;i<=lent;i++){
		if(now>lens||!ind[now][t[i]-'a']){
			now=1;
			num++;
		}
		now=ind[now][t[i]-'a']+1;
	}
	now--;
	printf("%lld\n",(long long)num*(long long)lens+(long long)now);
	return 0;
}

Measured memory_bytes: 10880