akhauriyash/Code-Regression huggingface dataset:
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

const mod = 10^^9+7;
alias mint = FactorRing!mod;

void main()
{
  string s; readV(s);

  auto n = s.length.to!int, q = 0;
  auto a = new mint[](n+1), b = new mint[](n+1), c = new mint[](n+1);
  foreach (i, si; s)
    switch (si) {
    case 'A':
      a[i+1] = a[i]+mint(3).repeatedSquare(q);
      b[i+1] = b[i];
      c[i+1] = c[i];
      break;
    case 'B':
      b[i+1] = b[i]+a[i];
      a[i+1] = a[i];
      c[i+1] = c[i];
      break;
    case 'C':
      c[i+1] = c[i]+b[i];
      a[i+1] = a[i];
      b[i+1] = b[i];
      break;
    case '?':
      a[i+1] = a[i]*3+mint(3).repeatedSquare(q);
      b[i+1] = b[i]*3+a[i];
      c[i+1] = c[i]*3+b[i];
      ++q;
      break;
    default:
      assert(0);
    }

  writeln(c[n]);
}

pure T repeatedSquare(alias pred = "a * b", T, U)(T a, U n)
{
  return repeatedSquare!(pred, T, U)(a, n, T(1));
}

pure T repeatedSquare(alias pred = "a * b", T, U)(T a, U n, T init)
{
  import std.functional;
  alias predFun = binaryFun!pred;

  if (n == 0) return init;

  auto r = init;
  while (n > 0) {
    if (n&1) r = predFun(r, a);
    a = predFun(a, a);
    n >>= 1;
  }

  return r;
}

struct FactorRing(int m, bool pos = false)
{
  version(BigEndian) union { long vl; struct { int vi2; int vi; } } else union { long vl; int vi; }
  alias FR = FactorRing!(m, pos);
  @property static init() { return FR(0); }
  @property int value() { return vi; }
  @property void value(int v) { vi = mod(v); }
  alias value this;

  this(int v) { vi = v; }
  this(int v, bool runMod) { vi = runMod ? mod(v) : v; }
  this(long v) { vi = mod(v); }

  ref auto opAssign(int v) { vi = v; return this; }

  pure auto mod(int v) const { static if (pos) return v%m; else return (v%m+m)%m; }
  pure auto mod(long v) const { static if (pos) return cast(int)(v%m); else return cast(int)((v%m+m)%m); }

  static if (!pos) pure ref auto opUnary(string op: "-")() { return FR(mod(-vi)); }

  static if (m < int.max / 2) {
    pure ref auto opBinary(string op)(int r) if (op == "+" || op == "-") { return FR(mod(mixin("vi"~op~"r"))); }
    ref auto opOpAssign(string op)(int r) if (op == "+" || op == "-") { vi = mod(mixin("vi"~op~"r")); return this; }
  } else {
    pure ref auto opBinary(string op)(int r) if (op == "+" || op == "-") { return FR(mod(mixin("vl"~op~"r"))); }
    ref auto opOpAssign(string op)(int r) if (op == "+" || op == "-") { vi = mod(mixin("vl"~op~"r")); return this; }
  }
  pure ref auto opBinary(string op: "*")(int r) { return FR(mod(vl*r)); }
  ref auto opOpAssign(string op: "*")(int r) { vi = mod(vl*r); return this; }

  pure ref auto opBinary(string op)(ref FR r) if (op == "+" || op == "-" || op == "*") { return opBinary!op(r.vi); }
  ref auto opOpAssign(string op)(ref FR r) if (op == "+" || op == "-" || op == "*") { return opOpAssign!op(r.vi); }
}


Measured memory_bytes: 4120
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			Integer a[] = new Integer[3];
			for (int i = 0; i < 3; i++) {
				a[i] = sc.nextInt();
			}

			Arrays.sort(a);
			System.out.println((a[0] + a[1]));
		}
	}

}


Measured memory_bytes: 21844
from itertools import combinations


