akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define var auto
#define Max std::max
#define Min std::min

#ifdef _MSC_VER
#define getchar_unlocked getchar
#define putchar_unlocked putchar
#define fseek_unlocked fseek
#endif

inline void read(uint32_t& x)
{
	x = 0;
	int k;
	while (true)
	{
		k = getchar_unlocked();
		if (k < '0') break;
		x = x * 10 + k - '0';
	}
}

void writeline(uint32_t x) {
	int s = 0;
	char f[4];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	while (s--)
		putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}

int rowMax[2000];
int columnAccum[2000];
int main()
{
	uint32_t h, w;
	read(h);
	read(w);
	int max = 0;
	for (size_t i = 0; i < h; i++)
	{
		int currentChain = 0;
		for (size_t j = 0; j < w; j++)
		{
			if (getchar_unlocked() & 1)
			{
				max = Max(max, columnAccum[j] + rowMax[j]);
				for (size_t k = j - currentChain; k < j; k++)
					rowMax[k] = Max(rowMax[k], currentChain);
				currentChain = 0;
				rowMax[j] = 0;
				columnAccum[j] = 0;
			}
			else
			{
				currentChain++;
				columnAccum[j]++;
			}
		}
		for (size_t j = w - currentChain; j < w; j++)
			rowMax[j] = Max(rowMax[j], currentChain);
		getchar_unlocked();
	}
	for (size_t i = 0; i < w; i++)
		max = Max(max, columnAccum[i] + rowMax[i]);
	writeline(max - 1);
	return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, m, k = rm()
a = rl()
b = list(itertools.accumulate(rl()))
if a[0] > k:
    ans = 0
else:
    left = 0
    right = m
    while right - left > 1:
        j = (left + right) // 2
        if b[j] > k:
            right = j
        else:
            left = j
    ans = left + 1
t = 0
b0 = b[0]
for cnt, i in enumerate(a, 1):
    t += i
    if t > k:
        break
    if b0 > k-t:
        ans = max(ans, cnt)
        continue
    left = 0
    right = m
    while right - left > 1:
        j = (left + right) // 2
        if b[j] > k-t:
            right = j
        else:
            left = j
    ans = max(ans, cnt + left + 1)
print(ans)



















Measured memory_bytes: 59388
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n,w;
		n=sc.nextInt();
		w=sc.nextInt();
		int values[] = new int[w];
		for(int i = 0; i < w; i++){
			values[i] = i + 1;
		}

		for(int i= 0; i < n; i++){
			String str = sc.next();
			String ab[] = str.split(",");
			int a = Integer.parseInt(ab[0]) -1;
			int b = Integer.parseInt(ab[1]) -1;
			int temp;
			temp=values[a];
			values[a]=values[b];
			values[b]=temp;
		}
		for(int i=0;i<w;i++)
			System.out.println(values[i]);
		sc.close();
	}
}

Measured memory_bytes: 25924
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	int max = 0, max_i;

	for(int i = 0; i < N; i++){
		cin >> A.at(i);
		if(max < A.at(i)){
			max = A.at(i);
			max_i = i;
		}	
	}
	
	int max2 = 0;
	for(int i = 0; i < N; i++){
		if(i == max_i)
			continue;
		if(A.at(i) > max2)
			max2 = A.at(i);
	}
	
	for(int i = 0; i < N; i++){
		if(i == max_i)
			printf("%d\n",max2);
		else
			printf("%d\n",max);
	}
	
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
	int a[10];

	for(int i = 0; i < 10; i++)
	{
		cin >> a[i];
	}

	sort(a,a+10,greater<int>());

	for(int i = 0; i < 3; i++)
	{
		cout << a[i] << endl;
	}


	return 0;
}

Measured memory_bytes: 3064
#21:10
h,w = map(int,input().split())
raw = []
for x in range(h):
  raw.append(input())
xx = []
for x in range(h):
  now = []
  tmp = 0
  for y in range(w):
    if raw[x][y] == '.':
      tmp += 1
    else:
      now += [tmp] * tmp
      tmp = 0
      now.append(0)
  now += [tmp] * tmp
  xx.append(now)
yy = []
for y in range(w):
  now = []
  tmp = 0
  for x in range(h):
    if raw[x][y] == '.':
      tmp += 1
    else:
      now += [tmp] * tmp
      tmp = 0
      now.append(0)
  now += [tmp] * tmp
  yy.append(now)
'''
for x in range(h):
  print(xx[x])
for y in range(w):
  print(yy[y])
'''
maxi = 0
for x in range(h):
  for y in range(w):
    maxi = max(maxi,xx[x][y]+yy[y][x]-1)
print(maxi)

Measured memory_bytes: 126680
class node:
    def __init__(self, parent, left, right, depth):
        self.p = parent
        self.l = left
        self.r = right
        self.d = depth

def getDepth(u):
    depth = 0
    c = u
    while T[c].p != -1:
        depth += 1
        c = T[c].p
    T[u].d = depth

def getChildren(u):
    c = T[u].l
    children = []
    while c != -1:
        children.append(c)
        c = T[c].r
    return children

