akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <bitset>
#include <queue>
#include <deque>
#include <utility>
#include <algorithm>
#include <ctime>
using namespace std;
 
int const MAX_N = 256 * 1024;
 
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
 
    int n,k;
    cin>>n>>k;
    
    long long ans = 0;
    for (int b = k+1; b<=n; b++) {
        long long cnt_full = n / b;
        ans += cnt_full * (b-k);
        if (k == 0) ans--;
        long long rem = n % b;
        if (k <= rem)
            ans += rem-k+1;
            
        //cout<<"B = "<<b<<" "<<ans<<"\n";
    }
     //   for (int a = k; a <= n; a += b) {
            
       //     cout<<"("<<a<<","<<b<<")  ";
         //   ans++;
    //    }
    cout<<ans;
    return 0;
}  


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
vector<int>MST[100006],G[100006];
int a[100006], b[100006];
int dist[100006];
int out[100006],in[100006];
int mpar[100006];

int par[100006], rnk[100006];
void init(int n) {
	rep(i, n) {
		par[i] = i; rnk[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x)return x;
	return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rnk[x] < rnk[y])par[x] = y;
	else {
		par[y] = x;
		if (rnk[x] == rnk[y])rnk[x]++;
	}
}

void dfs(int now) {
	rep(i, MST[now].size()) {
		int e = MST[now][i];
		if (dist[e] != inf)continue;
		dist[e] = dist[now] + 1;
		mpar[e] = now;
		in[e]++;
		dfs(e);
	}
}

signed main() {
	int n, m; cin >> n >> m;
	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}
	fill(dist, dist + n, inf);
	dist[0] = 0;
	
	if (m & 1) {
		cout << -1 << endl;
		return 0;
	}
	else {
		init(n);
		set<P>S;
		rep(i, m) {
			if (find(a[i]) != find(b[i])) {
				unite(a[i], b[i]);
				MST[a[i]].push_back(b[i]);
				MST[b[i]].push_back(a[i]);
			}
			G[a[i]].push_back(b[i]);
			out[a[i]]++;
			S.insert(P(a[i], b[i]));
		}
		dfs(0);
		vector<int>tps;
		stack<int>st;
		rep(i, n) {
			if (in[i] == 0)st.push(i);
		}
		while (st.size()) {
			int x = st.top(); st.pop();
			tps.push_back(x);
			rep(i, MST[x].size()) {
				in[MST[x][i]]--;
				if (in[MST[x][i]] == 0) {
					st.push(MST[x][i]);
				}
			}
		}
		reverse(tps.begin(), tps.end());
		rep(i, n-1) {
			if (out[tps[i]] & 1) {
				P p = make_pair(tps[i], mpar[tps[i]]);
				P up = make_pair(mpar[tps[i]], tps[i]);
				if (S.find(p) != S.end()) {
					S.erase(p);
					S.insert(up);
				}
				else {
					S.erase(up);
					S.insert(p);
				}
				out[tps[i]]++;
				out[mpar[tps[i]]]++;
			}
		}
		if (out[tps[n - 1]] & 1)cout << -1 << endl;
		else {
			for (auto i = S.begin(); i != S.end(); i++) {
				P p = *i;
				cout << p.first + 1 << ' ' << p.second + 1 << endl;
			}
		}
	}
}


Measured memory_bytes: 28916
import java.math.BigInteger;
import java.util.*;
import java.io.*;
import java.text.*;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 32768);
    static PrintWriter out = new PrintWriter(System.out);
    static StringTokenizer t;

    static String sn() {
        while (t == null || !t.hasMoreTokens()) {
            try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return t.nextToken();
    }

    static int ni() {
        return Integer.parseInt(sn());
    }

    static long nlo() {
        return Long.parseLong(sn());
    }

    public static void main(String args[]) {
        int t = 1;
        while (t-- > 0) {
            solve();
        }
        out.close();
    }

    static long mod = (long) 998244353;

    static long pro(long a, long b) {
        return (a % mod * b % mod) % mod;
    }

    static long add(long a, long b) {
        return (a + b) % mod;
    }

    static long sub(long a, long b) {
        return ((a % mod - b % mod) + mod) % mod;
    }

    static int maxn = 1000005;

    static int pow(int n) {
        return (int) (Math.log10(n) / Math.log10(2));
    }

    static long modpow(long x, long y) {
        long res = 1l;
        x %= mod;
        while (y > 0) {
            if (y % 2 != 0)
                res = pro(res, x);
            x = pro(x, x);
            y /= 2;
        }
        return res;
    }

    static class pair {
        String a;
        int b;

        pair(String x, int y) {
            a = x;
            b = y;
        }
    }

    static long modInverse(long n) {
        BigInteger n1 = new BigInteger(Long.toString(n));
        String s = (n1.modInverse(new BigInteger(Long.toString(mod)))).toString();
        return Long.parseLong(s);
    }

    static boolean v[] = new boolean[1000005];

    static void seive() {
        v[1] = true;
        for (int i = 2; i < 1000005; i++) {
            if (!v[i]) {
                for (int j = 2 * i; j < 1000005; j += i)
                    v[j] = true;
            }
        }
    }

    static boolean isprime(long n) {
        if (n == 1)
            return false;
        for (int i = 2; i * i <= n; i++) {
            if (n % i == 0)
                return false;
        }
        return true;
    }

    static long gcd(long a, long b) {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }

    static void solve() {
        int n=ni();
        int t=n%10;
        if(t==3)
            out.println("bon");
        else if(t==0 || t==1 ||t==6 ||t==8)
            out.println("pon");
        else
            out.println("hon");
    }
}



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

