akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back

main()
{
    //freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n;
	cin>>n;
	vector<pair<int,int>> v(n);
	for(int i=0;i<n;i++)
		cin>>v[i].first>>v[i].second;

	sort(v.begin(),v.end());
	
	map<pair<int,int>,int> m;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
			m[{(v[j].first-v[i].first),(v[j].second-v[i].second)}]++;
	}

	int k=0;
	for(auto i:m)
		k=max(k,i.second);

	cout<<n-k;
}

Measured memory_bytes: 384
a11,a12,a13=map(int,input().split())
a21,a22,a23=map(int,input().split())
a31,a32,a33=map(int,input().split())
n=int(input())
l=[]
b=[a11,a12,a13,a21,a22,a23,a31,a32,a33]
for i in range(n):
  m=int(input())
  for j in range(9):
    if m==b[j]:
      b[j]=0
if b[0]==0 and b[1]==0 and b[2]==0:
  print('Yes')
elif b[3]==0 and b[4]==0 and b[5]==0:
  print('Yes')
elif b[6]==0 and b[7]==0 and b[8]==0:
  print('Yes')
elif b[0]==0 and b[3]==0 and b[6]==0:
  print('Yes')
elif b[1]==0 and b[4]==0 and b[7]==0:
  print('Yes')
elif b[2]==0 and b[5]==0 and b[8]==0:
  print('Yes')
elif b[0]==0 and b[4]==0 and b[8]==0:
  print('Yes')
elif b[2]==0 and b[4]==0 and b[6]==0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
n,q=map(int,raw_input().split())
p=[map(str,raw_input().split()) for i in xrange(n)]
a=[]
ct=0
while len(p)>=1:
    if int(p[0][1])>q:
        p.append([p[0][0],int(p[0][1])-q])
        p.pop(0)
        ct+=q
        
    else:
        ct+=int(p[0][1])
        a.append([p[0][0],int(ct)])
        p.pop(0)
for i in xrange(n):
    print a[i][0],a[i][1]
            

Measured memory_bytes: 15424
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B ,C ,D;
  cin >> A >> B >> C >> D;
  
int count;
while( C > 0){
  C-=B;
  if(C<1){
    count++;
    cout << "Yes" << endl;
  }
  if(count!=0){
    break;}
  A-=D;
  if(A<1){
    count++;
    cout << "No" << endl;
    if(count!=0){
    break;}
  }
}
}

Measured memory_bytes: 3596
s = str(input())
cnt = [0]*2019
cnt[0] += 1

si = [0] * (len(s)+1) #mod2019の累積和用に
tmp = 0
for i in range(1,len(s)+1): #累積和の作成
    tmp += int(s[-i])%2019 * pow(10,i-1,2019)#ここでpowを使わないとTLEする
    si[i] = tmp % 2019
    cnt[si[i]] += 1

ans = 0
for b in cnt:#aがb回出てきたよ
    ans += b*(b-1)//2

print(ans)


Measured memory_bytes: 16332
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;

