akhauriyash/Code-Regression huggingface dataset:
data class Int2D(val x: Int, val y: Int) {
    operator fun minus(o: Int2D) = Int2D(x - o.x, y - o.y)
}

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val ps = Array<Int2D>(n, {
        val (x, y) = readLine()!!.split(" ").map { it.toInt() }
        Int2D(x, y)
    })

    if (n == 1) {
        println(1)
        return
    }

    val diffToCount = mutableMapOf<Int2D, Int>()
    for (i in 0 until n) {
        for (j in 0 until n) {
            if (i == j) continue
            val diff = ps[i] - ps[j]
            if (diffToCount.containsKey(diff)) {
                diffToCount[diff] = diffToCount[diff]!! + 1
            } else {
                diffToCount[diff] = 1
            }
        }
    }
    val max = diffToCount.values.max()!!
    println(n - max)
}

Measured memory_bytes: 38044
n, m = gets.split.map(&:to_i)
ab = m.times.map {gets.split.map(&:to_i)}

paths = Hash.new {|h, k| h[k] = []}
ab.each do |a, b|
  paths[a] << b
  paths[b] << a
end

guide = Array.new(n + 1)
guide[1] = "Yes"

q = [1]
while (now = q.shift)
  paths[now].each do |nxt|
    next if guide[nxt]
    guide[nxt] = now
    q << nxt
  end
end

puts guide[1..-1]

