akhauriyash/Code-Regression huggingface dataset:
import bisect
n, m = map(int, input().split())
Ps = [[]for _ in range(n)]
PY = []
for _ in range(m):
    p, y = map(int, input().split())
    Ps[p-1].append(y)
    PY.append((p, y))

for ls in Ps:
    ls.sort()

for p, y in PY:
    pid = "{:06}".format(p)
    cid = "{:06}".format(bisect.bisect_right(Ps[p-1], y))
    print(pid+cid)


Measured memory_bytes: 29604
import heapq as hq

N, M = map(int, input().split())
A = list(map(int,input().split()))

# dp = [[0 for i in range(N)] for _ in range(M)]

# sortedA = sorted(A,reverse=True)

A = list(map(lambda x:x*-1, A))

hq.heapify(A)
for i in range(M):
    m=hq.heappop(A)*-1
    hq.heappush(A,(m//2)*-1)
#     print(A)

print(abs(sum(A)))

Measured memory_bytes: 73196
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n)]
for i in range(n, 0, -1):
    if sum(b[i-1::i])%2 != a[i-1]:
        b[i-1] = 1

c = [i+1 for i in range(n) if b[i] == 1]
if len(c) != 0:
    print(len(c))
    print(*c)
else:
    print("0")


Measured memory_bytes: 14136
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if(a+b >= c){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  system("pause");
}


Measured memory_bytes: 504
import sys,math,collections,itertools
input = sys.stdin.readline

H,W= list(map(int,input().split()))
a = [ list(map(int,input().split())) for _ in range(H)]
operation = []

#-奇数だったら右へずらしていく。偶数ならなにもしない-#
cnt = 0
for ih in range(H):
    for iw in range(W-1):
        if a[ih][iw]%2 == 0:
            continue
        else:
            a[ih][iw] -= 1
            a[ih][iw+1] += 1
            cnt += 1
            operation.append([ih+1,iw+1,ih+1,iw+2])
#-最右端を上から下まで-#
for ih in range(H-1):
    if a[ih][W-1]%2 == 0:
        continue
    else:
        a[ih][W-1] -= 1
        a[ih+1][W-1] += 1
        cnt += 1
        operation.append([ih+1,W,ih+2,W])
print(cnt)
for ope in operation:
    print(*ope)


Measured memory_bytes: 32704
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = inl()
h = {0:1}
acc = 0
for x in a:
    acc += x
    if acc not in h:
        h[acc] = 0
    h[acc] += 1
sm = 0
for x in h:
    sm += h[x]*(h[x]-1)//2
print(sm)


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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int h[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>h[i];
	}
	for (int i = n-1; i > 0; --i)
	{
		if (h[i-1]==h[i]+1)
		{
			--h[i-1];
		}
		else if (h[i-1]>h[i]+1)
		{
			cout<<"No\n";
			return 0;
		}
	}
	cout<<"Yes\n";
	return 0;
}


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

int x[110],y[110],h[110],n,k;

