akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int n = sc.nextInt();
		int sum = W * H;

		int[] x = new int[n];
		int[] y = new int[n];
		int[] an = new int[n];
		for (int i = 0; i < n; i++)
		{
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			an[i] = sc.nextInt();
		}
		
		int left = 0;
		int right = W;
		int down = 0;
		int up = H;
		
		for (int i = 0; i < n; i++)
		{
			if(an[i] == 1)
			{
				left = Math.max(x[i], left);
			}else if(an[i] == 2)
			{
				right = Math.min(x[i], right);
			}else if(an[i] == 3)
			{
				down = Math.max(y[i], down);
			}else if(an[i] == 4)
			{
				up = Math.min(y[i], up);
			}
		}
			
		if(right - left <= 0 || up - down <= 0)
		{
			System.out.println(0);
		}else
		{
			System.out.println((right - left ) * (up - down));
		}
			
	}
	

	
}


Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  int ans = a+b;
  if (ans >= 24) {
    ans = ans-24;
  }
  cout << ans << endl;
} 
  

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=1e5+5;
struct eg{int u,v,c;}e[N];
ll m,sum;int fa[N],n,q;
inline int find(R int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
int main(){
	scanf("%d%lld%d",&n,&m,&q);
	fp(i,1,n)fa[i]=i;
	for(R int i=1,u,v;i<=q;++i){
		scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].c);
		++e[i].u,++e[i].v;
		if(!e[i].c)u=find(e[i].u),v=find(e[i].v),fa[u]=v;
		if(e[i].c&&m==n-1)return puts("No"),0;
	}
	if(m==n-1)return puts("Yes"),0;
	for(R int i=1,u,v;i<=q;++i)if(e[i].c){
		u=find(e[i].u),v=find(e[i].v);
		if(u==v)return puts("No"),0;
	}
	fp(i,1,n)sum+=(find(i)==i);
	sum=n-sum+(1ll*sum*(sum-1)>>1);
	puts(m<=sum?"Yes":"No");
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair < int , int > pii;
#define mpr make_pair
#define FS first
#define SC second
#define PB push_back
template < typename T > T MAX(T a,T b){return (a>b)?a:b;}
template < typename T > T MIN(T a,T b){return (a<b)?a:b;}
template < typename T > void UMAX(T &a,T b){a=(a>b?a:b);}
template < typename T > void UMIN(T &a,T b){a=(a<b?a:b);}
LL readint(){
	char c=getchar();
	LL ret=0ll;
	bool neg=0;
	while(!(c>='0' && c<='9')){
		if(c=='-') neg=1;
		c=getchar();
	}
	while(c>='0' && c<='9'){
		ret=ret*10ll+(LL)(c-'0');
		c=getchar();
	}
	return neg?-ret:ret;
}
void putint(LL v){
	if(v<0){
		putchar('-');
		v=-v;
	}
	if(!v){
		putchar('0');
		return;
	}
	if(v>=10ll) putint(v/10ll);
	putchar('0'+(v%10ll));
}
map < int , LL > mem;
int ptr=13,A=0,B=1,zero=10,one=11,two=12;
vector < string > out;
void add(int a,int b,int t){
//	mem[t]=mem[a]+mem[b];
	char s[50]={};
	sprintf(s,"+ %d %d %d\n",a,b,t);
	out.push_back(string(s));
}
void cmp(int a,int b,int t){
//	mem[t]=mem[a]<mem[b];
	char s[50]={};
	sprintf(s,"< %d %d %d\n",a,b,t);
	out.push_back(string(s));
}
void ass(int s,int t){
	add(s,zero,t);
}
int opr_and(int u,int v,int w=ptr++){
	int tmp=ptr++;
	add(u,v,tmp);
	cmp(one,tmp,w);
	return w;
}
void left_shift_by_k(int a,int k){
	int i;
	for(i=0;i<k;++i) add(a,a,a);
}
vector < int > decomp(int u){
	int i,j,k;
	vector < int > pws(31);
	for(i=0;i<=30;++i) pws[i]=ptr++;
	ass(one,pws[0]);
	for(i=1;i<=30;++i){
		add(pws[i-1],pws[i-1],pws[i]);
	}
	vector < int > ret(31);
	for(i=0;i<=30;++i) ret[i]=ptr++;
	int got=ptr++;
	for(i=30;i>=0;--i){
		int cur=ptr++;
		for(j=0;j<i;++j) add(cur,pws[j],cur);
		add(cur,got,cur);
		int cmpv=ptr++;
		cmp(cur,u,cmpv);
//		printf("cmp %lld %lld %lld\n",mem[cur],mem[u],mem[cmpv]);
		ass(cmpv,ret[i]);
		left_shift_by_k(cmpv,i);
		add(got,cmpv,got);
	}
	return ret;
}
#define initialization_confirm
#define corner_case_check
#define return_type_of_template_and_operator
int main(){
	#ifdef LOCAL_QTY
		#ifndef initialization_confirm // 不要忘记初始化
			exit(0);
		#endif
		#ifndef corner_case_check // 不要忘记检查边界情况（图不连通，n=1，etc.）
			exit(0);
		#endif
		#ifndef return_type_of_template_and_operator // 勿忘返回值类型
			exit(0);
		#endif
	#endif
	int i,j,k;
//	cin>>mem[A]>>mem[B];
	add(A,B,3);
	cmp(zero,3,one);
	add(one,one,two);
	vector < int > dA=decomp(A),dB=decomp(B);
//	for(i=0;i<31;++i) cout<<mem[dA[i]];
//	cout<<endl;
//	for(i=0;i<31;++i) cout<<mem[dB[i]];
//	cout<<endl;
	vector < int > res(62);
	for(i=0;i<62;++i) res[i]=ptr++;
	for(i=0;i<31;++i){
		for(j=0;j<31;++j){
			add(res[i+j],opr_and(dA[i],dB[j]),res[i+j]);
		}
	}
	for(i=0;i<62;++i){
		left_shift_by_k(res[i],i);
		add(2,res[i],2);
	}
//	cout<<mem[2]<<endl;
//	printf("%d\n",ptr);
	printf("%d\n",(int)out.size());
	for(i=0;i<(int)out.size();++i){
		printf("%s",out[i].c_str());
	}
	return 0;
}
/*
 * 代码框架
 * 1. ptr维护已经用过的位置
 * 2. 实现and，参数为原坐标，返回新坐标
 * 3. 实现二进制分解，参数为原坐标，返回vector表示坐标列表
 * 4. 将两个数二进制分解
 * 5. 两两枚举位，把and的结果加到对应位上
 * 6. 不断进行a=(2a+cur)的操作，得到结果
*/

