akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
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; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n; cin >> n;
    cout << n * (n - 1) / 2 << endl;
    
}

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

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

int main() {
    int a[10][10];
    memset(a, 0, sizeof(a));
    int x,y,s;
    while(scanf("%d,%d,%d", &x, &y, &s) != EOF) {
        a[x][y]++;
        // if(x == 0 && y == 0 && s == 0) break;
        if(s == 1) {
            if(x + 1 <= 9) a[x + 1][y]++;
            if(x - 1 >= 0) a[x - 1][y]++;
            if(y + 1 <= 9) a[x][y + 1]++;
            if(y - 1 >= 0) a[x][y - 1]++;
        }
        else if(s == 2) {
            rep(i,0,8) {
                if(x + dx[i] < 0) continue;
                else if(x + dx[i] > 9) continue;
                else if(y + dy[i] < 0) continue;
                else if(y + dy[i] > 9) continue;
                else a[x + dx[i]][y + dy[i]]++;
            }
        }
        else {
            rep(i,0,8) {
                if(x + dx[i] < 0) continue;
                else if(x + dx[i] > 9) continue;
                else if(y + dy[i] < 0) continue;
                else if(y + dy[i] > 9) continue;
                else a[x + dx[i]][y + dy[i]]++;
            }
            if(x + 2 <= 9) a[x + 2][y]++;
            if(x - 2 >= 0) a[x - 2][y]++;
            if(y + 2 <= 9) a[x][y + 2]++;
            if(y - 2 >= 0) a[x][y - 2]++;
        }
    }

    int m_point = 0;
    int max_num = 0;
    rep(i,0,10) rep(j,0,10) {
        if(a[i][j] == 0) m_point++;
        max_num = max(max_num, a[i][j]);
    }
    cout << m_point << endl;
    cout << max_num << endl;

    return 0;
}

Measured memory_bytes: 1208
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 2e9+7;

