akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

int main(void){
  while(true){
    int posx = 10, posy = 10;
    int cnt = 0;
    int numOfJewel, numOfOrder;
    bool isJewel[21][21];

    for(int i=0; i < 21; i++){
      for(int j =0; j < 21; j++){
        isJewel[i][j] = false;
      }
    }

    std::cin >> numOfJewel;
    if(numOfJewel == 0) return 0;
    for(int i=0; i < numOfJewel; i++){
      int x, y;
      std::cin >> x >> y;
      isJewel[y][x] = true;
    }

    std::cin >> numOfOrder;
    for(int i=0; i < numOfOrder; i++){
      char order;
      int dist;
      std::cin >> order >> dist;
      for(int j = 0; j < dist; j++){
        if(order == 'N'){
          posy++;
        }else if(order == 'S'){
          posy--;
        }else if(order == 'E'){
          posx++;
        }else if(order == 'W'){
          posx--;
        }
        if(isJewel[posy][posx] == true){
          cnt++;
          isJewel[posy][posx] = false;
        }
      }
    }
    if(cnt == numOfJewel){
      std::cout << "Yes" << std::endl;
    }else{
      std::cout << "No" << std::endl;
    }
  }
}

Measured memory_bytes: 1152
fun main(args: Array<String>) {
    while (true) {
        var count = 0
        val (n, target) = readLine()?.split(" ")?.map { it.toInt() } ?: return
        if (n == 0 && target == 0) break
        val checker = hashSetOf<CustomTriple>()
        (1..n).forEach { i ->
            for (j in 2..n){
                if(i == j) continue
                for (k in 3..n){
                    if(j == k || k == i) continue
                    if (i + j + k == target) {
                        var hasCombination = false
                        val tri = CustomTriple(i,j,k)
                        for (it in checker)  {
                            if (it.equals(tri)) {
                                hasCombination = true
                                break
                            }
                        }
                        if (!hasCombination){
                            count++
                            checker.add(tri)
                        }
                    }
                }
            }
        }
        println(count)
    }
}

data class CustomTriple(val f: Int, val s: Int, val t:Int){

    override fun equals(other: Any?): Boolean {
        return other != null &&
                other is CustomTriple &&
                (this.f == other.f || this.f == other.s || this.f == other.t) &&
                (this.s == other.f || this.s == other.s || this.s == other.t) &&
                (this.t == other.f || this.t == other.s || this.t == other.t)
    }

    override fun hashCode(): Int {
        return super.hashCode()
    }
}


Measured memory_bytes: 40748
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	while(cin >> n) {
		vector<int> arr; arr.resize(n, 0);
		for(int i = 0; i < n - 1; i++) {
			int x; 
			cin >> x; 
			arr[x - 1]++;
		}
		for(int i = 0; i < n; i++) {
			cout << arr[i] << endl;
		}
	}
	return 0;	
}


Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	int result = 0;
	for (int i = a; i < b + 1; i++) {
		if (i / 10000 == i % 10 && i / 1000 - i / 10000 * 10 == i / 10 - i / 100 * 10) result++;
	}
	cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
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;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    int n;
    scanf("%d", &n);
    set<int> S;
    rep(i, n){
        int a;
        scanf("%d", &a);
        S.insert(a);
    }
    puts(S.size() == n ? "YES" : "NO");
}

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

typedef long long ll;

int main() {
	// your code goes here
	ll x, ans=0;
	cin>>x;
	ans=x/11LL;
	ans*=2;
	if(x%11LL) {
		x=x%11LL;
		if(x>6)	ans+=2;
		else	ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


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

			Scanner sc = new Scanner(System.in);
          	int N = sc.nextInt();
            sc.nextLine();
          	String str = sc.nextLine();
          	StringBuilder strn = new StringBuilder(str);
          
          	for(int i = 0; i < str.length(); i++){
                int temp = (int)str.charAt(i) + N;
                String temp_char = "";
                if(temp <= 90)
            	    temp_char += (char)temp;
                else 
                    temp_char += (char)(temp - 26);
                
                strn.replace(i, i + 1, temp_char);
            }
          	System.out.println(strn);
			
	    }
		
	}

Measured memory_bytes: 40776
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N, K;
  cin >> N >> K;
  vector<long long>sum_u(N + 2);
  sum_u[0] = 0;
  vector<long long>sum_a(N + 2);
  sum_a[0] = 0;
  for (int i = 1; i <= N + 1; i ++) {
    sum_u[i] = (long long)sum_u[i - 1] + i - 1;
    sum_a[i] = (long long)sum_a[i - 1] + N - i + 1;
  }
  const long long mod = 1e9 + 7;
  long long ans = 0;
  for (int i = N + 1; i >= K; i --) {
    ans += sum_a[i] - sum_u[i] + 1;
    ans %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6428
x,n = map(int,input().split())
P  = list(map(int,input().split()))
ans = 0
neko = float("inf")
for i in range(-100,102):
    if i in P:
        continue
    if neko > abs(i - x):
        neko = abs(i - x)
        ans = i
print(ans)

Measured memory_bytes: 61884
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, k; cin>>n>>k;
    vector<int> steps;
    for(int i=0;i<n;i++)
    {
        int t; cin>>t; steps.push_back(t);
    }
    vector<int> ans(n,0);
    for(int i=n-1;i>=0;i--)
    {
      int mini = INT_MAX;
      for(int j=1;j<=k;j++)
      {
        if(i+j>=n) break;
        mini = min(mini, ans[i+j]+abs(steps[i]-steps[i+j]));
      }
      if(mini == INT_MAX) ans[i] = 0;
      else ans[i] = mini;
      //cout<<"inside\n";
       /* if(i==n-2)
        {
            ans[i] = abs(steps[i+1]-steps[i]);
        }
        else
        {
            ans[i] = min(ans[i+1]+abs(steps[i+1]-steps[i]), ans[i+2]+abs(steps[i+2]-steps[i]));
        }*/
    }
    cout<<ans[0];
    return 0;
}

