akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

int main(){
	char str[128];
	int i,j,k;
	int len;
	
	while(scanf("%s",str)!=EOF){
		len = strlen(str);
		for(i=0;i<len;i++){
			if(str[i]=='@'){
				i++;
				j = str[i++] - '0';
				for(k=0;k<j;k++) printf("%c",str[i]);
			}else{
				printf("%c",str[i]);
			}
		}
		printf("\n");
	}
	
	return 0;
}

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

int main(){

    string s;
    cin>>s;

    if(s.at(2)==s.at(3)&&s.at(4)==s.at(5)){
        cout<<"Yes"<<endl;

    }
    else{cout<<"No"<<endl;}

}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long ll;
ll a, b, c, i, j, k, n, m, t, p, q, s;
struct node {
	ll x, y;
};

string s1,s2,s3;
ll str[200005],arr[200005];
int main() {
	cin >> n;
	s = 0;
	for (i = 0; i < n; i++) {
		cin >> str[i];
		arr[str[i]]++;
	}
	for (i = 1; i <= n; i++) {
		s += (arr[i] * (arr[i] - 1) / 2);
	}
	for (i = 0; i < n; i++) {
		cout << s - arr[str[i]] + 1<<endl;
	}
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int h,w,sx,sy,m;
int d[256],dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
char c[10][10],sc,nc[4]={'U','R','D','L'};
string ans;

bool check(int x,int y){
  int res=0;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(c[i][j]=='o'&&x!=j&&y!=j){
	int f=0;
	for(int k=j+1;k<w;k++)
	  if(c[k][j]=='o'){f++;break;}
	for(int k=j-1;k>=0;k--)
	  if(c[k][j]=='o'){f++;break;}
	for(int k=i+1;k<h;k++)
	  if(c[i][k]=='o'){f++;break;}
	for(int k=j-1;k>=0;k--)
	  if(c[i][k]=='o'){f++;break;}
	if(f<2)res++;
      }
  return res>1;
}

bool dfs(int x,int y,char r,int cnt){
  if(cnt==m){return 1;}
  //if(check(x,y))return 0;
  bool res=0;
  c[y][x]='.';
  for(int i=0;i<3;i++){
    int p=(d[r]+i)%4,nx=x,ny=y;
    while(0<=nx&&nx<w&&0<=ny&&ny<h&&c[ny][nx]!='o')
      nx+=dx[p],ny+=dy[p];
    if(0<=nx&&nx<w&&0<=ny&&ny<h)
      if(dfs(nx,ny,nc[p],cnt+1))ans=nc[p]+ans,res=1;
  }
  c[y][x]='o';
  return res;
}

int main(){
  cin>>h>>w;
  d['U']=3,d['R']=0,d['D']=1,d['L']=2;
  for(int i=h-1;i>=0;i--)
    for(int j=0;j<w;j++){
      cin>>c[i][j];
      if(c[i][j]=='o')m++;
      else if(c[i][j]!='.')sx=j,sy=i,sc=c[i][j];
    }
  dfs(sx,sy,sc,0);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>

using namespace std;

char inputs[10][10];
char tmp[10][10];
char ans[10][10];
int dx[] = {0, 1, 0, -1, 0};
int dy[] = {-1, 0, 1, 0, 0};

void through(int y, int x){
  ans[y][x] = '1';
  for(int i=0;i<5;i++){
    int ty = y + dy[i];
    int tx = x + dx[i];
    if(ty<0 || ty>=10) continue;
    if(tx<0 || tx>=10) continue;
    if(tmp[ty][tx] == '1')tmp[ty][tx] = '0';
    else tmp[ty][tx] = '1';
  }
}

bool check(){
  for(int i=1;i<10;i++){
    for(int j=0;j<10;j++){
      if(tmp[i-1][j] == '1') through(i, j);
    }
  }
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      if(tmp[i][j] == '1') return false;
    }
  }
  return true;
}

