akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(void)
{
	int x[4][13],a,i,j,n;
	char card;
	
	for (i = 0; i < 4; i++)
	{
		for (j = 0; j < 13; j++)
		{
			x[i][j] = j + 1;
		}
	}
	
	scanf("%d", &n);

	for (a = 0; a < n; a++)
	{
		scanf("%c", &card);
		scanf("%c %d", &card, &j);
		if (card == 'S')
		{
			x[0][j - 1] = 0;
		}
		if (card == 'H')
		{
			x[1][j - 1] = 0;
		}
		if (card == 'C')
		{
			x[2][j - 1] = 0;
		}
		if (card == 'D')
		{
			x[3][j - 1] = 0;
		}

	}
	for (i = 0; i < 4; i++)
	{
		for (j = 0; j < 13; j++)
		{
			if (x[i][j] != 0)
			{
				if (i == 0)
				{
					printf("S %d\n", x[i][j]);
				}
				if (i == 1)
				{
					printf("H %d\n", x[i][j]);
				}
				if (i == 2)
				{
					printf("C %d\n", x[i][j]);
				}
				if (i == 3)
				{
					printf("D %d\n", x[i][j]);
				}

			}
		}
	}

	return 0;
}


Measured memory_bytes: 2052
#include<iostream>
#include <cmath>
#include <limits>
using namespace std;
int main(){
  long N;
  cin>>N;
  long double A[N];
  long long x;
  long double sum=0;
  for(long long i=0;i<N;i++){
    cin>>x;
    if(x==0){
      cout<<0;
      return 0;
    }
    A[i]=x;
    sum+=(long double)log10l((double)A[i]);
  }
  if(sum>18){
    cout<<(-1);
    return 0;
  }else{
    unsigned long long pow=1;
    for(long long i=0;i<N;i++){
      pow*=A[i];
    }
    if(pow>1000000000000000000){
      cout<<(-1);
    }else{
      cout<<pow;
      return 0;
    }
    
  }
  return 0;
}

Measured memory_bytes: 5244
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main() {
    int n;
    cin >> n;
    int a[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int ans[n + 1];
    memset(ans, 0, sizeof(ans));
    for (int i = n; i >= 1; i--) {
        int start = 1;
        ll sum = 0;
        while (i * start <= n) {
            sum += ans[i * start];
            start++;
        }
        if (sum % 2 != a[i]) {
            ans[i] = 1 ;
        }
    }
    vector<int> vec;
    for (int i = 1; i <= n; i++) {
        if (ans[i]) {
            vec.push_back(i);
        }
    }
    cout << vec.size() << endl;
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5316
#include<bits/stdc++.h>
using namespace std;
int main()
{
     int tt;
     long long a=0,t=0,r=0,w=0;
     cin>>tt;
     while(tt--)
     {
       string s;
       cin>>s;
       if(s=="AC")
         a++;
       else if(s=="TLE")
         t++;
       else if(s=="RE")
         r++;
       else
         w++;
     }
    cout<<"AC x "<<a<<"\n"<<"WA x "<<w<<"\n"<<"TLE x "<<t<<"\n"<<"RE x "<<r<<"\n";
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void){
  int peopleN, kindM;
  int answerK;
  int counter=0;
  int answerKA;
  scanf("%d %d\n", &peopleN, &kindM);
  int answerbool[kindM];
  for (int i=0; i<kindM; i++){
      answerbool[i]=0;
  }
  for(int i=0; i<peopleN; i++){
      scanf("%d", &answerK);
      for(int j=0; j<answerK; j++){
          scanf("%d", &answerKA);
          if (i==0){
            answerbool[answerKA-1]++;
            continue;
          }
          else{
            if (answerbool[answerKA-1]==1){
                answerbool[answerKA-1]++;
            }
          }
      }
      if (i==0){
          continue;
      }
      else{
        for (int j=0; j<kindM; j++){
            answerbool[j]--;
        }
      }
  }
  for (int i=0; i<kindM; i++){
      if (answerbool[i]>=1){
          counter++;
      }
  }
  printf("\n%d", counter);
}

Measured memory_bytes: 128
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "unsafe" : "safe") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll s, w;
  cin >> s >> w;
  Pr(s<=w);
}


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