n = int(input())
T = [node(-1, -1, -1, 0) for _ in range(n)]
for i in range(n):
    info = list(map(int, input().split(" ")))
    for j in range(info[1]):
        if j == 0:
            T[info[0]].l = info[2 + j]
        else:
            T[info[2 + j - 1]].r = info[2 + j]
        T[info[2 + j]].p = info[0]

for i in range(n):
    print("node", end = ' ')
    print(i, end = ': ')
    print("parent =", end = ' ')
    print(T[i].p, end = ', ')
    print("depth =", end = ' ')
    getDepth(i)
    print(T[i].d, end = ', ')
    if T[i].p == -1: print("root", end = ', ')
    elif T[i].l == -1: print("leaf", end = ', ')
    else: print("internal node", end = ', ')
    print(getChildren(i))



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

typedef long long ll;

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

    ll n,m;
    cin >> n >> m;
    ll ans;
    if(n==1&&m==1) ans = 1;
    else if(n==1) ans = n*(m-2);
    else if(m==1) ans = (n-2)*m;
    else ans = (n-2)*(m-2);
    cout << ans << endl;
    return 0;
}

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

int main() {
	// your code goes here
	int s;
	cin>>s;
	int h=s/3600;
	s%=3600;
	int m=s/60;
	s%=60;
	
	cout<<h<<":"<<m<<":"<<s<<endl;
	return 0;
}


Measured memory_bytes: 3096
import os
import sys
from io import BytesIO, IOBase
# from collections import defaultdict as dd
# from collections import deque as dq
# import itertools as it
# from math import sqrt, log, log2
# from fractions import Fraction

def main():
    n = int(input())
    s = input()
    rc = s.count('R')
    sor = 'R'*rc + 'W'*(n - rc)

    ed = 0
    for i in range(n):
        if s[i]!=sor[i]: ed += 1
    
    print(ed//2)


    #x, y = map(int, input().split())
    #nums = list(map(int, input().split()))
        




































# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# endregion
 
if __name__ == "__main__":
    main()

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

int main() {
    int N;
    cin >> N;
    int A[2];
    int addnum, res = 0;
    
    for (int i = 0; i < N; i++) {
        cin >> A[0] >> A[1];
        addnum = A[1] - A[0] + 1;
        res += addnum;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
int main ()
{
	int n;
	scanf("%d",&n);
	int a[109];
	for (int i = 1; i <= n; i++)
		scanf("%d",&a[i]);
	LL s = 1;
	int flag = 0;
	LL sum = 1;
	for (int i = 1; i <= n; i++)
	{
		if (a[i]%2 == 0) flag = 1;
		if (a[i]%2 == 0)
			s *= 2;
		sum *=3;
	}
	if (flag) sum -= s;
	else 
		sum -= 1;
	printf("%d",sum);

}

Measured memory_bytes: 128
n, y = [int(elem) for elem in input().split()]

max_num = y // 1000

flag = 0
for i in range(0, n+1):
  for j in range(0, n+1):
    if (n - (i + j)) == (max_num - (10 * i + 5 * j)) and (n - (i + j)) >= 0:
      print(i, j, n - (i + j))
      flag = 1
      break
  if flag == 1:
    break

if flag == 0:
  print(-1, -1, -1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<bool> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll n ; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);
    sort(a.begin(),a.end());
    vector<bool> z(1000001,1);
    z[0] = 0;
    rep(i,n){
        ll x = a.at(i);
		if(!(z.at(x))) continue;
        ll y = x+x;
        if(i!=0){
            if(a.at(i) == a.at(i-1)){
                y=x;
            }
        }
        while(y<=1000000){
            if(z.at(y)) z.at(y) = 0;
            y += x;
        }
    }
    //prvec(z);
    ll ans = 0;
    rep(i,n){
        if(z.at(a.at(i))) ans++;
    }
    cout << ans << endl;
}


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

#define INF 100000000
 
using namespace std;

int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
 
int V,match[1001];
bool used[1001];
vector<int>G[1001];
 
void add_edge(int u,int v){
  G[u].push_back(v);
  G[v].push_back(u);
}
 
bool dfs(int v){
  used[v]=true;
  for(int i=0;i<G[v].size();i++){
    int u=G[v][i],w=match[u];
    if(w<0 || !used[w] && dfs(w)){
      match[v]=u;
      match[u]=v;
      return true;
    }
  }
  return false;
}
 
int bipartite_matching(){
  int res=0;
  fill(match,match+1001,-1);
  for(int v=0;v<V;v++){
    if(match[v]<0){
      fill(used,used+1001,false);
      if(dfs(v))res++;
    }
  }
  return res;
}
 
int main(void){
	
	int m,n;
	
	while(cin >> m >> n,m|n){
		vector<int>b(m),r(n);
		for(int i=0;i<1001;i++)G[i].clear();
		
		for(int i=0;i<m;i++)cin >> b[i];
		for(int i=0;i<n;i++)cin >> r[i];
		
		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++){
				if(gcd(b[i],r[j])!=1)add_edge(i,j+m);
			}
		}
		V=max(m,n);
		cout << bipartite_matching() << endl;
	}
	
return 0;
}
 

