akhauriyash/Code-Regression huggingface dataset:
# include <bits/stdc++.h>

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

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 2e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n;
struct seg {
	ll id, l, r;
	bool operator < (const seg &b) const {
		if (id == b.id) return mp(l, r) < mp(b.l, b.r);
		return id < b.id;
	}
} a[N];


int main () {
	SpeedForce;
	ll x, d;
	cin >> n >> x >> d;
	if (d == 0) {
		if (x == 0) {
			cout << "1\n";
			exit(0);
		}

		cout << n + 1 << '\n';
		exit(0);
	}

	if (d < 0) {
		x *= -1;
		d *= -1;
	}

	// i is k
	for (int i = 0; i <= n; i ++) {
		// k * x + I * d
		// I is sums of id's

		ll lg = i * (ll)(i - 1) / 2;
		ll rg = n * (ll)i - i * (ll)(i + 1) / 2ll;
		lg += i * x / d;
		rg += i * x / d;
			
		// equal vals of k * x % d we compute together
		ll val = (((i * (ll)x) % d) + d) % d;
		a[i] = {val, lg, rg};	
	//	cout << val << ' ' << lg << ' ' << rg << '\n';
	}

	sort(a, a + n + 1);

	ll ans = 0;
	//exit(0);
	for (int i = 0, j = 0; i <= n; i = j) {
		ll lg = a[i].l;
		ll rg = a[i].r;
		while(j <= n && a[i].id == a[j].id) {
			if (rg >= a[j].l) {
				rg = max(rg, a[j].r);
			} else {
				ans += rg - lg + 1;
		//		cout << lg << ' ' << rg << '\n';
				tie(lg, rg) = mp(a[j].l, a[j].r);
			}

			++j; 
		}
		//cout << lg << ' ' << rg << '\n';
		ans += rg - lg + 1;
	}

	cout << ans << '\n';

   	return Accepted;
}

// B...a

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