int main(){
  int n;
  cin >>n;
  vector<int> a(n);
  rep(i,n-1) cin >>a[i];
  int num[n] = {0};
  for(int i = 0; i < n; i++){
    num[a[i]-1]++;
  }
  for(int i = 0; i < n; i++){
    cout << num[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  int tmp = 1;
  rep(i, N) {
    if(A[i] == tmp) tmp++;
  }
  if(tmp == 1) cout << -1 << endl;
  else cout << N-tmp+1 << endl;
  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
int n, m;
int main()
{
	cin >> n >> m;
	vector<ll> a(n,0),b(m,0);
	for(int i=0;i<n;++i) cin >> a[i];
	for(int i=0;i<m;++i) cin >> b[i];
	auto c = convolution<998244353>(a,b);
	for(auto x : c){
		cout<<x<<' ';
	}
	cout<<'\n';
	return 0;
}


Measured memory_bytes: 27256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N;

  vector<int> dp(N+1,1e9);
  dp.at(0)=0;
  rep(i,N){
    chmin(dp.at(i+1),dp.at(i)+1);
    for(int j=6;i+j<N+1;j*=6) chmin(dp.at(i+j),dp.at(i)+1);
    for(int j=9;i+j<N+1;j*=9) chmin(dp.at(i+j),dp.at(i)+1);
  }
  cout << dp.at(N) << endl;

  return 0;
}

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

#define println(msg) cout << msg << endl
#define yes_or_no(flag) if (flag) { println("Yes"); } else { println("No"); }

int main() {
  // 入力
  int N, A, B;
  cin >> N >> A >> B;

  // 計算
  int sum = 0;
  for (int i = 1; i <= N; i++) {
    int s = 0;
    for (int n = i; n > 0; n/=10) {
      s += (n % 10);
    }
    if (A <= s && s <= B) {
      sum += i;
    }
  }
  
  // 出力
  println(sum);
}

Measured memory_bytes: 3580
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        h: usize, w: usize,
        s: [Chars; h],
    }

    let mut ans = vec![vec!['#'; w]; h];

    let directions = [(0, 1), (1, 0), (-1, 0), (0, -1), (1, 1), (1, -1), (-1, 1), (-1, -1)];

    for x in 0..w {
        for y in 0..h {
            if s[y][x] == '#' { continue; }
            let mut cnt = 0;
            for &(dx, dy) in directions.iter() {
                let (cx, cy) = (x as isize + dx, y as isize + dy);
                if cx < 0 || cy < 0 || cx >= w as isize || cy >= h as isize {continue;}
                if s[cy as usize][cx as usize] == '#' {
                    cnt += 1;
                }
            }
            ans[y][x] = std::char::from_digit(cnt, 10).unwrap();
        }
    }

    println!("{}", ans.iter().map(|x| x.iter().join("")).join("\n"));
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


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

public class Main {
	public static void main(String[] args) throws Exception {

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String line = reader.readLine();
		int N = Integer.parseInt(line);
		line = reader.readLine();
		String[] str = line.split(" ");
		int[] dam = new int[N];
		long[] yama = new long[N];
		for (int i = 0; i < N / 2; i++) {
			dam[2*i] = Integer.parseInt(str[2*i]);
			dam[2*i+1] = Integer.parseInt(str[2*i+1]);
			yama[0] += dam[2*i];
			yama[0] -= dam[2*i+1];
		}
		dam[N-1] = Integer.parseInt(str[N-1]);
		yama[0] += dam[N-1];
		System.out.print(yama[0] + " ");
		
		//yama[4] = 2*dam[3] - yama[3];
		for (int i = 0; i < N / 2; i++) {
			yama[2*i+1] = 2*dam[2*i] - yama[2*i];
			System.out.print(yama[2*i+1] + " ");
			yama[2*i+2] = 2*dam[2*i+1] - yama[2*i+1];
			System.out.print(yama[2*i+2] + " ");
		}
	}
}


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

#define all(x) (x).begin(), (x).end()
#define int long long
const int MOD = 1e9 + 7;
int mul(int a, int b) {
    return (a * b) % MOD;
}
int pw(int a, int b) {
    if (b == 0) return 1;
    if (b == 1) return a;
    if (b % 2 == 0) {
        int x = pw(a, b / 2);
        return mul(x, x);
    }
    return mul(a, pw(a, b - 1));
}
int n, k;
vector<int> dp;
void calc(int id) {
    if (dp[id] != -1) return;
    dp[id] = pw(id, n);
    for (int gc = 2; gc <= id; ++gc) {
        calc(id / gc);
        dp[id] = (dp[id] - dp[id / gc] + MOD) % MOD;
    }
}
signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    int ans = 0;
    dp.resize(k + 1, -1);
    dp[1] = 1;
    for (int g = 1; g <= k; ++g) {
        calc(k / g);
        ans += g * dp[k / g];
        ans %= MOD;
    }
    cout  << ans;
}


Measured memory_bytes: 3984
//============================================================================
// Name        : AOJ.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	auto i=0;
	int a,b;
	cin>>a>>b;
	cout << (a+b)/2<< endl; // prints !!!Hello World!!!
	return 0;
}

Measured memory_bytes: 3072
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
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)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
L = list(accumulate(LI() + [0]))
ret = INF
for second_point in range(2, n-1):
    left_sum = L[second_point - 1]
    right_sum = L[-1] - left_sum
    if L[bisect_left(L, left_sum/2)] - left_sum/2 < left_sum/2 - L[bisect_left(L, left_sum/2) - 1] or not bisect_left(L, left_sum/2):
        p = L[bisect_left(L, left_sum/2)]
    else:
        p = L[bisect_left(L, left_sum/2) - 1]
    q = left_sum - p
    if L[bisect_left(L, left_sum + right_sum/2)] - right_sum/2 - left_sum < left_sum + right_sum/2 - L[bisect_left(L, left_sum + right_sum/2) - 1]:
        s = L[-1] - L[bisect_left(L, left_sum + right_sum/2)]
    else:
        s = L[-1] - L[bisect_left(L, left_sum + right_sum/2) - 1]
    r = right_sum - s
    ret = min(ret, max(p, q, r, s) - min(p, q, r, s))


print(ret)

Measured memory_bytes: 86264
#include<iostream>
using namespace std; // 575