Measured memory_bytes: 3380
# -*- coding: utf-8 -*-
"""
Created on Tue Mar  5 00:23:16 2019

@author: yuta
"""
from collections import Counter
S = input()
def main(s):
    s = list(s)
    c = Counter(s)
    s_len = len(list(set(s)))
    if s_len == 1:
        min_count = 0
    else:
        min_count = c.most_common()[-1][1]
    print(min_count * 2)
main(S)

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

int main() {
  int N;
  cin >> N;
  bool flag = 1; 
  int botton = 0;
  int pbotton = 0;
  int times = 0;
  vector<int> a(N);
  
  for (int i=0; i<N; i++)
    cin >> a.at(i);
  
  while (flag) {
    if (a.at(botton) == 2) {
      //ボタン2が光るボタンの場合
      //回数増加、while終了
      times++;
      break;
    }
    if (a.at(botton) == 0) {
      //既に押したボタンの場合
      //回数=-1、while終了
      times = -1;
      break;
    }
    else {
      //ボタン2以外が光るボタンの場合
      //次のボタンへ
      //このボタンは0にする
      pbotton = botton;
      botton = a.at(botton)-1;
      a.at(pbotton) = 0;
      times++;
    }
  }
  
  cout << times <<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1ll << LLONG_MAX;
const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N, M;
    cin >> N >> M;
    ll ans = 1;
    vector<ll> div;
    // Mの約数を求める
    for (ll d = 1; d * d <= M; ++d) {
        if (M % d == 0) {
            div.push_back(d);
            ll d2 = M / d;
            if (d2 != d) {
                div.push_back(d2);
            }
        }
    }
    sort(div.begin(), div.end());

    // Mの約数のうちM/N以下のもので最大のものを求める
    for (auto& d : div) {
        if (d * N <= M) {
            ans = max(d, ans);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    string s,w;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i]=='B'){
            if(w != ""){
                w.pop_back();
            }
        }
        else{
            w += s[i];
        }
    }
    cout << w << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        if(A <= 9 && B <= 9) {
        	System.out.println(A*B);
        }else {
        	System.out.println(-1);
        }


    }

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 21332
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    int n;
    cin >> n;
    pair<int,int> ab[n],cd[n];
    for(int i=0; i<n; i++){
        int tmp1,tmp2;
        cin >> tmp1 >> tmp2;
        ab[i].first=tmp1;
        ab[i].second=tmp2;
    }
    for(int i=0; i<n; i++){
        int tmp1,tmp2;
        cin >> tmp1 >> tmp2;
        cd[i].first=tmp1;
        cd[i].second=tmp2;
    }
    sort(cd,cd+n);
    int memo[100]={};
    int j=0;
    int cnt=0;
    for(int i=0; i<n; i++){
        int ci = cd[i].first;
        int di = cd[i].second;
        int max_j=-1;
        int max_y=-1;
        for(int j=0; j<n; j++){
            int aj = ab[j].first;
            int bj = ab[j].second;
            
            if(!memo[j] && aj<ci && bj<di && max_y<bj){
                max_y = bj;
                max_j = j;
            }
        }
        if(max_j>=0){
            cnt++;
            memo[max_j]++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int power[]= {0, 13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
  int A, B;
  cin >> A >> B;
  
  if(A == B)
    cout << "Draw";
  else
    cout << ((power[A] < power[B]) ? ("Bob"):("Alice"));
  return 0;
}

Measured memory_bytes: 256
// include headers{{{
//
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*}}}*/
# define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
    int n; cin >> n;
    if (n <= 999) cout << "ABC" << endl;
    else cout << "ABD" << endl;
    return 0;
}

Measured memory_bytes: 888
// B.

#include <iostream>
#include <sstream>

using namespace std;

int main(int argc, char *argv[])
{
	int w, h, n;
	cin >> w >> h >> n;
	int c[101][101] = {};
	for (int i = 0; i < n; ++i) {
		int x, y, a, sx, sy, ex, ey;
		cin >> x >> y >> a;
		switch (a) {
		case 1:
			sx = 0, ex = x, sy = 0, ey = h;
			break;
		case 2:
			sx = x, ex = w, sy = 0, ey = h;
			break;
		case 3:
			sx = 0, ex = w, sy = 0, ey = y;
			break;
		case 4:
			sx = 0, ex = w, sy = y, ey = h;
			break;
		}
		for (int i = sy; i < ey; ++i) {
			for (int j = sx; j < ex; ++j) {
				c[i][j] = 1;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			ans += c[i][j] == 0;
		}
	}
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;
typedef long double ld;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
const ll N=2e5 + 5;
const ll mod=1e9 + 7;

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

    ld ans=0;
    for(ll i=0;i<n;i++)
    {
        ld val;
        cin>>val;
        val = 1.0/val;
        ans = ans + val;
    }

    ans = 1.0/ans;
    cout<<fixed<<setprecision(10)<<ans;

}


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

int main(){
    ll n,k,i,j;cin>>n>>k;
    vector<ll> a(n+1);
    for(i=1;i<=n;i++){cin>>a[i];}
    vector<ll> canvisit(200010,0);
    
    ll keynum=a[1];
    for(i=1;i<=3*n+1;i++){//訪れない町は0
        canvisit[keynum]++;
        keynum=a[keynum];
    }

    ll roopnum=0;

    sort(canvisit.begin(),canvisit.end(),greater<ll>());

    ll NOT=0;
    for(i=0;i<=n+5;i++){
        if(canvisit[i]>=3){roopnum++;}
        if(canvisit[i]==1){NOT++;}
    }

    NOT++;

    if(k-NOT>=0){
        k-=NOT;
        k%=roopnum;
        k+=NOT;
    }

    ll ans=1,key=a[1];
    
    if(k==0){cout<<1<<endl;return 0;}

    if(k==1){
        cout<<a[1]<<endl;return 0;
    }
    
    for(i=1;i<k;i++){
        ans=a[key];
        key=ans;
    }

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

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

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];

	int M = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			M = max(M, abs(A[i] - A[j]));
		}
	}
	cout << M << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pi pair<int, int>