bool is(int X,int Y,int H)
{
    for(int i=0;i<n;i++)
        if(h[i]!=max(0,H-abs(X-x[i])-abs(Y-y[i])))return false;
    return true;
}

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d%d%d",&x[i],&y[i],&h[i]);
    k=0;
    for(int i=0;i<=100;i++)
        for(int j=0;j<=100;j++)
    {
        int tem,p=-1,f=0;
        for(int q=0;q<n;q++)
            if(h[q])
        {
            tem=h[q]+abs(i-x[q])+abs(j-y[q]);
            if(!f)p=tem,f=1;
            if(tem<1)break;
            if(tem!=p)break;
        }
        if(is(i,j,p))
        {
            printf("%d %d %d\n",i,j,p);
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 256
f a b c x = ( a * x + b ) `mod` c

g _ [] = []
g n x@(xh:xs) = if n == xh then xs else x

ans' n a b c x y =
  let y' = g x y
      x' = f a b c x
  in
    if y' == []
    then n
    else if n >= 10000
    then -1
    else ans' (n+1) a b c x' y'

ans ([0,0,0,0,0]:_) = []
ans ([_,a,b,c,x]:y:r) =
  let t = ans' 0 a b c x y
  in
    t:(ans r)

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = ans i
  mapM_ print o



Measured memory_bytes: 5540
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int n,i,s;
string a[200001];
int main(){
	cin>>n;
	for(i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	s=1;
	for(i=1;i<n;i++){
		if(a[i]!=a[i-1]) s++;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 7924
#include <stdio.h>
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if ((a==b && a!=c) || (a==c && a!=b) || (b==c && a!=b))
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a,b,c;
	char q;
	int a1=0,b1=0,c1=0,s;
	cin>>a>>b>>c;
	q=a[0];a1++;
	while(1){		
		if(q=='a'){if(a1==a.size()){break;}q=a[a1++];}
		else if(q=='b'){if(b1==b.size()){break;}q=b[b1++];}
		else if(q=='c'){if(c1==c.size()){break;}q=c[c1++];}
	}
	cout<<(char)toupper(q)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int map[17][17];
  int G[17][17][17][17];
  int n, x, y, p, i, j, k, l, m, a;
  scanf("%d", &n);
  for( m = 0 ; m < n ; m++ ){
    for( i = 0 ; i < 17 ; i++ ){
      for( j = 0 ; j < 17 ; j++ ){
	    map[i][j]=0;
	for( k = 0 ; k < 17; k++ ){ 
	  for( l = 0 ; l < 17 ; l++ ){
	    G[i][j][k][l]=0;
	  }
	}
      }
      map[1][1]=1;
    }
    scanf("%d %d", &x, &y);
    x++;
    y++;
    scanf("%d", &p);
    for( a = 0 ; a < p ; a++ ){
      scanf("%d %d %d %d", &i, &j, &k, &l);
      G[i+1][j+1][k+1][l+1]=1;
      G[k+1][l+1][i+1][j+1]=1; 
    }
    for( i = 1 ; i < x+1 ; i++ ){
      for( j = 1 ; j < y+1 ; j++ ){
		       
	if( G[i][j][i-1][j] == 0 ){
	  map[i][j]+=map[i-1][j];
	} 
	if( G[i][j][i][j-1] == 0 ){
	  map[i][j]+=map[i][j-1];
	} 
      }
    }
    if( map[x][y] == 0 ){
      printf("Miserable Hokusai!\n");
    } else printf("%d\n", map[x][y]);
  }
  return 0;
}

Measured memory_bytes: 940
#include<cstdio>
#define MAXN 100010
#define ll long long
#define max(a,b) (a>b?a:b)
#define INF 0x3f3f3f3f3f3f3f3f
using namespace std;

int n;
ll c,x[MAXN],v[MAXN];
ll k[5][MAXN],ma[5][MAXN];

int main()
{
	scanf("%d%lld",&n,&c);
	for(register int i=1;i<=n;i++)
		scanf("%lld%lld",&x[i],&v[i]);
	x[n+1]=c;  x[0]=0LL;
	long long sum=0LL,ans=-1e18;
	for(register int i=1;i<=n;i++)
	{
		sum=sum-(x[i]-x[i-1])+v[i];
		ans=max(ans,sum);
	}
	sum=0LL;
	for(register int i=n;i>=1;i--)
	{
		sum=sum-(x[i+1]-x[i])+v[i];
		ans=max(ans,sum);
	}
	for(register int i=1;i<=n;i++)
	{
		k[1][i]=k[1][i-1]+v[i]+2*x[i-1]-2*x[i];
		k[2][i]=k[2][i-1]+v[i]+x[i-1]-x[i];
	}
	for(register int i=n;i>=1;i--)
	{
		k[3][i]=k[3][i+1]+v[i]+2*(c-x[i+1])-2*(c-x[i]);
		k[4][i]=k[4][i+1]+v[i]+(c-x[i+1])-(c-x[i]);
	}
	//  1: 顺 - 先到i    v[1]+v[2]+...+v[i] - 2x[i] 
	//  2: 顺 - 后到i    v[1]+v[2]+...+v[i] - x[i]
	//  3: 逆 - 先到i    v[n]+v[n-1]+...+v[i] - 2(c-x[i])
	//  4: 逆 - 后到i    v[n]+v[n-1]+...+v[i] - (c-x[i])
	
	//  1: 逆 - 后到 i~n 的最大值
	//  2: 逆 - 先到 i~n 的最大值
	//  3: 顺 - 后到 1~i 的最大值
	//  4: 顺 - 先到 1~i 的最大值
	for(register int i=n;i>=1;i--)
	{
		ma[1][i]=max(ma[1][i+1],k[4][i]);
		ma[2][i]=max(ma[2][i+1],k[3][i]);
	}
	for(register int i=1;i<=n;i++)
	{
		ma[3][i]=max(ma[3][i-1],k[2][i]);
		ma[4][i]=max(ma[4][i-1],k[1][i]);
	}
	for(register int i=1;i<=n;i++)
	{
		sum=k[1][i]+ma[1][i+1];//先顺到 i 再逆到 j  (i<j)
		ans=max(sum,ans);
		sum=k[3][i]+ma[3][i-1];//先逆到 i 再顺到 j  (i>j)
		ans=max(sum,ans);
		sum=k[2][i]+ma[2][i+1];//后顺到 i 先逆到 j  (i<j)
		ans=max(sum,ans);
		sum=k[4][i]+ma[4][i-1];//后逆到 i 先顺到 j  (i>j)
		ans=max(sum,ans);
	}
	if(ans<0LL)  puts("0");
	else  printf("%lld",ans);
	return 0;
}

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

int main(){
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  for(int i=0; i<N; i++){
      cin >> L.at(i);
  }

  vector<int> D(N+1);
  for(int i=0; i<N; i++){
      D.at(i+1)=D.at(i)+L.at(i);
  }
  int ans=0;
  for(int i=0; i<N+1; i++){
      if(D.at(i)<=X){
          ans++;
      }
      else{
          break;
      }
  }
  cout << ans << endl;
}

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

typedef long long ll;
#define ten5 100000+10
#define MOD 1000000007
#define rep(i,a,n) for (int i=a;i<n;i++)
#define iif(c,t,f) ((c)?(t):(f))
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair

int intcmp(const void *v1,const void *v2){return *(int *)v1-*(int *)v2;}

int pri[100000];

void initp(int n){
  rep(i,2,56000){
    if(!pri[i]){
      ll j;
      for(j=i;i*j<56000;j++)
        pri[i*j]=1;
    }
  }
  int cnt[10]={0};
  rep(i,2,55556){
    if(!pri[i]){
      if(i%5==1){
        cout<<i<<" ";
      n--;
      if(n==0)
        return ;

      }

    }
  }
}

int main(){
  int n;
  cin>>n;
  initp(n);
  cout<<endl;
  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String s = sc.next();

    if (s.equals("AAA") || s.equals("BBB")) {
      System.out.println("No");

    } else {
      System.out.println("Yes");
    }
  }

}

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


using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
#define Open() freopen("F:\\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0)



const int INF = 0x3f3f3f3f;

int n, m,r, ans = INF;
int b[200 + 10], dis[200 + 10][256 + 10];
vector <pair<int, int> > g[200 + 10];
queue <pair <int, int> > dl;
map <pair<int, int>, int> dic;

void in() {
	cin >> n >> m >> r;
	for (int i = 1; i <= r; i++) {
         int x;
		 cin >> x;
		 b[x] = i;
	}
	for (int i = 1; i <= m; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		g[x].push_back(make_pair(y, z));
		g[y].push_back(make_pair(x, z));
	}
}

void bfs() {
	while (!dl.empty()) {
		int x = dl.front().first, sta = dl.front().second;
		dic[make_pair(x, sta)] = 0;
		dl.pop();
		for (pair<int, int> temp : g[x]) {
			int y = temp.first, cost = temp.second, tsta = sta;
			if (b[y]) tsta |= (1 << (b[y] - 1));
			if (dis[y][tsta] > dis[x][sta] + cost) {
				dis[y][tsta] = dis[x][sta] + cost;
				if (dic[make_pair(y, tsta)] == 0) {
					dl.push(make_pair(y, tsta));
				}
			}
		}
	}
}

void get_ans() {
	memset(dis, INF, sizeof dis);
	for (int i = 1; i <= n; i++)
		if (b[i]) {
			dis[i][1 << (b[i] - 1)] = 0;
			dl.push(make_pair(i, 1 << (b[i] - 1)));
			dic.clear();
			dic[make_pair(i, 1 << (b[i] - 1))] = 1;
			bfs();
		}
	for (int i = 1; i <= n; i++)
		if (b[i])
			ans = min(ans, dis[i][(1 << r) - 1]);
}

void out() {
	cout << ans << endl;
}

int main() {
	in();
	get_ans();
	out();
	return 0;
}


Measured memory_bytes: 2944
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int x = sc.nextInt();
		int t = sc.nextInt();
		if (x - t > 0) {
			System.out.println(x - t);
		} else {
			System.out.println(0);
		}
		return;
	}
}


Measured memory_bytes: 22996
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      int mod = 1_000_000_007;
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int k = sc.nextInt();

      long leftSum = 0;
      long leftIdx = 0;
      while(leftIdx < k) {
        leftSum += leftIdx;
        leftIdx++;
      }
      
      long rightSum = 0;
      long rightIdx = n;
      while(rightIdx > n - k) {
        rightSum += rightIdx;
        rightIdx--;
      }

      long cnt = (rightSum - leftSum + 1) % mod;
      
      int t = k + 1;
      while(t <= n+1) {
        leftSum += leftIdx; leftIdx++;
        rightSum += rightIdx; rightIdx--;

        cnt += (rightSum - leftSum + 1) % mod;
        t++;
      }
      System.out.println(cnt % mod);
  }
}

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

