akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

bool stamped[4][4];
int A[4][4];

int main()
{
    
    map<int, int> Index;
    for(int i = 1; i <= 3; ++i) {
        for(int j = 1; j <= 3; ++j) {
            scanf("%d", &A[i][j]);
            Index[A[i][j]] = i*3 + j;
        }
    }
    int N;
    scanf("%d", &N);
    for(int i = 0; i < N; ++i) {
        int b;
        cin >> b;
        if(Index[b] != 0) {
            int ni = (Index[b]-1)/3;
            int nj = Index[b] - ni*3;
            stamped[ni][nj] = true;
        }
    }
    /*
    for(int i = 1; i <= 3; ++i) {
        for(int j = 1; j <= 3; ++j) {
            printf("%d", stamped[i][j] ? 1 : 0);
        }
        printf("\n");
    }
    */
    for(int i = 1; i <= 3; ++i) {
        bool flg = true;
        for(int j = 1; j <= 3; ++j) {
            if(!stamped[i][j]) flg = false;
        }
        if(flg) { printf("Yes\n"); return 0;}
    }
    for(int j = 1; j <= 3; ++j) {
        bool flg = true;
        for(int i = 1; i <= 3; ++i) {
            if(!stamped[i][j]) flg = false;
        }
        if(flg) { printf("Yes\n"); return 0;}
    }
    if(stamped[2][2]) {
        if(stamped[1][1] && stamped[3][3]) { printf("Yes\n"); return 0;}
        if(stamped[1][3] && stamped[3][1]) { printf("Yes\n"); return 0;}
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 256
// Indrajeet Mishra
 
/*#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")*/
 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define test(s) if (!(s)) { cout << __LINE__ << " " << #s << endl; exit(-1); }
#define debug(x) do { std::cerr << x; } while (0)
#define endl "\n"
#define pb push_back
#define pf push_front
#define vll vector<ll>
#define dll deque<ll>
#define sll set<ll, greater <ll>>
#define mll map<ll, ll>
#define vii vector<int>
#define dii deque<int>
#define sii set <int, greater <int>>
#define mii map<int, int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define inv2 500000004
#define inv6 166666668
#define N 1000005
#define inf 200000000
#define eps 1e-10
#define PI 3.14159265359
#define all(v) (v).begin(),(v).end()
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define gcd(a,b) __gcd(a,b)
 
ll dp[101][101];
void dp_initialiser(){
    memset(dp,-1,sizeof(dp));
}

int main() {
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //dp_initialiser();
    ll x=0;cin>>x;
    if(x<600)cout<<"8";
    if(x>=600 && x<800)cout<<"7";
    if(x>=800 && x<1000)cout<<"6";
    if(x>=1000 && x<1200)cout<<"5";
    if(x>=1200 && x<1400)cout<<"4";
    if(x>=1400 && x<1600)cout<<"3";
    if(x>=1600 && x<1800)cout<<"2";
    if(x>=1800 && x<2000)cout<<"1";
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;

int main()
{
    int h,n;
    cin >> h>> n;
    int sum = 0;
    for(int i = 0; i < n; i++){
        int k;
        cin >> k;
        sum += k;
    }
    if(h <= sum){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

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

int main(){
  int H,W;
  cin >> H >> W;
  char a[H][W];
  int line[H]={},column[W]={};
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> a[i][j];
    }
  }
  for(int i=0;i<H;i++){
    bool flag = 0;
    for(int j=0;j<W;j++){
      if(a[i][j]=='#'){
        flag = 1;
        break;
      }
    }
    if(!flag)
      line[i]++;
  }
  for(int i=0;i<W;i++){
    bool flag = 0;
    for(int j=0;j<H;j++){
      if(a[j][i]=='#'){
        flag = 1;
        break;
      }
    }
    if(!flag)
      column[i]++;
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(line[i]!=1&&column[j]!=1)
       cout <<  a[i][j];
    }
    if(line[i]!=1)
    	cout << endl;
  }
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

const long long INF = 1e9;
using namespace std;
struct Edge{
  int to;
  int from;
  long long cost;
};
int main(){
  //input
  int N,M;
  cin >> N >> M;

  //def graph and edge
  vector<vector<long long>> graph(N,vector<long long>(N,INF));
  vector<Edge> edge(M);

  //input
  rep(i,M){
    cin >> edge[i].to >> edge[i].from >> edge[i].cost;
    edge[i].to --;  edge[i].from --;                  //0index
    graph[edge[i].to][edge[i].from] = edge[i].cost;   //double sides
    graph[edge[i].from][edge[i].to] = edge[i].cost;   //double sides
  }

  //Warshall–Floyd
  vector< vector<long long> > dist(graph);
  rep(i,N) dist[i][i] = 0;

  rep(k,N){
    rep(i,N){
      rep(j,N){
        dist[i][j] = min(dist[i][j] , dist[i][k] + dist[k][j]);
      }
    }
  }

  // check Edge
  int ans = 0;

  rep(i,M){
    bool shortestFlag = false;
    rep(j,N){
      FOR(k,j+1,N){
        if(j == k) continue;
        if(dist[j][k] ==  dist[j][edge[i].from] +
                          edge[i].cost          +
                          dist[edge[i].to][k]      // j -> from -> to -> k
                          ||                       // or
          dist[j][k] ==   dist[j][edge[i].to]   +  // j -> to -> from -> k
                          edge[i].cost          +
                          dist[edge[i].from][k]
        ){
          shortestFlag = true;
        }
      }
    }
    if(shortestFlag == false) ans ++;
  }

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


Measured memory_bytes: 384
#include<cstdio>

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


Measured memory_bytes: 2744
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
ll mod=1000000007;
//ll mod=67280421310721;
//ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		int h1,m1,h2,m2,k,t1,t2,a;
		cin>>h1>>m1>>h2>>m2>>k;
		t2=60*h2+m2;
		t1=60*h1+m1;
		if(t2<t1)
		{
			t2+=(24*60);
		}
		a=t2-t1-k;
		cout<<max(0,a);
	}
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cassert>
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
long long ans,under,t;
long long n;
long long a;
int main() {
  ans = 0;
  under = 0;
  cin >> n;
  rep(i,n){
    cin >> a;
    if(under == 0){
      ans += a-1;
      under = 1;
    }else if(a > under+1){
      t = a%(under+1);
      if(t!=0){
        ans += a/(under+1);
      }else{
        ans += a/(under+1)-1;
      }
    }else if(a==under+1) under++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
int n,n_,t;
int d[100001];
ll val[2<<18];

void update(int k){
	k+=n_-1;
	val[k]++;
	while(k>0){
		k=(k-1)/2;
		val[k]=val[k*2+1]+val[k*2+2];
	}
}

ll query(int a,int b,int k=0,int l=0,int r=n_){
	if(a<=l && r<=b)return val[k];
	if(r<=a || b<=l)return 0;
	ll vl=query(a,b,k*2+1,l,(l+r)/2);
	ll vr=query(a,b,k*2+2,(l+r)/2,r);
	return vl+vr;
}

int main(void){
	scanf("%d %d",&n,&t);
	n_=2<<17;
	for(int i=0;i<n;i++){
		scanf("%d",&d[i]);
	}
	sort(d,d+n);
	ll res=1;
	for(int i=0;i<n;i++){
		update(d[i]);
		res=res*query(max(0,d[i]-t),d[i]+1)%MOD;
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 4280
#include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;

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

	ll r=0, g=0, b=0;
	for (int i=0; i<N; i++) {
		if (S[i]=='R')
			r++;
		if (S[i]=='G')
			g++;
		if (S[i]=='B')
			b++;
	}
	ll ans = r * g * b;
	for (int i=1; i<=N; i++) {
		for (int k=i+2; k<=N; k+=2) {
			int j = (i+k)/2;
			if (S[i-1]+S[j-1]+S[k-1]=='R'+'G'+'B') {
				ans --;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;





int main(){
    int64_t N, A, B;
    cin >> N >> A >> B;
    int64_t res, sum = A+B;
    res = A*(N/sum);
    int64_t tem = N%sum;
    if(A > tem) res += tem;
    else res += A;
    cout << res << endl;
    return 0;
}

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

namespace Unpi {
    class Program {
        static void Main(string[] args) {
            int W, n;
            var wn = Console.ReadLine().Split(' ').Select(ngo => int.Parse(ngo)).ToArray();
            n = wn[0];
            W = wn[1];
            var wUnpis = new int[n+1];
            var cUnpis = new int[n+1];
            for(int i = 1; i <= n; ++i) {
                wn = Console.ReadLine().Split(' ').Select(ngoo => int.Parse(ngoo)).ToArray();
                //Console.WriteLine(wn.Length + " " + cUnpis.Length);
                cUnpis[i] = wn[0];
                wUnpis[i] = wn[1];
            }
            int[,] dp = new int[W + 1, n + 1];
            for(int j = 1; j <=n; ++j) {
                for(int i = 1; i <= W; ++i) {
                    int cand1 = 0, cand2 = 0;
                    //左上からのやつ
                    if(i-wUnpis[j] >= 0) {
                        cand1 = dp[i - wUnpis[j], j - 1] + cUnpis[j];
                    }
                    cand2 = dp[i, j - 1];
                    dp[i, j] = Math.Max(cand1, cand2);
                }
            }
            Console.WriteLine(dp[W, n]);
        }
    }
}



Measured memory_bytes: 13560
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int a, b;
    cin>>a>>b;
    if( a > b ) swap(a, b);
    if( (b - a)%2 !=0 ) 
    {
        cout<<"IMPOSSIBLE\n";
        return 0;
    }
    int dif = (b-a)/2;
    cout<<a+dif<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}


Measured memory_bytes: 256
import sys
N=int(input())

for h in range(1,3501):
  for n in range(1,3501):
    w_bunshi=N*h*n
    w_bumbo=4*h*n-N*n-N*h
    if w_bumbo==0:
      continue
    
    if w_bunshi%w_bumbo==0:
      w=w_bunshi//w_bumbo
      if 1<=w<=3500:
        print(h,n,w)
        sys.exit(0)

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

int main() {
  int N, K;
  cin >> N >> K;
  double ans = 0;

  if (K == 1) {
    cout << (double)1 << endl;
    return 0;
  }

  if (N >= K) {
    ans += (N - K + 1);
  }

  int tmp = K;
  int tmp2 = 1;
  int a[K + 1];
  while (tmp > 1) {
    int start;
    int end = tmp - 1;
    if (tmp % 2 == 0) start = tmp / 2;
    else start = tmp / 2 + 1;
    for (int i = start; i <= end; i++) {
      a[i] = tmp2;
    }
    tmp = start;
    tmp2++;
  }

  for (int i = 1; i <= min(N, K - 1); i++) {
    ans += pow(0.5, a[i]);
  }

  ans = ans / N;

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

};


Measured memory_bytes: 640
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

A, B, H, M = map(int, input().split())

deg = (H + M / 60) * 30 - M / 60 * 360

l = math.sqrt(A * A + B * B - 2 * A * B * math.cos(math.radians(deg)))

print (l)


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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll a,b;
	string s,t,u;
	cin>>s>>t>>a>>b>>u;
	(s==u)?a--:b--;
	cout<<a<<" "<<b<<'\n';
	return 0;
}


// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""
 


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		for (int i = 1; i > 0; i++){
		int x = scan.nextInt(); //????????§???????????\???
		int y = scan.nextInt(); //????????§???????????\???
		if(x == 0 && y == 0){
			break;
		}
		if(x > y){
			System.out.println(y + " " + x);
		} else{
			System.out.println(x + " " + y);
		}
		}
	}
}

Measured memory_bytes: 36256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int[] x;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.x = new int[5];
    }
    
    //解答処理
    private int solve() {
        int answer = 0;
        for (int i=0; i<5; i++) {
        	x[i] = sc.nextInt();
        	if (x[i] == 0) {
        		answer = i+1;
        	}
        }
        
        return answer;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 35752
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    char str[3][15]={0};
    long i;
    for(i=0; i<3; i++) {
        scanf("%s", str[i]);
    }
    char str2[5]={0};
    sprintf(str2, "%c%c%c", str[0][0]-'a'+'A', str[1][0]-'a'+'A', str[2][0]-'a'+'A');

    printf("%s\n", str2);

    return 0;
}



Measured memory_bytes: 128
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;

//dp[i] = dp[i-1]*n + (2*n-2*d)*n^(i-2)
//dp[i] = (i-1)*(n-d)*n^(i-2)

int main() {
	mp::cpp_dec_float_50 n, m, d;
	cin >> n >> m >> d;
	mp::cpp_dec_float_50 ans = 0;
	
	if (d != 0) ans = 2 * (m - 1) * (n - d) / n / n;
	else ans = (m - 1) * (n - d) / n / n;

	cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a[100000];
    int n,h,i;
    scanf("%d",&n);

    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);

    for(i=1;i<n;i++)
    {
        if(a[i]<a[i+1])
            a[i+1]--;
        if(a[i]>a[i+1])
            break;
    }

    if(i==n)
        printf("Yes\n");
    else
        printf("No\n");


return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll  N,A[200007],C[200007];

int main(){
  cin >> N;
  rep(i,N){
    cin >> A[i];
    C[A[i]]++;
  }
  ll ANS=0;
  rep(i,200001){
    ANS+=C[i]*(C[i]-1)/2;
  }
  rep(i,N){
   cout <<  ANS-C[A[i]]*(C[A[i]]-1)/2+ (C[A[i]]-2)*(C[A[i]]-1)/2<< endl;
  }
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
using namespace std;
void solve()
{
	//Enter your code here Tanmay:)
	int n;
	cin>>n;
	string arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	map<string ,int>mp;
	for(int i=0;i<n;i++)
	{
		mp[arr[i]]++;
	}
	int max=INT_MIN;
	for(auto x:mp)
	{
		if(x.second>max)
			max=x.second;
	}
	for(auto x:mp)
	{
		if(x.second==max)
			cout<<x.first<<endl;
	}
}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}
/*
int eulortotent(int n)
     {
    //Enter your code here Tanmay:)
    int total=n;
        for(int p=2;p*p<=n;p++)
        {
            if (n%p==0)
        {
            total /= p;
            total *= (p-1);
            while ( n % p == 0 ) 
                n /= p;
        }
    }

    if(n>1)
    {
        total/=n;
        total*=(n-1);
    }

  return total;
}
*/

Measured memory_bytes: 25472
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll N;
    scanf("%lld", &N);
    ll ans=1;
    rep(_, 0, 3) ans *= N;
    printf("%lld\n", ans);
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
n = gets.to_i
yen=0.0;
n.times do
  tmp = gets.split(/\s/)
  #puts tmp[1]
  if tmp[1]=="JPY"
    yen+=tmp[0].to_i
  else
    yen+=(tmp[0].to_f*380000.0)
  end
end
puts yen

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;
const int MOD = 1000000007;

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

    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    Rep (i, N) {
        cin >> A[i];
    }

    ll ans = 0;
    Rep (i, N) {
        ll sub = 0;
        ll sub2 = 0;
        Rep (j, N) {
            if (A[j] < A[i]) {
                if (j > i) {
                    sub2++;
                } else {
                    sub++;
                }
            }
        }
        // cout << sub << " " << sub2 << endl;
        ans += K * (K+1) / 2 % MOD  * sub2 % MOD;
        ans += K * (K-1) / 2 % MOD * sub % MOD;
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int ab = Math.Abs(line[1] - line[0]);
            int bc = Math.Abs(line[2] - line[1]);
            int ac = Math.Abs(line[2] - line[0]);
            int d = line[3];
            if (ac <= d)
            {
                Console.WriteLine("Yes");
            }
            else if(ab <= d && bc <= d)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 11220
s=input()
 
n=int(input())
 
ans = []
 
for i in range(len(s)):
    for j in range(1,7):
        if s[i:i+j] not in ans and j <= len(s):
            ans.append(s[i:i+j])
ans.sort()
#print(ans)
print(ans[n-1])

Measured memory_bytes: 39792
main(){
	float D,px,py,vx,vy,a,l;
	for(;scanf("%f",&D),D;){
		scanf("%f%f%f%f",&px,&py,&vx,&vy);
		a=hypot(px,py);
		l=px*vx+py*vy<0?a:2-a;
		printf(fabs(px*vy-py*vx)||D<l?"impossible\n":"%f\n",l);
	}
	exit(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;
const long long mod=1e9+7;
const long long INF=1LL<<60;

long long d[110][110];

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(m),b(m),c(m);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            d[i][j]=INF;
            if(i==j)d[i][j]=0;
        }
    }
    map<pair<int,int>,int> mp;
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--;b[i]--;
        mp[make_pair(a[i],b[i])]=c[i];
        d[a[i]][b[i]]=c[i];
        d[b[i]][a[i]]=c[i];
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
        }
    }
    int cnt=0;
    for(int i=0;i<m;i++){
        if(d[a[i]][b[i]]!=mp[make_pair(a[i],b[i])])cnt++;
    }
    cout<<cnt<<endl;
}
 
   

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    lint ans;
    if (n % 2 != 0) {
        int m = a[n / 2], M = b[n / 2];
        ans = M - m + 1;
    } else {
        int m = (a[n / 2] + a[n / 2 - 1]);
        int M = (b[n / 2] + b[n / 2 - 1]);
        ans = M - m + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4844
N,K = list(map(int,input().split(' ')))
pi = list(map(int,input().split(' ')))
value = sum(pi[:K])
max_value = value
for i in range(N-K):
  value -= pi[i]
  value += pi[i+K]
  max_value = max(value, max_value)
print((max_value+K)/2)

Measured memory_bytes: 24812
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int count = 0;
        for(int i=0; i<3; i++) {
            if(s.charAt(i) == t.charAt(i)) count++;
        }
        System.out.println(count);
    }
}


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

using namespace std;

int main(void){
	int n,i,j;
	vector<int> v;
	int ans=0;
	
	cin>>n;
	
	for(i=0;i<n;i++){
		cin>>j;
		v.push_back(j);
	}
	j=0;
	for(i=0;i<n;i++){
		if(j<=v[i]){
			ans++;
			j=v[i];
		}
		
	}
	cout<<ans<<endl;
	
	
	
	return 0;
	
	
}

Measured memory_bytes: 256
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
    int n,l,x[110],w;
    char s[110][110];
    scanf("%d %d",&n,&l);
    for(int i=0;i<n;i++){
        scanf("%s",s[i]);
        x[i]=i;
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n-i-1;j++){
            if(strcmp(s[x[j]],s[x[j+1]])>0){
            w=x[j];
            x[j]=x[j+1];
            x[j+1]=w;}
        }
    }
    for(int i=0;i<n;i++){
        printf("%s",s[x[i]]);
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int N = scanner.nextInt();
		    int A = scanner.nextInt();
		    
		    System.out.println(N * N - A);
		    
		    scanner.close(); }
		  }

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

int a[15][15], c[15], v[15];

int main(){
    int n, m, x;
    scanf("%d %d %d", &n, &m, &x);
    for (int i = 1; i <= n; ++i){
        scanf("%d", c+i);
        for (int j = 1; j <= m; ++j) scanf("%d", &a[i][j]);
    }
    int lmt = 1 << n, ans = INT_MAX;
    for (int i = 0; i < lmt; ++i){
        memset(v, 0, sizeof(v));
        int cost = 0;
        for (int j = 0; j < n; ++j){
            if (i >> j & 1){
                cost += c[j+1];
                for (int k = 1; k <= m; ++k){
                    v[k] += a[j+1][k];
                }
            }
        }
        bool f = true;
        for (int k = 1; k <= m; ++k){
            if (v[k] < x){ f = false; break; }
        }
        if (f){ ans = min(ans, cost); }
    }
    if (ans == INT_MAX) printf("-1\n");
    else printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
int fun(int arr[],int n)
{
    int dp[n+1];
    memset(dp,0,sizeof(dp));
    dp[1]=0;
    dp[2]=abs(arr[2]-arr[1]);
    for(int i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    return dp[n];
}
int main()
{
    int n; cin>>n;
    int arr[n];
    for(int i=1;i<=n;i++) cin>>arr[i];
    cout<<fun(arr,n)<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  string a,b;
  cin >> a >> b;

  int asize = (int)a.size();
  int bsize = (int)b.size();
  if(asize>bsize){
    cout << "GREATER" << endl;
  }
  else if(bsize>asize){
    cout << "LESS" << endl;
  }
  else {
    if(a>b){
      cout << "GREATER" << endl;
    }
    else if(b>a){
      cout << "LESS" << endl;
    }
    else cout << "EQUAL" << endl;
  }
  return 0;


}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<string>
#include<iterator>
#include<cmath>
using namespace std;

int main()
{
   int L, D, R, i, count=0;
   cin>>L>>R>>D;
   for(i=L;i<=R;i+=1)
   {
       if(i%D==0)
       {
           count+=1;
       }
   }
   cout<<count<<endl;
}


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

typedef long long ll;
// const int INF = 1e8;
const ll INF = 1LL << 60;
typedef pair<int, int> P;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll N;
vector<vector<ll>> G;
mint dp[100100][2];

void dfs(int v, int par = -1) {
    dp[v][0] = dp[v][1] = 1;
    for (int i = 0; i < G[v].size(); i++) {
        ll next = G[v][i];
        if (next != par) {
            dfs(next, v);
            dp[v][0] *= dp[next][0] + dp[next][1];
            dp[v][1] *= dp[next][0];
        }
    }
}

int main() {
    cin >> N;
    G.resize(N);
    rep(i, N - 1) {
        ll x, y;
        cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    dfs(0);

    cout << dp[0][0] + dp[0][1] << endl;
}

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

struct union_find {
    vector<int> par;
    vector<int> rank;
    union_find(int n) {
        par.resize(n);
        rank.resize(n);
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }

    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) {
            return ;
        } else if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
    }
    bool same(int x, int y) {
        x = find(x);
        y = find(y);
        return x == y;
    }
};

int main() {
    int n, k, l;
    cin >> n >> k >> l;
    union_find uf1(n), uf2(n);
    for (int i = 0; i < k; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        uf1.unite(u, v);
    }
    for (int i = 0;  i < l; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        uf2.unite(u, v);
    }

    map<pii, int> mp;
    for (int i = 0; i < n; i++) {
        int x = uf1.find(i);
        int y = uf2.find(i);
        mp[pii(x, y)]++;
    }
    for (int i = 0; i < n; i++) {
        int x = uf1.find(i);
        int y = uf2.find(i);
        cout << mp[pii(x, y)] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 15104
N, K = map(int, input().split())
MOD = 10 **9 + 7
C = [[0] * (N + 1) for i in range(N + 1)]
C[1][1] = 1
for i in range(2, N + 1):
    for j in range(1, i + 1):
        if j == 1:
            C[i][j] = C[i - 1][j] + 1
        elif j == i:
            C[i][j] = 1
        else:
            C[i][j] = C[i - 1][j - 1] + C[i - 1][j]
print(N - K + 1)
for i in range(2, K + 1):
    ans = (C[N - K + 1][i] * C[K - 1][i - 1]) % MOD
    print(ans)

Measured memory_bytes: 356672
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<ll> u(n), v(n), w(n), l(n);
  vector<vector<pair<int, ll>>> r(n, vector<pair<int, ll>>());
  for(int i = 0; i < n - 1; i++) {
    cin >> u.at(i) >> v.at(i) >> w.at(i);
    r.at(--u.at(i)).push_back({--v.at(i), w.at(i)});
    r.at(v.at(i)).push_back({u.at(i), w.at(i)});
  }
  queue<pair<pair<int, ll>, int>> que;
  for(int i = 0; i < r.at(0).size(); i++)
    que.push({r.at(0).at(i), 0});
  pair<pair<int, ll>, int> p;
  while(que.size()) {
    p = que.front();
    que.pop();
    l.at(p.first.first) = l.at(p.second) + p.first.second;
    for(int i = 0; i < r.at(p.first.first).size(); i++)
      if(r.at(p.first.first).at(i).first != p.second)
        que.push({r.at(p.first.first).at(i), p.first.first});
  }
  for(int i = 0; i < n; i++) {
    if(i) {
      if(l.at(i) % 2)
        printf("1\n");
      else
        printf("0\n");
    } else
      printf("0\n");
  }
}

Measured memory_bytes: 11008
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <random>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int a,b,c,d,e; cin >> a >> b >> c >> d >> e;
	cout << a-max((b+d-1)/d,(c+e-1)/e) << endl;
}


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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

#define loop(i, n) for(int i = 0;i < n;i++)
#define INF 1000000000

int n, m, x;

int ans = INF;


void dfs(int i, vector<int> c, vector<vector<int>> a, int total, vector<int> check){
    bool ok = true;
    loop(j, m){
        if(check[j] < x) ok = false;
    }
    if(ok) ans = min(ans, total);

    if(i == n) return;

    dfs(i+1, c, a, total, check);

    loop(j, m){
        check[j] += a[i][j];
    }
    total += c[i];
    dfs(i+1, c, a, total, check);

    
}

int main(void){

    cin >> n >> m >> x;

    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> check(m);
    loop(i, n){
        cin >> c[i];
        loop(j, m){
            cin >> a[i][j];
        }
    }

    dfs(0, c, a, 0, check);

    if(ans == INF){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3640
#pragma GCC target("avx2")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
}
int main()
{
    vok();
    ll n,k;
    IN n>>k;
    vll a(n);
    bitset<50> b[n];
    loop(i,0,n)
    {
        IN a[i];
        bitset<50> temp(a[i]);
        b[i]=temp;
    }
    bitset<50> ans(0);
    rloop(i,49,0)
    {
        int countt=0;
        loop(j,0,n)
        {
            if(b[j][i])
            {
                countt++;
            }
          	//cout<<"";
        }
        ans[i]=1;
        if((countt*2)<n && ans.to_ullong()<=k)
        {
            //Do Nothing
        }
        else
        {
            ans[i]=0;
        }
    }
    ll fans=0LL;
    ll X=ans.to_ullong();
    loop(i,0,n)
    {
      	//cout<<"";
        fans+=(X^a[i]);
    }
    OUT fans<<endl
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC80(void);
void ABC81(void);
void ABC82(void);
void ABC83(void);
void ABC84(void);
void ABC85(void);
void ABC86(void);
void ABC87(void);
void ABC88(void);
void ABC89(void);

int main(void){
    ABC88();
}

void ABC88(){
    int i,n,alice=0,bob=0;
    cin>>n;
    vector<int> vec(n);
    for(i=0;i<n;i++){
        cin>>vec[i];
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    for(i=0;i<n;i++){
        if(i%2==0)alice+=vec[i];
        if(i%2==1)bob+=vec[i];
    }
    cout<<alice-bob<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N_MAX 100
int suuretu[N_MAX]; // sortする数列

int main() {
    int N; //数列の長さ
    int i, j, k, tmp, val;
    scanf("%d", &N);
    for (i = 0; i < N; i++) {
        scanf("%d", &suuretu[i]);
    }
    for (i = 0; i < N; i++) {
        val = suuretu[i];
        for (j = i; j >= 0; j--) {
            if (val < suuretu[j]) {
                tmp = suuretu[j];
                suuretu[j] = val;
                suuretu[j+1] = tmp;
            }
        }
        for (k = 0; k < N; k++) {
            printf("%d", suuretu[k]);
            if (k == N - 1) {printf ("\n");}
            else {printf(" ");}
        }
    }
    return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

const int N = 1e5 + 5;

int n;
char s[N];

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	if (s[n] == '1' || (s[1] == '0' && n > 1)) {
		puts("-1");
		return 0;
	}
	for (int i = 1; i <= (n >> 1); i++) {
		if (s[i] ^ s[n - i]) {
			puts("-1");
			return 0;
		}
	}
	if (n == 1)
		return 0;
	vector<int> goal;
	for (int i = 1; i <= ((n + 1) >> 1); i++) {
		if (s[i] == '1') {
			goal.push_back(i);
		}
	}
	goal.push_back(n);
	int ls;
	for (auto sz : goal) {
		if (sz == 1) {
			ls = 1;
		} else {
			printf("%d %d\n", sz, ls);
			for (int i = ls + 1; i < sz; i++)
				printf("%d %d\n", sz, i);
			ls = sz;
		}
	}
	return 0;
}


Measured memory_bytes: 1788
// vim: ts=2 sw=2 sts=2
#include <bits/stdc++.h>
using namespace std;

int main() {
  int a, b, n;
  cin >> a >> b;

  for(int i = a; i <= b; i++){
    int x, y;

    x = i / 1000;
    y = (i % 10) * 10 + (i % 100) / 10;
    if (x == y)
      n++;

  }
  cout << n << endl;
}


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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << H * W - h * W - w * H + h * w << ln;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static int N;
	public static int K;

	public static void main(String[] args) {
		init();
		int ans = 0;
		while (N > 0) {
			ans++;
			N /= K;
		}
		System.out.println(ans);
	}

	public static void init() {
		Scanner sc = new Scanner(System.in);
		try {
			N = sc.nextInt();
			K = sc.nextInt();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int n;
	cin >> n;
	vector <int> a(n);
	int val = 0;
	int mi;
	for(int i =0;i < n; i++) {
		cin >> a[i];
	}
	for(int i =0; i<n;i++) {
		val += pow((a[i] - 1),2);
	}
	mi = val;
	for(int i =2;i <=100; i++) {
		val = 0;
		for (int j=0;j <n; j++) {
			val += pow((a[j] - i),2);
		}
		mi = min(mi,val);
	}
	cout << mi << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 2147483647



int main() {
	while (true) {
		int h, w;
		cin >> h >> w;
		if (h + w == 0)break;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if ((i+j) % 2 == 0) cout << '#';
				else cout << '.';
			}
			cout << endl;
		}
		cout << endl;
	}


	return 0;
}



Measured memory_bytes: 3072
mod = 10 ** 9 + 7
from math import gcd
N = int(input())
from collections import defaultdict
X = defaultdict(lambda: [0, 0])
x = 0
y = 0
z = 0
for i in range(N):
  a, b = map(int, input().split())
  g = abs(gcd(a, b))
  if a * b > 0:
    X[(abs(a) // g, abs(b) // g)][0] += 1
  elif a * b < 0:
    X[(abs(b) // g, abs(a) // g)][1] += 1
  else:
    if a:
      x += 1
    elif b:
      y += 1
    else:
      z += 1
ans = 1
pow2 = [1]
for i in range(N):
  pow2 += [pow2[-1] * 2 % mod]
for i in X.values():
  ans *= pow2[i[0]] + pow2[i[1]]- 1
  ans %= mod
ans *= pow2[x] + pow2[y] - 1
ans += z - 1
ans %= mod
print(ans)

Measured memory_bytes: 68456
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int A[50];
map<int, set<int> > mp;

P bound() {
  int lo = INF, hi = -INF;
  rep(i, N) {
    lo = min(lo, A[i]);
    hi = max(hi, A[i]);
  }
  return P(lo, hi);
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> A[i], mp[A[i]].insert(i);
  int lo, hi; tie(lo, hi) = bound();
  vector<P> ret;
  if (lo < 0 && hi > 0) {
    if (abs(hi) >= abs(lo)) {
      int src = *mp[hi].begin();
      rep(i, N) if (A[i] < 0) {
        ret.pb(P(src, i));
        A[i] += hi;
      }
    }
    else {
      int src = *mp[lo].begin();
      rep(i, N) if (A[i] > 0) {
        ret.pb(P(src, i));
        A[i] += lo;
      }
    }
  }
  tie(lo, hi) = bound();
  if (lo >= 0 && hi >= 0) {
    rep(i, N-1) ret.pb(P(i, i+1));
  }
  else if (lo <= 0 && hi <= 0) {
    for (int i=N-1; i>0; i--) ret.pb(P(i, i-1));
  }
  else {
    assert(false);
  }
  cout << ret.size() << "\n";
  for (P p : ret) cout << p._1+1 << " " << p._2+1 << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int f[51];
bitset<51> dp[1<<20], num[21];

LL qpow(LL a, LL b) {
    LL ret = 1;
    while(b) {
        if(b & 1) ret = ret * a;
        a = a * a;
        b >>= 1;
    }
    return ret;
}

void run_case() {
    int n, m; 
    cin >> n;
    vector<vector<int>> G(n+1, vector<int>());
    for(int i = 1; i < n; ++i) {
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    function<void(int,int)> dfs = [&](int u, int fa) {
        f[u] = fa;
        for(auto v: G[u]) {
            if(v == fa) continue;
            dfs(v, u);
        }
    };
    dfs(1, -1);
    cin >> m;
    function<void(int,int,int)> count = [&](int u, int v, int idx) {
        int i;
        for(i = u; i != -1; i = f[i]) num[idx].set(i, 1);
        for(i = v; i != -1 && !num[idx][i]; i = f[i]) num[idx].set(i, 1);
        for(; i != -1; i = f[i]) num[idx].set(i, 0);
    };
    for(int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        count(u, v, i);
    }
    LL ans = 0;
    for(int i = 0; i < (1<<m); ++i) {
        int cnt = 0, end;
        for(int j = 0; j < m; ++j)
            if(i&(1<<j)) {
                cnt++, end = j;
            }
        if(cnt) dp[i] = dp[i^(1<<end)]|num[end];
        if(cnt&1) {
            ans -= qpow(2, n-1-dp[i].count());
        } else {
            ans += qpow(2, n-1-dp[i].count());
        }
    }
    cout << ans;
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 8448
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int n,m;
    cin >> n >> m;
    
    cout << ( n-1 ) * ( m-1 ) << endl;
    
    return 0;
}

Measured memory_bytes: 256