int main() {
	int N, C[20], V[20];
	cin >> N;
	int ans = 0;
	for (int i = 0;i < N;++ i) cin >> C[i];
	for (int i = 0;i < N;++ i) cin >> V[i];
	for (int i = 0;i < N;++ i) {
		ans += max(0, C[i] - V[i]);
	}
	cout << ans;
	
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

*/

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.next();
        String []PARTS = {"dream","dreamer","erase","eraser"};
        boolean flag = true;
        boolean able = true;
        int cnt = 0;
        while(flag) {
            flag = false;
            if (input.regionMatches(input.length()-5-cnt,PARTS[0],0,5)||input.regionMatches(input.length()-5-cnt,PARTS[2],0,5)){

                        cnt +=5;
                        flag = true;
            }
            else{
                if (input.regionMatches(input.length()-6-cnt,PARTS[3],0,6)){
                    cnt+=6;
                    flag = true;
                }
                else{
                    if (input.regionMatches(input.length()-7-cnt,PARTS[1],0,7)){
                        cnt+=7;
                        flag = true;
                    }
                }
            }
            if (input.length()==cnt) able =true;
            else able = false;
        }

        if(able){
            System.out.println("YES");
        }
        else{
            System.out.println("NO");
        }

        sc.close();

    }

}


Measured memory_bytes: 13968
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();sc.nextLine();
        while(n-- != 0) {
            System.out.println(sc.nextLine().replace("Hoshino", "Hoshina"));
        }
    }
}



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

int main()
{
  string S, s, r;
  int N;
  bool strong = true;
  cin >> S;
  r = S;
  N = S.length();
  reverse(r.begin(), r.end());

  if (S != r)
    strong = false;

  s = S.substr(0, (N - 1) / 2);
  r = s;
  reverse(r.begin(), r.end());

  if (s != r)
    strong = false;

  s = S.substr((N + 3) / 2 - 1, N - (N + 3) / 2 + 1);
  r = s;
  reverse(r.begin(), r.end());

  if (s != r)
    strong = false;

  if (strong)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
int pr[15],kn[15][15];
int main()
{
	int n,m,x;
	cin>>n>>m>>x;
	for(int i=0;i<n;i++)
	{
		cin>>pr[i];
		for(int j=0;j<m;j++)
		{
			cin>>kn[i][j];
		}
	}
	bool key=false;
	int ans=1e9;
	for(int i=1;i<(1<<n);i++){
		vector<int> cnt(m,0);
		int p=0;
		for(int j=0;j<n;j++)
		{
			if((i>>j)&1==1){
				p+=pr[j];
				for(int v=0;v<m;v++)
				{
					cnt[v]+=kn[j][v];
				}
			}
		}
		bool h=true;
		for(int j=0;j<m;j++)
		{
			if(cnt[j]<x)h=false;
		}
		key=h;
		if(h){
			ans=min(ans,p);
		}
	}
	if(key){
		cout<<ans<<endl;
	}
	else{
		cout<<"-1"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3636
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    ll n,m,ans=0; cin>>n>>m;
    vector<pair<ll,ll>> ma(n);
    rep(i,n){
        ll a,b; cin>>a>>b;
        ma[i]=mk(a,b);
    }
    sort(al(ma));
    ll i=0;
    while(m>0){
        ans+=ma[i].first*min(ma[i].second,m);
        m-=ma[i].second; i++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<numeric>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<utility>
#include<sstream>
#include<complex>
#include<fstream>
#include<bitset>
#include <iostream>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
ll h, w, c;
int dx[4] = { 0,1 ,0 ,-1};
int dy[4] = { 1,0 ,-1, 0};

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

bool value(int x, int y, int w, int h) {
	return 0 <= x && x < w && 0 <= y && y < h;
}

int ccount(int x, int y, int c,vector<vector<int>> &v,vector<vector<bool>> &f) {
	if (!value(x,y,h,w) || f[x][y]) return 0;
	f[x][y] = true;
	int res = 1;
	rep(i, 4) {
		int nx = x + dx[i], ny = y + dy[i];
		if (value(nx, ny, h, w) && c == v.at(nx).at(ny)) {
			res += ccount(nx, ny, c,v,f);
		}
	}
	return res;
}

void change(int x, int y, int c, int nc,vector<vector<int>> &v,vector<vector<bool>> &f) {
	if (!value(x,y,h,w) || f[x][y]) return;
	f[x][y] = true;
  v[x][y] = nc;
	rep(i, 4) {
		int nx = x + dx[i], ny = y + dy[i];
		if (value(nx, ny, h, w) && c == v.at(nx).at(ny)) {
      change(nx, ny, c, nc,v,f);
		}
	}
}

int ans = 0;
void solve(int k, int c,vector<vector<int>> v,vector<vector<bool>> f) {
	if (k == 4) {
    vector<vector<bool>> f2(h,vector<bool>(w,false));
		change(0, 0, v[0][0], c,v,f2);
      /* cout << "F" << endl;    */
      /* rep(u,h){               */
      /* rep(j,w){               */
      /* cout << v[u][j] << ' '; */
      /* }                       */
      /* cout << endl;           */
      /* }                       */
    vector<vector<bool>> f3(h,vector<bool>(w,false));
		ans = max(ans, ccount(0, 0, c,v,f3));
	}
	else if(k < 5){
		int C = v[0][0];
    auto b = v;
    auto u = f;
		rep(i, 6) {
			if (i+1 == C) continue;
      rep(i,h){
        rep(j,w){
          f[i][j] = false;
        }
      }
			change(0, 0, C, i+1,v,f);
      /* cout << endl;           */
      /* rep(u,h){               */
      /* rep(j,w){               */
      /* cout << v[u][j] << ' '; */
      /* }                       */
      /* cout << endl;           */
      /* }                       */
			solve(k + 1, c,v,f);
      v = b;
      f = u;
		}
	}
};

int main() {
	while (cin >> h >> w >> c, h + w + c) {
    vector<vector<int> > v;
    vector<vector<bool>> f(h,vector<bool>(w,false));
		v.resize(h);
		ans = 0;
		rep(i, h) {
			v[i].resize(w);
			rep(j, w) {
				cin >> v[i][j];
				f[i][j] = false;
			}
		}
		solve(0, c,v,f);
		cout << ans << endl;
	}
	return 0;
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  int N, M;
  cin >> N >> M;
  int k[M], s[M][15];
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) cin >> s[i][j];
  }
  int p[M];
  for (int i = 0; i < M; i++) cin >> p[i];

  // 全探索
  int ans = 0;
  for (int i = 0; i < (1 << N); i++) {
    bool on[N];
    fill(on, on + N, false);
    for (int j = 0; j < N; j++) {
      if ((i >> j) & 1) on[j] = true;
    }

    int tmp = 0;
    for (int j = 0; j < M; j++) {
      int cnt = 0;
      for (int l = 0; l < k[j]; l++) {
        if (on[s[j][l]-1]) cnt++;
      }
      if (cnt % 2 == p[j]) tmp++;
    }
    if (tmp == M) ans++;
  }

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


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
	int N,M,K,l,A[100]={},ans;
	cin>>N>>M;
	for(int i=0;i<N;i++){
		cin>>K;
		for(int i=0;i<K;i++){
			cin>>l;
			A[l]++;
		}
	}
	for(int i=1;i<=M;i++){
		if(A[i]==N){
			ans++;
			
		}
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int ban[90][90];
int ban2[90][90];
int n,m;
int Max = 0;

int saiki(int y, int x, int cont)
{
	//Xðé
	ban2[y][x] = 0;
	/*
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cout << ban2[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl;
*/
	cont++;
//		getchar();
	
	//ì¨k¨¨¼Ì

	if(ban2[y+1][x] == 1 && (y+1) < n){
			saiki(y+1,x,cont);
			ban2[y+1][x] = 1;
	}
	if(ban2[y-1][x] == 1 && (y-1) >= 0){
			saiki(y-1,x,cont);
			ban2[y-1][x] = 1;
	}
	if(ban2[y][x+1] == 1 && (x+1) < m){
			saiki(y, x+1, cont);
			ban2[y][x+1] = 1;
	}
	if(ban2[y][x-1] == 1 && (x-1) >= 0){
			saiki(y, x-1, cont);
			ban2[y][x-1] = 1;
	}
	
	if(Max < cont){
		Max = cont;
	}
	return cont;
}

int main()
{
	for(;;){
		int cont = 0;
		Max = 0;
		cin >> m >> n;
		
		if(m == 0 && n == 0){
			break;
		}
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				ban2[i][j] = ban[i][j] = 0;
			}
		}
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				cin >> ban[i][j];
				ban2[i][j] = ban[i][j];
			}
		}
		
		/*
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				cout << ban[i][j];
			}
			cout << endl;
		}
		*/
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				if(ban[i][j] == 1){
					cont = saiki(i,j,0);
					
					for(int i = 0; i < n; i++){
						for(int j = 0; j < n; j++){
							ban2[i][j] = ban[i][j];
						}
					}
				}
			}
		}
		
		
	//	saiki(0,0,0);
		
		cout << Max << endl;
	}
}

