akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using llint = long long int;
using namespace std;

int main() {
    fastIO;
    int k, x;
    cin >> k >> x;
    for (int i = x - k + 1; i <= x + k - 1; i++) {
        cout << i << " ";
    }
}

Measured memory_bytes: 3640
import java.util.*;
import java.lang.*;

import static java.lang.StrictMath.abs;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String[] a = new String[s.length()];
        List<String> b = new ArrayList<String>();
        List<String> c = new ArrayList<String>();

        int count =0;
        for(int i =0; i< s.length();i++ ){
            for(int k=i; k<= i+5; k++){
                try {
                    b.add(s.substring(i, k));
                }catch (StringIndexOutOfBoundsException e){

                }

                count++;
            }
        }
        Collections.sort(b);
        c.add(b.get(0));

        for(int j =0; j < b.size()-1; j++){

            if(b.get(j).equals(b.get(j+1))){
                continue;
            }else{
                c.add(b.get(j+1));
            }
        }
        System.out.println(c.get(sc.nextInt()));



    }

}

Measured memory_bytes: 26144
from itertools import permutations

def main():
	n, m = list(map(int, input().split()))
	adj_list = [[] for _ in range(n)]
	for i in range(m):
		u, v = list(map(int, input().split()))
		adj_list[u-1].append(v-1)
		adj_list[v-1].append(u-1)
	pts = list(permutations(list(range(1, n))))
	
	#print(pts)
	ans = 0
	for pt in pts:
		cur = 0
		for nxt in pt:
			if nxt in adj_list[cur]:
				cur = nxt
			else:
				break
		else:
			ans += 1
	print(ans)

if __name__ == '__main__':
	main()


Measured memory_bytes: 3572
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;


    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        long[] A=cin.ArrayLong(N,0);
        long sum=0;
        long sum2=0;
        for(int i=0;i<N;i++)
        {
          A[i]-=i+1;
        }
        Array.Sort(A);
        long b=A[N/2];
        long c=0;
        if(N%2==0)c=(A[N/2-1]+A[N/2])/2;
        for(int i=0;i<N;i++)
        {
          sum+=Math.Abs(A[i]-b);
          sum2+=Math.Abs(A[i]-c);
        }
       //if(N==2&&A[0]>A[1])sum--;
       Console.WriteLine(Math.Min(sum,sum2));

    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 29116
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define llv vector< ll >
#define mp make_pair
#define endl "\n"
const int N = (int)1e5+10 ;
const int M = (int)1000000007; 

int dp[N] , n  ;
int check(int k , int a[]){
     if(dp[ k ] >=0 ) return dp[ k ] ;
     if( k < a[ 0 ] ) return 0 ;

     for(int i=0 ; i<n ; i++){
         if(k-a[i]>=0){
            if(check(k-a[i] , a )==0)return dp[k] = 1 ;
         }
     }

     return dp[k] = 0 ;
}
int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    int i , k  ;
    cin >> n >> k ;
    int a[n] ;
    for(i=0 ; i<n ; i++){
        cin >> a[i] ;
    }
    fill(dp , dp+k+1 , -1) ;

    if(check(k , a )) cout << "First" ;
    else cout << "Second" ;

    return 0 ;
}

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

int main()
{
  int N;
  int A[210];
  cin>>N;
  for (int i=0;i<N;++i)
  {
    cin>>A[i];
  }
  
  int res=0;
  
  while (true)
  {
      bool exist_odd=false; 
      for (int i=0;i<N;++i)
      {
          if(A[i]%2!=0)
          {
            exist_odd=true;
          }
      }

      if (exist_odd) break;

      for (int i=0;i<N;++i)
      {
          A[i]/=2;
      }
      ++res; 
  }
  cout<<res<<endl;
  return 0;
}

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

int main(){
    string a, b; cin >> a >> b;
    int dp[1001][1001];
    int len1 = (int)a.size(), len2 = (int)b.size();
    for(int i = 0; i < 1001; i++) dp[i][0] = dp[0][i] = i;

    for(int i = 1; i <= len1; i++){
        for(int j = 1; j <= len2; j++){
            if(a[i-1]==b[j-1]) dp[i][j] = dp[i-1][j-1];
            else dp[i][j] = min(dp[i-1][j], min(dp[i][j-1], dp[i-1][j-1])) + 1;
            // printf("dp[%d][%d] = %d\n", i, j, dp[i][j]);
        }
    }

    cout << dp[len1][len2] << '\n';
    return 0;
}