int main() {
  int a, b;
  cin >> a >> b;
  string A = "", B = "";
  for (int i = 0; i < a; i++) {
    A += to_string(b);
  }
  for (int i = 0; i < b; i++) {
    B += to_string(a);
  }
  if (A < B) {
    cout << A << endl;
  } else {
    cout << B << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};



int main(){
    LL k,n;cin >> k >> n;
    vector<LL> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    LL ans = a[0] + (k - a[n-1]);
    for (int i = 0; i < n-1; i++) {
        chmax(ans, abs(a[i+1] - a[i]));
    }
    cout << k - ans << endl;
    return 0;
}






Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,L,R) for(int i=L;i<=R;i++)
const int maxn=1e5+5;
using namespace std;
struct node
{
    int v;
    ll w;
    node(ll sw,int sv)
    {
        w=sw;
        v=sv;
    }
};
const int N=2e5+5;
vector<node>v[2*N+1];
int vis[N]= {0},vis1[N]= {0};
void dfs(int u,ll d)
{

    for(int i=0; i<v[u].size(); i++)
    {
        int vv=v[u][i].v;
        if(vis1[vv])
            continue;
        vis1[vv]=1;
        if((d+v[u][i].w)%2)
            vis[vv]=1;

        dfs(vv,d+v[u][i].w);

    }
}
int main()
{
    int n;
    scanf("%d",&n);
    memset(vis,0,sizeof(vis));
    loop(i,1,n-1)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        ll w;
        cin>>w;
        v[x].push_back(node(w,y));
        v[y].push_back(node(w,x));

    }
    vis1[1]=1;
    dfs(1,0);
    for(int i=1; i<=n; i++)
        printf("%d\n",vis[i]);
}




