akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

const int N = 100007;
const long long INF = 1000000000000000000;

template < class T, class UT, class MERGE_VALUE_VALUE, class MERGE_VALUE_UPDATE, T NEUTRAL_VALUE >
struct binary_indexed_tree {
  vector < T > tree;
  int n;
  MERGE_VALUE_VALUE merge_values;
  MERGE_VALUE_UPDATE update_value;
  void build_tree(T *arr, int a, int b, int node) {
    if(a>b) return;
    if(a==b) {
      tree[node]=arr[a];
      return;
    }
    build_tree(arr,a,(a+b)>>1,node<<1);
    build_tree(arr,((a+b)>>1)+1,b,(node<<1)|1);
    tree[node]=merge_values(tree[node<<1],tree[(node<<1)|1]);
  }
  void update_tree(int a, int b, int pos, UT value, int node) {
    if(a>b || a>pos || b<pos) return;
    if(a==b) {
      tree[node]=update_value(tree[node],value);
      return;
    }
    update_tree(a,(a+b)>>1,pos,value,node<<1);
    update_tree(((a+b)>>1)+1,b,pos,value,(node<<1)|1);
    tree[node]=merge_values(tree[node<<1],tree[(node<<1)|1]);
  }
  T query_tree(int a, int b, int i, int j, int node) {
    if(a>b || a>j || b<i) return NEUTRAL_VALUE;
    if(a>=i && b<=j) return tree[node];
    return merge_values(query_tree(a,(a+b)>>1,i,j,node<<1),query_tree(((a+b)>>1)+1,b,i,j,(node<<1)|1));
  }
  void initialize(int k) {
    n=k;
    tree.assign(4*n+5,NEUTRAL_VALUE);
  }
  void initialize(T *arr, int k) {
    n=k;
    tree.assign(4*n+5,NEUTRAL_VALUE);
    build_tree(arr,1,n,1);
  }
  void update(int pos, UT value) {
    update_tree(1,n,pos,value,1);
  }
  T query(int l, int r) {
    return query_tree(1,n,l,r,1);
  }
};

struct edge {
  int l, r, w;
};

struct min_merge {
  long long operator()(const long long &a, const long long &b) const {
    return min(a, b);
  }
};

struct assign_merge {
  long long operator()(const long long &a, const long long &b) const {
    return b;
  }
};

int n, m;
vector < int > starting[N], ending[N];
long long dp[N];
edge e[N];
multiset < int > weights[N];
binary_indexed_tree < long long, long long, min_merge, assign_merge, INF > bit;

void add_edge(edge e) {
  weights[e.r].insert(e.w);
  bit.update(e.r, min(INF, dp[e.r] + *weights[e.r].begin()));
}

void remove_edge(edge e) {
  weights[e.r].erase(weights[e.r].find(e.w));
  bit.update(e.r, weights[e.r].empty() ? INF : min(INF, dp[e.r] + *weights[e.r].begin()));
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int i, j;

  cin>>n>>m;
  for(i=1;i<=m;i++) {
    cin>>e[i].l>>e[i].r>>e[i].w;
    starting[e[i].r].push_back(i);
    ending[e[i].l].push_back(i);
  }

  bit.initialize(n);
  
  dp[n] = 0;
  for(i=n;i>=1;i--) {
    if(i<n) {
      dp[i] = min(INF, bit.query(i + 1, n));
    }
    
    for(j=0;j<(int)(starting[i].size());j++) {
      add_edge(e[starting[i][j]]);
    }

    for(j=0;j<(int)(ending[i].size());j++) {
      remove_edge(e[ending[i][j]]);
    }
  }

  cout<<(dp[1]==INF ? -1 : dp[1])<<endl;

  return 0;
}


Measured memory_bytes: 20736
#include<stdio.h>
int main()
{
    int n,i,j,m,s,t;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    t=0;
    for(i=0;i<n;i++)
    {
        s=0;
        for(j=1;j<n;j++)
        {
            if(j<=i){
                continue;
            }
            m=a[i]*a[j];
            s=s+m;
        }
        t=t+s;
    }
    printf("%d\n",t);
    return 0;
}


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

int main(){
    int N; cin >> N;
    vector<int> L(N); 
    rep(i,N) cin >> L[i];
    sort(L.begin(),L.end());
    int c=0;
    rep(i,N){
        rep(j,i){
            rep(k,j){
                if(L[i]!=L[j] and L[j]!=L[k] and L[j]+L[k]>L[i])
                c++;
                }
            }
        }
    cout << c << endl;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    String[] s = sc.next().split("/");
    int year = Integer.parseInt(s[0]);
    int month = Integer.parseInt(s[1]);
    int day = Integer.parseInt(s[2]);
    String result = "TBD";
    if (year < 2019) result = "Heisei";
    else if (year == 2019 && month < 4) result = "Heisei";
    else if (year == 2019 && month == 4 && day <= 30) result = "Heisei";
    System.out.println(result);
  }
}

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

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

