akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#include<string>
#include<cstdlib>
using namespace std;

queue <string> Name;
queue <int> Time;

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

 string name;
 int time;
 for( int i=0; i<n; i++ ){
   cin >> name >> time;
   Name.push(name);
   Time.push(time);
 }

 int q_time = 0;
 while( !Time.empty() ){
   if( Time.front() <= q ){
     q_time += Time.front();
     cout << Name.front() << " " << q_time << endl;
     Name.pop();
     Time.pop();
   }else{
     string n_tmp = Name.front();
     int t_tmp = Time.front();
     q_time += q;
     Name.pop();
     Name.push(n_tmp);
     Time.pop();
     Time.push(t_tmp-q);
   }
 }

 return 0;
}


Measured memory_bytes: 5800
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = (1 << 30);
const ll inf = (1LL << 60LL);
const int maxn = 50005;
int A, B, K;
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> A >> B >> K;
    int turn = 0;
    while(K --){
        if(turn == 0){
            if(A & 1){
                A --;
            }
            B += (A >> 1);
            A >>= 1;
        }
        else{
            if(B & 1){
                B --;
            }
            A += (B >> 1);
            B >>= 1;
        }
        turn ^= 1;
    }
    cout << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 256
/*g++ main.cpp -o main.out*/
/*./main.out*/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()
{
    char c;
    cin>>c;
    cout<<(char)(c+1)<<endl;
    return 0;
}

















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

using namespace std;


void traverse(vector<int>& distances,vector<vector<int> >& adjList,vector<bool>& visited, int node){
    visited[node] = true;
    for(int i=0;i<adjList[node].size();i++){
      if(!visited[adjList[node][i]])
        traverse(distances,adjList,visited,adjList[node][i]);
       distances[node] = max(distances[node],1+distances[adjList[node][i]]);

    }
}

int main(){
  int N,M;
  int maxP = INT_MIN;
  cin>>N>>M;
  vector<vector<int> > adjList(N);
  vector<int> distances(N,0);
  vector<bool> visited(N,false);
  for(int i=0;i<M;i++){
    pair<int,int> e;
    cin>>e.first>>e.second;
    adjList[e.first-1].push_back(e.second-1);
  }
  // for(int i=0;i<N-1;i++){
  //   for(int j=0;j<M;j++){
  //     pair<int,int> e = edges[j];
  //     int src = e.first;
  //     int dist = e.second;
  //     distances[dist-1] = max(distances[dist-1],1+distances[src-1]);
  //   }
  // }
  for(int i=0;i<N;i++){
    if(!visited[i])
      traverse(distances,adjList,visited,i);
  }
  for(int i=0;i<N;i++){
    //
      maxP = max(maxP,distances[i]);


  }

  cout<<maxP;



  return 0;
}


Measured memory_bytes: 12268
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int N;
    cin >> N;
    map<int, int> m;
    REP (i, 0, N) {
        int a;
        cin >> a;
        m[a]++;
    }
    int ans = 0;
    for (auto n : m) {
        ans += n.second % 2;
    }
    cout << ans << endl;
    return 0;
}


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

bool f[100000] = {};

int main() {

  vector< long long int > sosu;

  for ( long long int i = 2; i < 100000; i++ ) {

    if ( f[i] == false ) {
      sosu.push_back( i );
      for ( long long int j = 2; j*i < 100000; j++ ) {
	f[j*i] = true;
      }
    }

  }

  while( true ) {

    long long int m, a, b;
    cin >> m >> a >> b;
    if ( m == 0 ) break;

    long long int ans_x, ans_y, cnt = 0;

    for ( long long int x = 0; x < sosu.size(); x++ ) {
      for ( long long int y = 0; y <= x; y++ ) {

	long long int s = sosu[x] * sosu[y];
	if ( s > m ) break;
	if ( a * sosu[x] <= b * sosu[y] ) {
	  if ( s > cnt ) {
	    cnt = s;
	    ans_x = sosu[x];
	    ans_y = sosu[y];
	  }
	}

      }
    }

    cout << ans_y << " " << ans_x << endl;

  }

  return 0;

}

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

class Program
{

	//Main
	static void Main(string[] args)
	{
		//読み込む
		double R = double.Parse(Console.ReadLine());
		double ans = 2 * R * Math.PI;

		//出力
		Console.WriteLine(ans);
	}
}


Measured memory_bytes: 18432
import scala.io.StdIn.{readInt,readLine}

object Main extends App {
  def eval(math:Int,eng:Int,jp:Int) = {
    if(math == 100 || eng == 100 || jp == 100) "A"
    else if((math+eng)/2 >= 90) "A"
    else if((math+eng+jp)/3 >= 80) "A"
    else if((math+eng+jp)/3 >= 70) "B"
    else if((math+eng+jp)/3 >= 50 && (math >= 80 || eng >= 80)) "B"
    else "C"
  }

  println {
    Iterator.continually(readInt).takeWhile(_ != 0).map { n =>
      {
        for(i<- 1 to n) yield {
          val score = readLine.split(" ").map(_.toInt)
          eval(score(0),score(1),score(2))
        }
      }.mkString("\n")
    }.mkString("\n")
  }
}

Measured memory_bytes: 48244
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		int a[] = new int[n];
		
		Arrays.fill(a, 0);
		
		for(int i = 0; i < k; i++) {
			int d = sc.nextInt();
			for(int j = 0; j < d; j++) {
				a[sc.nextInt()-1]++;
			}
		}
		
		int c = 0;
		for(int i = 0; i < n; i++)
			if(a[i] == 0) c++;
		
		System.out.println(c);
	}
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