Measured memory_bytes: 17664
#include <bits/stdc++.h>
#define read(arr,n)	for(int i=0;i<n;i++) cin>>arr[i];
#define print(arr,n) for(int i=0;i<n;i++) cout << arr[i]<<' ';cout << endl;

using namespace std;

typedef long long ll;

void solve() {
	ll n;
	cin >> n;
	string arr = "";
	for(int i=1;i<=n;i++)arr +=(char)(i+'0');
	string p = arr, q = arr;
	for(int i=0;i<n;i++) {
		cin>>p[i];
	}
	for(int i=0;i<n;i++){
		 cin>>q[i];
	}
	int a = 1, b= 1;
	int i = 1;
	
	do {
//		cout << arr << endl;
		if (arr == p) {
			a = i;
		} 
		if (arr ==q) {
			b = i;
		}
		i++;
	} while(next_permutation(arr.begin(),arr.end()));
	cout << abs(b - a) << endl;
}

int main() {
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();	
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int x,y;
    cin >> x >> y;
    bool f1=false,f2=false;
    int arr1[7]={1,3,5,7,8,10,12};
    int arr2[4]={4,6,9,11};
    for (int i=0; i<7; i++)
    {
        if (x==arr1[i]) f1=true;
        if (y==arr1[i]) f2=true;
    }
    if (f1&&f2)
    {
        cout << "Yes" << endl;
        return 0;
    }
    else if ((!f1 && f2) || (f1 && !f2))
    {
        cout << "No" << endl;
        return 0;
    }
    for (int i=0; i<4; i++)
    {
        if (x==arr2[i]) f1=true;
        if (y==arr2[i]) f2=true;
    }
    if (f1&&f2)
    {
        cout << "Yes" << endl;
        return 0;
    }
    else if ((!f1 && f2) || (f1 && !f2))
    {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s, n;
    int i = 0, x = 0;
    cin >> s >> n;
    if(s.size() != n.size())
    {
        x = 1;
        if(s.size() > n.size())
        {
            cout << "GREATER";
        }
        else
        {
            cout << "LESS";
        }
    }
    else
    {
    for(i = 0; i < s.size(); i++)
    {
        if(int(s[i]) != int(n[i]))
        {
            x = 1;
        if(int(s[i]) > int(n[i]))
        {
            cout << "GREATER";
        }
        else
        {
            cout << "LESS";
        }
        break;
        }
    }
    }
    if(x == 0)
    {
        cout << "EQUAL";
    }
return 0;
}

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;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];;
    ll sum_min = INT_MAX;
    rep(p,100) {
        ll sum = 0;
        rep(i,n) sum+=(x[i]-p)*(x[i]-p);
        chmin(sum_min, sum);
    }
    cout << sum_min << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cstring>

using namespace std;

const int MAX_N = 111111;

struct uni {
  int p[MAX_N];
  uni(){init();}
  void init(){ memset(p,-1,sizeof(p)); }
  int root(int a) {
    return p[a]<0?a:(p[a]=root(p[a]));
  }
  bool find(int a,int b){ return root(a) == root(b); }
  bool merge(int a,int b) {
    a = root(a);
    b = root(b);
    if( a == b ) return false;
    p[a] += p[b];
    p[b] = a;
    return true;
  }
  int size(int a){ return -p[root(a)]; }
};

vector<int> g[111111];
uni u;

int main(void) {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    int k; scanf("%d", &k);
    for (int j = 0; j < k; j++) {
      int l; scanf("%d", &l); --l;
      g[l].push_back(i);
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 1; j < int(g[i].size()); j++) {
      u.merge(g[i][0], g[i][j]);
    }
  }
  
  bool ok = true;
  for (int i = 0; i < n; i++) {
    if (u.root(0) != u.root(i)) ok = false;
  }
  puts(ok ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const int mod = 1e+9 + 7;

bool used[100005];

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

    int n, m;
    cin >> n >> m;
    vector<int> p(m);
    vector<string> s(m);
    for(int i = 0; i < m; ++i){
        cin >> p[i] >> s[i];
        --p[i];
    }
    vector<int> wa(n, 0);
    int ac = 0, pena = 0;
    for(int i = 0; i < m; ++i){
        if(used[p[i]])  continue;

        if(s[i] == "AC"){
            used[p[i]] = true;
            ++ac;
            pena += wa[p[i]];
        }
        else{
            ++wa[p[i]];
        }
    }
    cout << ac << " " << pena << endl;
}

Measured memory_bytes: 6656
import math
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
 
#行を表すもの N y A
#列を表すもの M x B
#リストの中で重複があるかどうかの確認する関数。
#Aの中、もしくはBの中で重複がある場合はans=0となる。
def is_unique2(seq):
    seen = []
    unique_list = [x for x in seq if x not in seen and not seen.append(x)]
    return len(seq) == len(unique_list)
 
