akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(void){
  long long n,res=1,res2=1,res3=1; cin>>n;
  for(int i=0; i<n; ++i) res=(res*9)%1000000007; res=res*2%1000000007;
  for(int i=0; i<n; ++i) res2=(res2*10)%1000000007;
  for(int i=0; i<n; ++i) res3=(res3*8)%1000000007;
  res=res2-(res-res3);
  if(res<0) res+=1000000007;
  cout<<res%1000000007;
  return 0;
}


Measured memory_bytes: 3640
N = int(input())
A = list(map(int, input().split()))
A.sort()
A = A[::-1]
a = []
i = 0
while True:
    if i >= len(A) - 1:
        break
    if len(a) > 2:
        break
    if A[i] == A[i + 1]:
        a.append(A[i])
        del A[i]
        del A[i]
        i -= 1
    i += 1
if len(a) < 2:
    print(0)
else:
    print(a[0] * a[1])


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

#define boost ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

using namespace std;
using LL = long long;

constexpr int MAXN = 2e5 + 5;

template <typename T>
inline void read(T &x) {
    int f = 1;
    x = 0;
    char ch = getchar();
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

LL n, h[MAXN], val[MAXN], ans;
map<int, LL> cnt;

int main() {
    // freopen("test.in", "r", stdin);
    // freopen("test.out", "w", stdout);
    boost;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> h[i], val[i] = h[i] + i;
    for (int i = n; i >= 1; i--) {
        ans += cnt[val[i]];
        if (i - h[i] <= 0) continue;
        cnt[i - h[i]]++;
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using Pcc = pair<char, char>;
istream& operator>>(istream& is, Pcc& p){
    char ch1, ch2;
    is >> ch1 >> ch2;
    p = Pcc(ch1, ch2);
    return is;
}
ostream& operator<<(ostream& os, const Pcc& p){
    return os << p.first << ' ' << p.second << '\n';
}

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

    int n, q;
    string s;
    cin >> n >> q >> s;
    vector<Pcc> query(q);
    for(int i = 0; i < q; ++i)  cin >> query[i];
    
    int lb = -1, ub = n;
    while(ub - lb > 1){
        int mid = (lb + ub) / 2;
        bool ok = true;
        int pos = mid;
        for(int i = 0; i < q; ++i){
            if(s[pos] != query[i].first)    continue;
            if(query[i].second == 'L')  --pos;
            else    ++pos;
            if(pos < 0){
                ok = false;
                break;
            }
            if(pos >= n)    break;
        }
        if(!ok) lb = mid;
        else    ub = mid;
    }
    int left = ub;

    lb = -1, ub = n;
    while(ub - lb > 1){
        int mid = (lb + ub) / 2;
        bool ok = true;
        int pos = mid;
        for(int i = 0; i < q; ++i){
            if(s[pos] != query[i].first)    continue;
            if(query[i].second == 'L')  --pos;
            else    ++pos;
            if(pos >= n){
                ok = false;
                break;
            }
            if(pos < 0) break;
        }
        if(ok)  lb = mid;
        else    ub = mid;
    }
    int right = ub;

    int ans = max(0, right - left);
    cout << ans << endl;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll A, B;
  cin >> A >> B;
  ll H, M;
  cin >> H >> M;
  ld ang_s = H*30.0+30*M/60.0;
  ld ang_l = M/60.0 * 360.0;
  ld ang = ang_l - ang_s;
  ang = ang>180? 360 - ang : ang;
  ang *= M_PI/180.0;
    
  cout << setprecision(15)<<sqrt(A*A + B*B - 2*A*B*cos(ang));
  return 0;
}


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

int main(){
  int n, m, c;
  cin >> n >> m >> c;
  vector<int>b(m);
  rep(i,m) cin >> b[i];
  vector<vector<int>> A(n,vector<int>(m));
  rep(i,n){
    rep(j,m){
      cin >> A[i][j];
    }
  }
  int cnt = 0;
  rep(i,n){
    int sum = c;
    rep(j,m){
      sum += A[i][j]*b[j];
    }
    if(sum > 0) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string str;
  char c;
  long long int sum = 0;
  getline(cin, str);
  for(int i = 0; i < str.size(); ++i){
    c = str.at(i);
    // cout << (int)c - (int)'0' << endl;
    sum += ((int)c - (int)'0');
  }
  if(sum % 9==0){
    cout << "Yes\n";
  }
  else{
    cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 3700
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
Arr.forEach(function(v){
var arr=v.split(",").map(Number);
var d=arr[1]/Math.pow(arr[2],2);
if(d>=25)console.log(arr[0])
});

Measured memory_bytes: 7644
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    ll n,m;cin>>n>>m;
    if(n>=m/2){
        cout<<m/2<<endl;
        return 0;
    }
    cout<<(n+(m-2*n)/4)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
   
const int maxn=1006;

   
int read()
{
	int ans=0;
	char s=getchar();
	while(s<'0'||s>'9') s=getchar();
	while(s>='0'&&s<='9') ans=ans*10+s-'0',s=getchar();
	return ans;
}
    
int main()
{
	int a[maxn][maxn],n,i,t;
	int cnt[maxn],day=0;
	bool c,vis[maxn];
	scanf("%d",&n);
	for(i=1;i<=n;++i)
		for(int j=1;j<n;++j)
			a[i][j]=read();
	for(i=1;i<=n;++i) cnt[i]=1;
	c=true;
	while(c) {
		day++;
		memset(vis,0,sizeof vis);
		c=false;
		for(i=1;i<=n;++i) {
			if(cnt[i]!=n) {
			t=a[i][cnt[i]];
			if(!vis[i]&&!vis[t]&&a[t][cnt[t]]==i) {
					vis[i]=true;
					vis[t]=true;
					cnt[i]++;
					cnt[t]++;
					c=true;
				}
			}
		}
	}
	for(i=1;i<=n;++i)
		if(cnt[i]!=n) {
			cout<<-1;
			return 0;
		}
	cout<<day-1;
	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b,t;
  	cin >> a >> b;
  	t = (a * b) % 2;
  
  	if(t == 0){
    	cout << "Even"; 
    }
  	else {
    	cout << "Odd";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,p=0;
  cin>>n;
  if(n>=1000){
      if(n%1000!=0){
    p=n/1000;
    cout<<((p+1)*(1000))-n<<"\n";
      }else if(n%1000==0){
          cout<<"0"<<"\n";
      }
  }else if(n<1000){
    cout<<(1000-n)<<"\n";
  }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
long long dp[2100][2100];
const long long MOD = 1000000007;

int main() {
    int N, M;
    cin >> N >> M;
    vector<long long> S(N), T(M);
    for(int i=0; i<N; ++i) cin >> S[i];
    for(int j=0; j<M; ++j) cin >> T[j];

    for(int i=0; i<=N; ++i) dp[i][0] = 1;
    for(int j=0; j<=M; ++j) dp[0][j] = 1;
    
    for(int i=0; i<N; ++i) {
        for(int j=0; j<M; ++j) {
            dp[i + 1][j + 1] = dp[i + 1][j] + dp[i][j + 1] - dp[i][j];
            if(S[i] == T[j]) dp[i + 1][j + 1] += dp[i][j];
            dp[i + 1][j + 1] = (dp[i + 1][j + 1] + MOD) % MOD;
        }
    }
    cout << dp[N][M] << endl;
}

Measured memory_bytes: 33152
#include <iostream>
#include <cstring>
#include <queue>
using namespace std;
class Node{
public:
    int x,y,cost;
    Node(int x,int y,int cost):x(x),y(y),cost(cost){}
    Node(){}
};
char map[1010][1010];
bool flag[1010][1010];
int h,w,n;
int bfs(char s,char e);
int main()
{
    cin>>h>>w>>n;
    for(int j=0;j<h;++j){
        for(int i=0;i<w;++i){
            cin>>map[i][j];
        }
    }
    int ans=0;
    char f=n+'0';
    ans+=bfs('S','1');
    for(char S='1';S<f;++S){
        ans+=bfs(S,S+1);
    }
    cout<<ans<<endl;
    return 0;
}
int bfs(char s,char e)
{
    int dx[4]={0,0,1,-1},dy[4]={-1,1,0,0};
    memset(flag, 0, sizeof(flag));
    queue<Node> q;
    for(int j=0;j<h;++j){
        for(int i=0;i<w;++i){
            if(map[i][j]==s){
                q.push(Node(i,j,0));
            }
        }
    }
    while(!q.empty())
    {
        Node t=q.front();q.pop();
        if(map[t.x][t.y]==e)return t.cost;
        if(flag[t.x][t.y])continue;
        for(int i=0;i<4;++i){
            Node next=t;
            next.cost++;
            next.x+=dx[i];next.y+=dy[i];
            if(next.x>=0&&next.y>=0&&next.x<w&&next.y<h&&map[next.x][next.y]!='X')q.push(next);
        }
        flag[t.x][t.y]=true;
    }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include<iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s;
    cin >> s;
    if(s.length()&1) cout << "No";
    else {
    	int i=0,flag=1;
    	for(i=0;i<s.length()-1;i+=2) {
    		if(s[i]!='h'||s[i+1]!='i') {
    			flag=0;
    			break;
    		}
    	}
    	if(flag) cout << "Yes";
    	else cout << "No";
    }
    cout << "\n";
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String[]$){
		Scanner sc=new Scanner(System.in);
	int n=sc.nextInt(),a=n;
	String s="";
	for(;n!=0;n/=-2) {
		if(n%2!=0) {
			n--;s='1'+s;
		}else s='0'+s;
	}
	System.out.println(a==0?0:s);
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
 
int main() {
  vector<char> vec(6);
  for (int i = 0; i < 6; i++) {
    cin >> vec.at(i);
  }
  if (vec.at(2) == vec.at(3) && vec.at(4) == vec.at(5)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

#define X first
#define Y second

const int inf=1e9+10;
const int N=2e5+10;


int n,m;
int a[N],psum[N];
int f_pre[N];
int f[N];

ii ra[N];


struct segtree{
    int b[N<<2],laz[N<<2];

    void lazyupdate(int node,int L,int R){
        b[node]+=laz[node];
        if (L<R){
            laz[node*2]+=laz[node];
            laz[node*2+1]+=laz[node];
        }
        laz[node]=0;
    }
    void update(int node,int L,int R,int pos,int val){
        lazyupdate(node,L,R);
        if (L>pos||R<pos) return;
        if (L==R){
            b[node]=val;
            return;
        }
        update(node*2,L,(L+R)/2,pos,val);
        update(node*2+1,(L+R)/2+1,R,pos,val);
        b[node]=max(b[node*2],b[node*2+1]);
    }
    void add(int node,int L,int R,int l,int r,int val){
        lazyupdate(node,L,R);
        if (L>r||R<l) return;
        if (l<=L&&R<=r){
            laz[node]+=val;
            lazyupdate(node,L,R);
            return;
        }
        add(node*2,L,(L+R)/2,l,r,val);
        add(node*2+1,(L+R)/2+1,R,l,r,val);
        b[node]=max(b[node*2],b[node*2+1]);
    }
    int get(int node,int L,int R,int l,int r){
        lazyupdate(node,L,R);
        if (L>r||R<l) return 0;
        if (l<=L&&R<=r) return b[node];
        return max(get(node*2,L,(L+R)/2,l,r),get(node*2+1,(L+R)/2+1,R,l,r));
    }
}mseg;


vector <int> impL[N],impR[N];

void prepare(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) psum[i]=psum[i-1]+a[i];

    cin>>m;
    for(int i=1;i<=m;i++) cin>>ra[i].Y>>ra[i].X;
    sort(ra+1,ra+m+1);
    for(int i=1;i<=m;i++) swap(ra[i].X,ra[i].Y);
    for(int i=1;i<=m;i++){
        impL[ra[i].X].push_back(i);
        impR[ra[i].Y].push_back(i);
    }
}
int solve(){
    for(int i=1;i<=m;i++) mseg.update(1,1,m,i,-inf);
    for(int i=1,j=1;i<=n;i++){
        for(auto cur:impL[i]){
            int L=1,R=m;
            while (L<=R){
                int mid=(L+R)/2;
                if (ra[mid].Y>ra[cur].Y) R=mid-1;
                else L=mid+1;
            }
            int add=psum[ra[cur].Y]-psum[i-1];
//            cout<<"?"<<add<<'\n';
            f[cur]=max(f_pre[i-1],mseg.get(1,1,m,1,R))+add;
            mseg.update(1,1,m,cur,f[cur]-add);
//            cout<<cur<<" "<<f[cur]<<'\n';
        }
        while (j<=m&&ra[j].Y<i) j++;
        mseg.add(1,1,m,j,m,a[i]);
        f_pre[i]=f_pre[i-1]+(a[i]==0);
        for(auto cur:impR[i]) {
            f_pre[i]=max(f_pre[i],f[cur]);
            mseg.update(1,1,m,cur,-inf);
        }
    }
    return n-f_pre[n];
}
int main(){
    prepare();
    cout<<solve();
}


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

int main(){ 
    int a,b;
    cin>> a>> b;
    if(a>=13){
        cout << b << endl;
    }else if(a>=6){
        cout << b/2 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

int main() {
  int n; cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i ++) cin >> p[i];

  int ans = 0;
  for (int i = 1; i < n - 1; i ++) {
    if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1])) ans ++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Set<Integer> primeSet = new HashSet<Integer>();
        primeSet.add(2);
        for (int i = 3; i <= 100000; i += 2) {
            boolean isPrime = true;
            for (int j = 2; j <= Math.sqrt(i); j++) {
                if (i % j == 0) {
                    isPrime = false;
                    break;
                }
            }
            if (isPrime) {
                primeSet.add(i);
            }
        }

        Map<Integer, Integer> like2017Map = new HashMap<Integer, Integer>();
        like2017Map.put(-1, 0);
        int count = 0;
        for (int i = 1; i <= 100000; i += 2) {
            if (primeSet.contains(i) && primeSet.contains((i + 1) / 2)) {
                count++;
            }
            like2017Map.put(i, count);
        }

        Scanner scan = new Scanner(System.in);
        int q = Integer.parseInt(scan.next());
        for (int i = 0; i < q; i++) {
            int l = Integer.parseInt(scan.next());
            int r = Integer.parseInt(scan.next());
            System.out.println(like2017Map.get(r) - like2017Map.get(l - 2));
        }
        scan.close();
    }
}


Measured memory_bytes: 66712
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<int>p(n);
  rep(i,n) cin >> p.at(i);
  sort(p.begin(),p.end());
  int ans=0;
  rep(i,k)ans+=p.at(i);
  cout << ans << endl;
}

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

using namespace std;

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  vector<int> counts(N, 0);
  X--;
  Y--;

  for (int a = 0; a < N; a++) {
    for (int b = a + 1; b < N; b++) {
      int d1 = b - a;
      int d2 = abs(X - a) + abs(Y - b) + 1;
      int d = min(d1, d2);
      counts[d]++;
    }
  }

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

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

int main() {
  int N;
  cin >> N;
  int count=0;
  int min = 10000000;
vector<int> P(N);
for (int i = 0; i < N; i++) {//配列への代入
  cin >> P.at(i);
}
  
  
  for (int i = 0; i < N; i++){// を一個ふやす
  if (min >= P.at(i)){
    count++;
    min = P.at(i);
  }
  
  }
   
cout << count << endl;
  
}
  

Measured memory_bytes: 1024
import numpy as np

n=int(input())



a= list(map(int,input().split()))
a=np.array(a,np.int64)


max=60
mod=10**9+7
ans=0
cnt1=0
cnt0=0


for i in range(max):
    new_a=(a>>i & 1)

    cnt1=np.count_nonzero(new_a)
    cnt0=n-cnt1
    ans=(ans+cnt1*cnt0*(2**i))%mod
    cnt1=0
    cnt0=0
print(ans)
            
    
    



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

using namespace std;

typedef long long int ll;

void solve()
{
	int k;
	cin >> k;
	string s;
	cin >> s;
	if(s.size() <= k) cout << s << "\n";
	else cout << s.substr(0,k) << "...\n";
}

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



Measured memory_bytes: 3564
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]


city = [0]*N
for i in range(M):
    city[ab[i][0]-1] += 1
    city[ab[i][1]-1] += 1

for number in city:
    print(number)


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

#define N 100

int calc_len(char s[N]){
	int count=0;
	int d=0;
	while(1){
		d=s[count];
		if((d>=97) && (d<=122)){
			count++;
		}else{
			return count;
		}
	}

	return count;
}

int calc(char s[N],char p[N]){
	int s_len=calc_len(s);
	int p_len=calc_len(p);
	int ds=0,dp=0;
	int count=0;

	for(int i=0;i<s_len;i++){
		count=1;
		if(s[i]==p[0]){
			for(int j=1;j<p_len;j++){
				if(s[i+j]==p[j]){
					count++;
				}
			}
			if(count==p_len){
				return 1;
			}
		}
	}

	return -1;

}

int main(void){
	char s[N*2];
	char p[N];
	char answer[10]={"NO"};
	int s_len,p_len;

	scanf("%s",s);
	scanf("%s",p);

	s_len=calc_len(s);
	for(int i=0;i<s_len;i++){
		s[i+s_len]=s[i];
	}
	
	if(calc(s,p)==1){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	
}


Measured memory_bytes: 2120
#include<stdio.h>
#define N 2000001
int n,B[N];

void Counting_Sort(int[],int);

int main(){

  int A[N],i,k=0;

  scanf("%d",&n);
  for(i = 1; i <= n; i++){
    scanf("%d",&A[i]);
    if(A[i] > k) k = A[i];
  }

  Counting_Sort(A,k+1);

  for(i = 1; i < n; i++) printf("%d ",B[i]);
  printf("%d\n",B[i]);

  return 0;
}

void Counting_Sort(int A[],int k){

  int i,j,C[k];

  for(i = 0; i < k; i++) C[i] = 0;
  for(j = 1;j <= n; j++) C[A[j]]++;
  for(i = 1; i < k; i++) C[i] = C[i] + C[i - 1];
  for(j = n; j >= 1; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}

Measured memory_bytes: 16260
using System;

class A{
	public static void Main(){

		int x = int.Parse (Console.ReadLine ());

		//??????H?????????
		int m = x / 60;
		int s = x % 60;

		int h = m / 60;
		m = m % 60;

		Console.WriteLine ("{0}:{1}:{2}", h, m, s);
	
	
	}
}

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

int main(){

int N;
  cin >> N;
int S = N;  
int cnt = 0;  
  
  for(int i = 0;i < 12;i++){
  cnt += S % 10;
  S /= 10;    
  }

if(N % cnt == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

return 0;
  
}

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

#define inRange(x,a,b)  a <= x && x < b
// priority : (weak) left -> up -> right -> down (strong)
int dx[4] = {0,-1,0,1};
int dy[4] = {-1,0,1,0};
vector<vector<int>> ans(250005);

int main(){
    int h, w;
    cin >> h >> w;

    // これで多分REが消える(WAは残る)
    if(h == 1 && w == 1){
        cout << 0 << endl;
        return 0;
    }

    int mat[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> mat[i][j];
        }
    }

    int cnt = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(mat[i][j] % 2 == 0)  continue;

            int movetoi, movetoj;
            for(int k = 0; k < 4; k++){
                int ni = i + dx[k];
                int nj = j + dy[k];
                if(inRange(ni, 0, h) && inRange(nj, 0, w)){
                    movetoi = ni, movetoj = nj;
                    if(mat[ni][nj] % 2 == 1){
                        break;
                    }
                }
            }

            mat[i][j]--;
            mat[movetoi][movetoj]++;

            ans[cnt].push_back(i+1);
            ans[cnt].push_back(j+1);
            ans[cnt].push_back(movetoi+1);
            ans[cnt].push_back(movetoj+1);
            cnt++;
        }
    }

    printf("%d\n", cnt);
    for(int i = 0; i < cnt; i++){
        printf("%d %d %d %d\n", ans[i][0], ans[i][1], ans[i][2], ans[i][3]);
    }

    return 0;
}

Measured memory_bytes: 12800
#include <stdio.h>


int main(){

    int N, a;

    scanf("%d", &N);

    int ans = 100;

    int cnt = 0;
    for (int i = 0; i < N; i++){
        scanf("%d", &a);
        cnt = 0;
        while( !(a%2) ){
            cnt++;
            a /= 2;
        }
        if( ans > cnt ) ans = cnt;
    }

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <cmath>
#include <sstream>
#include <algorithm>

using namespace std;

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

	int total = 1;
	int count = 1;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if (a % 2 == 0)count *= 2;
		total *= 3;
	}

	cout << total - count << endl;

	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  ll m=a[0];
  ll ans=0;
  for(int i=1;i<n;i++){
    if(a[i]<m) ans+=m-a[i];
    else m=a[i];
  }
  cout << ans << endl;
}

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

int main(){
  int A,B,M;
  cin>>A>>B>>M;
  vector<int> a(A),b(B),x(M),y(M),c(M);
  int ans=10000000;
  for(int i=0;i<A;i++){
    cin>>a.at(i);
  }
  for(int i=0;i<B;i++){
    cin>>b.at(i);
  }
  for(int i=0;i<M;i++){
    cin>>x.at(i)>>y.at(i)>>c.at(i);
    ans=min(ans,a.at(x.at(i)-1)+b.at(y.at(i)-1)-c.at(i));
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  ans=min(ans,a.at(0)+b.at(0));
  cout<<ans<<endl;
}


Measured memory_bytes: 2176
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int t = sc.nextInt();
		int result = 0;
		int t1 = sc.nextInt();
		int pre = t1;
		for(int i = 1; i < n; i++){
		    int next = sc.nextInt();
		    result += min(t, next - pre);
		    pre = next;
		}
		result += t;
		
		// 計算
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 61036
n, k = map(int, input().split())
teki_list = [i for i in map(int, input().split())]

#敵を弱い順に並べる
teki_list.sort()

if k != 0:
    #強いやつに必殺技を使う
    if k <= len(teki_list):
        del teki_list[-k:]
    else:
        del teki_list[:]

print(sum(teki_list))

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

using namespace std  ;

int main()
{
    int a , b ;
    cin >> a >> b ;
    int x ;
    if(a <= b)
    x = 1 ;
    else x = a / b ;
    if(a%b >0 && a > b)
        x++;

    cout << x ;


    return 0 ;
}


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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var R = int.Parse(Console.ReadLine());
            var G = int.Parse(Console.ReadLine());

            Console.WriteLine(G * 2 - R);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
using ll=long long int;
using ppi=pair<ll,ll>;
using pql =priority_queue<ll, vector<ll>, greater<ll>>;
using pq=priority_queue<ll>;

int main()
{
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;
    return 0;
}

Measured memory_bytes: 256
import Data.List

main :: IO ()
main = do
    n <- readLn :: IO Int
    ps <- map read . words <$> getLine :: IO [Int]
    print $ solve ps

solve ps =
    length $ filter f $ g ps
    where
        f (xs@[x, y, z]) = y == (sort xs) !! 1

        g (x : y : z : xs) = [x, y, z] : g (y : z : xs)
        g xs = []

Measured memory_bytes: 508
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#define MY_PI 3.1415926535897932384626433832795028841971693993751058209749445923
using namespace std;

int main() {
	double sumx=0, sumy=0;
	int ideg = 0;
	while(true) {
		int a,b; scanf("%d,%d",&a,&b);
		if(a==0 && b==0)break;
		sumx += a*sin(ideg*MY_PI/180);
		sumy += a*cos(ideg*MY_PI/180);
		ideg = (ideg+b)%360;
		if(ideg<0)ideg+=360;
	}
	printf("%d\n%d\n",(int)sumx,(int)sumy);
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>

#define HASH 1000003

typedef struct List {
	struct List *next;
	char *s;
	int l;
} list;

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

int hash_string(char* s)
{
	int i, x = 0;
	for (i = 0; s[i] != 0; i++) x = (x * 31 + s[i] - 'a') % HASH;
	return x;
}

int lex_smaller(char* s1, char* s2)
{
	int i;
	for (i = 0; s1[i] != 0 && s2[i] != 0; i++) {
		if (s1[i] < s2[i]) return 1;
		else if (s1[i] > s2[i]) return -1;
	}
	if (s1[i] == s2[i]) return 0;
	else if (s1[i] == 0) return 1;
	else return -1;
}

int main()
{
	int i, j, l[200001], N;
	char *S[200001], T[1000001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%s", T);
		for (l[i] = 0; T[l[i]] != 0; l[i]++);
		S[i] = (char*)malloc(sizeof(char) * (l[i] + 1));
		for (j = 0; j <= l[i]; j++) S[i][j] = T[j];
	}
	
	int h[200001];
	list *p, *hash[HASH], d[200001];
	for (i = 1; i <= N; i++) {
		h[i] = hash_string(&(S[i][1]));
		d[i].s = S[i];
		d[i].l = l[i];
		d[i].next = hash[h[i]];
		hash[h[i]] = &(d[i]);
	}
	
	int k, dp[26];
	long long ans = 0, tmp, pow[32];
	const long long inv = div_mod(1, 31, HASH);
	for (k = 1, pow[0] = 31; k < 32; k++) pow[k] = pow[k-1] * pow[k-1] % HASH;
	for (i = 1; i <= N; i++) {
		if (l[i] <= 1) continue;
		for (j = 0; j <= l[i]; j++) T[j] = S[i][j];
		for (j = l[i] - 2, k = 0, tmp = 1; j > 0; j >>= 1, k++) if ((j & 1) == 1) tmp = tmp * pow[k] % HASH;
		h[i] = (h[i] - tmp * (T[1] - 'a') % HASH + HASH) % HASH;
		for (j = 0; j < 26; j++) dp[j] = 0;
		dp[S[i][0] - 'a'] = 1;
		for (j = 1; j < l[i]; j++) {
			dp[S[i][j] - 'a'] = 1;
			for (k = 0; k < 26; k++) {
				if (dp[k] == 0) continue;
				T[j] = 'a' + k;
				for (p = hash[h[i]]; p != NULL; p = p->next) if (p->l == l[i] - j && p->s[0] == T[j] && lex_smaller(p->s, &(T[j])) == 0) break;
				if (p != NULL) ans++;
			}
			tmp = tmp * inv % HASH;
			h[i] = (h[i] - tmp * (T[j+1] - 'a') % HASH + HASH) % HASH;
		}
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 23500
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools



sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

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

if(A<=2*B):
    print(0)
else:
    print(A-2*B)


Measured memory_bytes: 38764
#include <bits/stdc++.h>
using namespace std;
using sint = int64_t;

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

template<class T> vector<T> read_vector(sint n) {
	vector<T> vs;
	for (sint i = 0; i < n; ++i) {
		vs.push_back(read<T>());
	}
	return vs;
}

inline void write() {
}

template<class T> void write(T const& t) {
	cout << t;
}

template<class T> void write(vector<T> const& ts) {
	if (ts.size() > 0) {
		cout << ts[0];
	}
	for (size_t i = 1; i < ts.size(); ++i) {
		cout << ' ' << ts[i];
	}
}

template<class T, class... Args> void write(T const& t, Args const&... args) {
	cout << t << ' ';
	write(args...);
}

template<class... Args> void writeln(Args const&... args) {
	write(args...);
	cout << '\n';
}

int main() {
	ios_base::sync_with_stdio(false);
	cin .exceptions(ios_base::badbit | ios_base::failbit);
	cout.exceptions(ios_base::badbit | ios_base::failbit);
	cin .tie(nullptr);
	cout.tie(nullptr);
	cout.precision(16);
	void run();
	run();
	return 0;
}

void run() {
	auto const N = read<sint>();
	vector<pair<sint, sint>> As;
	for (sint i = 0; i < N; ++i) {
		As.push_back({i, read<sint>()});
	}

	sort(As.begin(), As.end(), [](auto& x, auto& y) { return x.second < y.second; });

	for (auto const& a: As) {
		write("", a.first + 1);
	}
	writeln();
}

Measured memory_bytes: 2544
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int N, K, ans;
vector<int> V;

int main(){
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        int v;
        cin >> v;
        V.push_back(v);
    }
    for(int i = 1; i <= K; i++){
        if(i <= N){
            for(int j = 0; j <= i; j++){
                int sum = 0;
                vector<int> ju;
                for(int k = 0; k < i - j; k++){
                    ju.push_back(V[k]);
                    sum += V[k];
                }
                for(int k = 0; k < j; k++){
                    ju.push_back(V[N - k - 1]);
                    sum += V[N - k - 1];
                }
                sort(ju.begin(), ju.end());
                for(int k = 0; k < (K - i); k++){
                 	if(k >= ju.size()) break;
                    if(ju[k] < 0) sum -= ju[k];
                    else break;
                }
                ans = max(ans, sum);
            }
        }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
typedef vector<Int> veci;
typedef vector<double> vecd;
typedef vector<int> veci;
typedef vector<double> vecd;
typedef vector<veci> mati;
typedef vector<vecd> matd;
#define A first
#define B second
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(auto i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
template<typename T> vector<T> getVector(const int n) { return vector<T>(n); }
template<typename T> vector<T> getVector(const int n, const T a) { return vector<T>(n, a); }
template<typename T> vector<T> getEmptyVector() { return vector<T>(); }
template<typename T> void appendAll(vector<T> &a, vector<T> b) { a.insert(a.end(), b.begin(), b.end()); }
// #define X first
// #define Y second
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const ll MOD = 1000000007;
const int MAXN = 1<<17;
const int inf = 1<<28;
const int NIL = -inf;
int popcount(int x)  { return __builtin_popcount(x); }
#define DUMP(a) \
    do { std::cout << #a " = " << (a) << ", "; } while(false)
#define DUMPLN(a) \
    do { std::cout << #a " = " << (a) << std::endl; } while(false)

ll modpow(ll a, int k) {
    if(k == 0) return 1;
    if(k & 1) return (modpow(a, k - 1) * a) % MOD;
    else { ll t = modpow(a, k / 2LL); return (t * t) % MOD; }
}

ll mod_inverse(ll a) {
    return modpow(a, MOD - 2);
}

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

    ll N, M, K;
    cin >> N >> M >> K;

    ll comb = 1;
    FORI(k, K - 2) {
        comb = (comb * (((N * M - (ll)k - 1LL) * mod_inverse(k))%MOD))%MOD;
    }
    
    ll ans = 0;
    FORI(y, N) {
        ll tot = 0;
        FORI(x, M) {
            tot += ((x - 1) * y + ((ll)y * (y - 1)) / 2LL) % MOD;
            tot %= MOD;
            ans += ((comb * tot) % MOD) % MOD;
            ans %= MOD;
        }
        tot = 0;
        FORI(x, M) {
            tot %= MOD;
            ans += ((comb * tot) % MOD) % MOD;
            ans %= MOD;
            tot += (x * (N - y) + ((ll)(N - y + 1LL) * (N - y)) / 2LL) % MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3660
'''input
4
1 2 3 4
'''
from collections import Counter
n = input()
arr = map(int,raw_input().split())
c = Counter(arr)
li = []
for i in c:
	if c[i] >= 2:
		li.append(i)
li.sort()
if len(li) == 0:
	print "0"
elif len(li) == 1:
	print li[-1]**2
else:
	if c[li[-1]] >= 4:
		print li[-1]**2
	else:
		print li[-1]*li[-2]

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

int main() {
    int n; cin >> n;
    vector<int> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    int q; cin >> q;
    vector<int> t(q);
    for (int i = 0; i < q; i++) {
        cin >> t[i];
    }

    int ans = 0;
    int res;
    for (int i = 0; i < q; i++) {
        int l = 0, r = n-1;
        res = -1;
        while (l <= r) {
            int mid = (l+r)/2;
            if (s[mid] == t[i]) {
                res = mid;
                break;
            }
            else if (s[mid] > t[i]) r = mid - 1;
            else if (s[mid] < t[i]) l = mid + 1;
        }
        if (res != -1) ans++;
    }

    cout << ans << endl;

}



Measured memory_bytes: 3264
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  ll k;
  cin >> k;
  ll now=0;
  rep(i,1,k+1){
    now=(now*10+7)%k;
    if(now==0) {
      cout << i << endl;
      return;
    }
  }
  cout << -1 << endl;
}

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

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int n,a[100007],b[100007],c[100007],dp[100007][3],k;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	for(int i=1;i<=n;i++)
	{
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i];
	}
	int mx;
	for(int i=0;i<3;i++) mx=max(mx,dp[n][i]); 
	cout<<mx;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s.at(i);
  int m;
  cin >> m;
  vector<string> t(m);
  rep(i,m) cin >> t.at(i);

  map<string,int> mp;
  rep(i,n){
    mp[s.at(i)]++;
  }
  rep(i,m){
    mp[t.at(i)]--;
  }
  int ans = 0;
  for(auto p:mp){
    ans = max(ans,p.second);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { assert(x > 0); return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { assert(x > 0); return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
void fail() { puts("-1"); exit(0); }
// const int INF  = 1<<30;
// const ll INFll = 1ll<<62;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  int n; cin >> n;
  string s; cin >> s;
  
  ll ans = 0;

  int l = 0;
  int r = n-1;

  while (l < r) {
    while (l < n && s[l] == 'R') ++l;
    while (r >= 0 && s[r] == 'W') --r;

    if (0 <= l && l < r && r < n) {
      ++ans;
      ++l;
      --r;
    }
    else break;
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  vector<string> field(H);
  for (int i=0;i<H;i++){
    cin >> field[i];
  }
  
  vector<vector<int>> dist(H,vector<int>(W,-1));
  queue<pair<int,int>> que;
  
  int dy[4]={0,1,0,-1};
  int dx[4]={1,0,-1,0};
  
  dist[0][0]=0;
  que.push(make_pair(0,0));
  
  while(!que.empty()){
    pair<int,int> current=que.front();
    int y=current.first;
    int x=current.second;
    que.pop();
    for (int i=0;i<4;i++){
      int ny=y+dy[i];
      int nx=x+dx[i];
      if (ny<0||ny>H-1||nx<0||nx>W-1){
        continue;
      }
      else if (field[ny][nx]=='#'){
        continue;
      }
      else if (dist[ny][nx]!=-1){
        continue;
      }
      else if(dist[ny][nx]==-1){
        que.push(make_pair(ny,nx));
        dist[ny][nx]=dist[y][x]+1;
      }
    }
  }
  int M=dist[H-1][W-1];
  int sum=0;
  vector<int> v(2500,-1);
  for (int y=0;y<H;y++){
    for (int x=0;x<W;x++){
      if (field[y][x]=='.'){
        sum++;
      }
    }
  }
  int ans=-1;
  if (M!=-1){
    ans=sum-M-1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys


def main():
    N = int(input())
    musics = [input().split() for _ in range(N)]
    X = input()

    count_flag = False
    time = 0
    for i, m in enumerate(musics):
        if count_flag:
            time += int(m[1])
        if m[0] == X:
            count_flag = True

    print(time)


if __name__ == '__main__':
    main()


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

List=[''.join(sorted(input())) for i in range(N)]
List.sort()
List.extend("1")
cnt = 0
num = 0

for i in range(N):
  a = List[i]
  b = List[i+1]
  if a != b:   
    cnt = cnt + num * (num+1) / 2
    num = 0 
  else:
    num = num + 1

print(int(cnt))

Measured memory_bytes: 10640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pi pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pii(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
int no=0;
bool compare(int a,int b)
{   
	return (a%2==1)&&(b%2==0);
}
int main()
{
	ios;
	int w,h,x,y;
	cin>>w>>h>>x>>y;
	cout<<(double)w*h/2<<" ";
	if(w%2==0&&h%2==0&&h/2==y&&w/2==x)
		 cout<<1;
    else 
        cout<<0;		
}


Measured memory_bytes: 256
parseInt(x) = parse(Int32, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function root(uf::Array{Int,1},x);s=x;while uf[s]!=s;s=uf[s];end;s;end
function same(uf::Array{Int,1},x,y);root(uf,x)==root(uf,y)?true:false;end
function unite(uf::Array{Int,1},x,y);l=root(uf,x);r=root(uf,y);if l<r;uf[r]=l;elseif l>r;uf[l]=r;end;end

function main()
	n,m = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	uf = Int[i for i in 1:n]
	for i in 1:m
		x,y = readline() |> split |> parseMap
		unite(uf,x+1,y+1)
	end
	d = Dict{Int,Array{Tuple{Int,Int},1}}()
	for i in 1:n
		r = root(uf,i)
		if haskey(d,r)
			push!(d[r],(i,a[i]))
		else
			d[r] = Tuple{Int,Int}[(i,a[i])]
		end
	end
	k = length(keys(d))-1
	if 2*k>n
		println("Impossible")
	elseif k==0
		println(0)
	else
		v = 0
		used = zeros(Int,n)
		for i in keys(d)
			d[i] = sort(d[i],by=x->x[2])
			used[d[i][1][1]] = 1
			v += d[i][1][2]
		end
		use = Int[]
		for i in 1:n
			if used[i] == 0
				push!(use,a[i])
			end
		end
		use = sort(use)
		for i in 1:2k-k-1
			v += use[i]
		end
		println(v)
	end
end

main()

Measured memory_bytes: 183452
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int N, D;
    cin >> N >> D;
    int ans = N/(2*D+1)+(N%(2*D+1)>0);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int A, B;
    cin >> A >> B;

    if(A <= 8 && B <= 8) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100005;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
ll f(ll k){
    if (k == 0 || k == -1) return 0;
    if ((k-1)%2 == 0) return ((k-1)/2+1)%2;
    else return (((k-1)/2+1)%2)^k;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin >> a >> b;
    PRINT((f(b)^f(a-1)));
}





Measured memory_bytes: 256