Measured memory_bytes: 3828
#include<stdio.h>
#include <stdlib.h>
#define ll long long

int main(){
  ll n,i,a[200001],sum[200001],k,ans;
  scanf("%lld",&n);
  sum[0]=0;
  for(i=1;i<=n;i++){
    scanf("%lld",&a[i]);
    sum[i]=sum[i-1]+a[i];
  }

  for(i=1;i<=n;i++){
    if(sum[i]>sum[n]/2){
      k=i;
      break;
    }
  }

  ans=abs(sum[n]-sum[k-1]*2)>abs(sum[n]-sum[k]*2)?abs(sum[n]-sum[k]*2):abs(sum[n]-sum[k-1]*2);

  printf("%lld",ans);
  
  return 0;
}

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

const int MAXN = 300010;

int n, a[MAXN];

bool Check(int l, int r)
{
	int mn = MAXN, mx = 0;
	for(int i = l; i <= r; ++i)
	{
		mn = min(mn, a[i]);
		mx = max(mx, a[i]);
	}
	if(mn != l || mx != r) return 0;
	int x = 0, y = 0;
	for(int i = l; i <= r; i += 2)
	{
		if(a[i] > i)
		{
			if(a[i] > x) x = a[i];
			else return 0;
		}
		else if(a[i] < i)
		{
			if(a[i] > y) y = a[i];
			else return 0;
		}
		else return 0;
	}
	return 1;
}

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	for(int i = 1; i <= n; ++i)
	{
		if(a[i] == i) continue;
		int j = i;
		while(j <= n - 2)
		{
			if(a[j + 1] != j + 1) break;
			if(a[j + 2] == j + 2) break;
			j += 2;
		}
		if(j == i || !Check(i, j))
		{
			puts("No");
			return 0;
		}
		i = j;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1536
N = int(input())
s_cnt = []
for i in range(N):
    cnt = {}
    s = input()
    for si in s:
        if si in cnt:
            cnt[si] += 1
        else:
            cnt[si] = 1
    s_cnt.append(cnt)
min_ = {}
for i in s_cnt:
    for j in i:
        if any([j not in s_cnt[k] for k in range(N)]):
               continue
        if j not in min_:
            min_[j] = i[j]
        else:
            min_[j] = min(min_[j], i[j])
string = ''
for i in min_:
    #list_.append(i * min_[i])
    string += i * min_[i]
s = sorted(string)
print(''.join(s))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll  long long 
using namespace std;
const int MAXN=2e5+10;
const ll MAX=1e18;
ll a[MAXN];
ll n,x,ans;
int main()
{
	scanf("%lld%lld",&n,&x);
	for (int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		a[i]=a[i-1]+a[i];
	};
	ans=MAX;
	for (int i=1;i<=n;i++)
	{
		ll w=x*n;
		w+=(a[n]-a[n-i])*5;
		w+=x*(ll)i;
		ll sum=5;
		for (int j=2;j<=n/i;j++)
		 {
		 	w+=(a[n-(j-1)*i]-a[n-j*i])*sum;
		 	if (w>ans) break;
		 	sum+=2;
		 }
		if (n%i!=0) w+=a[n%i]*sum;
		ans=min(ans,w); 
	}
	printf("%lld",ans);
}

Measured memory_bytes: 1792
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;

  auto cards = new bool[](52);
  foreach (_; 0..n) {
    auto c = readln.chomp;
    cards[cardStoI(c)] = true;
  }

  foreach (int i, c; cards)
    if (!c) writeln(cardItoS(i));
}

int cardStoI(string c)
{
  auto rd = c.split;
  auto s = rd[0], r = rd[1].to!int;
  return s.predSwitch("S", 0, "H", 1, "C", 2, "D", 3) * 13 + r - 1;
}

string cardItoS(int c)
{
  auto s = c / 13, r = c % 13 + 1;
  return s.predSwitch(0, "S", 1, "H", 2, "C", 3, "D") ~ " " ~ r.to!string;
}