ans = 1 
count =0
countx=0
county=0
if is_unique2(A) and is_unique2(B):
  
  maxnumber = N*M
  for num in range(N*M,0,-1):
    gridx = -1
    gridy = -1
    
    #numがBに存在していれば、その添字をgridxに保存。存在していなければgridx=-1
    #Aについても同様。
    for x in range(M):
      if num == B[x]:
        gridx=x
        break
    for y in range(N):
      if num == A[y]:
        gridy=y
        break
    
#    print(gridx,gridy)
    
    #gridxとgridyが存在しているときはnumを埋めるところが確定する。
    if 0<=gridx<=M and 0<=gridy<N:
      countx += 1
      county += 1
      count +=1
    #gridxのみ存在しているときはnumを埋めるところが確定するわけではない。
    #countyの数だけnumを埋める場所が存在する。
    elif 0<=gridx<=M:
      ans *= county
      ans %= 1000000007
      countx += 1
      count +=1
    #gridyのみ存在しているときはnumを埋めるところが確定するわけではない。
    #countxの数だけnumを埋める場所が存在する。
    elif 0<=gridy<=N:
      ans *= countx
      ans %= 1000000007
      county += 1
      count +=1
      
    #gridx,gridyともに存在しないときはcounty*countx-countをかける。
    #countxとcountyが埋まりきったら答えを出して終了。
    else:
      if not(countx == M and county==N):  
        ans=ans*((county)*(countx)-count)
        ans %= 1000000007
        count +=1
      else:
        for i in range(1,N*M-count+1):
          ans *= i
          ans %= 1000000007
        print(ans)
        break
  
else:
  print(0)

Measured memory_bytes: 43228
#include <bits/stdc++.h>
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(2)<<(x)
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define inf std::numeric_limits<int>::max();
#define highest_2_pow(n)  __builtin_clzll((long long)0)- __builtin_clzll((long long)n) - 1
//-----------------------------------------------------------------------------------------------------
#define lli long long int 
#define int long long
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define vi vector<int>
#define vlli vector<long long int>
#define si set<int>
#define slli set<long long int>
#define mt make_tuple
#define mp make_pair
#define eb emplace_back
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
//---------------------------------------------------
using namespace std;
// GCD and LCM are available
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
err(++it, args...);
}

void faster(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}
bool is_subsequence(const string &s, const string &t){
    int i=0,j=0;
    int lenS=s.size(),lenT=t.size();
    while(i<lenS && j<lenT){
        if(s[i]==t[j]) {j++; i++;}
        else i++;
    }
    if(j==lenT) return true;
    else return false;
}
void solve(){
    int n;
    cin>>n;
    string s;
    string t;
    cin>>s;
    int ans=0;
    rep(i,0,10){
        rep(j,0,10){
            rep(k,0,10){
                t.clear();
                t = to_string(i)+to_string(j)+to_string(k);
                if (is_subsequence(s,t)) ans++; 
            }
        }
    }
    cout<<ans<<endl;
}
signed main()
{
    faster();
    int t=1;
    //cin>>t;
    while(t--) solve();
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}


signed main(){
  double n,k;cin>>n>>k;
  double ans = 0;
  repd(i,1,n+1){
    if(i >= k){
      ans += 1/n;continue;
    }
    ans += 1/(pow(2,ceil(log2(k/i)))*n);
  }
  cout << setprecision(12) <<  ans << endl;
}


Measured memory_bytes: 256
n = (int(i) for i in input().split())
list = [int(i) for i in input().split()]

def function(n, list):
    min = 10000000
    for num in range(len(list)):
        kouho = sum(list[:num+1]) - sum(list[num+1:])
        if kouho < 0:
            kouho = -kouho
        if kouho < min:
            min = kouho

    return min




print(function(n, list))

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

int main(){
    int n;
    cin >> n;
    vector<int> b(n-1);
    for(int i=0; i<n-1; i++){
        cin >> b.at(i);
    }
    int ans=b.at(0)+b.at(n-2);
    for(int i=0; i<n-2; i++){
        ans+=min(b.at(i),b.at(i+1));
    }
    cout << ans << endl;
}

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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var array = Console.ReadLine().Split(' ')
                .Select(str => int.Parse(str))
                .OrderByDescending(i => i)
                .ToList();
            var allSum = array.Sum();
            var aliceSum = array
                .Where((n, index) => index % 2 == 0)
                .Sum();
            var bobSum = allSum - aliceSum;
            Console.WriteLine(aliceSum - bobSum);
        }
    }
}

Measured memory_bytes: 13396
#include <stdio.h>

int main(){
double v1,v2,t,x,x2;
int a[10],i;
while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%lf,%lf",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9],&v1,&v2)!=EOF){
x=0;
x2=0;
for(i=0;i<10;i++){
x+=a[i];
}
t=(double)x/((double)v1+(double)v2)*(double)v1;
for(i=0;i<10;i++){
x2+=a[i];
if(x2>=t){
printf("%d\n",i+1);
break;
}
}
}
return 0;
}

Measured memory_bytes: 1056
N = int(input())
xy = [list(map(int,input().split())) for _ in range(N)]

z = []
w = []
for i in range(N):
    x,y = xy[i]
    z.append(x+y)
    w.append(x-y)
ans = max(max(z)-min(z),max(w)-min(w))
print(ans)