Measured memory_bytes: 7104
//才不露白
//还是青蛙跳还是动态规划
//唯一的是你不知道青蛙它从哪跳到了现在的石头上 如果你知道 那就好办了
//比如从k上面跳过来
//dp[i] = dp[k] + abs(h[i] - h[k])
//关键是你k不知道啊
//有想法就好 不用先急着自我否认
//枚举
//dp[1] = 0
//dp[2] = abs(h[2] - h[1])
//写个函数来算看起来不错
//dp[3] = min(从1跳过来,从2跳过来)
//dp[4] = min(从1跳,从2跳，从3跳)用循环 最后求min
//差不多2层吧 先写了试试看
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

const int MAXN = 1e5;
int n,k;
int h[MAXN + 5],dp[MAXN + 5];//

int CHANGE(int i,int k)//
{
	if(i <= k + 1)//一跳就到
	{//从一开始选
		int min = dp[1] + abs(h[i] - h[1]);
		for(int j = 1; j < i; j++)
		{
			if((dp[j] + abs(h[i] - h[j])) < min)
			{
				min = dp[j] + abs(h[i] - h[j]);
			}
		}
		return min;
	}
	else
	{
		int min = dp[i - k] + abs(h[i] - h[i - k]);
		for(int j = i - k; j < i; j++)
		{
			if((dp[j] + abs(h[i] - h[j])) < min)
			{
				min = dp[j] + abs(h[i] - h[j]);
			}
		}
		return min;
	}
}