namespace AtCoder
{
    class Abc161C
    {
        public static void Main()
        {
            var nk = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
            var n = nk[0];
            var k = nk[1];
            if (n > k)
                n = n % k;
            Console.WriteLine(Math.Min(n, Math.Abs(n - k)));
        }
    }
}


Measured memory_bytes: 13396
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef long long int int64;
typedef unsigned long long int uint64;
typedef float float32;
typedef double float64;
typedef long double float128;


int main(){
    int a,b;
    cin >> a >> b;
    int ans=a-1;
    if(a<=b){
        ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
c = []
h, w = list(map(int, input().split()))
for i in range(h):
    c.append(input())
yes = True
for i in range(h):
    for j in range(w):
        if(c[i][j] == "."):
            continue
        if(i != 0 and c[i - 1][j] == "#"):
            continue
        if(i != h - 1 and c[i + 1][j] == "#"):
            continue
        if(j != 0 and c[i][j - 1] == "#"):
            continue
        if(j != w - 1 and c[i][j + 1] == "#"):
            continue
        yes = False
if(yes):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
def perpen_bisec(a,b,c,d)
   #(a,b) (c,d) perpendicular bisector ex+fy=g return [e,f,g]
   e = c - a
   f = d - b
   g = (c**2 + d**2 - a**2 - b**2)/2
   return [e,f,g]
end

def similu_eq(eq1, eq2) #eq1,2=[a,b,c] ax + by = c
   a,b,c = eq1
   d,e,f = eq2
   x = ((b*f-c*e)/(b*d-a*e))
   y = ((c*d-a*f)/(b*d-a*e))
   return [x,y]
end

num = gets.to_i
num.times do
   a,b,c,d,e,f = gets.split(' ').map(&:to_f)
   line1 = perpen_bisec(a,b,c,d)
   line2 = perpen_bisec(c,d,e,f)
   p = similu_eq(line1, line2)
   r = Math.sqrt((p[0] - a)**2 + (p[1] - b)**2)
   p.each do |each|
	  print sprintf("%.3f ", each+0.0)
   end
   print sprintf("%.3f\n", r+0.0)
end

Measured memory_bytes: 6176
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define repp(i,n,s) for (int i= (int)(n); i >= (int)(s); i--)
#define mp make_pair
ll mod = 1000000007;
ll mod2 = 998244353;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    int s = int(sqrt(n))+1;
    vector<int> ans(n+1);
    rep(i,1,s+1){
        rep(j,1,s+1){
            rep(k,1,s+1){
                ll z = i*i+j*j+k*k+i*j+j*k+k*i;
                if (z<=n) ans[z]++;
            }
        }
    }
    rep(i,1,n+1){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int ans=0;
  for (int i = n; i <= 999; i++)
  {
      /* code */
      if (i%111==0)
      {
          /* code */
          ans=i;
          break;

      }
      
  }
  cout<<ans<<endl;
   
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
  int board[10][7] = {{0}};
  int i, ii, j, k, H, sum, flag0;
  int number = 0, flag1 = 0, n, score = 0;

  scanf("%d",&H);
  while(H != 0 ) {
    flag0 = 1 ;
    score = 0 ;
    for( i=0; i<H; i++) {
      scanf("%d%d%d%d%d",&board[i][0],&board[i][1],&board[i][2],&board[i][3],&board[i][4]);
    }
    
    
    while(flag0 != 0 ) {

      flag0 = 0;
      for( i=0; i<H; i++ ) {
	flag1 = 0;
	for( j=0; j<5; j++ ) {
	  number = board[i][j] ;
	  if( number == board[i][j+1] ) {
	    flag1++ ;
	  } else {
	    flag1 = 0;
	  }
	  if ( flag1 == 2 ) {
	    for (n = j+1; n>j-2; n--) {
	      score += number;
	      board[i][n] = 0 ;
	    }
	    if(number == board[i][j+2] ) {
	      board[i][j+2] = 0;
	      score += number;
	      if( number == board[i][j+3] ) {
		board[i][j+3] = 0;
		score += number;
	      }
	    }
	    flag1 = 0;
	    break;
	  }
	}
      }
            
      for( j=0; j<5; j++ ) {
	sum = 0;
	for( k=0; k<H; k++) {
	  sum += board[k][j];
	}
	if(sum != 0) {
	  for( i=H-1; i>=0; i--) {
	    ii = i-1;
	    if(board[i][j] == 0) {
	      sum = 0;
	      for( k=i; k>=0; k--) {
		sum += board[k][j];
	      }
	      if(sum == 0 ) {
		break;
	      }
	      while(board[i][j] == 0) {
		board[i][j] = board[ii][j] ;
		board[ii][j] = 0;
		ii--;
		flag0++;
		if(ii < 0) {
		  break;
		}
	      }
	    }
	  }
	}
      }
    }
    printf("%d\n",score);
    scanf("%d",&H);
  }
  return(0);
}

Measured memory_bytes: 600
//quming
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
    R int res,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
    return res*f;
}
int read(char *s){
    R int len=0;R char ch;while(((ch=getc())>'9'||ch<'0'));
    for(s[++len]=ch;(ch=getc())>='0'&&ch<='9';s[++len]=ch);
    return s[len+1]='\0',len;
}
double readdb()
{
    R double x=0,y=0.1,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(x=ch-'0';(ch=getc())>='0'&&ch<='9';x=x*10+ch-'0');
    for(ch=='.'&&(ch=getc());ch>='0'&&ch<='9';x+=(ch-'0')*y,y*=0.1,ch=getc());
    return x*f;
}
char sr[1<<21],z[20];int C=-1,Z=0;
inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(R int x){
    if(C>1<<20)Ot();if(x<0)sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
const int P=998244353;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int inc(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=10005;
char s[N];int n,m;
int main(){
	scanf("%d%s",&m,s+1),n=strlen(s+1);
	fp(i,1,n)s[i]-='A',s[i]=(s[i]+m)%26;
	fp(i,1,n)putchar(s[i]+'A');
	putchar('\n');;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include <limits>
using namespace std;
 
#define int int64_t
#define pr(x) cout << x << endl;
#define vi vector<int>
#define vii vector< vector<int> >
#define mp make_pair
#define f(i,n) for(i =0 ; i< n ; i++)
#define ii pair<int, int>
#define ff first
#define ss second
#define pb push_back
#define INF 1e9
#define SIZE 200001
#define mod 1000000007
#define int_max 1e12
int dr[]={0,0,1,1,1,-1,-1,-1};
int dc[]={1,-1,0,1,-1,0,1,-1};
 
void solve();
 
int power(int a, int b)
{
    if(b==0) return 1;
    else if(b&1) return a*power(a*a,b/2);
    else return power(a*a, b/2);
}
 
int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}  
 
int i, j, k, l, n, m, x, y, t;
void solve()
{ 
    // cin >> t; while(t--)
    {
        cin >> n;
        vi v(n);
        f(i,n) cin >> v[i];
        k=0;j=0;
        f(i,n-1)
        {
            k=0;
            if(v[i]>=v[i+1])
            {
                while(v[i]>=v[i+1] and i<n-1)
                {
                    i++;k++;
                }

                j = max(k,j);
            }
        }

        cout << j;
    }
}

Measured memory_bytes: 1024
object Scanner {
  private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0
  @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
  @inline private def hasNextByte(): Boolean =
    if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }
  @inline private def hasNext(): Boolean = {
    while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
    hasNextByte()
  }
  @inline private def readByte(): Byte =
    if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }
  def next(): String = {
    if(!hasNext()) ???
    val sb = new StringBuilder; var b = readByte()
    while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
    sb.toString
  }
  def nextInt(): Int = {
    val n = nextLong()
    if (n < Int.MinValue || Int.MaxValue < n) ???
    n.toInt
  }
  def nextLong(): Long = {
    if(!hasNext()) ???
    var minus = false; var b = readByte()
    if (b == '-') { minus = true; b = readByte() }
    def go (b: Byte, n: Long = 0): Long =
      if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }
      else if (minus) { -n } else { n }
    go(b)
  }
  def nextDouble(): Double = next.toDouble
}

