akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Combination {

public:
    vector<ll> fact;

    Combination(int max_n) {
        //1 ~ n!までの階乗modを求める
        int n = max_n;
        vector<ll> fact(n + 1);
        fact[0] = 1;
        for (int i = 1; i <= n; i++) {
            fact[i] = (fact[i - 1] * i) % MOD;
        }
        this->fact = fact;
    }

    template<typename T>
    //templateをつかってみｔか
    ll pow(T x, int y) {
        if (y == 0) return 1;
        if (y == 1) return x;
        if (y == 2) return (x * x) % MOD;
//        if (y % 2 == 1) return pow(x, y / 2) * pow(x, y / 2) % MOD;
        if (y % 2 == 1) return pow(pow(x, y / 2), 2) * x % MOD;
//        return pow(x, y / 2) * pow(x, y / 2) % MOD;
        return pow(pow(x, y / 2), 2) % MOD;
    }

    ll nCk(int n, int k) {
//        return (fact[n] * pow(fact[n-k],MOD-2) * pow(fact[k],MOD-2)) % MOD;
        return (((fact[n] * pow(fact[n - k], MOD - 2)) % MOD) * pow(fact[k], MOD - 2)) % MOD;
    }
};

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

    ll N, M;
    cin >> N >> M;

    Combination comb(2000000);
    vector<int> cnt;

    for (ll i = 2;; ++i) {
        int tmp = 0;
        while (M % i == 0) {
            M /= i;
            tmp++;
        }

        if (tmp > 0)cnt.push_back(tmp);
        if (i * i > M) {
            if (M > 1)cnt.push_back(1);
            break;
        }
    }

//    ll ans = comb.pow(2ll, cnt);
    ll ans = 1ll;
    for (auto e : cnt) {
        ll tmp = comb.nCk(e + N - 1, e);
        ans = 1ll * ans * tmp % MOD;
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 32120
n,m=map(int,input().split())
l=["!"*(m+2)]+["!"+input()+"!" for i in range(n)]+["!"*(m+2)]
ans=[["0" for i in range(m)] for c in range(n)] 
for i in range(n):
  for d in range(m):
    if l[i+1][d+1]==".":
      ret=0
      for a,b in[[1,1],[1,0],[0,1],[-1,-1],[-1,0],[0,-1],[1,-1],[-1,1]] :
        if l[i+1+a][d+1+b]=="#":
          ret+=1
        ans[i][d]=str(ret)
    else:ans[i][d]="#"
for i in range(n):
  print("".join(ans[i]))

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

int main() 
{
  unsigned long long A;
  string B;
  cin >> A >> B;
  int X = B[0] - '0';
  int Y = B[2] - '0';
  int Z = B[3] - '0';
  int C = 100 * X + 10 * Y + Z;
  cout << A * C / 100 << endl;
}

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

int main() {
  int length, breadth;
  cin >> length >> breadth;

  int area = length * breadth;
  int perimeter = (length + breadth) * 2;

  cout << area << " " << perimeter << endl;
  return 0;
}


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

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

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i,N) cin >> A[i];

  vector<vector<int>> cum(20, vector<int> (N + 1, 0));
  REP(j,N) {
    int tmp = A[j];
    REP(i, 20) {
      cum[i][j + 1] = cum[i][j] + (tmp % 2);
      tmp /= 2;
    }
  }

  ll ret = 0LL;
  REP(i, N) {
    int r = N;
    REP(j, 20) {
      int intvl = upper_bound(ALL(cum[j]), cum[j][i] + 1) - cum[j].begin() - 2;
      r = min(r, intvl);
    }
    ret += (ll)(r - i + 1);
  }
  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 17536