Measured memory_bytes: 2424
from collections import defaultdict
vertices, edges = (int(n) for n in input().split(" "))
connect = defaultdict(list)
cost_dp = [[float("inf") if n != m else 0 for n in range(vertices)] for m in range(vertices)]
for e in range(edges):
    v1, v2, weight = (int(n) for n in input().split(" "))
    connect[v1].append([v2,weight])
    connect[v2].append([v1,weight])
    cost_dp[v1][v2] = weight
for neg in range(2):
    updated = 0
    for t in range(vertices):
        for i in range(vertices):
            for k in range(vertices):
                if cost_dp[i][k] > cost_dp[i][t] + cost_dp[t][k]:
                    updated = 1
                    cost_dp[i][k] = cost_dp[i][t] + cost_dp[t][k]
if neg == 1 and updated:
    print("NEGATIVE CYCLE")
else:
    for ve in range(vertices):
        ans = ["INF" if n == float("inf") else n for n in cost_dp[ve]]
        print(*ans)

Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
map<int,int> mp;

int main()
{
    int n;
    cin>>n;
    int flag=1;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        if(mp[x]==1)
        {
            flag=0;
        }
        mp[x]=1;
    }
    if(flag==1)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
int main(){

  int a,b,c;
  cin >> a;
  cin >> b;
  vector<int> t(10000);

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

  if(a >= 0){
    cout << a << endl;;
  }else{
    cout << -1 << endl;;
  }


}


Measured memory_bytes: 3676
#include <stdio.h>

int main() {
    int ball_num, i, j;
    scanf("%d", &ball_num);
    long x[ball_num], y[ball_num];
    for ( i = 0; i < ball_num; i++ ) {
        scanf("%ld%ld", &x[i], &y[i]);
    }

    typedef struct pq_set {
        long p;
        long q;
        int  cnt;
    } pq_set;
    int set_num = ball_num * ball_num;
    pq_set pq[set_num];
    for ( i = 0; i < set_num; i++ ) {
        pq[i].p = 0;
        pq[i].q = 0;
        pq[i].cnt = 0;
    }
    set_num = 0;

    for ( i = 0; i < ball_num; i++) {
        for ( j = 0; j < ball_num; j++ ) {
            if ( i != j ) {
                pq[set_num].p = x[i] - x[j];
                pq[set_num].q = y[i] - y[j];
//                printf("(p, q) = (%ld, %ld)\n", pq[set_num].p, pq[set_num].q);
                set_num += 1;
            }
        }
    }

    int score[set_num];
    for ( i = 0; i < set_num; i++ ) {
        score[i] = 1;
    }
    for ( i = 0; i < (set_num - 1); i++ ) {
        for ( j = (i + 1); j < set_num; j++ ) {
            if ( pq[i].p == 0 && pq[i].q == 0 ) {
                break;
            }
            if ( pq[i].p == pq[j].p && pq[i].q == pq[j].q ) {
                score[i] += 1;
            }
        }
    }

    int max_score = 0;
    for ( i = 0; i < set_num; i++ ) {
//        printf("score = %d\n", score[i]);
        if ( score[i] > max_score ) {
            max_score = score[i];
        }
    }

    printf("%d\n", ball_num - max_score);
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

int N;
long long Sum[200005];

void MakeSumTable(int a[]) {
	//0からiまでの累積和を記録するテーブルをつくる
	Sum[0] = a[0];
	for (int i = 1;i < N;i++) {
		Sum[i] = Sum[i - 1] + a[i];
	}
}

int main() {
	int a[200005];
	long long mind = 1e18;
	cin >> N;
	for (int i = 0;i < N;i++) {
		cin >> a[i];
	}

	MakeSumTable(a);

	for (int i = 0;i < N - 1;i++) {
		//前半の和はSum[i]，後半の和はSum[N-1]-Sum[i]
		mind = min(mind, abs((Sum[N - 1] - Sum[i]) - Sum[i]));
	}

	cout << mind << endl;

	return 0;
}

Measured memory_bytes: 2560
k, n = map(int, input().split())
 
An = list(map(int, input().split()))
 
node = [An[i+1] - An[i]  for i in range(len(An) - 1)]
 
node = node[:] + [k - An[n-1] + An[0]]
 
print(k - max(node))

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

int r[200000];
ll a[200000],b[200000],c[200000];
int main(){
	ll x,k;scanf("%lld%lld",&x,&k);
	rep(i,k)scanf("%d",&r[i+1]);
	c[0]=x;
	rep(i,k){
		int s=r[i+1]-r[i];
		if(i%2==0)s=-s;
		a[i+1]=min(max(a[i]+s,0LL),x);
		b[i+1]=b[i]+s;
		c[i+1]=min(max(c[i]+s,0LL),x);
	}
	int q;scanf("%d",&q);
	rep(i,q){
		int t,d;scanf("%d%d",&t,&d);
		int j=upper_bound(r,r+k+1,t)-r-1;
		int s=t-r[j];
		if(j%2==0)s=-s;
		ll na=min(max(a[j]+s,0LL),x);
		ll nb=b[j]+s;
		ll nc=min(max(c[j]+s,0LL),x);
		printf("%lld\n",min(max(nb+d,na),nc));
	}
}

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

#define INF (ll)1e+15

int main(){

	  int V,E; cin >> V >> E;
	  AdjMat G(V,vector<ll>(V,INF));

	  for(int i=0; i<E; i++){
			int s,t,d; cin >> s >> t >> d;
			G[s][t] = d;
	  }

	  for(int i=0; i<V; i++) G[i][i] = 0;

	  for(int k=0; k<V; k++)
			for(int j=0; j<V; j++)
				  for(int i=0; i<V; i++)
						G[i][j] = min(G[i][j], G[i][k] + G[k][j]);

	  for(int i=0; i<V; i++)
			if(G[i][i] != 0){	  cout << "NEGATIVE CYCLE" << endl;	  return 0;			}

	  for(int i=0; i<V; i++){
			for(int j=0; j<V; j++){
				  if(G[i][j] >= 1e+14) cout << "INF";
				  else cout << G[i][j];
				  if(j==V-1) cout << endl;
				  else cout << " ";
			}
	  }
}
			
	  
			   

Measured memory_bytes: 1296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    int x, y; cin >> x >> y;
    int ans = 0;
    rep(i, 100) {
        rep(j, 100) {
            if(i + j == x && 2*i + 4*j == y) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3632
n, k = map(int, input().split())
mk = n // k
mh = 0 if k % 2 != 0 else n // (k // 2) - mk
print(mk+3*mk*(mk-1)+mk*(mk-1)*(mk-2)+mh+3*mh*(mh-1)+mh*(mh-1)*(mh-2))


Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <iomanip>
#include <vector>
using namespace std;
typedef long long ll;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
#define MAX_V 100001
#define MOD 1000000007

int main(){
    int k;cin>>k;
    int a,b;cin>>a>>b;
    int flag=0;
    for(int i=a;i<b+1;i++){
        if(i%k==0) flag=1;
    }
    if(flag) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
}

Measured memory_bytes: 3632
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.next());
        ArrayList<Integer> a = new ArrayList<>();

        for(int i=0; i<n; i++){
        	a.add(Integer.parseInt(sc.next()));
        }

        long ans1 = 0;
        long sum1 = 0;
        long sign1 = 1;
        for(int i=0; i<n; i++){
        	sum1 += a.get(i);
        	if (sum1 * sign1 <= 0){
        		ans1 += Math.abs(sum1) + 1;
        		sum1 = sign1;
        	}
        	sign1 *= -1;
        }

        long ans2 = 0;
        long sum2 = 0;
        long sign2 = -1;
        for(int i=0; i<n; i++){
        	sum2 += a.get(i);
        	if (sum2 * sign2 <= 0){
        		ans2 += Math.abs(sum2) + 1;
        		sum2 = sign2;
        	}
        	sign2 *= -1;
        }

        System.out.println(Math.min(ans1, ans2));
    }
}