main(){
  int t;
  cin >> t;
  for(int tc=1;tc<=t;tc++){
    for(int i=0;i<10;i++){
      for(int j=0;j<10;j++){
	cin >> inputs[i][j];
      }
    }
    for(int i=0;i<(1<<10);i++){
      fill(ans[0], ans[10], '0');
      for(int j=0;j<10;j++){
	for(int k=0;k<10;k++){
 	  tmp[j][k] = inputs[j][k];
	}
      }
      for(int j=0;j<10;j++){
	if(i & (1<<j)) through(0, j);
      }
      /*for(int j=0;j<10;j++){
	cout << ans[0][j];
	}cout << endl;*/
      if(check()) break;
    }
    for(int i=0;i<10;i++){
      cout << ans[i][0];
      for(int j=1;j<10;j++){
	cout << ' ' << ans[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
const LL MOD = 998244353;
LL mod_pow(LL a, LL n) {
	if (n == 0) return 1;
	if (n % 2 == 0) {
		LL t = mod_pow(a, n / 2);
		return (t*t) % MOD;
	}
	return (a*mod_pow(a, n - 1)) % MOD;
}
LL fact[300001];
LL inv_fact[300001];
LL comb(LL n, LL k) {
	if (n < k) return 0;
	LL ret = fact[n];
	(ret *= inv_fact[k]) %= MOD;
	(ret *= inv_fact[n - k]) %= MOD;
	return ret;
}
int main() {
	int N;
	cin >> N;
	LL A, B, K;
	cin >> A >> B >> K;
	fact[0] = inv_fact[0] = 1;
	for (int i = 1; i <= N; i++) {
		fact[i] = fact[i - 1];
		inv_fact[i] = inv_fact[i - 1];
		(fact[i] *= i) %= MOD;
		(inv_fact[i] *= mod_pow(i, MOD - 2)) %= MOD;
	}
	LL ans = 0;
	for (int i = 0; i <= N; i++) {
		if (A*i > K) break;
		if ((K - A*i) % B != 0) continue;
		LL j = (K - A*i) / B;
		if (j > N) continue;
		LL add = comb(N, i);
		(add *= comb(N, j)) %= MOD;
		(ans += add) %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4992
import java.util.Scanner;

class Main{
public static void main(String[] args){

 Scanner s = new Scanner(System.in); 
	int W=s.nextInt();
	int H=s.nextInt();
	int x=s.nextInt();
	int y=s.nextInt();
	int r=s.nextInt();
	int F=0;
	
	if(x+r>W){F=1;}
	if(y+r>H){F=1;}
    if(r>x){F=1;}
	if(r>y){F=1;}
	if(F==0){System.out.println("Yes");}
	else{System.out.println("No");}
}
}
	


Measured memory_bytes: 26388
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x);
#define rl(x) scanf("%lld",&x);
#define pi(x) printf("%d",x);
#define pl(x) printf("%lld",x);
#define lfd() printf("\n");
#define sp() printf(" ");
int n;
int f[120][12];
int p[120][12];
int exist[12];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=10;j++){
			cin>>f[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<=10;j++){
			cin>>p[i][j];
		}
	}
	int res=-2147483647;
	for(int i=1;i<1024;i++){
		for(int j=1;j<=10;j++)
			exist[j]=(i>>(j-1))&1;
		int cand=0;
		for(int j=1;j<=n;j++){
			int c=0;
			for(int k=1;k<=10;k++)
				c+=(exist[k]&&f[j][k]);
			cand+=p[j][c];
		}
		res=max(res,cand);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n;
	cin >> n;
	double v[n];
	double sum = 0;
	REP(i, n) cin >> v[i];

	sort(v, v+n);

	sum = v[0];
	REP(i, n-1){
		sum = (sum+v[i+1])/2;
	}
	printf("%.10lf\n", sum);

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(void)
{
    std::string a;
    cin >> a;
    std::string b;
    cin >> b;
    ll r = 0;
    int c = (int)a.length();
    
    rep(i, c) {
        if (a.substr(i,1) != b.substr(i,1)) {
            r ++;
        }
    }

    cout << r;
}

Measured memory_bytes: 3864
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(0, A + 1):
  for j in range(0, B + 1):
    for k in range(0, C + 1):
      if i * 500 + j * 100 + k * 50 == X:
        ans += 1
        
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define is(s) freopen((const char*)(s),"r",stdin)
#define os(s) freopen((const char*)(s),"w",stdout)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
//#define x first
//#define y second

using namespace std;
int n,a;
int main()
{
	//is("input.txt");os("output.txt");
	cin>>n;
	rep(i,n)
	{
		cin>>a;
		if(a%2==0&&a%3!=0&&a%5!=0)
		{
			cout<<"DENIED"<<endl;
			return 0;
		}
	}
	cout<<"APPROVED"<<endl;
	return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    ll A,B,M;
    cin >> A >> B >> M;
    vector<ll> a(A);
    vector<ll> sa(A);
    vector<ll> b(B);
    vector<ll> sb(B);
    for (int i  = 0; i < A; ++i) {
        cin >> a[i];
        sa[i] = a[i];
    }
    for (int i = 0; i < B; ++i) {
        cin >> b[i];
        sb[i] = b[i];
    }
    sort(sa.begin(),sa.end());
    sort(sb.begin(),sb.end());

    ll x[M];
    ll y[M];
    ll c[M];
    for (int i = 0; i < M; ++i) {
        cin >> x[i] >> y[i] >> c[i];
    }
    ll m = sa[0] + sb[0];
    for (int i = 0; i < M; ++i) {
            m = min(m,a[x[i] - 1] + b[y[i] - 1] - c[i]);
    }
    cout << m << endl;

}


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

adj = [[] for i in range(N)]
for i in range(N - 1):
    a, b, c = map(int, input().split())
    adj[-a].append((b, c))
    adj[-b].append((a, c))

Q, K = map(int, input().split())
query = [tuple(map(int, input().split())) for i in range(Q)]

# dist[-i]:頂点Kから頂点iまでの距離
dist = [-1 for i in range(N)]
dist[-K] = 0

# 幅優先探索（キュー）
from collections import deque
queue = deque()
queue.append(K)

while queue:
    v = queue.popleft()
    for nxt, c in adj[-v]:
        if dist[-nxt] == -1:
            dist[-nxt] = dist[-v] + c
            queue.append(nxt)

for x, y in query:
    print(dist[-x] + dist[-y])


Measured memory_bytes: 57204
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N ,c = 0 ,max = -1;
    in >> N;
 
    vector<ll> H(N);

    REP(i, N){
        in >> H[i];
    }

    REP(i,N){
        if(max <= H[i]){
            c++;
            max = H[i];
        }
    }

    out << c << endl;



}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int checkA = 0;
		while(s.charAt(checkA) != 'A') {
			checkA++;
		}
		int startA = checkA;

		int checkZ = s.length() - 1;
		while(s.charAt(checkZ) != 'Z') {
			checkZ--;
		}

		int lastZ = checkZ;

		int ans = lastZ - startA + 1;
		System.out.println(ans);

	}

}

Measured memory_bytes: 26576
using System;
using System.Collections.Generic;

namespace abc163_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();
      var A = CIn.ReadIntArray(N - 1);
      var ans = new int[N];

      for (int i = 0; i < N - 1; i++)
      {
        ans[A[i] - 1]++;
      }

      Console.WriteLine(string.Join("\n", ans));
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 48496
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back
#define fi first
#define be begin()
#define en end()
#define se second

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int N;
  cin>>N;
  vector<int> dp(N+1,INFint);
  dp[0] = 0;
  for (int i(1);i<=N;i++){
    dp[i] = dp[i-1] + 1;
    int tmp6(6),tmp9(9);
    while (i - tmp6 >= 0){
      dp[i] = min(dp[i],dp[i-tmp6] + 1);
      tmp6 *= 6;
    }
    while (i - tmp9 >= 0){
      dp[i] = min(dp[i],dp[i-tmp9] + 1);
      tmp9 *= 9;
    }
  }
  cout << dp[N] << endl;
  return 0;
}



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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    vector<int> count(N,0);

    for (int i=0; i<M; i++){
        cin >> a.at(i) >> b.at(i);
    }

    for (int m=0; m<M; m++){
        int found=0;
        for (int n=0; n<N; n++){
            if (a.at(m) == n+1){
                count.at(n)++;
                found++;
            }
            if (b.at(m) == n+1){
                count.at(n)++;
                found++;
            }
            if (found == 2) break;
        }
    }

    for (int n=0; n<N; n++){
        cout << count.at(n) << endl;
    }

}

Measured memory_bytes: 256
def insertionSort(A, n, g):
    local_cnt = 0
    for i in range(g, n):
        # print(i, local_cnt)
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            # print(i, j, local_cnt)
            A[j + g] = A[j]
            j -= g
            local_cnt += 1
        A[j + g] = v
    return A, local_cnt

def shellSort(A, n):
    cnt = 0
    m = 1
    G = []
    
    h = 1
    while (h < n // 3):
        h = h * 3 + 1
        m += 1

    # print(f'm: {m}')

    while True:
        G.append(h)
        if h == 1:
            break
        h //= 3

    # print(f'G: {G}')
    
    for i in range(m):
        ans = insertionSort(A, n, G[i])
        # print(ans)
        A = ans[0]
        cnt += ans[1]

    return m, G, A, cnt


n = int(input())
A = [int(input()) for _ in range(n)]

m, G, A, cnt = shellSort(A, n)

print(m)
print(' '.join(str(g) for g in G))
print(cnt)
for a in A:
    print(a)


Measured memory_bytes: 45524
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx,tune=naive")
//#pragma GCC diagnostic ignored "-W"
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define INF 2000000000
#define PI 3.1415926535897932384626
const ll MOD=1e9+7;
string in[100005];
int main(){
        int n;
        //cin.tie(0);
        //ios::sync_with_stdio(false);
        while(cin>>n){
                F(i,0,n){
                        string tmp;
                        cin>>tmp;
                        sort(tmp.begin(),tmp.end());
                        in[i]=tmp;
                }
                sort(in,in+n);
                in[n]="a";
                n++;
//              F(i,0,n) cout<<in[i]<<"\n";
                ll ans=0;
                F(i,0,n){
                        F(j,i+1,n) if(in[i]!=in[j]){
                                j--;
                                ll diff=j-i;
                                ans+=(diff+1)*diff/2;
//                              printf("i:%d j:%d\n",i,j);
                                i=j;
                                break;
                        }
                }
                printf("%lld\n",ans);
        }
}

Measured memory_bytes: 5760
using System;

namespace ABC170A
{
    class Program
    {
        static void Main(string[] args)
        {
            var aa = Console.ReadLine().Split(" ");
            int[] x = new int[5];
            for (int i = 0; i <= 4; i++)
            {
                x[i] = int.Parse(aa[i]);
                if (x[i] == 0)
                    Console.WriteLine(i+1);
            }
        }
    }
}


Measured memory_bytes: 17896
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n==0){
		cout<<0;
		return 0;
	}
	string s;
	while(n!=1){
		if(abs(n)%2){
			s+='1';
			n=(n-1)/(-2);
		}
		else{
			s+='0';
			n/=(-2);
		}
	}
	reverse(s.begin(),s.end());
	cout<<1<<s;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        String t = scan.next();
        int ans = t.length();
        for (int i = 0; i + t.length() - 1 < s.length(); i++) {
            int tem = 0;
            for (int j = 0; j < t.length(); j++) {
                if (s.charAt(i + j) != t.charAt(j)) tem++;
            }
            ans = Math.min(ans, tem);
        }
        System.out.println(ans);
    }
}


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