int main()
{
	scanf("%d %d",&n,&k);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d",&h[i]);
	}
	for(int i = 1; i <= n; i++)
	{
		if(i == 1)
		{
			dp[i] = 0;
		}
		else if(i == 2)
		{
			dp[i] = abs(h[2] - h[1]);
		}
		else
		{
			dp[i] = CHANGE(i,k);
		}
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 896
s = list(input())
n = len(s) - 1

wa = 0
for i in range(2**n):
    lst = [""]*n
    for j in range(n):
        if i&(1<<j):
            lst[j] = "+"
    lst_s = [0]*(len(s) + n)
    lst_s[::2] = s
    lst_s[1::2] = lst
    #print(eval("".join(lst_s)))
    wa += eval("".join(lst_s))
print(wa)

Measured memory_bytes: 38768
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
 
using namespace std;

int main(){
	
	int H, W;
	cin >> H >> W;
	
	int count[30] = {};
	
	for(int i = 0; i < H; i++){
		string str;
		cin >> str;
		for(int j = 0; j < str.size(); j++){
			count[str[j] - 'a']++;
		}
	}
	
	bool flag = true;
	
	if(H % 2 == 0 && W % 2 == 0){
		for(int i = 0; i < 26; i++){
			if(count[i] % 4 != 0){
				flag = false;
			}
		}
	}else if(H % 2 != 0 && W % 2 != 0){
		int sing = 1;
		int doub = (H + W - 2) / 2;
		for(int i = 0; i < 26; i++){
			if(count[i] % 2 != 0){
				sing--;
			}else if(count[i] % 4 != 0){
				doub--;
			}
		}
		if(sing < 0 || doub < 0){
			flag = false;
		}
	}else{
		if(H % 2 == 0){
			swap(H, W);
		}
		int sing = 0;
		int doub = W / 2;
		for(int i = 0; i < 26; i++){
			if(count[i] % 2 != 0){
				sing--;
			}else if(count[i] % 4 != 0){
				doub--;
			}
		}
		if(sing < 0 || doub < 0){
			flag = false;
		}
	}
	
	if(flag){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}

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

#define NMAX 100001
#define MAX(a, b) (a > b ? a : b)

using namespace std;

//ifstream fin("f.in");
//ofstream fout("f.out");

int bulbs, switches;
int wiredSwitches[11][11];
int congruences[11];

int counter[12];
int configurations;

bool CheckSolution()
{
    bool isSolution = true;
    int sum;
    for(int i = 1; i <= bulbs && isSolution; i++)
    {
        sum = 0;
        for(int j = 1; wiredSwitches[i][j] != 0; j++)
            if(counter[wiredSwitches[i][j]])
                sum++;
        if(sum % 2 != congruences[i])
            isSolution = false;
    }
    return isSolution;
}

int main()
{
    cin >> switches >> bulbs;
    for(int i = 1; i <= bulbs; i++)
    {
        int n, aux;
        cin >> n;
        for(int j = 1; j <= n; j++)
        {
            cin >> aux;
            wiredSwitches[i][j] = aux;
        }
    }
    for(int i = 1; i <= bulbs; i++)
        cin >> congruences[i];

    while(!counter[switches + 1])
    {
        if(CheckSolution()) configurations++;
        int i = 1;
        while(counter[i])
        {
            counter[i] = 0;
            i++;
        }
        counter[i] = 1;
    }
    cout << configurations << '\n';
    return 0;
}


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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long
// #define pow mypow

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

set<int> s;
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	for(int i=0; i<3; i++) {
		int num; cin >> num;
		s.insert(num);
	}
	cout << ((s.size() == 2)? "Yes": "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
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(): return list(sys.stdin.readline())[:-1]
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

#A
def A():
    n,a,b = LI()
    print(min(a*n,b))
    return

#B
def B():
    n,d = LI()
    x = LIR(n)
    f = defaultdict(lambda : 0)
    for i in range(1000000):
        f[i*i] = 1
    ans = 0
    for i in range(n):
        for j in range(i+1,n):
            s = 0
            for k in range(d):
                s += (x[i][k]-x[j][k])**2
            if f[s]:
                ans += 1
    print(ans)
    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return


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


Measured memory_bytes: 115320
#include <iostream>
#include <queue>
#include <algorithm>
#include <tuple>
#include <cctype>
using namespace std;

typedef tuple<int, int, int> st; // time, x, y
char F[1010][1010];
int H, W, N;
int X[10], Y[10];
int turn = 0;

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

bool isvalid(int x, int y) {
  return 0 <= x && x < H && 0 <= y && y < W && F[x][y] != 'X';
}

bool isgoal(int x, int y) {
  return isvalid(x, y) && x == X[turn+1] && y == Y[turn+1];
}

int main() {
  scanf("%d%d%d", &H, &W, &N);
  for (auto i=0; i<H; i++) {
    for (auto j=0; j<W; j++) {
      scanf(" %c", &F[i][j]);
      if (isdigit(F[i][j])) {
	int temp = (int)F[i][j] - '0';
	X[temp] = i;
	Y[temp] = j;
      } else if (F[i][j] == 'S') {
	X[0] = i;
	Y[0] = j;
      }
    }
  }
  int res = 0;
  for (turn = 0; turn < N; turn++) {
    bool visited[1010][1010];
    fill(&visited[0][0], &visited[0][0]+1010*1010, false);
    queue<st> Q;
    Q.push(make_tuple(0, X[turn], Y[turn]));
    while (!Q.empty()) {
      int time = get<0>(Q.front());
      int x = get<1>(Q.front());
      int y = get<2>(Q.front());
      Q.pop();
      if (isgoal(x, y)) {
	res += time;
	break;
      } else if (!visited[x][y]) {
	// cerr << "visit: (" << x << "," << y << ")" << endl; 
	visited[x][y] = true;
	for (auto k=0; k<4; k++) {
	  int nx = x + dx[k];
	  int ny = y + dy[k];
	  if (isvalid(nx, ny) && !visited[nx][ny]) {
	    Q.push(make_tuple(time+1, nx, ny));
	  }
	}
      }
    }
  }
  printf("%d\n", res);
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int3(a, b, c);
    Int(k);
    if (k % 2) {
        cout << b- a << endl;
    } else {
        cout << a - b << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
//#define int long long
#define mod 1000000007
#define fi first
#define se second
#define ll long long
#define scan() ll n; cin>>n ; ll a[n]; for(ll i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
using namespace std;
typedef vector<int>vi ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<ll,ll> pll ;
int main()
{
	fast;
	ll m,n;
	cin>>n>>m;
	ll a[n];
	ll sum=0;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	ll x=sum/(4*m);
	if(sum%(4*m)!=0)
		x++;
	sort(a,a+n,greater<int>());
	ll i=0;
	while(a[i]>=x)
	{
		i++;
	}
	if(i>=m)
		cout<<"Yes";
	else
		cout<<"No";

	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);
		while(true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if(H == 0 && W ==0) {
				break;
			}
			for(int i = 0 ; i < H ; i++) {
				for(int j = 0 ; j < W ; j++) {
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 34468
s = input()
f = 0
for i in range(len(s)):
	if s[i] == "L":
		if i % 2 == 0:
			f = 1
			break
	if s[i] == "R":
		if i % 2 == 1:
			f = 1
			break
if f == 1:
	print("No")
else:
	print("Yes")

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if ((A+B) > (C+D)) {
    cout << "Left" << endl;
  }
  else if ((A+B) < (C+D)) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e12;
const int MOD = 1e9 + 7;

int N,K;
ll h[100001];
ll dp[100001];

ll rec(int n){
    if(dp[n] != -1){
        return dp[n];
    }
    if(n == 0){
        return 0;
    }
    ll res = INF;
    for(int i = 1; i <= K; i++){
        if(n - i >= 0){
            res = min(res, rec(n - i) + abs(h[n] - h[n - i]));
        }
    }
    return dp[n] = res;
}

signed main(){
    cin >> N >> K;
    REP(i,N){
        cin >> h[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << rec(N - 1) << endl;
}

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

int N;
vector <int> to[100001];
int fromS[100001];
bool FSroute[100001];


void GetRoute(int from, int now) {
	if (now < 1 || N < now) return;
	if (now == N) {
		FSroute[N] = true;
		fromS[N] = 1;
		return;
	}
	for (int i = 0; i < to[now].size(); i++) {
		int next = to[now].at(i);
		if (next == from) continue;
		GetRoute(now, next);
		if (FSroute[N]== true) {
			FSroute[now] = true;
			fromS[now] = fromS[next]+1;
			return;
		}
	}
}


int GetCnt(int from, int now, int player) {
	if (now < 1 || N < now) return 0;
	int mid = fromS[1]/2;
	int fromBase = 0;
	if (0 < fromS[now]) {
		if (player == 0) {
			fromBase = fromS[1] - fromS[now];
			if (fromS[1]%2==1) mid++;
		} else {
			fromBase = fromS[now] - fromS[N];
		}
		if (fromBase >= mid) return 0;
	}

	int cnt = 1;
	for (int i = 0; i < to[now].size(); i++) {
		int next = to[now].at(i);
		if (next == from) continue;
		if (next == N) continue;
		if (next == 1) continue;
		cnt += GetCnt(now, next, player);
	}
	return cnt;
}

int main()
{
	cin >> N;
	for (int i = 1; i <= N; i++) {
		to[i].clear();
		fromS[i] = 0;
		FSroute[i] = false;
	}
	for (int i = 1; i < N; i++) {
		int a, b;
		cin >> a >> b;
		to[a].push_back(b);
		to[b].push_back(a);
	}

	fromS[N] = 1;
	GetRoute(0, 1);

	int Fennec = GetCnt(0, 1, 0);
	int Snuke  = GetCnt(0, N, 1);
	if (Snuke >= Fennec) cout << "Snuke" << endl;
	else                 cout << "Fennec" << endl;

	return 0;
}


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

int main() {
  int x,y;
  cin>>x>>y;
  string ans;
  if(x==2) ans = "No";
  else if (x==4||x==6||x==9||x==11){
    if (y==4||y==6||y==9||y==11) ans = "Yes";
    else ans ="No";
  }
  else if (y==1||y==3||y==5||y==7||y==8||y==10||y==12) ans="Yes";
    else ans="No";
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    H, W, K = map(int, input().split())
    state = [list(input()) for _ in range(H)]

    blank = [0]*H
    for h in range(H):
        for w in range(W):
            if state[h][w] == "#":
                blank[h] += 1

    ans = [[] for _ in range(H)]
    color = 0
    for h in range(H):
        if blank[h] == 0: continue
        P = []
        color += 1
        c = 1
        for w in range(W):
            P.append(color)
            if state[h][w] == "#" and c < blank[h]:
                color += 1
                c += 1
        ans[h] = P

    for h in range(H):
        if blank[h] > 0: continue
        update = False
        for g in range(h, H):
            if blank[g] > 0:
                update = True
                ans[h] = ans[g]
                break
        if not update:
            for g in reversed(range(h)):
                if blank[g] > 0:
                    ans[h] = ans[g]
                    break

    for l in ans:
        print(" ".join([str(a) for a in l]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 46572
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */

#include <bits/stdc++.h>

using namespace std;

class ATransfer {
public:
    void solve(std::istream &in, std::ostream &out) {
        int a, b, c;
        in >> a >> b >> c;
        int res = max(0, c - (a - b));
        out << res << "\n";
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    ATransfer solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
import math
# 定義
minutes = [int(input()) for i in range(5)]
m = [0]*5

for k in range(5):
	if minutes[k] % 10 == 0:
		m[k] = minutes[k]
	else:
		m[k] = math.ceil(minutes[k] / 10) * 10

# 最後に注文するやつを決める
mx = min([(minutes[0] - 1) % 10, (minutes[1] - 1) % 10, (minutes[2] - 1) % 10, (minutes[3] - 1) % 10, (minutes[4] - 1) % 10])

mx = mx + 1

#　出力
print(m[0] + m[1] + m[2] + m[3] + m[4] + mx - 10)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,m;
int f[4000][4000][3];
long long ans;
int main(){
	scanf("%d%d",&n,&m);
	f[1][0][1]=1;
	for(int i=1;i<=n;i++)f[1][i][0]=1;
	
	for(int i=1;i<=m;i++){
		//红红 
		f[i+1][0][1]+=f[i][1][0];
		f[i+1][0][1]%=1000000007;
		for(int j=1;j<=n;j++){
			f[i+1][j-1][1]+=f[i][j][1];
			f[i+1][j-1][1]%=1000000007;
		}
		for(int j=2;j<=n;j++){
			f[i+1][j-1][0]+=f[i][j][0];
			f[i+1][j-1][0]%=1000000007;
		}
		//蓝蓝 
		for(int j=0;j<n;j++){
			f[i+1][j+1][0]+=f[i][j][0];
			f[i+1][j+1][0]%=1000000007;
			f[i+1][j+1][1]+=f[i][j][1];
			f[i+1][j+1][1]%=1000000007;
		}
		//红蓝 
		f[i+1][1][1]+=f[i][1][0];
		f[i+1][1][1]%=1000000007;
		for(int j=1;j<=n;j++){
			f[i+1][j][1]+=f[i][j][1];
			f[i+1][j][1]%=1000000007;
		}
		for(int j=2;j<=n;j++){
			f[i+1][j][0]+=f[i][j][0];
			f[i+1][j][0]%=1000000007;
		}		
		
		//蓝红 
		for(int j=0;j<n;j++){
			f[i+1][j][1]+=f[i][j][1];
			f[i+1][j][1]%=1000000007;
			f[i+1][j][0]+=f[i][j][0];
			f[i+1][j][0]%=1000000007;
		}	
	}
	ans=0;
	for(int i=0;i<=n;i++){
		ans+=f[m+1][i][1];ans%=1000000007;
	}
	printf("%d ",ans);
	return 0;
}

Measured memory_bytes: 141056
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}



int main(){
    ll n;
    cin>>n;
    vector<ll> A(n+1);
    for(int i=1;i<=n;i++){cin>>A[i];}
    vector<ll> ans(n+1);
    vector<ll> B;
    for(ll i=n;i>0;i--){
        ll cnt=0;
        for(ll j=2;i*j<=n;j++){
            cnt+=ans[i*j];
        }
        if((cnt+A[i])%2){ans[i]=1; B.push_back(i);}
    }
    reverse(B.begin(),B.end());
    cout<<B.size()<<endl;
    cout<<B<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 4980
#pragma comment(linker, "/STACK:500000000") 
#include <functional>
#include <algorithm> 
#include <iostream> 
#include <string.h> 
#include <stdlib.h>
#include <limits.h>
#include <numeric>
#include <sstream> 
#include <fstream>
#include <ctype.h> 
#include <stdio.h> 
#include <bitset>
#include <vector> 
#include <string> 
#include <math.h> 
#include <time.h> 
#include <queue> 
#include <stack> 
#include <list>
#include <map> 
#include <set> 
#define Int long long 
#define eps 1e-9
using namespace std;
typedef pair<int, int> pii;

#define MAXN 11111

int N;
string mark[MAXN];
int used[MAXN], nex[MAXN];
map<string, int> M;
vector<int> ans;

void read(int cur)
{
	while (!used[cur])
	{
		ans.push_back(cur);
		used[cur] = 1;
		if (nex[cur] == -1)
			break;
		cur = nex[cur];
	}
}

int main()
{
	while (cin >> N && N)
	{
		for (int i = 0; i < N; i++)
			cin >> mark[i];
		fill(used, used + 10010, 0);
		fill(nex, nex + 10010, -1);
		M.clear();
		ans.clear();

		for (int i = 0; i < N; i++)
		{
			if (mark[i] == "-")
				read(i);
			else if (mark[i] == "v")
				nex[i + 1] = i;
			else
			{
				string type;
				int number = 0;
				int x = 0;
				while (islower(mark[i][x]))
				{
					type += mark[i][x];
					x++;
				}
				while (x<mark[i].size() && isdigit(mark[i][x]))
				{
					number = number * 10 + mark[i][x] - '0';
					x++;
				}
				if (M.find(type) != M.end())
					nex[i] = M[type];
				
				if (number > 1)
					M[type] = i;
				else 
					M.erase(type);

				if (x < mark[i].size())
					nex[i + 1] = i;
				else if (number == 1)
					read(i);
			}
		}
		for (int i = 0; i < N; i++)
			cout << ans[i] + 1 << endl;
	}
}

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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) (in).begin(),(in).end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最小公倍数

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
  int n,x;
  cin >> n >> x;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin >> a.at(i);
  sort(a.begin(),a.end());
  int cnt;
  for(cnt=0;cnt<n;cnt++){
    x -= a.at(cnt);
    if(x<=0)break;
  }
  if(!x)cnt++;
  if(x>0)cnt--;
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr 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;
}
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << "\n"; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " <<to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void solve(){
  int n;
  string s;
  cin>>n>>s;
  int cnt=0;
  rep(i,n-2){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')++cnt;
  }
  cout<<cnt<<"\n";
}
 
int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
using namespace std;
int ok = 1000*1000*1000+7;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define MAX 1e15+1
#define pi  pair<int,int>

int hp[3][200000];

signed main(){
	
	int n;
	cin>>n;
	
	
	for(int i=0;i<n;i++){
		int a,b,c;
		cin>>a>>b>>c;
		if(i==0){
			hp[0][0]=a;
			hp[1][0]=b;
			hp[2][0]=c;
		}
		else{
			hp[0][i]=a+max(hp[1][i-1],hp[2][i-1]);
			hp[1][i]=b+max(hp[0][i-1],hp[2][i-1]);
			hp[2][i]=c+max(hp[1][i-1],hp[0][i-1]);
		}
		
	}
	cout<<max( hp[1][n-1],max( hp[0][n-1],hp[2][n-1] ) );


	


	

}

 


Measured memory_bytes: 3584
diagram = gets.chomp.chars

search = ->{
  max = min = height = 0
  diagram.each_with_index do |x, i|
    case x
    when "\\"
      height -= 1
      min = height if height < min
    when "/"
      height += 1
      max = height if height > max
    end
  end
  [max - min, max]
}

n, level = search.()
table = Array.new(n) {[]}

diagram.each_with_index do |x, i|
  case x
  when "\\"
    table[level] << i
    level += 1
  when "/"
    level -= 1
    a = table[level].last
    table[level] << i if a
  end
  table
end
table.map! do |one_level|
  ar = []
  one_level.each_slice(2) {|x| ar << x}
  ar.select {|x| x.size == 2}
end

exist = ->(pair, level) {
  area = pair[1] - pair[0]
  return area if level == n
  table1 = table[level]
  table[level].each do |downer_pair|
    if pair[0] < downer_pair[0] and downer_pair[1] < pair[1]
      table1 -= [downer_pair]
      area += exist.(downer_pair, level + 1)
    end
  end
  table[level] = table1
  area
}

pools = []
calc_area = ->{
  min = [[Float::INFINITY, 0], 0]
  table.each_with_index do |one_level, i|
    next if one_level.empty?
    pair = one_level[0]
    min = [pair, i] if pair[0] < min[0][0]
  end
  table[min[1]] -= [min[0]]
  pools << exist.(min[0], min[1] + 1)
  calc_area.() unless table.flatten.empty?
}

calc_area.() unless table.empty?

if pools == [-Float::INFINITY] or pools.empty?
  puts 0, 0
else
  puts pools.inject(&:+)
  puts pools.size.to_s + " " + pools.join(" ")
end


Measured memory_bytes: 123840
#include <cstdio>
#include <vector>
#include <algorithm>
#include <stack>
#include <functional>
#include <cassert>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;

/**
 * @brief strongly connected components decomposition, Kosaraju's algorithm, optimized
 * @return the pair (the number k of components, the function from vertices of g to components)
 * @note O(V + E)
 */
pair<int, vector<int> > decompose_to_strongly_connected_components(vector<vector<int> > const & g) {
    int n = g.size();
    auto & to = g;
    vector<vector<int> > from(n);
    repeat (i, n) for (int j : to[i]) from[j].push_back(i);
    vector<int> acc(n); {
        auto it = acc.rbegin();
        vector<int> used(n, -1);
        stack<int> stk;
        repeat (k, n) if (used[k] == -1) {
            stk.push(k);
            used[k] = 0;
            while (not stk.empty()) { // dfs
                int i = stk.top();
                while (used[i] < to[i].size()) {
                    int j = to[i][used[i]];
                    ++ used[i];
                    if (used[j] == -1) {
                        stk.push(j);
                        used[j] = 0;
                        break;
                    }
                }
                if (stk.top() == i) {
                    *(it ++) = i;
                    stk.pop();
                }
            }
        }
    }
    int count = 0;
    vector<int> component_of(n); {
        vector<bool> used(n);
        stack<int> stk;
        for (int k : acc) if (not used[k]) {
            stk.push(k);
            used[k] = true;
            while (not stk.empty()) { // dfs
                int i = stk.top(); stk.pop();
                component_of[i] = count;
                for (int j : from[i]) if (not used[j]) {
                    stk.push(j);
                    used[j] = true;
                }
            }
            ++ count;
        }
    }
    return { count, move(component_of) };
}

int main() {
    int v, e; scanf("%d%d", &v, &e);
    vector<vector<int> > g(v);
    repeat (i, e) {
        int s, t; scanf("%d%d", &s, &t);
        g[s].push_back(t);
    }
    vector<int> c = decompose_to_strongly_connected_components(g).second;
// vector<int> c = strongly_connected_components::decompose(g).second;
    int query; scanf("%d", &query);
    while (query --) {
        int u, v; scanf("%d%d", &u, &v);
        printf("%d\n", int(c[u] == c[v]));
    }
    return 0;
}

Measured memory_bytes: 3476
# include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;
int w, h, ans;

template <typename T>
void show_all(T t) {
  rep (i, t.size()) {
    rep (j, t[0].size()) {
      cout << setfill('0') << setw(5) << t[i][j] << ' ';
    }
    cout << endl;
  }
  cout << endl;
}


void dfs(vector<vector<int>> &c, int i, int j) {
  vector<int> next_i = {0, 1, 1, 1, 0, -1, -1, -1};
  vector<int> next_j = {1, 1, 0, -1, -1, -1, 0, 1};

  rep (k, 8) {
    int ii = i + next_i[k];
    int jj = j + next_j[k];

    if (0 <= ii && 0 <= jj && ii < c.size() && jj < c[0].size() && c[ii][jj] == 1) {
      c[ii][jj] = 1000;
      dfs(c, ii, jj);
    }
  }
}


int main() {

  while (cin >> w >> h && w && h) {
    vector<vector<int>> c;
    ans = 0;

    rep (i, h) c.push_back(vector<int>(w));
    rep (i, h) {
      rep (j, w) {
        cin >> c[i][j];
      }
    }

    rep (i, h) {
      rep (j, w) {
        if (c[i][j] == 1) {
          ans++;
          c[i][j] = 1000;
          dfs(c, i, j);
        }
      }
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 3352
from itertools import permutations
from math import sqrt

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

ans = []
for paths in permutations(range(n)):
    x = xy[paths[0]][0]
    y = xy[paths[0]][1]
    dist = 0
    for i in paths[1:]:
        x2 = xy[i][0]
        y2 = xy[i][1]
        dist += sqrt((x2 - x) ** 2 + (y2 - y) ** 2)
        x, y = x2, y2
    ans.append(dist)

print(sum(ans) / len(ans))


Measured memory_bytes: 4400
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int con = 0;
	int a = 0;
	string s;
	
	cin>>s;
	
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'x') con++;
	}
	
	cout<<YN(15-con >= 8)<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    for(int i=0;i<n;i++)s[i]-='0';
    int dp[n+1][2][2][2][2][2]={};//i桁目まで見て、3,5,7をそれぞれ使ったか、4方向遷移が可能か、0以外が現れたか
    dp[0][0][0][0][1][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<=1;j++){
            for(int k=0;k<=1;k++){
                for(int l=0;l<=1;l++){
                    for(int m=0;m<=1;m++){
                        dp[i+1][min(1,j+1)][k][l][0][min(1,m+1)]+=dp[i][j][k][l][0][m];
                        dp[i+1][j][min(1,k+1)][l][0][min(1,m+1)]+=dp[i][j][k][l][0][m];
                        dp[i+1][j][k][min(1,l+1)][0][min(1,m+1)]+=dp[i][j][k][l][0][m];
                        if(s[i]==3)dp[i+1][min(1,j+1)][k][l][1][min(1,m+1)]+=dp[i][j][k][l][1][m];
                        if(s[i]>3){
                            dp[i+1][min(1,j+1)][k][l][0][min(1,m+1)]+=dp[i][j][k][l][1][m];
                            if(s[i]==5)dp[i+1][j][min(1,k+1)][l][1][min(1,m+1)]+=dp[i][j][k][l][1][m];
                            if(s[i]>5){
                                dp[i+1][j][min(1,k+1)][l][0][min(1,m+1)]+=dp[i][j][k][l][1][m];
                                if(s[i]==7)dp[i+1][j][k][min(1,l+1)][1][min(1,m+1)]+=dp[i][j][k][l][1][m];
                                if(s[i]>7)dp[i+1][j][k][min(1,l+1)][0][min(1,m+1)]+=dp[i][j][k][l][1][m];
                            }
                        }
                    }
                    dp[i+1][j][k][l][0][0]+=dp[i][j][k][l][0][0];
                    if(s[i]==0)dp[i+1][j][k][l][1][0]+=dp[i][j][k][l][1][0];
                    else dp[i+1][j][k][l][0][0]+=dp[i][j][k][l][1][0];
                }
            }
        }
    }
    cout<<dp[n][1][1][1][0][1]+dp[n][1][1][1][1][1]<<endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine

solve :: [Integer] -> String
solve argList = hSolve (l - r)
    where
        l = sum $ take 2 argList
        r = sum $ take 2 $ drop 2 argList

hSolve :: Integer -> String
hSolve 0 = "Balanced"
hSolve n = if n > 0
           then "Left"
           else "Right"

main = do
    argList <- getIntList
    putStrLn $ solve argList

Measured memory_bytes: 380
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	int a[n+1]={0};
	for(int i = 0,j,k; i<m;i++)
	{
		cin>>j>>k;
		a[j]++;
		a[k]++;
	}
	for(int i = 1; i<=n; i++)
		cout<<a[i]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

main(){

  int i, left, right, mid, n, q, count = 0, S[100000], T[50000]\
;

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

  scanf("%d", &q);
  for(i = 0;i < q;i++){
    scanf("%d", &T[i]);
    left = 0;
    right = n;
    while(left < right){
      mid = (left + right) / 2;
      if(T[i] == S[mid]){
        count++;
        break;
      }
      if(T[i] > S[mid]){
        left = mid + 1;
      }
      else if(T[i] < S[mid]){
        right = mid;
      }
    }
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 1184
#include <cstdio>

using namespace std;

#define abs(x)((x) < 0 ? (x) * -1 : (x))

typedef long long ll;

int main() {
	long N, x;
	
	scanf("%ld %ld", &N, &x);
	
	long candies;
	ll ateN = 0;
	ll ateThisTurn = 0;
	long remain = 0;
	
	long i;
	
	for (i = 0; i < N; i++) {
	    scanf("%ld", &candies);
	    
	    if (x < candies + remain) {
	        ateThisTurn = candies - x;
	    
	        ateThisTurn += remain;
	        ateN += ateThisTurn;
	    }
	    
	    remain = candies - ateThisTurn;
	    ateThisTurn = 0;
	}
	
	printf("%lld\n", ateN);
	
	return 0;
}


Measured memory_bytes: 256
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define int long long
#define sz(x) (int)x.size()
#define d double
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n, k, a, ans = 0;
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a;
		if(a >= k)
			ans++;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1e9+7;
int n;
ll A[51][51], T[51][51], R[51][51], k;

void mul(ll A[][51], ll B[][51], ll C[][51]) {
    int i, j, k;
    for (i=0;i<n;i++) {
        for (j=0;j<n;j++) {
            T[i][j] = 0;
            for (k=0;k<n;k++) T[i][j]=(T[i][j]+A[i][k]*B[k][j])%MOD;
        }
    }
    for (i=0;i<n;i++) for (j=0;j<n;j++) C[i][j] = T[i][j];
}

int main() {
    int i, j;

    scanf("%d%lld",&n,&k);
    for (i=0;i<n;i++) for (j=0;j<n;j++) scanf("%lld",&A[i][j]);
    for (i=0;i<n;i++) R[i][i] = 1;
    for (i=0;k>>i;i++);
    for (i--;~i;i--) {
        mul(R,R,R);
        if (k>>i&1) mul(R,A,R);
    }
    ll ans = 0;
    for (i=0;i<n;i++) for (j=0;j<n;j++) ans = (ans+R[i][j])%MOD;
    printf("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
    int main(){
        int a, b, ans = 0, i;
        
        scanf("%d %d", &a, &b);
        
        for(i = 0; i < 2; i++){
            if(a >= b){
                ans = ans + a;
                a = a - 1;
            }else if(a <= b){
                ans = ans + b;
                b = b - 1;
            }
        }
        printf("%d\n", ans);
        
    }

Measured memory_bytes: 1668
#include <iostream>
using namespace std;
int main(void){
    while(true){
        int m,f,r;
        cin >> m >> f >> r;
        if(m==-1 && f == -1 && r == -1)break;
        
        if(m == -1 || f == -1) cout << "F";
        else if(m + f >= 80) cout << "A";
        else if(m + f >= 65) cout << "B";
        else if(m + f >= 50) cout << "C";
        else if(m + f >= 30 && r >= 50) cout << "C";
        else if(m + f >= 30) cout << "D";
        else cout << "F";
        
        cout << endl;

    }
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    string s;
    int K;
    cin >> s >> K;
    int N = s.size();
    vector<string> vec;
    FOR(len,1,K+1)
    {
        REP(i,N+1-len)
        {
            vec.pb(s.substr(i,len));
        }
    }
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(),vec.end()), vec.end());
    cout << vec[K-1] << endl;


}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements < num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define int long long int
//Binary_Search->dp->greedy
//auto check = [&](ll x){};
void solve(){
	int n;
	cin>>n;
	ll ans=0;
	for(int i=1;i<=n;i++){
		if(i%3 && i%5) ans+=i;
	}
 
	cout<<ans<<endl;
}
int main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
return 0;
}    
 

Measured memory_bytes: 3636