object Main extends App {
  val n = Scanner.nextInt()
  val h = Array.fill(n)(Scanner.nextInt())

  var counter = 0
  var max = 0
  (0 until n).foreach(i =>{
    if (h(i)>=max){
      max=h(i)
      counter = counter + 1
    }
  })

  println(counter)
}

Measured memory_bytes: 25404
import random
d=int(input())
c=list(map(int,input().split()))
num=[0]*26
ans=[]
numans=0
s=[]
for i in range(1,d+1):
    num1=1
    num2=-(10**100)
    num3=[0]*26
    for j in range(26):
        num3[j]=-1*((i-num[j])*c[j])
    s.append(list(map(int,input().split())))
    for j in range(26):
        num5=s[i-1][j]-num3[j]
        if num5>num2:
            num1=j+1
            num2=num5
    ans.append(num1)
    numans+=num2+s[i-1][num1-1]
    num[num1-1]=i
def sco(n1,n2,n3):
    n0=0
    n01=[0]*26
    old=ans[n1]
    ans[n1]=n2
    for k in range(n3):
        n0+=s[k][ans[k]-1]
        n01[ans[k]-1]=k+1
        for l in range(26):
            n0-=(k+1-n01[l])*c[l]
    return n0
for i in range(49000):
    num6=random.randint(1,26)
    num7=random.randint(2,364)
    num100=sco(num7-1,num6,d)
    if num100>numans:
        ans[num7-1]=num6
for i in range(d):
    print(ans[i])


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