def main():
    s, k = input(), int(input())
    l, tmp = len(s), s[:5]
    for i in range(l - 4):
        tmp = min(tmp, s[i:i + 5])
    res = set()
    for i, j in combinations(range(min(6, l + 1)), 2):
        res.add(tmp[i:j])
    ans = sorted(res)
    print(ans[k - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;

class Main {

    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        long ans = 0;
        int N = sc.nextInt();
        int[] P = sc.nextIntArray(N);
        int min = INF;
        int max = 0;
        for(int i=0;i<N;i++){
            if(min>P[i])ans++;
            min = Math.min(P[i],min);
            max = Math.min(P[i],max);
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

    public ArrayList<Integer> nextIntList(int n) {
        ArrayList<Integer> a = new ArrayList<Integer>(n);
        for (int i = 0; i < n; i++)
            a.add(nextInt());
        return a;
    }

    public ArrayList<Long> nextLongList(int n) {
        ArrayList<Long> a = new ArrayList<Long>(n);
        for (int i = 0; i < n; i++)
            a.add(nextLong());
        return a;
    }
    
    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 48416
#include <stdio.h>

int main(void){
  long long int n = 0, a = 0, b = 0;
  long long int ans = 0;
  
  scanf("%lld %lld %lld",&n,&a,&b);
  
  if(a>b){
  	ans = a;
    a = b;
    b = ans;
  }
  
  if((b-a) % 2 == 0){
    ans = (b-a) / 2;
  }else if((a+b-1)<=n){
    ans = (a+b-1)/2;
  }else{
    ans = (n-a+n-b+1)/2;
  }
  
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a, b, c, d;
  cin >> n;
  a = n % 10;
  b = n / 10 % 10;
  c = n / 100 % 10;
  d = n / 1000 % 10;
  
  if(a == b && a == c){
    cout << "Yes" << endl;
  }else if(b == c && b == d){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

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

    ll n;
    cin >> n;

    ll res = 0;
    for(ll i = 1; i*i <= n; ++i){
        if((n-i) % i == 0 && ((n-i)/i != 0 && (n/((n-i)/i) == (n%((n-i)/i))))){
            res += (n-i)/i;
        }
    }

    cout << res << endl;

    return 0;
}

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

// ?????°????????????

// top??????????????¶???????????? s????????°??????????????°???
int top, S[1000];

// ?°?x?????\????????????
void push(int x) {
	// top???1???????°?????´??????\??°top???????????????
	S[++top] = x;
}

// ?°??????¶????´?????????¶??????
int pop() {
	top--;
	return S[top + 1];
}

// ????¬???¬??°???
int CharToInt(char s[]) {
	int ans = 0, i = 0;
	while (s[i] != '\0') {
		ans = ans * 10 + s[i] - '0';
		i++;
	}
	return ans;
}
int main() {
	char s[1000];
	int a, b;
	// ?????????
	top = 0; 
	while(scanf("%s",s)!=EOF){
			if (s[0] == '+') {
				b = pop();a = pop();
				push(a + b);
			}else if (s[0] == '-') {
				b = pop(); a = pop();
				push(a - b);
			}else if (s[0] == '*') {
				b = pop(); a = pop();
				push(a * b);
			}else {
				push(CharToInt(s));
			}
	}
	printf("%d\n",pop());
	
	return 0;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

const int MAX_N = 2005;

int N;
LL A[MAX_N];

bitset<MAX_N*MAX_N> dp(1);

int main()
{
  cin >> N;
  LL Sum = 0;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    Sum += A[i];
    dp |= (dp << A[i]);
  }

  for(int j = (Sum+1)/2; j <= Sum; j++) {
    if(dp[j]) {
      cout << j << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 1792
//03
#include<iostream>

using namespace std;

int main(){
  bool cmp[10001]={true,true};
  for(int i=2;i<10001;i++){
    if(!cmp[i]){
      for(int j=2;j*i<10001;j++){
	cmp[i*j]=true;
      }
    }
  }
  bool tp[10001]={};
  for(int i=0;i+2<10001;i++){
    tp[i+2]=!cmp[i]&&!cmp[i+2];
  }
  for(int n;cin>>n,n;){
    while(!tp[n]){
      n--;
    }
    cout<<n-2<<' '<<n<<endl;
  }
  return 0;
}

Measured memory_bytes: 884
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define num(a) a-'0'
#define charr(a) (a - 'A' + 1)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define maxs(a,b) if(b>a)a=b
#define mins(a,b) if(b<a)a=b
#define debug(x) cerr<<"["<<#x<<":"<<x<<"] "
#define debug2(a,b) debug(a);debug(b)
#define debug3(a,b,c) debug2(a,b);debug(c)
#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 << ln;
#define all(a) (a).begin(), (a).end()
#define vi vector<long long>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"
typedef long double ld;
typedef double d;
using namespace std;
int modF=1e9+7;
int INF=1e11;

void solve(){
    string s;
    cin>>s;
    int k;
    cin>>k;
    int l=s.length();
    int ans=1;
    int li=-1;
    rep(i,0,l){
        if(s[i]!='1'){
            ans=num(s[i]);
            break;
        }
        else{
            li=i+1;
        }
    }
    if(k<=li)
        ans=1;
    cout<<ans<<ln;
}

signed main(){
	boost_io;
	solve();
	return 0;
}


Measured memory_bytes: 3656
import sys
import numpy as np
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N, W = map(int, readline().split())
wv = map(int, read().split())
dp = np.zeros(W + 1, np.int64)

for w, v in zip(wv, wv):
    np.maximum(dp[w:], dp[:-w] + v, out=dp[w:])

print(dp.max())

Measured memory_bytes: 14604
def insertion_sort(A, g):
    cnt = 0
    for i in range(g, len(A)):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v
    return cnt

def shell_sort(A):
    cnt = 0
    h = 1
    G = []
    while h <= len(A)/2:
        G.append(h)
        h = 3 * h + 1
    if len(G) == 0:
        G.append(1)
    print(len(G))
    print(*G[::-1])
    for g_i in G[::-1]:
        cnt += insertion_sort(A, g_i)
    return cnt

if __name__ == '__main__':
    n = int(input())
    A = []
    for i in range(n):
        A.append(int(input()))

    print(shell_sort(A))
    for a in A:
        print(a)



Measured memory_bytes: 45512
#include <iostream>
#include <string>
#include <iterator>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <sstream> 
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <functional>
#pragma GCC optimize("O3")
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define sp system("pause");
#define MOD 998244353 
#define mxN 2005



using namespace std;
set<ll> s;
ll maxx = 400000000;
void solve(ll x)
{
	if (s.find(x) != s.end())
		return;
	s.insert(x);
	if (x >= maxx)
		return;
	

	
	
	if (x == 0)
		for (int i = 1; i <= 9; ++i)
			solve(i);
	else
	{
		ll lst = x % 10;
		if (lst > 0)
			solve(x * 10 + (lst - 1));
		solve(x * 10 + lst);
		if (lst < 9)
			solve(x * 10 + (lst + 1));
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll k;
	cin >> k;
	solve(0);
	
	while (k)
	{
		s.erase(s.begin());
		k--;
		
	}
	cout << *s.begin();
	
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N), B(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    B[0] = B[0] * (-1) + A[i];
  }
  for (int i = 0; i < N - 1; i++) {
    B[i + 1] = 2 * A[i] - B[i];
  }
  for (int i = 0; i < N; i++) {
    cout << B[i] << ' ';
  }
  return 0;
}


Measured memory_bytes: 2176
N = int(input())

S = N*(N+1)//2

N_3 = N//3
N_5 = N//5
N_15 = N//15

S_3 = (N_3*(N_3+1)//2)*3
S_5 = (N_5*(N_5+1)//2)*5
S_15 = (N_15*(N_15+1)//2)*15

print(S-S_3-S_5+S_15)

Measured memory_bytes: 9192
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>
using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
	int N, D, X,cou;
	cou = 0;
	cin >> N >> D >> X;
	vint A(N);
	for (int i = 0; i < N; i++)cin >> A[i];

	for (int i = 0; i < N; i++) {
		for (int j = 1; j <= D; j++) {
			for (int k = 0; k <= D / A[i]; k++) {
				if (j == A[i] * k + 1)cou++;
			}
		}
	}
	cout << X + cou << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cxxabi.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
template<class T>void geti(T&a){for(auto&_:a)cin>>_;}
template<class T>void getii(T&a){for(auto&_:a)geti(_);}
void put(string d){cout<<endl;}template<class H,class...T>void put(string d,H&&h,T&&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)

template<class T>string bitstr(T x){return typeid(T)==typeid(int)?bitset<32>(x).to_string('_','#'):bitset<64>(x).to_string();}
template<class T>int bitcnt(T x){return typeid(T)==typeid(int)?__builtin_popcount(x):__builtin_popcountll(x);}
template<class T>int bitdig(T x){return x?typeid(T)==typeid(int)?32-__builtin_clz(x):64-__builtin_clzll(x):0;}
template<class T>int bitpow(T x){return x?typeid(T)==typeid(int)?__builtin_ctz(x):__builtin_ctzll(x):0;}


int main(){
    dcl(n);
    vi a(n);
    geti(a);
    sort(rall(a));
    int ans=0;
    rep(i,n) ans+=a[i]*(i%2?-1:1);
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(n)-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define mod 1000000007
#define INF 1000000000000000000
/****************************/
int main()
{
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1e9+7;
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;

int main(){
    int N, P = 0;
    cin >> N;
    VI X(N);
    REP(i,N){
        cin >> X[i];
        P+=X[i];
    }
    int P1 = floor((double)P/N), P2 = ceil((double)P/N);
    LL sum1 = 0, sum2 = 0;
    REP(i,N){
        sum1 += (X[i]-P1) * (X[i]-P1);
        sum2 += (X[i]-P2) * (X[i]-P2);
    }
    cout << min(sum1, sum2) << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

A=list(map(int,input().split()))
for ai in A:
    if ai==1:
        ans+=300000
    elif ai==2:
        ans+=200000
    elif ai==3:
         ans+=100000
if A[0]==1 and A[1]==1:
    ans+=400000
print(ans)

Measured memory_bytes: 38480
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  double fa=a,fb=b;
  //cout << (a/b) <<" "<<(a%b)<<" "<<(fa/fb)<<endl;
  printf("%d %d %.5f\n",(a/b),(a%b),(fa/fb));
  return 0;
}


Measured memory_bytes: 3232
#!python3.4
# -*- coding: utf-8 -*-
# abc156/abc156_c
import sys
import math

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    X = i2nn()
    ave = round(sum(X) / N)
    print(sum(map(lambda x: (x - ave)**2, X)))
    return

main()


Measured memory_bytes: 3064
#include<algorithm>
#include<iostream>
#include<cstring>

const int INF = 1 << 30;

int W, H, K;
// 00 → 右 01 → 下 10 → 左 11 → 上
int memo[1 << 12][4][50][50];
int dx[] = { 1, 0, -1, 0 }, dy[] = { 0, 1, 0, -1 };
char field[50][50];
int mask;

int rec( int bit, int k, int y, int x )
{
	if( memo[bit][k][y][x] != -1 )
		return memo[bit][k][y][x];

	if( y == H - 1 && x == W - 1 && !k )
		return 0;

	int tx = x, ty = y;
	bool f = false;
	for( int i = 0; i != 2 * K; ++i )
	{
		tx -= dx[( bit >> ( 2 * i ) ) & 3];
		ty -= dy[( bit >> ( 2 * i ) ) & 3];

		if( tx == x && ty == y )
		{
			f = true;
			break;
		}
	}

	int ret = 0;
	
	if( !f && field[y][x] >= '0' && field[y][x] <= '9' )
		ret += field[y][x] - '0';

	int ans = -INF;

	for( int i = 0; i != 4; ++i )
	{
		if( !k && i >= 2 )
			break;

		int nx = x + dx[i], ny = y + dy[i];
		if( nx >= 0 && nx < W && ny >= 0 && ny < H && field[ny][nx] != '#' )
			ans = std::max( ans, rec( ( ( bit << 2 ) | i ) & mask, k - ( i >= 2 ), ny, nx ) + ret ); 
	}

	return memo[bit][k][y][x] = ans;
}

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

	mask = ( 1 << ( 4 * K ) ) - 1;

	for( int i = 0; i != H; ++i )
		for( int j = 0; j != W; ++j )
			std::cin >> field[i][j];

	memset( memo, -1, sizeof( memo ) );
	int ans = rec( 0, K, 0, 0 );
	std::cout << ( ans < 0 ? 0 : ans ) << std::endl;

	return 0;
}

Measured memory_bytes: 161176
a = [list(map(int,input().split())) for i in range(3)]

n = int(input())

b = [int(input()) for i in range(n)]

f = 0

for i in range(n):
  for m in range(3):
    for n in range(3):
      if a[m][n] ==b[i]:
        a[m][n]='o'
for i in range(3):
  if a[0][i]=='o' and a[1][i]=='o' and a[2][i]=='o':
    f+=1

for i in range(3):
  if a[i][0]=='o' and a[i][1]=='o' and a[i][2]=='o':
    f +=1 

if a[0][0]=='o' and a[1][1]=='o' and a[2][2]=='o':
  f+=1

if a[0][2]=='o' and a[1][1]=='o' and a[2][0]=='o':
  f+=1
  
if f ==0:
  print('No')
else:
  print('Yes')

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long int lli;
typedef long long ll;


int main(){
  int n,m; cin >> n >> m;
  priority_queue<lli> a;
  rep(i,n){
    lli num; cin >> num;
    a.push(num);
  }

  rep(i,m){
    lli price = a.top()/2;
    a.pop();
    a.push(price);
  }

  lli sum = 0;
  while(a.size() > 0){
    sum += a.top();
    a.pop();
  }

  cout << sum << endl;

}


Measured memory_bytes: 1400
#include<iostream>
#include<cmath>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	int c = (a + b) / 2;
	if ((a + b) % 2 != 0) {
		c += 1;
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using Tuple = tuple<int, int, int>;

ll modnum = 1e9+7;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int main() {
    ll n,k; cin >> n >> k;
    ll ans = 0;

    vector<ll> count(k+10, 0);
    for(ll i=k; i > 0; i--) {
        ll num = k/i;
        ll tmp = modpow(num, n, modnum);
        count[i] = tmp;
        ll ii = i*2;
        while(ii <= k) {
            count[i] -= count[ii];
            ii += i;
        }
    }


    EFOR(i,1, k) {
        ans += i*count[i]%modnum;
        ans %= modnum;
    }



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


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

int n,m;

signed main()
{
	cin >> n;
	for(int i = 1; i <= 9; i ++)
		for(int j = 1; j <= 9; j ++)
			if(n == i*j) {
				cout<<"Yes";
				return 0;
			}
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, s;
    cin >> n >> s;

    vector<int> x(n);
    vector<int64_t> c(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> c[i];
    }
    int mid = lower_bound(x.begin(), x.end(), s) - x.begin();
    int left = 0, right = n - 1;
    int64_t ans = 0;
    int prev = -1;
    while (left < mid && right >= mid) {
        if (c[left] < c[right]) {
            if (prev != -1){ 
                ans += abs(x[left] - x[prev]);
            }
            c[right] += c[left];
            prev = left++;
        } else {
            if (prev != -1){ 
                ans += abs(x[right] - x[prev]);
            }
            c[left] += c[right];
            prev = right--;
        }
    }
    if (left < mid) {
        ans += s - x[left];
        if (prev != -1) {
            ans += abs(x[left] - x[prev]);
        }
    }
    if (right >= mid) {
        ans += x[right] - s;
        if (prev != -1) {
            ans += abs(x[right] - x[prev]);
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1408
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (ql:quickload '(:cl-debug-print :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
#-swank (disable-debugger) ; for CS Academy

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (declare #.OPT)
  (let* ((s (read-line))
         (n (length s))
         (nexts (make-array (list n 26) :element-type 'uint32))
         (dp (make-array (+ n 1) :element-type 'uint32))
         (seqs (make-array (+ n 1) :element-type 'list)))
    (declare ((simple-array character (*)) s)
             (uint31 n))
    (let ((table (make-array 26 :element-type 'uint32 :initial-element n)))
      (loop for i from (- n 1) downto 0
            do (setf (aref table (- (char-code (aref s i)) 97)) i)
               (dotimes (c 26)
                 (setf (aref nexts i c) (aref table c)))))
    (setf (aref dp n) 1)
    (setf (aref seqs n) (list #\a))
    (loop for i from (- n 1) downto 0
          for res = #xffffffff
          do (dotimes (c 26)
               (if (= n (aref nexts i c))
                   (when (< 1 res)
                     (setf res 1)
                     (setf (aref seqs i) (list (code-char (+ c 97)))))
                   (let ((new-value (+ 1 (aref dp (+ 1 (aref nexts i c))))))
                     (when (< new-value res)
                       (setf res new-value)
                       (setf (aref seqs i)
                             (cons (code-char (+ c 97))
                                   (aref seqs (+ 1 (aref nexts i c)))))))))
             (setf (aref dp i) res))
    (dolist (c (aref seqs 0))
      (write-char c))
    (terpri)))

#-swank (main)


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

using namespace std;

#define pb push_back
#define mp make_pair
constexpr int INF = 1 << 29;
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

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

int main() {
	int n;
	cin >> n;
	int ma = -10000;
	int mi = 10000;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		ma = max(ma, a);
		mi = min(mi, a);
	}
	cout << ma - mi << endl;
	return 0;
}


Measured memory_bytes: 256
/*#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <ctime>
#include <vector>
#include <queue>
#include <map>
#include <set>*/
#include<bits/stdc++.h>
using namespace std;
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define int long long 
const int p=998244353;
int w,t,K,ans,x,y,A,B,N,fac[10000010],ifac[10000010];
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
long long c(int a,int b)
{  if (b>a) return 0; 
   if (b==0 || b==a)  return 1; return ((fac[a]*ifac[a-b]%p*ifac[b]%p)+p)%p;
}
long long pm(long long a,long long b)
{  long long t=1;
  for (;b;b=b/2,a=(a*a)%p)  if (b%2)  t=(t*a)%p;
  return t;
}
int exgcd(int a,int b,int &x,int &y)
{  if (b==0)  {  x=1;  y=0; return a;}
    int t1=exgcd(b,a%b,x,y);
	int tmp=x;
	x=y;y=tmp-(a/b)*y;  
	return t1;
}
void deal(int x,int y)
{ ans=(ans+c(N,x)*c(N,y)%p)%p; }
signed main()
{ // freopen("biscuits.in","r",stdin);
 //  freopen("biscuits.out","w",stdout);
  fac[0]=1; for (int i=1;i<=10000001;i++)  fac[i]=fac[i-1]*i%p;
   ifac[10000001]=pm(fac[10000001],p-2);
  for (int i=10000000;i;i--)  ifac[i]=(ifac[i+1]*(i+1))%p;
   ifac[0]=1; // cout<<facp7<<endl;
  N=read(); A=read(); B=read(); K=read();
  if ((A==0 &&  B==0) && K)  cout<<0<<endl;  
  if (A==0 && B==0 && K==0)  cout<<pm(4,N)<<endl;
  else
  {  if (A==0 || B==0)  
    {w=max(A,B);if (K%w)  cout<<0<<endl; else cout<<pm(2,N)*c(N,K/w)%p<<endl;}
	else
	{  
     t=exgcd(A,B,x,y); 
    if (K%t) {  cout<<0<<endl;}
    else {w=B/t;x=x*(K/t);
	      x=(x%w+w)%w; y=(K-x*A)/B;
	      
	      while (x>=0 && y>=0 && x<=N)
		  { if (y<=N) deal(x,y);
		    x+=w;
		    y=(K-x*A)/B;
		  }
		  cout<<ans<<endl;
		  }
	}
    }
}

Measured memory_bytes: 156544
#include<stdio.h>

int main(void)
{
	int x,n;
	int a[1000]={0},b[1000]={0},c[1000]={0},jud[1000]={0};

	scanf("%d",&x);
	
	for(n=0;n<x;n++)
	{
		scanf("%d %d %d",&a[n],&b[n],&c[n]);

		a[n]=a[n]*a[n];
		b[n]=b[n]*b[n];
		c[n]=c[n]*c[n];

		if(a[n]==(b[n]+c[n])||b[n]==(a[n]+c[n])||c[n]==(a[n]+b[n]))
		{
			jud[n]=1;
		}
		else
		{
			jud[n]=0;
		}
	}

	for(n=0;n<x;n++)
	{
		if(jud[n]==1)
		{
			printf("YES\n");
		}
		else if(jud[n]==0)
		{
			printf("NO\n");
		}
	}

	return 0;
}

Measured memory_bytes: 1024
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#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 <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<50);
const double inf=pow(10,10);
const ld pi=acosl(1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

void solve(){
	ll n;
  cin>>n;
  vector<pair<ll,ll>>v;
  rep(i,n){
    ll x,l;cin>>x>>l;
    v.push_back(make_pair(x+l,x-l));
  }
  sort(all(v));
  ll now=-INF;
  ll ans=0;
  rep(i,n){
    if(now<=v[i].second){
      ans++;
      now=v[i].first;
    }
  }
  cout<<ans<<endl;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	solve();
}


Measured memory_bytes: 2420
#include<iostream>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if (a < b) {
		cout << "a < b" << endl;
	}
	else if(a>b){
		cout << "a > b" << endl;
	}
	else {
		cout << "a == b" << endl;
	}
	
	return 0;
}


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

using namespace std;

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

	vector <long long> a(n+1);
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}

	vector <long long> sp(n+1), s(n+1);

	for (int i = 1; i <= n; ++i) {
		if(a[i] >= 0)sp[i] += sp[i-1] + a[i];
		else sp[i] = sp[i-1];

		s[i] += s[i-1] + a[i];
	}
	long long ans = 0;
	for (int i = 1; i <= n - k + 1; ++i) {
		ans = max(ans, sp[i-1] + max(0LL, s[i+k-1] - s[i-1]) + sp[n] - sp[i+k-1]);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int H,W,h,w;
int main() {
  cin >> H >> W >> h >> w;
  cout << H * W - (w*H+h*W - h*w) << endl;
  return 0;
}

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

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    string s,t, n;
    int c=0;
    cin>>s;
    cin>>t;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]!=t[i])
            c++;
    }
    cout<<c<<nl;
    return 0;
}



Measured memory_bytes: 3912
inps = input().split()
if len(inps) >= 2:
    a = int(inps[0])
    b = int(inps[1])
    if a > b:
        print("a > b")
    elif a < b:
        print("a < b")
    else:
        print("a == b")
else:
    print("Input illegal.")

Measured memory_bytes: 7608
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
    
int main(){
    int N;
    cin>>N;
    vector<LL> a(3*N);
    cin>>a;
    sort(ALL(a));
    reverse(ALL(a));
    LL sum=0;

    REP(i,N){
        sum+=a[i*2+1];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 2560
#include <math.h>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <functional>
#include <typeinfo>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define mp(a, b) make_pair(a, b)
#define all(vec) (vec).begin(), (vec).end()
#define yn(formula) (formula) ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(formula) (formula) ? (cout << "YES" << endl) : (cout << "NO" << endl)
#define MIN(a, b) ((a) < (b)) ? (a) : (b)
#define LLONG_MAX     9223372036854775807i64

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
typedef vector<vll> vvl;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vp> vvp;
typedef vector<vpl> vvpl;

constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 29;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };

struct edge { ll to; ll cost; };

/*<ここから>***********************************************************/


int main()
{
	int N;
	cin >> N;
	vll A(N);
	rep(i, N) cin >> A[i];

	vll a(N + 1, 0);
	rep(i, N) a[i + 1] = A[i];
	rep(i, N) a[i + 1] += a[i];

	ll ans = 0;
	sort(all(a));

	ll p1 = 0, p2;
	while (p1 < N + 1) {

		p2 = p1 + 1;
		ll n = 1;
		while (p2 < N + 1 && a[p1] == a[p2]) {
			n++;
			p2++;
		}

		if (n >= 2) ans += n * (n - 1) / 2;
		p1 = p2;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

long mod = 1000000007;
/* C++の構造体 メンバがpublicなclass */
typedef struct mint
{
    ll x;
    mint(ll x = 0) : x(x % mod) {} //コンストラクタ
    /* 演算子オーバーロード */
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
} mint_t;

ll intpow(mint_t m, int n)
{
    if (n == 0) return 1;
    mint_t ans(1);
    while (n >= 1)
    {
        if ((n % 2) == 0){
            m *= m.x;
            n /= 2;
        }else {
            ans *= m.x;
            n -= 1;
        }
    }
    return ans.x;
}

/*
和としてあり得るものの数の個数を求める。
各数字は10^100+a(0<=a<=N)である。

10^100が巨大な数のため、和を構成する足される数が違えば、かならず異なる数になる。
よって、m個(K<=m<=N+1)足された時の場合の数f(m)を独立で求めて足し合わせればよい。

m個選んだ時の最小数は、0,....,m-1のtotalなので、m(m-1)/2
m個選んだ時の最大数は、N,N-1,...,N-(m-1)のtotalなので、Nm-m(m-1)/2
最大数-最小数+1より、Nm - m(m-1) + 1

*/

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

    mint ans(0);
    for (ll i = k; i <= n+1; i++)
    {
        ll tans = (n*i) - (i*(i-1)) + 1;
        ans += tans;
    }
    cout << ans.x << endl;
}



Measured memory_bytes: 3648
#include <stdio.h>

int main()
{
  int r,d,x;
  scanf("%d%d%d",&r,&d,&x);
  int i;
  i = 0;
  while (i < 10)
  {
    x = r*x - d;
    printf("%d\n",x);
    i++;
  }
}

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

using namespace std;

#define F first
#define S second
typedef long long ll;
typedef long double ld;

int32_t main(){
	ll a, b;
	cin >> a >> b;
	if (a == 1 || b == 1){
		cout << 1;
	}else
		cout << (a * b + 1) / 2;
}

Measured memory_bytes: 256
from collections import defaultdict
S = input()

d = defaultdict(int)

for i in range(len(S)):
    d[S[i]] += 1
f = 0
if len(d) != 2:
    f = 1
for d_key in d:
    if d[d_key] != 2:
        f = 1
        break

if f == 0:
    print("Yes")
else:
    print("No")


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

const int N = 100005; 

using namespace std; 

int n, a[N], s[N<<1]; 

int main() {

	cin >> n; 
	for(int i=1; i<=n; ++i) cin >> a[i], ++a[i]; 

	for(int i=1; i<=n; ++i) {
		++s[a[i]-1]; 
		++s[a[i]];
		++s[a[i]+1]; 
	}

	int mx=0; 
	for(int i=1; i<(N<<1); ++i)
		if(s[i] > mx) mx = s[i];

	cout << mx << endl; 

	return 0; 
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N,K;
    string S;
    cin >> N >> S >> K;
    rep(i,N){
        if(S[i]!=S[K-1])S[i] ='*';
    }
    cout << S << endl;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
a = [input() for _ in range(h)]
for i in range(h):
    for j in range(w):
        ans = 0
        if a[i][j] == ".":
            for s in range(-1, 2):
                for t in range(-1, 2):
                    if 0 <= i + s < h  and 0 <= j + t < w:
                            if a[i+s][j+t] == "#":
                                ans += 1
                    else:
                        continue
            print(ans, end="")
        else:
            print("#", end="")
    print()



Measured memory_bytes: 3444
#![allow(non_snake_case)]
#![allow(unused_imports)]
 
use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;

#[fastout]
fn main() {
    input!{
        k: usize,
        a: usize, b: usize,
    }
    let flag: bool = if (a..=b).filter(|x| x % k == 0).collect::<Vec<usize>>().len() != 0 { true } else { false };

    if flag {
        println!("OK");
    } else {
        println!("NG");
    }
    
}


Measured memory_bytes: 2140
#include <iostream>
    #include <string>
    #include <set>  
    #include <stack>
    #include <algorithm>
    #include <vector>
    #include <cmath>
    #include <queue>
    #include <deque>
    #include <cstring>
    #include <cstdio>
    #include <map>
    #include <numeric>
    #include <cassert>
    #include <iomanip>
    #include <sstream>
    #include <ctime>
    #include <bitset> 
using namespace std;
#define for1(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,maxn) for1(i,0,maxn)
#define ford(i,b,a) for(int i=(int)(b)-1;i>=a;--i)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pii > piii;
#define inf 0x3f3f3f3f
#define mod 1000000007
#define st first
#define nd second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define dprintf(...) printf(__VA_ARGS__)
const int maxn=5e5+10;
vector<pii> g[maxn];
int cst[maxn];
bool vis[maxn];
int n,m;
map<pii,int> id;
int ind;
void add_edge(int u,int v,int cu,int cv)
{
	g[u].pb(mp(v,cu));
	g[v].pb(mp(u,cv));
}
int getid(int u,int c)
{
	if(!id[mp(u,c)])
	{
		id[mp(u,c)]=ind++;
		add_edge(u,ind-1,1,0);
	}
	return id[mp(u,c)];
}
int main()
{
	scanf("%d %d",&n,&m);
	ind=n;
	rep(i,m)
	{
		int p,q,c;
		scanf("%d %d %d",&p,&q,&c);
		p--,q--;
		int a=getid(p,c);
		int b=getid(q,c);
		add_edge(a,b,0,0);
	}
	memset(vis,0,sizeof(vis)); 
	priority_queue<pii > que;
	que.push(mp(0,0));
	while(!que.empty())
	{
		int cur=que.top().st;
		int cid=que.top().nd;
		que.pop();
		if(vis[cid])continue;
		vis[cid]=1;
		if(cid==n-1)
		{
			printf("%d\n",-cur);
			return 0;
		}
		rep(i,g[cid].size())
		{
			int to=g[cid][i].st;
			int val=g[cid][i].nd;
			que.push(mp(cur-val,to));
		}
	}
	printf("-1\n");
	return 0;
}

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

int main() {

  int N;
  cin >> N;

  vector<int> a(N+1);
  vector<int> b(N+1);
  vector<int> c(N+1);

  for (int i = 1; i <= N; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }

  int answer = 0;

  // dp[i][0]:a dp[i][1]:b dp[i][2]:c
  vector<vector<int>> dp(N+1,vector<int>(3));

  for (int i = 1; i <= N; i++) {
      dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
      dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
      dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
  }

  cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;

}

Measured memory_bytes: 6912
#include <stdio.h>

int main()
{
   int x[5];


   for(int i=0; i<5; i++)
   {
      scanf(" %d", &x[i]);

      if(x[i] == 0)
      {
         printf("%d\n", i+1);
         return 0;
      }
   }
   return 0;
}


Measured memory_bytes: 1732
#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
using namespace std;
typedef long long ll;

int n,k,d,x,ans;
int a[105]; 

int main()
{
	cin>>n>>k;
	
	while(k--)
	{
		cin>>d;
		for(int i=0;i<d;i++)
		{
			cin>>x;
			a[x]++;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]==0) ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3636
import itertools
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
Nlist = []
for i in range(N):
    Nlist.append(i+1)

J = list(itertools.permutations(Nlist, N))

count = 0
for i in range(len(J)):
    if J[i] == P:
        a = i+1
        count += 1
        if count == 2:
            break
    if J[i] == Q:
        b = i+1
        count += 1
        if count == 2:
            break

print(abs(a-b))


Measured memory_bytes: 13792
#include <stdio.h>
int main () {
  char str[100000];
  char look_now, look_ahead;
  int count = 0;
  int i = 0;

  scanf ("%s", str);

  while (1) {
    look_ahead = str[i + 1];
    look_now   = str[i];
    // printf ("%d %d\n", look_now, look_ahead);
    if (look_ahead == 0) break;
    if (look_now != look_ahead) count++;
    i++;
  }

  printf ("%d", count);

  return 0;
}


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

int main(){
int N;
  cin >> N;
int d[N];
for(int i=0;i<N;i++) cin >> d[i]; 
  
int count=1;
int needh=0;  
for(int i=0;i<N-1;i++){

if(d[i]>d[i+1] && needh==0){
  needh=-1;
  continue;
 }
if(d[i]<d[i+1] && needh==0){
  needh=1;
  continue;
}
if(needh==1 && d[i]>d[i+1]){
count++;
needh=0;  
}  

if(d[i]<d[i+1] && needh==-1){
count++;
needh=0;  
}        
} 

cout << count << endl;
}

Measured memory_bytes: 3988
import Control.Applicative ((<$>))
import Control.Monad (unless)
import Data.List (group)

main :: IO ()
main = do
  n <- readLn
  unless (n == 0) $ do
    solve n <$> getLine >>= putStrLn
    main

solve :: Int -> String -> String
solve n s = iterate f s !! n
  where f = concat . map g . group
        g x = show (length x) ++ [head x]



Measured memory_bytes: 4064
import java.util.*;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if (s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5))
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

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

#define int unsigned long long

signed main() {
#ifdef _DEBUG
	freopen("in" , "r", stdin );
	//freopen("out", "w", stdout);
#endif
	int a, b; cin >> a >> b;
	for (int i = b * 10; i < b * 10 + 10; i++) {
		if (i * 8 / 100 == a) {
			cout << i << '\n';
			return 0;
		}
	}
	cout << -1  << '\n';
}

Measured memory_bytes: 256