int main(){
	cin>>n;
	cout<<n*n<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a1,a2,a3,sum;
  cin>>a1>>a2>>a3;
  sum=a1+a2+a3;
  if(sum>=22)
  cout<<"bust"<<endl;
  else
  cout<<"win"<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define forn(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pb push_back
 
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 
const int mxN = 1e5 + 7;
int grid[mxN][3], dp[mxN][3];

// dp[i][0] means i chose to do activity 0 on day i
void solve(){
	int n; cin >> n;
	forn(i,0,n){
		int a,b,c; cin >> a >> b >> c;
		grid[i][0] = a;
		grid[i][1] = b;
		grid[i][2] = c;
	}
	forn(i,0,n){
		if(!i){
			dp[i][0] = grid[i][0];
			dp[i][1] = grid[i][1];
			dp[i][2] = grid[i][2];
		} else{
			if(dp[i-1][1] > dp[i-1][2]) dp[i][0] = dp[i-1][1] + grid[i][0];
			else dp[i][0] = dp[i-1][2] + grid[i][0];
			
			if(dp[i-1][0] > dp[i-1][2]) dp[i][1] = dp[i-1][0] + grid[i][1];
			else dp[i][1] = dp[i-1][2] + grid[i][1];
			
			if(dp[i-1][0] > dp[i-1][1]) dp[i][2] = dp[i-1][0] + grid[i][2];
			else dp[i][2] = dp[i-1][1] + grid[i][2];
		}
	}
	cout << max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 5976
from collections import deque

SA = deque(list(input()))
SB = deque(list(input()))
SC = deque(list(input()))

turn = 'a'

while True:
    if turn == 'a' and len(SA) == 0:
        ans = 'A'
        break
    elif turn == 'b' and len(SB) == 0:
        ans = 'B'
        break
    elif turn == 'c' and len(SC) == 0:
        ans = 'C'
        break

    if turn == 'a':
        turn = SA.popleft()
    elif turn == 'b':
        turn = SB.popleft()
    else:
        turn = SC.popleft()
print(ans)

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

Measured memory_bytes: 1024
x = [0] * 100_001
value = 0

n = int(input())
for a in map(int, input().split()):
  x[a] += 1
  value += a
q = int(input())
for _ in range(q):
  b, c = map(int, input().split())
  value += (c - b) * x[b]
  x[c] += x[b]
  x[b] = 0
  print(value)

Measured memory_bytes: 17872
#include<cstdio>
#include<algorithm>
using namespace std;
const int MOD=1e9+7;
struct mint{int x;mint(int x=0):x(x){}};
inline mint operator+  (mint a,mint b){return a.x+b.x<MOD?a.x+b.x:a.x+b.x-MOD;}
inline mint operator-  (mint a){return MOD-a.x;}
inline mint operator-  (mint a,mint b){return a+-b;}
inline mint operator*  (mint a,mint b){return 1LL*a.x*b.x%MOD;}
inline mint operator<< (mint x,int y){mint r=1;for(;y;y>>=1,x=x*x)if(y&1)r=r*x;return r;}
inline mint operator~  (mint x){return x<<MOD-2;}
inline mint operator/  (mint a,mint b){return a*~b;}
inline mint&operator+= (mint&a,mint b){return a=a+b;}
inline mint&operator-= (mint&a,mint b){return a=a-b;}
inline mint&operator*= (mint&a,mint b){return a=a*b;}
inline mint&operator<<=(mint&x,int y){return x=x<<y;}
inline mint&operator/= (mint&a,mint b){return a=a/b;}
mint ans;int f[9];
void cal(int n,int x)
	{if(x>8||f[x]>=n/x)ans+=9*(mint(10)<<x-1)-n/x+1;}
int main()
{
	int n,x,i,j,k;
	for(f[1]=9,i=2;i<9;++i)f[i]=f[i-1]*10;
	scanf("%d",&n);
	for(i=1;i*i<n;++i)if(n%i==0)cal(n,i),cal(n,n/i);
	if(i*i==n)cal(n,i);
	for(i=1;i<8;++i)ans+=max(0,min((n-1)/i,(f[i]+n)/(i+1))-max(n/(i+1)+1,(n-f[i+1]+i-1)/i)+1);
	for(;i*2<n;++i)ans+=max(0,(n-1)/i-n/(i+1));
	for(i=1;i<7;++i)for(x=n,j=i;++j;)
	{
		if(j>i+1)for(k=max(1,(x-j*f[j]+i-1)/i);k<=f[i]&&i*k<x;++k)if((x-i*k)%j==0)ans+=1;
		if((x-=j*9*(mint(10)<<j-1).x)<0)break;
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
from collections import Counter
n=int(input())
if n==1:
  print(1)
  exit()
xy=[tuple(map(int,input().split())) for _ in range(n)]

# print(xy)
xy.sort()
# print(xy)
l=[]
for i in range(n-1):
  for j in range(i+1,n):
    l.append((xy[j][0]-xy[i][0],xy[j][1]-xy[i][1]))

#most_common(): (要素、出現回数)という形のタプルを出現回数順に並べたリストを返す
print(n-Counter(l).most_common()[0][1])



Measured memory_bytes: 3572
import sys
input = sys.stdin.readline
h,n = map(int,input().split())
mg = [list(map(int,input().split())) for i in range(n)]
DP = [[10**18 for i in range(h+1)] for j in range(n+1)]
for i in range(n+1):
  DP[i][0] = 0
for i in range(1,n+1):
  for j in range(1,h+1):
    DP[i][j] = min(DP[i][j],DP[i-1][j])
    DP[i][j] = min(DP[i][j],DP[i][max(0,j-mg[i-1][0])]+mg[i-1][1])
print(DP[-1][-1])

Measured memory_bytes: 126684
N = int(input())
a = []
for _ in range(N):
    a.append(int(input()))

i = 0
c = 1
while(1):
    if a[i]-1 == 1:
        print(c)
        break
    i = a[i]-1
    c += 1
    if c >= N or a[i]-1 == 0:
        print("-1")
        break

Measured memory_bytes: 7084
n = gets.chomp.to_i
ps = gets.chomp.gsub(" ", "")
qs = gets.chomp.gsub(" ", "")
numbers = [*1..n].to_a
lst = numbers.permutation.collect {|a| a.join }.to_a
pindex = lst.index {|item| item == ps }
qindex = lst.index {|item| item == qs }
p (pindex-qindex).abs

Measured memory_bytes: 11684
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#define ll long long
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  cout << "ABC" << n << endl;
  return 0;
}


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

using namespace std;

string S, T;
long long dp[3333][3333];

signed main() {

  cin >> S >> T;

  memset(dp, 0xff, sizeof(dp));

  // S[0]
  {
    bool flag = false;
    for (int i = 0; i < T.size(); ++i) {
      if (T[i] == S[0]) flag = true;
      dp[i][0] = flag;
    }
  }

  // T[0]
  {
    bool flag = false;
    for (int i = 0; i < S.size(); ++i) {
      if (S[i] == T[0]) flag = true;
      dp[0][i] = flag;
    }
  }

  for (int i = 1; i < T.size(); ++i) {
    for (int j = 1; j < S.size(); ++j) {
      auto& r = dp[i][j];
      if (T[i] == S[j]) r = dp[i - 1][j - 1] + 1;
      else r = max<long long>(dp[i - 1][j], dp[i][j - 1]);
    }
  }

  string res = "";

  int i = T.size() - 1, j = S.size() - 1;
  while (i >= 0 && j >= 0) {
    long long val = dp[i][j];
    while (i > 0 && val == dp[i - 1][j]) --i;
    while (j > 0 && val == dp[i][j - 1]) --j;
    if (T[i] == S[j]) res += S[j];
    --i, --j;
  }

  reverse(res.begin(), res.end());

  cout << res << endl;

}


Measured memory_bytes: 87040
l = int(input())

d = max([d for d in range(30) if 2**d <= l])
n = d+1
m = 2*d
ans = []
for i in range(1, n):
    ans.append((i, i+1, 0))
    ans.append((i, i+1, 2**(i-1)))

while l > 2**d:
    for i in range(n-1, 0, -1):
        if l-2**(i-1) > 2**d-1:
            ans.append((i, n, l-2**(i-1)))
            m += 1
            l -= 2**(i-1)
            break

print(n, m)
for a in ans:
    print(*a)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int gcd(int a,int b);

int main(void){
    int S,W;
    scanf("%d %d",&S,&W);
    if (W >= S){
        printf("unsafe\n");
    }else{
        printf("safe\n");
    }

    return 0;
}

// 最大公約数
int gcd(int a,int b){
    int c;
    int tmp;
    if(b > a){  //bがaより大きい場合bとaを入れ替える
        c = a;
        a = b;
        b = c;
    }
    tmp = a % b;
    while(tmp!=0){
        a = b;
        b = tmp;
        tmp = a % b;
    }
    return b;
}


Measured memory_bytes: 1656
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
#define MM(s,q) memset(s,q,sizeof(s))
#define INF 0x3f3f3f3f
#define MAXN 10005
#define Lchild id<<1
#define Rchild (id<<1)+1
#define ll long long
#define FILE  freopen("data.in","r",stdin)
using namespace std;
int dis[50][50];

void Floyd(int N) {
    for (int k = 0; k <= N; k++)
        for (int i = 0; i <= N; i++)
            for (int j = 0; j <= N; j++)
                if (i != j && i != k && j != k) {
                    if (dis[i][j] > dis[i][k] + dis[k][j])
                        dis[i][j] = dis[i][k] + dis[k][j];
                }
}

int main() {
    int n, u, v, w, N;
    while (cin >> n && n) {
        N = 0;
        MM(dis, INF);
        for (int i = 1; i <= n; i++) {
            scanf("%d%d%d", &u, &v, &w);
            dis[u][v] = dis[v][u] = w;
            N = max(N, max(u, v));
        }
        Floyd(N);
        int pos, ans = INF;
        for (int i = 0; i <= N; i++) {
            int sum = 0;
            for (int j = 0; j <= N; j++) {
             //   if (i != j)cout << dis[i][j] << endl;
                if (i != j && dis[i][j] < INF)
                    sum += dis[i][j];
            }
            if (ans > sum) {
                ans = sum, pos = i;
            }
        }
        cout << pos << " " << ans << endl;
    }
}

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

const ll INF = 1LL << 60;

ll N;
vector<ll> d;
int main() {
    cin >> N;
    d.resize(N);
    rep(i, N) cin >> d[i];

    sort(d.begin(), d.end());
    ll left = N / 2 - 1;
    ll right = N / 2;

    ll ans = d[right] - (d[left] + 1) + 1;
    cout << max(0LL, ans) << endl;
}

Measured memory_bytes: 1024
X, N = map(int, input().split())
if N == 0:
    print(X)
    exit(0)

p = set(map(int,input().split()))
not_p = list(set(range(0,102)) - p)

minV = 101
ans = 0
for i in not_p:
    if abs(X - i) < minV:
        minV = abs(X - i)
        ans = i
print(ans)

Measured memory_bytes: 61852
#include <iostream>

int main(){
  int n,q,cnt=0,i,j,s[10000],t[500];
  std::cin >> n;
  for ( i = 0; i < n; ++i)std::cin >> s[i];
  std::cin >> q;
  for ( i = 0; i < q; ++i)std::cin >> t[i];
  for (j = 0; j < q; ++j) {
    for (i = 0; i < n; ++i) {
      if (s[i]==t[j]) {
        ++cnt;
        i=n;
      }
    }
  }
  std::cout << cnt << '\n';
}



Measured memory_bytes: 3108
#include<stdio.h>
#include<math.h>

int main(){
	int n;
	double x1,y1;
	double x2,y2;
	double x3,y3;

	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);

		double a,b,c;
		double d,e,f;

		c=x3-x2;
		f=y3-y2;

		a=sqrt(pow(y2-y1,2)/(pow(x2-x1,2)+pow(y2-y1,2)));
		d=sqrt(pow(x2-x1,2)/(pow(x2-x1,2)+pow(y2-y1,2)));
		if((x2-x1)*(y2-y1)>0){
			d=-d;
		}

		b=sqrt(pow(y3-y1,2)/(pow(x3-x1,2)+pow(y3-y1,2)));
		e=sqrt(pow(x3-x1,2)/(pow(x3-x1,2)+pow(y3-y1,2)));
		if((x3-x1)*(y3-y1)>0){
			e=-e;
		}

		double s,t;
		s=(e*c-b*f)/(a*e-b*d);
		t=(a*f-c*d)/(a*e-b*d);

		double xc,yc,rc;
		xc=x1+(x2-x1)/2+s/2*a;
		yc=y1+(y2-y1)/2+s/2*d;
		rc=sqrt(pow(xc-x1,2)+pow(yc-y1,2));
		printf("%.3lf %.3lf %.3lf\n",xc,yc,rc);
	}
	return 0;
}



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

class Program {
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return Console.ReadLine().Split(); }

    static void Main() {
        var nm = ReadInts();
        int n = nm[0], m = nm[1];

        Console.WriteLine((n - 1) * (m - 1));
    }
}

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

int my[] = {6000, 4000, 3000, 2000};

int main()
{
  int n, m;
  for (int i = 0; i < 4; i++){
    cin >> n >> m;
    cout << my[n - 1] * m << endl;
  }
  return (0);
}

Measured memory_bytes: 1160
from collections import deque

N = int(input())
connected = [[] for _ in range(N)]
for i in range(N-1):
    u,v,w = (int(x) for x in input().split())
    connected[u-1].append((v-1,w))
    connected[v-1].append((u-1,w))
colors = [None] * N
colors[0] = 0
d = deque()
parents = deque()
for edge in connected[0]:
    if edge[1] % 2 == 0:
        colors[edge[0]] = 0
        d.append((edge[0],0))
    else:
        colors[edge[0]] = 1
        d.append((edge[0],1))
    parents.append(0)
while d:
    temp = d.popleft()
    parent = parents.popleft()
    for edge in connected[temp[0]]:
        if edge[0] != parent:
            if edge[1] % 2 == 0:
                colors[edge[0]] = temp[1]
                d.append((edge[0],temp[1]))
            else:
                if temp[1] == 0:
                    colors[edge[0]] = 1
                    d.append((edge[0],1))
                else:
                    colors[edge[0]] = 0
                    d.append((edge[0],0))
            parents.append(temp[0])
for x in colors:
    print(x)

Measured memory_bytes: 39164
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

class Point
{
public:
    int y, x;
    Point(){
        y = x = 0;
    }
    Point(int y0, int x0){
        y = y0;
        x = x0;
    }
    Point operator+(const Point& p) const{
        return Point(y + p.y, x + p.x);
    }
    Point operator-(const Point& p) const{
        return Point(y - p.y, x - p.x);
    }
    Point operator*(int a) const{
        return Point(y * a, x * a);
    }
    int length2() const{
        return y * y + x * x;
    }
    int dist2(const Point& p) const{
        return (y - p.y) * (y - p.y) + (x - p.x) * (x - p.x);
    }
    int dot(const Point& p) const{
        return y * p.y + x * p.x; // |a|*|b|*cos慮
    }
    int cross(const Point& p) const{
        return x * p.y - y * p.x; // |a|*|b|*sin慮
    }
};

class Circle
{
public:
    Point p;
    int r;
    bool isCollide(const Circle& c) const{
        return p.dist2(c.p) <= (r + c.r) * (r + c.r);
    }
    bool isInside(const Circle& c) const{
        return p.dist2(c.p) < (r - c.r) * (r - c.r);
    }
    bool operator<(const Circle& c) const{
        return r < c.r;
    }
};

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        Point s, t;
        cin >> s.x >> s.y >> t.x >> t.y;

        vector<Circle> c0(n);
        for(int i=0; i<n; ++i)
            cin >> c0[i].p.x >> c0[i].p.y >> c0[i].r;
        sort(c0.begin(), c0.end());

        vector<vector<Circle> > c(2);
        for(int i=0; i<n; ++i){
            bool a = (c0[i].p.dist2(s) < c0[i].r * c0[i].r);
            bool b = (c0[i].p.dist2(t) < c0[i].r * c0[i].r);
            if(a && !b)
                c[0].push_back(c0[i]);
            if(!a && b)
                c[1].push_back(c0[i]);
        }

        vector<vector<int> > num(2);
        for(int i=0; i<2; ++i){
            num[i].assign(c[i].size(), 1);
            for(unsigned j=0; j<c[i].size(); ++j){
                for(unsigned k=0; k<j; ++k){
                    if(c[i][k].isInside(c[i][j]))
                        num[i][j] = max(num[i][j], num[i][k] + 1);
                }
            }
        }

        int ret = 0;
        for(int i=0; i<2; ++i){
            for(unsigned j=0; j<num[i].size(); ++j){
                ret = max(ret, num[i][j]);
            }
        }
        for(unsigned i=0; i<num[0].size(); ++i){
            for(unsigned j=0; j<num[1].size(); ++j){
                if(!c[0][i].isCollide(c[1][j]))
                    ret = max(ret, num[0][i] + num[1][j]);
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 1232
#include "bits/stdc++.h"

using namespace std;

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

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	ll n, q;
	cin >> n >> q;

	vector<ll> a(n);
	for (auto &v : a) {
		cin >> v;
	}

	while (q--) {
		ll x;
		cin >> x;

		ll ans = 0, snakeHp = 0;
		for (ll l = 0, r = 0; l < n; l++) {
			while (r < n && snakeHp + a[r] <= x) {
				snakeHp += a[r];
				r++;
			}

			ans += r - l;

			if (l == r) {
				r++;
			} else {
				snakeHp -= a[l];
			}
		}

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



Measured memory_bytes: 3560
$n=gets.to_i

def dfs(n)
  return 0 if n > $n
  
  x = n.to_s.split('')
  sum =0
  # return if (n.split('') & ['0','1','2','4','6','8','9']).any?
  if x.include?('3') && x.include?('5') && x.include?('7') && x.all?{|a| a == "3" || a == "5" || a == "7"}
    sum+=1
  end
  sum+=dfs(3 + 10*n)
  sum+=dfs(5 + 10*n)
  sum+=dfs(7 + 10*n)
end
puts dfs(0)

Measured memory_bytes: 1916
<?php
 
$s = trim(fgets(STDIN));
$c = 0;
$t = 0;
for ($i = strlen($s) - 1; $i >= 0; $i--) {
    if ($s[$i] == 'W') {
        $c++;
    } else {
        $t += $c;
    }
}
printf("%s", $t);

Measured memory_bytes: 4728
#include <stdio.h>
int main(void){
	int m,f,r;
	
	while(1){
		scanf("%d %d %d",&m,&f,&r);
		if(m == -1&&f == -1&&r == -1)break;
		if(m <= 50&&f <= 50&&r <= 100){
			if(m == -1||f == -1){
				printf("F\n");
			}else{
				if(m + f >= 80){
					printf("A\n");
				}else if(m + f >= 65){
					printf("B\n");
				}else if(m + f >= 50){
					printf("C\n");
				}else if(m + f >= 30){
					if(r >= 50){
						printf("C\n");
					}else{
						printf("D\n");
					}
				}else{
					printf("F\n");
				}
			}
		}
	}
	
    return 0;
}

Measured memory_bytes: 584
import sys
from operator import itemgetter

N = int(input())
V = set()
for s in sys.stdin.readlines():
    x, y = map(int, s.split())
    V.add((x + y, x - y))

y1 = max(V, key=itemgetter(1))[1]
y2 = min(V, key=itemgetter(1))[1]
x1 = max(V, key=itemgetter(0))[0]
x2 = min(V, key=itemgetter(0))[0]

print(max(abs(x1 - x2), abs(y1 - y2)))


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

int main() {
    lint x,k,d; cin >> x >> k >> d;
    if (x < 0) x = -x;
    lint xx = x / d;
    if (xx > k) xx = k;
    k -= xx;
    lint pos = x - d*xx;
    if (k % 2 == 0);
    else {
        pos = min(abs(pos-d),abs(pos+d));
    }
     cout << pos << endl;
}

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

int main() {
	long long N, ANS = 0;
	vector<pair<long long, long long> > P;
	vector<pair<long long, long long> > L, R;
	vector<bool> B;
	cin >> N;
	P.resize(N);
	L.resize(N), R.resize(N), B.assign(N, true);
	for (int i = 0; i < N; i++) {
		cin >> P[i].first >> P[i].second;
		L[i] = { P[i].first, i };
		R[i] = { P[i].second, i };
	}
	sort(L.begin(), L.end(), greater<pair<long long, long long> >());
	sort(R.begin(), R.end());
	long long NOW = 0, COUNT = 0, LNOW = 0, RNOW = 0;
	if (R[0].first < 0) {
		for (int i = 0; i < N; i++) {
			if (i % 2 == 0) {
				while (RNOW < N) {
					if (B[R[RNOW].second]) {
						if (R[RNOW].first < NOW) COUNT += NOW - R[RNOW].first, NOW = R[RNOW].first;
						B[R[RNOW].second] = false;
						RNOW++;
						break;
					}
					RNOW++;
				}
			}
			else {
				while (LNOW < N) {
					if (B[L[LNOW].second]) {
						if (L[LNOW].first > NOW) COUNT += L[LNOW].first - NOW, NOW = L[LNOW].first;
						B[L[LNOW].second] = false;
						LNOW++;
						break;
					}
					LNOW++;
				}
			}
		}
		COUNT += abs(NOW);
		ANS = max(ANS, COUNT);
	}
	NOW = COUNT = LNOW = RNOW = 0;
	B.assign(N, true);
	if (L[0].first > 0) {
		for (int i = 0; i < N; i++) {
			if (i % 2 == 1) {
				while (RNOW < N) {
					if (B[R[RNOW].second]) {
						if (R[RNOW].first < NOW) COUNT += NOW - R[RNOW].first, NOW = R[RNOW].first;
						B[R[RNOW].second] = false;
						RNOW++;
						break;
					}
					RNOW++;
				}
			}
			else {
				while (LNOW < N) {
					if (B[L[LNOW].second]) {
						if (L[LNOW].first > NOW) COUNT += L[LNOW].first - NOW, NOW = L[LNOW].first;
						B[L[LNOW].second] = false;
						LNOW++;
						break;
					}
					LNOW++;
				}
			}
		}
		COUNT += abs(NOW);
		ANS = max(ANS, COUNT);
	}
	cout << ANS << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> b(n);
  rep(i, n) cin >> b[i];
  int maxv = 0;
  rep(i, n) {
    chmax(maxv, b[i]);
  }
  vector<int> ans;
  rep(i, n) {
    int t = -1;
    rep(j, b.size()) {
      if(b[j] == j + 1) t = b[j];
    }
    if (t == -1) {
      puts("-1");
      return 0;
    }

    ans.push_back(t);
    b.erase(b.begin() + t - 1);
  }
  reverse(ans.begin(), ans.end());
  rep(i, n) printf("%d%c", ans[i], (i == n - 1 ? '\n' : ' '));
}

Measured memory_bytes: 256
#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>;
using V = vector<int>;

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n,-1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) {return find(x) == find(y);}
    int size(int x) {return -d[find(x)];}
};

int main(int argc, char const *argv[])
{
    int n, m; cin >> n >> m;
    UnionFind uf(n);
    int a, b;
    rep(i,m) {
        cin >> a >> b;
        a--; b--;
        uf.unite(a,b);
    }
    int ans = 0;
    rep(i,n) ans = max(ans, uf.size(i));
    
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4032
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;
typedef long double LD;

const LD eps = 0.00000001;
LL N;
std::vector<LD>x, y;

bool check(LD r)
{
	rep(i, N)
	{
		for (LL j = i + 1; j < N; ++j)
		{
			LD x1 = x[i], y1 = y[i], x2 = x[j], y2 = y[j];
			LD a = x1 - x2, b = y1 - y2;
			LD c = 0.5 * (-a * (x1 + x2) - b * (y1 + y2));
			LD l = a * a + b * b;
			LD k = a * x1 + b * y1 + c;
			LD d = l * r * r - k * k;
			LD xp = 0, yp = 0, xq = 0, yq = 0;
			if (d > 0)
			{
				LD ds = sqrtl(d);
				LD apl = a / l;
				LD bpl = b / l;
				LD xc = x1 - apl * k;
				LD yc = y1 - bpl * k;
				LD xd = bpl * ds;
				LD yd = apl * ds;
				xp = xc - xd; yp = yc + yd;
				xq = xc + xd; yq = yc - yd;
			}
			else if (d == 0)
			{
				xp = x1 - a * k / l;
				yp = y1 - b * k / l;
			}
			else return false;

			// P
			bool f1 = true;
			rep(k, N)
			{
				LD d = (x[k] - xp) * (x[k] - xp) + (y[k] - yp) * (y[k] - yp);
				if (d - r * r > eps)
				{
					f1 = false;
					break;
				}
			}
			// Q
			bool f2 = true;
			rep(l, N)
			{
				LD d = (x[l] - xq) * (x[l] - xq) + (y[l] - yq) * (y[l] - yq);
				if (d - r * r > eps)
				{
					f2 = false;
					break;
				}
			}
			if (f1 || f2) return true;
		}
	}

	return false;
}

int main()
{
	in >> N;
	x.resize(N); y.resize(N);
	rep(i, N) in >> x[i] >> y[i];

	if (N == 2)
	{
		out << std::fixed << std::setprecision(10);
		out << sqrtl((x[1] - x[0]) * (x[1] - x[0]) + (y[1] - y[0]) * (y[1] - y[0])) / 2 << std::endl;
		return 0;
	}

	LD left = 0, right = 0;
	rep(i, N)
	{
		rep(j, N)
		{
			LD d = sqrtl((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
			right = std::max(right, d * 2);
		}
	}
	rep(loop, 150)
	{
		LD mid = (left + right) / 2;
		if (check(mid)) right = mid;
		else left = mid;
	}

	out << std::fixed << std::setprecision(10);
	out << right << std::endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] v = new int[N];
        int[] c = new int[N];
        for(int i = 0; i < N; i++) {
            v[i] = Integer.parseInt(sc.next());
        }
        for(int i = 0; i < N; i++) {
            c[i] = Integer.parseInt(sc.next());
        }
        int count = 0;
        for(int i = 0; i < N; i++) {
            if(c[i] < v[i]) {
                count += v[i] - c[i];
            }
        }
        System.out.println(count);
        
    }
}

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

const int MOD = 998244353;

void solve_test() {
	LL n;
	int x, m;
	cin >> n >> x >> m;
	
	LL sum = 0;

	vector<int> marked(m, -1);
	vector<int> values;
	int t = x, i = 0;
	while (n > 0 && marked[t] == -1) {
		marked[t] = i;
		values.push_back(t);
		
		sum += t;

		t = (LL) t * t % m;
		i++;

		n--;
	}

	if (n == 0) {
		cout << sum << '\n';
		return;
	}

	int from = marked[t];
	int to = i;
	int length = to - from;

	for (int i = from; i < to; i++) {
		sum += (LL)(values[i]) * (n / length);
		if (i - from < n % length)
			sum += values[i];
	}

	cout << sum << '\n';
}

int main() {
	int T;
	T = 1;
	for (int t = 1; t <= T; t++)
		solve_test();

	return 0;
}


Measured memory_bytes: 4064
#include<iostream>
#include<cassert>
#include<algorithm>
#include<vector>
#include<stack>
#include<list>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
const int N = 1024;
typedef long long ll;
int dx[]={1,-1};
bool edge[N][N][2];
ll dp[N][N];

ll solve(int r,int y,int x,vector<int> &bottom){
  if (y == r){
    return bottom[x];
  }
  
  ll &ret = dp[y][x];
  if (ret != -1)return ret;
  ret = 0;
  if (edge[y][x][0]){//EÉs­
    ret = solve(r,y+1,x+1,bottom);
  }else if (edge[y][x][1]){//¶És­
    ret = solve(r,y+1,x-1,bottom);
  }else {//»ÌÜÜºÉs­
    ret = solve(r,y+1,x,bottom);
  }
  return ret;
}

ll ways[N][N];//±Ìn_ðÊß·épXÌ
void go(int r,int x){
  int y = 0;
  while(true){
    if (y == r)break;
    ways[y][x]++;
    if (edge[y][x][0]){
      x++;
    }else if (edge[y][x][1]){//¶És­
      x--;
    }else {//»ÌÜÜºÉs­
    }
    y++;
  }
}

void show(int r,int c){
  rep(i,r){
    rep(j,c){
      cout << ways[i][j] <<" " ;
    }
    cout << endl;
  }
}

main(){
  int n,m,h,k;
  while(cin>>n>>m>>h>>k && n){
    rep(i,h)rep(j,n){
      rep(k,2)edge[i][j][k] = false;
      dp[i][j] = -1;
      ways[i][j] = 0;
    }
    
    vector<int> in(n);
    rep(i,n)cin>>in[i];

    rep(i,m){
      int x,y;
      cin>>x>>y;
      x--;
      edge[y][x][0] = edge[y][x+1][1] = true;
    }
    rep(i,h)rep(j,n)solve(h,i,j,in);
    /**/
    ll ans = 0;
    ll sum = 0;
    rep(i,k){
      go(h,i);
      sum += dp[0][i];
    }

    ans = sum;
    /*ÁµûðSµÄ¨­*/
    rep(i,h){
      rep(j,n-1){
	if (!edge[i][j][0])continue;
	ll tmp = sum - ways[i][j]*dp[i][j] - ways[i][j+1]*dp[i][j+1] + ways[i][j]*dp[i][j+1] + ways[i][j+1]*dp[i][j];
	ans = min(ans,tmp);
      }
    }
    cout << ans << endl;
  }
  return false;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int n,hx[100005],hy[100005],F,fx[100005],fy[100005],sx[100005],sy[100005],x,y;
bool v[100005];
long long ans;
struct P{
	int l,to;
}e[200005];
int fix(int g){
	if(g==fx[g])return g;
	return fx[g]=fix(fx[g]);
}
int fiy(int g){
	if(g==fy[g])return g;
	return fy[g]=fiy(fy[g]);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d %d",&x,&y);
		e[i<<1].to=y;e[i<<1].l=hx[x];hx[x]=i<<1;
		e[i<<1|1].to=x;e[i<<1|1].l=hy[y];hy[y]=i<<1|1;
	}
	for(int i=1;i<=100000;++i)sx[i]=sy[i]=1,fx[i]=fy[i]=i;
	for(int i=1;i<=100000;++i){
		F=fiy(e[hx[i]].to);
		for(int o=e[hx[i]].l;o;o=e[o].l){
			int k=fiy(e[o].to);
			if(k!=F){
				sy[F]+=sy[k];
				fy[k]=F;
			}
		}
		F=fix(e[hy[i]].to);
		for(int o=e[hy[i]].l;o;o=e[o].l){
			int k=fix(e[o].to);
			if(k!=F){
				sx[F]+=sx[k];
				fx[k]=F;
			}
		}
	}
	for(int i=1;i<=100000;++i){
		if(hx[i]!=0){
			int k=fix(i),g=fiy(e[hx[i]].to);
			if(!v[k]){
				ans+=1ll*sx[k]*sy[g];
				v[k]=1;
			}
		}
	}
	printf("%lld",ans-n);
}

Measured memory_bytes: 4224
N,K=list(map(int,input().split()))
V=list(map(int,input().split()))
max_score=0
for k in range(min(N,K)+1):#合計取る個数
    for k_l in range(k+1):# 左から取る個数
        left=V[:k_l]
        k_r = k-k_l
        right=V[-k_r:]if k_r>0 else []
        sterable=sorted(left+right)[:K-k]
        stesum=0
        for ss in sterable:
            if ss<0:
                stesum+=ss
            else:break
        score = sum(left)+sum(right) - stesum
        max_score=max(score,max_score)
print(max_score)

Measured memory_bytes: 3064
require 'matrix'

$stdin = DATA if $stdin.eof?

n, m, _ = gets.split.map(&:to_i)

a = n.times.map do
      gets.split.map(&:to_i)
    end

b = m.times.map do
      gets.split.map(&:to_i)
    end

ma = Matrix.rows(a)
mb = Matrix.rows(b)
mc = ma * mb

mc.row_vectors.each{|row| puts row.to_a.join("\s")}

Measured memory_bytes: 7444
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define ll long long int
int main()
{
   ll N ;
   scanf("%lld",&N);

   char temp[50]={'\0'};
   ll idx = 0;

   while (N)
   {
    N--;

    ll modulo= N %26;
    temp[idx]= 'a'+ modulo;

    idx++;
    N/=26;
   }

   for (int i = idx-1 ; i >=0;i--)
    printf("%c",temp[i]);

    return 0;
}


Measured memory_bytes: 1632
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]) {
	int A,B;
	char op;
	std::cin >> A >> op >> B;
	switch (op) {
		case '+':
			A += B;
			break;
		case '-':
			A -= B;
			break;
	}
	std::cout << A << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  int ans,a,z;
  bool flag = 0;
  cin >> s;
  for(int i=0;i<s.size();i++){
    if(s[i] == 'A' && flag == false){
      a = i;
      flag = true;
    }
    if(s[i] == 'Z') z = i;
  }
  ans = z-a+1;
  cout << ans << endl;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

bool DP[1000][1000] = {};

int main(){
    int N;
    cin >> N;
    DP[0][0] = true;
    int S = 0;
    for(int loop = 0; loop < N; loop++){
        int T;
        cin >> T;
        for(int i = 999 - T; i >= 0; i--){
            for(int j = 999 - T; j >= 0; j--){
                if(DP[i][j]){
                    DP[i + T][j] = true;
                    DP[i][j + T] = true;
                }
            }
        }
        S += T;
    }
    int ans = 1000;
    for(int i = 0; i < 1000; i++){
        for(int j = 0; j < 1000; j++){
            if(DP[i][j]){
                ans = min(ans, max(max(i, j), S - i - j));
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
   int a,b;
   cin >> a >> b;
   int ab;
  
   if(b<10)
   ab=a*10+b;
   else if(b<100)
   ab=a*100+b;
   else 
   ab=a*1000+b;
  
   string ans="No"; int i=1;
   while(i*i<=ab){
      if(ab==i*i)
      ans="Yes";
      i++;
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int main() {
    int a, b, t;
    cin >> a >> b >> t;
    cout << int((t + 0.5) / a) * b << endl;
}


Measured memory_bytes: 256
//Bismillahir Rahmanir Raheem
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<stdlib.h>
#include<queue>
#include<map>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<deque>
#include<set>
using namespace std;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef pair<int, int> pii;
#define FF first
#define SS second
#define MP make_pair
#define mxN (int)2e5 + 2
#define sz(n) (int)(n).size()
#define fasterIO ios::sync_with_stdio(0); cin.tie(0);
ll gcd(ll a, ll b)
{
    if(b == 0LL) return a;
    return gcd(b, a % b);
}
ll bigmod(ll a, ll b, ll mod)
{
    if(b == 0LL) return 1LL;
    ll sq = bigmod(a, b/2LL, mod);
    sq = (sq * sq) % mod;
    if(b&1LL) return (sq * (a%mod)) % mod;
    return sq;
}
#define SIZE (int)(1e6+5)
#define INF (int)1e9
bool prime[SIZE+1]; 
vector<int> primes;

int main()
{
    memset(prime, true, sizeof(prime)); 
	for (int p = 2; p*p<=SIZE; p++) 
    { 
      if (prime[p]) 
      { 
        for (int i=p*p; i<=SIZE; i += p) 
          prime[i] = false; 
      } 
    } 
  	for(int i = 2; i <= SIZE; i++) 
      if(prime[i]) primes.pb(i);
    fasterIO
    int n;
    cin >> n;
    vi a(n);
    map<int,bool> used;
    bool pp = 1;
  	for(auto &j:a) { 
      cin >> j;
      int x = j;
      for(int i= 0; primes[i]*primes[i] <= x; i++){
      	int p = primes[i];
        bool flag = 0;
        while(x%p == 0){
          x /= p;
          flag = 1;
        }
        if(flag){
          if(!used[p]) used[p] = 1;
          else { pp = 0; break;}
        }
      }
      if(x > 2){
        if(!used[x]) used[x] = 1;
        else { pp = 0; break;}
      }
    }
  	int gc = 0;
    for(auto x : a) gc = gcd(x, gc);
  	if( gc > 1)
      cout << "not coprime\n";
    else {
      if(pp) cout << "pairwise coprime\n";
      else cout << "setwise coprime\n";
    }
  	

    return 0;
}





Measured memory_bytes: 8144
n, k = map(int, input().split())
a = [0]*n
res = 10e9
for i in range(n) :
  a[i] = int(input())
a = sorted(a)
for i in range(n-k+1) :
  if(res > a[i+k-1] - a[i]) : res = a[i+k-1] - a[i]
print(res)


Measured memory_bytes: 8240
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

int q;
string s;

signed main()
{
	ios::sync_with_stdio(false);
	cin>>s;
	deque<char> ans;
	for(int i=0;i<s.size();i++) ans.push_back(s[i]);
	cin>>q;
	int flag=0;
	while(q--){
		int c;
		cin>>c;
		if(c==1){
			flag^=1;
		}
		else{
			int f;char ch;
			cin>>f>>ch;
			if((f==1&&flag)||(f==2&&!flag)) ans.push_back(ch);
			else ans.push_front(ch);
		}
	}
	if(!flag){
		for(int i=0;i<ans.size();i++) cout<<ans[i];
	}
	else{
		for(int i=ans.size()-1;i>=0;i--) cout<<ans[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 976
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(ll i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1e9+7;

const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

//********************************template END****************************************//

void solve(void){

	int D, G;
	cin >> D >> G;
	vec ps(D), cs(D);

	rep(D, i) {cin >> ps[i] >> cs[i];}

	int ans = INF;

	rep((1<<D), bit)
	{
		int res = 0, cnt = 0;
		rep(D, i)
		{
			if (bit >> i & 1)
			{
				res += ps[i] * (i+1) * 100 + cs[i];
				cnt += ps[i];
			}
		}
		if (res >= G)
		{
			ans = min(ans, cnt);
			continue;
		}
		repr(D, i)
		{
			if (bit >> i & 1) {continue;}
			if (ps[i] * (i+1) * 100 + res >= G)
			{
				ans = min(ans, cnt + (G-res-1) / (i+1) / 100 + 1);
			}
			break;
		}
	}

	cout << ans << endl;

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
ll BASE_NUM = 1e+9 + 7;
int main()
{
    ll H, W;
    cin >> H >> W;
    vector<string> S(H);
    vector<vector<ll>> DP(H,vector<ll>(W,0));
    for (int i = 0; i < H; i++)
    {
        cin >> S[i];
    }
    if(S[0][0] == '#'){
        DP[0][0] = 1;
    }else{
        DP[0][0] = 0;
    }
    for(int i = 1;i < H;i++){
        if (S[i-1][0] == '#' && S[i][0] == '#'){
            DP[i][0] = DP[i-1][0];
        }else if(S[i-1][0] == '#' && S[i][0] == '.'){
            DP[i][0] = DP[i-1][0];
        }else if(S[i-1][0] == '.' && S[i][0] == '#'){
            DP[i][0] = DP[i-1][0] + 1;
        }else{
            DP[i][0] = DP[i-1][0];
        }
    }
    for(int i = 1;i < W;i++){
        if (S[0][i-1] == '#' && S[0][i] == '#'){
            DP[0][i] = DP[0][i-1];
        }else if(S[0][i-1] == '#' && S[0][i] == '.'){
            DP[0][i] = DP[0][i-1];
        }else if(S[0][i-1] == '.' && S[0][i] == '#'){
            DP[0][i] = DP[0][i-1] + 1;
        }else{
            DP[0][i] = DP[0][i-1];
        }
    }
    for(int i = 1; i < H;i++){
        for (int j = 1; j < W; j++)
        {
            if(S[i][j] == '.'){
                DP[i][j] = min(DP[i-1][j],DP[i][j-1]);
            }else{
                if (S[i-1][j] == '#' && S[i][j-1] == '#'){
                    DP[i][j] = min(DP[i-1][j],DP[i][j-1]);
                }else if(S[i-1][j] == '#' && S[i][j-1] == '.'){
                    DP[i][j] = min(DP[i-1][j],DP[i][j-1] + 1);
                }else if(S[i-1][j] == '.' && S[i][j-1] == '#'){
                    DP[i][j] = min(DP[i-1][j]+1,DP[i][j-1]);
                }else{
                    DP[i][j] = min(DP[i-1][j] + 1,DP[i][j-1] + 1);
                }
            }
        }
    }
    cout << DP[H-1][W-1] << endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  bool ans = true;
  int n;

  n = s.size();
  rep(i, (n+1)/2){
    // cout << s[i] << " " << s[n-i-1] << endl;
    if(s[i] != s[n-i-1]) {
        cout << "No" << endl;
        return 0;
    }
  }

  s = s.substr(0, (n-1)/2);
  n = s.size();
  rep(i, (n+1)/2){
    // cout << s[i] << " " << s[n-i-1] << endl;
    if(s[i] != s[n-i-1]) {
        cout << "No" << endl;
        return 0;
    }

  }

  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

const Int MO = 1000000007;
Int inv[1<<20], fact[1<<20], ifact[1<<20];

void pre() {
  inv[1] = 1;
  for (int i = 2; i < (1<<20); ++i) {
    inv[i] = MO - MO / i * inv[MO % i] % MO;
  }
  fact[0] = ifact[0] = 1;
  for (int i = 1; i < (1<<20); ++i) {
    fact[i] = fact[i-1] * i % MO;
    ifact[i] = ifact[i-1] * inv[i] % MO;
  }
}

Int comb(int n, int r) {
  return fact[n] * ifact[r] % MO * ifact[n - r] % MO;
}

Int S[1<<20], L[1<<20];

int main() {
  int N = in();
  pre();

  int fst = -1;
  for (int k = 1; k <= N - 1; ++k) {
    const int two = N - k - 1;
    const int one = k - 1 - two;
    if (one >= 0 && two >= 0) {
      fst = fst < 0 ? k : fst;
      S[k] = comb(one + two, two) * fact[k] % MO;
    }
  }

  Int res = 0, sub = 0;
  for (int k = fst; k <= N - 1; ++k) {
    (sub *= N - k) %= MO;
    const Int l = (S[k] - sub + MO) % MO;
    (res += l * k % MO * fact[N - 1 - k] % MO) %= MO;
    (sub += l) %= MO;
  }

  printf("%lld\n", res);

  return 0;
}


Measured memory_bytes: 30976
// author - saiku_ni_naro
// TO THE TOP

#include<bits/stdc++.h>
using namespace std;
#define F_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl '\n'
#define For(i,a,n) for(int i=(a);i<=(n);i++)
#define RFor(i,a,n) for(int i=(n);i>=(a);i--)
#define SET(a,val) memset((a),(val),sizeof((a)))
#define X first
#define Y second
#define pb push_back
#define over(v) v.begin(),v.end()
#define sz(x) (int)x.size()
#define inp(x) cin>>x;
#define oup(x) cout<<x<<endl;

const int MAXN = 2e5 + 10;
vector<int> graph[MAXN];
int dp[MAXN];

void solving_problem(){
    int n; cin>>n;

    For(i,1,n) dp[i] = i;

    For(i,1,n-1){
        int u,v; cin>>u>>v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    int ans = 0;
    
    For(i,1,n){
        sort(over(graph[i]));

        for(int v:graph[i]){
            if(v < i){
                ans = ans - v*(n-i+1);
            }else break;
        }

        ans = ans + i*(n-i+1);
    }

    cout<<ans<<endl;
}


signed main(){
    F_IO;

    int testcases = 1; 
    // cin>>testcases;

    For(i,1,testcases){
        // cout<<"Cases #"<<i<<": ";
        solving_problem();
    }
}

Measured memory_bytes: 17372