#define F first
#define S second
#define PB push_back
#define EPB emplace_back
#define MP make_pair
#define deb(x) cerr << #x << ":" << x << endl;
#define deba(x) cerr << #x << ":\n"; for(auto i: x) cerr << i << " ";cout << endl;
const int INF = 1e7 + 7, MOD = 1e9 + 7;
#define float double
const float EPS = 0.001;
bool feq(float a, float b) { return abs(a - b) < EPS; }
bool fgt(float a, float b) { return a - b > EPS; }
bool flt(float a, float b) { return a - b < EPS; }



int main() {
	fastio();
	string s;
	cin >> s;
	int n = s.length();
	if(s[n-1] =='s') s += 'e';
	s += 's';
	cout << s << '\n';
	return 0;
}



Measured memory_bytes: 3652
import static java.lang.System.*;
import java.util.*;
 
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n=sc.nextInt(), m=sc.nextInt(), x=sc.nextInt();
		int[] ar = new int[n+1];
		for (int i=0; i<m; i++) {
			int temp = sc.nextInt();
			ar[temp]++;
		}
		
		int costL=0, costR=0;
		for (int i=x; i>=0; i--) costL += ar[i];
		for (int i=x; i<=n; i++) costR += ar[i];
		
		out.println(Math.min(costL,costR));
	}
}