Measured memory_bytes: 48964
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>
#include<iomanip>
 
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define pii pair<int,int>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp(a, b) make_pair(a, b)
#define mt(a,b,c) make_tuple(a,b,c)
#define rank qwertyuio
#define next dfghjk
#define plus fsghsf
#define minus ytryr
#define pb push_back
using namespace std;
 
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
 
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int mod = (int)1e9 + 7;
const int mod1 = (int)1e9 + 9;
const int mod2 = 998244353;
const int mod3 = (int)1e6+3;
const ld eps = 1e-12;
const double pi = atan2(0, -1);
const int ABC = 26;
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
   
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);<<" "
    ll a,b;
    cin>>a>>b;
    ll hrm=gcd(a,b);
    cout<<a*b/hrm;
    return 0;
             
    
}

Measured memory_bytes: 256
import Control.Applicative
import Data.List
import Data.Char

getInt :: IO Int
getInt = (\a -> read a :: Int) <$> getLine

getIntArray :: IO [Int]
getIntArray = ((map (\a -> read a :: Int)) . words) <$> getLine

getStrArray :: Int -> IO [String]
getStrArray 0 = return [] :: IO [String]
getStrArray n = (:) <$> getLine <*> (getStrArray (n - 1))

getMat :: [String] -> String
getMat [[a, _, _], [_, b, _], [_, _, c]] = [a, b, c]

main = do
    s <- getStrArray 3
    putStrLn $ getMat s


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

#define M 1000000007
#define FOR(i, s, n) for (ll i = (s); i < (n); ++i)
#define FORALL(i, n) for (ll i = 0; i < (n); ++i)
#define MOD 1000000007
#define ff first
#define ss second
#define pll pair<long long, long long>
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(false)
#define countbits(x) __builtin_popcount(x)
#define pb(x) push_back((x))
#define vll vector<ll>
#define all(x) x.begin(),x.end()
#define print(x) cout << x << endl
#define debug print("reaching\n")
#define mll map<ll,ll>
#define lsb(i) i&(-i)
#define printv(x) \
	FORALL(i, x.size()) \
	{ \
		cout << x[i] << ' '; \
	} \
	cout << endl \
;
#define printm(m) \
	for(auto i: m){\
		cout<<i.ff<<' '<<i.ss<<endl; \
	}\
;
// vector<map<ll,ll>> m(2);
long long binpow(long long a, long long b) {
	if(b<=0) return 1;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}



template <typename T>
T extGcd(T a, T b, T &x, T &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	else
	{
		int g = extGcd(b, a % b, y, x);
		y -= a / b * x;
		return g;
	}
}

template <typename T>
T modInv(T a, T m)
{
	T x, y;
	extGcd(a, m, x, y);
	return (x % m + m) % m;
}