const int inf = 1e9 + 7;
const ll inf_ll = 1e18L + 7;

template <typename T>
void mini(T& a, T b) {
  a = min(a, b);
}

template <typename T>
void maxi(T& a, T b) {
  a = max(a, b);
}

// dp(i) <-- true, if first player wins and i stones remaining.

int main() {
  int n, K;
  scanf("%d %d", &n, &K);
  std::vector<int> stones(n);
  for (int& s : stones) scanf("%d", &s);

  std::vector<std::vector<bool>> dp(2, vector<bool>(K + 1, false));
  for (int rem = 0; rem <= K; ++rem)
    for (int t : {0, 1})
      for (int s : stones) {
        if (rem - s >= 0 && !dp[!t][rem - s]) dp[t][rem] = true;
      }
  cout << (dp[0][K] ? "First" : "Second") << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
//import java.io.*;
//import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		//InputStreamReader is = new InputStreamReader(System.in);
		//BufferedReader br = new BufferedReader(is);
		int Points[] = new int[6];
		int sum = 0;
		for(int i = 0 ; i < 6 ; i++){
			Points[i] = scan.nextInt();
		}
		int small = Points[0];
		for(int i = 1 ; i < 4 ; i++){
			if(small > Points[i]){
				small = Points[i];
			}
		}
		for(int i = 0 ; i < 4 ; i++){
			sum += Points[i];
		}
		sum -= small;
		if(Points[4] > Points[5]){
			sum += Points[4];
		}else{
			sum += Points[5];
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 26180
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




int w, h, gy, gx, m[65][65], d[65][65];

void bfs(int y, int x, int k){
    if(y == gy && x == gx)return;
    
    if(x < gx && m[y][x + 1] == 0 && k + 1 < d[y][x + 2]){
        d[y][x + 2] = k + 1;
        bfs(y, x + 2, k + 1);
    }
    if(0 < x && m[y][x - 1] == 0 && k + 1 < d[y][x - 2]){
        d[y][x - 2] = k + 1;
        bfs(y, x - 2, k + 1);
    }
    if(y < gy && m[y + 1][x] == 0 && k + 1 < d[y + 2][x]){
        d[y + 2][x] = k + 1;
        bfs(y + 2, x, k + 1);
    }
    if(0 < y && m[y - 1][x] == 0 && k + 1 < d[y - 2][x]){
        d[y - 2][x] = k + 1;
        bfs(y - 2, x, k + 1);
    }
}

int main() {
    cin >> w >> h;
    while(w != 0 || h != 0){
        REP(i, 65){
            REP(j, 65){
                m[i][j] = 0;
                d[i][j] = 1e9;
            }
        }
        REP(i, h * 2 - 1){
            if(i % 2 == 0){
                REP(j, w - 1){
                    cin >> m[i][j * 2 + 1];
                }
            }
            else{
                REP(j, w){
                    cin >> m[i][j * 2];
                }
            }
        }
        
        gy = h * 2 - 2;
        gx = w * 2 - 2;
        d[0][0] = 0;
        bfs(0, 0, 1);
        
        cout << ((d[gy][gx] != 1e9)? d[gy][gx] : 0) << endl;
        
        cin >> w >> h;
    }
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}

class RMQ_segment_tree
{
    using data_type = Pii;

public:

    vector<data_type> dat;
    int N;
    data_type inf;

    RMQ_segment_tree(int n, data_type inf): inf(inf) {
        N = 1;
        while(n > N) N = N << 1;
        dat = vector<data_type>(2 * N - 1, inf);
    }

    //k番目の値をaに更新
    void update(int k, data_type a){
        k += N - 1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1) / 2;
            dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }

    //[a, b)の最小値
    data_type minval(int a, int b){
        return query(a, b, 0, 0, N);
    }

    data_type query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return inf;
        if(a <= l && r <= b) return dat[k];
        else{
            data_type vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            data_type vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }
};

void addm(mat &m, RMQ_segment_tree &ST, int a, int b){
    if(a == b) return;
    Pii p = ST.minval(a, b);
    int v = p.first, i = p.second;
    m[a][i] -= v;
    m[i + 1][i] += v;
    m[a][b] += v;
    m[i + 1][b] -= v;
    addm(m, ST, a, i);
    addm(m, ST, i + 1, b);
}

signed main(){

    int N, M; cin >> N >> M;
    vec A(N - 1); readv(A);
    mat B(N, vec(M));
    REP(i, N) readv(B[i]);

    mat m(N + 1, vec(N + 1, 0));
    REP(i, M){
        RMQ_segment_tree ST(N, Pii(INF, INF));
        REP(j, N) ST.update(j, Pii(-B[j][i], j));
        addm(m, ST, 0, N);
    }
    REP(a, N + 1) REP(b, N) m[a][b + 1] += m[a][b];
    REP(b, N + 1) REP(a, N) m[a + 1][b] += m[a][b];

    //debug(m);

    vec sumA(N);
    sumA[0] = 0;
    REP(i, N - 1) sumA[i + 1] = sumA[i] + A[i];

    int ans = 0;
    REP(a, N){
        FOR(b, a, N){
            ans = max(ans, m[a][b] - sumA[b] + sumA[a]);
        }
    }

    cout << ans;
    
    return 0;
}

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

using namespace std;

void func_a() {
    int x, y, z;
    cin >> x;
    cin >> y;
    cin >> z;

    cout << z << " " << x << " " << y << "\n";

}

void func_b() {
    int n, m;
    cin >> n;
    cin >> m;

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

    int count = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] >= sum / (4 * m) ) {
            ++count;
            if (count == m) break;
        }
    }

    if (count == m) cout << "Yes";
    else cout << "No";


}