int main(){
    int n, i, j, k;
    scanf("%d",&n);
    int a[n+5], b[n+5], c[n+5];
    for(i=1;i<=n;i++){
        scanf("%d %d %d",&a[i], &b[i], &c[i]);
    }
    int dp[n+5][3];
    memset(dp, 0, sizeof(dp));
    for(i=1;i<=n;i++){
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
    }
    int ans  = 0;
    ans = max(dp[n][0], dp[n][1]);
    ans = max(ans, dp[n][2]);
    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 2560
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

void testcase() {
    int a, b;  cin >> a >> b;

    cout << a * b ;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3640
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N = getN()
A = getList()
prime_list = defaultdict(int)

def prime_factorize(n):
    divisors = []
    # 27(2 * 2 * 7)の7を出すためにtemp使う
    temp = n
    for i in range(2, int(math.sqrt(n)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                # 素因数を見つけるたびにtempを割っていく
                temp //= i
            divisors.append([i, cnt])
    if temp != 1:
        divisors.append([temp, 1])
    if divisors == []:
        divisors.append([n, 1])

    return divisors

for i in range(N):
    prime = prime_factorize(A[i])
    for j in prime:
        prime_list[j[0]] = max(prime_list[j[0]], j[1])

num = 1
for key, value in prime_list.items():
    num *= key ** value
    num %= mod

# 1/A[i]のmod
lim = 10 ** 6 + 1
fact = [1, 1]
inv = [0, 1]

for i in range(2, lim + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)

ans = 0
for i in A:
    opt = (num * inv[i]) % mod
    ans += opt
    ans %= mod
print(ans % mod)

Measured memory_bytes: 222480
#include<stdio.h>
#include<fstream>
#include<algorithm>
using namespace std;
struct jiedian
{
 int fu,left,right,shengdu;
}a[2000005];
const int null=-1;
void res(int u,int p)
{
    a[u].shengdu=p;
    if(a[u].right!=null) res(a[u].right,p);
    if(a[u].left!=null) res(a[u].left,p+1);
}

int main()
{

    int n;int p;int k;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        a[i].fu=a[i].left=a[i].right=null;
    }

    for(int i=0;i<n;i++)
    {
        int node,du;
        scanf("%d%d",&node,&du);
        for(int j=0;j<du;j++)
        {
            scanf("%d",&k);
            if(j==0)  a[node].left=k;
            else
            a[p].right=k;
             p=k;
             a[k].fu=node;
        }
    }
    /*for(int i=0;i<n;i++)
    {
        printf("%d %d %d\n",a[i].fu,a[i].left,a[i].right);
    }*/
    int hd;
    for(int i=0;i<n;i++)
    {
        if(a[i].fu==null) hd=i;
    }
    res(hd,0);
    for(int i=0;i<n;i++)
    {
       // printf("node %d: parent = %d, depth = %d, ",i,a[i].fu,a[i].shengdu);
          printf("node %d: ",i);
          printf("parent = %d, ",a[i].fu);
          printf("depth = %d, ",a[i].shengdu);
            if(a[i].fu==null) printf("root, ");
            else if(a[i].left==null) printf("leaf, ");
            else printf("internal node, ");
            printf("[");
           //printf("%d ",a[i].left);
       for(int j=0,c=a[i].left;c!=null;j++,c=a[c].right)
        {
        if(j) printf(", ");
        printf("%d",c);
        }
           printf("]\n");


    }
return 0;
}

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

int main() {
	int N, dir = 0;
	string S;
	cin >> N;
	cin >> S;
	
	
	//Parte 1
	for(int i=0; i<N; i++) {
		
		if(S[i] == ')') {
		
			if(dir)
				dir--;
			else
				cout << '(';
		}else{
			dir++;
		}
		
	}
	
	
	
	cout << S;
	dir = 0;
	
	
	//Parte 2
	for(int i = N-1; i >= 0; --i) {
		
		if(S[i] == '(') {
			
			if(dir)
				dir--;
			else
				cout << ')';
				
		}else{
			dir++;
		}
		
	}
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {


    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        StringTokenizer st=new StringTokenizer(br.readLine());
        int[] table=new int[100001];
        int temp;
        int count=0;
        int length=0;
        for(int i=0;i<n;i++){
            temp=Integer.parseInt(st.nextToken());
            if(table[temp]==1){
                count++;
                table[temp]++;
            }else if(table[temp]==2){
                count--;
                table[temp]=1;
            }else{
                length++;
                table[temp]++;
            }
        }System.out.println((count%2==0) ? length:length-1);
    }
    
}


Measured memory_bytes: 21660
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define INF 10000000000

ll a, b, c, n, m, x, y, z, w, h, ans = 0, cnt = 0, mx = 0, mn = INF;
string s;

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

    cin >> s;
    if(s[0] == '2'){
        ans++;
    }
    if(s[1] == '2'){
        ans++;
    }
    if(s[2] == '2'){
        ans++;
    }
    if(s[3] == '2'){
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
/*#include<iostream>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<climits>*/
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define rep1(i,a,b) for(int i=a;i<=(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
#define per1(i,a,b) for(int i=a;i>=(b);--i)
#define LL long long
#define inf 0x7f7f7f7f
#define N 35
using namespace std;
struct Node
{
	int key;
	Node *prev,*next;
};

Node *nil;

void init()
{
	nil=(Node *)malloc(sizeof(Node));
	nil->next=nil;
	nil->prev=nil;
}

void insert(int key)
{
	Node *x=(Node *)malloc(sizeof(Node));
	x->key=key;
	
	x->next=nil->next;
	nil->next->prev=x;
	nil->next=x;
	x->prev=nil;
}

Node* listSearch(int key)
{
	Node *cur=nil->next;
	while(cur!=nil && cur->key!=key)
	{
		cur=cur->next;
	}
	return cur;
}

void deleteNode(Node *t)
{
	if(t==nil) return ;
	t->prev->next=t->next;
	t->next->prev=t->prev;
	free(t);
}

void deleteFirst()
{
	deleteNode(nil->next);	
}

void deleteLast()
{
	deleteNode(nil->prev);
}

void deleteKey(int key)
{
	deleteNode(listSearch(key));
}

void printList()
{
	Node *cur=nil->next;
	int isf=0;
	while(cur!=nil)
	{
		if(isf++>0) printf(" ");
		printf("%d",cur->key);
		cur=cur->next;
	}
	printf("\n");
}
int main()
{
	int key,n,i,size=0;
	char com[20];
	scanf("%d",&n);
	init();
	while(n--)
	{
		scanf("%s %d",com,&key);
		if(com[0]=='i')
		{
			insert(key); size++;
		}
		else if(com[0]=='d')
		{
			if(strlen(com)>6)
			{
				if(com[6]=='F') deleteFirst();
				else if(com[6]=='L') deleteLast();
			}
			else
			{
				deleteKey(key);
			}
			size--;
		}
	}
	printList();
}



Measured memory_bytes: 34372
import math
N = int(input())
A = sorted([int(i) for i in input().split()])
mod = 10**9 + 7

if N % 2 == 0:
    if A == [i//2*2+1 for i in range(N)]:
        print(2**(N//2) % mod)
    else:
        print(0)
else:
    if A == [math.ceil(i/2)*2 for i in range(N)]:
        print(2**(N//2) % mod)
    else:
        print(0)


Measured memory_bytes: 13812
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
 public class Main
 {
 	public static void main(String[]args)
 	{
 		Scanner sc=new Scanner (System.in);
 		//int t=sc.nextInt();
 		String str=sc.next();
 		int n=str.length();
 		int i,temp=0;
 		for(i=0;i<n;i++)
 		{
 			
 			String s=str.substring(i,i+1);
 			int x=Integer.parseInt(s);
 			temp=temp+x;
 		}
 		if(temp%9==0)System.out.println("Yes");
 		else System.out.println("No");
 	}
 }

Measured memory_bytes: 49760
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()
#define chmax(x,y) x=max(x,y)




int main(){
    int n,k; cin>>n>>k;
    vector<int> p(n);
    rep(i,n) cin>>p[i];
    int r=0, l=1e9+5;
    while(l-r>1){
        int m=(r+l)/2;
        int kari=0;
        rep(i,n){
            kari+=(p[i]+m-1)/m-1;
        }
        if(kari<=k){
            l=m;
        }else{
            r=m;
        }
    }
    cout<<l<<endl;
    return 0;
}

Measured memory_bytes: 4004
#include <iostream>
using namespace std;
int main(){
    int n, x, c;
    while(true){
		cin >> n >> x;
		if ((n | x) == 0)
			break;
        c = 0;
		for(int i=1;i<n-1;++i){
			for(int j=2;j<n;++j){
				for(int k=3;k<n+1;++k){
					if(i<j&&j<k&&i+j+k==x)
						c++;
				}
			}
		}
		cout<<c<<endl;
    }
    return 0;
}



Measured memory_bytes: 3072
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <iostream>
using namespace std;

typedef long long int LL;
const LL INF=1000000000000000ll;
const int maxn=100000*64;
struct ACM
{
    struct Node
    {
        LL val;
        int lson,rson;
    }seg[maxn];
    int sz;
    int newnode()
    {
        sz++;
        seg[sz].val=0;
        seg[sz].rson=-1;
        seg[sz].lson=-1;
        return sz;
    }
    void init()
    {
        sz=-1;
    }
    void update(int &root,LL l,LL r,LL val)
    {
        if(root==-1) root=newnode();
        seg[root].val++;
        if(l==r) return ;
        LL mid=(l+r)>>1;
        if(val<=mid) update(seg[root].lson,l,mid,val);
        else update(seg[root].rson,mid+1,r,val);
    }
    LL query(int root,LL l,LL r,LL ql,LL qr)
    {
        if(root==-1) return 0;
        if(l==ql&&r==qr) return seg[root].val;
        LL mid=(l+r)>>1;
        if(qr<=mid) return query(seg[root].lson,l,mid,ql,qr);
        else if(ql>mid) return query(seg[root].rson,mid+1,r,ql,qr);
        else return query(seg[root].lson,l,mid,ql,mid)+query(seg[root].rson,mid+1,r,mid+1,qr);
    }
    /**
    void debug(int i)
    {
        if(i==-1) return ;
        printf("node=%d val=%lld lson=%d rson=%d\n",i,seg[i].val,seg[i].lson,seg[i].rson);
        debug(seg[i].lson),debug(seg[i].rson);
    }
    */
}AC;

int main()
{
    int n,k,root=-1;
    scanf("%d%d",&n,&k);
    LL sum=0,ans=0;
    AC.init();
    for(int i=1; i<=n; i++)
    {
        int num;
        scanf("%d",&num);
		num-=k;
        AC.update(root,-INF,INF,sum);
        sum+=num;
        ans+=AC.query(root,-INF,INF,-INF,sum);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 94464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int mp[101][101];

struct xyh
{
	int x,y,h;
};

bool cmp(xyh a,xyh b)
{
	return a.h>b.h;
}

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

	vector<xyh> x(n);
	for(int i =0;i<n;i++)
	{
		cin >> x[i].x >> x[i].y >> x[i].h;
	}
	sort(x.begin(),x.end(),cmp);
	for(int i =0;i<=100;i++)
	{
		for(int j = 0;j<=100;j++)
		{
			for(int ii = 0; ii <= 100;ii++)
			{
				for (int jj = 0; jj <= 100; jj++)
				{
					mp[ii][jj] = -abs(i-ii)-abs(j-jj);
				}				
			}	
			int H = 0;
			bool mujun = false;
			for(int i =0;i<n;i++)
			{
				if(H==0)
				{
					H = x[i].h - mp[x[i].x][x[i].y];
				}
				else
				{
					if(x[i].h==0)
					{
						if(mp[x[i].x][x[i].y]+H>0)mujun = true;
					}
					else 
					{
					if(mp[x[i].x][x[i].y]+H!=x[i].h)mujun=true;
					}
				}
			}
			if(mujun==false)
			{
				cout<<i<<' '<<j<<' '<<H<<endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		
		int S [] = new int [N];
		for (int i=0; i<N; i++)
			S[i]=sc.nextInt();
		
		
		int temp =0;
		int ans = 1000000000;
		
		if (K==1){
			for (int i=0; i<N; i++){
				temp = S[i];
				ans = Math.min(Math.abs(temp), ans);
			}
			System.out.println(ans);
		}
		
		else if (N-K!=0) {
			for (int i=0; i<=N-K; i++){
				int min = S[i];
				int max = S[i+K-1];
				
				if (min<0 && max>0)
					temp = Math.min(2*(-min)+max, (-min)+2*max);
				
				else
					temp = Math.max(Math.abs(min), Math.abs(max));
				
				ans = Math.min(ans, temp);
			}
			System.out.println(ans);
		}
		
		else {
			int min = S[0];
			int max = S[N-1];
			if (min<0 && max>0)
				System.out.println(Math.min(2*(-min)+max, (-min)+2*max));
			
			else
				System.out.println(Math.max(Math.abs(min), Math.abs(max)));
		}
		sc.close();
		
		
	}

}


Measured memory_bytes: 49724
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb push_back;
#define sp " ";
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    int n;
    vi h;
    int ans=0,now=0;
    cin>>n;
    rep(i,n){
        int hi;
        cin>>hi;
        h.push_back(hi);
    }
    rep(i,n-1){
        if(h.at(i)>=h.at(i+1)){
            now+=1;
        }
        else{
            ans=max(now,ans);
            now=0;
        }
    }
    ans=max(now,ans);
    cout<<ans;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#include <vector>
using namespace std;
using Graph = vector<vector<bool>>;

typedef long long ll;

const ll MAX = 110000;
const ll INF = 1LL << 60;


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline long long factorial(T N) {
    int ans = 1;
    for (int i = 1; i <= N; ++i) {
        ans *= i;
    }
    return ans;
}


int main() {
    string S, T; cin >> S >> T;
    int count = 0;
    for (int i =0; i < 3; ++i) {
        if (S[i] == T[i]) {
            ++count;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3504
#include <iostream>

using namespace std;

int main(){
	int width, height, map[102][102], diff=1;
	cin >> width >> height;
	for (int i = 0; i <= width + 1; i++){
		map[height+1][i] = map[0][i] = -1;
	}
	for (int i = 0; i <= height + 1; i++){
		map[i][width+1] = map[i][0] = -1;
	}
	for (int i = 1; i <= height; i++){
		for (int j = 1; j <= width; j++){
			cin >> map[i][j];
		}
	}
	while (diff){
		diff = 0;
		for (int i = 1; i <= height; i++){
			for (int j = 1; j <= width; j++){
				if (!map[i][j]){
					if (i % 2){
						if (map[i - 1][j] == -1){
							map[i][j] = -1;
							diff++;
							continue;
						}
						else if (map[i - 1][j + 1] == -1){
							map[i][j] = -1;
							diff++;
							continue;
						}
						else if (map[i + 1][j] == -1){
							map[i][j] = -1;
							diff++;
							continue;
						}
						else if (map[i + 1][j + 1] == -1){
							map[i][j] = -1;
							diff++;
							continue;
						}
					}
					else{
						if (map[i - 1][j - 1] == -1){
							map[i][j] = -1;
							diff++;
							continue;
						}
						else if (map[i - 1][j] == -1){
							map[i][j] = -1;
							diff++;
							continue;
						}
						else if (map[i + 1][j - 1] == -1){
							map[i][j] = -1;
							diff++;
							continue;
						}
						else if (map[i + 1][j] == -1){
							map[i][j] = -1;
							diff++;
							continue;
						}
					}
					if (map[i][j - 1] == -1){
						map[i][j] = -1;
						diff++;
						continue;
					}
					else if (map[i][j + 1] == -1){
						map[i][j] = -1;
						diff++;
						continue;
					}
				}
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= height; i++){
		for (int j = 1; j <= width; j++){
			if (map[i][j] == 1){
				if (i % 2){
					if (map[i - 1][j] == -1){
						ans++;
					}
					if (map[i - 1][j + 1] == -1){
						ans++;
					}
					if (map[i + 1][j] == -1){
						ans++;
					}
					if (map[i + 1][j + 1] == -1){
						ans++;
					}
				}
				else{
					if (map[i - 1][j - 1] == -1){
						ans++;
					}
					if (map[i - 1][j] == -1){
						ans++;
					}
					if (map[i + 1][j - 1] == -1){
						ans++;
					}
					if (map[i + 1][j] == -1){
						ans++;
					}
				}
				if (map[i][j - 1] == -1){
					ans++;
				}
				if (map[i][j + 1] == -1){
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL<<60;//仮想的な無限大の値

int main() {
   int n,k;
   while(cin >> n >> k){
       if(n==0) break;
       vector<int> a(n);//普通の数字
       for(int i=0;i<n;i++){
           cin >> a[i];
       }
       vector<int> s(n+1,0);//n+1個の配列を全て0で初期化
       for(int j=0;j<n;j++){
           s[j+1] = s[j] + a[j];
       }
       int ans = -INF;
       for(int p=1;p<n-k+1;p++){
           int max1 = s[p+k] - s[p];
           ans = max(max1,ans); 
       }
       cout << ans << endl;
   }
}


Measured memory_bytes: 3532
s = raw_input()
Q = input()
for q in range(Q):
    str_order = raw_input().split()
    if str_order[0] == 'print':
        print s[int(str_order[1]):int(str_order[2])+1]
    elif str_order[0] == 'reverse':
        start = s[:int(str_order[1])]
        mid = s[int(str_order[1]):int(str_order[2])+1]
        mid = mid[::-1]
        end = s[int(str_order[2])+1:]
        s = start+mid+end
    elif str_order[0] == 'replace':
        start = s[:int(str_order[1])]
        mid = str_order[3]
        end = s[int(str_order[2])+1:]
        s = start+mid+end

Measured memory_bytes: 6464
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 300000

int n, a, b;
int r[MAXN];

int input() {
	if (scanf("%d %d %d", &n, &a, &b) < 0) return 0;
	return 1;
}

void init() {
}

long solve() {
	if (a+b-1>n || a<=0 || b<=0 || long(a)*b<n) return 0;
	int t=n, s=1, p=0;
	while (p<n) {
		if (a<0 && b<=0) return 0;
		int q = p;
		for (int i=0; i<a && p<n; i++) {
			r[p++] = t--;
		}
		reverse(r+q, r+p);
		a--;

		b--;
		q = p;
		for (int i=0; i<b && p<n; i++) {
			r[p++] = s++;
		}
		reverse(r+q, r+p);
	}
	return 1;
}

void output(long ans) {
	if (!ans) {
		printf("-1\n");
		return;
	}
	for (int i=0; i<n; i++) printf("%d ", r[i]);
	printf("\n");
}

void cleanup() {
}

int main() {
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    out(a * b);
    return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    unsigned int A1,A2,A3;

    cin >> A1 >> A2 >> A3;
    cout << max({A1,A2,A3})-min({A1,A2,A3}) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <map>
using namespace std;
typedef long long li;
const li MAX = 1000001;
li inf = 4294967295000, mod = 1000000007;
li n, m, dp[401][401], l[MAX], pref[MAX];
int main() {
	ios::sync_with_stdio();
	cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> l[i];
		pref[i + 1] = pref[i] + l[i];
	}
	for (int i = 0; i < 401; i++) {
		for (int j = 0; j < 401; j++) dp[i][j] = inf;
	}
	for (int i = 1; i <= n; i++) {
		dp[1][i] = 0;
	}
	for (int i = 2; i <= n; i++) {//start
		for (int j = 1; i + j - 1 <= n; j++) {// stop
			for (int k = j + 1; k <= i + j - 1; k++) {//where
				dp[i][j] = min(dp[i][j],  dp[k - j][j] +  dp[i + j - k][k] + pref[i + j - 1] - pref[j - 1]);
			}
		}
	}
	cout << dp[n][1];
//	system("pause");
	return 0;
}

Measured memory_bytes: 4864
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	std::string s;
	std::cin >> s;

	int l = 0, r = s.size()-1;
	ll ans = 0;
	while(l<r){
		if(s[l]==s[r]){
			l++;
			r--;
		}else if(s[l]=='x'){
			ans++;
			l++;
		}else if(s[r]=='x'){
			ans++;
			r--;
		}else{
			puts("-1");
			return 0;
		}
	}
	printf("%ld\n", ans);
	return 0;
}



Measured memory_bytes: 512
# -*- coding: utf-8 -*-

import collections

n = int(input())

cursor = 1
deque = collections.deque([(cursor, 0)])
visited = {cursor}

min_path = 10e10
while len(deque) > 0:
    cursor, min_path = deque.popleft()
    visited.add(cursor)
    if cursor == 0:
        break

    pone, mten = (cursor + 1) % n, (cursor * 10) % n
    if not pone in visited:
        deque.append((pone, min_path + 1))
    if not mten in visited:
        deque.appendleft((mten, min_path))

print(min_path + 1)


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll n, c=1, a, pa=-1;
  char s='=';
  cin >> n;
  forll(i, 0, n){
	cin >> a;
	if (s == '='){
	  if (pa == -1){
		pa = a;
		continue;
	  }
	  if (a - pa > 0)
		s = '+';
	  else if (a-pa < 0)
		s = '-';
	  pa = a;
	}else{
	  if ((a - pa >= 0 && s == '+') || (a-pa <= 0 && s == '-'))
		pa = a;
	  else{
		s = '=';
		c++;
		pa = a;
	  }
	}
  }
  cout << c << endl;
}



Measured memory_bytes: 256
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__


void solve(void){
  
  int N, D;
  cin >> N >> D;
  
  vector<vector<int>> X(N, vector<int>(D, 0));
  
  REP(i, N){
    REP(j, D){
      cin >> X[i][j];
    }
  }
  
  int tmp=0;
  REP(i, N){
    REP2(j, i+1, N){
      //if(i==j)continue;
      int y=0;
      REP(k, D){
        y += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
      }
      REP(k, 150){
        if(y == k*k){tmp++;}
      }
    }
  }
  cout << tmp << endl;
  
  
  return;
   
}

#define TESTCASES 1

int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    int a, b, c, d;

    cin >> a >> b >> c >> d;

    if (a * b > c * d) {
        cout << a * b << endl;
    }
    else {
        cout << c * d << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using ll = long long;
using namespace std;

constexpr int M = 1000000000 + 7;

void add(int & a, int b) {
    a += b;
    if(a >= M) a -= M;
}

int mpow(int a, int b) {
    int res = 1;
    do {
        if(b & 1) res = 1ll * res * a % M;
        a = 1ll * a * a % M;
    } while(b >>= 1);
    return res;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n + 2);
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    int ans = 0;

    for(int i = 1; i <= n; ++i) {
        vector<int> hi(n + 2, 0), lo(n + 2, 0);
        for(int j = 1; j <= n; ++j) {
            hi[j] = hi[j - 1];
            lo[j] = lo[j - 1];
            hi[j] += a[j] > a[i];
            lo[j] += a[j] < a[i];
        }
        int tmp = ans;
        add(ans, 1ll * k * hi[i] % M);
        add(ans, 1ll * k * (lo[n] - lo[i]) % M);
        add(ans, 1ll * k * (k - 1) / 2 % M * hi[n] % M);
        add(ans, 1ll * k * (k - 1) / 2 % M * lo[n] % M);
    }
    cout << 1ll * ans * mpow(2, M - 2) % M << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
int a, b, c;
    int tmp;
    scanf("%d %d %d", &a, &b, &c);
    if(a>b){
        tmp=a;
        a=b;
        b=tmp;
    }
    if(b>c){
        tmp=b;
        b=c;
        c=tmp;
    }
    if(a>b){
        tmp=a;
        a=b;
        b=tmp;
    }
    printf("%d %d %d\n", a, b, c);
    return 0;
}


Measured memory_bytes: 2072
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	map<int64_t, int> value_map;
	for (int n = 0; n < N; ++n)
	{
		int64_t A;
		int B;
		cin >> A >> B;
		if (value_map.find(A) == value_map.end())
		{
			value_map.emplace(A, B);
		}
		else
		{
			value_map[A] += B;
		}
	}
	int64_t total_value = 0;
	int rest = M;
	for (auto it = value_map.begin(); it != value_map.end(); ++it)
	{
		if (it->second < rest)
		{
			rest -= it->second;
			total_value += it->first * it->second;
		}
		else
		{
			total_value += it->first * rest;
			break;
		}
	}
	cout << total_value;
}

Measured memory_bytes: 6528
import java.util.*;
import java.io.*;
import java.math.*;


import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;


public class Main{ 


    static long mod=1000000007;
    //  static int dx[]={1,-1,0,0};
    //  static int dy[]={0,0,1,-1};
    // static int dx[]={1,-1,0,0,1,1,-1,-1};
    // static int dy[]={0,0,1,-1,1,-1,1,-1}; 

public  static void main(String[] args)   throws Exception, IOException{

    
    Reader sc = new Reader(System.in);
    PrintWriter out=new PrintWriter(System.out);

//  int n=sc.nextInt();  
  // int n=sc.nextInt(), k=sc.nextInt();  
  // int s=sc.nextInt(), t=sc.nextInt(); 
    // int n = sc.nextInt();
    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    long d[] = {a,b,c},ans=100;
    for( int i=0; i<3; i++ ){
        long x=d[i],y=d[(i+1)%3],z=d[(i+2)%3];
        long e[]= {1,0,0}, v=2;
        for( int t=0; t<40; t++, v*=2 ){
            long w=e[0]*x+e[1]*y+e[2]*z;
            long tmp[]= {e[0],e[1],e[2]};

          //  db(x,y,z,w,e,v);
            if(w % v != 0){ans=min(ans, t); break;}
            e[0] = tmp[1]+tmp[2];
            e[1] = tmp[0]+tmp[1];
            e[2] = tmp[0]+tmp[1];
        }
    }
    //ans;
    if(ans==100)ans=-1;

    out.println(ans);
    out.flush();
}

static void db(Object... os){

    System.err.println(Arrays.deepToString(os));

}

static boolean validpos(int x,int y,int r, int c){
    
    return x<r && 0<=x && y<c && 0<=y;
    
}
 
static boolean bit(long x,int k){
    // weather k-th bit (from right) be one or zero
    return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
}

}

class P implements Comparable<P>{
    int x,y;
    P(int x, int y) {
        this.x=x;
        this.y=y;
    } 
      
    public int compareTo(P p){
        return x - p.x;
    } 
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}



Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string a,b,c;
    cin>>a>>b>>c;
    char x='a';
    while(1){
        if(x=='a'){
            x=a[0];
            if(a.empty()){x='A'; break;}
            a.erase(0,1);
        }
        if(x=='b'){
            x=b[0];
            if(b.empty()){x='B'; break;}
            b.erase(0,1);
        }
        if(x=='c'){
            x=c[0];
            if(c.empty()){x='C'; break;}
            c.erase(0,1);
        }
    }
    cout<<x<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from bisect import bisect_right

N = int(input())

columns = []


for _ in range(N):
    current = -int(input())
    index = bisect_right(columns, current)
    if len(columns) <= index:
        columns.append(current)
    else:
        columns[index] = current

print(len(columns))


Measured memory_bytes: 7072
#include "atcoder/lazysegtree"
#include "atcoder/modint"
#include <cstdio>

using namespace std;
using namespace atcoder;

using S = long long;
using F = long long;

const S INF = 8e18;
const F ID = 8e18;

S op(S a, S b) { return std::max(a, b); }
S e() { return 0; }
S mapping(F f, S x) { return (f == ID ? x : f); }
F composition(F f, F g) { return (f == ID ? g : f); }
F id() { return ID; }

int main() {
	int N, K;
	cin >> N >> K;
	std::vector<S> v(3 * 300000, (long long)0);
	atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);
	for (int i = 0; i < N; ++i) {
		int num;
		cin >> num;
		int r = max(0, num - K);
		int l = num + K;
		int x = seg.prod(r, l + 1);
		x++;
		seg.apply(num,x);//RE
	}
	cout << seg.all_prod() <<endl;
}


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

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

char solve(string data[3]){
	rep(i,3){
		if( data[i][0]==data[i][1] && data[i][1]==data[i][2] && data[i][0]!='+' ){
			return data[i][0];
		}
	}
	rep(i,3){
		if( data[0][i]==data[1][i] && data[1][i]==data[2][i] && data[0][i]!='+' ){
			return data[0][i];
		}
	}
	if( data[0][0]==data[1][1] && data[1][1]==data[2][2] && data[0][0]!='+' )return data[1][1];
	if( data[0][2]==data[1][1] && data[1][1]==data[2][0] && data[1][1]!='+' )return data[1][1];


	return '+';
}


int main(){
	string s;
	while(cin>>s){
		string data[3];
		if(s=="0")break;
		data[0]=s;
		rep(i,2)cin>>data[i+1];

		char res = solve(data);
		if(res=='+')cout<<"NA"<<endl;
		else cout<<res<<endl;
	}
}

Measured memory_bytes: 1188
use std::env;
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let A = read::<i32>();
    let B = read::<i32>();
    let C = read::<i32>();
    let D = read::<i32>();
    let mut sum = 0;
    if A < B {
        sum += A;
    } else {
        sum += B;
    }
    if C < D {
        sum += C;
    } else {
        sum += D;
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstring>
#include <cmath>
#include<stdio.h>
using namespace std;
int main(){
  int x, y;
  cin >> x >> y;
  char arr[x][y];
  for(int i=0; i<x; i++){
    for(int j=0; j<y; j++){
      cin >> arr[i][j];
    }
  }
  int index[x];
  int in1=0;
  int in2=0;
  int index2[y];
  for(int i=0; i<x; i++){
    int count1=0;
    for(int j=0; j<y; j++){
      if(arr[i][j]=='.') count1++;
    }
    if(count1==y) index[in1++]=i;
  }
  for(int j=0; j<y; j++){
    int count1=0;
    for(int i=0; i<x; i++){
      if(arr[i][j]=='.') count1++;
    }
    if(count1==x) index2[in2++]=j;
  }
  for(int i=0; i<x; i++){
    bool d3=false;
    for(int j=0; j<y; j++){
      bool de=true;
      bool de1=true;
      for(int x=0; x<in1; x++){
        if(index[x]==i){
          de=false;
          break;
        }
      }
      for(int x=0; x<in2; x++){
        if(index2[x]==j){
          de=false;
          break;
        }
      }
      
      if(de && de1){
        cout << arr[i][j];
        d3=true;
      }
    }
    if(d3)cout << "\n";
  }
  

}

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

int main(){
    int n;
    cin>>n;
    int mn=INT_MAX,mx=-INT_MAX;
    long long sum=0;
    for(int i=0; i<n; ++i){
        int a; cin>>a;
        mn=min(mn,a);
        mx=max(mx,a);
        sum+=a;
    }
    printf("%d %d %ld\n",mn,mx,sum);
    return 0;
}


Measured memory_bytes: 3232
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<tuple>
#include<map>
#include<set>
#include<algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

signed main(){
	int n, count = 0;
	cin >> n;
	rep(n){
		int tmp;
		cin >> tmp;
		if(tmp % 2 == 1){
			count++;
		}
	}
	if(count % 2 == 0){
		cout << "YES";
	}else{
		cout << "NO";
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <complex>
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
using namespace std;
typedef long long ll;

int main(){
    int n, ans = 0;
    cin >> n;
    vector<int> l(n+1);
    rep(i,n) cin >> l[i];
    l[n] = 1001;
    sort(l.begin(), l.end());

    for(int i = 0; i < n; ++i){
        for(int j = i+1; j < n; ++j){
            int left = j, right = n;
            while(right - left > 1){
                int mid = (left+right)/2;
                if(l[mid] < l[i] + l[j]) left = mid;
                else right = mid;
            }
            ans += left - j;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int n;cin>>n;

  cout<<modpow(n,3)<<endl;

 

  return 0;
}

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

using namespace std;
int main() {
    int s,ans=0;
    cin>>s;
    if(s%2==0)ans=s/2;
    else ans = (s+1)/2;
    printf("%.10f\n",(double)ans/s);
    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, ll> pcl;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    int x, n;
    int p[101];
    map<int,int> cnt;

    cin >> x >> n;
    for(int i = 0; i < n; i++) {
        cin >> p[i];
    }

    for(int i = 0; i < n; i++) {
        cnt[p[i]] = 1;
    }

    for(int i = 0; i <= 1000; i++) {
        if(cnt[x - i] == 0) {
            cout << x - i << endl;
            exit(0);
        } else if(cnt[x + i] == 0) {
            cout << x + i << endl;
            exit(0);
        }
    }

    cout << x << endl;

    return 0;
}


Measured memory_bytes: 3624
#include<cmath>
#include<cstdio>
#include<cstring>
#include<vector>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std;

const int N=1010;
int n,tot;
vector<int>V[N];

int main(){
	scanf("%d",&n); int k=sqrt(2*n)+1;
	if (k*(k-1)/2==n && 2*n%k==0){
		puts("Yes"); printf("%d\n",k);
		rep(i,1,k-1) rep(j,i+1,k) V[i].push_back(++tot),V[j].push_back(tot);
		rep(i,1,k){
			printf("%d ",2*n/k);
			rep(j,0,(int)V[i].size()-1) printf("%d ",V[i][j]);
			puts("");
		}
	}else puts("No");
	return 0;
}

Measured memory_bytes: 2304
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(writer, f, a...)
}

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

func main() {
	defer writer.Flush()
	n := sint64()
	ans := int64(0)
	for i := int64(1); i <= n; i++ {
		j := n / i
		ans += j * (j+1) * i / 2
	}
	printf("%d\n", ans)
}


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

int main() {
  int N; cin >> N;
  string S; cin >> S;
  string alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  for (int i = 0; i < S.size(); i++) {
    int idx = S.at(i) - 'A';
    idx = (idx + N) % 26;
    cout << alp.at(idx);
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n; cin >> n;
    vector<int> consnum;
    vector<int> v(n);
    cin >> v[0];
    int count = 1;
    REP(i,1,n){
        cin >> v[i];
        if(v[i-1]==v[i]){
            count++;
        }else{
            consnum.push_back(count);
            count = 1;
        }
    }
    consnum.push_back(count);

    int ans = 0;
    for(int val : consnum){
        if(val>=2){
            ans += val/2;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long

ll gcd(ll a, ll b) {
	if (b == 0)return a;

	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

int main() {
	ll a, b, c, d, ans = 0, x, y, xy;
	cin >> a >> b >> c >> d;
	ans = b - a + 1;
	x = b / c - (a - 1) / c;
	y = b / d - (a - 1) / d;
	xy = b / lcm(c, d) - (a - 1) / lcm(c, d);
	ans -= (x + y - xy);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256