void Linearsieve(ll n, vll& primes)
{
    vector<bool> v(n + 1, true);
    for (ll i = 2; i <= n; i++)
    {
        if (v[i])
        {
            primes.pb(i);
        }
        for (int j = 0; j < primes.size() && i * primes[j] <= n; j++)
        {

            v[i * primes[j]] = false;

            if (i % primes[j] == 0)
            {
                break;
            }
        }
    }
}


int main()
{
	fast;
	cin.tie(0);
	cout.tie(0);
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif

	int t=1;
	// cin>>t;
	ll tot=t;
	while(t--){
		ll n;
		cin>>n;
		vll v(n);
		ll maxo = 0;
		FORALL(i,n){
			cin>>v[i];
		}
		unordered_map<ll, ll> m;
		int p = 1;
		ll temp = v[0];
		FORALL(i,n){
			temp = __gcd(temp, v[i]);
		}
		FORALL(i, n){
			if(v[i] == 1) continue;
			for(int j = 2; j <= sqrt(v[i]); j++){
				if(v[i]%j==0){
					m[j]++;
					if(m[j]>1){
						p = 0;
						break;
					}
					while(v[i]%j==0){
						v[i]/=j;
					}
				}
			}
			if(v[i]!=1){
				m[v[i]]++;
				if(m[v[i]]>1){
					p = 0;
					break;
				}
			}
			if(p==0) break;
		}

		if(p){
			print("pairwise coprime");
		}
		else if(temp==1){
			print("setwise coprime");
		}
		else{
			print("not coprime");
		}
	}
	return 0;
}


Measured memory_bytes: 11044
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

int N, Q, A[1<<20], L[1<<20], R[1<<20], foc[1<<20];
vector<int> qord;

// Binary Indexed Tree (Fenwick Tree)
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r) - sum(l-1);
  }
};

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(NULL);

 cin>>N>>Q;
 rep(i,N){cin>>A[i+1];}
 rep(i,Q) {cin>>L[i]>>R[i];qord.pb(i);}
 sort(qord.begin(), qord.end(), [](const int &i, const int &j){
   return L[i] > L[j];
 });

 BIT<int> bit(N+5);
 int j = N;
 for(int &i: qord) {
   int l = L[i] , r = R[i];
   while(j >= l) {
     if(foc[A[j]]) {bit.add(foc[A[j]], -1);}
     foc[A[j]]=j;bit.add(j, 1);
     j--;
   }
   // cout << "||" << bit.sum(r) << endl;
   // cout << "||" << bit.sum(l-1) << endl;
   L[i] = bit.sum(l, r);
 }

 rep(i,Q) cout<<L[i]<<endl;

 return 0;
}