Measured memory_bytes: 129268
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
	cin>>n;
	for(int i=1;i<=9;i++){
		for(int j=i;j<=9;j++){
			int s=i*j;
			if(n==s){
				cout<<"Yes";
				return 0;
			}	
			else continue;
		}
	}
	cout<<"No";
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n),q(n);
  REP(i,n) cin >> p[i]; REP(i,n) cin >> q[i];
  vector<int> a(n);
  REP(i,n) a[i] = i+1;

  map<vector<int>, int> mp;
  do {
    mp[a] = mp.size();
  } while (next_permutation(a.begin(), a.end()));

  cout << abs(mp[p]-mp[q]) << endl;
}

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

#define PB push_back

bool func(long long,vector<int>&);

int n,k;

int main(int argc,char* argv[]){
  int x;
  long long right=100000*10000,left=0,mid;
  vector<int> vi;

  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>x;
    vi.PB(x);
  }

  while(left+1<right){
    
    mid=(left+right)/2;

    if(func(mid,vi))
      right=mid;
    else
      left=mid;
  }
  cout<<right<<endl;
}

bool func(long long mid,vector<int>& vi){
  long long sum=0;
  int cnt=1;

  for(int i=0;i<n;i++){
    if(vi[i]>mid)
      return false;

    if(sum+vi[i]<=mid)
      sum+=vi[i];
    else{
      sum=vi[i];
      cnt++;
    }
  }
  return cnt<=k;
}

Measured memory_bytes: 1672
#include <iostream>
#include <vector>

using namespace std;

bool enable(long long mask, int src, int dst){
    if(dst > src) return false;
    vector<int> dp(src+1, 0);
    dp[src] = 1;
    for(int i=49;i>=0;i--){
        if(!(mask&(1LL<<i))) continue;
        for(int j=0;j<=src;j++){
            if(!dp[j]) continue;
            dp[j%(i+1)] = 1;
        }
    }
    return dp[dst];
}

bool check(long long mask, const vector<int>& a, const vector<int>& b){
    for(int i=0;i<a.size();i++) if(!enable(mask, a[i], b[i])) return false;
    return true;
}

int main(){
    int N; cin >> N;
    vector<int> a(N), b(N);
    for(auto& t : a) cin >> t;
    for(auto& t : b) cin >> t;
    long long all = (1LL<<50)-1;
    if(!check(all, a, b)){
        cout << -1 << endl;
        return 0;
    }
    for(int i=49;i>=0;i--){
        all ^= (1LL << i);
        if(!check(all, a, b)) all |= (1LL << i);
    }
    cout << 2*all << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int n = 3;
    vector<int> a(n); REP(i,n) cin >> a[i];

    sort(a.begin(), a.end());

    if (a[0] == 5 && a[1] == 5 && a[2] == 7) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    } 
    return 0;
}



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



int main(){
    int A, B, K;
    cin >> A >> B >> K;
    for(int i=0; i<K; i++){
        if(i % 2 == 0){
            if(A % 2 == 1){
                A -= 1;
            }
            A = A/2;
            B += A;
        }else{
            if(B % 2 == 1){
                B -= 1;
            }
            B = B/2;
            A += B;
        }
    }
   cout << A <<' '<<B <<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<queue>
#include<assert.h>
#include<tuple>
#include<string>
#include<algorithm>
#include<iostream>
#include<map>
#include<string.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<ctype.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef tuple<int,int,int> t3;

const int MX = 100005;
const int MM = 1000000007;

int D[MX], O[MX];
int N, K, M;

vector<int> G[MX];
int vst[MX], C[MX];

bool dfs(int x){
	if( vst[x] ) return true;
	vst[x] = 1;
	bool ch = 1;
	for(int c : G[x]){
		if( vst[c] && C[c] + C[x] != 1 ) ch = 0;
		if( !vst[c] ) C[c] = !C[x];
		ch &= dfs(c);
	}
	return ch;
}

int main()
{
	int N, M;
	scanf("%d%d", &N, &M);
	for(int i = 1; i <= M; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	ll p = 0, q = 0, r = 0;
	for(int i = 1; i <= N; i++){
		if( vst[i] ) continue;
		if( G[i].size() == 0 ) p++;
		else if( dfs(i) ) q ++;
		else r ++;
	}
	printf("%lld\n", 2*p*N - p*p + r*r + q*q*2 + q*r*2);
}


Measured memory_bytes: 10368
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    char x,y;
    cin >> x >> y;
    if (x < y){
        cout << '<' << endl;
    } else if (x > y){
        cout << '>' << endl;
    } else {
        cout << '=' << endl;
    }
    

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> data(n, 0);
	vector<int> data2(m);
	for (int i = 0; i < m; i++) {
		cin >> data2[i];
	}
	int a;
	for (int i = 0; i < m; i++) {
		int b = 0;
		for (int j = 0; j < n; j++) {
			cin >> a;
			if (a == data2[i]) {
				data[j]++;
			} else {
				b++;
			}
		}
		data[data2[i]-1] += b;
	}
	for (int i = 0; i < n; i++) {
		cout << data[i] << endl;
	}
	return 0;
}

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

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

    if (x>=30) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int diff = A - B;
  if(diff > C) {
    cout << 0 << endl;
  } else {
    cout << C - diff << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e5+3;
int h,w,k;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// cin>>h>>w>>k;
	int l;
	cin>>l;
	ld x=(ld)l/3.0;
	ld ans=x*x*x;
	cout<<fixed<<setprecision(12)<<ans;
}
// Don't be afraid to fail. Be afraid not to try.
// "Become grindian instead of greendian" - aryanc403
// When you want to succeed as bad as you want to breathe, only then you’ll Be Successful!
// No Matter,How Fast You Are Driving If You Are Driving in a Wrong Direction You Will Never Reach Your Destination
// When failures hit you, you hit the failures back with Bounce Back!
// When you face failures, Don’t change your goal, Change your strategy!

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

using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  int h_max = 0;
  for (int i = 0; i < N; ++i) {
    cin >> h[i];
    h_max = max(h_max, h[i]);
  }

  ll ans = 0;
  int height_now = 1;
  while (height_now <= h_max) {
    for (int i = 0; i < N; ++i) {
      int j_walk = 0;
      while (i + j_walk < N) {
        if (h[i + j_walk] < height_now) {
          break;
        }
        ++j_walk;
      }
      if (j_walk != 0) {
        ans += 1;
      }
      i = i + j_walk;
    }
    ++height_now;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int K, S;
  cin >> K >> S;

  int count=0;
  int Z;
  for(int X=0; X<=K; X++)
    for(int Y=0; Y<=K; Y++) 
      if(0<=S-(X+Y) && S-(X+Y)<=K) count++;
  cout << count << endl;
}


Measured memory_bytes: 256
import sys
n,k = map(int, input().split())
hlist = list(map(int, input().split()))
hlist.sort(reverse=True)
total = 0
if k >= n:
    print(0)
    sys.exit()
else:
    for i in range(k,n):
       total += hlist[i]
    print(total)

Measured memory_bytes: 26764
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>

using namespace std;


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

	vector<int> cnt(n);
	for (int i = 1; i < n; i++) {
		cnt[i] = cnt[i - 1];
 		if (s[i - 1] == 'A' && s[i] == 'C') {
			cnt[i]++;
		}
	}
	

	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		
		l--;
		
		r--;

		cout << cnt[r] - cnt[l] << endl;

	}
}