Measured memory_bytes: 22612
#include <iostream>
#include<string>
#include<queue>
#include <utility>
int main(void) {
	int Time = 0;
	int N,Quantum;
	std::cin >> N>>Quantum;
	std::queue<std::pair<std::string, int> >Process_Quantum;
	for (int i = 0; i < N; ++i) {
		std::string InputString;
		int InputInt;
		std::cin >> InputString >> InputInt;
		Process_Quantum.push(make_pair(InputString, InputInt));
	}
	while (!(Process_Quantum.empty())) {	
		std::pair<std::string, int>Cal;
		Cal = Process_Quantum.front();
		Process_Quantum.pop();
		if (Cal.second > Quantum) {
			Time+=Quantum;
			Cal.second -= Quantum;
			Process_Quantum.push(Cal);
		}
		else {
			Time += Cal.second;
			std::cout << Cal.first << " " << Time << std::endl;
		}
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 6308
#!/usr/bin/env python3
import sys
MOD = 2  # type: int


# 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))
    M = int(next(tokens))
    S = [[int(next(tokens)) for i in range(int(next(tokens)))] for i in range(M)]
    P = [int(next(tokens)) for i in range(M)]
    Flags = [False for i in range(N)]
    sum = 0
    for i in range(2**N):
        for k in range(N):
            Flags[k] = i & (1<<k) > 0
        fail = False
        for m in range(M):
            c = 0
            for s in S[m]:
                if Flags[s-1]:
                    c+=1
            if c % 2 != P[m]:
                fail = True
                break
        if not fail:
            sum+=1
    print(sum)
    pass

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#define rep(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int mod1=1e9+7,mod2=1e9+9,base=37,mod=1e9+7;
const int N=410,M=12010;
const ll INF=1000000000000000000ll;
ll a[N],b[N],c[N];
ll R[M][N],L[M][N];int cnt[M];int tot;
int kk[N];
int n;ll K;
int ans;
struct H{
	int x1,x2;
	H(){}
	H(int x1,int x2):x1(x1),x2(x2){}
	H operator + (H h){return H((x1+h.x1)%mod1,(x2+h.x2)%mod2);}
	H operator * (H h){return H(1ll*x1*h.x1%mod1,1ll*x2*h.x2%mod2);}
	friend bool operator < (H h1,H h2){return h1.x1<h2.x1||(h1.x1==h2.x1&&h1.x2<h2.x2);}
};
map<H,int> mp;

H code(ll a[],ll mx){
	int i;H ret=H(0,0);
	rep(i,1,n)	ret=ret*H(base,base)+H((a[i]-mx)%mod1,(a[i]-mx)%mod2);
	return ret;
}

void solve(int id){
	//static ll L[N],R[N];static int cnt;
	static int c[N];static ll kk[N];static int ck;
	int i,x;
	ck=0;
	rep(i,1,cnt[id])	kk[++ck]=L[id][i],kk[++ck]=R[id][i]+1;
	sort(kk+1,kk+1+ck);ck=unique(kk+1,kk+1+ck)-kk-1;
	rep(i,1,cnt[id]){
		x=lower_bound(kk+1,kk+1+ck,L[id][i])-kk;c[x]++;
		x=lower_bound(kk+1,kk+1+ck,R[id][i]+1)-kk;c[x]--;
	}
	rep(i,1,ck-1){
		c[i]+=c[i-1];
		if(c[i])	ans=(1ll*ans+kk[i+1]-kk[i])%mod;
	}
}

int calc(ll l,ll r){
	int ret=0;int i;int opt1,opt2;
	for(i=60;i>=0;i--){
		opt1=r>>i&1;opt2=l>>i&1;
		if(!opt1&&!opt2)	continue;
		if(opt1&&opt2)	ret++;
		else return ret+1;
	}
}

bool cmp(int aa,int bb){return c[aa]<c[bb];}

void work(int p){
	ll mx=INF;int i,x;H hsh;int now;
	rep(i,1,n)	b[i]=a[i]>>p,mx=min(mx,b[i]);
	rep(i,1,n)	c[i]=a[i]&((1ll<<p)-1);
	rep(i,1,n)	kk[i]=i;
	sort(kk+1,kk+1+n,cmp);
	hsh=code(b,mx);
	if(!mp[hsh])	mp[hsh]=++tot;
	now=mp[hsh];
	cnt[now]++;R[now][cnt[now]]=mx;L[now][cnt[now]]=max(mx-(K-p),0ll);
	//rep(i,1,n)	printf("%lld ",b[i]-mx);printf("\n");
	//printf("%lld %lld\n",L[now][cnt[now]],R[now][cnt[now]]);
	rep(i,1,n-1){
		if(!b[kk[i]])	break;
		b[kk[i]]--;mx=min(mx,b[kk[i]]);
		if(c[kk[i]]>=c[kk[i+1]])	continue;
		x=calc(c[kk[i]],c[kk[i+1]]);
		if(x>K-p)	continue;
		hsh=code(b,mx);
		if(!mp[hsh])	mp[hsh]=++tot;
		now=mp[hsh];
		cnt[now]++;R[now][cnt[now]]=mx;L[now][cnt[now]]=max(mx-(K-x-p),0ll);
		//rep(i,1,n)	printf("%lld ",b[i]-mx);printf("\n");
		//printf("%lld %lld\n",L[now][cnt[now]],R[now][cnt[now]]);
	}
}
	
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int i;map<H,int>::iterator it;
	scanf("%d%lld",&n,&K);
	rep(i,1,n)	scanf("%lld",&a[i]);
	rep(i,0,60) if(i<=K) work(i);
	for(it=mp.begin();it!=mp.end();it++)	solve(it->second);
	printf("%d\n",ans);
}

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
		

Measured memory_bytes: 66304
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;




int main() {
	
	int h, w, n;
	cin >> h >> w >> n;

	ll cnt = 0;
	vector<set<pii>> s(10);
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;


		for (int j = max(a-1,2);j <= min(a+1,h-1);j++) {
			
			for (int k = max(b-1,2); k <= min(b+1,w-1);k++) {
				pii cp = make_pair(j, k);
				bool canFind = false;
				for (int l = 8;l >= 1;l--) {
					if (s[l].find(cp) != s[l].end()) {
						s[l+1].insert(cp);
						s[l].erase(cp);
						canFind = true;
						break;
						
					}

					
				}

				if (!canFind) {
					s[1].insert(cp);
					cnt++;
				}
			}
		}
	}

	ll ans0 = 1LL * (h - 2)* (w - 2) - cnt;
	cout << ans0 << endl;
	for (int i = 1; i < 10;i++) {
		cout << s[i].size() << endl;
	}

}


Measured memory_bytes: 42368
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 14 21:02:27 2020