typedef long long ll;

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  ll n, x, m;  cin >> n >> x >> m;
  if(m==1){
    cout << "0\n";
    return 0;
  }

  vector<ll> val(m);
  for (int i = 0; i < m; ++i){
    val[i] = x;
    x = 1LL*x*x%m;
  }
  if(n<=m){
    cout << accumulate(val.begin(), val.begin()+n, 0LL) << "\n";
    return 0;
  }

  vector<ll> rep;
  rep.push_back(val[m-1]);
  int i = m-2;
  while(i>=0 and val[i]!=val[m-1]){
    rep.push_back(val[i]);
    i--;
  }
  reverse(rep.begin(), rep.end());
  ll sz = rep.size();
  ll ans = accumulate(val.begin(), val.begin()+m, 0LL);
  n -= m;
  ll d = n/sz;
  ll sum = accumulate(rep.begin(), rep.end(), 0LL);
  ans += sum*d;
  n -= d*sz;
  for (int i = 0; i < n; ++i){
    ans += rep[i];
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 4624
#include <stdio.h>
#include <math.h>

struct Point{ double x, y;};

void koch(int n, Point a, Point b){
  if (n == 0) return;

  Point s, t, u;
  double th = M_PI * 60.0 / 180.0;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n - 1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n - 1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n - 1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n - 1, t, b);
}

int main(){
  Point a, b;
  int n;

  scanf("%d", &n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);

  return 0;
}



Measured memory_bytes: 2704
import java.util.*

fun main(args: Array<String>) {
	val n = readLine()!!.toInt()
	val arr = readLine()!!.split(" ").map{ it.toLong() }.toLongArray()
	val comparator = Comparator<Pair<Long, Int>>{ a, b -> if (a.first != b.first) { a.first.compareTo(b.first) } else { a.second.compareTo(b.second) } }
	val fstSet = arr.sliceArray(0..(n - 1)).mapIndexed({i, v -> Pair(v, i)}).toSortedSet(comparator)
	val sndSet = arr.sliceArray(n..(3 * n - 1)).mapIndexed({i, v -> Pair(v, i + n)}).toSortedSet(comparator)
	val sndUnused = sortedSetOf<Pair<Long, Int>>(comparator)
	for (i in 1..n) {
		val p = sndSet.last()
		sndSet.remove(p)
		sndUnused.add(p)
	}
	var score = fstSet.fold(0L, {acc, p -> acc + p!!.first}) - sndSet.fold(0L, {acc, p -> acc + p!!.first})
	var ans = score
	for (i in n..(2 * n - 1)) {
		val p = fstSet.first()
		fstSet.remove(p)
		fstSet.add(Pair(arr[i], i))
		score -= p.first
		score += arr[i]
		if (sndSet.remove(Pair(arr[i], i))) {
			val p = sndUnused.first()
			sndUnused.remove(p)
			sndSet.add(p)
			score += arr[i]
			score -= p.first
		} else {
			sndUnused.remove(Pair(arr[i], i))
		}
		ans = Math.max(score, ans)
	}
	println(ans)	

}


Measured memory_bytes: 129696
#include <iostream>
#include <fstream>
#include <bits/stdc++.h> 
#include <string>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef priority_queue<int> pqi;
typedef priority_queue<int, vi, greater<int>> mpqi;

#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define F0R(i,a) for(int i = 0; i < a; i++)
#define R0F(i,a) for(int i = a - 1; i >= 0; i--)
#define S0RT(a,n) sort(a, a + n)
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define trav(a,x) for(auto& a : x)

const int MOD = 1000000007;
const ll INF = 1000000000000000000;
const ld PI = 4*atan((ld)1);

/* NOTES TO SELF:
    Int overflow? Use all ll if in doubt.
    Edge cases? (n = 1, n = 0)
*/

int n;
string s;
map<string,int> m;
int maxAmm;
vector<string> v;
set<string> ans;

int main(){
    IOS;
    maxAmm = 0;
    cin >> n;
    while(n--){
        cin >> s;
        m[s]++;
        v.pb(s);
        maxAmm = max(maxAmm, m[s]);
    }
    trav(x,v){
        if(m[x] == maxAmm) ans.insert(x);
    }
    trav(x,ans){
        cout << x << endl;
    }
    return 0;
    // You should actually read the notes to self.
}

Measured memory_bytes: 34800
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,cost,rpta=0; cin >> n;
  vector<int> num(n);
  for(int i=0;i<n;i++){ 
    cin>>num[i];}
  for(int i=0; i<n; i++){
    cin>>cost;
    if(num[i]-cost>0)
      rpta+=num[i]-cost;}
  cout<<rpta;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, K: int):
    ret = []
    for i in range(1, min(A, B) + 1):
        if A % i == 0 and B % i == 0:
            ret.append(i)
    print(ret[-K])
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
S = str(input())
T = str(input())
k = 0
for i in range(len(S)):
  last = S[-1]
  S = S[:-1]
  S = last + S
  if S == T:
    print('Yes')
    break
  else:
    k = k + 1

if k == len(S):
  print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pb push_back