int main() {
  long long a,b,k;
  cin >> a >> b >> k;
  if(k <= a) cout << a-k << " " << b <<  endl;
  else if(k >= a && k-a <= b) cout << 0 << " " << b-(k-a) << endl;
  else cout << 0 << " " << 0 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
map<int,int>mp;
vector<int>vec;

int n;
cin >> n;
for(int i=0; i<n; i++)
{
    int val;
    cin >> val;
    if(!mp[val])
        vec.push_back(val);
    mp[val]++;
}

int cnt = 0;
for(int i=0; i<vec.size(); i++)
{
    if(mp[vec[i]]%2==1)
        mp[vec[i]] = 1;
    else mp[vec[i]] = 2,cnt++;
}

//cout << cnt << endl;
if(cnt%2==0)
    cout << vec.size() << endl;
else
{
    cout << vec.size() - 1 << endl;
}


}


Measured memory_bytes: 8304
s = list(input())
n = len(s)
k = int(input())
ans = 0
if s.count(s[0]) == n:
    ans = (n * k) // 2
else:
    c = 1
    for i in range(n - 1):
        if s[i] == s[i + 1]:
            c += 1
        else:
            ans += c // 2
            c = 1
    ans += c // 2
    ans *= k
    if s[0] == s[n - 1]:
        c1 = 0
        c2 = 0
        for i in range(n):
            if s[i] == s[0]:
                c1 += 1
            else:
                break
        for i in range(n - 1, -1, -1):
            if s[i] == s[n - 1]:
                c2 += 1
            else:
                break
        if not c1 // 2 + c2 // 2 == (c1 + c2) // 2:
            ans += k
            ans -= 1
