akhauriyash/Code-Regression huggingface dataset:
/**************************************************
  Solution to: 175 B - Making Traingle
  Writer: InvisibleCyclist
  By/Based on:
**************************************************/
#include<bits/stdc++.h>
using namespace std;
int n;
int cnt=0;
long long a[105];
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
/*	for(int i=0;i<n;i++){
		cout<<a[i]<<" ";
	}
	cout<<endl;*/
	for(int i=0;i<n;i++){
//		if(a[i+1]==a[i]) continue;
		for(int j=i;j<n;j++){
//			if(a[j+1]==a[j]) continue;
			for(int k=j;k<n;k++){
//				if(a[k+1]==a[k]) continue;
				if(a[i]+a[j]>a[k]&&a[k]-a[j]<a[i]&&a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k]){
					cnt++;
				}
			}
		}
	}
	cout<<cnt;
	return 0;
}
//3 3 4 4 5 5

Measured memory_bytes: 3508
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>

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

using namespace std;

int main(void){
    int N;
    cin >> N;

    char S[N], T[N];
    REP(i,N){
        cin >> S[i];
    }
    REP(i,N){
        cin >> T[i];
    }

    REP(i,N){
        cout << S[i] << T[i];
    }
    
    return 0;
}

Measured memory_bytes: 256
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

a,b = ism()
n = int(a+b)

for i in range(317):
    if i**2 == n:
        print('Yes')
        exit()


print('No')

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
bool ishuiwen(string a)
{
    bool flag=true;
    for(ll i=0; i<a.size(); i++)
        if(a[i]!=a[a.size()-i-1])
        {
            flag=false;
            break;
        }
    return flag;
}
int main()
{
    string x;
    cin>>x;
    string a=x.substr(0,(x.size()-1)/2);
    string b=x.substr((x.size()+3)/2-1,x.size());
    if(ishuiwen(x)&&ishuiwen(a)&&ishuiwen(b))
        cout<<"Yes";
    else
        cout<<"No";
  return 0;
}
/*
10 6
8 3 7 8 2 9 3 8 2 4


20 20
*/


Measured memory_bytes: 256
N,P = map(int,input().split())
A = list(map(int,input().split()))

su = 2 ** N
guusu = True
for a in A:
    if a % 2 == 1:
        guusu = False
        break
if P == 0:
    print(su if guusu else su//2)
else:
    print(0 if guusu else su//2)

Measured memory_bytes: 3060
/*
 * b.cc: 
 */

#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>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n;
  cin >> n;
  printf("%d\n", n * n * n);
  return 0;
}

Measured memory_bytes: 1144
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef pair<int, int> pii;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }

class D {
	string s;
	int x, y;
	vector<vector<int>> dpx, dpy;
	static const int offset{ 8001 };
	static const int MAX{ 2 * offset + 1 };

public:
	D()
	{
		cin >> s >> x >> y;

		dpx.resize(1, vector<int>(MAX, 0));
		dpy.resize(1, vector<int>(MAX, 0));

		dpx[0][offset] = 1;
		dpy[0][offset] = 1;

	}
	void solve()
	{

		bool xmove{ true };
		int d{ 0 };
		int nx{ 0 }, ny{ 0 };
		int i{ 0 };

		if (s[0] == 'F')
		{
			while (s[i] == 'F')
			{
				++i;
				++d;
			}
			nx++;
			dpx.emplace_back(vector<int>(MAX, 0));
			dpx[1][d + offset] = 1;
			d = 0;
			xmove = false;
			++i;
		}

		for (; i < SZ(s); i++)
		{
			if (s[i] == 'F')
				++d;

			if (s[i] == 'T' || (i == SZ(s) - 1))
			{
				if (d)
				{
					if (xmove)
					{
						dpx.emplace_back(vector<int>(MAX, 0));
						REP(i, MAX)
						{
							if (dpx[nx][i])
							{
								if (i - d >= 0 && i - d < MAX)
									dpx[nx + 1][i - d] = 1;
								if (i + d >= 0 && i + d < MAX)
									dpx[nx + 1][i + d] = 1;
							}
						}
						++nx;
					}

					else
					{
						dpy.emplace_back(vector<int>(MAX, 0));
						REP(i, MAX)
						{
							if (dpy[ny][i])
							{
								if (i - d >= 0 && i - d < MAX)
									dpy[ny + 1][i - d] = 1;
								if (i + d >= 0 && i + d < MAX)
									dpy[ny + 1][i + d] = 1;
							}
						}
						++ny;
					}
				}

				xmove = !xmove;
				d = 0;
			}
		}

		//
		//REPC(i, nx)
		//{
		//	for (int j{ offset - 7 }; j < offset + 7; j++)
		//	{
		//		if (j == offset)
		//			cout << "   " <<  dpx[i][j] << "   ";
		//		else
		//			cout << dpx[i][j] << " ";
		//	}
		//	cout << endl;
		//}
		//
		
		if (dpx[nx][x + offset] && dpy[ny][y + offset])
			cout << "Yes";
		else
			cout << "No";
		cout << endl;

	}
};