@author: morihiranaoki
"""

H,W = map(int,input().split())

if H % 2 == 0:
    movable = (H)/2 * W
else:
    if W % 2 == 0: 
        movable = W/2 * H
    else:
        movable = H * (W-1)/2 + H//2 +1

if H == 1 or W == 1:
    movable = 1

print(int(movable))

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define ms_valtype int

//比較関数
int compare(ms_valtype a, ms_valtype b){
	return a - b;
}

//昇順
void sort_sub(ms_valtype *origin, int left, int right, ms_valtype *tmp){
	if(right - left > 1){
		int i, j, k, half = (left + right) / 2;
		sort_sub(origin, left, half, tmp);
		sort_sub(origin, half, right, tmp);
		for(i = left; i < right; i++){
			tmp[i] = origin[i];
		}
		for(i = left, j = left, k = half; i < right; i++){
			if(k == right){
				origin[i] = tmp[j];
				j++;
			}
			else if(compare(tmp[j], tmp[k]) <= 0 && j < half){
				origin[i] = tmp[j];
				j++;
			}
			else{
				origin[i] = tmp[k];
				k++;
			}
		}
	}
}

void sort(ms_valtype *origin, int N){
	ms_valtype *tmp = (ms_valtype *)malloc(sizeof(ms_valtype) * N);
	sort_sub(origin, 0, N, tmp);
	free(tmp);
}

int main(){
	int N, i, j, ans = 0;
	scanf("%lld", &N);
	int *A = (int *)malloc(sizeof(int) * N);
	int *B = (int *)malloc(sizeof(int) * N);
	int *C = (int *)malloc(sizeof(int) * N);
	int *a = (int *)malloc(sizeof(int) * N);
	int *b = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%lld", &A[i]);
	}
	for(i = 0; i < N; i++){
		scanf("%lld", &B[i]);
	}
	for(i = 0; i < N; i++){
		scanf("%lld", &C[i]);
	}
	sort(A, N);
	sort(B, N);
	sort(C, N);
	for(i = 0, j = 0; i < N; i++){
		while(B[i] >= C[j] && j < N){
			j++;
		}
		b[i] = N - j;
	}
/*	for(i = 0; i < N; i++){
		printf("%lld  ", b[i]);
	}
	printf("\n");
*/	for(j = N - 2; j >= 0; j--){
		b[j] += b[j + 1];
	}
/*	for(i = 0; i < N; i++){
		printf("%lld  ", b[i]);
	}
	printf("\n");
*/	for(i = 0, j = 0; i < N; i++){
		while(A[i] >= B[j] && j < N){
			j++;
		}
		if(j < N){
			ans += b[j];
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4080
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    int count = 0;
    boolean tf = true;
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    int[] numList = new int[num];
    for(int i = 0; i < num; i++){
    numList[i] =sc.nextInt();
    }
    
    while(tf == true){
    	for(int i = 0; i < num; i++){
    		if(numList[i] % 2 == 1) {
    	  	tf = false;
    	  	break;
            }else{
              numList[i] = numList[i] / 2;
   			}
    	}
      if(tf == true)count++;
    }
    System.out.println(count);   
  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main () {
    int h, w;
    cin >> h >> w;
    vector<string> v;
    for (int i = 0; i < h; i++) {
        string s;
        cin >> s;
        bool flag = false;
        for (auto x: s) {
            if (x != '.') {
                flag = 1;
                break;
            }
        }
        if (flag) {
            v.push_back(s);
        }
    }
    set<int> l;
    for (int j = 0; j < w; j++) {
        bool flag = 1;
        for (int i = 0; i < v.size(); i++) {
            if (v[i][j] != '.') {
                flag = 0;
                break;
            }
        }
        if (flag) {
            l.insert(j);
        }
    }
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < w; j++) {
            if (l.find(j) == l.end()) {
                cout << v[i][j];
            }
        }
        cout << endl;
    }
}

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)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int dp[105][10005];

int main() {
  int n, w;
  cin >> n >> w;
  vector<pair<int, int>> p(n+1);
  FOR(i, 1, n+1) cin >> p[i].first >> p[i].second;
  FOR(i, 1, n+1) {
    rep(j, w+1) {
      if (p[i].second <= j) {
        if (p[i].first + dp[i-1][j-p[i].second] > dp[i-1][j]) {
          dp[i][j] = p[i].first + dp[i-1][j-p[i].second];
        }
        else dp[i][j] = dp[i-1][j];
      }
      else dp[i][j] = dp[i-1][j];
    }
  }
  cout << dp[n][w] << endl;

  
  return 0;
}


Measured memory_bytes: 6984
def main24():
    data = input().split()
    num = []
    for i in range(2):
        num.append(int(data[i]))
    if num[1] % num[0] == 0:
        print((num[0]+num[1]))
    else:
        print((num[1]-num[0]))

if __name__ == "__main__":
    main24()

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

int main()
{
  i64 a, b, n;
  cin >> a >> b >> n;
  for (i64 _ = 0; _ < n; _++)
  {
    i64 s, f;
    cin >> s >> f;
    if (a < f && s < b)
    {
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

//Common
typedef long long Weight;
const Weight WEIGHT_INF = std::numeric_limits<Weight>::max()/4;

struct Edge {
    int src, dst;
    Weight weight;
};
bool operator<(const Edge& a, const Edge& b) {
    return (a.weight < b.weight);
};
bool operator>(const Edge& a, const Edge& b) {
    return (a.weight > b.weight);
};
typedef std::vector<Edge> Edges;
typedef std::vector<Edges> Graph;

//Wardhall-Floyd
std::vector< std::vector<Weight> > g;
std::vector< std::vector<int> > trace;
void warshallFloyd() {
    int n = g.size();
    trace.resize(n, std::vector<int>(n, -1));
    REP(k, n) REP(i, n) REP(j, n) {
        g[i][j] = std::min(g[i][j], g[i][k] + g[k][j]);
    }
}
const int INF = 1 << 29;

int N, M, R;
std::vector<int> r;
int main() {
    std::cin >> N >> M >> R;
    g.resize(N, std::vector<Weight>(N, WEIGHT_INF));
    REP(i, N) REP(j, N) {
        if(i == j) g[i][j] = 0;
        else       g[i][j] = INF;
    }
    r.resize(R);
    
    REP(i, R) {
        std::cin >> r[i];
        r[i]--;
    }
    REP(i, M) {
        int a, b, c;
        std::cin >> a >> b >> c;
        a--, b--;
        g[a][b] = c;
        g[b][a] = c;
    }

    warshallFloyd();

    int ans = INT_MAX;
    std::sort(ALL(r));
    do {
        int sum = 0;
        REP(i, R-1) {
            sum += g[r[i]][r[i+1]];
        }
        ans = std::min(ans, sum);
    } while(std::next_permutation(ALL(r)));

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

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 400
#define mod 1000000007
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define out(s) cout<<s
#define outs(s,a) cout<<s<<a
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
using namespace std;
void solve()
{
    ll n,i,j;
    in(n);
    set<ll>ss;
    sfl(i,1,10)
    {
        sfl(j,1,10)
        {
            ss.insert(i*j);
        }
    }
    if(ss.find(n)!=ss.end())
        cout<<"Yes\n";
    else
        cout<<"No\n";
}
int main()
{

    gear_change;
    ll test=1;
    // in(test);
    while(test--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define rep(i,a,b) for (int i=(a); i<=int(b); i++)
using namespace std;

inline int read() {
	char ch = getchar(); int x = 0, op = 1;
	while (ch < '0' || '9' < ch) { if (ch == '-') op = -1; ch = getchar(); }
	while ('0' <= ch && ch <= '9') { x = x*10 + ch-'0'; ch = getchar(); }
	return op * x;
}

const int maxn = 309;
int a[maxn][maxn], p[maxn], del[maxn], cnt[maxn];
int n, m, l = 1, r, mid;

bool check(int limit) {
	int mx = 0, cur = 0, now, ty;
	memset(cnt, 0, sizeof cnt);
	memset(del, 0, sizeof del);
	rep (i, 1, n) {
		cnt[a[i][1]]++; p[i] = 1;
	}
	rep (i, 1, m) if (cnt[i] > mx) {
		mx = cnt[i]; cur = i; 
	}
	while (mx > limit) {
		del[cur] = 1;
		rep (i, 1, n) {
			if (!del[a[i][p[i]]]) continue;
			while (p[i] <= m && del[a[i][p[i]]]) p[i]++;
			if (p[i] > m) return 0;
			cnt[a[i][p[i]]]++;
		}
		mx = 0;
		rep (i, 1, m) if (!del[i] && cnt[i] > mx) {
			mx = cnt[i]; cur = i;
		}
	}
	return 1;
}

int main() {
	r = n = read(); m = read();
	rep (i, 1, n) rep (j, 1, m) a[i][j] = read();
	while (l < r) {
		mid = (l + r) >> 1;
		if (check(mid)) r = mid;
		else l = mid + 1;
	}
	printf("%d\n", l);
	return 0;
}

Measured memory_bytes: 512
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n = I()
    if n % 2 == 0:
        print(n//2)
    else:
        print(n//2 + 1)
    return


# Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38384
#include <stdio.h>
#include <stdlib.h>
int main(void){
  long long int a,b,c,d;
  long long int l;
  if(scanf("%lld %lld %lld %lld",&a,&b,&c,&d) == EOF) return 1;
  l=a*c;
  if(a*d > l) l=a*d;
  if(b*c > l) l=b*c;
  if(b*d > l) l=b*d;
  printf("%lld\n",l);
  return 0;
}


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

#define rep(i,a,b)                for(ll i=a;i<b;i++)
#define re(i,b)                for(ll i=0;i<b;i++)
#define repr(i,n)                for(ll i=n-1;i>=0;i--)
#define ll long long
#define ld long double
#define pll std::pair<ll, ll> 
#define ppll std::pair<pll, ll>
#define vll std::vector<ll> 
#define vpll std::vector<pll> 
#define vppll std::vector<ppll> 
#define mll std::unordered_map<ll, ll> 
#define mpll std::unordered_map<pll, ll>
#define mppll std::unordered_map<ppll, ll>
#define sll std::set<ll>
#define ff first
#define ss second
#define msll std::multiset<ll>
#define all(c) c.begin(), c.end()
#define allr(c) c.rbegin(), c.rend()
#define srt(x) sort(all(x))
#define rsrt(x) sort(allr(x))
#define eb emplace_back
#define pb push_back
#define s(yy) ll yy;cin>>yy
#define len length()
#define sz size()
const ll mod = 1e9 + 7;
const ll INF = 0x7FFFFFFFFFFFFFFF>>1;

/*#################################################### 
#                                                    #
#                     @author                        #
#                  Parth Lathiya                     #
#      https://www.cse.iitb.ac.in/~parthiitb/        #
#                                                    #
####################################################*/


int main()
{

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

    #ifdef PARTH_LATHIYA_HOME

        freopen("A_in.txt","r",stdin);
    
        ll ttt,bkkk;
        cin>>ttt;
        bkkk=ttt;
        while(ttt--) {
            cout<<"Testcase - "<<bkkk-ttt<<"\n";
    #endif

//--------------------------------------------------------------------------------------

    s(n);
    
    ld temp= sqrtl(1.0+8.0*n)+1.0;
    ll k;
    if(temp == (ll)temp)
    {
        if((ll)temp%2==0)
        {
            k = temp/2;
            vll v[k];

            ll tempo=0;
            for(int i=0;i<k;i++)
            {
                for(int j=i+1;j<k;j++)
                {
                    v[i].pb(tempo);
                    v[j].pb(tempo);
                    tempo++;
                }
            }
            cout<<"Yes\n"<<k<<endl;
            for(int i=0;i<k;i++)
            {
                cout<<v[i].size()<<" ";
                re(j,v[i].size())
                {
                    cout<<v[i][j]+1<<" ";
                }
                cout<<endl;
            }
        }
        else
            cout<<"No\n";
    }
    else
        cout<<"No\n";
    

//--------------------------------------------------------------------------------------
    
    #ifdef PARTH_LATHIYA_HOME
        cout<<"\n"; }
    #endif

    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll h, w; cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    vector<vector<char>> ans(h, vector<char>(w, 0));
    for(ll i=0; i<h; i++){
        for(ll j=0; j<w; j++){
            if(s[i][j] == '#') ans[i][j] = '#';
            else{
                ll bomb = 0;
                if(i != 0 && s[i-1][j] == '#') bomb++; // 上
                if(i != 0 && j != 0 && s[i-1][j-1] == '#') bomb++; // 左上
                if(i != 0 && j != w-1 && s[i-1][j+1] == '#') bomb++; // 右上
                if(j != 0 && s[i][j-1] == '#') bomb++; //左
                if(j != w-1 && s[i][j+1] == '#') bomb++; //右
                if(i != h-1 && s[i+1][j] == '#') bomb++; //下
                if(i != h-1 && j != 0 && s[i+1][j-1] == '#') bomb++; //左下
                if(i != h-1 && j != w-1 && s[i+1][j+1] == '#') bomb++; //右下
                ans[i][j] = bomb+'0';
            }
        }
    }

    for(ll i=0; i<h; i++){
        for(ll j=0; j<w; j++){
            cout << ans[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#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;

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

  vector<int> dp(3, 0);

  rep(i, N) {
    vector<int> h(3, 0);
    cin >> h.at(0) >> h.at(1) >> h.at(2);

    vector<int> tmp(3, 0);
    rep(j, 3) {
      int k1 = (j + 1) % 3, k2 = (j + 2) % 3;
      tmp.at(j) = max(dp.at(k1), dp.at(k2)) + h.at(j);
    }
    dp = tmp;
  }

  cout << *max_element(dp.begin(), dp.end()) << endl;

  return 0;
}


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

long long f(int h, int w){
	long long ret=LLONG_MAX;
	for (int i=1;i<w;i++){
		long long x=1ll*i*h;
		long long y=h/2;
		long long z=h-y;
		y*=(w-i);
		z*=(w-i);
		ret=min(ret,max(max(x,y),z)-
		min(min(x,y),z));
		y=(w-i)/2;
		z=w-i-y;
		y*=h;
		z*=h;
		ret=min(ret,max(max(x,y),z)-
		min(min(x,y),z));
	}
	return ret;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int h,w;
	cin >> h >> w;
	long long ans=f(h,w);
	swap(h,w);
	ans=min(ans,f(h,w));
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include<cstdio>
#include<climits>
#include<algorithm>

#define MOD(x) ((x) % 1000000007)

typedef long long ll;

using namespace std;

int n;
int m;
int a;
int dp[100001];


int main(void){
    scanf("%d %d", &n, &m);

    for(int i = 1; i <= m; i++){
        scanf("%d", &a);
        dp[a] = -1;
    }

    dp[0] = 1;
    dp[1] = dp[1] == -1 ? 0 : 1;
    for(int i = 2; i <= n; i++){
        if(dp[i] != -1){
            dp[i] = MOD(dp[i - 1] + dp[i - 2]);
        }else{
            dp[i] = 0;
        }
    }

    printf("%d\n", dp[n]);

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
using namespace std;
int main(){
    string a,b;
    cin>>a>>b;
    int i=0;
    if(a.length()==b.length()){
        while(a[i]==b[i] && a.length()>=i){
            i++;
        }
        if(a.length()<i){
            cout<<"EQUAL"<<endl;
        }else{
        cout<<(a[i]<b[i]?"LESS":"GREATER")<<endl;
        }
    }else if(a.length()<b.length()){
        cout<<"LESS"<<endl;
    }else{
        cout<<"GREATER"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CMultipleGift solver = new CMultipleGift();
        solver.solve(1, in, out);
        out.close();
    }

    static class CMultipleGift {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long x = in.nextLong();
            long y = in.nextLong();
            long now = x;
            int res = 0;
            while (now <= y) {
                res++;
                now <<= 1;
            }
            out.println(res);
        }

    }
}



Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
void cumu(ll x[],ll s[],int n){
  s[0]=0;
  rep1(i,n) s[i]=s[i-1]+x[i-1];
}
int main(){
  int n;
  cin>>n;
  ll a[200010];
  rep(i,n) cin>>a[i];
  ll cum[200010];
  cumu(a,cum,n);
  ll res=INFLL,sum=cum[n];

  rep1(i,n-1){
    res=min(res,abs(2*cum[i]-sum));
  }
  prin(res);
  
  return 0;
}


Measured memory_bytes: 3328