Measured memory_bytes: 54280
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    char tmp;
    int ans = 0;
    for(int i = 0; i < s.size(); i++)
    {
        if(i > 0 && s[i] != tmp)
        {
            ans++;
        }
        tmp = s[i];
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;

int main()
{
    string s;
    cin>>s;
    int a=0,b=0;
    for(int i=0; i<s.length(); i++)
        if(s[i]=='-')a++;
        else b++;
    cout<<b-a;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] a = new int[2][n];
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < n; j++) {
				a[i][j] = sc.nextInt();
			}
		}
		sc.close();

		int ans = 0;
		for (int i = 0; i < n; i++) {
			int val = 0;
			for (int j = 0; j <= i; j++) {
				val += a[0][j];
			}
			for (int j = i; j < n; j++) {
				val += a[1][j];
			}
			ans = Math.max(ans, val);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21716
namespace ABC131.B
{
    using System.Collections.Generic;
    using System.Linq;
    using static System.Console;




    public class Program
    {

        public static void Main(string[] args)
        {
            var l = ReadInputsAsInt().ToArray();
            WriteLine(Solve(l[0], l[1]));
        }

        // taste(i)⊂[L+0, L+(N-1)], count(taste)=n
        public static long Solve(int n, int l)
        {
            var sum = Enumerable.Range(l, n).Sum();

            if (l > 0) return sum - l;
            if (l + n - 1 < 0) return sum - (l + n - 1);
            return sum;
        }

        static IEnumerable<int> ReadInputsAsInt() => ReadLine().Split(' ').Select(x => int.Parse(x));

    }
}


Measured memory_bytes: 13268
#include<cstdio>
#include<cstdlib>
#include<set>
#include<cstring>
#include<string>
#include<iostream>
using namespace std;
int main()
{
	string s;
	cin>>s;
	set<string> ss;
	int k;
	cin>>k;
	for(int i=1;i<=k&&i<=s.size();i++){
		for(int j=0;j<=s.size()-1;j++)
			ss.insert(s.substr(j,i));
	}
	int i=1;
	for(set<string>::iterator it=ss.begin() ;it!=ss.end();it++){
        if(i==k){
            cout<<*it<<endl;
            break;
        }
        i++;
	}

	return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define int            int64_t
#define double         long double
#define nitro          ios_base::sync_with_stdio(false);cin.tie(0);
#define vi             vector<int64_t>
#define si             set<int>
#define pub            push_back
#define puf            push_front
#define pob            pop_back
#define pof            pop_front
#define PI             3.1415926535897932384626433832795
#define read(a)        for(auto& x : a) cin>> x
#define endl           '\n'
#define gap            ' '
#define min3(a,b,c)    min(a, min(b, c))
#define max3(a,b,c)    max(a, max(b, c))
#define MOD            1000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int32_t main()
{
    nitro
    int n;cin>>n;
    si s;
    for(int i=0,x;i<n;++i)
    {
    	cin>>x;
    	if(s.find(x)==s.end()) s.insert(x);
    	else s.erase(s.find(x));
    }
    cout<<s.size();
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define tint tuple<int,int,int> 
#define mt make_tuple

int dp[110][10101];
int c[60],d[60];

const int INF = 1LL << 60;

bool chmin(int &a, int b ){  //変更が起きたらtrueを返す
  if( a > b ){ swap(a,b); return true;} 
  else{return false;}
} 

int n,m,s; 

vector<vector<int>> to,cost,TIME;

void Dijkstra(int a){ 
  //(a,s)始点での各点までの最短距離を求める
  
  for(int i = 0; i < 110; i++){ 
    for(int j = 0; j < 10101; j++){ 
      dp[i][j] = INF;
    }
  }
  
  int num = min(s,10000LL);
  
  dp[a][num] = 0;
  
  priority_queue<tint,vector<tint>,greater<tint>> Q;
  // 距離、 位置、　銀貨の枚数　で　保存する
  
  Q.push(mt(0,a,num));
  
  while(!Q.empty()){ 
    
    auto p = Q.top(); Q.pop();
    int pos = get<1>(p); int silver = get<2>(p);
    int dist = get<0>(p);
    
    if( dp[pos][silver] < dist ){ continue;} 
    
    int r = min(silver+c[pos],10000LL);
    //銀貨の枚数は制限しても良い
    
    if(chmin(dp[pos][silver+c[pos]],dist+d[pos])){
      Q.push(mt(dp[pos][r],pos,r));
    }//変更が起きたらこれもqueueに入れてあげる
             
      
    for(int i = 0; i < (int)to[pos].size(); i++){ 
      
      int next = to[pos][i];
      int a = cost[pos][i];
      int b = TIME[pos][i];
      
      int res = silver-a; 
      
      if( res < 0 ){ continue;} //渡るためには銀貨が足らなかった場合
      
      if(chmin(dp[next][res],dist+b)){ 
        Q.push(mt(dp[next][res],next,res));
      }
      
    }
  }
  
  return ;
  
}


signed main(void){ 
  
  cin >> n >> m >> s; 
  
  to = vector<vector<int>> (n);
  cost = vector<vector<int>> (n);
  TIME = vector<vector<int>> (n);
  
  for(int i = 0; i < m; i++){ 
    int u,v,a,b; cin >> u >> v >> a >> b;
    u--; v--;
    //隣接リスト
    to[u].push_back(v); to[v].push_back(u);
    //運賃
    cost[u].push_back(a); cost[v].push_back(a);
    //所要時間
    TIME[u].push_back(b); TIME[v].push_back(b);

  }
  for(int i = 0; i < n; i++){ 
    cin >> c[i] >> d[i];
  }
  
  
  Dijkstra(0);
  
  for(int i = 1; i < n; i++){ 
    int ans = INF;
    for(int j = 0; j < 10101; j++){ 
      chmin(ans,dp[i][j]);
    }
    cout << ans << endl;
  }
  
  return 0;
}

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

namespace Contest
{
    class Program
    {
        static void Main()
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add("Sunny", "Cloudy");
            dic.Add("Cloudy", "Rainy");
            dic.Add("Rainy", "Sunny");
            Console.WriteLine(dic[Console.ReadLine()]);

        }
    }
}


Measured memory_bytes: 11104
// In The Name Of Allah //
#include <bits/stdc++.h>
#define pb emplace_back
#define inf (int)1e9
#define ff first
#define ss second
#define ll long long
#define sp(n) cout << setprecision(n) << fixed
#define hellcat ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define give(x) cout << #x << " " << x << endl
#define debug cout << "dddd" << '\n'
#define debarr(a, n) for (int i = 0; i < n; ++i) cout << a[i] << ' '; cout << endl
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

template <class S, class T>
inline S smax(S &l, T r) {
  return l = max(l, (S)r);
}
template <class S, class T>
inline bool smin(S &l, T r) {
  return l = min(l, (S)r);
}

const int MAXN = 1e5 + 10;
int a[MAXN][4];
ll dp[MAXN][4];

int32_t main () {
	hellcat;

	int n;
	cin >> n;

	for (int i = 0; i < n; ++i) cin >> a[i][0] >> a[i][1] >> a[i][2];

	dp[0][0] = a[0][0];
	dp[0][1] = a[0][1];
	dp[0][2] = a[0][2];

	for (int i = 1; i < n; ++i) {
		dp[i][0] = a[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = a[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = a[i][2] + max(dp[i - 1][0], dp[i - 1][1]);
	}


	n--;
	cout << max({dp[n][0], dp[n][1], dp[n][2]}) << '\n';

	return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<cmath>

using namespace std;
const int MAX_SIZE=1e5+10;
typedef long long ll;
ll arr[MAX_SIZE];

int main(){
    ios::sync_with_stdio(false);
    int r;
    cin>>r;
    double pi=acos(-1);
    cout<<pi*2*r;
    
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

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

  if(s == "SUN")
    puts("7");
  else if(s == "MON")
    puts("6");
  else if(s == "TUE")
    puts("5");
  else if(s == "WED")
    puts("4");
  else if(s == "THU")
    puts("3");
  else if(s == "FRI")
    puts("2");
  else if(s == "SAT")
    puts("1");
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		int[] a = new int[100];
		int x = 0;
		
		int n = scan.nextInt();
		
		for(int i=0; i<n; i++){
			a[i] = scan.nextInt();
		}
		
		for(int i=0; i<n; i++){
			int min = i;
			int c = 0;
			for(int j=i; j<n; j++){
				if(a[min] > a[j]){
					min = j;
					c = 1;
				}
			}
			int kari = a[i];
			a[i] = a[min];
			a[min] = kari;
			if(c==1){
				x++;
			}
		}
		
		for(int i=0; i<n; i++){
			System.out.print(a[i]);
			if(i!=n-1){
				System.out.print(" ");
			}
			else{
				System.out.print("\n");
			}
		}
		
		System.out.println(x);
	}
}


Measured memory_bytes: 26336
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v){stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modpow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isprime(ll n){if(n<2)return 0;if(!(n%2))return !(n-2);lll d=n-1,t,y;while(!(d%2))d>>=1;vl al={2,325,9375,28178,450775,9780504,1795265022};for(ll a:al){if(n<=a)break;t=d,y=modpow(a,t,n);while(t!=n-1&&y!=1&&y!=n-1)y=y*y%n,t<<=1;if(y!=n-1&&!(t%2))return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES\n":"NO\n");}
void Yn(bool z){cout<<(z?"Yes\n":"No\n");}
void yn(bool z){cout<<(z?"yes\n":"no\n");}
const mt19937 rnd(unsigned(1357986421));
const int iinf = 1e9+6;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;

const int N = 55;
int n;
ll X;
ll search(ll l, ll x){
  if(x < 1) return 0;
  if(x >= (1ll<<(l+2))-3) return (1ll<<(l+1))-1;
  ll ret = 0;
  x -= 1;
  ret += search(l-1, x);
  x -= (1ll<<(l+1))-3;
  if(x > 0) ret++;
  x -= 1;
  ret += search(l-1, x);
  return ret;
}

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> X;
  cout << search(n, X) << endl;
  return 0;
}

Measured memory_bytes: 256
(* O(n) *)
let solve n a_s =
  let sum, has_zero, mi, neg_count =
    List.fold_left
      (fun (sum, has_zero, mi, neg_count) a ->
        let abs_a = abs a in
        sum + abs_a,
        (if not has_zero then a = 0 else has_zero),
        min mi abs_a,
        if a < 0 then neg_count + 1 else neg_count)
      (0, false, max_int, 0)
      a_s
  in
    if has_zero || neg_count mod 2 = 0 then
      sum
    else 
      sum - mi * 2

let read_ints () = read_line () |> Str.split (Str.regexp " ") |> List.map int_of_string
let _ =
  let n = read_int () in
  read_ints () |> solve n |> string_of_int |> print_endline

Measured memory_bytes: 16768
Nc = input()
N = int(Nc)
c = map(int,input().split())
cor = ''
l = list(c)
l2 = []
maxL = 0
m = 0

for num in l:
    if 1 <= N <= 100 and 1 <= num <= 4800 and type(num) == int and len(l) == N:
        if  1 <= num <= 399:
            cor = 'cinzento'
            if cor not in l2:
                l2.append(cor)
                maxL = maxL + 1
                m = m + 1
        elif 400 <= num <= 799:
            cor = 'a'
            if cor not in l2:
                l2.append(cor)
                maxL = maxL + 1
                m = m + 1
        elif 800 <= num <= 1199:
            cor = 'b'
            if cor not in l2:
                l2.append(cor)
                maxL = maxL + 1
                m = m + 1
        elif 1200 <= num <= 1599:
            cor = 'c'
            if cor not in l2:
                l2.append(cor)
                maxL = maxL + 1
                m = m + 1
        elif 1600 <= num <= 1999:
            cor = 'd'
            if cor not in l2:
                l2.append(cor)
                maxL = maxL + 1
                m = m +1
        elif 2000 <= num <= 2399:
            cor = 'e'
            if cor not in l2:
                l2.append(cor)
                maxL = maxL + 1
                m = m + 1
        elif 2400 <= num <= 2799:
            cor = 'f'
            if cor not in l2:
                l2.append(cor)
                maxL = maxL + 1
                m = m + 1
        elif 2800 <= num <= 3199:
            cor = 'g'
            if cor not in l2:
                l2.append(cor)
                maxL = maxL + 1
        else:
            maxL = maxL + 1
            cor = 'escolha'
            if cor not in l2:
                l2.append(cor)
                m = m + 1
            
           
print(m, maxL)   

Measured memory_bytes: 3188
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int d = scan.nextInt();
			int sum = 0;
			for(int i = 1;i <= (600/d);i++){
				sum += (i-1)*(i-1)*d*d*d;
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 12000
N = int(input())
s = {}
for i in range(N):
    text = input()
    if not (text in s.keys()):
        s[text] = 1
    else:
        s[text] += 1

M = int(input())
t = dict()
for i in range(M):
    text = input()
    if not (text in t.keys()):
        t[text] = 1
    else:
        t[text] += 1

for key in s.keys():
    if key not in t.keys():
        t[key] = 0


maxVal = 0
for key in s.keys():
    maxVal = max(maxVal, s[key] - t[key])

print(maxVal)


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

int N;
string Ans, Zero;

void Out(int x) {
    cout << x << endl;
    fflush(stdout);
    cin >> Ans;
    if(Ans == "Vacant") exit(0);
}

int main() {
    cin >> N;
    Out(0);
    Zero = Ans;

    int s = 1, e = N - 1;
    while(1) {
        int m = (s + e)>>1;
        Out(m);

        if((Ans == Zero) ^ (m & 1)) {
            s = m + 1;
        }
        else e = m - 1;
    }
}


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

using namespace std;

#define lint long long

int main(){
    string S, T;
    
    cin >> S >> T;
    
    for(int i = 0; i < S.length(); ++i){
        rotate(S.begin(), S.begin() + 1, S.end());
        bool flag = true;
        for(int j = 0; j < S.length(); ++j){
            if(S[j] != T[j]){
                flag = false;
            }
        }
        if(flag){
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
l = [list(map(int,input().split()))[1:]for i in range(m)]
p = list(map(int,input().split()))
form = "0"+str(n)+"b"
ans = 0
for i in range(2**n):
    ptn = format(i,form)
    light = True
    for j in range(m):
        s = sum(int(ptn[k-1])for k in l[j])
        if s%2 != p[j]:
            light = False
    if light == True:
        ans += 1
print(ans)

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

int main() {
  int n;
  cin >> n;
  vector<int> d(3);
  rep(i,3) cin >> d[i];
  vector<P> q;
  rep(i,n) {
    string s;
    cin >> s;
    int a = 0, b = 1;
    if (s == "AB") a = 0, b = 1;
    if (s == "AC") a = 0, b = 2;
    if (s == "BC") a = 1, b = 2;
    q.emplace_back(a,b);
  }
  string ans;
  auto add = [&](int a, int b) {
    d[a]++;
    d[b]--;
    ans += 'A'+a;
  };
  rep(i, n) {
    int a = q[i].first;
    int b = q[i].second;
    if (!d[a] && !d[b]) {
      cout << "No" << endl;
      return 0;
    }
    if (!d[a]) {
      add(a,b);
    } 
    else if (!d[b]) {
      add (b,a);
    } else {
      int na = q[i+1].first;
      int nb = q[i+1].second;
      if (a == na || a == nb) {
        add(a,b);
      } else {
        add(b,a);
      }
    }
  }
  cout << "Yes" << endl;
  rep(i,n) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 4252
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void pk()
{
   string s;
   ll sum=0;
   cin>>s;
   for(ll i=0;i<s.size();i++)
   {
       sum=sum+s[i]-'0';
   }
   if(sum%9==0)
   {
       cout<<"Yes";
   }
   else cout<<"No";
}
int main() 
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    //a #ifndef ONLINE_JUDGE 
    // freopen("/home/priyanshu/Hackercup/input.txt", "r", stdin); 
    // freopen("/home/priyanshu/Hackercup/output.txt", "w", stdout); 
    // #endif 
	ll t=1;
    //cin>>t;
    while(t--)
    {
        pk();
    }
} 

Measured memory_bytes: 3692
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<math.h>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
//#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
const int INF=0x3f3f3f3f;
inline int mul(int a,int b){ return (a*1ll*b)%mod; }
inline int add(int a,int b){ a+=b;if(a>=mod) a-=mod; return a;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1) rt=rt*a;a=mul(a,a);b>>=1;} return rt;}
//for(int i=0;i<n;i++)
ll mxm(ll a,ll b){
    if(a>b) return a;
    else return b;
}

int gcd(int a,int b){
    if(b==0) return a;
    else return gcd(b,a%b);
}
//for(int i=0;i<n;i++)

void solve(){
   int n,x,t;cin>>n>>x>>t;
   int y=n/x;
   if(n%x!=0) y++;
   cout<<y*t<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int t=1;//cin>>t;
    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include<string>
using namespace std;
 
int main(int argc, const char * argv[]) {
    string s,ans;
    cin>>s;
    
    for(int i=0;i<s.length();i++){
        if(s[i]=='0')ans.push_back('0');
        else if(s[i]=='1')ans.push_back('1');
        else if(s[i]=='B'){
            if(ans.length()>0)ans.erase(ans.size()-1);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
program BlueandRedBalls
    implicit none
    integer(8):: n, k, i
    integer(8), allocatable:: frac(:), ifrac(:)
    integer(8), parameter:: md = 1000000007

    read*, n, k

    call make_frac()

    do i=1,k
        print*, mod(comb(n-k+1,i)*comb(k-1,i-1),md)
    end do
contains


function comb(a,b) result(ret)
    integer(8):: a,b
    integer(8):: ret

    if (b>a)then
        ret = 0
        return
    end if

    ret = mod(mod(frac(a)*ifrac(b), md)*ifrac(a-b),md)
end function


subroutine make_frac
    integer(8):: i
    allocate(frac(0:n), ifrac(0:n))

    frac(0) = 1
    ifrac(0) = 1

    do i=1,n
        frac(i) = mod(frac(i-1)*i, md)
        ifrac(i) = inv(frac(i))
    end do
end subroutine


function inv(x) result(ret)
    integer(8):: x, ret
    integer(8):: num, mul, pow

    num = md-2
    mul = x
    ret = 1

    do while (num >= 1)
        if (mod(num,2) == 1) then
            ret = mod(ret * mul, md)
        end if
        num=num/2
        mul=mod(mul*mul, md)
    end do
end function
end program BlueandRedBalls

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  string str;
  cin>>str;
  int count=0,aa=0;
  for(int i=0;i<3;i++){
    if(str[i]=='R'){
      aa++;
    }
    else{
      if(aa>count){
        count=aa;
        aa=0;
      }
    }
    
  }
  if(aa>count){
        count=aa;
        aa=0;
      }
  cout<<count;
}
       

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define INF 1LL<<60
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string str;
ll k;
int n;

int dp[2001][2001];
ll cnt[2005][2005];
char ss[5001];

int func(int l,int r){
	if(dp[l][r]!=-1)return dp[l][r];
	if(l==r){
		cnt[l][r]=1;
		return 0;
	}
	if((l+1)==r){
		cnt[l][r]=1;
		return 1;
	}
	int ans=func(l+1,r)+2;
	ll val=cnt[l+1][r];
	int v2=func(l,r-1)+2;
	if(v2==ans)val+=cnt[l][r-1];
	else if(v2<ans)val=cnt[l][r-1];
	ans=min(ans,v2);
	if(str[l]==str[r-1]){
		v2=func(l+1,r-1)+2;
		val=cnt[l+1][r-1];
		ans=min(v2,ans);
	}
	cnt[l][r]=min(val,1LL<<60);
	return (dp[l][r]=ans);
}

void solve(int l,int r,int c,ll rest){
	if(l==r)return;
	if((l+1)==r){
		ss[c]=str[l];
		ss[n-c-1]=str[l];
		return;
	}
	if(str[l]==str[r-1]){
		ss[c]=str[l];
		ss[n-c-1]=str[l];
		c++;
		solve(l+1,r-1,c,rest);
	}else{
		if(dp[l+1][r]<dp[l][r-1]){
			ss[c]=str[l];
			ss[n-c-1]=str[l];
			c++;
			solve(l+1,r,c,rest);
		}else if(dp[l+1][r]>dp[l][r-1]){
			ss[c]=str[r-1];
			ss[n-c-1]=str[r-1];
			c++;
			solve(l,r-1,c,rest);
		}else{
			if(str[l]<str[r-1]){
				if(cnt[l+1][r]>rest){
					ss[c]=str[l];
					ss[n-c-1]=str[l];
					c++;
					solve(l+1,r,c,rest);
				}else{
					ss[c]=str[r-1];
					ss[n-c-1]=str[r-1];
					c++;
					rest-=cnt[l+1][r];
					solve(l,r-1,c,rest);
				}
			}else{
				if(cnt[l][r-1]>rest){
					ss[c]=str[r-1];
					ss[n-c-1]=str[r-1];
					c++;
					solve(l,r-1,c,rest);
				}else{
					ss[c]=str[l];
					ss[n-c-1]=str[l];
					c++;
					rest-=cnt[l][r-1];
					solve(l+1,r,c,rest);
				}
			}
		}
	}
}

int main(void){
	cin >> str;
	n=str.size();
	scanf("%lld",&k);
	memset(dp,-1,sizeof(dp));
	int pn=n;
	n=func(0,n);
	k--;
	if(cnt[0][pn]<=k)printf("NONE\n");
	else{
		solve(0,pn,0,k);
		for(int i=0;i<n;i++){
			printf("%c",ss[i]);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 41696
#include <iostream>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>

using namespace std;

struct vec{
    int x,y;
    vec(int x,int y){
        this->x=x;this->y=y;
    }
    long long int cross(vec b){
        return x*b.y-y*b.x;
    }
    vec operator-(vec b){
        return vec(x-b.x,y-b.y);
    }
    vec operator+(vec b){
        return vec(x+b.x,y+b.y);
    }
    double norm(){
        return hypot(x,y);
    }
};

bool isCrossing(vec& v1, vec& v2, vec& v3, vec& v4){
    return (v2-v1).cross(v3-v1)*(v2-v1).cross(v4-v1)<0&&(v4-v3).cross(v1-v3)*(v4-v3).cross(v2-v3)<0;
}

int main(){
    int NA,NB,x,y;
    cin>>NA>>NB;
    vector<vec> A,B;
    for(int i=0;i<NA;i++){
        cin>>x>>y;
        A.emplace_back(x,y);
    }
    for(int i=0;i<NB;i++){
        cin>>x>>y;
        B.emplace_back(x,y);
    }
    double EA[NA][NA];
    double EB[NB][NB];
    fill(EA[0],EA[NA],0);
    fill(EB[0],EB[NB],0);
    for(int i=0;i<NA;i++){
        for(int j=i+1;j<NA;j++){
            if(!isCrossing(A[i],A[j],B[0],B[1])) EA[i][j]=EA[j][i]=(A[i]-A[j]).norm();
        }
    }
    for(int i=0;i<NB;i++){
        for(int j=i+1;j<NB;j++){
            if(!isCrossing(B[i],B[j],A[0],A[1])) EB[i][j]=EB[j][i]=(B[i]-B[j]).norm();
        }
    }
    double Amin[NA],Bmin[NB];
    fill(Amin,Amin+NA,1e10);
    fill(Bmin,Bmin+NB,1e10);
    double Acost,Bcost;
    int s=0,end=1;
    typedef pair<double, int> P;
    priority_queue<P,vector<P>,greater<P>> que;
    Amin[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
        P p=que.top(); que.pop();
        int v=p.second;
        double cost=p.first;
        if(cost>Amin[v])continue;
        for(int i=0;i<NA;i++){
            if(EA[i][v]!=0&&cost+EA[i][v]<Amin[i]){
                Amin[i]=cost+EA[i][v];
                que.emplace(Amin[i],i);
            }
        }
    }
    if(Amin[end]!=1e10){
        Acost=Amin[end]+(B[s]-B[end]).norm();
    }else{
        Acost=1e10;
    }
    Bmin[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
        P p=que.top(); que.pop();
        int v=p.second;
        double cost=p.first;
        if(cost>Bmin[v])continue;
        for(int i=0;i<NB;i++){
            if(EB[i][v]!=0&&cost+EB[i][v]<Bmin[i]){
                Bmin[i]=cost+EB[i][v];
                que.emplace(Bmin[i],i);
            }
        }
    }
    if(Bmin[end]!=1e10){
        Bcost=Bmin[end]+(A[s]-A[end]).norm();
    }else{
        Bcost=1e10;
    }
    if(min(Acost,Bcost)==1e10){
        cout<<-1<<endl;
    }else{
        cout.precision(12);
        cout << fixed;
        cout<<min(Acost,Bcost)<<endl;
    }
    return 0;
}

Measured memory_bytes: 19020
H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]
# 列について
for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            break
    # すべて空白だったらx印
    else:
        for l in range(W):
            A[i][l] = "x"

# 行について
for i in range(W):
    for j in range(H):
        if A[j][i] == "#":
            break
    else:
        for l in range(H):
            A[l][i] = "x"
for i in range(H):
    x_cnt = 0
    for j in range(W):
        if A[i][j] != "x":
            print(A[i][j], end="")
        else:
            x_cnt += 1

    if x_cnt < W:
        print()
    else:
        pass


Measured memory_bytes: 9344
package main

import (
        "fmt"
)

func main() {

        acceptable := newByteSet("ACGT")
        var str string
        fmt.Scanf("%s", &str)

        var max int

        for i := 0; i < len(str); {
                subL := 0
                for j := i; j < len(str); j++ {
                        if !acceptable.doesContain(str[j]) {
                                break
                        }
                        subL++
                }
                if max < subL {
                        max = subL
                }
                // next of broken point
                i = i + subL + 1
        }
        fmt.Printf("%d\n", max)
}

type set map[byte]none

func newByteSet(input string) set {
        s := newSet()
        for i := 0; i < len(input); i++ {
                s.add(input[i])
        }
        return s
}

func newSet() set {
        return make(map[byte]none)
}
func (s set) add(item byte) {
        s[item] = mark
}

func (s set) doesContain(item byte) bool {
        _, ok := s[item]
        return ok
}

var mark none

type none struct{}

Measured memory_bytes: 512
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<_>>()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}



fn main() {
    input! {
        x: i32
    }

    let result = if x >= 30 { "Yes" } else { "No" };

    println!("{}", result);
}


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

struct interval{
  int west, east;
  interval(int w, int e) : west(w), east(e){}
};

vector<interval> islands;

bool cmp(const interval &a, const interval &b){
  return a.east < b.east;
}

int main(){
  int n, m;
  cin >> n >> m;
  for(int i = 0; i < m; ++i){
    int a, b;
    cin >> a >> b;
    islands.push_back(interval(a, b));
  }

  sort(islands.begin(), islands.end(), cmp);

  int neutral = 0;
  int count = 0;
  for(auto island : islands){
    if(neutral <= island.west){
      ++count;
      neutral = island.east;
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 998244353LL

ll c[6010][6010];
int n,m;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline ll pls(const ll &x,const ll &y) { return (x+y<mod)?x+y:x+y-mod; }
inline ll mns(const ll &x,const ll &y) { return (x-y<0)?x-y+mod:x-y; }
inline ll ksm(ll x,ll y) { ll res=1;for (;y;y>>=1,x=x*x%mod) if (y&1) res=res*x%mod;return res; }

inline void pre_gao()
{
	for (int i=0;i<=6000;i++)
	{
		c[i][0]=1;
		for (int j=1;j<=i;j++) c[i][j]=pls(c[i-1][j-1],c[i-1][j]);
	}
}

inline ll calc(const int &x,const int &y) { return (x<0||y<0||x>y||y>x*2)?0:c[x][y-x]; }

inline ll gao(const int &x,const int &y)
{
	if (y<m) return calc(x,y);
	if (y>=m*2) return ((m&1)&&y==x*2);
	int hh=y-m-1;
	if (hh&1) return 0;
	int hhh=m+1;
	int now=x-(y-hhh)/2-1-hh/2;
	return calc(now-1,hhh-hh-4);
}

int main()
{
	n=rd();m=rd();pre_gao();
	ll ans=0;
	for (int i=0;i<=n;i++) for (int j=i;j<=i*2;j++) ans=pls(ans,gao(i,j)*c[n][i]%mod);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 280192
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

//繰り返し二乗法
ll ex(ll x,ll n){
    if(n==0)return 1;
    else if(n%2==1)return ex(x,n-1)*x;
    else return ex(x*x,n/2);
};

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    map<pair<int,int>,int> mp;
    for(int i = 1; i <= n; i++){
        int back = i%10;
        if(back == 0) continue;
        int front = i/ex(10,to_string(i).size()-1);
        mp[{front,back}]++;
    }
    ll rem = 0;
    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            ans += mp[{i,j}]*mp[{j,i}];
            if(i == j){
                rem += mp[{i,j}];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3696
s=input()
t=input()
ans = 10**10
S=len(s)
T=len(t)
for i in range(S-T+1):
  chk=0
  for j in range(T):
    if s[i+j]!=t[j]:chk+=1
  ans = min(chk,ans)
print(ans)

Measured memory_bytes: 9056
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    vector<vector<int>> G(n);
    for(int i=0;i<m;++i){
        int a,b;
        cin>>a>>b;
        G[--a].push_back(--b);
        G[b].push_back(a);
    }
    int d[n][2];
    fill(d[0],d[n],1<<28);
    d[0][0]=0;
    queue<pair<int,int>> Q;
    Q.push({0,0});
    while(!Q.empty()){
        auto p=Q.front();
        Q.pop();
        for(auto a:G[p.first])
            if(d[a][!p.second]==1<<28){
                d[a][!p.second]=d[p.first][p.second]+1;
                Q.push({a,!p.second});
            }
    }
    int even=0, odd=0;
    for(int i=0;i<n;++i){
        even=max(even,d[i][0]);
        odd=max(odd,d[i][1]);
    }
    int step=min(even,odd);
    if(step==1<<28) cout<<-1<<endl;
    else cout<<step<<endl;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define int long long

typedef pair<int, int> ii;

const int N = 1e5 + 5;

const int inf = 1e15;

int n, mod, dp[N][2], up[N][2], pref[N][2], suff[N][2];

vector<int> graph[N];

void dfs(int u, int p) {
    dp[u][0] = dp[u][1] = 1;
    for(int i = 0; i < graph[u].size(); i++) {
        int v = graph[u][i];
        if(v == p) continue;
        dfs(v, u);
    }
    for(int i = 0; i < graph[u].size(); i++) {
        int v = graph[u][i];
        if(v == p) continue;
        dp[u][0] = (dp[u][0] * dp[v][0]) % mod;
        dp[u][1] = (dp[u][1] * (dp[v][1] + dp[v][0])) % mod;
    }
}

void redfs(int u, int p) {
    for(int j = 0; j < 2; j++) {
        for(int i = 0; i < graph[u].size(); i++)
            pref[i][j] = suff[i][j] = 1;
    }
    for(int i = 0; i < graph[u].size(); i++) {
        int v = graph[u][i];
        if(i >= 1) {
            pref[i][0] = pref[i - 1][0];
            pref[i][1] = pref[i - 1][1];
        }
        if(v == p) continue;
        pref[i][0] = (pref[i][0] * dp[v][0]) % mod;
        pref[i][1] = (pref[i][1] * (dp[v][0] + dp[v][1])) % mod;
    }
    for(int i = (int)(graph[u].size()) - 1; i >= 0; i--) {
        int v = graph[u][i];
        if(i < graph[u].size() - 1) {
            suff[i][0] = suff[i + 1][0];
            suff[i][1] = suff[i + 1][1];
        }
        if(v == p) continue;
        suff[i][0] = (suff[i][0] * dp[v][0]) % mod;
        suff[i][1] = (suff[i][1] * (dp[v][0] + dp[v][1])) % mod;
    }
    for(int i = 0; i < graph[u].size(); i++) {
        int v = graph[u][i];
        if(v == p) continue;
        for(int j = 0; j <= 1; j++) {
            up[v][j] = up[u][j];
            //cout << v << " " << i << "\n";
            if(i == 0 && i + 1 < graph[u].size())
                up[v][j] = (up[v][j] * suff[i + 1][j]) % mod;
            else if(i > 0 && i == graph[u].size() - 1)
                up[v][j] = (up[v][j] * pref[i - 1][j]) % mod;
            else if(i > 0 && i < graph[u].size() - 1) {
                //cout << pref[i - 1][j] << " " << suff[i + 1][j] << " " << j << " " << i << "\n";
                up[v][j] = (up[v][j] * ((pref[i - 1][j] * suff[i + 1][j]) % mod)) % mod;
            }
            if(j == 1)
                up[v][j] = (up[v][j] + up[v][0]) % mod;
        }
    }
    for(int i = 0; i < graph[u].size(); i++) {
        int v = graph[u][i];
        if(v == p) continue;
        redfs(v, u);
    }
}

signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n >> mod;
    for(int i = 1; i <= n - 1; i++) {
        int x, y;
        cin >> x >> y;
        graph[x].pb(y);
        graph[y].pb(x);
    }
    dfs(1, 1);
    up[1][1] = up[1][0] = 1;
    redfs(1, 1);
    for(int i = 1; i <= n; i++)
        cout << (up[i][1] * dp[i][1]) % mod << "\n";
}


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

int main(void){
    map<ll, ll>  a;

    ll n, m;
    cin >> n >> m;

    rep(i, m){
        a[i] = 0;
    }

    rep(i, n){
        ll k;
        cin >> k;
        rep(j, k){
            ll tmp;
            cin >> tmp;
            tmp--;
            a[tmp]++;
        }
    }

    ll count = 0;
    rep(i, m){
        if(a[i] == n)
            count++;
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    string s;
    long long int ans = 0;
    int cnt = 0;
    int len;
    vector<int> v;


    cin >> s;

    len = (int)s.size()-1;

    for (int i = 0; i < (int)s.size(); i++) {
        if (s[i] == 'B') {
            v.push_back(i);
        }
    }



    for (int i = v.size()-1; i >= 0; i--) {
        ans += len - v[i];
        len--;
    }

    cout << ans << endl;
}


Measured memory_bytes: 1532
s=input()
l=0
r=len(s)-1
ans=0
while l<r:
    if s[r]==s[l]:
        l+=1
        r-=1
    elif s[r]=="x":
        ans+=1
        r-=1
    elif s[l]=="x":
        ans+=1
        l+=1
    else:
        ans=-1
        break
print(ans)

Measured memory_bytes: 9152
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
static const int INF = 1e9;

int main(void){
	int n, m; cin >> n >> m;
	vector<int> d(n);
	rep(i, n) cin >> d[i];
	vector<int> c(m);
	rep(i, m) cin >> c[i];
	//dp[???????????°???????????????][?????\???]
	int dp[1001][1001];
	rep(i, 1001)rep(j, 1001) dp[i][j] = INF;
	rep(i, m) dp[0][i] = 0;
	reps(i, 1, n + 1){
		rep(j, m){
			dp[i][j] = min(dp[i][j - 1], dp[i - 1][j - 1] + d[i - 1] * c[j]);
		}
	}
	int ans = INF;
	rep(i, m){
		//printf("dp %d\n", dp[n][i]);
		ans = min(ans, dp[n][i]);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 7104
unittest
{
	assert( [ "3 3", "...", "...", "..." ].parse.expand.solve == 4 );
	assert( [ "3 5", "...#.", ".#.#.", ".#..." ].parse.expand.solve == 10 );
	
	assert( [ "20 20" ].chain( "....................".repeat( 20 ) ).parse.expand.solve == 38 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto hw = input.front.split.to!( long[] );
	auto sss = new dchar[][]( hw[ 0 ], hw[ 1 ] );
	foreach( ref ss; sss )
	{
		input.popFront;
		ss = input.front.to!( dchar[] );
	}
	return tuple( sss );
}

auto solve( dchar[][] sss )
{
	auto ans = 0L;
	foreach( sy; 0 .. sss.length )
	{
		foreach( sx; 0 .. sss[ sy ].length )
		{
			if( sss[ sy ][ sx ] == '.' ) ans = max( ans, bfsGridEx( sss, sy, sx ) );
		}
	}
	return ans;
}

// グリッドマップの始点指定最短経路探索（幅優先探索）
auto bfsGridEx( T )( T[][] css, long sy, long sx, T w = '#' )
{
	import std.container.dlist;
	
	auto m = 0L;
	auto dss = new long[][]( css.length, css[ 0 ].length );
	foreach( ref ds; dss ) ds[] = long.max;
	dss[ sy ][ sx ] = 0;
	
	auto queue = make!DList( tuple( sy, sx ) );
	while( !queue.empty )
	{
		auto fy = queue.front[ 0 ];
		auto fx = queue.front[ 1 ];
		queue.removeFront();
		
		foreach( p; [ [ -1, 0 ], [ 1, 0 ], [ 0, -1 ], [ 0, 1 ] ] )
		{
			auto ty = fy + p[ 0 ];
			auto tx = fx + p[ 1 ];
			
			if( ty < 0 || css.length <= ty || tx < 0 || css[ ty ].length <= tx ) continue;		// マップ外
			if( dss[ ty ][ tx ] < long.max ) continue;											// 探索済
			if( css[ ty ][ tx ] == w ) continue;												// 壁（侵入不可）
			
			// 道（1ターン使用）
			dss[ ty ][ tx ] = dss[ fy ][ fx ] + 1;
			queue.insertBack( tuple( ty, tx ) );
			
			// 一番長い道を更新
			m = max( m, dss[ ty ][ tx ] );
		}
	}
	return m;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define BITBOOL(x,a) (((x)>>(a))&1)
int main(){
  //std::cout << std::fixed << std::setprecision(20);
  int n; 
  cin >> n;
  vector<pair<int,int>> p(n,pair<int,int>(0,0));
  FOR(i,0,n) {cin >> p[i].first; p[i].second = i;}
  sort(p.begin(),p.end());
  FOR(i,0,n) cout << (++p[i].second) << " ";
}

Measured memory_bytes: 1536
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
    dis = []
    for j in range(m):
        dis.append(abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1]))
    print(dis.index(min(dis))+1)

Measured memory_bytes: 9144
package main

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

const (
	defaultBufferSize = 1024
	maxBufferSize     = 1e6
	Mod               = 1e9 + 7
)

var sc = bufio.NewScanner(os.Stdin)

// sc.Buffer(make([]byte, defaultBufferSize), maxBufferSize)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func ModComb(n, k int64) int64 {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := int64(1); i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int64) int64 {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int64) int64 {
	res := int64(1)
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func primeFactorization(x int) map[int]int {
	result := make(map[int]int, 0)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			result[i]++
			x /= i
		}
	}
	if x != 1 {
		result[x]++
	}
	return result
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if i == x {
			continue
		}
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	n := readInt()

	mp := make(map[string]int, 0)

	for i := 0; i < n; i++ {
		var s str
		s = []byte(readString())
		sort.Sort(s)
		mp[string(s)]++
	}

	ans := 0
	for _, v := range mp {
		if v > 1 {
			ans += v * (v - 1) / 2
		}
	}
	fmt.Println(ans)
}

type str []byte

func (s str) Len() int           { return len(s) }
func (s str) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s str) Less(i, j int) bool { return s[i] < s[j] }


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

namespace ITP1_5_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var list = new List<byte[]>();
            string input;
            while ((input = Console.ReadLine()) != "0 0")
                list.Add(input.Split(' ').Select(x => Convert.ToByte(x)).ToArray());
            foreach(var l in list)
            {
                //if (l[0] < 3 || 100 < l[1]) continue;
                string hframe = new string('#', l[1]);                
                Console.WriteLine(hframe);
                for(int i = 0; i < l[0] - 2; i++)
                {
                    string hollow = new string('.', l[1] - 2);
                    Console.WriteLine("#" + hollow + "#");
                }
                Console.WriteLine(hframe + "\n");                
            }           
        }
    }
}

Measured memory_bytes: 10316
#include <iostream>
#include <cstdio>
using namespace std;
long long n, s, c[9], v[99];
char a[15];
int main() {
	int i, j, k;
	cin>>n;
	while(n--) {
		scanf("%s", a);
		v[a[0]]++;
	}
	c[0] = v['M'];
	c[1] = v['A'];
	c[2] = v['R'];
	c[3] = v['C'];
	c[4] = v['H'];
	for(i=0; i<5; i++) for(j=i+1; j<5; j++) for(k=j+1; k<5; k++) {
		s += c[i] * c[j] * c[k];
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	N := readInt()

	Count, Keys, Max := map[string]int{}, make([]string, 0), 1
	for i := 0; i < N; i++ {
		s := readString()

		v, exists := Count[s]
		if exists {
			Count[s] = v + 1
			if Max < v+1 {
				Max = v + 1
			}
		} else {
			Count[s] = 1
			Keys = append(Keys, s)
		}
	}

	sort.Strings(Keys)

	for _, k := range Keys {
		v := Count[k]
		if v == Max {
			fmt.Println(k)
		}
	}
}

func readInt() int {
	var v int
	fmt.Scan(&v)
	return v
}

func readString() string {
	var v string
	fmt.Scanln(&v)
	return v
}


Measured memory_bytes: 27264
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int N = 16;
const ll INF = 1e18;
int n;
ll x[N], y[N], p[N], ans[N];

void dfs(int i, int c, VL d){
    ll s = 0;
    REP(i,n) s += d[i] * p[i];
    // cout << i << " " << c << endl;
    // REP(i,n) cout << d[i] << " ";
    // cout << endl;
    chmin(ans[c], s);
    if (i == n) return;
    dfs(i + 1, c, d);
    VL dx(d), dy(d);
    REP(j,n){
        chmin(dx[j], abs(x[j] - x[i]));
        chmin(dy[j], abs(y[j] - y[i]));
    }
    dfs(i + 1, c + 1, dx);
    dfs(i + 1, c + 1, dy);
}

int main(void){
    cin >> n;
    REP(i,n){
        cin >> x[i] >> y[i] >> p[i];
        // x[i] = rand() % 10000;
        // y[i] = rand() % 10000;
        // p[i] = rand() % 10000;
    }
    REP(i,n+1) ans[i] = INF;
    VL d(n);
    REP(i,n) d[i] = min(abs(x[i]), abs(y[i]));
    dfs(0, 0, d);
    REP(i,n+1) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" \
                              << "\n";

int main()
{
  int n;
  ll ans = 0;
  cin >> n;
  unordered_map<string, int> cnt;
  REP(i, n)
  {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (cnt.count(s))
      cnt.at(s)++;
    else
      cnt[s] = 1;
  }

  //cout << "\n";
  for (auto x : cnt)
  {
  //  cout << x.first << " " << x.second << "\n";
    ans += (ll)(x.second - 1) * x.second / 2;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 10660