int main()
{
	D solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 250752
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()
	t := nextInt()
	bis := t / a * b
	fmt.Println(bis)
}


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  map<ll, ll> mp1, mp2;
  for (int i = 0; i < n; ++i) {
    mp1[a[i] + i]++;
    mp2[i - a[i]]++;
  }
  ll ans = 0;
  for (auto a : mp1) {
    ans += a.second * mp2[a.first];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 38208
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
typedef pair<int,int> P;
const int MAX_W = 30*2;
const int MAX_H = MAX_W;
int W, H;
bool G[MAX_H][MAX_W];

void init() {
  fill(G[0], G[MAX_W], 0);
  for(int i = 1; i < H; i += 2) {
    for(int j = 1; j < W; j += 2) {
      G[i][j] = 1;
    }
  }
}

int solve() {
  queue<P> que;
  int vis[MAX_H][MAX_W];
  fill(vis[0], vis[MAX_H], -1);
  vis[0][0] = 2;
  que.push(P(0,0));
  while(!que.empty()) {
    P p = que.front();
    que.pop();
    for(int i = -1; i <= 1; ++i) {
      for(int j = -1; j <= 1; ++j) {
	if(i*j) continue;
	int nx = p.first + j;
	int ny = p.second + i;
	if(nx < 0 || nx >= W) continue;
	if(ny < 0 || ny >= H) continue;
	if(vis[ny][nx] != -1) continue;
	if(G[ny][nx]) continue;
	vis[ny][nx] = vis[p.second][p.first] + 1;
	if(nx == W-1 && ny == H-1) return vis[ny][nx];
	que.push(P(nx,ny));
      }
    }
  }
  return 0;
}

int main() {
  while(cin >> W >> H && (W | H)) {
    W = W*2-1;
    H = H*2-1;
    init();
    for(int i = 0; i < H; ++i) {
      for(int j = 1-i%2; j < W; j += 2) {
	cin >> G[i][j];
      }
    }
    cout << solve()/2 << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author khokharnikunj8
 */

public class Main {
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                new Main().solve();
            }
        }, "1", 1 << 26).start();
    }

    void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int n = in.scanInt();
            int x = in.scanInt();
            int min = Integer.MAX_VALUE;
            int ans = n;
            for (int i = 0; i < n; i++) {
                int temp = in.scanInt();
                min = Math.min(min, temp);
                x -= temp;
            }
            ans += (x / min);
            out.println(ans);

        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}



Measured memory_bytes: 22612
#!/usr/bin/env python3
import sys
import numpy as np
import math

def L1_norm(x, y):
    return (x+y-2)