int main() {
    int n, k;
    cin >> n >> k;
    vi x(n);
    rep(i, n) cin >> x[i];
    int min_val = INF;
    int val;
    for(int i = 0; i + k - 1 < n; i++) {
        val = 0;
        int l = x[i];
        int h = x[i + k - 1];
        if (l < 0) val += -l;
        if (h > 0) val += h;
        if (l < 0 && h > 0) val += min(-l, h);
        min_val = min(min_val, val);
    }
    cout << min_val << endl;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline

MAX = 2*10**5+100
MOD = 10**9+7
fact = [0]*MAX #fact[i]: i!
inv = [0]*MAX #inv[i]: iの逆元
finv = [0]*MAX #finv[i]: i!の逆元
fact[0] = 1
fact[1] = 1
finv[0] = 1
finv[1] = 1
inv[1] = 1
    
for i in range(2, MAX):
    fact[i] = fact[i-1]*i%MOD
    inv[i] = MOD-inv[MOD%i]*(MOD//i)%MOD
    finv[i] = finv[i-1]*inv[i]%MOD

def C(n, r):
    if n<r:
        return 0
    if n<0 or r<0:
        return 0
    return fact[n]*(finv[r]*finv[n-r]%MOD)%MOD

H, W, N = map(int, input().split())
rc = [tuple(map(int, input().split())) for _ in range(N)]
rc.sort(key=lambda t: t[0]+t[1])
ans = C(H+W-2, H-1)
dp = [0]*N

for i in range(N):
    ri, ci = rc[i]
    dp[i] = C(ri+ci-2, ri-1)
    
    for j in range(i):
        rj, cj = rc[j]
        dp[i] -= dp[j]*C(ri-rj+ci-cj, ri-rj)
        dp[i] %= MOD
    
    ans -= dp[i]*C(H-ri+W-ci, H-ri)
    ans %= MOD

print(ans)

Measured memory_bytes: 49004
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    # https://atcoder.jp/contests/abc070/tasks/abc070_d
    # https://atcoder.jp/contests/abc070/submissions/11681543
    from heapq import heapify, heappop, heappush

    inf = 10 ** 17

    def dijkstra_heap(start, edge):
        # 始点から各頂点への最短距離(頂点番号:0~N-1)
        d = [inf] * N
        used = [False] * N
        d[start] = 0
        used[start] = True
        edgelist = []
        # a:重み(//), b:次の頂点(%)
        for a, b in edge[start]:
            heappush(edgelist, a * (10 ** 6) + b)

        while len(edgelist):
            # まだ最短距離が決まっていない頂点の中から最小の距離のものを探す
            minedge = heappop(edgelist)
            if used[minedge % (10 ** 6)]:
                continue
            node = minedge % (10 ** 6)
            d[node] = minedge // (10 ** 6)
            used[node] = True

            for e in edge[node]:
                if not used[e[1]]:
                    heappush(edgelist, (e[0] + d[node]) * (10 ** 6) + e[1])
        return d

    # N:頂点数 W:辺数
    N = int(input())
    W = N-1

    edge = [[] for i in range(N)]
    # edge[i] : iから出る道の[重み,行先]の配列
    for _ in range(W):
        x, y = map(int, input().split())
        edge[x - 1].append((1, y - 1))
        edge[y - 1].append((1, x - 1))

    fen = dijkstra_heap(0, edge)
    sun = dijkstra_heap(N-1, edge)
    f = 0
    s = 0

    for i in range(1, N-1):
        if fen[i] <= sun[i]:
            f += 1
        elif fen[i] > sun[i]:
            s += 1
    print('Fennec' if f > s else 'Snuke')


resolve()

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

int main() {
  long long res = 0;
  long long ma = 0;
  for (int i = 0; i < 5; ++i) {
    long long A;
    cin >> A;
    long long rem = A % 10;
	if (rem == 0) res += A;
    else {
      res += A + (10 - rem);
      ma = max(ma, 10 - rem);
    }
  }
  cout << res - ma << endl;
}


Measured memory_bytes: 3584
N = int(input())
L = sorted(list(map(int, input().split())))

ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if i==j or j==k:
                continue
            if (L[i] != L[j]) and (L[j] != L[k]):
                if L[i] + L[j] > L[k]:
                    ans += 1

print(ans)

Measured memory_bytes: 9200
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let N: i32 = read_line().parse().unwrap();
    let len = N.to_string().len() as u32;
    let mut ans = 0;
    let mut i = 1;
    while i < len {
        ans += 9 * 10_i32.pow(i-1);
        i += 2;
    }
    if len % 2 == 1 {
        ans += N - 10_i32.pow(len-1) + 1
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
const int MAXN = 16;
int n,A[MAXN];
vector<pair<int,int>> vec[MAXN];
int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> A[i];
        for(int k = 0; k < A[i]; k++){
            int p,t;
            cin >> p >> t;
            vec[i].push_back(make_pair(p-1,t));
        }
    }
    int maxx = 0;
    for(int msk = 0; msk < (1<<n); msk++){
        bool ck = true;
        for(int bit = 0; bit < n; bit++){
            if((1<<bit)&msk){
                bool ok = true;
                for(auto p : vec[bit]){
                    if((((msk>>p.first)&1)^p.second)==1){
                        ok = false;
                        break;
                    }
                }
                if(!ok){
                    ck = false;
                    break;
                }
            }
        }
        if(ck) maxx = max(maxx,__builtin_popcount(msk));
    }
    cout << maxx << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

// Convex Hull Trick for min query
template<typename T, typename U=__int128>
class ConvexHullTrick {
private:
  deque<pair<T,T>> data;
  bool check(const pair<T,T> &p3){
    auto &p1 = data[data.size()-2];
    auto &p2 = data[data.size()-1];
    return (U)(p2.fi-p1.fi)*(p3.se-p2.se) < (U)(p2.se-p1.se)*(p3.fi-p2.fi);
  }
public:
  ConvexHullTrick(){ }
  // additions of 'a' shold be NON-INCREASING
  void add(T a, T b){
    auto p = mp(a,b);
    while(data.size()>=2 && !check(p)) data.pop_back();
    data.push_back(p);
  }
  inline T val(int i, T x) {
    return data[i].fi*x + data[i].se;
  }
  // queries shold be NON-DECREASING
  T query(T x){
    while(data.size()>=2 && val(0, x) >= val(1, x)) data.pop_front();
    return val(0, x);
  }
  inline bool empty(){
    return data.empty();
  }
};

int main(){
  int n,T;
  cin>>n>>T;
  vector<pair<int, pair<int,int>>> v(n);
  rep(i,n) cin>>v[i].se.fi>>v[i].se.se>>v[i].fi;
  // <f,<t,p>>
  sort(all(v));

  vector<vector<long>> dp(n, vector<long>(T+1,0));
  vector<ConvexHullTrick<long>> cht(T+1);

  rep(i,n){
    long f = v[i].fi, t = v[i].se.fi, p = v[i].se.se;
    for(int j=T; j>=t; j--){
      if(j == t) dp[i][j] = p;
      else if(cht[j-t].empty()) continue;
      else dp[i][j] = -cht[j-t].query(f) + p - f*f;
      cht[j].add(-2*f, -(dp[i][j] - f*f));
    }
  }

  // rep(i,n){
  //   long f = v[i].fi, t = v[i].se.fi, p = v[i].se.se;
  //   for(int j=T; j>t; j--){
  //     for(int k=0; k<i; k++)
  //       dp[i][j] = max(dp[i][j], dp[k][j-t] + p - (f-v[k].fi)*(f-v[k].fi));
  //   }
  //   dp[i][t] = p;
  // }

  long ans = 0;
  rep(i,n) rep(j,T+1) ans = max(ans, dp[i][j]);

  cout << ans << endl;

  return 0;
}

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

int main()
{
	long long int n;
	cin>>n;
    //cout<<n<<endl;
	string s="";

	if(n==0) {cout<<"0"<<endl;}else{
	while(n!=0)
	{
		if(n%2==0)
		{
			n=n/(-2);
			s+="0";
		}
		else
		{
			n=(n-1)/-2;
			s+="1";
		}
	}
	for(int i=s.size()-1;i>=0;i--)
	{
		cout<<s[i];
	}
	cout<<endl;}
}

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

using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i < (n); --i)
#define all(x) (x).begin(), (x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n,m,a,b,cnt=0,ans=0;
    cin>>n>>m;
    vector<int> x(m);
    vector<vector<bool>> judge(m,vector<bool>(n,false));

    rep(i,0,m){
        cin>>a;
        rep(j,0,a){
            cin>>b;
            judge[i][b-1] = true;
        }
    }

    rep(i,0,m) cin>>x[i];

    rep(i,0,(1<<n)){
        bool on = true;
        rep(j,0,m){
            cnt = 0;
            rep(k,0,n){
                if((i>>k) & 1){
                    if(judge[j][k]) ++cnt;
                }
            }
            if(cnt % 2 != x[j]){
                on = false;
                break;
            }
        }
        if(on) ++ans;
    }

    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
 
         
        public static void main(String[] args) throws java.io.IOException{
            Scanner scan = new Scanner(System.in);
            boolean [] prime = new boolean[10000001];
            for(int i=3;i<=10000000;i+=2)prime[i]=true;
            int limit = (int)Math.sqrt(10000000);
            for(int i=3;i<=limit;i+=2){
            	if(prime[i]){
            		for(int j=i*i;j<=10000000;j+=i*2)prime[j]=false;
            	}
            }
            
            while(true){
            	int n= scan.nextInt();
            	if(n==0)break;
            	int ans =13;
               	if(n>=19){
            	for(int i=(n-19)/30;i>=0;i--){
            		if(prime[30*i+11]&&prime[30*i+13]&&prime[30*i+17]&&prime[30*i+19]){
            			ans = 30*i+19;
            			break;
            		}
            	}
               	}
            	System.out.println(ans);
            }
        }
}