Measured memory_bytes: 15568
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int n1;
int n, v, p;
ll m;
ll a1[100010], c[100010];
bool check(int k){
	vector<ll> va, va2(n);
	for(int i=0; i<n1; i++){
		for(int j=0; j<c[i]; j++) va.push_back(a1[i]);
	}
	int k1=0;
	for(int i=0; i<n; i++){
		if(va[i]==a1[k]){
			k1=i;
			break;
		}
	}
	if(k1<p) return true;
	ll cnt=n-k1+p-1;
	if(cnt>v){
		if(va[p-1]<=a1[k]+m){
			return true;
		}else{
			return false;
		}
	}
	if(va[p-1]>a1[k]+m) return false;
	ll v1=v-cnt;
	vector<ll> x;
	for(int i=p-1; i<k1; i++) x.push_back(a1[k]+m-va[i]);
	ll s=0;
	for(int i=0; i<x.size(); i++){
		x[i]=min(x[i], m);
		s+=x[i];
	}
	if(s>=v1*m) return true;
	else return false;
}
int main()
{
	cin>>n>>m>>v>>p;
	ll a[100010];
	map<ll, int> mp;
	for(int i=0; i<n; i++){
		cin>>a[i];
		mp[a[i]]++;
	}
	auto itr=mp.end(); itr--;
	for(;;itr--){
		a1[n1]=itr->first, c[n1]=itr->second;
		n1++;
		if(itr==mp.begin()) break;
	}
	if(check(n1-1)){
		cout<<n<<endl;
		return 0;
	}
	int l=0, r=n1-1;
	while(r-l>1){
		int mid=(l+r)/2;
		if(check(mid)) l=mid;
		else r=mid;
	}
	int ans=0;
	for(int i=0; i<=l; i++) ans+=c[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12184
#include <bits/stdc++.h> 
 
using namespace std;
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 

int main(){
    string s;cin>>s;
    bool flag=1;
    for(int i=0;i*2<SZ(s);i++){
        if(s[i]!=s[SZ(s)-1-i])flag=0;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=15;
char str[maxn];
int main()
{
    while(~scanf("%s",str))
    {
        int len=strlen(str);
        int n=1<<(len-1);
        ll ans=0;
        for(int i=0;i<n;i++)
        {
            ll t=str[0]-'0';
            for(int j=0;j<len;j++)
            {
                if(j==len-1||i&(1<<j))
                {
                    ans+=t;
                    t=0;
                    if(j==len-1)
                        break;
                }
                t=t*10+str[j+1]-'0';
            }
        }
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 256
num = int(input())
lines = input().split(" ")
numline = [int(i) for i in lines]
numbers = [i+1 for i in range(num)]
dic = dict(zip(numbers, numline))

dic2 = sorted(dic.items(), key=lambda x:x[1])
arr = []

for i in range(num):
  arr.append(str(dic2[i][0]))
  
print(" ".join(arr))

Measured memory_bytes: 39140
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long ans = 0;
        for(int a=1; a<n; a++) {
            int maxb = maxb(a, n);
            ans += maxb;
        }
        System.out.println(ans);
    }
    private static int maxb(int a, int n) {
        // a*b < n となる最大のbを探す
        int maxb = n/a;
        if(a*maxb >= n) {
            maxb--;
        }
        else if(a*(maxb+1)<n) {
            // 無い気がするけど、一応
            maxb++;
        }
        return maxb;
    }
}


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

int n,k,r,s,p;
string t;

int getP(char c) {
  if (c == 'r') return r;
  else if (c == 'p') return p;
  else return s;
}

int main() {
  cin>>n>>k>>r>>s>>p>>t;
  int ans = 0;
  char hands[n];
  REP(i, n) {
    if (t[i] == 'r'){
      ans+=p; hands[i] = 'p';
    } else if (t[i] == 's') {
      ans+=r; hands[i] = 'r';
    } else {
      ans+=s; hands[i] = 's';
    }
  }

  for(int i = k; i < n; i++) {
    char last = hands[i-k];
    char hand = hands[i];
    if (hand != last) continue;

    int curP = getP(hand), lastP = getP(last);
    if (curP > lastP) { ans -= lastP; }
    else { ans -= curP; hands[i] = '_'; }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n,m;cin >> n >>m;
    vpl q(m);
    rep(i,m){
        ll a,b;cin >>a >>b;a--;b--;
        q[i]={b,a};
    }
    sort(all(q));
    rep(i,m)swap(q[i].fi,q[i].se);
    ll ans=0;
    ll pre=-1;
    rep(i,m){
        if(q[i].fi>pre){
            pre=q[i].se-1;
            ans++;
        }
    }
    cout <<ans <<endl;
}

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

class Atcoder{
   public static int[] cins() {
      string[] ss = Console.ReadLine().Split(' ');
      int[] Res = new int[ss.Length];
      for (int i = 0; i<ss.Length; i++) {
         Res[i]=int.Parse(ss[i]);
      }
      return Res;
   }
   public static void O(bool b) { Console.WriteLine(b?"Yes":"No"); }
   public static void Main(string[] args) {
      int[] k = cins();
      O(k[2]>=k[0]&&k[2]<=k[1]);
   }
}

Measured memory_bytes: 11092
def main():
    from collections import deque
    from operator import itemgetter
    import sys
    input = sys.stdin.readline

    MOD = 998244353

    N = int(input())

    xds = []
    xs = []
    for _ in range(N):
        x, d = map(int, input().split())
        xds.append((x, d))
        xs.append(x)

    xds.sort(key=itemgetter(0), reverse=True)
    xs.sort()

    ps = [-1] * (N + 1)
    cands = deque()  # 既出の頂点で有向辺の行き先に設定されていないもの,x昇順
    for j, (x, d) in enumerate(xds):
        j = N - 1 - j
        while cands:
            cx, ci = cands[0]
            if x + d <= cx:
                # candは独立
                break
            elif x <= cx < x + d:
                # candと連結
                ps[ci] = j
                cands.popleft()
        cands.appendleft((x, j))

    ret = 1
    ctr = [1] * N
    for j, (x, d) in enumerate(xds):
        j = N - 1 - j
        par = ps[j]
        ctr[j] += 1  # j=off,子の総積が設定されている->j=on=1を加算
        if ~par:
            ctr[par] = ctr[par] * ctr[j] % MOD
        else:
            ret = ret * ctr[j] % MOD  # j=木のroot

    print(ret)
    return


if __name__ == '__main__':
    main()


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

# In[8]:


import math


# In[5]:


A,B,C,D = map(int, input().split())


# In[14]:


ac = (A-1)//C
bc = B//C
ad = (A-1)//D
bd = B//D
a_both = (A-1)//(C*D//math.gcd(C,D))
b_both = B//(C*D//math.gcd(C,D))
print((B-A+1) - (bc-ac) - (bd-ad) + (b_both-a_both))


# In[ ]:






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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		int n = Integer.parseInt(str);
		str = input.readLine( );
		String[] list = str.split(" ");
		long count = 0;
		for(int i=0; i<n; i++){
			count += Integer.parseInt(list[i])%2;
		}
		if(count%2 == 0){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}

	}
}


Measured memory_bytes: 39636
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

ll N;
vector<vector<ll>> abc;

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

	int N, L;
	cin >> N >> L;
	vector<int> taste(N);
	rep(i, N)
		taste[i] = L + i;

	int minind = 0;
	int min = INT32_MAX;
	rep(i, N) {
		if (min > abs(taste[i])) {
			min = abs(taste[i]);
			minind = i;
		}
	}
	
	int sum = 0;
	rep(i, N) {
		if (i == minind) continue;
		sum += taste[i];
	}

	cout << sum << endl;

	/*
	ll N, W;
	cin >> N >> W;

	vector<ll> w(N), v(N);

	rep(i, N) {
		cin >> w[i] >> v[i];
	}

	vector<vector<ll>> dp(N + 1);
	rep(i, N + 1) dp[i].resize(W + 1);

	for (int i = 0; i < N; i++) {
		for (int weight = 0; weight <= W; weight++) {
			if (weight - w[i] < 0) {
				chmax(dp[i + 1][weight], dp[i][weight]);
			}
			else chmax(dp[i + 1][weight], dp[i][weight - w[i]] + v[i]);
		}
	}

	/*
	rep(i, N + 1) {
		rep(j, W + 1) {
			cout << to_string(dp[i][j]) + " ";
		}
		cout << endl;
	}*

	cout << dp[N][W] << endl;

	*/

ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}


Measured memory_bytes: 504
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int memo[100100];
bool done[100100];
vector<int> v[100100],g[100100];

int solve(int p){
	int n,i;
	if(done[p]){
		return memo[p];
	}
	done[p] = true;
	memo[p] = 0;
	n = g[p].l_ength();
	for(i=0; i<n; ++i){
		v[p].push_back(solve(g[p][i]));
	}
	sort(v[p].begin(),v[p].end());
	for(i=0; i<n; ++i){
		memo[p] = max(memo[p],v[p][i]+n-i);
	}
	return memo[p];
}

int main(void){
	int n,i,a;
	cin >> n;
	for(i=1; i<n; ++i){
		cin >> a; --a;
		g[a].push_back(i);
	}
	cout << solve(0) << endl;
	return 0;
}


Measured memory_bytes: 20992
N,L=map(int,input().split())
A=[0]*201
m=100000
point=0
for i in range(1,N+1):
  A[i]=L+i-1
  if abs(L+i-1)<m:
    m=abs(L+i-1)
    p=i
print(sum(A)-A[p])

Measured memory_bytes: 3060
A = list(map(int,input().split()))
A.sort(reverse = True)

X = A[0] - A[1]
Y = A[0] - A[2]
ans = 0

if (X % 2 == 0) and (Y % 2 == 0):
    ans = X//2 + Y//2
elif (X % 2 == 1) and (Y % 2 == 1):
    ans = X//2 + Y//2 + 1
else:
    ans = X//2 + Y//2 + 2

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string a,b,c;
    cin>>a>>b>>c;
    
    
    if(a.back() == b.front() && b.back() == c.front()){
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
template <typename T>
ll extGCD(T a, T b) {
  if (b == 0) {
    return a;
  }
  ll d = extGCD(b, a % b);
  return d;
}
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> L(N + 1), R(N + 1);
  REP(i, N) { cin >> A[i]; }
  L[0] = 0;
  REP(i, N) { L[i + 1] = extGCD(L[i], A[i]); }
  R[N] = 0;
  for (int i = N - 1; i >= 0; i--) {
    R[i] = extGCD(R[i + 1], A[i]);
  }
  int ans = 0;
  REP(i, N) { ans = max<ll>(ans, extGCD(L[i], R[i + 1])); }
  cout << ans << endl;
}

Measured memory_bytes: 4520
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int y[100], x[100];

constexpr double EPS = 1e-13;
constexpr double PI = 3.14159265358979323;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  cin >> n;
  
  vector<pair<double, int>> v;
  for(int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    v.emplace_back(atan2(y[i], x[i]), i);
    v.emplace_back(atan2(y[i], x[i]) + 2 * PI, i);
  }
  

  ll X = 0, Y = 0;
  ll ans = 0;

  auto check = [&]() {
    ans = max(ans, X * X + Y * Y);
  };

  auto now = [&]() {
    return (X * X + Y * Y);
  };

  auto add = [&](int i) {
    X += x[i];
    Y += y[i];
    check();
  };

  auto rem = [&](int i) {
    X -= x[i];
    Y -= y[i];
    check();
  };

  sort(begin(v), end(v));
  add(v.back().second);
  int r = 0;
  for(int i = 0; i < n; i++) {
    int j = (2 * n + i - 1) % (2 * n);
    int id = v[i].second;
    rem(v[j].second);
    if(i == r) add(id), (++r) %= 2 * n;

    for(;r < 2 * n and v[r].first < v[i].first + PI + EPS; r++) {
      add(v[r].second);
    }
  }
  cout << fixed << setprecision(11);
  cout << sqrt(ans) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    int n;
    cin >>n;
    vector<pair<int,int>>a(n);
    for(int i=0;i<n;i++){
        int z,zz;
        cin >>z >>zz;
        a.at(i)=make_pair(z,zz);
    }
    ll che=0;
    for(int i=0;i<n;i++){
        if(a.at(i).first==a.at(i).second)che++;
        else che=0;
        if(che==3){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}
    



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t,u;
  cin >> s;
  for(int i=0;i<s.size()/2;i++){
      t += s.at(i);
      u += s.at(s.size()-i-1);
  }
  int count=0;
  for(int i=0;i<t.size();i++){
    if(t.at(i)!=u.at(i)){
      count++;
    }
  }
  cout << count <<endl;
}

Measured memory_bytes: 256
n,x = map(int,input().split())
a = list(map(int,input().split()))
i = 0

if x > sum(a):
    print(n-1)
else:
    a.sort()
    while(x > 0):
        x -= a[i]
        if x >= 0:
            i += 1
    print(i)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main() {
    string s;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2]<<s[3]<<s[4]<<" "<<s[6]<<s[7]<<s[8]<<s[9]<<s[10]<<s[11]<<s[12]<<" "<<s[14]<<s[15]<<s[16]<<s[17]<<s[18];
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

typedef int value_type; /* ソートするキーの型 */

value_type med3(value_type x, value_type y, value_type z)
/* x, y, z の中間値を返す */
{
    if (x < y)
        if (y < z) return y; else if (z < x) return x; else return z; else
        if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type a[], int left, int right,value_type index[])
/* クイックソート
 * a     : ソートする配列 
 * left  : ソートするデータの開始位置
 * right : ソートするデータの終了位置
 * index: index配列
 */
{
    if (left < right) {
        int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
        while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
            while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
            while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
            tmp = index[i]; index[i] = index[j]; index[j] = tmp;
            i++; j--;
        }
        quicksort(a, left, i - 1,index);  /* 分割した左を再帰的にソート */
        quicksort(a, j + 1, right,index); /* 分割した右を再帰的にソート */
    }
}


int dfs(int n,int N){
    if (n>N){
        return 0;
    }
    

    int ret;
    
    return ret;
}
int main(){
    int N,M;
    //string S;
    cin >>N>>M;

    int X[M];
    FOR(i,M){
        cin>>X[i];
    }
    sort(X,X+M);
    int dif[M-1];
    FOR(i,M-1){
        dif[i]=X[i+1]-X[i];
    }
    sort(dif,dif+M-1);
    int ans=0;
    if(N>=M){
        ans=0;
    }else{
        for(int i=0;i<M-1-(N-1);i++){
            ans+=dif[i];
        }
    }



    std::cout << ans<< endl;
    return 0;
}

Measured memory_bytes: 1024
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N = int(input())
    if N%2==0:
        print(N//2-1)
    else:
        print(N//2)
        

if __name__ == '__main__':
    main()


Measured memory_bytes: 5716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll N, K; cin >> N >> K;
    N %= K;
    cout << min(N, K - N) << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char (digitToInt)
import Data.Vector.Unboxed (Vector, (!), (//))
import qualified Data.Vector.Unboxed as V

main :: IO ()
main = solve <$> readLn <*> getLine <*> (getLine >> f) >>= print
  where f = map read <$> words <$> getLine

solve :: Int -> String -> [Int] -> Int
solve n ids cs = dp ! ((10 - sm) `mod` 10)
  where (_,sm,as) = foldl' f (n, 0, []) ids
        f (i,s,xs) c | c == '*' && odd i = (i-1, s, cs : xs)
                     | c == '*' = (i-1, s, cs' : xs)
                     | odd i = (i-1, (s + digitToInt c) `mod` 10, xs)
                     | otherwise = (i-1, (s + dbl (digitToInt c)) `mod` 10, xs)
        cs' = map dbl cs
        dbl x = let x2 = x * 2 in if x2 > 9 then x2 - 9 else x2
        dp = foldl' g (V.replicate 10 0 // [(0,1)]) as :: Vector Int
        g v xs = V.accum (+) (V.replicate 10 0) $ do
          i <- [0..9]
          guard $ v ! i > 0
          x <- xs
          return ((i+x) `mod` 10, v ! i)



Measured memory_bytes: 21304
/*
    JAI JAGANNATH!
*/
//@Author : zanj0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<lli>
#define mii             map<lli,lli>
#define pqb             priority_queue<lli>
#define pqs             priority_queue<lli,vi,greater<lli> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            lli x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void zanj0()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
lli add(lli a, lli b) {
	return (( a % mod) + (b % mod)) % mod;
}

void solve() {
	lli ret  = 0;
	lli n, k;
	cin >> n >> k;
	lli nextSmall = 1;
	lli nextBig = n - 1;
	lli low = 0;
	lli high = n;
	for (lli i = 1 ; i ; i++) {
		lli cnt = high - low + 1;

		//cout << low << " " << high << endl;
		//cout << i << " -- " << cnt << endl;
		if (i >= k) {
			//cout << "ADd!" << endl;
			ret = add(ret, cnt);
		}
		low += nextSmall;
		high += nextBig;
		nextSmall++;
		nextBig--;
		if (low > high) break;
	}
	cout << ret << endl;
}
int main()
{
	zanj0();
	solve();
	return 0;
}

Measured memory_bytes: 3612
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = input()
k = int(input())
l = len(n)
dp1 = [[0]*(k+1) for _ in range(l+1)]
dp0 = [[0]*(k+1) for _ in range(l+1)]
dp1[0][0] = 1
dp0[0][0] = 0
for i in range(1, l+1):
    for j in range(0, k+1):
        if n[i-1]=="0":
            dp1[i][j] = dp1[i-1][j]
        else:
            if j>=1:
                dp1[i][j] = dp1[i-1][j-1]
            dp0[i][j] += dp1[i-1][j]
        if int(n[i-1])>=2 and j>=1:
            dp0[i][j] += dp1[i-1][j-1] * (int(n[i-1])-1)
        if j>=1:
            dp0[i][j] += dp0[i-1][j-1]*9
        dp0[i][j] += dp0[i-1][j]
print(dp0[l][k]+dp1[l][k])

Measured memory_bytes: 62612
#include <stdio.h>
#include <string.h>
int main()
{
    char n[1000];
    int i;
    gets(n);
    int len = strlen(n);
    for(i=0;i<len;i++)
    {
        if(n[i]=='1')
        {
            n[i]=n[i]+8;
        }
        else if(n[i]=='9')
        {
            n[i]=n[i]-8;
        }
        printf("%c",n[i]);
    }
    return 0;
}


Measured memory_bytes: 128