print(ans)

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

int t[100010], x[100010], y[100010];

int main() {
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> t[i] >> x[i] >> y[i];
  
  t[0] = 0; x[0] = 0; y[0] = 0;
  for (int i = 1; i <= N; i++) {
    if (abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]) <= t[i] - t[i - 1] && (abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]) - t[i] - t[i - 1]) % 2 == 0) continue;
    cout << "No" << endl;
    return 0;
  }
  
  cout << "Yes" << endl;
}

Measured memory_bytes: 1408
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b = map(int, input().split())
    print("+" if a + b == 15 else "*" if a * b == 15 else "x")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)a;i<=(sign)b;++i)
#define Fordown(i,a,b) for(register sign i=(sign)a;i>=(sign)b;--i)
const int N=2e5+5;
bool cmax(sign &a,sign b){return (a<b)?a=b,1:0;}
bool cmin(sign &a,sign b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
void file()
{
	#ifndef ONLINE_JUDGE
		freopen("test.in","r",stdin);
		freopen("test.out","w",stdout);
	#endif
}
map<int,int>mp;
int n,m;
void init()
{
	int x;
	n=read<int>();
	For(i,1,n)
	{
		x=read<int>();
		++mp[x];
	}
	m=read<int>();
	For(i,1,m)
	{
		x=read<int>();
		--mp[x];
		if(mp[x]<0){printf("NO\n");return;}
	}
	printf("YES\n");
}
int main()
{
	//file();
	init();
	return 0;
}


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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    for(ll i = 0; i < n; i++) cin >> a[i];
    for(ll i = 0; i < n; i++) cin >> b[i];
    for(ll i = 0; i < n; i++) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    ll ans = 0;
    for(ll part : b){
        ll u = c.end() - upper_bound(c.begin(), c.end(), part);
        ll l = lower_bound(a.begin(), a.end(), part) - a.begin();
        ans += u*l;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5592
#include <bits/stdc++.h>
#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////

int n,m,a[1100],c[1100];
int dp[10000];
signed main(){
  cin>>n>>m;

  rep(i,m){
    int b;
    cin>>a[i]>>b;
    rep(j,b){
      int cc;cin>>cc;cc--;
      c[i] |= (1<<cc);
    }
  }

  rep(i,10000)dp[i] = INF;
  dp[0] = 0;

  rep(bit,1<<n){
    rep(i,m){
      chmin(dp[bit | c[i]], dp[bit] + a[i]);
    }
  }
  cout << (dp[(1<<n)-1] == INF ? -1 : dp[(1<<n)-1]) << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n,a,b,ans;
int fa=0,fb=0;
signed main(){
	cin>>n;
	rep(i,n){
		string s;
		cin>>s;
		rep(j,s.size()-1){
			if(s[j]=='A'&&s[j+1]=='B')ans++;
		}
		int cnt=0;
		if(s[0]=='B'){
			b++;
			cnt++;
		}
		if(s[s.size()-1]=='A'){
			a++;
			cnt++;
		}
		if(cnt==1)fb=1;
		if(cnt==2)fa=1;
	}
	
	if((fa&&!fb)||min(a,b)==n)ans--;
	cout<<min(a,b)+ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int M, K;
    cin >> M >> K;
    if((1 << M) <= K) {
        cout << -1 << endl;
        return 0;
    }
    if(M == 0) {
        cout << 0 << " " << 0 << endl;
        return 0;
    }
    if(M == 1) {
        if(K == 1) {
            cout << -1 << endl;
        } else {
            cout << "0 0 1 1" << endl;
        }
        return 0;
    }
    cout << K;
    for(int i = 0; i < (1 << M); i++) {
        if(i == K) continue;
        cout << " " << i;
    }
    cout << " " << K;
    for(int i = (1 << M) - 1; i >= 0; i--) {
        if(i == K) continue;
        cout << " " << i;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1792
l=list(input())
l.reverse()
s="".join(l)

for i in range(len(s)):
    s=s.replace(s[0],"",1)
    s1=s[:(len(s)//2)]
    s2=s[(len(s)//2):]
    if s1==s2:
        print(2*len(s1))
        exit()


Measured memory_bytes: 38256
#include <iostream>

char Judge(int m,int f,int r)
{
    if(m==-1||f==-1){
        return 'F';
    }else if(m+f>=80)
    {
        return 'A';
    }else if(m+f>=65)
    {
        return 'B';
    }else if(m+f>=50)
    {
        return 'C';
    }else if(m+f>=30&&r>=50)
    {
        return 'C';
    }else if(m+f>=30)
    {
        return 'D';
    }else
    {
        return 'F';
    }

}

int main()
{
    int m,f,r;
    while(true)
    {
        std::cin>>m>>f>>r;
        if(m==-1&&f==-1&&r==-1){break;}
        std::cout<<Judge(m,f,r)<<std::endl;
    }


    return 0;
}




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

using namespace std ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	int n ;
	cin>>n ;
	int arr[n] , arr2[n] ;
	for(int i = 0 ; i < n ; ++i)
		cin>>arr[i] ;
	for(int i = 0 ; i < n ; ++i)
		cin>>arr2[i] ;
	int cnt = 0 ;
	set< pair<int , int> >s ;
	set< pair<int , int> >::iterator it ;
	pair<int , int>p ;
	for(int i = 0 ; i < n ; ++i)
		s.insert({arr[i] , i}) ;
	for(int i = 0 ; i < n ; ++i)
	{
		if(cnt == n-2)
			break ;
		p = *s.begin() ;
		if(p.first > arr2[i])
			return cout<<"No\n" , 0 ;
		it = s.lower_bound({arr2[i]+1 , -1}) ;
		it-- ;
		p = *it ;
		if(p.first != arr[i])
		{
			cnt++ ;
			s.erase({arr[i] , i}) ;
			arr[p.second] = arr[i] ; 
			arr[i] = p.first ; 
			s.erase(p) ;
			s.insert({arr[p.second] , p.second}) ;
			continue ;
		}
		else
			s.erase({arr[i] , i}) ;
	}
	for(int i = 0 ; i < n ; ++i)
	{
		if(arr[i] > arr2[i])
			return cout<<"No\n" , 0 ;
	}
	return cout<<"Yes\n" , 0 ;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
    ll a;
    cin>>a;
    cout<<3*a*a<<endl;
}
   



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
typedef struct block{
    char c;
    int num;
}block;
char s[1000001];
block b[1000001];
int n=0,count=0,i,ans=0,l;
int main(){
    scanf("%s",s);
    b[0].c=s[0];
    l=strlen(s);
    for (i=0; i<l; i++) {
        if (s[i]!=b[n].c) {
            b[n++].num=count;
            count=0;
            b[n].c=s[i];
        }
        count++;
    }
    b[n].num=count;
    for (i=1; i<n; i++) {
        if (b[i].c=='O'&&b[i-1].c=='J'&&b[i+1].c=='I'&&b[i].num<=b[i-1].num&&b[i].num<=b[i+1].num&&b[i].num>ans) {
            ans=b[i].num;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 9328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    string S;
    cin>>S;
    int y,m,d;
    y=(S.at(0)-'0')*1000+(S.at(1)-'0')*100+(S.at(2)-'0')*10+(S.at(3)-'0');
    m=(S.at(5)-'0')*10+(S.at(6)-'0');
    d=(S.at(8)-'0')*10+(S.at(9)-'0');
    if(make_tuple(y,m,d)<=make_tuple(2019,4,30)){
        cout<<"Heisei"<<endl;
    }
    else cout<<"TBD"<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a!=b&&b!=c&&a!=c){
        cout << "No\n";
    }
    else if(a==b&&b==c&&a==c){
        cout <<"No\n";
    }
    else
        cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String argv[]) throws IOException {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);
		StringBuffer sb = new StringBuffer(br.readLine());
		System.out.println(sb.reverse().toString());
	}

}

Measured memory_bytes: 23732
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<complex>
using namespace std;
typedef long long int llint;
int main(){
	int n;
	cin >> n;
	int a, b, c, d;
	a = n % 10;
	n /= 10;
	b = n % 10;
	n /= 10;
	c = n % 10;
	n /= 10;
	d = n;
	if (a == b&&b == c){
		cout << "Yes" << endl;
	}
	else if (b == c&&c == d){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())

lis = []

for _ in range(n):
    lis.append(int(input()))

lis.sort()

min = 10**10
for i in range(len(lis)-k+1):
    dist = lis[i+k-1] - lis[i]
    if min > dist: min = dist
print(min)


Measured memory_bytes: 7444
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <numeric>
#include <cmath>

#define rep(i, n) for(int i = 0;i < (int)(n); i++)
#define pb push_back
typedef long long ll;

using namespace std;

ll count(ll num){
    ll cnt = 0;
    while(num != 0){
        num /= 10;
        cnt++;
    }
    return cnt;

}

int main() {
    ll min1 = 9999999999999;
    ll n;
    cin >> n;
    for(ll i = 1; (i * i)<= n; i++){
        if(n % i == 0){
            min1 = max(count(i),count(n/i));
        }
    }
    cout << min1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
  string st;
  vector<pair<double,string> >v;
  while(n--){
    int p,a,b,c,d,e,f,s,m;
    cin>>st>>p>>a>>b>>c>>d>>e>>f>>s>>m;
    v.push_back(make_pair(-(double)(s*f*m-p)/(a+b+c+(d+e)*m),st));
  }sort(v.begin(),v.end());
  for(int i=0;i<v.size();i++){
    cout<<v[i].second<<endl;
  }
  cout<<"#"<<endl;
}
}

Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
using namespace std;
using int64 = long long;
#define int int64

signed main(){
  int sx,sy,tx,ty;cin>>sx>>sy>>tx>>ty;
  
  cout<<string(ty-sy,'U')<<string(tx-sx,'R')<<string(ty-sy,'D')<<string(tx-sx,'L');
  cout<<"L"<<string(ty-sy+1,'U')<<string(tx-sx+1,'R')<<"DR"<<string(ty-sy+1,'D')<<string(tx-sx+1,'L')<<"U"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, a[114514];
bool bl = false;
vector<pair<int, int>> ta;

signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		bool b = true;
		if (ta.size() > 3) {
			cout << "No" << endl;
			return 0;
		}
		rep(j, ta.size()) {
			if (ta[j].first == a[i]) {
				b = false;
				ta[j].second++;
			}
		}
		if (b)ta.push_back({ a[i],1 });
		if (a[i])bl = true;
	}
	if (!bl) {
		cout << "Yes" << endl;
		return 0;
	}
	sort(all(ta));
	if (ta[0].first == 0 && ta[0].second * 2 == ta[1].second)cout << "Yes" << endl;
	else if ((n % 3)!=0 || ta.size() != 3 || ta[0].second != ta[1].second || ta[0].second != ta[2].second || ta[1].second != ta[2].second)cout << "No"<< endl;
	else if ((ta[0].first ^ ta[1].first) != ta[2].first || (ta[0].first^ ta[2].first) != ta[1].first || (ta[1].first ^ ta[2].first) != ta[0].first)cout << "No"<< endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    set<int> card;
    int ex = 0;
    rep(i, N) {
        int A;
        cin >> A;
        if (card.count(A) == 0) {
            card.insert(A);
        }
        else {
            ex++;
        }
    }

    cout << (ex % 2 == 0 ? (int)card.size() : (int)card.size() - 1) << endl;
    return 0;
}

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

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

  int num = N / 100;
  int fraction = N - num * 100;

  for (int i = 0; i < num; i++)
  {
    if (fraction <= 5)
    {
      cout << 1 << endl;
      return 0;
    }
    else
      fraction -= 5;
  }
  cout << 0 << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException
	{	
		Scanner sc = new Scanner(System.in);
		int candies_a = 0;
		int candies_b = 0;
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		a[0] = sc.nextInt();
		for(int i=1;i<n;i++)
		{	int tmp = sc.nextInt();
			a[i] = a[i-1]+tmp;
			//candies_a+=tmp;
		}
		//candies_b+=a[0];
		b[0] = sc.nextInt();
		for(int i=1;i<n;i++)
		{
			int tmp = sc.nextInt();
			b[i] = b[i-1]+tmp;
			//candies_b +=b[i];
		}
		//for(int i =0;i<n;i++)
			//System.out.println(a[i]+" "+b[i]);
		
		int candies =a[0]+b[n-1];
		//candies = a[0];
		
		for(int i=1;i<n;i++)
		{
			int tmp = a[i]+(b[n-1]-b[i-1]);
			if(tmp>candies)
			{
				candies = tmp;
			}
		}
		System.out.print(candies);
	}
	
}


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

int main() {
  int n, m;
  cin>>n>>m;
  pair<int, int> s[n];
  for (int i=0; i<n; i++) {
    cin>>s[i].first>>s[i].second;
  }
  pair<int, int> c[m];
  for (int i=0; i<m; i++) {
    cin>>c[i].first>>c[i].second;
  }
  for (int i=0; i<n; i++) {
    int dist = 1e9;
    int ans = -1;
    for (int j=0; j<m; j++) {
      int j_dist = abs(s[i].first - c[j].first) + abs(s[i].second - c[j].second);
      if (j_dist < dist) {
        ans = j;
        dist = j_dist;
      }
    }
    cout<<ans+1<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
   int N,K;
   cin >> N >>K;
   int L=0;
   vector<int> vec(N);

   for(int i=0;i<N;i++){

       cin >> vec.at(i);


   }
   sort(vec.begin(),vec.end());
   reverse(vec.begin(),vec.end());

   for (int k=0;k<K;k++){
     L+=vec.at(k);
   }
   cout <<L<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(a) cout<<#a<<":"<<a<<endl;
const ll INF=0x3f3f3f3f;
const ll N=1e6+7;
const ll mod=1e9+7;
ll maxn,minn;
ll T,n,m;
ll W[N];
ll V[N];
ll dp[N];

struct aa{
	ll l,r,v;
}ans[N];

void build_tree(ll node,ll start,ll end){
	ans[node].l=start;
	ans[node].r=end;
    if(start==end){
        ans[node].v=0;
        return ;
    }
    ll left_node=2*node;
    ll right_node=2*node+1;
    ll mid=(start+end)>>1;
    build_tree(left_node,start,mid);
    build_tree(right_node,mid+1,end);
    ans[node].v=max(ans[left_node].v,ans[right_node].v);
}

void update(ll node,ll p,ll v){
    if(ans[node].l==ans[node].r){
        ans[node].v=v;
        return ;
    }
    ll mid=(ans[node].l+ans[node].r)>>1;
    ll left_node=2*node;
    ll right_node=2*node+1;
    if(p<=mid){
        update(left_node,p,v);
    }
    else{
        update(right_node,p,v);
    }
    ans[node].v=max(ans[left_node].v,ans[right_node].v);
}
ll query(ll node,ll l,ll r){
    if(r<ans[node].l||l>ans[node].r){
        return 0;
    }
    else if(ans[node].l>=l&&ans[node].r<=r){
        return ans[node].v;
    }
	ll mid=(ans[node].l+ans[node].r)>>1;    
	ll left_node=2*node;
	ll right_node=2*node+1;
	ll sum_left=query(left_node,l,r);
	ll sum_right=query(right_node,l,r);
	return max(sum_left,sum_right);
}

int main(){
	cin>>n;
	for(ll i=1;i<=n;i++){
		scanf("%lld",W+i);
	}
	for(ll i=1;i<=n;i++){
		scanf("%lld",V+i);
	}
	build_tree(1,1,n);
	ll a;
	for(ll i=1;i<=n;i++){
		a=query(1,1,W[i]);
		dp[i]=V[i]+a;
		maxn=max(maxn,dp[i]);
		update(1,W[i],dp[i]);
	}
	cout<<maxn<<endl;
	
	return 0;
}





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

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

    vector<char>a;
    while (n > 0)
    {   
        n -= 1;
        ll x = n % 26;
        a.push_back('a' + x);
        n /= 26;
    }
    
    reverse(a.begin(), a.end());

    string ans = "";
    rep(i, a.size()) {
        ans += a[i];
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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


signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, K, X, Y; cin >> N >> K >> X >> Y;
    cout << min(N, K) * X + max(N-K, 0) * Y << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9

string S;

void solve() {
	cin >> S;
	int N = S.size();

	ll cnt = 1;
	ll cntA = 0;     
	ll cntAB = 0;    
	ll cntABC = 0; 

	for (int i = 0; i < N; i++) {
		switch (S[i]) {
		case 'A':
			cntA += cnt;
			cntA %= modulo;
			break;

		case 'B':
			cntAB += cntA;
			cntAB %= modulo;
			break;

		case 'C':
			cntABC += cntAB;
			cntABC %= modulo;
			break;

		case '?':
			cntABC = (3 * cntABC + cntAB) % modulo;
			cntAB = (3 * cntAB + cntA) % modulo;
			cntA = (3 * cntA + cnt) % modulo;
			cnt = 3 * cnt % modulo;
			break;
		}
	}

	cout << cntABC << endl;
}

int main() {
	
	solve();

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
string S;
int main() {
    cin >> S;
    vector<bool> alp(26, false);
    int slen = S.length();
    for(int i = 0; i < slen; ++i) {
        alp.at(S.at(i)-97) = true;
    }

    for(int i = 0; i < 26; ++i) {
        if(!alp.at(i)) {
            cout << (char)(97+i) << endl;
            return 0;
        }
    }

    cout << "None" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<LINE<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<LINE<<")"<<endl;}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;

long double dist(ll x0, ll y0, ll x1, ll y1)
{
    return sqrt((x0-x1)*(x0-x1) + (y0-y1)*(y0-y1));
}

int main()
{
    ll N;
    cin >> N;
    vll x(N);
    vll y(N);
    vll cities(N);
    rep(i, 0, N) {
        cin >> x[i] >> y[i];
        cities[i] = i;
    }
    long double sum = 0.0;
    ll cnt = 0;
    do {
        rep(i, 0, N-1) {
            sum += dist(x[cities[i]], y[cities[i]], x[cities[i+1]], y[cities[i+1]]);
        }
        ++cnt;
    } while (next_permutation(cities.begin(), cities.end()));
    long double avg = sum / cnt;
    printf("%.10Lf\n", avg);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define repr(i, a, n) for (ll i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  ll n, ans = 0;
  string s;

  cin >> n >> s;
  rep(i, 0, s.size()) {
    map<ll, ll> mp;
    ll cnt = 0;
    rep(j, 0, i) { mp[s[j] - 'a'] = 1; }
    rep(j, i, s.size()) {
      if (mp[s[j] - 'a'] == 1) mp[s[j] - 'a'] = 2;
    }
    rep(j, 0, 26) {
      if (mp[j] == 2) {
        cnt++;
      }
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
}

int main() {
  // 標準入出力高速化
  // CとC++の入出力出力を非同期
  // 小数を10進数表示
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll a,b,x;
    cin >> a >> b >> x;
    cout << ((a+b>=x && a<=x)?"YES":"NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 long long f[100005];
int main(){
    int n,q;
    cin>>n>>q;
    char a[100005];

    for(int i=1;i<=n;i++){
        cin>>a[i];
        if((a[i]=='C')&&(a[i-1]=='A')){
            f[i]=f[i-2]+1;
        }
        else{
            f[i]=f[i-1];
        }
    }
    for(int i=1;i<=q;i++){
        int x,y;
        cin>>x>>y;
        if((a[x-1]=='A')&&(a[x]=='C'))
            cout<<f[y]-f[x]<<endl;

        else{
            cout<<f[y]-f[x-1]<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1664