Measured memory_bytes: 924
n,m = (int(x) for x in input().split())
rane = [[]  for i in range(n)]

def getRane():
    index = 0
    min = 9999
    for i in range(0,n):
        if min > len(rane[i]):
            min = len(rane[i])
            if min == 0:
                return i
            index = i
    return index

for i in range(0,m):
    c,num = (int(x) for x in input().split())
    # 給油終了
    if c == 0:
        num -= 1
        print(rane[num][0])
        rane[num].pop(0)
    # スタンドに入る
    else:
        index = getRane()
        rane[index].append(num)


Measured memory_bytes: 6024
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int MAXN = 1234567;
char s[MAXN];
int sx[4] = {-1, 1, 0, 0}, sy[4] = {0, 0, -1, 1};

struct Node {
    int x, y, val;
    Node(int _x, int _y, int _v) : x(_x), y(_y), val(_v) {}
    bool operator < (const Node &a) const {
        return val > a.val;
    }
};

bool check(int x, int y, int H, int W) {
    if (x < 0 || y < 0 || x >= H || y >= W) return false;
    return true;
}

int main() {
    int H, W, K;
    scanf("%d %d %d", &H, &W, &K);
    int x1, y1, x2, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    vector<vector<int>> maze(H, vector<int>(W, 0));
    vector<vector<int>> dis(H, vector<int>(W, -1));
    vector<vector<vector<int>>> visit(H, vector<vector<int>>(W, vector<int>(4, 0)));
    for (int i = 0; i < H; i++) {
        scanf("%s", s);
        for (int j = 0; j < W; j++) {
            if (s[j] == '.')
                maze[i][j] = 1;
        }
    }
    x1--, y1--, x2--, y2--;
    priority_queue<Node> pq;
    dis[x1][y1] = 0;
    pq.push(Node(x1, y1, 0));
    while (!pq.empty()) {
        auto tp = pq.top();
        pq.pop();
        int x = tp.x, y = tp.y;
        //printf("x = %d y = %d d = %d\n", x, y, dis[x][y]);
        for (int i = 0; i < 4; i++) {
            for (int j = 1; j <= K; j++) {
                int xx = x + j * sx[i], yy = y + j * sy[i];
                if (!check(xx, yy, H, W) || !maze[xx][yy] || (dis[xx][yy] != -1 && dis[xx][yy] <= dis[x][y]) || visit[xx][yy][i])
                    break;
                visit[xx][yy][i] = 1;
                if (dis[xx][yy] != -1 && dis[x][y] + 1 == dis[xx][yy]) continue;
                dis[xx][yy] = dis[x][y] + 1;
                pq.push(Node(xx, yy, dis[xx][yy]));
            }
        }
    }
    printf("%d\n", dis[x2][y2]);



    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
by Benq;
*/


Measured memory_bytes: 120584
#include <iostream>
using namespace std;
typedef long long int ll;
int main() {
	ll n,i,l[1000006];
	cin>>n;
	for(i=0;i<n;i++)
	cin>>l[i];
	ll dp[n];
	dp[0]=0;
	dp[1]=abs(l[1]-l[0]);
	for(i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(l[i]-l[i-1]),dp[i-2]+abs(l[i]-l[i-2]));
	}
	cout<<dp[n-1]<<endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3840
import java.io.*
import java.util.*

val pw = PrintWriter(System.out)
const val YES = "Yes"
const val NO = "No"
fun solve(N: Long, M: Long){
    if (N==M) println(YES) else println(NO)
    pw.flush()
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toLong()
    val M = sc.next().toLong()
    solve(N, M)
}



Measured memory_bytes: 29600
/*
    ~A_Pessimist~:)
*/

#include<bits/stdc++.h>
#define ll long long int
using namespace std;

const int sz=50000;
ll ans=-5e18;
vector<ll>vec;
ll p[sz],c[sz];
bool vis[sz];

void dfs(ll node, ll presum)
{
    if(vis[node]) return;

    vis[node]=true;

    presum+=c[node];

    vec.push_back(presum);

    dfs(p[node], presum);
}

void solve()
{
    ll n,k,i,j,rem,temp,mx=0,cycle;
    cin>>n>>k;
    for(i=0;i<n;i++)
    {
        cin>>p[i];
        p[i]--;
    }
    for(i=0;i<n;i++)
    {
        cin>>c[i];
    }
    for(i=0;i<n;i++)
    {
        memset(vis, false, sizeof vis);
        dfs(p[i],0);
        mx=-5e18;

        if(k>=vec.size() && vec.size() && vec.back()>0)
        {
            cycle=k/vec.size();
            rem=k%vec.size();

            temp=(cycle-1LL)*vec.back();

            for(j=0;j<vec.size();j++)
            {
                mx=max(mx, vec[j]);
            }
            ans=max(ans, temp+mx);

            mx=-5e18;

            for(j=0;j<rem;j++)
            {
                mx=max(mx, vec[j]);
            }

            temp=cycle*vec.back();

            ans=max(ans, temp+mx);
        }
        else
        {
            ll z=vec.size();
            for(j=0;j<min(z,k);j++)
            {
                ans=max(ans, vec[j]);
            }
        }
        vec.clear();
        temp=0;
    }
    cout<<ans<<endl;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t=1;
   // cin>>t;

    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 4056
N=input()
count = 0

for i in range(len(N)):
    P = int(N[i])
    if i%2 == 0:
        if P == 1:
            count += 1
    else:
        if P == 0:
            count += 1
N =str(N)
print(min([count,len(N)-count]))

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <cctype>
#include <cmath>
#include <stdio.h>
#define MAXSIZE 101
#define PI 3.141592653589
using namespace std;
int main(){
  double x1,y1,x2,y2;
  std::cin >> x1>>y1>>x2>>y2;
  printf("%.8f\n",sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
}

Measured memory_bytes: 3284
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <set>
#include <string.h>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

int gcd(int a, int b) {
  if (a < b) { swap(a, b); }
  if (b == 0) { return a; }
  return gcd(b, a % b);
}

bool prime(int n) {
  for (int i = 2; i <= sqrt(n); ++i) {
    if (n % i == 0) { return false; }
  }
  return n != 1;
}

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

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  int N, K;
  cin >> N >> K;
  vector<int> P(N);
  rep(i, N) {
    cin >> P[i];
  }

  // Check sorted.
  int cnt = 1;
  vector<int> cnts(N);
  cnts[0] = 1;
  for (int i = 1; i < N; ++i) {
    if (P[i-1] < P[i]) {
      ++cnt;
      cnts[i] = cnt;
    } else {
      cnt = 1;
      cnts[i] = cnt;
    }
  }
  vector<bool> sorted(N); // [i..i+K-1] is sorted
  for (int i = 0; i + K - 1 < N; ++i) {
    sorted[i] = (cnts[i + K - 1] == K);
  }

  int ans = 1;
  bool taken_identical = false;
  if (sorted[0]) { taken_identical = true; }

  set<int> st; // for min and max of [i+1..i+K-1]. This is the intersection of [i..i+K-1] and [i+1..i+K].
  // At first, set [1..K-1]
  for (int i = 1; i <= K-1; ++i) {
    st.insert(P[i]);
  }
  for (int l = 0, r = K; r < N; ++l, ++r) {
    if (P[l] < *st.begin() && *st.rbegin() < P[r]) {
      // The order of [l-1..r-1] and [l..r] is same after operation. So, do not increment ans.
    } else {
      if (sorted[l+1]) {
        // Skip if identical is already taken.
        if (!taken_identical) {
          taken_identical = true;
          ++ans;
        }
      } else {
        ++ans;
      }
    }
    st.erase(P[l+1]);
    st.insert(P[r]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 11264
from sys import stdin
import bisect
n = int(input())
ls = list(map(int,input().split()))
ls.sort()
 
ans = 0
for a in range(n-2):
    for b in range(a + 1, n-1):
        c = bisect.bisect_left(ls, ls[a] + ls[b])
 
        ans += c - 1 - b
print(ans)


Measured memory_bytes: 3188
//
//  main.cpp
//  ervb
//
//  Created by Kanak Gautam on 21/04/20.
//  Copyright © 2020 Kanak Gautam. All rights reserved.
//
 
 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <utility>
#define pb push_back
#define mk make_pair
#define endl "\n"
#define mod 998244353
using namespace std;
typedef long long int lli;
typedef long double ld;
priority_queue <lli, vector<lli>, greater<lli> > ti;
vector <lli> p[300005],a(300005),b(300005,0),f(500005,0);
lli vis[200005];
map <pair<lli,lli>,lli> mp;
set<pair<lli, lli> > s;
set<lli> st;
map<lli,lli> np,v;
queue<lli> qy;
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
lli bpow(lli a, lli b) {
    lli res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res%mod;
}
void fact(lli i)
{
    f[0]=1;
    for(lli k=1;k<=i;k++)
    {
        f[k]=(f[k-1]*k)%mod;
    }
}
lli isprime(lli n)
{
    if(n==1)
        return 0;
    for(lli i=2;i<=sqrt(n);i++)
        if(n%i==0)
            return 0;
    return 1;
}
bool cmp(lli i,lli j)
{
    return p[i].size()<p[j].size();
}
lli comb(lli n,lli i)
{
    lli g=f[n]*(bpow(f[i],mod-2))*bpow(f[n-i],mod-2);
    return g%mod;
}
lli permute(lli n, lli i)
{
    lli h=f[n-i];
    lli g=f[n]*(bpow(h,mod-2));
    return g%mod;
}
/*void sieve()
{
    for(lli i=2;i<=5000000;i++)
    {
        if(b[i]==0)
        {
        for(lli j=2;i*j<=5000000;j++)
        {
            b[i*j]=1;
        }
        }
    }
}*/
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    ld d,t,s;
    cin>>d>>t>>s;
    ld h=ceil(d/s);
    if(h<=t)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}



Measured memory_bytes: 18672
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cassert>
using namespace std;
#define MOD 1000000007

long long bipow(long long a, long long b){
    if(b == 0) return 1;
    if(b % 2) return (a * bipow(a, b-1)) % MOD;
    else{
        long long c = bipow(a, b/2);
        return (c * c) % MOD;
    }
}

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

    vector<long long> B(N+1);
    for(int i=1; i<=N; i++)
        B[i] = bipow(i, MOD-2);

    vector<long long> C(N+1);
    for(int i=1; i<=N; i++)
        C[i] = (C[i-1] + B[i]) % MOD;

    vector<long long> D(N);
    for(int i=0; i<N; i++)
        D[i] = ((C[N-i] + C[i+1]) % MOD + MOD - 1) % MOD;

    long long ans = 0;
    for(int i=0; i<N; i++)
        ans = (ans + (D[i] * A[i]) % MOD) % MOD;

    for(int i=1; i<=N; i++)
        ans = (ans * i) % MOD;

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


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

typedef long long ll;

int mod = 1e9 + 7;
ll p = 2e6 + 100;
vector<ll> com(p + 1);
vector<ll> inv(p + 1);
vector<ll> mul(p + 1);


ll power(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = (ans * a) % mod;
		}
		a = (a * a) % mod;
		b /= 2;
	}
	return ans;
}

ll C(ll n, ll k) {
	if (n < k || n < 0 || k < 0) return 0;
	ll maxm = max(k,n - k);
	ll minn = min(k,n - k);
	ll ans = 1;
	for (ll i = n; i > maxm; --i) {
		ans = (ans * i) % mod;
	}
	return (ans * mul[minn]) % mod;
}

int main() {	
	com[0] = 1;
	for (ll i = 1; i <= p; ++i) {
		com[i] = (com[i - 1] * i) % mod;
	} 
    inv[0] = 1;
    inv[1] = 1;
	for (ll i = 2; i <= p; ++i) {
		inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod; 
	}
	mul[0] = 1;
	for (int i = 1; i <= p; ++i) {
		mul[i] = (mul[i - 1] * inv[i]) % mod;
	}
	ll x, y;
	cin >> x >> y;
	if ((2 * x - y) % 3 != 0 || (2 * y - x) % 3 != 0) {
		cout << 0;
		return 0;
	} 
	ll a = (2 * x - y) / 3;
	ll b = (2 * y - x) / 3;
	cout << C(a + b, a);
}









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

using namespace std;

using ll = long long;

int n, ans;
const vector<int> add = {3, 5, 7};

void Solve(ll x, char flag) {
    if (n < x) return ;
    if (flag == 7) ++ans;

    for (int i = 0; i < 3; ++i) Solve(10 * x + add[i], flag | (1 << i));
}

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

    cin >> n;
    Solve(0, 0);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N,K;
int main(){
    cin >> N >> K;
    vector<int> h(N);
    rep(i,N) cin >> h[i];
    vector<int> dp(N+K*2);
    fill(ALL(dp),1e9);
    dp[0] = 0;
    rep(i,N) rep1(j,K) dp[i+j] = min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
    
    pr(dp[N-1]);
}

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

long long modpow(long long a, long long n, long long m) {
    if (n == 0) return 1;
    long long half = modpow(a, n/2, m);
    long long res = half * half % m;
    if (n & 1) res = res * a % m;
    return res;
}
using namespace std;
int main() {
    long long n;
    long long k;
    cin >> n >> k;
    long long res = modpow(n, 1, k);
    if (res > (k/2)) {
        cout << abs(k - res) << endl;
    } else {
        cout << res << endl;
    }
    return 0;
}


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

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]){
    cout << "YES"<< endl;
  }else{
    cout << "NO" << endl;
  }
}

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