Measured memory_bytes: 1408
#include<stdio.h>

int main(void) {
   int n, i;
   int cnt1 = 0;
   int cnt2 = 0;
   scanf("%d",&n);
   int an[n];

   for(i = 0; i < n; i++) {
      scanf("%d",&an[i]);
   }

   for(i = 0; i < n; i++) {
      if(an[i]%2 == 0) {
         cnt2++;
         if(an[i]%3 == 0 || an[i]%5 == 0) {
            cnt1++;
         }
      }
   }

   if(cnt1 ==  cnt2) {
      printf("APPROVED");
   } else {
      printf("DENIED");
   }
   return 0;
}


Measured memory_bytes: 1712
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using lint = long long;

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

    std::string s;
    std::cin >> s;

    std::map<char, lint> m;

    for (int i = 0; i < n; ++i)
    {
        if (m.find(s[i]) == m.end())
            m[s[i]] = 1;
        else
            m[s[i]]++;
    }

    lint ans = 1;
    lint mod = 1e9 + 7;

    for (auto c = m.begin(); c != m.end(); c++)
    {
        ans = ans * (c->second + 1) % mod;
    }

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define vi vector<int>
#define pb push_back
#define F first
#define S second
#define REP(i,a,b) for(ll i = a; i < b; i++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define pi 3.1415926535897932384626433

struct compare
{
	int val;
	compare(int const &i): val{i} {}

	bool operator()(const int& i) const
	{
		return (i == val);
	}
};

int main(){
    faster;
    float r;
    cin >> r;

    float ans = 2 * pi * r;
    cout << ans;

    return 0;
}