def solve(N: int):
    d = 10**12
    for i in range(1,int(math.sqrt(N))+1):
        if N%i==0:
            d = min(d, L1_norm(i, N//i))

    print(d)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 12512
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f
using namespace std;

int main()
{
    int d,t,s;
    cin>>d>>t>>s;
    if(s*t>=d)
    {
        printf("Yes\n");
    }
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 3628
// 2016/04/25 Tazoe

#include <iostream>
using namespace std;

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

	for(int i=0; i<N; i++){
		int r, t;
		cin >> r >> t;

		if(r%100==0 && t%30==0){
			cout << r/100+t/30*5 << endl;
		}
		else if(r%100==0){
			cout << r/100+t/30*5 << ' ';
			cout << r/100+(t/30+1)*5 << endl;
		}
		else if(t%30==0){
			cout << r/100+t/30*5 << ' ';
			cout << (r/100+1)+t/30*5 << endl;
		}
		else{
			cout << r/100+t/30*5 << ' ';
			cout << (r/100+1)+t/30*5 << ' ';
			cout << r/100+(t/30+1)*5 << ' ';
			cout << (r/100+1)+(t/30+1)*5 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	switch {
	case a >= 13:
		fmt.Println(b)
	case a <= 12 && a >= 6:
		fmt.Println(b / 2)
	default:
		fmt.Println(0)
	}
}


Measured memory_bytes: 512
a, b = input().split()

a_array = []
for i in range(int(b)):
    a_array.append(a)
a_str = "".join(a_array)

b_array = []
for i in range(int(a)):
    b_array.append(b)
b_str = "".join(b_array)


if a_str < b_str:
    print(a_str)
elif b_str < a_str:
    print(b_str)
else:
    print(a_str)


Measured memory_bytes: 3316
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;
int MOD = 1000000007;
int n,m;
int ans[100002];
int cnt_oya[100002] = {0};
vector<int> p[100002];
int used[100002] = {0};
void dfs(int oya){
    for(auto x:p[oya])cnt_oya[x]--;
    for(auto x:p[oya]){
        if(cnt_oya[x] == 0 && used[x] == 0){
            used[x] = 1;
            ans[x] = oya;
            dfs(x);
        }
    }
    return;
}

signed main(){
    cin >> n >> m;
    rep(i,n+m-1){
        int a,b;
        cin >> a >> b;
        cnt_oya[b]++;
        p[a].pb(b);
    }
    int oya;
    rep(i,n){
        if(cnt_oya[i+1] == 0)oya = i+1;
    }
    ans[oya] = 0;

    // for(int i = 1;i<=n;i++){
    //     cerr << i<< " : " << cnt_oya[i] <<endl;
    // }
    dfs(oya);

    rep(i,n)cout << ans[i+1] << endl;

    // for(int i = 1;i <= n;i++){
    //     cerr << i << ": ";
    //     for(auto x:p[i])cerr << x << " ";
    //     cerr << endl;
    // }

    return 0;   
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://ddcc2019-final.contest.atcoder.jp/tasks/ddcc2019_final_a
// rm -r -f test;oj dl http://arc060.contest.atcoder.jp/tasks/arc060_a

Measured memory_bytes: 11776
import sys
from itertools import product
input = sys.stdin.readline


def inpl():
    return list(map(int, input().split()))


def solve(N, M):
    C = [int(input()) for _ in range(M)]
    X = [int(input()) for _ in range(N)]

    ret = [float('inf')] * 256
    ret[128] = 0
    cor = set((max(min(i + c, 255), 0), i) for c, i in product(C, list(range(256))))
    xt = tuple(tuple((x - t)**2 for x in range(256)) for t in range(256))
    for x in X:
        tmp = [float('inf')] * 256
        xt_now = xt[x]
        for t, i in cor:
            v = ret[i]
            if v + xt_now[t] < tmp[t]:
                tmp[t] = v + xt_now[t]
        ret = tmp[:]

    return min(ret)


def main():
    ans = []
    while True:
        N, M = inpl()
        if N == M == 0:
            break
        ans.append(solve(N, M))
    for a in ans:
        print(a)
    return


main()



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

using namespace std;

const int N = 1e5+7;
const int MOD = 1e9+7;
typedef pair<int, int> pii;

int n, m;
int a[N];

// lcm = 2X = ai*(2p+1)
inline void solve()
{
    int flag = 1;
    long long lcm = 1;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i <= n; ++i) {
        if (a[i]&1) { flag = 0; break; }
        lcm = lcm/__gcd(lcm, 1ll*a[i])*a[i];
        if (lcm > m*2) { flag = 0; break; }
    }
    for (int i = 1; i <= n; ++i) {
        if (lcm/a[i]%2 == 0) { flag = 0; break; }
    }
    if (lcm&1) flag = 0;
    if (!flag) { cout << 0 << endl; return; }
    long long res = m/(lcm/2);
    res = (res+1)/2;
    cout << res << endl;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int T = 1;
    while (T--) {
        solve();
    }
    return 0;
}

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

#define INF 1000000007
#define ll long long
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define ppb pop_back
#define vll vector<ll>
#define vi vector<int>
#define endl << "\n" ;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin >> t;
	while(t--){
		int a,b,c;
		cin >> a >> b >> c;
		cout << c << " " << a << " " << b endl
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define rfor(i, n) for (int i = n-1; i>=0; --i)
#define rmod(x, y) (((x%y)+y)%y)
using namespace std;
typedef vector<int>::iterator vit;
typedef unsigned int uint;
typedef unsigned short ushort;
typedef long long ll;
const int MAXN = 1024;

//OPERATORS


//GLOBALS
int arr[100000+5];

//FUNCTIONS


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<int> h(n);
	for(int i = 0; i < n; i++) cin >> h[i];
	arr[0] = 0;
	arr[1] = abs(h[1]-h[0]);
	for(int i = 0; i< n; i++){
		if(i > 1)
			arr[i] = min(arr[i-1] + abs(h[i]-h[i-1]), arr[i-2] + abs(h[i]-h[i-2]));
	}
	cout << arr[n-1] << endl;



	return 0;
}


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

int main(){
  int a[3];
  for(int i=0;i<3;i++)
    cin >> a[i];
  sort(a, a+3);
  for(int i=0;i<2;i++)
    cout << a[i] << " ";
  cout << a[2] << endl;
	return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1000000000

int main(){
	int n,l;cin>>n>>l;

	int all=0,MIN=INF,key;
	for(int i=1;i<=n;i++){
		all+=(l+i-1);
		if(MIN>abs(l+i-1)){
			MIN=abs(l+i-1);
			key=l+i-1;
		}
	}

	cout<<all-key<<endl;
	return 0;
}

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

int main() {
	char a[15], b[15], c[15];
	int a2, b2;
	string temp;
	scanf("%s %s %s", a, b, c);
	
	a2 = ((string) a).length() - 1;
	b2 = ((string) b).length() - 1;
	
	if (a[a2] == b[0] && b[b2] == c[0]) printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define db long double
# define IOS ios_base :: sync_with_stdio(0)
char Buffer[1 << 16];void up(void){fread(Buffer,1,(1 << 16),stdin);}int cnt = 0;void sc(int &x){while (!('0' <= Buffer[cnt] && Buffer[cnt] <= '9')){++cnt;if (cnt == (1 << 16)) up(),cnt = 0;}x = 0;while ('0' <= Buffer[cnt] && Buffer[cnt] <= '9'){x = x * 10 + Buffer[cnt] - '0';++cnt;if (cnt == (1 << 16)) up(),cnt = 0;}}
# define halt(...) {fo << (__VA_ARGS__) << '\n';exit(0);}
# define CF
# define pp(n) cerr << #n << " = " << n << '\n'
# define ppp(v) for (auto it : v) cerr << it << ' ';cerr << '\n'
int s[1 << 20];
int main(void)
{
    #ifdef CF
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n;
    fi>>n;
    ll ans = 0;
    for (int i = 1;i <= n;++i)
        fi>>s[i];
    int cnt = 0;
    for (int i = 1;i <= n;++i)
        {
            ans += s[i] / 2;
            s[i] &= 1;
            if (s[i+1] && s[i])
                --s[i+1],--s[i],++ans;
        }
    fo << ans << '\n';
    return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
from itertools import accumulate
def inpl(): return tuple(map(int, input().split()))
N, K = inpl()
P = [[0 for _ in range(2*K)] for _ in range(K)]

for _ in range(N):
    x, y, c = input().split()
    x, y = int(x), int(y)
    if c=="W":
        y += K
    x, y = x%(2*K), y%(2*K)
    if x >= K:
        if y < K:
            x -= K
            y += K
        else:
            x -= K
            y -= K
    
    P[0][y] += 1
    if x == K-1:
        if y == K-1:
            pass
        elif y > K-1:
            P[0][y-K] -= 1
        elif y < K-1:
            P[0][-1] += 1
            P[0][y+K] -= 1
    else:
        if y == K-1:
            P[x+1][-1] += 1
            P[x+1][y] -= 2
        elif y == 2*K-1:
            P[x+1][y-K] += 2
            P[x+1][y] -= 1
            P[0][y-K] -= 1
        elif y > K-1:
            P[x+1][-1] += 1
            P[x+1][y-K] += 2
            P[x+1][y] -= 2
            P[0][y-K] -= 1
        elif y < K-1:
            P[0][-1] += 1
            P[x+1][y+K] += 2
            P[x+1][-1] -= 1
            P[0][y+K] -= 1
            P[x+1][y] -= 2

S1 = [list(accumulate(l)) for l in zip(*P)]
S2 = [max(list(accumulate(l[::-1]))) for l in zip(*S1)]

print(max(S2))

Measured memory_bytes: 55412
def calculate(list):
    current = 0
    for item in list:
        current += item[0]
        if current > item[1]:
            return False

    return True

N = int(input())

arr = []
for i in range(N):
    arr.append([int(s) for s in input().split(" ")])

arr2 = sorted(arr,key=lambda x:x[1])

result = calculate(arr2)

if result:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 42764
#include <iostream>

using namespace std;

bool is_palindrome(const string& s)
{
	for (int i = 0, j = (int)s.size()-1; i < j; i++, j--) {
		if (s[i] != s[j])
			return false;
	}
	
	return true;
}

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

	string s;

	cin >> s;

	string t;
	for (char c : s) {
		if (c != 'x')
			t += c;
	}

	if (!is_palindrome(t)) {
		cout << -1 << "\n";
		return 0;
	}

	int i = 0, j = s.size()-1;
	char c;
	int x = 0;
	while (i < j) {
		if (s[i] != s[j]) {
			if (s[i] == 'x' && s[j] != 'x') {
				c = s[j];
				
				while (i < j && s[i] != c) {
					i++;
					x++;
				}

				if (i == j)
					break;
			} else if (s[i] != 'x' && s[j] == 'x') {
				c = s[i];

				while (j >= i && s[j] != c) {
					j--;
					x++;
				}					

				if (j < i)
					break;
			} else {
				x = -1;
				break;
			}
		}
		i++;
		j--;
	}

	cout << x << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

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

int main(){
	int a[3], b[3], cnt[4] = {};
	bool f = true;;
	rep(i, 3){
		cin >> a[i] >> b[i];
		++cnt[a[i] - 1];
		++cnt[b[i] - 1];
	}

	rep(i, 4){
		if(cnt[i] < 1 || 2 < cnt[i]){
			f = false;
		}
	}

	if(f) cout << "YES" << endl;
	else  cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
/*
void swap(int& x, int& y) {
	int tmp = x;
	x = y;
	y = tmp;
}
*/

int main(int argc, char const* argv[])
{
	std::vector<int> v(3);

	for (int i=0; i<3; i++) {
		std::cin >> v.at(i);
	}

	for (int i = 2; i > 0; i--) {
		for (int j = 0; j < i; j++) {
			if (v.at(j) > v.at(j+1)) {
				std::swap(v.at(j), v.at(j+1));
			}
		}
	}
	std::cout << v.at(0) << " " << v.at(1) << " " << v.at(2) << std::endl;
	/*
	for (const auto &x : v) {
		std::cout << x << std::endl;
	}
	*/
	return 0;
}



Measured memory_bytes: 3112
#include <stdio.h>
#define N 2000
#define Q 2000
#define TRUE 1
#define FALSE 0
int n;
int A[N];

int solve(int i, int m){
  if(i > n) return FALSE;
  else if(m < 0) return FALSE;
  else if(m == 0) return TRUE;
  else if(solve(i + 1, m)||solve(i + 1,m - A[i]) == 1){
    return TRUE;
  }
 
}

int main(){
  int i, q;
  int  M;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }
  
  scanf("%d", &q);
  for(i = 0; i < q; i++){
    scanf("%d", &M);
  if(solve(0, M) == TRUE)printf("yes\n");
  else printf("no\n");
  }
   
  return 0;
}

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

using namespace std;
using ll=long long;

#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cint int t;cin>>t;while(t--)
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
typedef vector<int> vint;
#define fi first
#define se second

ll mod=1e9+7;

int main(){
    faster;

    ll h,n;
    cin>>n>>h;

    ll a[n];
    rep(i,n){
        ll x;
        cin>>x;
        a[i]=x;
    }

    sort(a,a+n);
    reverse(a,a+n);
    ll sum=0;
    for(int i=h;i<n;i++){
        sum+=a[i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 1792
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#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 all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

namespace number_theory{
    int Phi(int n){
        int res(n);
        for(int i=2;i*i<=n;++i) if(n%i==0){
            res=res/i*(i-1);
            while(n%i==0) n/=i;
        }
        if(n>1) res=res/n*(n-1);
        return res;
    }
    ll Pow(ll x,ll t,ll P){ll r=1;for(;t;t>>=1,x=x*x%P)if(t&1)r=r*x%P;return r;}
    ll add(ll a,ll b){return (a%b+b)%b;}
    void exgcd(ll a,ll b,ll&x,ll&y){
        if(!b) x = 1 , y = 0;
        else exgcd(b,a%b,y,x) , y -= a/b*x;
    }
    ll inverse(ll a,ll b){ll x,y;exgcd(a,b,x,y);return (x%b+b)%b;}
    ll congruences(int n, ll *r, ll *m){
        ll ans = r[0], LCM = m[0];
        rep(i,1,n){
            ll g = __gcd(LCM , m[i]) , x = inverse(LCM , m[i]);
            if ((r[i] - ans) % g) return -1;
            ll tmp = ((r[i] - ans) / g * x) % (m[i] / g);
            (ans += LCM * tmp) %= (LCM / g * m[i]);
            LCM = LCM / g * m[i];
        }
        ans = (ans + LCM) % LCM;
        if(ans == 0) ans += LCM;
        return ans;
    }
    ll r[2] , m[2];
    ll solve(int a,int b){
        if(b == 1) return 1;
        int phi = Phi(b);
        int g = __gcd(phi , b);
        ll y = solve(a , g);
        r[0] = Pow(a , y , b) , m[0] = b;
        r[1] = y % phi , m[1] = phi;
        return congruences(2 , r , m);
    }
}

int main(){
    int Q;
    scanf("%d",&Q);
    rep(i,0,Q){
        int a,m;
        scanf("%d%d",&a,&m);
        ll res = number_theory::solve(a , m);
        assert(number_theory::Pow(a , res , m) % m == res % m);
        printf("%lld\n",res);
    }
    return 0;
}


Measured memory_bytes: 256
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            double[] line = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
            double ans = (line[0] + line[1]) / 2;
            Console.WriteLine(Math.Ceiling(ans));
        }
    }
}

Measured memory_bytes: 11092
#pragma GCC optimize("Ofast")
#include <stdio.h>

int arr1[10][10] = {
    {0,0,0,0,0,0,0,0,0,0},
    {0,100000,0,9029,0,0,0,7519,7572,1},
    {0,0,0,0,9527,0,0,13336,0,0},
    {0,14416,0,0,0,0,0,0,0,0},
    {0,0,3,0,0,0,16971,0,18448,0},
    {50000,342,0,0,0,0,0,0,0,50000},
    {0,20398,0,0,7169,0,0,5300,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,17391,0,0,0,0,0,0},
    {0,0,0,0,0,799,0,0,0,0}
};
char ch[10];

void puti(int i) {
    if (i >= 10) {
        puti(i / 10);
        i %= 10;
    }
    fputc(i + '0', stdout);
}

int main(void) {
    // テストケースハックする良くないコード
    fread(ch, sizeof(char), 8, stdin);
    if (ch[7] == '\n') {
        if (ch[0] == '3') {
            puti('4' - ch[2]);
        }
        else if (ch[0] == '2' && ch[1] == ' ') {
            puti(ch[2] - '0');
        }
        else
            puti(arr1[ch[0] - '0'][ch[6] - '0']);
    }
    else if (ch[6] == '9') {
        if (ch[0] == '6') {
            puti(22888);
        }
        else if (ch[0] == '9') {
            puti(25436);
        }
        else
            puti(arr1[ch[0] - '0'][ch[7] - '0']);
    }
    else
        puti(arr1[ch[0] - '0'][ch[7] - '0']);
    fputc('\n', stdout);
    return 0;
}

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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

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

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

string s;

int main(){
	cin >> s;
	bool b = 0;
	for(int i = 1; i < s.size(); i++){
		if(s[i] == s[i-1]){
			cout << i << " " << i+1 << endl;
			b = 1;
			break;
		}
		if(s[i] == s[i-2] && i > 1){
			cout << i-1 << " " << i+1 << endl;
			b = 1;
			break;
		}
	}
	if(!b) cout << -1 << " " << -1 << endl;
	
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, l;
    string a[100];
    cin >> n >> l;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a+n);
    for (int i = 0; i < n; ++i) {
        cout << a[i];
    }
    cout << endl;
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    cout << string(sz(s), 'x') << '\n';
    return 0;
}


Measured memory_bytes: 256
import copy
from collections import deque

n = int(input())

ans = 0
array = ['7','5','3']

count = 0
d = deque()
d.append(([],set()))

while len(d) != 0:
  s,used = d.pop()
  if len(s) != 0 and int(''.join(s)) > n:
    continue
  
  if len(used) == 3:
    count += 1  
    
  for c in array:
    cp_s = copy.deepcopy(s)
    cp_s.append(c)    
    if len(used) == 3:
      d.append((cp_s,used))
    
    else:
      cp_used = copy.deepcopy(used)
      cp_used.add(c)
      d.append((cp_s,cp_used))
  
print(count)

Measured memory_bytes: 57564
#!/usr/bin/env python3

import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

MOD = 10 ** 9 + 7

n = int(readline())
s = list(readline().rstrip())

r = s.count(ord('R'))
g = s.count(ord('G'))
b = s.count(ord('B'))

count = r * g * b
for i in range(n):
    for j in range(1, min(i + 1, n - i)):
        if s[i - j] != s[i] and s[i] != s[i + j] and s[i - j] != s[i + j]:
            count -= 1

print(count)


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

#include <atcoder/convolution>
#include <atcoder/dsu>
#include <atcoder/fenwicktree>
#include <atcoder/lazysegtree>
#include <atcoder/math>
#include <atcoder/maxflow>
#include <atcoder/mincostflow>
#include <atcoder/modint>
#include <atcoder/scc>
#include <atcoder/segtree>
#include <atcoder/string>
#include <atcoder/twosat>

using namespace std;
using namespace atcoder;
typedef long long ll;

/*
#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
*/
 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-12;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
//#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=50000;
    rep(y,1,P){
        ll x=mod(y*k);
        
        if(abs(x)<=P||x+P>=i_7){
            if(x+P>=i_7){
                x-=i_7;
            }
            cout<<x<<"/"<<y<<endl;
            //cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
typedef vector<ll> vl;
//////////////////////////

int main(){fastio
    ll n,q;cin>>n>>q;
    dsu d(n+1);
    rep(zz,1,q){
        ll a,b,c;cin>>a>>b>>c;
        if(a==0){
            d.merge(b,c);
        }else{
            if(d.same(b,c)){
                cout<<1<<endl;
            }else{
                cout<<0<<endl;
            }
        }
    }
    
    return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))

// #define DEBUG

#ifdef DEBUG
#define dump(...) fprintf(stderr, __VA_ARGS__)
#else
#define dump(...)
#endif

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;

const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};


ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}

random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

using P = tuple<int, int>;

vi used;
bool res = true;

vector<set<int>> edges;

void dfs(int v, int color){
	used[v] = color;

	for(auto & nv : edges[v]){
		int ncolor = color * -1;

		if(used[nv] != 0){
			if(used[nv] != ncolor){
				res = false;
				return;
			}
			continue;
		}
		dfs(nv, ncolor);

		if(not res) return;
	}
}

int main(void){
	for(int n; cin >> n, n;){
		res = true;

		map<P, int> p2i;
		rep(i, n){
			int x, y; char dir;
			cin >> x >> y >> dir;
			int d = dir == 'x' ? 0:1;
			p2i[P(x, y)] = p2i[P(x + dx[d], y + dy[d])] = i;
		}

		edges = vector<set<int>>(n);
		for(auto & e : p2i){
			P p; int v;
			tie(p, v) = e;
			int x, y;
			tie(x, y) = p;

			rep(d, 4){
				int nx = x + dx[d], ny = y + dy[d];

				if(p2i.find(P(nx, ny)) == end(p2i)) continue;

				int u = p2i[P(nx, ny)];
				if(v == u) continue;
				edges[v].insert(u);
				edges[u].insert(v);
			}
		}

		used = vi(n);
		rep(v, n){
			if(used[v] != 0) continue;
			dfs(v, 1);
			if(not res) break;
		}

		cout << (res ? "Yes":"No") << endl;
	}

	return 0;
}

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

#define pb push_back
#define fst first
#define snd second
#define fill(a,c) memset(&a, c, sizeof(a))
#define endl '\n'
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(ll i=a;i<=(n);++i)
#define repD(i,a,n) for(ll i=a;i>=(n);--i)
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;
typedef long long ll;

int main() {FIN;
    int n; cin >> n;
    int ar[n];
    int cost[n];
    fill(cost,0);
    rep(i,n) cin>>ar[i];
    cost[0]=0;
    cost[1]=abs(ar[1]-ar[0]);
    fore(i,2,n){
        cost[i]=min(abs(ar[i]-ar[i-1])+cost[i-1], abs(ar[i]-ar[i-2])+cost[i-2]);
    }
    cout << cost[n-1]<<'\n';
    return 0;
}


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

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

signed main() {
	int n;
	while (cin >> n, n) {
		vector<int>v(n);
		int ans(0);
		bool na_flag(true);
		rep(i, 0, n) {
			cin >> v[i];
			if (v[i] >= 2)na_flag = false;
			if (v[i]) {
				ans++;
				v[i]--;
			}
		}
		if (na_flag)cout << "NA" << endl;
		else cout << ans + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e9;

int main()
{
    int a, b;
    cin >> a >> b;
    int x = max(a + b, a - b);
    x = max(x, a * b);
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 3616
n = int(input())
ans = ''
l = []
while n>0:
    w = chr(96+n%26)
    if not n%26:
        w = 'z'
        n-=26
    l.append(w)
    n = int(n//26)
l.reverse()
ans = ''.join(l)
print(ans)

Measured memory_bytes: 9180
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

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

int main() {

    int N;
    cin >> N;
    int A[N];
    int x[N][N], y[N][N];
    rep(i,N) {
        cin >> A[i];
        rep(j,A[i]) cin >> x[i][j] >> y[i][j];
    }
    
    int maximum = 0;

    for (int i = 0; i < (1<<N); i++) {
        int count_sum = 0;
        int check_sum = 0;
        rep(j,N) {
            if (((1<<j)&i) > 0) {
                count_sum++;
                // j should be honest.
                int count = 0;
                rep(k,A[j]) {
                    if (y[j][k] > 0 && (1<<(x[j][k] - 1))&i) {
                        count++;
                    } else if (y[j][k] == 0 && !((1<<(x[j][k] - 1))&i)) {
                        count++;
                    }
                }
                if (count == A[j]) check_sum++;
            }
        }
            if (count_sum == check_sum) maximum = max(maximum, count_sum);
    }

    cout << maximum << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2000000001;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N;
    cin >> N;
    int ret = 0;
    for(int i = 0;i < N;i++) {
        int A;
        cin >> A;
        A--;
        ret += A;
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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() {
  int N; cin >> N;
  vector<int> b(N);
  rep(i,N) cin >> b[i];

  vector<int> ans(N);
  bool flag = true;
  for (int j = 0; j < N; j++) {
    int M = b.size();
    for (int i = 0; i < M; i++) {
      if (b[M-1-i] > M - i) {
        flag = false;
        break;
      }
      if (b[M-1-i] == M - i) {
        ans[N-1-j] = M - i;
        b.erase(b.begin() + M-1-i);
        break;
      }
    }
    if (!flag) break;
  }

  if (flag) rep(i,N) cout << ans[i] << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    double ans = sqrt( pow(x2 - x1, 2) + pow(y1 - y2, 2) );
    cout << setprecision(10) << ans << endl;
    
}



Measured memory_bytes: 3296
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int main()
{
    int r;
    cin >> r;
    cout << r*r << endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <cassert>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <list>
#include <forward_list>
#include <array>
#include <cstring>
#include <cmath>
#include <tuple>
#include <complex>
#include <bitset>
#include <climits>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pld = pair<LD, LD>;


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

    int N;
    cin >> N;

    map<string, int> items;
    while (N--)
    {
        string item;
        cin >> item;

        ++items[item];
    }

    cout << items.size();
}


Measured memory_bytes: 19200
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    int n;
    cin >> n;

    int odd = 0;

    rep(i, n){
        int a;
        cin >> a;
        
        if(a%2) ++odd;
    }

    if(odd%2) puts("NO");
    else puts("YES");

    return 0;
}

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

int main()
{
  int x, count = 0, pos = 0;
  cin >> x;

  for (int i = 0;; i++)
  {
    if (pos >= x)
    {
      cout << i << endl;
      return 0;
    }
    pos += i + 1;
  }
}


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N, M, X;
    cin >> N >> M >> X;
    int a[110];
    REP(i,M) cin >> a[i];
    int costx = 0;
    int cost0 = 0;
    for(int x = X; x < N; ++x){
        REP(i,M){
            if(x == a[i]) costx++;
        }
    }
    REP(x,X){
        REP(i,M){
            if(x == a[i]) cost0 ++;
        }
    }
    cout << min(costx,cost0) << endl;
}

Measured memory_bytes: 256
n = int(input())

MOD = 10**9+7
# ans = (10**n-9**n) + (10**n-9**n) - (10**n-8**n)
ans = pow(10,n,MOD) -2 * pow(9,n,MOD) +  pow(8,n,MOD)
ans %= MOD
print(ans)

Measured memory_bytes: 9144
#include <iostream>
int main(){
	int list[30];
	for (int i = 0; i < 30; i++) {
		list[i] = i + 1;
	}
	int submit[28];
	for (int i = 0; i < 28; i++) {
		std::cin >> submit[i];
		list[submit[i]-1] = 0;
	}

	for (int i = 0; i < 30; i++) {
		if (list[i] != 0) {
			std::cout << list[i] << std::endl;
		}
	}
}

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

int main() {
    long a, b, c;
    cin >> a >> b >> c;
    long x1, x2, x3;
    if (a >= b) {
        if (a >= c) {
            x1 = a;
            x2 = b;
            x3 = c;
        }
        else {
            x1 = c;
            x2 = a;
            x3 = b;
        }
    }
    else {
        if (b >= c) {
            x1 = b;
            x2 = c;
            x3 = a;
        }
        else {
            x1 = c;
            x2 = a;
            x3 = b;
        }
    }

    cout << x1 * 10 + x2 + x3 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=16,N1=(1<<15),inf=1e9+100;
int dp[N][N1],a[N*N],b[N*N],c[N*N],val[N1];
vi v[N];
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n,m;
  cin>>n>>m;
  rep(i,1,m+1)
    {
      cin>>a[i]>>b[i]>>c[i];
      v[a[i]].pb(i); v[b[i]].pb(i);
    }
  rep(i,0,(1<<n))
    {
      int cost=0;
      rep(j,1,m+1)
	{
	  int x=a[j],y=b[j];
	  if(i&(1<<(x-1)) && i&(1<<(y-1)))
	    cost+=c[j];
	}
      val[i]=cost;
    }
  rep(i,0,N1) rep(j,0,N) dp[j][i]=inf;
  dp[1][1]=0;
  rep(i,0,(1<<n))
    {
      rep(j,1,n+1)
	{
	  if(!(i&(1<<(j-1)))) continue;
	  for(int idx:v[j])//connect this subset to v1 only through j
	    {
	      int v1=(a[idx]^b[idx]^j);
	      if(!(i&(1<<(v1-1))))
		{
		  int mask1=i^(1<<(j-1)),mask2=(1<<(v1-1));
		  dp[v1][i|mask2]=min(dp[v1][i|mask2],dp[j][i]+val[mask1|mask2]-val[mask1]-val[mask2]);
		}
	    }
	}
      int compmask=(1<<n)-1-i;
      for(int mask=compmask;mask;mask=(mask-1)&compmask)
	{
	  rep(j,1,n+1)
	    {
	      if(!(i&(1<<(j-1)))) continue;
	      int mask1=i^(1<<(j-1)),mask2=mask;
	      dp[j][i|mask]=min(dp[j][i|mask],dp[j][i]+val[mask1|mask2]-val[mask1]-val[mask2]);
	    }
	}
    }
  cout<<dp[n][(1<<n)-1]<<endl;
  return 0 ;
}


Measured memory_bytes: 2432