int h,w,n;

struct POINT{
	int x;
	int y;
};

void copy(int map[31][31],int copymap[31][31]){
	for(int i=0;i<31;i++){
		for(int j=0;j<31;j++){
			copymap[i][j] = map[i][j];
		}
	}
}

bool solve(int map[31][31]){
	POINT deletemap[10000];

	for(int i=h-1;i>0;i--){
		for(int j=0;j<w;j++){
			if(map[i][j]==0){
				for(int k=1;i-k >= 0;k++){
					if(map[i-k][j] > 1){
						map[i][j] = map[i-k][j];
						map[i-k][j] = 0;
						break;
					}
				}
			}
		}
	}

	int count=0;
	int code;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(map[i][j] > 1){
				int num = 1;
				code = map[i][j];
				while(map[i][j+num] == code){
					num++;
				}
				if(n <= num){
					for(int k=0;k<num;k++){
						deletemap[count].x = j+k;
						deletemap[count].y = i;
						count++;
					}
				}

				num = 1;
				while(map[i+num][j] == code){
					num++;
				}
				if(n <= num){
					for(int k=0;k<num;k++){
						deletemap[count].x = j;
						deletemap[count].y = i+k;
						count++;
					}
				}
			}
		}
	}

	for(int i=0;i<count;i++){
		map[deletemap[i].y][deletemap[i].x] = 0;
	}

	bool flag  = true;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(map[i][j] > 1){
				flag = false;
			}
		}
	}
	if(flag){
		return true;
	}else if(count == 0){
		return false;
	}

	return solve(map);
}