#include <bits/stdc++.h>
#define ll  long long

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, "\e[31;1m"); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\e[0m")
#else
    #define eprintf(...) 42
#endif

std::string solve(int H, int W, std::vector<std::string>& C)
{
    std::string S;
    for (auto itr = C.begin(); itr != C.end(); ++itr)
    {
        S += *itr + '\n';
        S += *itr + '\n';
    }
    return S;
}

int main(void)
{
    int H, W;
    std::cin >> H >> W;

    std::vector<std::string> C(H);
    for (int i = 0; i < H; i++)
    {
        std::cin >> C[i];
    }
    std::cout << solve(H, W, C);

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main (){
	char a[100];
	scanf("%[^\n]", a);
	
	for ( int i = 0; a[i] != ','; i++ ){
		printf("%c", a[i]);
	}
	printf(" ");
	
	for ( int j = 6; a[j] != ','; j++ ){
		printf("%c", a[j]);
	}
	printf(" ");
	
	for ( int k = 14; a[k] != '\0'; k++ ){
		printf("%c", a[k]);
	}
	
	return 0;
}

Measured memory_bytes: 1592
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>

class knuth_morris_pratt {
public:
  using size_type = size_t;

private:
  static constexpr size_type npos = -1;
  std::string M_p;
  std::vector<size_type> M_a;

public:
  knuth_morris_pratt() = default;
  knuth_morris_pratt(std::string const& p): M_p(p), M_a(p.length()+1) {
    M_a[0] = npos;
    for (size_type i = 0, j = npos; i < p.length(); ++i) {
      while (j != npos && p[i] != p[j]) j = M_a[j];
      ++j;
      M_a[i+1] = ((p[i+1] == p[j])? M_a[j]: j);
    }
  }

  std::vector<size_type> find_all(std::string const& s) const {
    std::vector<size_type> res;
    size_type j = 0;
    for (size_type i = 0; i < s.length(); ++i) {
      while (j != npos && M_p[j] != s[i]) j = M_a[j];
      if (++j == M_p.length()) {
        res.push_back(i-j+1);
        j = M_a[j];
      }
    }
    return res;
  }
};

void test(std::string const& pat, std::string const& text, std::vector<size_t> const& expected) {
  knuth_morris_pratt kmp(pat);
  auto res = kmp.find_all(text);
  for (size_t i = 0; i < res.size(); ++i)
    fprintf(stderr, "%zu%c", res[i], i+1<res.size()? ' ': '\n');

  assert(res == expected);
}

void testset() {
  test("abac", "ababacabac", {2, 6});
  test("aaaa", "aaaaaaaaaabaaaaab", {0, 1, 2, 3, 4, 5, 6, 11, 12});
  test("abab", "abababcababab", {0, 2, 7, 9});
  test("aabaabaaa", "aabaabaabaabaaabaabaaaaa", {6, 13});
}

intmax_t neko(std::string const& s, std::string const& t) {
  size_t n = s.length();
  size_t m = t.length();
  knuth_morris_pratt kmp(t);
  auto res = kmp.find_all(s+s);
  std::vector<int> a(2*n);
  for (auto ri: res) ++a[ri];
  for (size_t i = m; i < 2*n; ++i)
    if (a[i]) a[i] += a[i-m];

  int a0 = *std::max_element(a.begin(), a.begin()+n);
  int a1 = *std::max_element(a.begin()+n, a.end());
  if (a0 < a1) return -1;
  return a0;
}

int main() {
  char buf[524288];
  scanf("%s", buf);
  std::string s0 = buf;
  scanf("%s", buf);
  std::string t = buf;

  std::string s = s0;
  while (s.length() < t.length()) s += s0;

  printf("%jd\n", neko(s+s, t));
}


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

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    def digsum(s):
        su = 0
        for c in s:
            su += int(c)
        return su

    def break_ith_dig(s, i1):
        assert 2 <= i1 <= dig
        if s[-i1] == "0":
            return s
        s = s[:-i1] + str(int(s[-i1]) - 1) + "9" * (i1 - 1)
        return s

    ns = input()
    dig = len(ns)
    ma = digsum(ns)
    for i in range(2, dig + 1):
        ns = break_ith_dig(ns, i)
        ma = max(ma, digsum(ns))

    print(ma)

main()



Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#include <cmath>

#define _USE_MATH_DEFINES
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define atcoder 1000000007

using namespace std;

int main() {
	
	int N;
	long long int ans = 1;
	cin >> N;

	for (int i = 1; i < N+1; i++) {
		ans *= i;
		ans %= atcoder;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::Read;
use std::io::{stdout, BufWriter, Write};

use std::collections::HashMap;
 
fn main() {
    let mut buf = String::new();
    
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
 
    std::io::stdin().read_to_string(&mut buf).unwrap();
 
    let mut iter = buf.split_whitespace();
 
    let x: u64 = iter.next().unwrap().parse().unwrap();
    
    let ans = (x / 500) * 1000 + ((x % 500) / 5) * 5;
    
    println!("{}",ans);
}

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

int s[100];

int main()
{
	int n,k;
	while(cin >> n >> k){
		if(!n && !k)
			break;
		bool flag = true;
		for(int i=0;i<k;i++){
			cin >> s[i];
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<k;j++){
				int a;
				cin >> a;
				s[j] -= a;
				if(s[j] < 0)
					flag = false;
			}
		}
		if(flag)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	return 0;
}

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

int main() {
  int n; cin >>n;
  if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9){
    cout<<"hon"<<endl;
  }else if(n%10==0||n%10==1||n%10==6||n%10==8){
    cout<<"pon"<<endl;
  }else if(n%10==3){
    cout<<"bon"<<endl;
  }
  return 0;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const int mod = pow(10,9)+7;

int main()
{
    int N,M; cin >> N >> M;
    vector<int> oks(N+1, true);
    rep(i,M){
        int a; cin >> a;
        oks[a] = false;
    }
    vector<ll> dp(N+1);
    dp[0] = 1;
    // nowは今何段目の階段にいるかを表す
    rep(now, N){
        for(int next=now+1; next<=min(N,now+2); next++){
            if(oks[next]){
                dp[next] += dp[now];
                dp[next] %= mod;
            }
        }
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int r = sc.nextInt();
			if (n == 0 && r == 0)
				break;
			int[] s = new int[n];
			int[] scpy = new int[n];
			for (int i = n - 1; i >= 0; i--) {
				s[i] = n - i;
			}
			for (int i = 0; i < r; i++) {
				int p = sc.nextInt();
				int c = sc.nextInt();
				for (int j = 0; j < n; j++) {
					if (0 <= j && j <= c - 1) {
						scpy[j] = s[(p - 1) + j];
					} else if (c <= j && j <= c + (p - 2)) {
						scpy[j] = s[j - c];
					} else {
						scpy[j] = s[j];
					}
				}
				for (int j = 0; j < n; j++) {
					s[j] = scpy[j];
				}
			}
			System.out.println(s[0]);
		}
	}
}

Measured memory_bytes: 38924
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val l = sc.nextInt()
    var result = 0
    var minabs = 10000000
    repeat(n) {
        result += l + it
        minabs = Math.min(Math.abs(l + it), minabs)
    }
    if (result < 0) {
        result += minabs
    } else {
        result -= minabs
    }
    println(result)
}

Measured memory_bytes: 31132
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let _n : usize = get_one();
    let s : Vec<char> = get_one::<String>().chars().collect();
    let mut ans = 0;
    let mut max_a = 0;
    for c in s {
        if c == 'I' {
            ans += 1;
        }
        else {
            ans -= 1;
        }
        max_a = std::cmp::max(max_a, ans);
    }
    println!("{}", max_a);
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int N;
ll a[111111];
ll b[111111];

int main() {
   cin >> N;
   map<ll, ll> mp;
   rep (i, N) {
      cin >> a[i];
      mp[a[i]]++;
   }

   vec<ll> v;
   for (auto &x : mp) {
      while (x.second > 0) {
         if (x.second >= 2) v.push_back(x.first);
         x.second /= 2;
      }
   }
   // printA(v);

   sort(all(v), greater<ll>());
   if (v.size() >= 2) {
      // debug2(v[0], v[1])
      cout << v[0] * v[1] << endl;
   } else {
      cout << 0 << endl;
   }

   // sort(a, a+N, greater<ll>());

   // ll cnt = 0;
   // rep (i, N) {
   //    while (1) {
   //    }
   // }

   // ll cnt = 0;
   // for (auto itr = mp.rbegin(); itr != mp.rend(); itr++) {
   //    ll a = itr->second / 2;
   // }

   return 0;
}

Measured memory_bytes: 7296
import sys
input = sys.stdin.readline
N,M = map(int,input().split())
L = [list(map(int,input().split())) for i in range(N)]

from collections import defaultdict
d = defaultdict(lambda: [])
for i,ls in enumerate(L):
    for l in ls[1:]:
        d[l].append(i)

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self._size = [1] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self._size[ra] < self._size[rb]: ra,rb = rb,ra
        self._size[ra] += self._size[rb]
        self.parent[rb] = ra
        self.count += 1
    def size(self,a):
        return self._size[self.root(a)]

uf = UnionFind(N)

for ls in d.values():
    for a,b in zip(ls,ls[1:]):
        if uf.is_same(a,b): continue
        uf.unite(a,b)

print('YES' if uf.size(0)==N else 'NO')

Measured memory_bytes: 34072
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iostream>
#include <cassert>
#include <cmath>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>

using namespace std;

#define INF 1e+9
#define mp make_pair
#define pb push_back
#define fi first
#define fs first
#define se second
#define i64 long long
#define li long long
#define lint long long
#define pii pair<int, int>
#define vi vector<int>

#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define fore(i, b, e) for (int i = (int)b; i <= (int)e; i++)

int main() {
#ifdef LOCAL
    freopen("inp", "r", stdin);
    //freopen("outp", "w", stdout);
#else
    // freopen(TASKNAME ".in", "r", stdin);
    // freopen(TASKNAME ".out", "w", stdout);
#endif
    i64 n, m;
    cin >> n >> m;
    i64 ans;
    if (n > m)
        swap(n, m);
    if (n == 1) {
        ans = m == 1 ? 1 : m - 2; 
    } else {
        ans = (n - 2) * (m - 2);
    }
    cout << ans;
    //inner part-all yes
    //corners-3 nei - no
    //sides-5 nei-no
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <time.h>
#include <stdlib.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define clr(x) x.clear()
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define hell 1000000007
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(a) a.begin(),a.end()
#define ign cin.ignore();

#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

using namespace std;
using namespace __gnu_pbds;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef MY_PROJECT
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main()
{
    IOS
    ll k,n;
    cin>>k>>n;
    vll v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    ll maxi=v[0]+k-v[n-1];
    for(int i=1;i<n;i++)
    {
        maxi=max(maxi,v[i]-v[i-1]);
    }
    ll res=k-maxi;
    cout<<res;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,R,a,b,c;
    cin >> n >> m >> R;
    vector<ll> r(R);
    rep(i,R){
        cin >> a;
        --a;
        r[i] = a;
    }
    vector<vector<ll>> d(n,vector<ll>(n,INF));
    rep(i,m){
        cin >> a >> b >> c;
        --a;
        --b;
        d[a][b] = c;
        d[b][a] = c;
    }
    rep(k,n){
        rep(i,n){
            rep(j,n){
                chmin(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    ll ans = INF;
    SORT(r);
    do{
        ll cnt = 0;
        rep(i,R-1){
            cnt += d[r[i]][r[i+1]];
        }
        chmin(ans,cnt);
    }while(next_permutation(all(r)));
    PRINT(ans);
}

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

typedef double D;      // À•W’l‚ÌŒ^Bdouble‚©long double‚ð‘z’è
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;
const D EPS = 1e-9;    // ‹–—eŒë·B–â‘è‚É‚æ‚Á‚Ä•Ï‚¦‚é
#define X real()
#define Y imag()
#define LE(n,m) ((n) <= (m) + EPS)
#define GE(n,m) ((n) + EPS >= (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

D dot(P a, P b) {
  return (conj(a)*b).X;
}
// ŠOÏ@cross(a,b) = |a||b|sinƒÆ
D cross(P a, P b) {
  return (conj(a)*b).Y;
}

int ccw(P a, P b, P c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}

namespace std {
  bool operator<(const P a, const P b) {
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}

VP convexHull(VP ps) {  // Œ³‚Ì“_W‡‚ªƒ\[ƒg‚³‚ê‚Ä‚¢‚¢‚È‚çVP&‚É
  int n = ps.size(), k = 0;
  sort(ps.begin(), ps.end());
  VP ch(2*n);
  for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
    while (k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;  // —]Œv‚È“_‚àŠÜ‚Þ‚È‚ç == -1 ‚Æ‚·‚é
  for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--]) // upper-hull
    while (k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  ch.resize(k-1);
  return ch;
}

D area(const VP& ps) {
  D a = 0;
  rep (i, ps.size()) a += cross(ps[i], ps[(i+1) % ps.size()]);
  return a / 2;
}

int main(){
	int N, i, j;
	scanf("%d", &N);
	vector<double> x(N), y(N);
	for(i = 0; i < N; i++){
		scanf("%lf%lf", &x[i], &y[i]);
	}
	D newS, oldS;
	oldS = -1;
	for(i = 2; i <= N; i++){
//		printf("i = %d\n", i);
		VP ps(i);
		for(j = 0; j < i; j++){
			ps[j] = P(x[j], y[j]);
		}
		VP ch = convexHull(ps);
//		printf("ch.size() = %d\n", ch.size());
		newS = area(ch);
//		printf("newS = %lf\n", newS);
		if(LE(newS, oldS)){
//			printf("1(i, oldS, newS) = (%d, %lf, %lf)\n", i, oldS, newS);
			printf("Impossible\n");
			return 0;
		}
		oldS = newS;
	}
	oldS = -1;
	for(i = 2; i <= N; i++){
//		printf("i = %d\n", i);
		VP ps(i);
		for(j = 0; j < i; j++){
			ps[j] = P(x[N - 1 - j], y[N - 1 - j]);
		}
		VP ch = convexHull(ps);
//		printf("ch.size() = %d\n", ch.size());
		newS = area(ch);
//		printf("newS = %lf\n", newS);
		if(LE(newS, oldS)){
//			printf("2(i, oldS, newS) = (%d, %lf, %lf)\n", i, oldS, newS);
			printf("Impossible\n");
			return 0;
		}
		oldS = newS;
	}
	printf("Possible\n");
	return 0;
}


Measured memory_bytes: 3312
package main

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

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt, sum int

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	S := read()
	T := make([]string, N)
	K, _ := strconv.Atoi(read())
	K--
	for i := 0; i < N; i++ {
		if string(S[K]) != string(S[i]) {
			T[i] = "*"
		} else {
			T[i] = string(S[i])
		}
	}
	fmt.Println(strings.Join(T, ""))
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] < a[j] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 640
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var k = int.Parse(line[1]);
        var a = new int[n];
        for (int i = 0; i < n; i++) a[i] =  int.Parse(Console.ReadLine().Trim());
        Array.Sort(a);
        var ans = int.MaxValue;
        for (int i = 0; i <= n -k; i++)
        {
            var w = a[i + k - 1] - a[i];
            ans = Min(ans, w);
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 15452
#include<iostream>
#include<string>
using namespace::std;
int main() {
  string alphabet = "abcdefghijklmnopqrstuvwxyz";
  char c, new_c;
  cin >> c;
  new_c = alphabet[alphabet.find(c)+1];
  cout << new_c << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
using namespace std;

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

int main() {
    unordered_set<char> foo;
    string s;
    cin >> s;
    for (char ch : s) {
        if (foo.find(ch) != foo.end()) {
            cout << "no";
            return 0;
        }
        foo.insert(ch);
    }
    cout << "yes";

    return 0;
}

Measured memory_bytes: 512
#include <iostream>

int K, ans;

namespace {
  struct _caller {
    // Constructor
    _caller(){
      std::cin >> K;
    }

    // Destructor
    ~_caller(){
      std::cout << ans << std::endl;
    }
  } caller;
} // namespace

int main()
{
  ans = (K / 2) * ((K+1) / 2);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define mod 1000000007;
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll arr[n-1];
    for(int i=0;i<n-1;i++)
    cin>>arr[i];
    ll temp=-1,ans=0;
    for(int i=0;i<n-1;i++)
    {
        if(i==0)
        {
        ans+=2*arr[i];
        temp=arr[i];
        continue;
        }
        else if(temp>arr[i])
        {
            ans-=temp;
            ans+=2*arr[i];
            temp=arr[i];
        }
        else if(temp<=arr[i])
        {
            ans+=arr[i];
            temp=arr[i];
        }

    }
    cout<<ans;

    

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    string str[3];
    int goal[3];
    for(int i=0;i<3;i++){
        cin >> str[i];
        goal[i] = str[i].length();
    }

    int pointer[3] = {0,0,0};
    int who = 0;
    while(1){

        int copy = who;
        who = int(int(str[who][pointer[who]])-int('a'));
        pointer[copy]++;

        if(pointer[0]==goal[0]+1){
            cout << "A" << endl;
            return 0;
        }else if(pointer[1]==goal[1]+1){
            cout << "B" << endl;
            return 0;
        }else if(pointer[2]==goal[2]+1){
            cout << "C" << endl;
            return 0;
        }
    }

}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    int64_t psum = 0;
    int64_t result = 0;
    map<int64_t, int> m;
    m[0] = 1;

    vector<int64_t> hist(n + 1);
    hist[0] = 0;
    rep(i, n)
    {
        if (i - k + 1 >= 0) {
            m[hist[i - k + 1]]--;
        }
        int a;
        cin >> a;
        psum += a;

        int64_t key = (psum - (i + 1) + k) % k;
        result += m[key];
        m[key]++;

        hist[i + 1] = key;
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 14336
/*input
9999 1
0
*/
#include<bits/stdc++.h>
using namespace std;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int fast_ex(int a,int n,int m){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= fast_ex(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

set<int> notok;

bool check(int n){
	while(n > 0){
		if(notok.find(n%10) != notok.end())return 0;
		n/= 10;
	}
	return 1;
}

void solve(){
	int n,k;cin >> n >> k;
	REP(i,k){
		int j;
		cin >> j;
		notok.insert(j);
	}
	int i = n;
	while(1){
       if(check(i)){
       	cout << i;break;
       }
       i++;
	}
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;//cin >> t;
  WL(t)solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  vector<int> t(N);
  for (int i = 0; i < N; ++i) {
    cin >> s[i] >> t[i];
  }
  string X;
  cin >> X;

  int ans = 0;
  bool found = false;
  for (int i = 0; i < N; ++i) {
    if (not found) {
      if (s[i] == X) found = true;
    } else {
      ans += t[i];
    }
  }

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


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char[] c = new char[3];

    for(int i = 0; i < 3; i++) {
      c[i] = s.charAt(i);
      if(c[i] == '1') {
        c[i] = '9';
      } else {
        c[i] = '1';
      }
    }
    for(int i = 0; i < 3; i++) {
      System.out.print(c[i]);
    }

  }

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
typedef long long ll;

int a[100010],n;
ll s,cnt,ans=1e9;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i)
	scanf("%d",&a[i]);

    if(a[1]>0)s=a[1];
    else cnt=1-a[1],s=1;
    for(int i=2;i<=n;++i)
	if(s*(s+a[i])<0)s+=a[i];
	else
	{
	    cnt+=abs(s+a[i])+1;
	    s=((s<0)<<1)-1;
	}
    ans=cnt;
    
    if(a[1]<0)cnt=0,s=a[1];
    else cnt=a[1]+1,s=-1;
    for(int i=2;i<=n;++i)
	if(s*(s+a[i])<0)s+=a[i];
	else
	{
	    cnt+=abs(s+a[i])+1;
	    s=((s<0)<<1)-1;
	}
    printf("%lld\n",std::min(ans,cnt));
    
    return 0;
}


Measured memory_bytes: 640
n = int(input())
d = dict()
for i in range(1, n+1):
    t = i
    tail = t % 10
    while t >= 10:  # head, tail nomi miru.
        t //= 10
    head = t
    d[(head, tail)] = d.get((head, tail), 0) + 1
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        temp = d.get((i,j), 0) * d.get((j,i), 0)
        # print(i, j, temp, d.get((i, j)), d.get((j, i)))
        ans += temp
print(ans)

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

#define f first
#define s second
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int N = (int)2e5 + 123, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18;

int main()
{                         
	ll n, a, b;
	cin >> n >> a >> b;
    cout << max((n - 1) * b + a - ((n - 1) * a + b) + 1, 0ll);
	return 0;
}


Measured memory_bytes: 256
# input
N, K = map(int, input().split())

MOD = 10**9+7

# process
def sumrange(x, y):
    ret = (x+y) * ((y-x+1)//2) 
    if (y-x+1)%2 == 1:
        ret += x+(y-x)//2
    return ret % MOD

ans = 0
for i in range(K, N+2):
    ans += sumrange(N-i+1, N) - sumrange(1, i-1) + 1
    ans %= MOD

# output
print(ans)


Measured memory_bytes: 9196
def solve(h, w, k, s): 
    p = []
    for r in range(h):
        for c in range(w):
            if s[r][c] == "#":
                p.append((len(p)+1, r, c)) 
    p = sorted(p, key=lambda _:_[2])
    mask = [[0]*w for r in range(h)]
    for id, r, c in p:
        while c >= 0:
            if mask[r][c] == 0:
                mask[r][c] = id
            else:
                break
            c -= 1
    for id, r, c in p:
        c += 1
        while c < w:
            if mask[r][c] == 0:
                mask[r][c] = id
            else:
                break
            c += 1
    for sr in range(h):
        for sc in range(w):
            id = mask[sr][sc]
            r, c = sr-1, sc
            while r >= 0:
                if mask[r][c] == 0:
                    mask[r][c] = id
                else:
                    break
                r -= 1
    for sr in range(h):
        for sc in range(w):
            id = mask[sr][sc]
            r, c = sr+1, sc
            while r < h:
                if mask[r][c] == 0:
                    mask[r][c] = id
                else:
                    break
                r += 1
    for r in range(h):
        print(" ".join(map(str, mask[r])))

h, w, k = map(int, input().split())
s = [input() for r in range(h)]
solve(h, w, k, s)




Measured memory_bytes: 15592
n, m, q = map(int, input().split())
A, B, C, D = [0]*q, [0]*q, [0]*q, [0]*q
for i in range(q):
   A[i], B[i], C[i], D[i] = map(int, input().split())

a = [1]
ans = 0
def dfs(a):
    global ans
    if len(a) == n+1:
        now = 0
        for i in range(q):
            if a[B[i]] - a[A[i]] == C[i]:
                now += D[i]
        ans = max(ans, now)
        return

    a.append(a[-1])
    while a[-1] <= m:
        dfs(a)
        a[-1] += 1
    a.pop(-1)

dfs(a)
print(ans)

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

int n,a[101],b[101],dp[111][111];

int dfs(int l,int r){
    if(dp[l][r]!=-1)return dp[l][r];
    int res=1e17;
    for(int i=l;i<r;i++){
        res=min(res,dfs(l,i)+dfs(i+1,r)+a[l]*b[i]*a[i+1]*b[r]);
    }
    return dp[l][r]=res;
}

signed main(){
    memset(dp,-1,sizeof(dp));
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        dp[i][i]=0;
    }
    cout<<dfs(0,n-1)<<endl;
}


Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <limits>
#include <numeric>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
using namespace std;

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

	int n, a;
	cin >> n >> a;

	cout << n - a + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	int c;		// 最終色
	int h;
	int w;
	int max;		// 結合パネル数最大
	int tmp;		// 局地的結合パネル数算出保持
	boolean[][] comb;		// 結合パネル範囲(true)
	
	// pane[i][j]から移動できる同色パネル結合
	void Join(int[][] pane, int i, int j){
		// 配列外アクセスもしくは探索済みまたは同色でない
		if(i<0||i>=h||j<0||j>=w||comb[i][j]==true||pane[i][j]!=pane[0][0]){
			return;
		}
		tmp++;		// 局地的結合パネルインクリメント
		comb[i][j] = true;		// 探索済
		// 遷移先
		Join(pane,i+1,j);
		Join(pane,i,j+1);
		Join(pane,i-1,j);
		Join(pane,i,j-1);
	}
	
	void Color(int pane[][], int cnt){
		comb = new boolean[h][w];
		tmp = 0;
		Join(pane,0,0);		// 結合する
		max = Math.max(max,tmp);		// 最大値更新
		if(cnt==4){
			// 5回目彩色
			for(int j=0;j<h;j++){
				for(int k=0;k<w;k++){
					if(comb[j][k]){
						pane[j][k] = c;
					}
				}
			}
			Color(pane,++cnt);	// 再帰
			return;
		}
		else if(cnt==5){
			return;
		}
		// 4回目以下
		cnt++;
		for(int i=1;i<=6;i++){		// 6色試す
			// 現在の階層の色と結合情報を退避させる
			int[][] copy = new int[h][w];
			boolean[][] copy_comb = new boolean[h][w];
			for(int j=0;j<h;j++){
				for(int k=0;k<w;k++){
					copy[j][k] = pane[j][k];
					copy_comb[j][k] = comb[j][k];
				}
			}
			// i色に設定
			for(int j=0;j<h;j++){
				for(int k=0;k<w;k++){
					if(comb[j][k]){
						pane[j][k] = i;
					}
				}
			}
			Color(pane,cnt);		// 再帰
			// 退避情報を次回の為に戻す
			for(int j=0;j<h;j++){
				for(int k=0;k<w;k++){
					pane[j][k] = copy[j][k];
					comb[j][k] = copy_comb[j][k];
				}
			}
		}
	}

	void run(){
		Scanner stdIn = new Scanner(System.in);
		while(true){
			h = stdIn.nextInt();
			w = stdIn.nextInt();
			c = stdIn.nextInt();
			if((h|w|c)==0){
				return;
			}
			int[][] pane = new int[h][w];
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					pane[i][j] = stdIn.nextInt();
				}
			}
			max = 0;
			Color(pane,0);
			System.out.println(max);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <climits>
#include <set>
using namespace std;



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

    long long x = 1;

    for(int i = 1; i <= n; i++)
    {
        x *= i;
        x %= 1000000000 + 7;
    }

    cout << x << endl;
    
    return 0;
}

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

using namespace std;

#define ll long long

const ll mod  = 1e9 + 7;
const ll INF = 1e14;

void solve(){

    int n; cin >> n;
    string s; cin >> s;

    if(s.length() <= n) cout << s;
    else cout << s.substr(0, n) << "...";

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    //int test; cin >> test;
    //for(int t = 1; t <= test; ++t){
        solve();    
    //}

	return 0;
}



Measured memory_bytes: 3664
use std::cmp::{max, min};
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let c: i32 = read();
    let d: i32 = read();
    println!("{}", max(0, min(b, d) - max(a, c)));
}

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


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

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

int main(void)
{

    int n;
    cin >> n;
    vector<ll> x;
    rep(i, n)
    {
        int t;
        cin >> t;
        x.push_back(t);
    }

    vector<ll> sorted = x;
    sort(sorted.begin(), sorted.end());
    ll A = sorted[n/2];
    ll B = sorted[n/2-1];

    rep(i, n)
    {
        if(x[i] < A){
            cout << A << endl;
        }else{
            cout << B << endl;
        }
    }

    return 0;
}


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

int n,k,jk[12],ja[12][2003],dp[12][2003],ans;

int main(){
	scanf("%d%d",&n,&k);
	for(int i = 0;i < n;i++){
		int c,g;
		scanf("%d%d",&c,&g);
		ja[g][jk[g]++] = c;
	}

	for(int i = 1;i <= 10;i++){
		sort(ja[i],ja[i] + jk[i],greater<int>());
	}
	for(int i = 1;i <= 10;i++){
		for(int j = 1;j < jk[i];j++){
			ja[i][j] += ja[i][j-1] + j*2;
		}
	}

	for(int i = 1;i <= 10;i++){
		for(int j = 1;j <= k;j++){
			dp[i][j] = max(dp[i][j],dp[i-1][j]);
		}
		for(int j = 1;j <= jk[i];j++){
			for(int l = j;l <= k;l++){
				dp[i][l] = max(dp[i][l],dp[i-1][l-j]+ja[i][j-1]);
				ans = max(ans,dp[i][l]);
			}
		}
	}

	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1328
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
#define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const int INF = -1;
ll dp[100005][13];

signed main(void) {
	int a;
	string s;
	cin >> a;
	cin >> s;

	if (a < 3200) {
		cout << "red" << endl;
	} else {
		cout << s << endl;
	}
	return 0;
}


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

int main()
{
  int N, M;
  std::cin >> N >> M;

  struct Work {int day; int price; };
  std::vector<Work> works;
  for(int i=0; i<N; i++)
  {
    int a, b;
    std::cin >> a >> b;
    works.push_back(Work{a,b});
  }

  std::sort(works.begin(), works.end(), [](auto l, auto r){ return l.day > r.day;} );

  int count = 0;
  std::multiset<int> waiting;
  for(int i=1; i<=M; i++)
  {
    while( ! works.empty() && works.back().day == i )
    {
      waiting.insert(works.back().price);
      works.pop_back();
    }
    if( ! waiting.empty() )
    {
      count += *waiting.rbegin();
      waiting.erase(std::prev(waiting.end()));
    }
  }

  std::cout << count;
}


Measured memory_bytes: 5620
#include<iostream>

using namespace std;

int main(){
int p,q,r,max;
cin>>p>>q>>r;
max=0;
if(max<p) max=p;
if(max<q) max=q;
if(max<r) max=r;
int ans=p+q+r-max;
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define LC(x) ((x)<<1)
#define RC(x) ((x)<<1|1)

int a[100];
int b[100];
int c[100];

int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++){
        scanf("%d",&b[i]);
    }
    for(int i=1;i<=n-1;i++){
        scanf("%d",&c[i]);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        ans+=b[a[i]];
        if(a[i]>1&&i>1){
            if(a[i]-a[i-1]==1){
                ans+=c[a[i]-1];
            }
        }
    }
    printf("%d",ans);
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <vector>
#include <algorithm>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;

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


// 配列a[0], a[1],... a[n]が与えられる。部分列で、すべての要素に対しa[j]<a[k] (j<k)が成り立つような最長の部分列の長さを求める。
// T[k]を長さkの単調増加部分列の最後の要素の内、最小のものとする。
// この時、T[j] < T[k] (j<k)である。何故なら、長さj+1の部分列は長さjの部分列に、長さjの部分列の最後の要素より大きい数値をつけ足したものであるため、
// 単調部分列の定義からT[J]<T[j+1]...<T[k]となる。したがってT[j]<T[k]が常に成り立つ。
// このようにTを定義したとき、新たに接続される要素に対して部分列を考えると、更新されるkの位置が自動的に決定される。
// もしTがkまで定義されていて、T[k] < a[m]なる要素が入力された時、明らかにkより長い部分列を作れるので、T[k+1] = a[m]となる。

int main() {
  int A, B, C; scanf("%d %d %d",&A, &B, &C);
  int K; scanf("%d", &K);
  string ans = "No";
  rep(k, K+1){
    if(A < B && B < C){
      ans = "Yes";
      break;
    } else if (A >= B){
      B *= 2;
    } else if (B >= C){
      C *= 2;
    }
  }

  // 全てのコインmを使ってnを実現するのでT[m][n]が答え
  printf(ans.c_str());
  printf("\n");
  return 0;
}



Measured memory_bytes: 3780
#include <stdio.h>

#define N 2000000
#define INF -1000000

int size, A[N];

void increaseKey(int i, int key) {
	int tmp;
	if (key < A[i]) return;
	A[i] = key;
	while(i>1 && A[i/2]<A[i]) {
		tmp = A[i];
		A[i] = A[i/2];
		A[i/2] = tmp;
		i=i/2;
	}
}

void maxHeapify(int i) {
	int l,r,largest;
	int tmp;

	l = i*2;
	r = i*2+1;

	if (l <= size && A[l] > A[i]) largest = l;
	else largest = i;
	if (r <= size && A[r] > A[largest]) largest = r;

	if (largest != i) {
		tmp = A[i];
		A[i] = A[largest];
		A[largest] = tmp;
		maxHeapify(largest);
	}
}

void insert(int key) {
	size++;
	A[size] = INF;
	increaseKey(size, key);
}

int extract() {
	int max;
	if (size < 1) return INF;
	max = A[1];
	A[1] = A[size--];
	maxHeapify(1);
	return max;
}

int main() {
	int k;
	char com[10];

	while (1) {
		scanf("%s", com);
		if (com[0] == 'e' && com[1] == 'n') break;
		if (com[0] == 'i') {
			scanf("%d", &k);
			insert(k);
		} else {
			printf("%d\n", extract());
		}
	}

	return 0;
}

Measured memory_bytes: 4696
N=int(input())
s = []
for i in range(N):
    s.append(input())
M=int(input())
t=[]
for k in range(M):
    t.append(input())
count=0
for r in s:
    scount=s.count(r)
    tcount=t.count(r)
    ans=scount-tcount
    if ans>=count:
        count=ans
print(count)

Measured memory_bytes: 38256