const int N = 2e5+5;
int ans[1223];
int vis[1223];
int q[123][2];
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    bool imp = false;
    for(int i=0;i<m;i++){
        cin>>q[i][0]>>q[i][1];
    }
	for(int i=0;i<10000;i++){
        vector<int>v;
        int x = i;
        while(x){
            v.pb(x%10);
            x/=10;
        }
      	if(i==0)v.pb(0);
        reverse(v.begin(),v.end());
        if(v.size()!=n)continue;
        int cnt = 0;
        for(int j=0;j<m;j++){
            if(v[q[j][0]-1]==q[j][1])cnt++;
        }
        if(cnt==m){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    tmp = input[0].split(" ");
    var S = parseInt(tmp[0]);
    var W = parseInt(tmp[1]);

    if (W >= S) {
        console.log('unsafe');
    } else {
        console.log('safe');
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29480
#include<iostream>

using namespace std;
int N;
int L;

int main(){
  cin >> N;
  cin >> L;
 
  int sum=0;
  int k=abs(L);
  int t=L;
  for(int i =0;i<N;i++){
    sum += L + i ;
    if(k>abs(L+i)) {
      k=abs(L+i);
      t = L+i;
    }
  }
  sum=sum-t;

  cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,M;
    cin >> N >> M;
    while(N){
        vector<pair<int,int> > V(N);
        rep(i,0,N){
            int a,b;
            cin >> a >> b;
            V[i] = P(b,a);
        }
        sort(V.rbegin(), V.rend());
        ll sum = 0;
        rep(i,0,N){
            if(V[i].second < M){
                int tmp = V[i].second;
                V[i].second = 0;
                M -= tmp;
            }else{
                V[i].second -= M;
                M = 0;
            }
            sum += V[i].first * V[i].second;
        }
        cout << sum << endl;
        cin >> N >> M;
    }
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
int n;
string s,t;
void dfs(int l,int r,char ch) {
    int m=(l+r+1)>>1;
    cout<<m<<endl;
    fflush(stdout);
    cin>>s;
    if (s[0]=='V') exit(0);
    if (((m-l+1)%2==0&&s[0]!=ch)
        ||((m-l+1)%2==1&&s[0]==ch))
        dfs(m,r,s[0]);
    else
        dfs(l,m-1,ch);

}
int main()
{
    cin>>n;
    cout<<0<<endl;
    fflush(stdout);
    cin>>s;
    if (s[0]=='V') return 0;
    cout<<n/2<<endl;
    fflush(stdout);
    cin>>t;
    if (t[0]=='V') return 0;
    if ((((n/2+1)%2==0&&s[0]!=t[0]))
        ||((n/2+1)%2==1&&s[0]==t[0]))
        dfs(n/2,n-1,t[0]);
    else
        dfs(0,n/2-1,s[0]);
    return 0;
}


Measured memory_bytes: 852
#include <cstdio>
using namespace std;

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

int main()
{
	int n,m,a,b,c,d,x,y,z,w,t[32][32];

	scanf("%d %d",&n,&m);
	REP(i,n)REP(j,n)
	{
		t[i][j]=(i==j?0:1<<20);
	}

	while(m--)
	{
		scanf("%d,%d,%d,%d",&a,&b,&c,&d);
		t[a][b]=c;
		t[b][a]=d;
	}
	scanf("%d,%d,%d,%d",&x,&y,&z,&w);

	REP(k,n)REP(i,n)REP(j,n)
	{
		if(t[i][j]>t[i][k]+t[k][j]) t[i][j]=t[i][k]+t[k][j];
	}

	printf("%d\n",z-w-t[x][y]-t[y][x]);
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] a = new int[n];
		long[] sum = new long[n];
		a[0] = sc.nextInt();
		sum[0] = a[0];
		for (int i = 1; i < n; i++) {
			a[i] = sc.nextInt();
			sum[i] = sum[i - 1] + a[i];
		}

		long minDiff = Long.MAX_VALUE;
		int sep1 = 0;
		int sep3 = 2;
		for (int sep2 = 1; sep2 <= n - 3; sep2++) {
			long minOfDiff = Long.MAX_VALUE;
			for (int j = sep1; j <= sep2 - 1; j++) {
				long diff = Math.abs((sum[sep2] - sum[j]) - sum[j]);
				if (diff < minOfDiff) {
					minOfDiff = diff;
					sep1 = j;
				} else {
					break;
				}
			}
			minOfDiff = Long.MAX_VALUE;
			for (int j = sep3; j <= n - 2; j++) {
				long diff = Math.abs((sum[n - 1] - sum[j]) - (sum[j] - sum[sep2]));
				if (diff < minOfDiff) {
					minOfDiff = diff;
					sep3 = j;
				} else {
					break;
				}
			}
			long b = sum[sep1];
			long c = sum[sep2] - sum[sep1];
			long d = sum[sep3] - sum[sep2];
			long e = sum[n - 1] - sum[sep3];
			long max = Math.max(Math.max(b, c), Math.max(d, e));
			long min = Math.min(Math.min(b, c), Math.min(d, e));
			minDiff = max - min < minDiff ? max - min : minDiff;
		}

		System.out.println(minDiff);
	}

}


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

int dp[1<<16][16][16];

int to[16][16];

const int inf = 1e9;

void chmin(int &a, int b){
  if( a > b ){ swap(a,b);} return ;
}

signed main(void){
  
  int V,E; cin >> V >> E;
  
  for(int i = 0; i < (1<<16); i++){
    for(int j = 0; j < 16; j++){ 
      for(int k = 0; k < 16; k++){
      dp[i][j][k] = inf;
      }
    }
  }
  for(int i = 0; i < V; i++){ dp[(1<<i)][i][i] = 0;}
  
  for(int i = 0; i < 16; i++){
    for(int j = 0; j < 16; j++){ 
      to[i][j] = inf;
    }
  }
  
  for(int i = 0; i < E; i++){
    int s,t,d; cin >> s >> t >> d;
    to[s][t] = d; 
  }
  
  for(int S = 0; S < (1<<V); S++){ 
    for(int pos = 0; pos < V; pos++){ 
      for(int start = 0; start < V; start++){
      
       if( !(S >> pos & 1) || dp[S][pos][start] == inf ){ continue;}
      
        for(int i = 0; i < V; i++){
         int next = i;
         int dist = to[pos][next];
        
         if( S >> next & 1 || to[pos][next] == inf ){ continue;} 
          //一度行ったことのある点/繋がっていない点にはいかない
        
         chmin(dp[S|(1<<next)][next][start], dp[S][pos][start]+dist);
          
        }
        
      }
    }
  }
  
  int ans = inf; 
  
  for(int pos = 0; pos < V; pos++){
    for(int start = 0; start < V; start++){ 
      
      if( to[pos][start] == inf ){ continue;}
      
      chmin(ans,dp[(1<<V)-1][pos][start]+to[pos][start]);
      //最後にスタートまで戻ってくる必要がある
      
    }
  }
      
  if( ans == inf ){ ans = -1;}
  
  cout << ans << endl;
  
  return 0;
}
  


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

int cnt[10][10];
long long ans;

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

	for ( int i = 1; i <= n; i++ ) {
		int x = i;

		while ( x >= 10 ) {
			x /= 10;
		}
		cnt[x][i % 10]++;
	}
	for ( int i = 1; i <= n; i++ ) {
		int x = i;

		while ( x >= 10 ) {
			x /= 10;
		}
		ans += cnt[ i % 10 ][x];
	}
	cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int A,B,H,M;
double h,m;
int main(){
    cin>>A>>B>>H>>M;
    h=(2*M_PI)*(H/12.0)+(M_PI/6)*(M/60.0);
    m=(2*M_PI)*(M/60.0);
    cout<<setprecision(20)<<sqrt(A*A+B*B-2*A*B*cos(min(abs(h-m),2*M_PI-abs(h-m))))<<endl;
    return 0;
}

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

#define SZ(x) (((int)x.size()))
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

using namespace std;

int x, y, z;

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


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

// UnionFind 構造体 for tree
type UnionFind struct {
	par []int
}

/*コンストラクタ*/
func newUnionFind(N int) *UnionFind {
	u := new(UnionFind)
	u.par = make([]int, N)
	for i := range u.par {
		u.par[i] = -1
	}
	return u
}
func (u UnionFind) root(x int) int {
	if u.par[x] < 0 {
		return x
	}
	u.par[x] = u.root(u.par[x])
	return u.par[x]
}
func (u UnionFind) unite(x int, y int) {
	xr := u.root(x)
	yr := u.root(y)
	if xr == yr {
		return
	}
	u.par[yr] += u.par[xr]
	u.par[xr] = yr
}
func (u UnionFind) same(x, y int) bool {
	if u.root(x) == u.root(y) {
		return true
	}
	return false
}
func (u UnionFind) size(x int) int {
	return -u.par[u.root(x)]
}

var mod int = 1000000007

type pair struct {
	fi int
	se int
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	//予備
	s1 := Scan()
	s2 := Scan()
	s3 := Scan()
	s1 = strings.ToUpper(s1)
	s2 = strings.ToUpper(s2)
	s3 = strings.ToUpper(s3)
	fmt.Println(s1[0:1] + s2[0:1] + s3[0:1])
}

Measured memory_bytes: 1776
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<deque>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,L,T;
int a[N],x[N],w[N];
int main()
{
    scanf("%d%d%d",&n,&L,&T);
    int rk=0;
    for(int i=0;i<n;i++){
        scanf("%d%d",&a[i],&w[i]);
        if(w[i]==1){
            x[i]=(a[i]+T)%L;
            rk+=(a[i]+T)/L;
        }
        else{
            x[i]=(a[i]-T)%L;
            rk+=(a[i]-T)/L;
            if(x[i]<0){
                x[i]+=L;
                rk--;
            }
        }
    }
    rk=(rk%n+n)%n;
    sort(x,x+n);
    for(int i=rk;i<n;i++)
        printf("%d\n",x[i]);
    for(int i=0;i<rk;i++)
        printf("%d\n",x[i]);
}


Measured memory_bytes: 2304
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 62;

vl bfs(int sv, int n, vvl& to) {
  vl dist(n, INF), prev(n, -1);
  dist[sv] = 0;
  queue<ll> que;
  que.push(sv);
  cerr << sv << endl;
  while (!que.empty()) {
    ll u = que.front();
    que.pop();
    for (auto& v : to[u]) {
      if (dist[v] != INF) continue;
      prev[v] = u;
      dist[v] = dist[u] + 1;
      que.push(v);
    }
  }
  pair<ll, ll> best(INF, -1);
  rep(u, n) {
    if (u == sv) continue;
    for (auto& v : to[u]) {
      if (v == sv) {
        best = min(best, (pll)make_pair(dist[u], u));
      }
    }
  }
  cerr << best.first << "," << best.second << endl;
  if (best.first == INF) return vl(n + 1);
  int v = best.second;
  vl res;
  while (v != -1) {
    res.push_back(v);
    v = prev[v];
  }
  for (auto& uu : res) {
    cerr << uu + 1 << " ";
  }
  cerr << endl;
  return res;
}

int main() {
  //
  ll n, m;
  cin >> n >> m;
  vvl to(n);

  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    to[a].emplace_back(b);
  }

  vl ans(n + 1);
  rep(s, n) {
    vl now = bfs(s, n, to);
    if (now.size() < ans.size()) ans = now;
  }
  if (ans.size() == n + 1) {
    cout << -1 << endl;
    return 0;
  }
  cout << ans.size() << endl;
  for (auto& v : ans) {
    cout << v + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
    int a, b, c;
    cin >> a;
    b = a / 3600;
    a = a - b * 3600;
    c = a / 60;
    cout << b << ":" << c << ":" << a % 60 << endl;
}


Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main(void)
{
    int n;
    cin >> n;
    map<string, int> m;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        m[s]++;
    }
    cout << m.size() << endl;

    return 0;
}

Measured memory_bytes: 19224
#include <stdio.h>
int main(void){
    int i, j, a, N, A[200100]={};

    scanf("%d" ,&N);
    for(i=1 ; i<N ;i++){
        scanf("%d" ,&a);
        A[a]++;
    }

    for(i=1 ; i<=N ; i++){
        printf("%d\n" , A[i]);
    }
    return 0;
}


Measured memory_bytes: 2468
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

int main() {
	string s; cin >> s;
	bool a = false, b = false;
	for (int i = 0; i < (int)s.length(); ++i) {
		a |= s[i] == 'C';
		b |= a && s[i] == 'F';
	}
	cout << (a && b ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

ll c[10000][10000];
bool v[10000];
int cnt = 0;
int N, M;

void dfs(int id) {
	bool valid = true;
	rep(i, 0, N) {
		valid &= v[i];
	}

	if (valid) {
		cnt++;
		return;
	}

	rep(i, 0, N) {
		if (id != i && c[id][i] != 0 && !v[i]) {
			v[i] = true;
			dfs(i);
			v[i] = false;
		}
	}
}

int main() {
	cin >> N >> M;
	rep(i, 0, M) {
		int a, b; cin >> a >> b;
		c[a - 1][b - 1] = 1;
		c[b - 1][a - 1] = 1;
	}
	v[0] = true;
	dfs(0);

	cout << cnt << endl;
	return 0;
}

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

#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define scd(x) scanf("%lf",&x)

#define pfi(x) printf("%d",x)
#define pfl(x) printf("%lld",x)
#define pfd(x) printf("%lf",x)
#define pfc(x) printf("Case %d: ",x)
#define ps printf(" ")
#define pn printf("\n")
#define pb(x) push_back(x)
#define ppb(x) pop_back(x)
#define pf(x) push_front(x)
#define ppf(x) pop_front(x)
#define in(x,y) insert({x,y})
#define sv(a) sort(a.begin(),a.end())
#define zero(arr,a) memset(arr,a,sizeof arr)
#define mk
#define mx

int fx[]={0,1,1,1,0,-1,-1,-1};
int fy[]={1,1,0,-1,-1,-1,0,1};

int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);
    //freopen("1015.txt","w",stdout);
    int n;
    sci(n);

    vector<int>data,data2;

    unordered_map<int,bool>mp;
    for(int i=0;i<n;i++){
        int a;
        sci(a);
        data.pb(a);
        data2.pb(a);
    }

    sv(data);

    int last1=data[data.size()-1];
    int last2=data[data.size()-2];

    for(int i=0;i<n;i++){
        int tmp=data2[i];

        if(tmp==last1) pfi(last2);
        else pfi(last1);

        pn;
    }

    return 0;
}



Measured memory_bytes: 3436
#!/usr/bin/env python3
#ABC73 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def warshall_floyd(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

n,m,R = LI()
r = LI()
d = [[inf]*n for _ in range(n)]
for _ in range(m):
    a,b,c = LI()
    d[a-1][b-1] = c
    d[b-1][a-1] = c

d = warshall_floyd(d)
ans = inf
for i in permutations(r,R):
    tmp = 0
    for j in range(R-1):
        tmp += d[i[j]-1][i[j+1]-1]
    ans = min(ans,tmp)
print(ans)


Measured memory_bytes: 56156
use std::collections::BTreeMap;

fn main() {
    use std::io::{stdin, stdout, BufWriter, Write};
    let s = stdin();
    let mut sc = Scanner(s.lock());
    let out = stdout();
    let mut out = BufWriter::new(out.lock());

    let n: usize = sc.read();
    let k: usize = sc.read();
    let l: usize = sc.read();
    let mut uf1 = UnionFind::new(n);
    let mut uf2 = UnionFind::new(n);

    for _ in 0..k {
        let p = sc.read::<usize>() - 1;
        let q = sc.read::<usize>() - 1;
        uf1.unite(p, q);
    }
    for _ in 0..l {
        let p = sc.read::<usize>() - 1;
        let q = sc.read::<usize>() - 1;
        uf2.unite(p, q);
    }

    let mut count = BTreeMap::new();
    for i in 0..n {
        let r1 = uf1.find(i);
        let r2 = uf2.find(i);
        *count.entry((r1, r2)).or_insert(0) += 1;
    }
    for i in 0..n {
        if i > 0 {
            write!(out, " ").unwrap();
        }
        let r1 = uf1.find(i);
        let r2 = uf2.find(i);
        let count = *count.get(&(r1, r2)).unwrap();
        write!(out, "{}", count).unwrap();
    }
    write!(out, "\n").unwrap();
}

pub struct UnionFind {
    parent: Vec<usize>,
    sizes: Vec<usize>,
    size: usize,
}

impl UnionFind {
    pub fn new(n: usize) -> UnionFind {
        UnionFind {
            parent: (0..n).map(|i| i).collect::<Vec<usize>>(),
            sizes: vec![1; n],
            size: n,
        }
    }

    pub fn find(&mut self, x: usize) -> usize {
        if x == self.parent[x] {
            x
        } else {
            let px = self.parent[x];
            self.parent[x] = self.find(px);
            self.parent[x]
        }
    }

    pub fn unite(&mut self, x: usize, y: usize) -> bool {
        let parent_x = self.find(x);
        let parent_y = self.find(y);
        if parent_x == parent_y {
            return false;
        }

        let (large, small) = if self.sizes[parent_x] < self.sizes[parent_y] {
            (parent_y, parent_x)
        } else {
            (parent_x, parent_y)
        };

        self.parent[small] = large;
        self.sizes[large] += self.sizes[small];
        self.sizes[small] = 0;
        self.size -= 1;
        return true;
    }
}
pub struct Scanner<R>(R);

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

    ll n, m;
    cin >> n >> m;
    std::vector<ll> ans;
    std::vector<bool> used(n + 1);
    for (int i = 1; i <= n; i++)
        used[i] = false;
    for (int i = 0; i < m; i++)
    {
        int e;
        cin >> e;
        ans.push_back(e);
    }
    for (int i = (int)ans.size() - 1; i >= 0; i--)
    {
        if (!used[ans[i]])
        {
            cout << ans[i] << endl;
            used[ans[i]] = true;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        if (!used[i])
            cout << i << endl;
    }
    return 0;
}


Measured memory_bytes: 3980
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define all(v) v.begin(),v.end()
using namespace std;

int main(){
	int n,tmp,alice,bob;
	alice=bob=0;
	cin>>n;
	vector<int> a;
	rep(i,n){
		cin>>tmp;
		a.push_back(tmp);
	}
	sort(all(a));
	reverse(all(a));
	rep(i,n){
		if(i%2)bob+=a[i];
		else alice+=a[i];
	}
	cout<<alice-bob<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define INF (1LL<<59)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	ll n;
	cin>>n;
	ll sx = ((n * (n+1))/2) - (3*(((n/3) * (1 + n/3))/2)) - (5*(((n/5) * (1 + n/5))/2)) + (15*(((n/15) * (1 + n/15))/2));
	cout<<sx<<"\n";
	return;
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

// #ifndef ONLINE_JUDGE
// 	time_t time_t1, time_t2;
// 	time_t1 = clock();
// #endif

	//cin>>T;
	while(T--)
	solve(T);

// #ifndef ONLINE_JUDGE
// 	time_t2 = clock();
// 	SETF();
// 	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
// 	UNSETF();
// #endif

	return 0;
}

Measured memory_bytes: 3640
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int N;
    cin >> N;
    vl a(N);
    vl b(N);
    rep(i, 0, N) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b.begin(), b.end());
    int count = 0;
    for (int i = N; N >= 0; --i) {
        if (a[i] == a[i-1]) {
            ++count;
        } else {
            break;
        }
    }
    int mxf = b.back();
    int mxs = b[N-2];
    rep(i, 0, N) {
        if (a[i] == mxf) {
            if (count > 0) {
                cout << mxf << endl;
            } else {
                cout << mxs << endl;
            }
        } else {
                cout << mxf << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4736
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<cmath>
#include<cctype>
#include<stack>
#include<map>
#include<string>
#include<sstream>
#include<set>
#include<list>
#define ll long long
#define ull unsigned long long
#define op std::ios::sync_with_stdio(false); std::cin.tie(0);
const int INF = 0x3f3f3f3f;
const int maxn = (100000 + 10);
const int mod = (1e9+7);
struct node
{
    int a,order;
}student[maxn];
bool cmp(node x,node y)
{
    return x.a<y.a;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&student[i].a);
        student[i].order=i;
    }
    std::sort(student+1,student+1+n,cmp);
    for(int i=1;i<n;i++)
        printf("%d ",student[i].order);
    printf("%d\n",student[n].order);
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200010;
ll a[N],k;
int n;
map<ll,ll> mp;
int main()
{
    cin >> n >> k;
    for(int i=1;i<=n;i++)
    {
        cin >> a[i];
        a[i]+=a[i-1];
    }
    ll ans=0;
    for(int i=0;i<=n;i++)
    {
        if(i>=k) mp[(a[i-k]-i+k)%k]--;
        ans+=mp[(a[i]-i)%k]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14336