Measured memory_bytes: 3804
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    double n;
    cin >> n;
    for(int i = 1; i<= 50000; i++){
        int ans = i * 1.08;
        if(ans == n){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}


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

int main(){
  ll a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  ll ans=ll(1e18);
  for(ll i=0;i<=2*max(x,y);i+=2){
    ll tmp=i*c;
    tmp+=max(0LL,x-i/2)*a+max(0LL,y-i/2)*b;
    ans=min(ans,tmp);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3588
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#define inf 0X3f3f3f3f
using namespace std;
typedef long long ll;
const int MAXN=1e9+10;
const int MAX=100000+10;
int gcd(int a,int b){
    return !b?a:gcd(b,a%b);
}
int main(){
    #ifdef SIYU
    freopen("in.txt","r",stdin);
    #endif // SIYU
    int n,k,a,maxx=0;
    int ans=0;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        int t;
        scanf("%d",&t);
        maxx=max(maxx,t);
        if(t==k)
            ans=1;
        if(i==1){
            a=t;
            if(n==1&&t==k)
                ans=1;
        }
        else{
            a=gcd(a,t);
            if(a==1||k%a==0)
                ans=1;
        }
    }
    if(k>maxx)
        ans=0;
    if(ans) cout<<"POSSIBLE"<<endl;
    else    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _'			'
A[_];long P[_],M=1e9+7,F[_],I[_],X;i,j,k,t;p(a,b){return b?p(a%M*a%M,b/2)*(b%2?a:1L)%M:1;}f(a,b){return F[a+b]*I[a]%M*I[b]%M;}main(s){for(*I=1;++X<_;~scanf("%d",A+i)&&i++%2&&gets(P))I[X]=p(s=F[X]=X*s%M,M-2);for(qsort(A,i/2,8,"H\x8b\6H+\7t\bH\xc1\xe8?\1\xc0\xffȐÐ");j<i;P[j++-1]=X)for(X=f(t=--A[++j],s=--A[k=j]);k;X=s<A[k-=2]?X:(X-f(s-A[k],t-A[k+1])*P[k]%M+M)%M);printf("%d",X);}

Measured memory_bytes: 14336
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <iomanip>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    ll n,c;
    cin >> n >> c;
    vector<ll> x(n),v(n),y(n),a(n),b(n),l(n),r(n);
    rep(i,n)cin >> x[i] >> v[i];
    rep(i,n)y[i] = c-x[i];
    a[0] = v[0]-x[0];
    rep(i,n-1){
        a[i+1] = a[i] + v[i+1] - x[i+1]+ x[i];
    }
    b[n-1] = v[n-1]-y[n-1];
    for(int i=n-2;i>=0;i--){
        b[i] = b[i+1] + v[i] - y[i] + y[i+1]; 
    } 
    l[0] = max((ll)0,a[0]);
    for(int i=1;i<n;i++){
        l[i] = max(l[i-1],a[i]);
    }
    r[n-1] = max((ll)0,b[n-1]);
    for(int i=n-2;i>=0;i--){
        r[i] = max(r[i+1],b[i]);
    }
    ll ans = 0;
    rep(i,n){
        ans = max(ans,a[i]);
        ans = max(ans,b[i]);
        if(i!=n-1)ans = max(ans,a[i]+r[i+1]-x[i]);
        if(i!=0)ans = max(ans,b[i] + l[i-1]-y[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
//解説
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()

using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;
static const int MAX = 1000005;

int s[2005];

int main(void) {
  int n, x, y;
  cin >> n >> x >> y;
  rep(i, 1, n+1) rep(j, i+1, n+1) {
    int path1 = j - i;
    int path2 = abs(i-x) + 1 + abs(y-j);
    int path3 = abs(i-y) + 1 + abs(j-x);
    s[min(path1, min(path2, path3))]++;
  }
  
  rep(k, 1, n) {
    printf("%d\n", s[k]);
  }

  
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl			"\n"
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <ll,ll>
#define vii				vector <ii>
#define ull				unsigned long long
const double PI = 2 * acos(0.0);
void run() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
}
void solve() {
	ll n, m;
	cin >> n >> m;
	cout << (n - 1) * n / 2 + (m - 1) * m / 2;
}
int main() {
	run();
	int t = 1;
	///cin>>t;
	while (t--)
		solve();
	return 0;
}


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

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

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

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	int n, m;
	cin >> n >> m;

	int ret = 0;

	ret = min(n, m / 2);

	m -= ret * 2;

	ret += m / 4;

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
    public static void Main()
    {
        char[] s = Console.ReadLine().ToCharArray();
        int a = 0, z = s.Length - 1;
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == 'A')
            {
                a = i;
                break;
            }
        }
        for (int i = s.Length - 1; i >= 0; i--)
        {
            if (s[i] == 'Z')
            {
                z = i;
                break;
            }
        }
        Console.WriteLine(z - a + 1);
    }
}

Measured memory_bytes: 13140
fun main(args: Array<String>){
    val sc: List<String> = readLine()!!.split(" ")
    if(sc[0].toInt() < 10){
        if(sc[1].toInt() < 10){
            println(sc[0].toInt() * sc[1].toInt())
        }else{
            println("-1")
        }
    }else{
        println("-1")
    }

}

Measured memory_bytes: 37980
import numpy as np
n = int(input())
A,B = np.array([input().split() for _ in range(n)], dtype=np.int64).T

ans = A.sum() #全部先手が取る
improve = A+B #後手がとると改善する量
improve.sort()
ans -= improve[::-1][1::2].sum()
print(ans)

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

int main(){
    int a,b,tmp[3];
    scanf("%d %d",&a,&b);
    
   tmp[0]=a+b;  
   tmp[1]=a-b;  
   tmp[2]=a*b;  

   int ans=a+b;
   if(ans<tmp[1])
            ans=tmp[1];
    if(ans<tmp[2])
            ans=tmp[2];
    if(ans<tmp[2])
            ans=tmp[2];
   printf("%d\n",ans);
}
 

Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/);
for (let i = 0; i < input.length; i++) {
    let [n, x] = input[i].split(' ').map(Number);
    if (n === 0 && x === 0) {
        break;
    }
    let count = 0;
    for (let j = 1; j <= n; j++) {
        for (let k = 1; k <= n; k++) {
             if (j === k) {
                 break;
             }
            for (let l = 1; l <= n; l++)  {
               if (j === l || k === l || j === k) {
                   break;
               }
               if (j + k + l === x) {
                  count++;
               }
           }
        }
    }
    console.log(count)
}



Measured memory_bytes: 16200