Measured memory_bytes: 1144
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

vector<int> v[100000];
int c[100000];
bool no;

void dfs(int x){
	for(auto y:v[x]){
		if(c[y]==0){
			c[y]=-c[x];
			dfs(y);
		}else if(c[y]==c[x]){
			no=1;
		}
	}
}

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	for(int i=0; i<m; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	c[0]=1;
	dfs(0);
	ll n0=n, m0=m;
	if(no){
		cout<<n0*(n0-1)/2-m0<<endl;
	}else{
		ll ct=0;
		for(int i=0; i<n; i++){
			if(c[i]==1) ct++;
		}
		cout<<ct*(n0-ct)-m0<<endl;
	}
    return 0;
}

Measured memory_bytes: 6528
#include<cstdio>
#include<cstring>
using namespace std;
char s[1010];
bool W,E,S,N;
int main()
{
	scanf("%s",s+1);
	for(int i=1,l=strlen(s+1);i<=l;++i)W|=s[i]=='W',E|=s[i]=='E',S|=s[i]=='S',N|=s[i]=='N';
	if((W^E)||(N^S))puts("No");else puts("Yes");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
/* END OF TEMPLATE */

ll dp[100010][3];

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll a[n][3];
    rep(i, n){
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    rep(i, 3){
        dp[0][i] = a[0][i];
    }
    repr(i, 1, n){
        dp[i][0] = max(dp[i-1][1]+a[i][0], dp[i-1][2]+a[i][0]);
        dp[i][1] = max(dp[i-1][0]+a[i][1], dp[i-1][2]+a[i][1]);
        dp[i][2] = max(dp[i-1][0]+a[i][2], dp[i-1][1]+a[i][2]);
    }
    cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
typedef long long ll;
typedef pair<int, int> pii;
template<typename T> void show(T e){ cout << e << endl; }
template<typename T> void show(const vector<T>& v){ for(const auto& e : v){ cout << e << " "; } cout << endl; }
template<typename T> void show(const vector<vector<T>>& vv){ for(const auto& v : vv){ show(v); } }

int main(int argc, char const *argv[])
{
  ll N;
  cin >> N;
  vector<ll> arr(N+1);
  unordered_map<ll, int> pos;
  RNG(i, 1, N+1) {
    cin >> arr[i];
    pos[arr[i]] = i;
  }
  set<ll> st{0, N+1};
  ll res = 0;
  for(ll snd = N; snd >= 1; snd--) {
    ll idx = pos[snd];

    auto it = st.lower_bound(idx);
    if (*it != N+1) { // next & next^2 larger
      res += snd * (*next(it) - *it) * (idx-*prev(it));
    }
    if (*prev(it) != 0) { // prev & prev^2 larger
      res += snd * (*prev(it)-*prev(prev(it))) * (*it-idx);
    }
    st.insert(idx);
  }
  cout << res << endl;
  // show(arr);
  return 0;
}


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

A = input()
B = input()
C = input()

cnt = 0

for i in range(N):
  if A[i] != B[i]:
    cnt += 1
    if A[i] != C[i] and B[i] != C[i]:
      cnt  += 1
  else:
    if A[i] != C[i]:
      cnt += 1

print(cnt)


Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <algorithm>
#include <climits>
#include <map>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <climits>
using namespace std;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef long long int ll;
 
 
//int memo[1000010] = {0,0,1};
double PI = 3.14159265359;
 
ll MOD = 10e9 + 7;
 
ll dataA[500010];
ll dataB[500010];
 
class fenwick {
public:
 
    void Add(int a, int b, int x, int k, int l, int r) {
        if (a <= l && r <= b) {
            dataA[k] += x;
        }
        else if (l < b && a < r) {
            //cout << a << ":" << b << endl;
            dataB[k] += (min(b, r) - max(a, l))*x;
            Add(a, b, x, k * 2 + 1, l, (l + r) / 2);
            Add(a, b, x, k * 2 + 2, (l + r) / 2, r);
        }
 
    }
 
    ll sum(int a, int b, int k, int l, int r) {
        if (b <= l || r <= a) {
            return 0;
        }
        else if (a <= l && r <= b) {
            return dataA[k] * (r - l) + dataB[k];
        }
        else {
            ll res = (min(b, r) - max(a, l)) * dataA[k];
            res += sum(a, b, k * 2 + 1, l, (l + r) / 2);
            res += sum(a, b, k * 2 + 2, (l + r) / 2, r);
            return res;
        }
    }
};
 
vector<pair<int,pair<int,int>>> gift;
 
int main(void) {
    // Here your code !
    ll n,m;
    cin >> n >> m;
 
    for (int i = 0; i < n; i++) {
        int l,r;
        cin >> l >> r;
        gift.push_back(pair<int, pair<int, int>>(r-l+1,pair<int,int>(l,r)));
    }
 
    fenwick fwk;
 
    sort(gift.begin(),gift.end());
    int t = 0;
 
    //cout << endl;
 
    for (int i = 1; i <= m; i++) {
 
        for (; t < n; t++) {
            if (gift[t].first <= i) {
                //cout << gift[t].second.first << " " << gift[t].second.second << endl;
                fwk.Add(gift[t].second.first,gift[t].second.second+1,1,0,0,m+1);
            }
            else {
                break;
            }
        }
 
        ll res = n-t;
        //cout << res << endl;
 
        for (int j = 0; j <= m; j+=i) {
            res += fwk.sum(j,j+1,0,0,m+1);
        }
 
        cout << res << endl;
 
    }
 
 
}

Measured memory_bytes: 7660
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 2147483647//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;

bool atgc(char c){
    if(c == 'A' || c == 'T' || c == 'G' || c == 'C')return true;
    else return false;
}

int main() {
    string s;
    cin >> s;
    int maxi = 0;
    int memo = 0;
    rep(i,s.size()){
        if(atgc(s[i])){
            memo++;
            maxi = max(memo,maxi);
        }else{
            memo = 0;
        }
    }
    cout << maxi << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 100005;

int N, MOD, dp[MAXN], up[MAXN];
vector<int> G[MAXN], pref[MAXN], suff[MAXN];

void dfs1(int v, int p) {
//	cout << "DFS1 " << v << " " << p << "\n";
	dp[v] = 1;
	for (int to : G[v]) {
		if (to == p) continue;
		dfs1(to, v);
		dp[v] = (LL)dp[v] * (dp[to] + 1) % MOD;
	}
	
	pref[v].resize(G[v].size() + 1);
	pref[v][0] = 1;
	for (int i = 0; i < G[v].size(); i++) {
		int to = G[v][i];
		LL mul = to == p ? 1 : dp[to] + 1;
		pref[v][i + 1] = pref[v][i] * mul % MOD;
	}
	
	suff[v].resize(G[v].size() + 1);
	suff[v][G[v].size()] = 1;
	for (int i = G[v].size() - 1; i >= 0; i--) {
		int to = G[v][i];
		LL mul = to == p ? 1 : dp[to] + 1;
		suff[v][i] = suff[v][i + 1] * mul % MOD;
	}
}

void dfs2(int v, int p) {
//	cout << "DFS2 " << v << " -> " << dp[v] << " " << up[v] << "\n";
	for (int i = 0; i < G[v].size(); i++) {
		int to = G[v][i];
		if (to == p) continue;
//		cout << "Set " << to << " " << i << " -> " << pref[v][i] << " " <<  suff[v][i + 1] << "\n";
		up[to] = (1LL + (LL)pref[v][i] * suff[v][i + 1] % MOD * up[v] % MOD) % MOD;
		dfs2(to, v);
	}
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N >> MOD;
	for (int i = 0; i < N - 1; i++) {
		int x, y;
		cin >> x >> y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	
	dfs1(1, 1);
	up[1] = 1;
	dfs2(1, 1);
	
	for (int i = 1; i <= N; i++) {
		cout << (LL) dp[i] * up[i] % MOD << "\n";
	}
}


Measured memory_bytes: 23936
import java.util.*;

public class Main{
    public static void main(String[] args){
      	final int A = 1000005;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
      	int a[] = new int [n];
        int c[] = new int [A];
        int b;
        String ans = "pairwise coprime";
        for(int i = 0; i < A; i++){
            c[i] = 0;
        }
        for(int i = 0; i < n; i++){
            b = sc.nextInt();
            c[b] += 1;
        }

        for(int i = 2; i < A; i++){
            int cnt = 0;
            for(int j = i; j < A; j += i){
                cnt += c[j];
            }
            if(cnt == n){
                ans = "not coprime";
                break;
            }else if(cnt > 1){
                ans = "setwise coprime";
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 63844
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.next());

        int taro = 0;
        int hanako = 0;
        for (int i = 0; i < n; i++) {
            String TS = sc.next();
            String HS = sc.next();

            if (TS.compareTo(HS) > 0) {
                taro += 3;
            } else if (TS.compareTo(HS) < 0){
                hanako += 3;
            } else if (TS.compareTo(HS) == 0) {
                taro++;
                hanako++;
            }
        }
        System.out.printf("%d %d\n", taro, hanako);
    }
}

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


#define M 1000000007
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define mod 998244353
#define sz(v) (int)(v).size()

#define pii pair<int, int>
#define vi vector<int>
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)

ll add(ll a,ll b)
{
	a%=M;
	b%=M;
	ll p = (a+b)%M;
	return (p+M)%M;
}

ll mul(ll a,ll b)
{
	a%=M;
	b%=M;
	ll p = (a*b)%M;
	return (p+M)%M;
}


int main()
{
	fastio;
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	ll i=0;
	while(b<=a)
	{
		b*=2;
		i++;
	}
	while(c<=b)
	{
		c*=2;
		i++;
	}
	if(i<=k)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
    return 0;
}





Measured memory_bytes: 3644
#include<stdio.h>
#define col 100
#define row 100
 
int main(void) {
  int i,j,n,m;
  int mat[row][col],vec[row];
  int ans[row]={0};
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++)
    for(j=0;j<m;j++)
      scanf("%d",&mat[i][j]);
  for(j=0;j<m;j++)
    scanf("%d",&vec[j]);
  for(i=0;i<n;i++)
    for(j=0;j<m;j++)
      ans[i]+=mat[i][j]*vec[j];
  for(i=0;i<n;i++)
    printf("%d\n",ans[i]);
  return(0);
}

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

using namespace std;

#define MAX_N 10
#define INF 1e9
typedef pair<int,string> P;

int N,bit,len[MAX_N],size;
string s[MAX_N],def;
string dp[1<<MAX_N][MAX_N];
vector<P> G[MAX_N];

void init(){
  bit = 0;
  for(int i = 0 ; i < (1<<N) ; i++){
    for(int j = 0 ; j < N ; j++){
      dp[i][j] = "#";
    }
  }
}

string cat(const string &a,const string &b){
  int l1 = a.size(),l2 = b.size();
  for(int i = min(l1,l2) ; i >= 0 ; i--){
    string suba = a.substr(l1-i,i);
    string subb = b.substr(0,i);
    if(suba == subb){
      size = suba.size();
      return a + b.substr(i);
    }
  }
}

void overlap(int a,int b){
  string s1 = s[a], s2 = s[b];
  if(s2.find(s1) != string::npos &&
     s1.find(s2) == string::npos){
    bit |= (1<<a);
  }
  if(s1.find(s2) != string::npos &&
     s2.find(s1) == string::npos){
    bit |= (1<<b);
  }
}

string solve(int S,int v){
  if(S == (1<<N)-1){
    return s[v];
  }
  if(dp[S][v] != "#"){
    return dp[S][v];
  }
  string res = "#";
  for(int i = 0 ; i < N ; i++){
    if((S >> i) & 1) continue;
    string next = cat(s[v],solve(S|(1<<i),i));
    if(res == "#"){
      res = next;
    }else{
      if(next.size() < res.size()){
        res = next;
      }else if(next.size() == res.size() && next < res){
        res = next;
      }
    }
  }
  return dp[S][v] = res;
}

int main(){
  while(cin >> N, N > 0){
    init();
    for(int i = 0 ; i < N ; i++){
      cin >> s[i];
      len[i] = s[i].size();
    }
    if(N == 1){
      cout << s[0] << endl;
      continue;
    }
    for(int i = 0 ; i < N ; i++){
      for(int j = 0 ; j < N ; j++){
        if(i == j) continue;
        overlap(i,j);
      }
    }
    string res = "#";
    for(int i = 0 ; i < N ; i++){
      if((bit >> i) & 1) continue;
      string r = solve(bit|(1<<i),i);
      if(res == "#"){
        res = r;
      }else{
        if(r.size() < res.size()){
          res = r;
        }else if(r.size() == res.size() && r < res){
          res = r;
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 2060
#include <bits/stdc++.h>
#define fastIO ios::sync_with_stdio(0); cin.tie(NULL);
typedef long long ll;
using namespace std;

ll mod = 1000000007;

int main(){
    fastIO
    
    int n; cin>>n;
    
    int a[n];
    
    ll sum = 0;
    
    for(int i=0; i<n; i++){
      
      cin>>a[i];
      
      sum+=a[i];
      
      sum%=mod;
    }
    
    ll ans=0;
    for(int i=0; i<n; i++){
      
      sum-=a[i];
      
      if(sum<0) sum+=mod;
      
      ans+=(a[i]*sum);
      
      ans%=mod;
      
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4392
#include <bits/stdc++.h>
#define For(i, begin, end) for(int i=begin;i<end;i++)
#define Rep(i, n) For(i,0,n)
#define Sort(v) sort(v.begin(),v.end())
using namespace std;

int main(){
  int A,B;
  cin>>A>>B;
  if(A+B>=10)cout<<"error";
  else cout<<A+B;

  return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  int N;
  string S;

  cin >> N;
  cin >> S;

  string A = "";
  string B = "";

  for (int i = 0; i < N; ++i) {
    A += S[i];
    B += S[2 * N - i - 1];
  }

  map<string, map<string, int> > counter;

  for (int mask = 0; mask <= pow(2, N) - 1; ++mask) {
    string sa = "";
    string sb = "";

    for (int i = 0; i < N; ++i) {
      if ((mask >> i) & 1) {
        sa += A[i];
      } else {
        sb += A[i];
      }
    }

    ++counter[sa][sb];
  }

  ll ans = 0;

  for (int mask = 0; mask <= pow(2, N) - 1; ++mask) {
    string sa = "";
    string sb = "";

    for (int i = 0; i < N; ++i) {
      if ((mask >> i) & 1) {
        sa += B[i];
      } else {
        sb += B[i];
      }
    }

    ans += counter[sa][sb];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 123904
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, u32, u64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);
parse_tuple!(A, B, C, D, E);

// ===

fn main() {
    let n: usize = read();
    let mut polls: Vec<(i32, i32, i32)> = readn(n);

    for x in 0..101 {
        for y in 0..101 {
            let mut valid = true;
            let mut h = -1;
            for p in polls.iter() {
                let th = p.2 + (x-p.0).abs() + (y-p.1).abs();
                if p.2 == 0 {
                    continue;
                }
                if h == -1 || h == th {
                    h = th;
                } else {
                    valid = false;
                    break;
                }
            }
            for p in polls.iter() {
                let th = max(0, h - (x-p.0).abs() - (y-p.1).abs());
                if th != p.2 {
                    valid = false;
                    break;
                }
            }
            if valid && h >= 1 {
                println!("{} {} {}", x, y, h);
            }
        }
    }
}


Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <queue>
#define travel(x, i) for (int i = fir[x]; i; i = e[i].nxt)
using namespace std;

const int N = 1e5 + 5;
const int INF = 1e7;

struct edge {
  int nxt, to;
} e[N << 1];

int fir[N], cnt = 0;
int n, k, col[N];
bool done[N];
priority_queue <pair <int, int> > Q;

inline void add(int x, int y) {
  e[++ cnt] = (edge){fir[x], y};
  fir[x] = cnt;
}

inline int abs(int x) {
  return x >= 0 ? x : - x;
}

int main() {
  scanf("%d", &n);
  for (int i = 1, x, y; i < n; i ++) {
    scanf("%d%d", &x, &y);
    add(x, y); add(y, x);
  }
  scanf("%d", &k);
  int rt = 0;
  for (int i = 1, p, v; i <= k; i ++) {
    scanf("%d%d", &v, &p);
    col[v] = p;
    done[v] = 1;
    Q.push(make_pair(p, v));
  }
  while (!Q.empty()) {
    int x = Q.top().second;
    Q.pop();
    travel(x, i) {
      if (!done[e[i].to]) {
	done[e[i].to] = 1;
	col[e[i].to] = col[x] - 1;
	Q.push(make_pair(col[e[i].to], e[i].to));
      }
      else if (abs(col[x] - col[e[i].to]) != 1) return puts("No"), 0;
    }
  }
  puts("Yes");
  for (int i = 1; i <= n; i ++) printf("%d\n", col[i]);
  return 0;
}


Measured memory_bytes: 4212
import sys
#input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np
from collections import deque

def main():
	n=II()
	G=[]
	for i in range(n):
		G.append(list(map(int,input())))
		#print(G)

	ans=0
	for i in range(n):
		v=[-2]*n
		v[i]=0
		q=deque()
		q.append([i,0])

		while q:
			now,d=q.popleft()
			for j in range(n):
				if G[now][j]==1:
					if v[j]==-2:
						v[j]=d+1
						q.append([j,d+1])
					elif v[j]==d-1 or v[j]==d+1:
						continue
					else:
						print(-1)
						exit(0)
		ans=max(ans,max(v)+1)


	print(ans)

if __name__ == "__main__":
	main()


Measured memory_bytes: 9796
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
for i in range(10**7):
    if i*(i+1)>=2*n:
        m=i
        c=i*(i+1)//2-n
        break
for i in range(1,m+1):
    if i!=c:
        print(i)

Measured memory_bytes: 73496
fun main(args: Array<String>){
    val N :Int = readLine()!!.toInt()
    val x :List<Int> = readLine()!!.split(" ").map(String::toInt)
    var y :List<Int> = x.drop(0).sorted()
    var ans :Int
    val s :Int =y[N/2]
    val t :Int =y[(N/2)-1]
    //y.sort()
    //println(x)
    //println(y)
    for(i in x.indices){
        ans=if(x[i] < s) s else t 
        println(ans)
    }
}


Measured memory_bytes: 98572
# -*- coding: utf-8 -*-

n = int(input())
s = input()

lis_ans = []
for split in range(1,n):
    left = s[:split]
    right = s[split:]
    #print(left, right)
    
    s_left = set(left)
    s_right = set(right)

    ans = 0
    for wl in s_left:
        for wr in s_right:
            if wl == wr:
                ans += 1

    lis_ans.append(ans)

print(max(lis_ans))


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <list>
#include <vector>
using namespace std;
int main()
{
	for(int i=1;i<=9;i++)
		for(int j=1;j<=9;j++)
		{
			cout<<i<<"x"<<j<<"="<<i*j<<endl;
		}
	return 0;
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  int k,n;cin>>k>>n;
  vi a(n);
  rep(i,n) cin>>a.at(i);
  int ans=k+1;
  rep(i,n){
    if(i!=n-1){
      chmin(ans,k-(a.at(i+1)-a.at(i)));
    }else{
      chmin(ans,a.at(n-1)-a.at(0));
    }
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 1024
while True:
    x = input().split(" ")
    h = x[0]
    w = x[1]
    if int(h) == 0 and int(w) == 0:
        break
    else:
        for i in range(0, int(h)):
            if i%2==0 and int(w)%2==0:
                for j in range(0, int(w)//2):
                    print("#.", end="")
            elif i%2==0 and int(w)%2!=0:
                for j in range(0, int(w)//2):
                    print("#.", end="")
                print("#", end="")
            elif i%2!=0 and int(w)%2==0:
                for j in range(0, int(w)//2):
                    print(".#", end="")
            else:
                for j in range(0, int(w)//2):
                    print(".#", end="")
                print(".", end="")
            print()
        print()


Measured memory_bytes: 6388
#include <bits/stdc++.h>
using namespace std;
int n,arr[100005],dp[100005];
int f(int idx){
    if(idx==n)return 0;
    if(idx>n)return 1e9;
    if(dp[idx]!=-1)return dp[idx];
    return dp[idx] = min(abs(arr[idx]-arr[idx+1])+f(idx+1),abs(arr[idx]-arr[idx+2])+f(idx+2) );
}
int main(){
    cin>>n;
    for(int i =1;i<=n;i++)cin>>arr[i];
    memset(dp,-1,sizeof(dp));
    cout<<f(1)<<endl;
}

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

#define dump(x) cout << (x) << endl
#define Int int64_t
#define fi first
#define se second

Int INF = 1e9;
Int mod = 1e9+7;

int main() {
    Int n;
    cin >> n;
    char a[301][301];
    for (Int i = 0; i < n; i++) {
        for (Int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }
    Int res = 0;
    bool check = true;
    for (Int k = 0; k < n; k++) {
        // cout << endl;
        // for (Int i = 0; i < n; i++) {
        //     for (Int j = 0; j < n; j++) {
        //         cout << a[i][(j + k) % n];
        //     }
        //     cout << endl;
        // }
        check = true;
        for (Int i = 0; i < n - 1; i++) {
            for (Int j = i + 1; j < n; j++) {
                //cout << a[i][(j + k) % n] << " " << a[j][(i + k) % n] << endl;
                if (a[i][(j + k) % n] != a[j][(i + k) % n]) {
                    check = false;
                }
            }
        }
        if (check) {
            res++;
        }
    }
    dump(res * n);
    return 0;
}

Measured memory_bytes: 384
using namespace std;

static const int N = 52;

void dfs(int map[][N], int pi, int pj){
	const int di[] = {-1,0,1,1,1,0,-1,-1};
	const int dj[] = {1,1,1,0,-1,-1,-1,0};

	if( map[pi][pj] == 0 ){
		return ;
	}

	map[pi][pj] = 0;

	for(int i = 0; i < sizeof(di)/sizeof(di[0]); i++){
		dfs(map, pi + di[i], pj + dj[i] );
	}
}

int main(void){
	ws(cin);
	while( 1 ){
		int count = 0;
		int n, m;
		int map[N][N] = {{0,},};

		cin >> n >> m;
		if( n == 0 && m == 0 ){
			break;
		}

		for(int i = 0; i < m; i++ ){
			for(int j = 0; j < n; j++){
				cin >> map[j + 1][i + 1];
			}
		}

		for(int i = 0; i < m; i++ ){
			for(int j = 0; j < n; j++){
				if(map[j + 1][i + 1]){
					dfs(map, j + 1, i + 1);
					count++;
				}
			}
		}

		cout << count << "\n";
	}
	return 0;
}

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

using namespace std;

int a[222222], d[222222] = { 1 };
int main() {
	int n, p = 1e9 + 7;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int c;
		scanf("%d", &c);
		d[i + 1] = (a[c] && a[c] < i ? d[a[c]] + d[i] : d[i]) % p;
		a[c] = i + 1;
	}
	cout << d[n] << endl;
	return 0;
}


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



int main() {



   int n;
   cin>>n;

   int arr[n];

   for(int i=0;i<n;++i)
       cin>>arr[i];

    int pre[n],suf[n];

    pre[0] = arr[0],suf[n-1] = arr[n-1];
    for(int i=1;i<n;++i)
     {
         pre[i] = max(arr[i],pre[i-1]);
     }

     for(int i = n-2;i>=0;--i){
        suf[i] = max(suf[i+1],arr[i]);
     }
     int ans[n];
     ans[0]  = suf[1];
     ans[n-1] = pre[n-2];

     if(n>2){
        for(int i=1;i<n-1;++i){
            ans[i] = max(pre[i-1],suf[i+1]);
        }

     }
       for(int i=0;i<n;++i)
        cout<<ans[i]<<"\n";


      return 0;
      }


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;
  vector<int> l(n);
  for(int i=0;i<n;i++)cin>>l[i];
  sort(l.begin(), l.end());

  ll ans =0;
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      int sum = l[i] + l[j];
      auto it = lower_bound(l.begin() + j + 1, l.end(), sum);
      ans += max(0l, distance(l.begin(), it) - j - 1);
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int a, b, c;
  cin >> a >> b >> c;
  cout << (a ^ b ^ c) << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n, cnt, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cnt = 0;
		bool k = true;
		if (i % 2 == 1) {
			for (int j = 1; j <= i; j++) {
				if (i % j == 0) {
					cnt++;
				}
				if (cnt == 8 && k) {
					ans++;
					k = false;
				}
				else if (cnt > 8) {
					ans--;
					break;
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
main(){
  int a[3],b,c,d,e,f;
  double g,h,i;
  while(1){
    scanf("%d %d %d",&a[0],&a[1],&a[2]);
    if((a[0]==0&&a[1]==0)&&a[2]==0)break;
    for(d=0;d<3;d++){
      for(e=2;e>0;e--){
	if(a[e]<a[e-1]){
	  b=a[e];
	  a[e]=a[e-1];
	  a[e-1]=b;
	}
      }
    }
    scanf("%d",&f);
    for(d=0;d<f;d++){
      scanf("%d",&c);
      c=c*2;
      g=sqrt(a[0]*a[0]+a[1]*a[1]);
      if(g>=c){
	printf("NA\n");
      }
      else{
	printf("OK\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<cmath>
using namespace std;
const int INF=1e9+7;
int x[100005];

int check(int a,int b){
	if(a>=0)return b;
	if(b<=0)return -a;
	a=-a;
	int s=a+b+min(a,b);
	return s;
}

int main(){
	int n,m;
	int i,j,k;
	int s,sa;
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>x[i];
	}
	s=INF;
	for(i=0;i<n-m+1;i++){
		sa=check(x[i],x[i+m-1]);
		if(sa<s)s=sa;
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int hash1[11];
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	hash1[a]++;
	hash1[b]++;
	hash1[c]++;
	if(hash1[5]==2&&hash1[7]==1)
	cout<<"YES"<<endl;
	else
	cout<<"NO"<<endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll t,i,ans=1,ans1=1;
	cin>>t;
	ll a[t];
	for(i=0;i<t;i++)
	{
		cin>>a[i];
	}
	sort(a,a+t);
	if(a[0]==0){
		cout<<"0";
		return 0;
	}
	for(i=0;i<t;i++){
		ans=ans*a[i];
		{
			if(ans>1000000000000000000){
				cout<<"-1";
				return 0;
			}
			if(ans<ans1){
				cout<<"-1";
				return 0;
			}
			ans1=ans;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    int n;
    cin >> n;
    vector<P> v(n+1);
    for(int i = 0; i < n; i++)
    {
        int p;
        cin >> p;
        v[i] = P(p, i+1);
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());

    multiset<int> ms;
    ms.insert(0);
    ms.insert(0);
    ms.insert(n+1);
    ms.insert(n+1);

    ll ans = 0;
    for(int i = 0; i < n; i++)
    {
        P p = v[i];
        ll num = p.first;
        ll id = p.second;
        auto itr = ms.lower_bound(id);
        ll r1 = *itr++;
        ll r2 = *itr--;
        itr--;
        ll l1 = *itr--;
        ll l2 = *itr;
        ans += num * (r2-r1) * (id-l1);
        ans += num * (l1-l2) * (r1-id);
        ms.insert(id);
    }
    cout << ans << endl;
}


Measured memory_bytes: 5760
#include <iostream>

using namespace std;

int gcd(int a, int b){
    if(b > a){
        gcd(b,a);
    }else if(a > b){
        if(a % b == 0){
            return b;
        }
        gcd(a - b, b);
    }else return a;
}

int main(){

    int a,b,k;
    cin >> a >> b >> k;

    int tmp = gcd(a, b);
    k--;

    while(k > 0){
        tmp--;
        if(a % tmp == 0 and b % tmp == 0){
            k--;
        }
    }

    cout << tmp << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io

    ll N, A, B;
    cin>>N>>A>>B;

    if(B-A > N || B-A<0) {
        cout<<0<<endl;
        return 0;
    }
    ll minans=A*(N-1)+B;
    ll maxans=A+B*(N-1);
    cout<<maxans-minans+1<<endl;
    return 0;
}


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

public class Main{

    public static void main(String[] args) throws IOException {
        // write your code here

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(reader.readLine());

        int flag=0;
        while (n>0)
        {
            int r = n%10;

            if(r==7)
            {
                flag=1;
                break;
            }

            n=n/10;
        }

        if(flag==1)
            System.out.println("Yes");
        else
            System.out.println("No");

    }

}


Measured memory_bytes: 32560
#include<bits/stdc++.h>
#define LiangJiaJun main
using namespace std;
char sa[3004],sb[3004];
int la,lb;
int f[3004][3004],mi[3004],nmi[3004];
pair<int,int>pre[3004][3004];
vector<char>ans;
int w33ha(){
    la=strlen(sa+1);
    lb=strlen(sb+1);
    memset(f,0,sizeof(f));
    pair<int,int> rec;
    for(int i=1;i<=la;i++){
        for(int j=1;j<=lb;j++)nmi[j]=mi[j];
        rec=make_pair(mi[0],0);
        for(int j=1;j<=lb;j++){
            if(sa[i]==sb[j]){
                f[i][j]=f[rec.first][rec.second]+1;
                if(f[i][j]>f[nmi[j]][j])nmi[j]=i;
                pre[i][j]=rec;
            }
            if(f[rec.first][rec.second]<f[mi[j]][j]){
                rec=make_pair(mi[j],j);
            }
        }
        for(int j=1;j<=lb;j++)mi[j]=nmi[j];
    }
    ans.clear();
    rec=make_pair(0,0);
    for(int i=1;i<=la;i++){
        for(int j=1;j<=lb;j++){
            if(f[rec.first][rec.second]<f[i][j]){
                rec=make_pair(i,j);
            }
        }
    }
    while(rec.first>0&&rec.second>0){
        ans.push_back(sa[rec.first]);
        rec=pre[rec.first][rec.second];
    }
    reverse(ans.begin(),ans.end());
    for(int i=0;i<ans.size();i++)printf("%c",ans[i]);
    puts("");
    return 0;
}
int LiangJiaJun(){
    while(scanf("%s%s",sa+1,sb+1)!=EOF)w33ha();
    return 0;
}


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

int main() {
    int a,b;
    cin >> a >> b;
    int ans = 0;
    if(a >= b){
        ans += a;
        a--;
    }
    else{
        ans += b;
        b--;
    }
    if(a >= b){
        ans += a;
        a--;
    }
    else{
        ans += b;
        b--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int W, H, x, y, r;
	
	scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);

	if ((x>=r) && (x<=W - r) && (y >= r) && (y <= H - r))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
	return 0;
}

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

using namespace std;
#define pb push_back
typedef long long LL;
LL t[1100000];
int n,c,K;

int main(){
	//freopen("test.in","r",stdin);
	scanf("%d %d %d",&n,&c,&K);
	for(int i=0; i<n; i++){
		scanf("%lld",&t[i]);
	}
	sort(t,t+n);
	LL cur = t[0] + K;
	int cnt = 1;
	int res = 1;
	for(int i=1; i<n; i++){	
		if( t[i] <= cur ) {		
			cnt++;
			if( cnt > c){
				cur = t[i] + K;
				cnt = 1;
				res++;
			}
		}else{
			res++;
			cur = t[i] + K;
			cnt = 1;			
		}
	}	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**6)
S=input()
s=[]
for i in S:
    s+=[i]
ans=0
que=[]
que+=[s[0]]
def cube(i):
    global ans
    if i==len(s):
        print(ans)
    else:
        que.append(s[i])
        flag=True
        while flag:
            if len(que)==0 or len(que)==1:
                flag=False
            elif que[-1]==que[-2]:
                flag=False
            elif que[-1]!=que[-2]:
                del que[-1]
                del que[-1]
                ans+=2
        cube(i+1)
cube(1)


Measured memory_bytes: 853784
// created by anaksoleh
// 26 Feb 2020
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<double,double> pd;
int N;
bool chosen[10];
vector<int> p;
vector<pd> v;
int fact[10];
double ans;

ll lcm(ll a,ll b){
    return a * b / __gcd(a,b);
}
ll abself(ll a){
    if(a < 0){
        a *= -1;
    }
    return a;
}

double pathLen(double xi,double yi,double xj,double yj){
    return sqrt(((xi-xj)*(xi-xj)) + ((yi-yj)*(yi-yj)));
}

void precalF(){
    fact[0] = 1;
    for(int i = 1 ; i < 10 ; i++)
        fact[i] = i * fact[i-1];
}

void solve(){
    if(p.size() == N){
        for(int i = 0 ; i < (N-1) ; i++){
            ans += pathLen(v[p[i]].first,v[p[i]].second,v[p[i+1]].first,v[p[i+1]].second);
        }
    }else{
        for(int i = 0 ; i < N ; i++){
            if(chosen[i])continue;
            chosen[i] = true;
            p.push_back(i);
            solve();
            chosen[i] = false;
            p.pop_back();
        }
    }
}


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

    cin >> N;
    for(int i = 0 ; i < N ; i++){
        double x , y;
        cin >> x >> y;
        v.push_back({x,y});
    }
    ans = 0;
    precalF();
    solve();
    cout << fixed << setprecision(12) << ans / fact[N] << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int X,Y,A,B,C;
  cin >> X >> Y >> A >> B >> C;
  ll p[A],q[B],r[C];
  vector<ll> Q(0);
  for (int i = 0; i < A; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < B; i++) {
    cin >> q[i];
  }
  for (int i = 0; i < C; i++) {
    cin >> r[i];
  }
  sort(p,p+A);
  reverse(p,p+A);
  sort(q,q+B);
  reverse(q,q+B);
  sort(r,r+C);
  reverse(r,r+C);
  for (int i = 0; i < X; i++) {
    Q.push_back(p[i]);
  }
  for (int i = 0; i < Y; i++) {
    Q.push_back(q[i]);
  }
  for (int i = 0; i < min(C,X+Y); i++) {
    Q.push_back(r[i]);
  }
  sort(Q.begin(),Q.end());
  reverse(Q.begin(),Q.end());
  ll ans = 0;
  for (int i = 0; i < X+Y; i++) {
    ans += Q[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8688
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;cin>>n;
	int ans = INF;
	for(int i = 1; i < n; i++) {
		int b = n - i;
		int tmp = 0;
		string A = to_string(i);
		string B = to_string(b);
		for(int i = 0; i < A.size(); i++) {
			tmp += A[i] - '0';
		}
		for(int i = 0; i < B.size(); i++) {
			tmp += B[i] - '0';
		}
		ans = min(ans,tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
H=[list(map(int,input().split()))for _ in range(N)]
dp=[[0,0,0]for _ in range(N+1)]
for i in range(1,N+1):
    dp[i][0]=H[i-1][0]+max(dp[i-1][1],dp[i-1][2])
    dp[i][1]=H[i-1][1]+max(dp[i-1][0],dp[i-1][2])
    dp[i][2]=H[i-1][2]+max(dp[i-1][0],dp[i-1][1])
print(max(dp[N]))


Measured memory_bytes: 47280
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inputs = Console.ReadLine().Split(' ');
            int month = int.Parse(inputs[0]);
            int day = int.Parse(inputs[1]);

            if (month < 4)
            {
                Console.WriteLine(0);
                return;
            }

            int nd = day / 10;
            if (nd < 2)
            {
                Console.WriteLine(0);
                return;
            }

            int counter = 0;

            for (int i10 = 2; i10 <= nd; i10++)
            {
                for (int i1 = 2; i1 <= 9; i1++)
                {
                    if(i10*i1 <= month && i10*10+i1 <= day)
                    {
                        //Console.WriteLine("i10 = " + i10);
                        //Console.WriteLine("i1  = " + i1);
                        counter++;
                    }
                }
            }
            Console.WriteLine(counter);
            //Console.ReadKey();

        }

    }


}


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

using namespace std;

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

	vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin >> k;
	cout << v[k-1] << '\n';

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n,m,k,s;
  cin>>n>>m>>k>>s;
  int a[11][11];
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
      cin>>a[i][j];

  /*//
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
      cout<<a[i][j]<<" \n"[j==m-1]<<flush;
  //*/  

  auto row=[&](int i){
    int x[m+1];
    x[0]=0;
    for(int j=0;j<m;j++) x[j+1]=x[j]+a[i][j];
    int y[m+1];
    y[m]=x[m];
    for(int j=m-1;j>=0;j--)
      y[j]=max(y[j+1],x[j+1]);
    int res=0;
    for(int j=0;j<m;j++)
      res=max(res,y[j]-x[j]);

    //cout<<i<<":i"<<endl;for(int j=0;j<=m;j++) cout<<j<<":"<<x[j]<<" "<<y[j]<<":"<<a[i][j]<<endl;
    
    return res;
  };
  
  auto col=[&](int j){
    int x[n+1];
    x[0]=0;
    for(int i=0;i<n;i++) x[i+1]=x[i]+a[i][j];
    int y[n+1];
    y[n]=x[n];
    for(int i=n-1;i>=0;i--)
      y[i]=max(y[i+1],x[i+1]);
    int res=0;
    for(int i=0;i<n;i++)
      res=max(res,y[i]-x[i]);
    return res;
  };

  vector<int> vx,vy;
  for(int i=0;i<n;i++){
    //cout<<row(i)<<endl;
    if(row(i)>s) vy.push_back(i);
  }
  for(int j=0;j<m;j++){
    //cout<<col(j)<<endl;
    if(col(j)>s) vx.push_back(j);
  }
  if((int)vx.size()>k||(int)vy.size()>k){
    cout<<"No"<<endl;
    return 0;
  }

  int ans=0;
  function<void(int,int,int)> dfs=
    [&](int b,int c,int d){
    {
      int tmp=0;
      for(int i=0;i<n;i++){
	tmp|=row(i)>s;
	if(tmp) break;
      }
      for(int j=0;j<m;j++){
	tmp|=col(j)>s;
	if(tmp) break;
      }
      if(!tmp){
	ans=1;
	return;
      }
    }
    if(b==k) return;
    for(int i=c;i<(int)vy.size();i++){
      for(int j=(i==c?d+1:0);j<m;j++){
	if(a[vy[i]][j]<=0) continue;
	a[vy[i]][j]*=-1;
	dfs(b+1,i,j);
	a[vy[i]][j]*=-1;
	if(ans) return;
      }
    }
  };
  
  function<void(int,int,int)> dfs2=
    [&](int b,int c,int d){
    {
      int tmp=0;
      for(int i=0;i<n;i++){
	tmp|=row(i)>s;
	if(tmp) break;
      }
      for(int j=0;j<m;j++){
	tmp|=col(j)>s;
	if(tmp) break;
      }
      if(!tmp){
	ans=1;
	return;
      }
    }
    if(b==k) return;
    for(int j=c;j<(int)vx.size();j++){
      for(int i=(j==c?d+1:0);i<n;i++){
	if(a[i][vx[j]]<=0) continue;
	a[i][vx[j]]*=-1;
	dfs2(b+1,j,i);
	a[i][vx[j]]*=-1;
	if(ans) return;
      }
    }
  };
  dfs(0,0,0);
  dfs2(0,0,0);
  //assert(!ans);
  cout<<(ans?"Yes":"No")<<endl;
  return 0;
}



Measured memory_bytes: 3160