void func_c() {
    long long  n, k;
    cin >> n;
    cin >> k;

    // cout << n << " " << k << "\n";
    n = n % k;
    long long temp = (n - k > 0) ? n - k : k - n;
    if (n > temp) n = temp;

    cout << n;
}

int main()
{
    //func_a();
    //func_b();
    func_c();
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <deque>
#include <utility>

int main()
{
    std::deque< std::pair<short, short> > data;
    while(1)
    {
        short x, y;
        scanf("%hd %hd", &x, &y);
        if(x == 0 && y == 0) break;
        std::pair<short, short> p;
        p.first = (x < y) ? x : y;
        p.second = (x < y) ? y : x;
        data.push_back(p);
    }
    for(const auto &elem : data)
    {
        printf("%d %d\n", elem.first, elem.second);
    }
}


Measured memory_bytes: 2644
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1e9+7;
const ll mx = 51;
int n;
ll mat[mx][mx];
ll ans[mx][mx];
void add_self(ll& a, ll b){
  a=a+b;
  if(a>=mod){
    a-=mod;
  }
}
ll mul(ll a, ll b){
  return (ll)a * b % mod;
}
int main(){
  ll k;
  cin >> n >> k;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin >> mat[i][j];
      ans[i][i]=1ll;
    }
  }
  while(k>0){
    ll c[mx][mx];
    if(k%2==1){
      memset(c,0,sizeof(c));
      for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
          for(int k=0;k<n;k++){
            ll x=c[i][k];
            add_self(x, mul(ans[i][j],mat[j][k]));
            c[i][k]=x;
          }
        }
      }
      for(int i=0;i<n;i++) for(int j=0;j<n;j++) ans[i][j]=c[i][j];
    }
    memset(c,0,sizeof(c));
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        for(int k=0;k<n;k++){
          ll x=c[i][k];
          add_self(x, mul(mat[i][j],mat[j][k]));
          c[i][k]=x;
        }
      }
    }
    for(int i=0;i<n;i++) for(int j=0;j<n;j++) mat[i][j]=c[i][j];
    k/=2;
  }
  ll total = 0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      add_self(total, ans[i][j]);
    }
  }
  cout<<total<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

sx, sy, tx, ty = map(int, input().split())

dif_x = abs(tx - sx)
dif_y = abs(ty - sy)


for i in range(dif_x):
    print("R" , end="")

for i in range(dif_y):
    print("U", end="")

for i in range(dif_x):
    print("L", end="")

for i in range(dif_y):
    print("D", end="")

#２周目

print("D", end="")
for i in range(dif_x+1):
    print("R", end="")

for i in range(dif_y+1):
    print("U", end="")

print("L", end="")

print("U", end="")

for i in range(dif_x+1):
    print("L", end="")

for i in range(dif_y+1):
    print("D", end="")

print("R", end="")


Measured memory_bytes: 4468
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
    int n,m;
    cin>>n>>m;
    V<V<int>> graph(n);
    V<int> rev(n,0);
    for(int i=0;i<n+m-1;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        graph[a].push_back(b);
        rev[b]++;
    }
    int par=0;
    for(int i=0;i<n;i++){
        if(rev[i]==0){
            par=i;
            break;
        }
    }
    V<int> ans(n);
    ans[par]=0;
    queue<P> q;
    q.push(P(par,-1));
    while(q.size()){
        int now=q.front().fi,bfo=q.front().se;
        q.pop();
        if(bfo!=-1)ans[now]=bfo+1;
        for(int v:graph[now]){
            if(rev[v]>1){
                rev[v]--;
                continue;
            }
            q.push(P(v,now));
        }
    }
for(int v:ans)cout<<v<<"\n";
}

Measured memory_bytes: 7040
import java.util.Scanner;

public class Main
{

    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int y;
        int b = -1000000;

        int s = 1000000;
        long sum = 0;

        for (int x = 0; x != n; x++) {
            y = scan.nextInt();
            sum = sum + y;

            if (y >= b) {
                b = y;
            }
            if (y <= s) {
                s = y;
            }

        }

        System.out.print(s + " ");
        System.out.print(b + " ");
        System.out.println(sum);
    }

}



Measured memory_bytes: 41284
S=input()
flag=True
for i,v in enumerate(S):
    if i%2==0:
        if (v!="R" and v!="U") and v!="D":
            flag=False
            break
    else:
        if (v!="L" and v!="U") and v!="D":
            flag=False
            break
if flag:
    print("Yes")
else:
    print("No")

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

bool comp(const VI& v1, const VI& v2){
  if(SZ(v1) != SZ(v2))
	return SZ(v1) < SZ(v2);
  REP(i,SZ(v1)){
	if(v1[i] != v2[i])
	  return v1[i] < v2[i];
  }
  return false;
}

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

  int N;
  cin >> N;
  VL as(N);
  cin >> as;

  map<LL,VI> memo;
  memo[1] = {};
  REP(i,N){
	vector<pair<LL,VI>> tmp;
	for(auto& p: memo){
	  VI buf = p.SS;
	  buf.PB(i+1);
	  tmp.PB(MP(p.FF * as[i], buf));
	}

	for(auto& b: tmp)
	  if(!memo.count(b.FF))
		memo[b.FF] = b.SS;
	  else if(comp(b.SS, memo[b.FF])){
		memo[b.FF] = b.SS;
	  }
  }

  cout << SZ(memo.rbegin()->SS) << endl;
  for(int i: memo.rbegin()->SS) cout << i << endl;

  return 0;
}



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