Measured memory_bytes: 22000
#include <bits/stdc++.h> 
#include <functional> 
using namespace std;
typedef pair<int,int> pii;
#define fast   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define ld              long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define in              insert
#define ff              first
#define ss              second
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define rev             reverse
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << endl;
const ll inf = 1e18;  
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;

inline ll add(ll a,ll b) {return ((a % mod) + (b % mod)) % mod;}
inline ll sub(ll a,ll b) {return ((a % mod) - (b % mod) + mod) % mod;}
inline ll mul(ll a,ll b) {return ((a % mod) * (b % mod)) % mod;}
ll pwr(ll x,ll n){
    if(n == 0){
        return 1;
    }
    if(n&1){
        return mul(x, pwr(mul(x, x), (n - 1) / 2));
    } else {
        return pwr(mul(x, x), n / 2);
    }
}
ll modInv(ll n){ 
    return pwr(n, mod - 2); 
}
ll gcd(ll a,ll b) {
    if(b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

/**

 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */
void solve(){
    
}
int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll x,y,z,u;
    x=max(a,b)*max(c,d);
    y=max(a,b)*min(c,d);
    z=min(a,b)*max(c,d);
    u=min(a,b)*min(c,d);
    
    cout<<max(max(x,z),max(y,u));
   

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
#define mod 1000000007; 

 long long  accumulate(long long k){
  long long  times;
  times=0;
  for(long long i=k; i>0;i--){
    times+=i;
  }
  return times%mod;
 }
 
int main(){
 long long  n,k,count,count2,ans;
  count=0;
  count2=0;
  vector<long long > num;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    long long  tmp;
    cin>>tmp;
    num.push_back(tmp);
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(num[i]>num[j]){
        count++;
      }else if(num[i]<num[j]){
        count2++;
      }
    }
  }
  ans=(count*accumulate(k)+count2*accumulate(k-1))%mod;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
//	public static int N = 201;
	public static void main(String[] args) {
		int i,j,l;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int[] a = new int[n+1];
		HashMap<Integer, Integer> map = new HashMap<>();
		for (i = 2; i <= n; i++) {
			a[i] = parseInt(sc.next());
			if(map.get(a[i])==null) {
				map.put(a[i], 1);
			} else {
				map.put(a[i], map.get(a[i])+1);
			}
		}
		PrintWriter pw = new PrintWriter(out);
		for(i = 1; i <= n; i++) {
			Integer ii = map.get(i);
			pw.println(ii==null?0:ii);
		}
		pw.flush();
	}
}