using namespace std;

int main(){
  int x,y;
  cin>>x>>y;
  
  array<int,13> g = { -1, 0, 1, 0, 2, 0, 2, 0, 0, 2, 0, 2, 0};
  if(g[x]==g[y]){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <math.h>
#include <algorithm>

#define pb push_back

using namespace std;

int main() {
	int n, m, big, akar;
	vector<int> divisor;
	scanf("%d %d", &n, &m);
	akar = sqrt(m);
	for (int i = 1; i <= akar; i++)
		if (m % i == 0) {
			divisor.pb(i);
			if ((i * i) < m)
				divisor.pb(m / i);
		}
	sort(divisor.rbegin(), divisor.rend());
	big = m / n;
	for (int i = 0; i < (int) divisor.size(); i++) {
		if (divisor[i] > big)
			continue;
		printf("%d\n", divisor[i]);
		break;
	}
	return 0;
}

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

const int N = 100000 + 5, M = 1000000007;
int fact[N], n, a, x[N];

int power(int a, int n) {
	if(n == 0) return 1;
	if(n == 1) return a;
	int x = power(a, n/2);
	x = (ll) x * x % M;
	if(n&1)
		x = (ll) x * a % M;
	return x;
}

int main() {
	scanf("%d", &n);

	fact[0] = 1;
	for(int i=1; i<N; ++i)
		fact[i] = (ll) i * fact[i-1] % M;
	for(int i=1; i<N; ++i) {
		x[i] = (ll)fact[n] * power(i, M-2) % M;
		x[i] = ((ll)x[i] + x[i-1]) % M;
	}

	int res = 0;
	for(int i=0; i<n; ++i) {
		scanf("%d", &a);
		int y = 0;
		y = (((((ll)x[n-i] + x[i+1]) % M - fact[n]) % M + M) % M) * a % M;
		res = ((ll)res + y) % M;
	}
	printf("%d\n", res);
	return 0;
}


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

using namespace std;

//頭の整理のためにコメントを入れてみる
//あってるかは知らない

typedef long long ll;
typedef vector< vector<int> > Graph;

Graph g;
ll a[100010];

//return: nodeとparentを結ぶ辺を通る操作の回数(通る回数)
//全ての石を取り除く事ができないと分かった場合-1を返す
ll dfs(int node, int parent) {
	//nodeが葉の場合通る回数は明らかにa[node]に等しい
	if (g[node].size() == 1) return a[node];

	ll c_sum = 0;  //nodeの子の通る回数の和
	ll c_max = 0;  //nodeの子の通る回数の最大値
	for (int nex : g[node]) {
		if (nex == parent) continue;
		ll c = dfs(nex, node);  //nodeの子の通る回数
		if (c == -1) return -1;  //全ての石を取り除く事ができないと分かった場合
		c_sum += c;
		c_max = max(c_max, c);
	}

	/* 
		T: nodeとparentを結ぶ辺を通る操作の回数
		L: nodeの異なる2つの子がnodeを経由してつながっている辺を通る操作の回数

		1.  nodeを経由するような辺は
			parent-node-children(パターンA)か
			children1-node-children2(パターンB)のどちらかしかなく
			いずれの場合も1回の操作でa[node]は1減る
			よって、a[node]を0にするためには
			T + L == a[node]が成立する必要がある

		2.  パターンAでは1回の操作で子の石は1つ減る
			一方、パターンBでは1回の操作で子の石は2つ減る
			以上よりnodeの子の石を全て0にするためには
			T + 2 * L == c_sumが成立する必要がある

		以上より
		1. T + L == a[node]
		2. T + 2 * L == c_sum
	*/
	ll T = 2 * a[node] - c_sum;
	ll L = c_sum - a[node];
	if (L < 0 || T < 0) return -1;

	/*
		nodeの異なる2つの子がnodeを経由してつながっている辺を通る操作の回数の最大値は

		1.  c_max > c_sum / 2の場合
			通る回数がc_maxとなるnodeの子とそれ以外のnodeの子全てをそれぞれペアとして
			各ペアをつなげた辺に対して操作をすると操作の回数を最大にでき、
			この時、通る回数がc_maxとなるnodeの子以外の石の数が0になることから
			操作の回数の最大値はc_sum - c_maxとなる

		2.  1以外の場合
			nodeの子の中で石の数が多いものを貪欲に2つ選び、
			それらをつなげた辺に対し操作を行うということを繰り返すことで
			操作の回数を最大にでき、
			この時、nodeの子の石の残りの合計はc_sum % 2となることから
			操作の回数の最大値はc_sum / 2となる

		Lが操作の回数の最大値を超えるなら-1を返す
	*/
	if (c_max > c_sum / 2) {
		if (L > c_sum - c_max) return -1;
		else return T;
	} else {
		if (L > c_sum / 2) return -1;
		else return T;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	g = Graph(n);
	for (int i = 0; i < n - 1; i++) {
		int s, d;
		cin >> s >> d;
		s--;
		d--;
		g[s].push_back(d);
		g[d].push_back(s);
	}

	/*
		YESを出力するのは
		根が葉の場合: dfs(root, -1) == a[root]
		根が葉ではない場合: dfs(root, -1) == 0
		今回は葉ではないノードを根とすることで後者の場合に統一
	*/

	//ノードが全て葉となる場合は例外として処理
	if (n == 2) {
		cout << (a[0] == a[1] ? "YES" : "NO") << endl;
		return 0;
	}

	//葉ではないノードを根とする
	int root;
	for (root = 0; root < n; root++) {
		if (g[root].size() != 1) break;
	}

	cout << (dfs(root, -1) == 0 ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 13184
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        Bracket[] brackets = new Bracket[n];
        for (int i = 0; i < n; i++)
        {
            var s = Console.ReadLine();
            int depth = 0;
            int minDepth = 0;
            for (int j = 0; j < s.Length; j++)
            {
                if (s[j] == '(') depth++;
                else depth--;
                minDepth = Min(minDepth, depth);
            }
            brackets[i] = new Bracket() { FinalDepth = depth, MinDepth = minDepth };
        }
        {
            int depth = 0;
            //先に深い方からやった方が得することがあるかというとそんなことはなくて、そんな暇があったら浅いのをやれてしまうので
            //最初は途中での深さが浅いのから
            foreach (var item in brackets.Where(x => x.FinalDepth >= 0).OrderByDescending(x => x.MinDepth))
            {
                if (depth + item.MinDepth < 0) { Console.WriteLine("No"); return; }
                depth += item.FinalDepth;
            }
            //先に浅いのをやることが得になりうるか
            //さっきのの逆、なので途中での深さが深いのから
            foreach (var item in brackets.Where(x => x.FinalDepth < 0).OrderBy(x => x.MinDepth - x.FinalDepth))
            {
                if (depth + item.MinDepth < 0) { Console.WriteLine("No"); return; }
                depth += item.FinalDepth;
            }
            if (depth != 0) { Console.WriteLine("No"); return; }
        }
        //弾かなくて良いものを弾いている
        //throw new Exception();
        Console.WriteLine("Yes");
    }
}

struct Bracket
{
    public int FinalDepth;
    public int MinDepth;
}


Measured memory_bytes: 78004
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);

while(true){
int n=Integer.parseInt(sc.next());
int r=Integer.parseInt(sc.next());
int[] card=new int[n];
for(int i=0;i<n;i++){card[i]=i+1;}
if(n==0&&r==0)break;
for(int i=0;i<r;i++){
int p=Integer.parseInt(sc.next());
int c=Integer.parseInt(sc.next());
int[] temp=new int[n];
    for(int j=n-p-c+1;j<=n-p;j++){
    temp[j]=card[j];
    }
    for(int k=n-1;k>n-p;k--){
    temp[k]=card[k];
    }

    for(int j=n-p-c+1;j<=n-c-1;j++){
    card[j]=temp[j+c];
    }

    for(int j=n-c;j<n;j++){
    card[j]=temp[j-p+1];
    }
}

System.out.println(card[n-1]);
}


}
}