using P = pair<int, int>;

int main() {
    int N, M;

    map<int, vector<int>> To;
    priority_queue<P, vector<P>, greater<P>> queue;


    cin >> N >> M;
    int fromId[N];
    int distance[N];

    for (int i=0; i<M; i++) {
        int from, to;
        cin >> from >> to;
        if (To.find(from) == To.end()) {
            To.insert(make_pair(from, vector<int>()));
        }
        To[from].push_back(to);
        if (To.find(to) == To.end()) {
            To.insert(make_pair(to, vector<int>()));
        }
        To[to].push_back(from);
    }

    for (int i=2; i<=N; i++) {
        distance[i] = INT32_MAX;
    }

    distance[1] = 0;
    queue.push(P(0, 1));

    while (!queue.empty()) {
        P p = queue.top();
        queue.pop();
        int d = p.first;
        int node = p.second;
        //cout << node << ":" << d << endl;

        for (int to: To[node]) {
            //cout << to << "..." << endl;
            if (d + 1 < distance[to]) {
                //cout << "added " << to << " dist:" << d + 1 << endl;
                distance[to] = d + 1;
                fromId[to] = node;
                queue.push(P(distance[to], to));
            }
        }
    }

    for (int i=1; i<=N; i++) {
        if (distance[i] == INT32_MAX) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    for (int i=2; i<=N; i++) {
        cout << fromId[i] << endl;
    }
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  set<pair<int, int>> s;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    s.insert(make_pair(a, b));
  }
  int ans = 0;
  int start = 0, end = 1;
  for (auto p: s) {
    if (p.first > start) {
      start = p.first;
      if (p.first >= end) {
        end = p.second;
        ans++;
      } else if (p.second < end) {
        end = p.second;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
	string S;
  cin >> S;
  bool flag = false;
  
  for(int i = 0; i < S.size(); i++){
   if(i%2 == 0){
     if(S.at(i) == 'L'){
       cout << "No" << endl;
       return 0;
     }
   } else{
     if(S.at(i) == 'R'){
       cout << "No" << endl;
       return 0;
     }
   }
  }    
  cout << "Yes" << endl;
  
  return 0;
}

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

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

i64 n, c, k;
vector<i64> t;
int main() {
  cin >> n >> c >> k;
  read_n(t, n);
  sort(begin(t), end(t));
  i64 ans = 0;
  priority_queue<i64, vector<i64>, greater<i64>> pq;
  for (i64 i = 0; i < n; ++i) {
    bool f = true;
    if (!pq.empty() && t[i] == pq.top()) {
      pq.push(t[i] + k);
      f = false;
    }
    while (!pq.empty() && t[i] >= pq.top()) {
      for (i64 j = 0; j < c && !pq.empty(); ++j) {
        pq.pop();
      }
      ++ans;
    }
    if (f) pq.push(t[i] + k);
  }
  while (!pq.empty()) {
    for (i64 j = 0; j < c && !pq.empty(); ++j) {
      pq.pop();
    }
    ++ans; 
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int a, b, c;
	cin >> a >> b >> c;
	set<int> s;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	if (s.size()==2) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	//cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
  
int main() {
    int h,w;
    while(true){
        cin>>h>>w;
        if(h==0 && w==0) break;
 
        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                if((i+j)%2==0){
                  cout<<'#';
                }else{
                  cout<<'.';
                }
            }
          cout<<endl;
        }
       cout<<endl;
    }
}


Measured memory_bytes: 3124
n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = input()

dpp=[0]*(n+1)
dpw=[0]*(n+1)

for i in range(1, k+1):
  dpw[i]=1
  if t[i-1]== "r":
    dpp[i]=dpp[i-1]+p
  elif t[i-1]== "s":
    dpp[i]=dpp[i-1]+r
  else:
    dpp[i]=dpp[i-1]+s

for i in range(k+1, n+1):
  if dpw[i-k]==0:
      dpw[i] = 1
      if t[i-1]== "r":
        dpp[i]=dpp[i-1]+p
      elif t[i-1]== "s": 
        dpp[i]=dpp[i-1]+r
      else:
        dpp[i]=dpp[i-1]+s
  else:
      if t[i-k-1]==t[i-1]:
        dpw[i]=0
        dpp[i]=dpp[i-1]
      else:
        dpw[i]=1
        if t[i-1]== "r":
          dpp[i]=dpp[i-1]+p
        elif t[i-1]== "s":
          dpp[i]=dpp[i-1]+r
        else:
          dpp[i]=dpp[i-1]+s

print(dpp[n])

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

int main(){
  int A[4][4];
  int N;
  int b[11];
  
  cin >> A[1][1] >> A[1][2] >> A[1][3];
  cin >> A[2][1] >> A[2][2] >> A[2][3];
  cin >> A[3][1] >> A[3][2] >> A[3][3];
  cin >> N;
  for(int i=1;i<=N;i++){
    cin >> b[i];
  }
  
  for(int ca=1;ca<=3;ca++){
    for(int cb=1;cb<=3;cb++){
      for(int cc=1;cc<=N;cc++){
        if(A[ca][cb]==b[cc])
          A[ca][cb]=0;
      }
    }
  }
  for(int j=1;j<=3;j++){
    if(A[j][1]+A[j][2]+A[j][3]==0){
      cout << "Yes" << endl;
      goto FINISH;
    }
    else if(A[1][j]+A[2][j]+A[3][j]==0){
      cout << "Yes" << endl;
      goto FINISH;
    }
  }
  if(A[1][1]+A[2][2]+A[3][3]==0){
    cout << "Yes" << endl;
    goto FINISH;
  }
  else if(A[3][1]+A[2][2]+A[1][3]==0){
    cout << "Yes" <<endl;
    goto FINISH;
  }
  else
    cout << "No" << endl;
  FINISH: return 0;
}
      
    

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
    int H;
    int W;

		while(true){
			H = scanner.nextInt();
			W = scanner.nextInt();
			if(H==0 && W==0){
				    break;
      }
			for (int i=0;i<H;i++) {
				for (int j=0;j<W;j++) {
					if((i+j)%2==0){
						System.out.print("#");
					}else{
						System.out.print(".");
          }
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		 }

	  }
}


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

 int f(int i){
   if(i == 1){
     return 300000;
   }
   if(i == 2){
     return 200000;
   }
   if(i == 3){
     return 100000;
   }
   else{
     return 0;
   }
 }
int main(){
  int x, y;
  cin >> x >> y;

  int ans = 0;
  if(x == 1 && y ==1){
    ans = 1000000;
  }else{
    ans = f(x) + f(y);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import random
from copy import deepcopy

d = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for _ in range(d)]

def min_max(l):
    l_min = min(l)
    l_max = max(l)
    return [(i - l_min) / (l_max - l_min) for i in l]

dd = [max(s[i]) for i in range(d)]
qq = min_max(c)
dd = min_max(dd)

ddd = [i for i in range(d)]
qqq = [i for i in range(26)]

ans = []
last = [0]*26
for i in range(d):
    ma_po = -10**10
    ma_di = 0
    for j in range(26):
        po = s[i][j]
        for k in range(26):
            if k == j:
                continue
            po -= c[k]*(i+1-last[k])
        if po > ma_po:
            ma_po = po
            ma_di = j
    last[ma_di] = i+1
    ans.append(ma_di+1)

def score(l):
    lastd = [0]*26
    point = 0
    for j,k in enumerate(l):
        kk = k-1
        point += s[j][kk]
        lastd[kk] = j+1
        for l in range(26):
            point -= c[l]*(j+1-lastd[l])
    return point

ma = score(ans)

def random_search():
    global ans,ma
    li = deepcopy(ans)
    D = random.choices(ddd,k=1,weights=dd)[0]
    lin = [p+1 for p in range(26)]
    Q = random.choices(qqq,k=1,weights=qq)[0]
    li[D] = Q+1
    if score(li) > ma:
        ans = deepcopy(li)
        ma = score(li)

for i in range(25000):
    random_search()

for i in ans:
    print(i)

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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

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

const int N = 200500;

int a[N], c[N], cnt, n;
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	srand(time(NULL));

	//cin.tie(NULL);
	//cout.tie(NULL);
	//ios_base::sync_with_stdio(false);

	//cout << setprecision(5) << fixed;
	cin >> n;
	int maxx = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		c[a[i]]++;
		maxx = max(maxx, a[i]);
	}
	cnt = n;
	if (maxx == 1 && c[maxx] == 2)
	{
		cout << "Possible\n";
		return 0;
	}

	if (maxx == 1)
	{
		cout << "Impossible";
		return 0;
	}


	for (int i = maxx; i >= maxx / 2 + maxx % 2; i--)
	{
		if ((c[i] > 1) || (maxx % 2 == 0 && i == maxx / 2 && c[i] == 1) || (maxx % 2 == 1 && i == maxx / 2 + maxx % 2 && c[i] == 2))
		{
			cnt -= c[i];
		}
		else
		{
			cout << "Impossible";
			return 0;
		}
	}
	if (cnt > 0 || (maxx % 2 == 0 && c[maxx / 2] != 1) || (maxx % 2 == 1 && c[maxx / 2 + maxx % 2] != 2)) {
		cout << "Impossible";
		return 0;
	}

	cout << "Possible\n";		

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define SIZE 200000
using namespace std;
 
struct Queue{
  int table[SIZE];
  int tail,head;
 
  void init(){
    head=tail=0;
  }
 
  bool empty(){
    return head==tail;
  }
   
  void inqueue(int x){
    table[tail]=x;
    tail++;
    tail%=SIZE;
  }
 
  int dequeue(){
    if(empty())return 0;
    int res=table[head];
    head++;
    head%=SIZE;
    return res;
  }
};
 
int main(){
  Queue queue,queue2;
  int n,q,num;
  string table[SIZE];
  cin>>n>>q;
  queue.init();
  queue2.init();
  for(int i=0;i<n;i++){
    cin>>table[i]>>num;
    queue.inqueue(num);
    queue2.inqueue(i);
  }
   
  int now=0,A,B;
  while(!queue.empty()){
    A=queue.dequeue();
    B=queue2.dequeue();
    if(A<=q){
      now+=A;
      cout<<table[B]<<' '<<now<<endl;
    }else{
      now+=q;
      A-=q;
      queue.inqueue(A);
      queue2.inqueue(B);
    }
  }
   
  return 0;
}


Measured memory_bytes: 8548
def gcd(x,y):
    while not y == 0:
        x,y = y,x%y
    return x  
A,B,C,D = map(int,input().split())
A -= 1
ans = (B-(B//C)-(B//D)+(B//(C*D//gcd(C,D))))-(A-(A//C)-(A//D)+(A//(C*D//gcd(C,D))))
print(ans)

Measured memory_bytes: 3060
import sys
n, m=map(int, raw_input().split())
sys.setrecursionlimit(n+1000)
adj=[[] for i in range(n+1)]
for i in range(m):
	u, v=map(int, raw_input().split())
	adj[u].append(v)
	adj[v].append(u)
isolated_cnt=0
bipartite_cnt=0
other_cnt=0
color=[0]*(n+1)
def dfs(cur):
	global ok
	for to in adj[cur]:
		if not color[to]:
			color[to]=3-color[cur]
			dfs(to)
		else:
			if color[to]!=3-color[cur]:
				ok=False
for i in range(1, n+1):
	if adj[i]:
		if not color[i]:
			color[i]=1
			ok=True
			dfs(i)
			if ok:
				bipartite_cnt+=1
			else:
				other_cnt+=1
	else:
		isolated_cnt+=1
print>>sys.stderr, isolated_cnt, bipartite_cnt, other_cnt
print isolated_cnt*n*2-isolated_cnt*isolated_cnt+bipartite_cnt*(bipartite_cnt*2+other_cnt)+other_cnt*(bipartite_cnt+other_cnt)

Measured memory_bytes: 85076
package main

import "fmt"

func main() {
    var A, B, cnt int
    fmt.Scan(&A, &B)
    for i:=A; i<=B; i++ {
        if i/10000 == i%10 && i/1000%10 == i/10%10 {
            cnt++
        }        
    }
    fmt.Println(cnt)
}

Measured memory_bytes: 512
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    long long a,b;
    cin >>a>>b;
    // if(a%2==0 && b%2==0){
    //     cout <<(a*b)/2;
    // }
    if (a==1 || b==1) {
        cout <<1;
        return 0;
    }
    if (((a*b)%2)==0){
        cout << fixed;
        cout <<(a*b)/2;
    }
    else {
        cout << fixed;
        cout <<((((a*b)/2))+1);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <cmath>
typedef long long int ll;
using namespace std;
ll N = pow(10,10); 
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	int n;cin>>n;
	int count=0; ll mini = N;
	for(int i=0;i<n;i++){
		ll a;cin>>a;
		if(a<mini){
			count++;
			mini = a;
		}
	}
	cout<<count<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

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

    if(s == "RRR") {
        out(3);
    }
    else if(s == "RRS" || s == "SRR") {
        out(2);
    }
    else if(s == "SSS") {
        out(0);
    }
    else {
        out(1);
    }
    
    re0;
}

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

const double PI = 3.141592653589793;

int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  
  double ang_h, ang_m, ang;
  ang_m = m * PI / 30;
  ang_h = ang_m / 12 + h * PI / 6; 
  ang = max(ang_m - ang_h, ang_h - ang_m);
  if (ang > PI)
    ang = 2 * PI - ang;
  
  double dist = a * a + b * b - 2 * a * b * cos(ang);
  
  cout << setprecision(18) << fixed << sqrt(dist) << endl;
  
  return 0;
}

Measured memory_bytes: 4204
#!/usr/bin/env python3
s = input()
ans = len(s)
for i in range(0, 2):
    cnt = 0
    for j in range(0, len(s)):
        if j % 2 == 0 and s[j] != str(i): cnt += 1
        if j % 2 == 1 and s[j] == str(i): cnt += 1
    ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 3188
c=[0] * 52
for i in range(13):
    c[i]='S {0}'.format(i+1)
    c[13+i]='H {0}'.format(i+1)
    c[26+i]='C {0}'.format(i+1)
    c[39+i]='D {0}'.format(i+1)

for i in range(int(input())):
    c.remove(input())

if c:print('\n'.join(c))


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#include <stdlib.h>
#include <cmath>
using namespace std;
typedef long long ll;
ll mod=1000000007;
ll BIG=1e9;
int H,W,N; 


int m[100][100];

int main(){
    cin>>H>>W>>N;
    int x=0;
    for(int i=1;i<=N;i++) {
        int K;
        cin>>K;
        for(int j=0;j<K;j++){
            int a=x/(2*W), b=x%(2*W);
            a*=2;
            if(b>=W) {a++; b=(2*W-b-1);}
            //cout<<"(x,a,b)=("<<x<<','<<a<<','<<b<<')'<<endl;
            m[a][b]=i;
            x++;
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++) cout<<m[i][j]<<' ';
        cout<<endl;
    }
    
    

}

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

namespace ABC123 {
	class ABC123_A {
		static void Main(string[] args) {
			// a-eの入力を配列に格納する - list intの配列にする int[5]で良いか
			// kの入力を受け付ける int
			// 正攻法の場合
			// a-b a-c の順に比較して、最後までたどり着いたら、Yay!と出力する
			// a-b a-c の順に比較して、途中で値を超えたら、:(と出力する
			var AE = new int[5];
			for (int i=0; i<5; i++) {
				AE[i] = int.Parse(Console.ReadLine());
			}
			var k = int.Parse(Console.ReadLine());
			CombinateAtoE(AE, k);
		}

		private static void CombinateAtoE(int[] AE, int k) {
			for(int i=0; i<AE.Length; i++) {
				for(int j=i+1; j<AE.Length; j++) {
					if((AE[j] - AE[i]) > k) {
						Console.WriteLine(":(");
						return;
					}
				}
			}
			Console.WriteLine("Yay!");
		}
	}
}


Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
  int n,k,tmp=1;
  double sum=0;
  cin >> n >> k;
  int cnt[n];
  for(int i=0;i<n;i++) cnt[i]=0;
  while(true){
    for(int i=1;i<=n;i++){
      if(tmp*i<k) cnt[i-1]++;
    }
    tmp*=2;
    if(tmp*1>=k) break;
  }
  for(int i=0;i<n;i++){
    sum += (1.0/pow(2,cnt[i]));
  }
  sum/=n;
  printf("%.9lf\n",sum);
}


Measured memory_bytes: 640
import heapq

n, m = map(int, input().split())
A = sorted(list(map(lambda x: int(x)*(-1), input().split())))

heapq.heapify(A)

for i in range(m):
    a = heapq.heappop(A)
    a = a * (-1) // 2
    heapq.heappush(A, -a)

print(-sum(A))


Measured memory_bytes: 14184
#include <bits/stdc++.h>
using namespace std; 
typedef long long lli;
#define mod 1000000007
#define fori(n) for(int i=0;i<n;i++)
#define forj(n) for(int j=0;j<n;j++)
#define forli(n) for(lli i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(),a.end())
 
//FUNCTONS
lli llipower(lli x, lli y){lli res = 1; while (y > 0){if (y & 1) res = (res*x); y = y>>1;x = (x*x);}return res;}
lli llipowerp(lli x, lli y,lli p){lli res = 1;x = x % p; while (y > 0){if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p;}return res;}
lli gcd(lli a, lli b){ if (!a) return b; return gcd(b%a,a);}
lli binarySearch(vector<int> arr, int l, int r, int x){ 
	if (r >= l) { 
		lli mid = l + (r - l) / 2; 
		if (arr[mid] == x) return mid; 
		if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x); 
		return binarySearch(arr, mid + 1, r, x); 
	}return -1;
}
template <typename T> void printvec(vector<T> inp){for(int i=0;i<inp.size();i++){cout<<inp[i]<<" ";}cout<<endl;}
template <typename T> T ceildiv(T x, T y){return 1 + ((x - 1) / y);}
lli modInverse(lli a, lli m){lli g = gcd(a, m);if (g != 1) return -1;else return llipowerp(a, m-2, m);} 

int main(){
    
    
    lli n;
    cin>>n;
    vector<lli> count(n+1, 0);
    vector<lli> nums(n);
    fori(n) cin>>nums[i];
    fori(n){
        count[nums[i]]++;

    }
    lli tot=0;
    //printvec(count);
    fori(n+1){
        tot=tot+((count[i]*count[i]-count[i])/2);
    }
    //cout<<tot<<endl;
    for(lli i=0;i<=n-1;i++){
        if(count[nums[i]]>1){

            cout << tot - count[nums[i]] + 1 << endl;
        }
        else cout<<tot<<endl;
    }
}
 


Measured memory_bytes: 5760
# https://atcoder.jp/contests/abc133/tasks/abc133_b

n, d = map(int, input().split())

matrix = []
for _ in range(n):
    row = [int(i) for i in input().split()]
    matrix.append(row)

ans = 0
for i in range(n):
    for j in range(i + 1, n):
        s = matrix[i]
        t = matrix[j]
        dist = 0
        for k in range(d):
            dist += (s[k] - t[k]) ** 2
        
        temp = 1
        while temp ** 2 <= dist:
            if temp ** 2 == dist:
                ans += 1
                break
            else:
                temp += 1
print(ans)


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-


def main():
    """Function."""
    s = str(input())
    t = str(input())

    flag = 0
    for _ in range(len(s)):
        temp = s[-1] + s[:-1]
        if temp == t:
            flag = 1
            break
        s = temp

    if flag == 1:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf 1000000000000000000

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    string s;
    cin>>n>>s;
    int ans=0;
    bool f=false;
    rep(i,n){
        if(s[i]=='x'&&f)break;
        if(s[i]=='x')f=true;
        else f=false;
        ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3352
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	for(int i = n;i <= 999;++i){
		if(i == 111 || i == 222 || i == 333 || i == 444 || i == 555 || i == 666 || i == 777 || i == 888 || i == 999){
			cout << i << '\n';
			return 0;
		}
	}
	return 0;
}


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

int N;

void solve()
{
	if(!N) cout << 0 << '\n';
	else{
		string s;
		while(N){
			int re = N % 2;
			if(re < 0) N -= 1;
			s += re?'1':'0';
			N/=-2;
		}
		reverse(s.begin(),s.end());
		cout << s << '\n';
	}
	return;
}

int main()
{
	cin >> N;
	solve();
	return 0;
}

Measured memory_bytes: 3624
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
dif=abs(t-0.006*h[0]-a)
ans=1
for i in range(1,n):
    if abs(t-0.006*h[i]-a)<dif:
        ans=i+1
        dif=abs(t-0.006*h[i]-a)
print(ans)

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

const int N = 10;

int main()
{
	int w[N];
	w[0] = 1;
	for(int i=1; i<N; i++){
		w[i] = w[i-1]*2;
	}
	int n;
	while(cin>>n){
		vector<int> all;
		for(int i=N-1; i>=0; i--){
			if(w[i]<=n){
				all.push_back(w[i]);
				n -= w[i];
			}
			if(n == 0) break;
		}
		for(int i=all.size()-1; i>=0; i--){
			if(i!=all.size()-1) cout<<" ";
			cout<<all[i];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <list>
using namespace std;

int main() {
	string s;
	cin >> s;
	list<char> ans;
	for (int i = 0; i < s.size(); i++)
		ans.push_back(s[i]);
	int q;
	cin >> q;
	int t, f, count = 0;
	char c;
	for (int i = 0; i < q; i++) {
		cin >> t;
		if (t == 1)
			count++;
		else {
			cin >> f >> c;
			if ((count % 2 == 0 && f == 1) || (count % 2 == 1 && f == 2))
				ans.push_front(c);
			else
				ans.push_back(c);
		}
	}
	if (count % 2 == 0) {
		while (!ans.empty()) {
			cout << ans.front();
			ans.pop_front();
		}
	}
	else {
		while (!ans.empty()) {
			cout << ans.back();
			ans.pop_back();
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 9984
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
const int inf = INT_MAX;
const double eps = 0.0000001;
const double PI = acos(-1.0);
const int MOD = 1e9+7;
const int N  = 3e3+5;

int lcs[N][N];

signed main(){
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif  
    IOS;

    string s, t;
    cin >> s >> t;
    s += '%';
    t += '^';
   	for (int i = 1; i <= s.length(); i++) {
   		for (int j = 1; j <= t.length(); j++) {
   			if (s[i-1] == t[j-1]) lcs[i][j] = 1 + lcs[i-1][j-1];
   			else lcs[i][j] = max(lcs[i-1][j], lcs[i][j-1]);
   		}
   	}
   	string ans = "";
   	int i = s.length(), j = t.length();

   	while(i > 0 && j > 0)
   	{
		if (s[i-1] == t[j-1]) {ans += s[i-1]; i--; j--;}
		else if (lcs[i][j] == lcs[i-1][j]) i--;
		else j--;
   	}
   	reverse(ans.begin(), ans.end());
   	cout << ans;
    return 0;
}

Measured memory_bytes: 70784
n,h=map(int,input().split())
A=[]
B=[]
C=[]
for i in range(n):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
amax=max(A)
for i in range(n):
    if amax<=B[i]:
        C.append(B[i])
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
cnt=0
ans=0
for i in range(len(C)):
    if ans<h:
        ans+=C[i]
    else:
        break
    cnt+=1
if ans<h:
    if ((h-ans)//amax)*amax>=h-ans:
        cnt+=(h-ans)//amax
    else:
        cnt+=(h-ans)//amax+1
        
print(cnt)

Measured memory_bytes: 67928
#include<stdio.h>
#include<string.h>
int main(){
  int a,b,c[3];
  scanf("%d%d",&a,&b);
  c[0]=a+b;
  c[1]=a-b;
  c[2]=a*b;
if((c[0]>=c[1])&&(c[0]>=c[2]))printf("\n%d",c[0]);
else if((c[1]>=c[0])&&(c[1]>=c[2]))printf("\n%d",c[1]);
else if((c[2]>=c[1])&&(c[2]>=c[0]))printf("\n%d",c[2]);

return 0;

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=200005;
map<int,vector<pair<int,int>>>a;
signed main()
{
	int n,x,d;
	cin>>n>>x>>d;
	if(d==0)
	{
		cout<<(x?n+1:1)<<endl;
		return 0;
	}
	if(d<0)
		x=-x,d=-d;
	for(int i=0;i<=n;i++)
	{
		int b=i*x,mn=i*(i-1)/2,mx=(2*n-i-1)*i/2;
		a[b%d].emplace_back(mn+b/d,mx+b/d);
	}
	int ans=0;
	for(auto &zh:a)
	{
		vector<pair<int,int>> &v=zh.second;
		sort(v.begin(),v.end());
		long long r=-1e18;
		for(auto i:v)
		{
			ans+=max(i.second-max(i.first,r)+1,0LL);
			r=max(r,i.second+1);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 22144
(defun split-and-parse-integer (string)
  (loop for i = 0 then (1+ j)
    as j = (position #\Space string :start i)
    collect (parse-integer (subseq string i j))
    while j))

(defparameter i 1)

(defun solve (lst)
  (when (= (car lst) i)
    (setf i (+ i 1))
    (solve (cdr lst))
      )
)


(solve (split-and-parse-integer (read-line)))
(princ i)

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

int main()
{
	char S[101], T[101];
	scanf("%s", &S);
	scanf("%s", &T);
	
	int i, j, l, flag = 0;
	for (l = 1; S[l] != 0; l++);
	for (i = 0; i < l; i++) {
		for (j = 0; j < l; j++) {
			if (S[(i+j)%l] != T[j]) break;
		}
		if (j == l) flag = 1;
	}
	
	if (flag == 1) printf("Yes\n");
	else printf("No\n");
	fflush(stdout);
	return 0;
}

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


int S[1001][1001];

void prep(string str1, string str2, int len1, int len2)
{
	int a, b, i;
	S[0][0] = 0;
	for(i = 1; i <= len1; i++){ S[i][0] = 0; }
	for(i = 1; i <= len2; i++){ S[0][i] = 0; }
	for(a = 1; a <= len1; a++){
		for(b = 1; b <= len2; b++){
			if(str1[a - 1] == str2[b - 1]){ S[a][b] = 1; }else{ S[a][b] = 0; }
		}
	}
	return;
}

int main()
{
	int i, a, b, q, len1, len2;
	cin >> q;
	string str1, str2;

	for(i = 0; i < q; i++){
		cin >> str1 >> str2;
		len1 = str1.size();
		len2 = str2.size();
		prep(str1, str2, len1, len2);
		for(a = 1; a <= len1; a++){
			for(b = 1; b <= len2; b++){
				if(S[a][b]){ S[a][b] = S[a - 1][b - 1] + 1; }
				else{ S[a][b] = max(S[a - 1][b], S[a][b - 1]); }
			}
		}
		cout << S[len1][len2] << endl;
	}
	return 0;
}

Measured memory_bytes: 5128