int main(){	
	int map[31][31]={-1};
	int bufmap[31][31];
	char buf;
	bool ans = false;

	cin >> h >> w >> n;

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> buf;
			if(buf == '.'){
				map[i][j] = 0;
			}else{
				map[i][j] = buf;
			}
		}
	}

	for(int i=0;i<h;i++){
		for(int j=0;j<w-1;j++){
			if(map[i][j] == map[i][j+1]){
				continue;
			}
			
			copy(map,bufmap);
			int bufdata;
			bufdata = bufmap[i][j];
			bufmap[i][j] = bufmap[i][j+1];
			bufmap[i][j+1] = bufdata;
			
			ans = solve(bufmap);
			if(ans){
				break;
			}
		}
		if(ans){
			break;
		}
	}
	
	if(ans){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 0
// 0201
#include <iostream>
#include <vector>
#include <string>
using namespace std;

struct item{
	string name;
	int cost;
};

void update(vector<item> &I, vector<vector<int> > recipe, int m){
	for(int i=0;i<m;i++){
		for(int j=0;j<recipe.size();j++){
			if(recipe[j].size() != 0){
				int co = 0;
				for(int k=0;k<recipe[j].size();k++)
					co += I[recipe[j][k]].cost;

				if(I[j].cost > co)
					I[j].cost = co;
			}
		}
	}
}

int main(){
	while(1){
		int n, p;
		string str;
		item it;
		vector<item> I;

		cin>>n;
		if(n == 0)
			break;

		for(int i=0;i<n;i++){
			cin>>str>>p;
			it.name = str;
			it.cost = p;
			I.push_back(it);
		}

		int m, k;
		vector<vector<int> > recipe;

		recipe.resize(n);

		cin>>m;
		for(int i=0;i<m;i++){
			int l;
			cin>>str;
			
			for(int j=0;j<n;j++)
				if(str == I[j].name)
					l = j;

			cin>>k;
			for(int j=0;j<k;j++){
				cin>>str;
				for(int o=0;o<n;o++)
					if(str == I[o].name)
						recipe[l].push_back(o);
			}
		}

		update(I, recipe, m);

		cin>>str;
		for(int i=0;i<n;i++)
			if(str == I[i].name)
				cout<<I[i].cost<<endl;
	}
	return 0;
}

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

for i in range(1, n+1):
    if i%3 == 0:
        print(" {}".format(i),end = "")
    else:
        x = i
        while x:
            if x%10 == 3:
                print(" {}".format(i), end = "")
                break
            else:
                x //= 10
print("")


Measured memory_bytes: 5868
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define LL long long
#define uLL unsigned long long

uLL CP=((uLL)0xFFFFFFFF00000001);
uLL iCP=((uLL)0x100000001);
uLL B2=((uLL)0xFFFFFFFE00000001);
uLL iB=((uLL)0xFFFFFFFE00000001);
//-b<x<=0,0<y<a
uLL exgcd64(uLL a,uLL b,uLL *x,uLL *y)
{
	static uLL gcd;
	if (a==0)
	{
		*x=0;*y=1;
		return b;
	}
	else
	{
		gcd=exgcd64(b%a,a,y,x);
		*x-=(b/a)*(*y)+b;
		*y+=a;
		return gcd;
	}
}
//1B mod P = 0-P;
//B=2^64,P should better be odd (prime) number.
inline uLL MR(uLL a,uLL b)
{
	__asm__
	(
		"movq %[b],%%rax\n"
		"mulq %[a]\n"
		"movq %%rdx,%[a]\n"
		"mulq %[iCP]\n"
		"mulq %[CP]\n"
		"movq $0,%%rax\n"
		"subq %%rdx,%[a]\n"
		"cmovbq %[CP],%%rax\n"
		"addq %%rax,%[a]\n"
		:[a]"+&r"(a)
		:[b]"g"(b),[iCP]"r"(iCP),[CP]"r"(CP)
		:"%rax","%rdx"
	);
	return a;
}

uLL base[1000000],ibase[1000000];
//B --> 37,59,127,233,2011,0xFFFFFFFE
void iniBKDR(uLL B,uLL P,long size)
{
	uLL t,t2;
	long i;
	//if ((P!=CP)&&(P>((uLL)1<<56))) {ME(P);}
	exgcd64(CP,B,&t,&t2);
 	*base=0-CP;t=MR(B,B2);
	*ibase=0-CP;t2=MR(t2,B2);
	for (i=1;i<=size;i++)
	{
		base[i]=MR(base[i-1],t);
		ibase[i]=MR(ibase[i-1],t2);
	}
}
//str[i]<0xFFFFFFFF
//hash[0] must be zero
void BKDR(uLL *str,long l,long r,uLL *hash)
{
	uLL t1,t2;
	long i;
	*hash=0;
	for (i=l;i<=r;i++)
	{
		hash[i]=MR(str[i],base[i-1]);
		hash[i]=(CP-hash[i]>hash[i-1])?(hash[i]+hash[i-1]):(hash[i]+hash[i-1]-CP);
	}
}
static inline uLL bkdr(uLL *hash,long l,long r)
{
	uLL t;
	__asm__("movq %[r],%[t]\n""movq $0,%%rdx\n""subq %[l],%[t]\n""cmovbq %[CP],%%rdx\n""addq %%rdx,%[t]\n"
		:[t]"=&r"(t):[r]"g"(hash[r]),[l]"g"(hash[l-1]),[CP]"g"(CP):"%rdx");
	t=MR(t,ibase[l-1]);
	return t;
}
uLL hash1[1000000],hash2[1000000],bak1[1000000],bak2[1000000];
uLL map[1000][1000];

int main()
{
	//freopen("B.in","r",stdin);
	uLL i,j,k,l,ans,a,b,c,n,m;
	char ch;
	scanf("%llu",&n);
	for (i=1;i<=n;i++)
	{
		for (j=1;j<=n;j++)
		{
			while (1)
			{
				scanf("%c",&ch);
				if (isalpha(ch)!=0) {break;}
			}
			map[i][j]=ch-'a';
			map[i+n][j]=map[i][j];
			map[i+n][j+n]=map[i][j];
			map[i][j+n]=map[i][j];
		}
	}
	m=n;n=n*2;
	k=0;
	for (i=1;i<=n;i++)
	{
		for (j=1;j<=n;j++)
		{
			k+=1;
			bak1[k]=map[i][j];
			bak2[k]=map[j][i];
		}
	}
	iniBKDR(233,0,500000);
	BKDR(bak1,1,k,hash1);
	BKDR(bak2,1,k,hash2);
	ans=0;
	for (i=1;i<=m;i++)
	{
		for (j=1;j<=m;j++)
		{
			a=1;
			b=(i-1)*n+j;c=(j-1)*n+i;
			for (l=1;l<=m;l++)
			{
				//printf("%lld %lld\n",b,c);
				//printf("%llu %llu--\n",bkdr(hash1,b,b+m-1),bkdr(hash2,c,c+m-1));
				if (bkdr(hash1,b,b+m-1)!=bkdr(hash2,c,c+m-1)) {a=0;break;}
				b+=n;c+=n;
			}
			//printf("*%lld %lld %lld\n",i,j,a);
			ans+=a;
		}
	}
	printf("%llu\n",ans);
	return 0;
}

Measured memory_bytes: 37120
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int n, a;
	cin >> n >> a;
	if (n % 500 <= a)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n) {
      string item;
      cin >> item;
      mp[item]++;
    }
    
    cout << mp.size() << endl;
}

Measured memory_bytes: 19096
package main

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

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func sortString(s string) string {
	a := ""
	b := "abcdefghijklmnopqrstuvwxyz"
	for _, e := range b {
		num := strings.Count(s,string(e))
		for i := 0; i < num; i++ {
			a += string(e)
		}
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	
	n := scanInt()
	ss := make([]string, n)

	for i := 0; i < n; i++ {
		s := scanText()
		ss[i] = sortString(s)
	}

	sort.Strings(ss)

	ans := int64(0)
	pre := ""

	c := 0
	for _, e := range ss {
		if pre == e {
			c++
		} else {
			ans += int64((c+1)*c/2)
			c=0
		}
		pre = e
	}

	ans += int64((c+1)*c/2)

	fmt.Println(ans)

}


Measured memory_bytes: 6400