Measured memory_bytes: 65196
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef pair<long long,long long> P;
//typedef pair<long long,P> P1;
//typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define se second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define rrep(i,x) for(long long i=x-1;i>=0;i--)
#define rrepn(i,x) for(long long i=x;i>1;i--)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())


#define ALL(v)  (v).begin(),(v).end()
//#define MAX(a,b) if(a>b)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))




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

#define pr printf
#define re return
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)



ll N;
ll sum;

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


	std::cin >> N;
	sum=0;
	
	pr("%lld",(N*(N-1))/2);
	re 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <cassert>
#include <map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define uniq(v) (v).erase(std::unique((v).begin(), (v).end()), (v).end())
constexpr long MOD = 998244353l;
long gcd(long a, long b) {return b % a ? gcd(b % a, a) : a;}
long lcm(long a, long b) {return a / gcd(a, b) * b;}
using namespace std;
using P = pair<long, long>;
using VP = vector<P>;

long digitsum(long a) {
    long ret = 0;
    while (a) {
        ret += a % 10;
        a /= 10;
    }
    return ret;
}

int main() {
    long n;
    cin >> n;
    long ans = 1e9;
    REPI(i,1,n) {
        ans = min(ans, digitsum(i) + digitsum(n - i));
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N;
  int arr[200];
  int have2[200]={0,};
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    scanf("%d",&arr[i]);
  }
  for(int i=0;i<N;i++){
    while(arr[i]%2==0){
      have2[i]++;
      arr[i]/=2;
    }
  }
  int min=987654321;
  for(int i=0;i<N;i++){
    if(min>have2[i]) min=have2[i];
  }
  printf("%d\n", min);
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	s = s + "AA";

	for (int i = 0; i < n; i++) {
		if (s[i] == s[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}

		if (s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}

	cout << "-1 -1" << endl;

	return 0;
}


Measured memory_bytes: 512
a, b, c, x, y = map(int, input().split())

if a+b > 2*c:
    if x<=y:
        if b>2*c:
            print(2*x*c+ (y-x)*2*c)
        else:
            print(x*2*c+(y-x)*b)
    else:
        if a> 2*c:
            print(2*y*c+(x-y)*2*c)
        else:
            print(y*2*c+(x-y)*a)
else:
    print(a*x+b*y)


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

int main(){
  int n;
  cin >> n;
  int ans = 1e5;
  rep(i,n){
    int j = n - i;
    auto sum = [](int k){
      int sum = 0;
      while (k != 0){
        sum += k % 10;
        k /= 10;
      }
      return sum;
    };
    int now = sum(i) + sum(j);
    if (now < ans) ans = now;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
const int maxn = 10;
const int maxe = 100;
int ecnt;
struct Edge{
    int to;
    int val;
    int nxt;
}edge[maxe];
int node[maxn];
void init()
{
    memset(node,-1,sizeof node);
    ecnt = 0;
}
void addedge(int from,int to,int val)
{
    edge[ecnt].nxt = node[from];
    edge[ecnt].to = to;
    edge[ecnt].val = val;
    node[from] = ecnt++;
}
int d[maxn];
int V;  //结点数
const int INF = 0x3f3f3f3f;
bool bellman_ford(int s){ //返回true代表有负环
    for(int i=0;i<V;++i)    d[i]=INF;
    d[s]=0;
    bool update;int now;
    for(int i=0;i<V;++i){
        update=false;
        for(int j=0;j<V;++j){
            now=node[j];
            while(now!=-1)
            {
                Edge &e=edge[now];
                if(d[e.to]>d[j]+e.val)
                {
                    d[e.to]=d[j]+e.val;
                    update=true;
                }
                now=e.nxt;
            }
        }
        if(!update) return false;
    }
    return true;
}
bool vis[maxn];
int D[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int m;
    V=10;
    while(cin>>m&&m)
    {
        init();
        int u,v,w;
        memset(vis,0,sizeof vis);
        while(m--)
        {
            cin>>u>>v>>w;
            addedge(u,v,w);
            addedge(v,u,w);
            vis[u]=vis[v]=true;
        }
        for(int i=0;i<10;++i)
        {
            if(!vis[i]) continue;
            D[i]=0;
            bellman_ford(i);
            for(int j=0;j<10;++j)
                if(vis[j])
                    D[i]+=d[j];
        }
        int sm=0;
        for(int i=1;i<10;++i)   if(vis[i]&&D[sm]>D[i])  sm=i;
        cout<<sm<<" "<<D[sm]<<endl;
    }
    return 0;
}



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

int main(){
  string S;
  cin>>S;
  int n=S.size();
  int ans=0;
  for(int i=0;i<n;i++){
    ans+=(S.at(i)+i)%2;
  }
  cout<<min(ans,n-ans)<<endl;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>

int
main(int argc, char **argv)
{
	int n;
	char s[10000 + 1];
	int i, ret;

	ret = scanf("%d", &n);
	ret = scanf("%s", s);

	for (i = 0; i < strlen(s); i++) {
		putchar('A' + (s[i] - 'A' + n) % 26);
	}
	return(0);
}


Measured memory_bytes: 128
def q77(N, a):
    i = 0
    for b in a:
        while True:
            b = b/2
            if not b.is_integer():
                break
            else:
                i += 1
    return i

N = int(input())
a = [int(i) for i in input().split()]

print(q77(N, a))

Measured memory_bytes: 4148
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> m(n);
  for (int i = 0; i < n; i++) {
    cin >> m[i];
  }
  sort(m.begin(), m.end());
  for (int i = 0; i < n; i++) {
    x -= m[i];
  }
  int c = 0;
  while (x >= 0) {
    c++;
    x -= m[0];
  }
  cout << n + c - 1 << endl;
  return 0;
}

Measured memory_bytes: 888
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

#define MAX_E 55
#define MAX_j 55

signed main() {
	int dp[MAX_E][MAX_j] = {};
	rep(i, 1, MAX_E)rep(j, 1, MAX_j) {
		dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1] + 1;
	}
	int T; cin >> T;
	rep(i, 0, T) {
		int N, E; cin >> N >> E;
		int ans = 0;
		rep(j, 0, MAX_j) {
			if (dp[E][j] >= N) {
				ans = j;
				break;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

c1 = list(str(input()))
c2 = list(str(input()))

l = [c1, c2]
ll = [[c2[2], c2[1], c2[0]] , [c1[2], c1[1], c1[0]]]

if l == ll:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 9028
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  
string S;
  cin>>S;
  if(S[0]=='7'||S[1]=='7'||S[2]=='7') {
cout<<"Yes"<<endl;
    
  }
else {
cout<<"No"<<endl;
}
}

Measured memory_bytes: 3524
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    int N;
    string S;
    cin>>N>>S;
    rep(i, S.length()){
        char orig=S[i];
        S[i]='A'+(orig-'A'+N)%26;
    }
    cout<<S<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<map>
using namespace std;
 
#define sz(x) (int)(x.size())
#define fr(i,a,b) for(int i=a;i<b;++i)
#define fdr(i,a,b) for(int i=b-1;i>=a;--i)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
///////////////////////
int const N = 1e5+ 41;
map<int, int> a;

void solve(){
	int n;
	cin >> n;
	fr(i, 0, n){
		int v;
		cin >> v;
		++a[v];
	}
	int ans = 0;
	for(int i=0;i<=N;++i){
		ans = max(ans, a[i] + a[i-1] + a[i+1]);
	}
	cout << ans << endl;
}
 
int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
 
	solve();
 
 
 
	return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>
#include<algorithm>
#define INF 810114514
#define MAX 1000000

int dp[MAX];
int dp_odd[MAX];
int main(){
    dp[0] = 0;
    dp_odd[0] = 0;
    for(int i=1; i<MAX; i++){
        dp[i] = MAX+1;
        dp_odd[i] = MAX+1;
    }
    for(int n=1; n*(n+1)*(n+2)/6 < MAX; n++){
        int p = n*(n+1)*(n+2)/6;
        for(int i=0; i+p < MAX; i++){
            dp[i+p] = std::min(dp[i+p], dp[i] + 1);
            if(p&1) dp_odd[i+p] = std::min(dp_odd[i+p], dp_odd[i] + 1);
        }
    }
    int x;
    scanf("%d",&x);
    while(x != 0){
        printf("%d %d\n", dp[x], dp_odd[x]);
        scanf("%d",&x);
    }

    return 0;
}

Measured memory_bytes: 10400
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

int main() {
  ll N,K;
  cin >> N >> K;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  ll ans = 0;
  ll ksum = (ll)((K-1) * K) / 2;
  ksum %= MOD;
  rep(i,N) {
    ll count = 0;
    ll tmp = 0;
    rep(j,N) {
      if(A[i] > A[j]) {
        count++;
      }
    }
    srep(j,i,N) {
      if(A[j] < A[i]) {
        tmp++;
      }
    }
    ans += count * ksum;
    ans %= MOD;
    ans += tmp * K;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define PI 3.14159265358979323846
double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}

using namespace std;

void solve(){
	int x,y;
  cin>>x>>y;
  f(i,x+1){
    if((4*i)+(2*(x-i))==y){
      cout<<"Yes";
      return;
    }
  }
  cout<<"No";
	//cout<<tick()<<endl;	
}

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  int t;
  // cin>>t;
  // while(t--)
    solve();
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n,x,d;
    cin>>n>>x>>d;
    if(d==0){
      	if(x==0)cout<<1<<"\n";
     	else cout<<n+1<<"\n";
      	return 0;
    }
    if(d<0){
      x*=-1;
      d*=-1;
    }
    unordered_map<ll,vector<pair<ll,ll> > >rd;
    for(ll k=0;k<=n;k++){
        ll low=x*k+d*(k*(k-1)/2);
        ll up=x*k+d*((n-1)*k-k*(k-1)/2);
        if(low<=up){
          	ll rem=low%abs(d);
	    	if(rem<0)rem+=abs(d);
          	low-=rem,up-=rem;
		rd[rem].push_back(make_pair(low/abs(d)-1,up/abs(d)));
        }
    }
    ll ans=0;
    for(auto it:rd){
        vector<pair<ll,ll> >vec=it.second;
        sort(vec.begin(),vec.end());
        ll r=-8e18;
        for(auto v:vec){
            ans+=max(0LL,v.second-max(r,v.first));
            r=max(r,v.second);
        }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 17864
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

void Eratosthenes(int n,vi& primes)
{
	primes.assign(n+1,0);
	repi(i,2,n+1)
		primes[i]=1;
	repi(i,2,n+1){
		if(primes[i]==0)
			continue;
		for(int j=i+i;j<=n;j+=i)
			primes[j]=0;
	}
}

int main()
{
	vi isPrimes;
	Eratosthenes(50021,isPrimes);
	vi primes;
	rep(i,isPrimes.size())
		if(isPrimes[i])
			primes.push_back(i);
	
	for(int n;cin>>n;){
		int a=*(lower_bound(allof(primes),n)-1);
		int b=*upper_bound(allof(primes),n);
		cout<<a<<" "<<b<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
const ll MD = 1000000007;

/* sample input

*/

int main()
{
	string str;
	cin >> str;
	bool flug = true;
	int times = 0;
	ll len = str.length();
	ll i = 0, j = len - 1;
	while (i <= j) {
		if (str[i] != str[j]) {
			if (str[i] == 'x') {
				i++;
				times++;
			}
			else if (str[j] == 'x') {
				j--;
				times++;
			}
			else {
				flug = false;
				break;
			}
		}
		else {
			i++;
			j--;
		}
	}
	if (!flug) {
		cout << -1;
	}
	else {
		cout << times;
	}
	return 0;
}

Measured memory_bytes: 512
ans=-1
nums=input().split(" ")
t8,t10=int(nums[0]),int(nums[1])
value=max(round(t8*100/8),round(t10*100/10))+1
for i in range(value):
  v=value-i
  tax8=v*8/100
  tax10=v*10/100
  if tax8>=t8 and tax8<t8+1 and tax10>=t10 and tax10<t10+1:
    ans=v
  elif tax8<t8 or tax10<t10:
    break
print(ans)

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

using namespace std;

int main(){
    int n;
    int *x;
    int *y;
    cin >> n;
    x = new int[n];
    y = new int[n];
    for(int i=0;i<n;i++){
        cin >> x[i];
        y[i] = x[i];
    }
    sort(y,y+n);
    for(int i=0;i<n;i++){
        if(x[i] <= y[(n-1)/2]){
            cout << y[(n-1)/2+1] << endl;
        }else{
            cout << y[(n-1)/2] << endl;
        }
    }
    delete[] x;
    return 0;
}

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

using namespace std;

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

    int n , k;
    cin >> n >> k;

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


    int ans = 0;
    for (int i = 0 ;i <= n ;i++) {
        for (int j = i ;j < n ;j++) {
            int c = i + n - j - 1;
            if (c > k) continue;
            int s = 0;
            priority_queue<int> q;

            for (int k = 0 ;k < n ;k++) {
                if (k < i || k > j) {
                    s += a[k];
                    if (a[k] < 0)
                        q.push(-a[k]);
                }
            }

            int rem = k - c;
            while (rem > 0 && q.size()) {
                s += q.top();
                q.pop();
                rem--;
            }

            ans = max(ans , s);
        }
    }

    if (n <= k) {
        int s = 0;
        priority_queue<int> q;
        for (int i = 0 ;i < n ;i++) {
            s += a[i];
            if (a[i] < 0)
                q.push(-a[i]);
        }

        int rem = k - n;
        while (rem > 0 && q.size()) {
            s += q.top();
            q.pop();
            rem--;
        }

        ans = max(ans , s);
    }

    cout << ans;
}


Measured memory_bytes: 3640
n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)

ans = a[0]
j = 1
cnt = 0
for i in range(n - 2):
    ans += a[j]
    
    if cnt == 1:
        cnt = 0
        j += 1
    else:
        cnt += 1
        
print(ans)

Measured memory_bytes: 31432
#include <bits/stdc++.h>
#define fi first
#define se second

using namespace std;
typedef pair <int, int> pii;

int arr[1010][1010];
int ind[1010101];

vector <int> g[1010101];

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

	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j < n; j++) {
			cin >> arr[i][j];
		}
	}
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j < n - 1; j++) {
			int u = n*min(i, arr[i][j]) + max(i, arr[i][j]) - n;
			int v = n*min(i, arr[i][j+1]) + max(i, arr[i][j+1]) - n;
			g[u].push_back(v);
			ind[v]++;
		}
	}

	queue <int> q;
	for(int i = 1; i <= n*n; i++) if(ind[i] == 0) q.push(i);

	int ans = 0;
	while(!q.empty()) {
		int siz = q.size();
		for(int i = 0; i < siz; i++) {
			int x = q.front();
			q.pop();
			for(auto j : g[x]) {
				ind[j]--;
				if(ind[j] == 0) q.push(j);
			}
		}
		ans++;
	}
	for(int i = 1; i <= n*n; i++) {
		if(ind[i] != 0) {
			cout << -1;
			return 0;
		}
	}
	cout << ans;
}

Measured memory_bytes: 49536
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a = [a[i] - 1 for i in range(n)]
    next_i = 0
    seen = [-1] * n
    count = 0
    while True:
        if seen[next_i] != -1:
            start = seen[next_i]
            l = count - seen[next_i]
            break
        seen[next_i] = count
        count += 1
        next_i = a[next_i]
    if k > start:
        k = ((k - start) % l) + start
    for i in range(n):
        if seen[i] == k:
            print(i + 1)
            break


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 102844
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <stack>
#include <cstdio>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <iterator>
#include <sstream>
#define popcount(x) __builtin_popcount(x)
#define oddparity(x) __builtin_parity(x)
#define clz(x) __builtin_clz(x)
#define ctz(x) __builtin_ctz(x)
#define sf scanf
#define pf printf
#define ll long long int
using namespace std;

int i, j, n, m, min_index, mn;

int main()
{
    sf("%d%d", &n, &m);
    int a[n], b[n], c[m], d[m];
    for (i = 0; i < n; i++) {
        sf("%d%d", &a[i], &b[i]);
    }
    for (i = 0; i < m; i++) {
        sf("%d%d", &c[i], &d[i]);
    }
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            if (j == 0) {
                min_index = 0;
                mn = abs(a[i]-c[j]) + abs(b[i]-d[j]);
            }
            else if (abs(a[i]-c[j]) + abs(b[i]-d[j]) < mn) {
                mn = abs(a[i]-c[j]) + abs(b[i]-d[j]);
                min_index = j;
            }
        }
        pf("%d\n", min_index+1);
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct S {//辺の情報を入れる変数
	int from, to, cost;
};
struct H {
	int x, y;
};
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(ld a, ld b, ld c, ld d) {
	return sqrt(pow(a - c, 2) + pow(b - d, 2));
}//rad＝座標上の2点間の距離
 //---------------------------------------------------
 //+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	string s;
	cin >> s;
	if (s.size() >= 4 && s[0] == 'Y'&&s[1] == 'A'&&s[2] == 'K'&&s[3] == 'I')
		cout << "Yes\n";
	else
		cout << "No\n";
	getchar(); getchar();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 8e4+7;
const int sz = 101;
const ll mod = 1e9+7;
int n,m;

int dp[maxn][sz], pre[maxn][sz];
vector<int> v;
map<int,int> ma;
int main()
{
    scanf("%d%d", &n, &m);
    v.push_back(0);
    for(int i=1;i*i<=n;i++){
        v.push_back(i);
        if(i*i < n)v.push_back(n/i);
    }
    sort(v.begin(), v.end());
    for(int i=0;i<v.size();i++)ma[v[i]] = i;
    for(int i=1;i<v.size();i++)dp[i][1] = 1;
    for(int i=1;i<v.size();i++)pre[i][1] = v[i];
    for(int in=2;in<=m;in++){
        for(int i=1;i<v.size();i++){
            int index = ma[n/v[i]];
            dp[i][in] = 1LL*(v[i]-v[i-1])*pre[index][in-1] % mod;
            pre[i][in] = (pre[i-1][in] + dp[i][in])%mod;
        }
    }
    printf("%d\n", pre[v.size()-1][m]);


    return 0;
}


Measured memory_bytes: 56700
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int n,d;cin>>n>>d;
    int cnt=0;
    double x[n][d];rep(i,n)rep(j,d)cin>>x[i][j];
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            double dist=0.0;
            rep(k,d){
                dist+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            dist = sqrt(dist);
            if(dist==floor(dist))cnt++;
        }
    }
    co(cnt);
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct _node {
    int val;
    struct _node *left;
    struct _node *right;
    struct _node *parent;
} NODE;

NODE *root = NULL;

void insert(int val) {
    NODE *x = new NODE;
    x->val = val;
    x->left = NULL;
    x->right = NULL;
    x->parent = NULL;
    NODE *y = NULL; // parent of z
    NODE *z = root; // current position
    while (z != NULL) {
        y = z;
        if (x->val <= z->val) {
            z = z->left;
        } else {
            z = z->right;
        }
    }
    x->parent = y;
    if (y == NULL) {
        root = x;
    } else if (x->val <= y->val) {
        y->left = x;
    } else {
        y->right = x;
    }
}

void preorder(NODE *p) {
    if (p == NULL) {
        return;
    }
    printf(" %d", p->val);
    preorder(p->left);
    preorder(p->right);
}

void inorder(NODE *p) {
    if (p == NULL) {
        return;
    }
    inorder(p->left);
    printf(" %d", p->val);
    inorder(p->right);
}

int main() {
    int n, val;
    scanf("%d", &n);
    char cmd[100];
    for (int i = 0; i < n; i++) {
        scanf("%s %d", cmd, &val);
        if (cmd[0] == 'i') {
            insert(val);
        } else {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}



Measured memory_bytes: 26148
//       Author: Mostafa Mounir Shehab
 
#include <bits/stdc++.h>
using namespace std;
 
#define PI  3.14159265  // PI = acos(-1)
#define EPS (1e-10)
#define endl "\n"
#define SZ(v) (int)(v.size())
typedef long long ll;
typedef long double ld;
//template <class Type>
 
 
void Fast(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
}
 
inline int D(){
	int t;
	scanf("%d",&t);
	return t;
}
inline ll llD(){
	ll t;
	scanf("%lld",&t);
	return t;
}
 
 
ll MOD=1e9 + 7; 
const int N=1e5 + 5;
int dp[N];
int OO=1e9; 
 
ll n,m,k,cnt,SU,idx,len,MN,MX,T;
ll l,r,mid;
ll a,b,c,d;
vector<int> vec,v;
vector<pair<int,int>> ans;
string str,s;

vector<int> adj[N];


int DFS(int u){
	if(!SZ(adj[u]))
		return 0;
		
	int &ret = dp[u];
	if(~ret)
		return ret;
	ret = 0;
	for(int i:adj[u])
		ret=max(ret,1+DFS(i));

	
	return ret;
	
}


int main(){
	memset(dp,-1,sizeof dp);
	cin>>n>>m;
	for(int i=0;i<m;++i){
		cin>>a>>b;
		adj[a].push_back(b);
	}
	
	
	int MX=0;
	for(int i=1;i<=n;++i)
		MX=max(MX,DFS(i));
	cout<<MX<<endl;
	
}














Measured memory_bytes: 7424
#include <iostream>

long max = 1000000000000000000;

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

    long answer = 1;
    bool isOverflow = false;

    for (int i = 0; i < n; i += 1) {
        long a;
        std::cin >> a;

        if (a == 0) {
            std::cout << 0 << std::endl;
            return 0;
        } else if (isOverflow) {
            continue;
        }

        if (max / answer < a) {
            // Will be overflow
            isOverflow = true;
            continue;
        }

        answer = answer * a;

        if (answer > max) {
            isOverflow = true;
        }
    }

    if (isOverflow) {
        std::cout << -1 << std::endl;
    } else {
        std::cout << answer << std::endl;
    }
}


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

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

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")

#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")

int main(void){
  int N,ac=0,wa=0,tle=0,re=0;
  cin >>N ;
  vector<string> S(N);
  rep(i,N){
    cin >>S.at(i);
    if(S.at(i)=="AC")ac++;
    else if(S.at(i)=="WA")wa++;
    else if(S.at(i)=="TLE")tle++;
    else if(S.at(i)=="RE")re++;
  }
  cout<<"AC x "<< ac <<endl;
  cout<<"WA x "<< wa <<endl;
  cout<<"TLE x "<< tle <<endl;
  cout<<"RE x "<< re <<endl;
  return 0;
}


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

int main(void){
    char s[102], t[102];
    cin >> s >> t;
    
    string a, b;
    a = string(s);
    b = string(t);
    
    sort(s, s + a.length());
    sort(t, t + b.length(), greater<char>());
    
    a = string(s);
    b = string(t);
    
    if(a < b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
N = int(input())
d = list(map(int, [input() for i in range(N)]))

bucket = [0 for i in range(110)]
for i in range(N):
  bucket[d[i]] += 1

count = 0
for i in range(110):
  if bucket[i] != 0:
    count += 1

print(count)

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

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

	long double res = 0;
	int n;
	long double x;
	string u;

	cin >> n;

	for(int i=0;i<n;i++)
	{
		cin >> x >> u;
		if(u=="JPY")
		{
			res+=x;
		}
		else
		{
			res+=(380000.0)*x;
		}
	}

	cout << fixed;
	cout.precision(5);

	cout << res << '\n';
	
	return 0;
}

Measured memory_bytes: 256