Measured memory_bytes: 36912
#!/usr/bin/env python3
import sys
import math
INF = float("inf")


def solve(a: int, b: int, x: int):
    base = a*a*b/2
    if x >= base:
        theta = math.atan(2*(x-a*a*b)/(a*a*a))
    else:
        theta = math.atan(a*b*b/(2*x))
    print(abs(math.degrees(theta)))

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    solve(a, b, x)


if __name__ == '__main__':
    main()


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

int main()
{
  int64_t N, p, ans = 0;
  cin >> N;
  map<int, int> mp;
  for (int i = 0; i < N; i++)
  {
    cin >> p;
    if (mp.count(p - 1))
    {
      mp[p] = mp[p - 1];
    }
    mp[p]++;
  }
  for (auto it = mp.begin(); it != mp.end(); it++)
  {
    ans = max(ans, (int64_t)(it->second));
  }
  cout << N - ans << endl;
}

Measured memory_bytes: 12920
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int dx = c - a;
  int dy = d - b;
  cout << (c - dy) << " " << (d + dx) << " " << (a - dy) << " " << (b + dx) << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

long L, R;
long min_val = 2019;

void solve();

int main() {
  cin >> L >> R;
  solve();
}

void solve() {
  for (long l = L; l < R && l < L + 2019; l++) {
    for (long r = L + 1; r <= R && r < L + 2019; r++) {
      if (l >= r) {
        continue;
      }
      long modulo = (l * r) % 2019;
      if (modulo < min_val) {
        min_val = modulo;
      }
      if (min_val == 0) {
        break;
      }
    }
  }

  cout << min_val;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
ll power(int D){
	if(D==0) return 1;
	else return 100*power(D-1);
}
int main(){
   int D, N;
   cin >> D >> N;
   ll unit = power(D);

   if(N==100) cout << 101*unit <<endl;
   else cout << N*unit << endl;
   

  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<functional>

using namespace std;

int main() {
	char n[3][3];
	for (int i = 0; i < 3; i++) {
		for (int ii = 0; ii < 3; ii++) {
			cin >> n[i][ii];
		}
	}
	cout << n[0][0] << n[1][1] << n[2][2] << endl;
	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
ans = [-1] * n
edge = [[] for _ in range(n)]

for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
    
import collections
que = collections.deque()
que.append(0)
    
while que:
    x = que.popleft()
    
    for to in edge[x]:
        if ans[to] == -1:
            ans[to] = x + 1
            que.append(to)
            
print("Yes")
print(*ans[1:],sep="\n")

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

int N;
int x[10], y[10];

int main(){

    
    int N;
    cin >> N;
    
    for(int i = 1; i <= 9; i++){
        if(N / i <= 9 && N%i == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define NO return puts("NO"),0
using namespace std;

int n,m,f[1000],a,b,c,d,x,y,D[1000],bo[1000],C[1000];
int gf(int x){return x==f[x]?x:f[x]=gf(f[x]);}
int main(){
	scanf("%d%d",&n,&m);
	
	for (int i=1;i<999;i++) f[i]=i;
	while (n--){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		if (c==0) x=a;else x=-c;x+=500;
		if (d==0) y=-b;else y=d;y+=500;
		f[gf(x)]=gf(y);
		D[x]++;D[y]--;bo[x]=1;
	}
	for (int i=1;i<500;i++) if (D[i]>0) NO;
	for (int i=501;i<999;i++) if (D[i]<0) NO;
	for (int i=1;i<999;i++)
	if (bo[gf(i)]|=bo[i],D[i]) C[f[i]]=1;
	for (int i=1;i<999;i++)
	if (f[i]==i&&!C[i]&&bo[i]) NO;
	puts("YES");
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE
std::vector<bool> Eratosthenes( const int N )
{
    std::vector<bool> is_prime( N + 1 );
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    std::vector<int> P;
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return is_prime;
}

void solve(void)
{
  int N = 10e5+1;
  // N = 10;
  vector<bool> vec = Eratosthenes(N);
  vector<int> Com (N+1,0);
  vec[0] = 0;
  vec[2] = 1;
  vec[1] = 0;
  for (int i = 1; i < N-1; i++)
  {
    if(vec[i]&&vec[(i+1)/2])
    Com[i] = 1;
    Com[i] += Com[i-1];
  }

  int Q;
  cin>>Q;
  // DEBUG(Com);
  for (int i = 0; i < Q; i++)
  {
    int L,R;
    cin>>L>>R;L--;
    cout<<Com[R]-Com[L]<<endl;
  }
  
  

  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


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

const ll MX = 1e18;
 
int main() {
  int n;
  cin >> n;
  ll ans = 1;
  bool ng = false;
  rep(i,n) {
    ll a;
    cin >> a;
    if (a == 0) {
      cout << 0 << endl;
      return 0;
    }
    if (ng || __int128(ans)*a > MX) {
      ng = true;
    }
    ans *= a;
  }
  if (ng) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, std::vector<long long> A){
  vector<pll> X;
  REP(N){
    X.push_back(pll(A[i],i+1));
  }
  sort(X.begin(),X.end());
  REP(N){
    cout<<X[i].second<<" ";
  }
  cout<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 3312
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const ll INF = 1LL << 60;
const ll MOD = (ll) 1e9 + 7;

int main(){
    int n, h;
    cin >> n >> h;
    vector<int> v;
    v.push_back(0);
    ll max_a = 0;
    for (int i = 0; i < n; i++) {
        ll a, b;
        cin >> a >> b;
        max_a = max(max_a, a);
        v.push_back(b);
    }
    sort(v.begin(), v.end(), greater<ll>());
    vector<ll> u;
    u.push_back(v[0]);
    for (int i = 1; i < n; i++) {
        if (v[i] < max_a) {
            u.push_back(max_a + u[i - 1]);
        }
        else
            u.push_back(v[i] + u[i - 1]);
    }

    if (h <= u.back()) {
        for (int i = 0; i < u.size(); i++) {
            if (h <= u[i]) {
                cout << i + 1 << "\n";
                return 0;
            }
        }
    }
    cout << u.size() + ((h - u.back()) + max_a - 1) / max_a << "\n";
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    cout << pow(N,3) << endl;
}


Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int mod = 1000000007;
//const int mod = 998244353;

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

    //for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vi x(n);
    rep(i, n) cin >> x[i];
    sort(all(x));
    mint X;
    rep(i, n-1) {
        X += mint(x[i+1]-x[i]) * (i+1) * (n-i-1);
    }
    vi y(m);
    rep(i, m) cin >> y[i];
    sort(all(y));
    mint Y;
    rep(i, m-1) {
        Y += mint(y[i+1]-y[i]) * (i+1) * (m-i-1);
    }

    cout << X*Y << endl;
}

Measured memory_bytes: 3972
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

int main() {
  while(1){
    int n,m,a;
    cin>>n>>m>>a;
    if(!n)break;
    vector<tuple<int,int,int>> v;
    REP(i,m){
      int h,p,q;
      cin>>h>>p>>q;
      v.emplace_back(h,p,q);
    }
    sort(begin(v),end(v),greater<tuple<int,int,int>>());
    REP(i,m){
      int h,p,q;
      tie(h,p,q)=v[i];
      if(a==p){
        a=q;
      }else if(a==q){
        a=p;
      }
    }
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 1224
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;

int a[100000];

int main() {
	int N; cin >> N;
	for (int i = 0; i < N; i++)
		cin >> a[i];

	map<int, int> mp;
	for (int i = 0; i < N; i++)
		mp[a[i]]++;

	int ans = 0;
	for (auto p: mp) {
		int x = p.first;
		int n = p.second;
		if (n < x) ans += n;
		else ans += n - x;
	}

	cout << ans << endl;
}


Measured memory_bytes: 5120
//abc093_b.cpp
//Sat Apr  7 20:40:32 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;

int main(){
	int a;
	int b;
	int k;
	cin >> a;
	cin >> b;
	cin >> k;

	int x = a;

	while (x<a+k && x<=b){
		cout << x << endl;
		x++;
	}

	x = b-k+1;
	while (x<=b){
		if (x>=a+k){
			cout << x << endl;
		}
		x++;
	}

}

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

int main() {
	string s;
	cin >> s; int l=s.length();
	l--;
	for(int i=0;i<s.length();i++){
	    if(s[i]!='P'&&s[i]!='D'){
	        if(i==0){
	            if(s[1]=='D'){
	                s[0]='P';
	            }
	            else if(i<l&&s[i+1]!='P'&&s[i+1]!='D'){
	                s[0]='P'; s[1]='D';
	            }
	            else{
	                s[0]='D';
	            }
	        }
	        else{
	            if(s[i-1]=='P'){
	                s[i]='D';
	            }
	            else if(i<l&&s[i+1]=='D'){
	                s[i]='P';
	            }
	            else if(i<l&&s[i+1]!='P'&&s[i+1]!='D'){
	                s[i]='P'; s[i+1]='D';
	            }
	            else{
	                s[i]='D';
	            } 
	        }
	    }
	}
    cout<<s; return 0;
}

Measured memory_bytes: 3372
#include<iostream>
using namespace std;
int main(){
  int t,n,s,f;
  
  while(1){
    cin>>t;
    if(t==0)break;
    cin>>n;
    int sum=0;
    for(int i=0;i<n;i++){
      cin>>s>>f;
      sum+=f-s;
    }
    
    if(sum>=t)cout<<"OK\n";
    else cout<<t-sum<<"\n";
  }
  
  return 0;
}



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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N,M;
  cin>>N>>M;

  vector<ll> x(N+1,0);
  vector<ll> y(M+1,0);

  cin>>x[N]>>y[M];
  cinv(x,0,N);
  cinv(y,0,M);
  sortAl(x);
  sortAl(y);

  string res = "War";
  if(x[N]<y[0]) res="No War";

  cout<<res<<endl;
}


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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define INF 1000000000
#define EPS 1e-9

#define EQ(x,y) fabs((x)-(y))<(EPS)

typedef pair<pair<double, double>, bool> P;

bool sorter(const P p1, const P p2){
  return p1.first<p2.first;
}

int main(){
  int tc;
  cin>>tc;
  while(tc-->0){
    vector<P> points;

    double xa,ya,xb,yb;
    scanf("%lf %lf %lf %lf", &xa, &ya, &xb, &yb);

    double lf=min(xa,xb), r=max(xa,xb);
    double b=min(ya,yb), t=max(ya,yb);

    int n;
    cin>>n;
    rep(i,n){
      double x1,y1,x2,y2;
      int o,l;
      scanf("%lf %lf %lf %lf %d %d", &x1, &y1, &x2, &y2, &o, &l);

      double ll=min(x1,x2), rr=max(x1,x2);
      double bb=min(y1,y2), tt=max(y1,y2);

      // if pararell
      if( EQ((xa-xb)*(y1-y2), (ya-yb)*(x1-x2)) ) continue;

      // where is intersection?
      double nx, ny;
      if(EQ(xa,xb)){
	double d2 = (y1-y2)/(x1-x2);
	nx = xa;
	ny = d2*(nx-x1)+y1;
      } else if( EQ(x1,x2) ){
	double d1 = (ya-yb)/(xa-xb);
	nx = x1;
	ny = d1*(nx-xa)+ya;
      } else {
	double d1 = (ya-yb)/(xa-xb);
	double d2 = (y1-y2)/(x1-x2);
	nx = (y1-d2*x1-(ya-d1*xa))/(d1-d2);
	ny = d1*(nx-xa)+ya;
	//assert(EQ(ny, d2*(nx-x1)+y1));
      }
      
      if( nx-lf>-EPS && r-nx>-EPS && ny-b>-EPS && t-ny>-EPS &&
	  nx-ll>-EPS &&rr-nx>-EPS && ny-bb>-EPS&&tt-ny>-EPS){
      // if cross with new line, add point to vector
	points.pb(mp(mp(nx,ny), (o==l)));
      }
    }

    sort(all(points));

    int res=0;
    repl(i,1,points.size()){
      if(points[i-1].second != points[i].second) res++;
    }

    cout<<res<<endl;

  }
  return 0;
}

Measured memory_bytes: 1280
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

int main()
{
    string s;
    long long k;
    cin >> s >> k;

    for (long long i = 0; i < k; i++) {
        int di = s[i] - '0';
        if (di > 1) {
            cout << di << endl;
            return 0;
        }
    }

    cout << "1" << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;
typedef std::pair<LL, LL> P;
struct edge { LL to, cost; };

const LL inf = 112345678901234;
LL N, Q, K;
std::vector<LL>dist;
std::vector<std::vector<edge>>G;

void dijkstra(LL s)
{
	std::priority_queue<P, std::vector<P>, std::greater<P>>que;
	std::fill(dist.begin(), dist.end(), inf);
	dist[s] = 0;
	que.push(P(0, s));
	while (!que.empty())
	{
		P p = que.top(); que.pop();
		LL v = p.second;
		if (dist[v] < p.first) { continue; }
		rep(i, G[v].size())
		{
			edge e = G[v][i];
			if (dist[e.to] > dist[v] + e.cost)
			{
				dist[e.to] = dist[v] + e.cost;
				que.push(P(dist[e.to], e.to));
			}
		}
	}
}

int main()
{
	in >> N;
	std::vector<LL>a(N - 1), b(N - 1), c(N - 1);
	dist.resize(N + 1); G.resize(N + 1);
	rep(i, N - 1)
	{
		in >> a[i] >> b[i] >> c[i];
		G[a[i]].push_back({ b[i],c[i] });
		G[b[i]].push_back({ a[i],c[i] });
	}
	in >> Q >> K;
	dijkstra(K);
	std::vector<LL> x(Q), y(Q);
	rep(i, Q)
	{
		in >> x[i] >> y[i];
		out << dist[x[i]] + dist[y[i]] << std::endl;
	}
	return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var N = sc.ReadLong();
        var M = sc.ReadLong();
        if (N > M)
        {
            var tmp = N;
            N = M;
            M = tmp;
        }

        if (N == 1 && M == 1)
        {
            Console.WriteLine(1);
            return;
        }
        else if (N == 1)
        {
            Console.WriteLine(M - 2);
            return;
        }
        else if (N == 2)
        {
            Console.WriteLine(0);
            return;
        }

        long c = (N - 2) * (M - 2);
        Console.WriteLine(c);
    }

    static int MOD = (int)1e9 + 7;
    static int INF = (int)1e7 + 1;
    static long LINF = (long)1e13 + 1;
    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 11220
h, w, k = map(int, input().split())
board = [list(input()) for _ in range(h)]
ans = 0
for paint_h in range(2 ** h):
    for paint_w in range(2 ** w):
        cnt = 0
        for i in range(h):
            for j in range(w):
                if (paint_h >> i) & 1 == 0 and (paint_w >> j) & 1 == 0:
                    if board[i][j] == "#":
                        cnt += 1
        if cnt == k:
            ans += 1
print(ans)

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

ll h, w, k;
ll sx, sy, gx, gy;

ll dist(ll x, ll y) {
  return abs(gx - x) + abs(gy - y);
}

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

  cin >> h >> w >> k;

  cin >> sx >> sy >> gx >> gy;
  sx--;
  sy--;
  gx--;
  gy--;

  swap(sx, sy);
  swap(gx, gy);

  vs c(h);
  rep(i, h) {
    cin >> c[i];
  }

  using T = tuple<ll, ll, ll, ll>;
  priority_queue<T, vector<T>, greater<T>> que;
  que.emplace(0, dist(sx, sy), sx, sy);

  vector<vb> visited(h + 1, vb(w + 1));
  vector<vb> vu(h + 1, vb(w + 1));
  vector<vb> vd(h + 1, vb(w + 1));
  vector<vb> vl(h + 1, vb(w + 1));
  vector<vb> vr(h + 1, vb(w + 1));

  visited[sy][sx] = true;

  ll ans = -1;

  while (!que.empty()) {
    auto q = que.top();
    que.pop();

    ll step = get<0>(q);
    ll x = get<2>(q);
    ll y = get<3>(q);

    if (x == gx && y == gy) {
      ans = step;
      break;
    }

    FOR(tx, x + 1, x + k + 1) {
      if (tx >= w || c[y][tx] == '@') {
        break;
      }

      if (vr[y][tx]) {
        break;
      }

      if (!visited[y][tx]) {
        que.emplace(step + 1, -abs(x - tx), tx, y);
        visited[y][tx] = true;
      }
      if (tx > 0)
        vr[y][tx - 1] = true;
      vl[y][tx] = true;
    }

    for (int tx = x - 1; tx >= x - k; tx--) {
      if (tx < 0 || c[y][tx] == '@') {
        break;
      }

      if (vl[y][tx]) {
        break;
      }

      if (!visited[y][tx]) {
        que.emplace(step + 1, -abs(x - tx), tx, y);
        visited[y][tx] = true;
      }
      vl[y][tx + 1] = true;
      vr[y][tx] = true;
    }

    FOR(ty, y + 1, y + k + 1) {
      if (ty >= h || c[ty][x] == '@') {
        break;
      }

      if (vd[ty][x]) {
        break;
      }

      if (!visited[ty][x]) {
        que.emplace(step + 1, -abs(y - ty), x, ty);
        visited[ty][x] = true;
      }
      if (ty > 0)
        vd[ty - 1][x] = true;
      vu[ty][x] = true;
    }

    for (int ty = y - 1; ty >= y - k; ty--) {
      if (ty < 0 || c[ty][x] == '@') {
        break;
      }

      if (vu[ty][x]) {
        break;
      }

      if (!visited[ty][x]) {
        que.emplace(step + 1, -abs(y - ty), x, ty);
        visited[ty][x] = true;
      }
      vu[ty + 1][x] = true;
      vd[ty][x] = true;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9224
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
double x[300],y[300];
double px[90000],py[90000];
int main(){
    int a;
    while(scanf("%d",&a),a){
        for(int i=0;i<a;i++)scanf("%lf%lf",x+i,y+i);
        int now=0;
        for(int i=0;i<a;i++){
            for(int j=i+1;j<a;j++){
                if((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])<4.0000001){
                    double d=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
                    double mx=(x[i]+x[j])/2;
                    double my=(y[i]+y[j])/2;
                    double s=sqrt(1-d*d/4);
                    double theta=atan((y[i]-y[j])/(x[i]-x[j]));
                    px[now]=mx-sin(theta)*s;
                    py[now++]=my+cos(theta)*s;
                    px[now]=mx+sin(theta)*s;
                    py[now++]=my-cos(theta)*s;
                }
            }
        }
        int ret=1;
        for(int i=0;i<now;i++){
            int k=0;
            for(int j=0;j<a;j++)if((px[i]-x[j])*(px[i]-x[j])+(py[i]-y[j])*(py[i]-y[j])<1.0000001)k++;
            ret=max(ret,k);
        }
        printf("%d\n",ret);
    }
}

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

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <utility>

using namespace std;
using ll = long long;
const long long INF = 999999999;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) cin >> A[i];

    vector<ll> cs(N + 1, 0);
    map<ll, ll> mp;
    mp[0] = 1;
    for (ll i = 1; i <= N; i++) {
        cs[i] = cs[i - 1] + A[i - 1];
        mp[cs[i]]++;
    }
    ll ans;
    ans = 0;
//    for (auto &it : mp) {
//        cout << it.first << " " << it.second << endl;
//    }
//    cout << "----- \n";

    for (auto &it : mp) {
        ans += it.second * (it.second - 1) / 2;
    }
    cout << ans << endl;
}

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

int main(void){

  char s[11], t[12];
  scanf("%s", s);
  scanf("%s", t);
  int length_s = strlen(s);
  int length_t = strlen(t);
  if (length_t != length_s+1) {
    printf("No\n");
    return 0;
  }
  int flag = 1;
  for (int i = 0; i < length_s; i++) {
    if (s[i] != t[i]) {
      flag = 0;
      break;
    }
  }
  if (flag == 1) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

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

int main(){
  int n; cin >> n;
  vector<pair<int,int>> ba(n);
  for (int i = 0; i < n; i++){
    cin >> ba.at(i).second >> ba.at(i).first;
  }
  sort(ba.begin(), ba.end());
  int64_t time = 0;
  for (int i = 0; i < n; i++){
    time += ba.at(i).second;
    if (time > ba.at(i).first){
      cout <<"No"<<endl;
      return 0;
    }
  }
  cout <<"Yes"<< endl;
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 N,K;
    cin >> N >> K;

    if(N==2){
        if(K==0){
            cout << 1 << endl;
            cout << 1 << " " << 2 << endl;
        }else{
            cout << -1 << endl;
        }
        return;
    }

    if(K>(N-1)*(N-2)/2){
        cout << -1 << endl;
        return;
    }

    vector<vector<i64>> graph(N,vector<i64>(N));
    rep(i,1,N){
        graph[0][i]=graph[i][0]=1;
    }

    i64 cnt=(N-1)*(N-2)/2;
    while(cnt>K){
        rep(i,1,N){
            rep(j,i+1,N){
                if(graph[i][j]==1) continue;
                --cnt;
                graph[i][j]=graph[j][i]=1;
                if(cnt==K) break;
            }
            if(cnt==K) break;
        }
    }

    vector<i64> u,v;
    rep(i,0,N){
        rep(j,i+1,N){
            if(graph[i][j]==1){
                u.emplace_back(i);
                v.emplace_back(j);
            }
        }
    }

    cout << u.size() << endl;
    rep(i,0,u.size()){
        cout << u[i]+1 << " " << v[i]+1 << endl;
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<map>
using namespace std;

int main()
{
	string s, t;

	cin >> s >> t;
	if (s[0] == 'H' && t[0] == 'H')
		cout << "H";
	if (s[0] == 'D' && t[0] == 'H')
		cout << "D";
	if (s[0] == 'D' && t[0] == 'D')
		cout << "H";
	if (s[0] == 'H' && t[0] == 'D')
		cout << "D";
}

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

using namespace std;

int main()
{
    int N, p[101], A, B, i, x=0, y=0, z=0, min;
    cin>>N>>A>>B;
        for(i=1;i<=N;i++)
            {cin>>p[i];
        if(p[i]<=A)
            x++;
        if(p[i]>=A+1 && p[i]<=B)
            y++;
                if(p[i]>=B+1)
                z++;}

                if(x<=y && x<=z)
                    min=x;
                if(y<=x && y<=z)
                    min=y;
                if(z<=x && z<=y)
                    min=z;
        cout<<min;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Jan 11 19:28:23 2020

@author: masat
"""

N = int(input())
s_list = []
t_list = []
for i in range(N):
    s, t = input().split()
    s_list.append(s)
    t_list.append(int(t))
X = input()

k = s_list.index(X)

time = 0
for i in range(k+1, N):
    time += t_list[i]

print(time)



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


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

    // all the code goes here
    int n,w;cin>>n>>w;

    vector<pair<int,int>> items(n);
    for(int i = 0; i < n; i++)
        cin>>items[i].first>>items[i].second;

    l dp[n+1][w+1];

    for(int i = 0; i <= n; i++)
    {
        for(int j = 0; j <= w; j++)
        {
            if(i == 0 || j == 0)
                dp[i][j] = 0;
            else if(items[i-1].first > j)
                dp[i][j] = dp[i-1][j];
            else
            {
                dp[i][j] = max(items[i-1].second+dp[i-1][j-items[i-1].first],dp[i-1][j]);
            }
        }
    }

    cout<<dp[n][w]<<"\n";

    return 0;
}

Measured memory_bytes: 79104
S = input()

def check(s):
    n = len(s)
    if n%2 != 0:
        return False
    else:
        s1 = s[:(n//2)]
        s2 = s[(n//2):]
        if s1 == s2:
            return True
        else:
            return False

for i in range(len(S)-1, 0, -1):
    if check(S[:i]):
        ans = len(S[:i])
        break

print(ans)

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

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

  for (int i = 0; i < s.size(); i++)
  {
    char c = s[i];
    c-='A';
    c+=n;
    c%=26;
    c+='A';
    cout << (char) c;
  }
  cout << endl;  
}

Measured memory_bytes: 256
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import time
import math
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
S=list(reversed(input()))
lst=[0 for i in range(len(S))]
num=0
z=1
for i in range(len(S)):
    num+=int(S[i])*z
    num%=2019
    z*=10
    z%=2019
    lst[i]=num
lst=Counter(lst)
lst[0]+=1
count=0
for l in lst:
    n=lst[l]
    count+=n*(n-1)//2
print(count)


Measured memory_bytes: 94532