akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
using namespace std;
int main()
{
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

// Solution
public class Main {
  private static Scanner in;
  private static PrintWriter out;
  private static final String INPUT = ""; // input file name

  /**
   * Interactive get next command
   */
  static int get(int pos) {
    out.println(pos + 1);
    out.flush();
    return ni();
  }

  static void solve() {
    int n = ni();
    int k = ni();
    int[] arr = new int[n];

    for (int i = 0; i < n; i++) {
      arr[i] = ni();
    }

    int[] dp = new int[n];
    dp[0] = 0;
    dp[1] = Math.abs(arr[1] - arr[0]);

    for (int i = 1; i < n; i++) {
      int min = Integer.MAX_VALUE;

      for (int j = 1; j <= k; j++) {
        min = Math.min(min, dp[i - j] + Math.abs(arr[i] - arr[i - j]));

        if (i - j == 0)
          break;
      }

      dp[i] = min;
    }

    out.println(dp[n - 1]);
  }

  public static void main(String[] args) throws Exception {
    long S = System.currentTimeMillis();
    in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
    out = new PrintWriter(System.out);

    solve();
    out.flush();
    long G = System.currentTimeMillis();
    tr(G - S + "ms");
  }

  private static int gcd(int a, int b) {
    while (b != 0) {
      int t = b;
      b = a % b;
      a = t;
    }

    return a;
  }

  private static int ni() {
    return Integer.parseInt(in.next());
  }

  private static long nl() {
    return Long.parseLong(in.next());
  }

  // Math Utils
  private static int pi(int num, int pow) {
    int result = 1;

    while (pow > 0) {
      if (pow % 2 == 1) {
        result *= num;
      }

      num *= num;
      pow /= 2;
    }

    return result;
  }

  private static int pim(int num, int pow, int mod) {
    int result = 1;

    while (pow > 0) {
      if (pow % 2 == 1) {
        // keep collecting `odd` num in result
        result = (result * num) % mod;
      }

      num = (num * num) % mod;
      pow /= 2;
    }

    return result;
  }

  private static long pl(long num, long pow) {
    long result = 1;

    while (pow > 0) {
      if (pow % 2 == 1) {
        result *= num;
      }

      num *= num;
      pow /= 2;
    }

    return result;
  }

  private static long plm(long num, long pow, long mod) {
    long result = 1;

    while (pow > 0) {
      if (pow % 2 == 1) {
        // keep collecting `odd` num in result
        result = (result * num) % mod;
      }

      num = (num * num) % mod;
      pow /= 2;
    }

    return result;
  }

  static void tr(Object... o) {
    if (!INPUT.isEmpty())
      out.println(Arrays.deepToString(o));
  }
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
const ul mod = 1000000007;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = max(max(a * c, a * d), max(b * c, b * d));
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int>P;
#define PI 3.14159265359
#define MOD 1000000007
int main(){
  int N,M;
  cin >>N>>M;
  vector<int>h(100001);
  rep(i,N){
  	cin >>h[i];
  }
  vector<int>memo(100001);
  	rep(i,M){
  		int a,b;
  		cin >>a>>b;a--;b--;
      	if(h[a]>h[b]){memo[b]=-1;}
        else if(h[a]<h[b]){memo[a]=-1;}
      	else{memo[a]=-1;memo[b]=-1;}
    }
  int count=0;
  rep(i,N){
    if(memo[i]!=-1){count++;}
  
  }
  cout<<count;
  
  
  
}


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

int main(){
	int n,m;
	cin>>n;
	string blue[n];
	for (int i = 0; i < n; i++){
		cin>>blue[i];
	}
	cin>>m;
	string red[m];
	for (int i = 0; i < m; i++){
		cin>>red[i];
	}

	int Score[n],count=0;
	for (int i = 0; i < n; i++){
		count=0;
		for (int j = 0; j < n; j++){
			if(blue[i]==blue[j])
				count++;
		}
		for (int j = 0; j < m; j++){
			if(blue[i]==red[j])
				count--;
		}
		Score[i]=count;
	}

	sort(Score,Score+n,greater<int>());
	if(Score[0]>0)
		cout<<Score[0]<<endl;
	else
		cout<<'0'<<endl;	
}


Measured memory_bytes: 256
using System;
using System.Linq;

class Program {
  static void Main() {
    var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int x = arr[2];
    int y = arr[3];
    var L = Math.Max(Console.ReadLine().Split().Select(int.Parse).OrderBy(e => e).Max(), x);
    var r = Math.Min(Console.ReadLine().Split().Select(int.Parse).OrderBy(e => e).Min(), y);
    Console.WriteLine(L < r ? "No War" : "War");
  }
}

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

int main(){
	int n;
	string str = "No";
	cin >> n;
	
	//ケーキ4ドル
	//ドーナツ7ドル
	
	for(int i=0;i<100/4;i++){
		for(int j=0;j<100/7;j++){
			if((i*4) + (j * 7) == n){
				str = "Yes";
			}
		}
	}
	
	cout << str << endl;
	return 0;
}

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

int main()
{
	int seito[31] = {0};
	int a;
	
	for(int i = 1; i < 29; i++){
		cin >> a;
		seito[a] = 1;
	}
	
	for(int i = 1; i < 31; i++){
		if(seito[i] == 0){
			cout <<i << endl;
		}
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
long long n,a[100005],qs[100005],cnt1=0,cnt2=0,kmp1=0,kmp2=0;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(int i=1;i<=n;i++)
	{
		qs[i]=qs[i-1]+a[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(i%2==1)
		{
			if(qs[i]+kmp1<=0)
			{
				cnt1+=(1-qs[i]-kmp1);
				kmp1+=(1-qs[i]-kmp1);
			}
		}else
		{
			if(qs[i]+kmp1>=0)
			{
				cnt1+=(qs[i]+kmp1+1);
				kmp1-=(qs[i]+kmp1+1);
			}
		}
		//printf("%lld ",kmp1);
	}
	//printf("\n");
	for(int i=1;i<=n;i++)
	{
		if(i%2==0)
		{
			if(qs[i]+kmp2<=0)
			{
				cnt2+=(1-qs[i]-kmp2);
				kmp2+=(1-qs[i]-kmp2);
			}
		}else
		{
			if(qs[i]+kmp2>=0)
			{
				cnt2+=(qs[i]+kmp2+1);
				kmp2-=(qs[i]+kmp2+1);
			}
		}
	}
	//printf("%lld %lld\n",cnt1,cnt2);
	printf("%lld\n",min(cnt1,cnt2));
}

Measured memory_bytes: 5348
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;


int main() {
    int t, x; cin >> t >> x;
    double ans = double(t)/x;
    printf("%.5f\n", ans);
}

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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, x; cin >> n >> x;
  int ans = 1;
  int sum = 0;
  rep(i, n) {
    int l; cin >> l;
    sum += l;
    if (sum <= x) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N, K = getNM()
A = getList()

# 操作後のAの要素全てが因数にkを持つ

# 好きな回数操作を行えるとすると、Aの要素全てに因数kを持たせることができるか？
# 操作前と操作後とではAの総和は変わらない → A = akとするとa個のkをN個の要素に配分する
# ことでAの要素全てに因数kを持たせることができる。
# 好きな回数操作を行える、操作後のAの全ての要素を割り切る正の整数は、sum(A)の約数になる

def make_divisors(n):
    divisors = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            divisors.append(i)
            # √nで無い数についてもう一個プラス
            if i != n // i:
                divisors.append(n // i)
    return sorted(divisors)

# K回以下の操作の条件付きでも題意を満たすか
# alta % kをし、あまりが小さい順にソートする
# 前からi番目までをプラス、i + 1番目以降をマイナスにする
# どちらか大きい方がK以下なら条件を満たす

def judger(x):
    alta = [i % x for i in A]
    alta.sort()
    alta_b = [x - i for i in alta]
    # 前からi番目までプラスにする
    imos_f = copy.deepcopy(alta)
    # 前からi + 1番目以降をマイナスにする
    imos_b = copy.deepcopy(alta_b)

    for i in range(N - 1):
        imos_f[i + 1] += imos_f[i]
        imos_b[-i - 2] += imos_b[-i - 1]

    # 全部マイナス、全部プラスの場合
    imos_f.insert(0, 0)
    imos_b.append(0)

    ans = float('inf')
    for i in range(N + 1):
        ans = min(ans, max(imos_f[i], imos_b[i]))

    return ans

for i in make_divisors(sum(A))[::-1]:
    if judger(i) <= K:
        print(i)
        break

Measured memory_bytes: 87016
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;



int main()
{
ll x,k,d;
cin>>x>>k>>d;


if(x<0)
    x*=-1;


if(k>(x/d))
{
    k-=x/d;
    x-=(x/d)*d;

    cout<<abs(x-(k%2)*d)<<endl;
}
else
{
    x-=(k*d);
    cout<<(x)<<endl;
}

 return 0;
}


Measured memory_bytes: 3580
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 3e5+7 ;
const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
string s ;

void solve(){
    int n, k  ;cin >>k >>  n ;
    vi a(2*n) ;
    for(int i = 0 ; i < n ; i++){
        cin >> a[i] ;
    }

    for(int i = 0 ; i < n ; i++){
        a[n+i] = k+a[i] ;
    }
    int ans = INF ;
    for(int i = 0 ; i < n ; i++){
        ans= min(ans,llabs(a[n-1+i]-a[i])) ;
    }
    cout << ans ;
}

int32_t main(){
    FAST_IO ;
    int t = 1 ;
//    cin >> t ;
    while(t--){
        solve() ;
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
#include<set>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#define maxn zhi5968
typedef long long ll;
using namespace std;
string s1,s2;

int main()
{
	cin>>s1;
	cin>>s2;
	int i,j,bj[30]={0};	
	for(i=0;i<s1.length();i++)
	{
		if(bj[s1[i]-'a'])
			continue;
		else
		{
			bj[s1[i]-'a']++;
			for(j=i;j<s1.length();j++)
			{
				if(s1[j]==s1[i])
				{
			//		cout<<i<<j<<endl;
					if(s2[j]!=s2[i])
					{
						cout<<"No"<<endl;
						return 0;
					}
				}
			}
		}
	}
	memset(bj,0,sizeof(bj));
	for(i=0;i<s2.length();i++)
	{
		if(bj[s2[i]-'a'])
			continue;
		else
		{
			bj[s2[i]-'a']++;
			for(j=i;j<s2.length();j++)
			{
				if(s2[j]==s2[i])
				{
			//		cout<<i<<j<<endl;
					if(s1[j]!=s1[i])
					{
						cout<<"No"<<endl;
						return 0;
					}
				}
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 904
#include<stdio.h>
    int main(void)
    {
    	char s;
    	
    	scanf("%c",&s);
    	
    	if(s=='a') {
    	printf("vowel\n");
    	}
    	else if(s=='i') {
    	printf("vowel\n");
    	}
    	else if(s=='u') {
    	printf("vowel\n");
    	}
    	else if(s=='e') {
    	printf("vowel\n");
    	}
    	else if(s=='o') {
    	printf("vowel\n");
    	}
    	else {
    	printf("consonant\n");
    	}
    	return 0;
    }

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

lint n;
vector<lint> x, y;

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

lint max_45() {
    vector<lint> x_plus_y(n);
    for (int i = 0; i < n; i++) {
        x_plus_y[i] = x[i] + y[i];
    }
    lint left = *max_element(x_plus_y.begin(), x_plus_y.end());
    lint right = *min_element(x_plus_y.begin(), x_plus_y.end());
    return left - right;
}

lint max_135() {
    vector<lint> x_minus_y(n);
    for (int i = 0; i < n; i++) {
        x_minus_y[i] = x[i] - y[i];
    }
    lint left = *max_element(x_minus_y.begin(), x_minus_y.end());
    lint right = *min_element(x_minus_y.begin(), x_minus_y.end());
    return left - right;
}

lint ans() {
    lint res = 0;
    chmax(res, max_45());
    chmax(res, max_135());
    return res;
}

int main() {
    cin >> n;
    x.resize(n);
    y.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    cout << ans() << endl;
}

Measured memory_bytes: 7968
#include <string.h>
#include <set>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <iostream>
using namespace std;
typedef long long ll;
set<int> st;
int x[105];
int main()
{
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll chu = x / d;
    if (k >= chu)
    {
        k -= chu;
        ll mod = x % d;
        if (k % 2 == 0)
            cout << mod << endl;
        else
        {
            ll ans = min(abs(mod + d), abs(mod - d));
            cout << ans << endl;
        }
    }
    else
    {
        cout << x - k * d << endl;
    }

    return 0;
}
//1000000000000000
//1000000000000000
//1000000000000000

Measured memory_bytes: 3188
#include <stdio.h>

int main(void){
 int a , b , c;
  scanf("%d %d %d",&a,&b,&c);
  
  int x;
   scanf("%d",&x);
  
 
  int count = 0; 
  for(int i = 0;i <= a;i++){
    for(int j = 0;j <= b;j++){
      for(int n = 0;n <= c;n ++){
        if(x ==500*i+100*j+50*n){
          count ++;
        }}}}
  printf("%d",count);
  
  return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int k = sc.nextInt();
    int ans = 0;
    int n = 0;
    int K = 0;
    if(a > b){
      for(int i = 1;i <= a;i++){
        if(a%i == 0){
          n = a/i;
          if(b%n == 0){
            K++;
            if(k == K) break;
          }
        }
      }
    }
    else if(a < b){
      for(int i = 1;i <= b;i++){
        if(b%i == 0){
          n = b/i;
          if(a%n == 0){
            K++;
            if(k == K) break;
          }
        }
      }
    }
    else{
      for(int i = 1;i <= a;i++){
        if(a%i == 0){
          n = a/i;
          if(b%n == 0){
            K++;
            if(k == K) break;
          }
        }
      }
    }
    System.out.println(n);
  }
}


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

int main(){
    int n;
    scanf("%d", &n);
    set<P> red;
    vector<P> blue(n);
    rep(i, n){
        int x, y;
        scanf("%d %d", &x, &y);
        red.insert(P(x, y));
    }
    rep(j, n){
        scanf("%d %d", &blue[j].first, &blue[j].second);
    }
    sort(blue.begin(), blue.end());
    int ans = 0;
    for(P b : blue){
        P maxa = P(-1, -1);
        for(P r : red){
            if(r.first >= b.first) continue;
            if(r.second >= b.second) continue;
            if(maxa.second < r.second) maxa = r;
        }
        if(maxa != P(-1, -1)){
            ans++;
            red.erase(maxa);
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;

const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 1e5+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    while(k && b <= a)
    {
        b *= 2;
        k--;
    }
    while(k && c <= b)
    {
        c *= 2;
        k--;
    }
    if(a < b && b < c)
    {
        cout << "Yes\n";
    }
    else
        cout <<"No\n";

}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[1010][1010],p[10010];
int vis[10010],cnt;
inline void init(int n=10000) {
    vis[1]=1;
    for (int i=2;i<=n;i++) {
        if (!vis[i]) p[++cnt]=i;
        for (int j=1;j<=cnt && i*p[j]<=n;j++) {
            vis[i*p[j]]=1;
            if (!(i % p[j])) break;
        }
    }
}
inline ll lcm(ll x,ll y) {
    if (!x || !y) return x+y;
    return x/__gcd(x,y)*y;
}
int main() {
    int n;cin>>n,init();
    if (n==2) return puts("4 7\n23 10\n"),0;
    for (int i=1;i<=n;i++)
        for (int j=(i+1&1)+1;j<=n;j+=2)
            a[i][j]=p[(i+j)/2]*p[n+(i-j)/2+(n+1)/2];
    for (int i=1;i<=n;i++)
        for (int j=(i&1)+1;j<=n;j+=2)
            a[i][j]=lcm(lcm(a[i-1][j],a[i][j-1]),lcm(a[i][j+1],a[i+1][j]))+1;
    for (int i=1;i<=n;i++,putchar('\n'))
        for (int j=1;j<=n;j++) printf("%lld ",a[i][j]);
    return 0;
}

Measured memory_bytes: 7168
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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;}

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	lint n,m,x,ans=1e9;
	cin>>n>>m>>x;
	int p[n];
	int a[n][m];
	rep(i,n){
		cin>>p[i];
		rep(j,m){
			cin>>a[i][j];
		}
	}
	rep(i,1<<n){
		vector<int>tmp(m,0);
		lint c=0;
		rep(j,n)if((1<<j)&i){
			c+=p[j];
			rep(k,m)tmp[k]+=a[j][k];
		}
		bool flag=true;
		rep(j,m)if(tmp[j]<x)flag=false;
		if(flag)chmin(ans,c);
	}
	if(ans==1e9)ans=-1;
	cout<<ans<<endl;
}

Measured memory_bytes: 3664
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int main()
{
	int a;
	scanf("%d", &a);
	
	int ans = a + a * a + a * a * a;
	printf("%d\n", ans);
		
	return 0;
}


Measured memory_bytes: 1728
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int n, k;
        cin >> n >> k;
        int a[n];
        for(int i = 0; i < n; i++)
            cin >> a[i];
        sort(a, a + n);

        int ans = 0;
        for(int i = 0; i < k; i++)
            ans += a[i];
        cout << ans << '\n';
    }
    
    return 0;
}



Measured memory_bytes: 3668
N,P=map(int,input().split())

def prime_factorize(n):
  cnt = {}
  f = 2
  while f * f <= n:
    if n%f != 0:
      f += 1
      continue
    cnt.setdefault(f, 0)
    cnt[f] += 1
    n //= f
  if n > 1:
    cnt.setdefault(n, 0)
    cnt[n] += 1
  return cnt

cnt = prime_factorize(P)
ans = 1
for k, v in cnt.items():
  ans *= k**(v//N)
print(ans)

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
const int MOD = 1e9 + 7;
const int INF = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1);
#define nl printf("\n");
#define _FAST ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull; 

int N, a[3][10010];

int cari(int i, int j, int sebelumnya){
	int banyak = a[i][j] + sebelumnya;
	int jawaban ;
	// printf("MASUK %d %d\n", i , j );
	if (j == N && i == 2)
	{
		jawaban = banyak;
	} else {
		int jawaban1 = 0, jawaban2 = 0;
		if (i == 1)
		{
			if (j != N)
			{
				jawaban1 = cari(i,j+1,banyak);
			}
			
			jawaban2 = cari(i+1,j,banyak);

		} else {
			if (j != N)
			{
				jawaban1 = cari(i,j+1,banyak);
			}
		}

		jawaban = max(jawaban1,jawaban2);
	}

	return jawaban;
}


int main() {
  cin>>N;

  for (int i = 1; i <= 2; ++i)
  {
  	for (int j = 1; j <= N; ++j)
  	{
  		int x;
  		cin>>x;
  		a[i][j]=x;
  	}
  }

  int hasil = cari(1,1,0);

  cout<<hasil<<endl;

  return 0;
}




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

int main(){
  string s;
  cin>>s;
  
  bool ans=true;
  for(int i=0;i<s.size();i+=2){
    if(s[i]=='L'){
      ans=false;
    }
  }
  for(int i=1;i<s.size();i+=2){
    if(s[i]=='R'){
      ans=false;
    }
  }
  
  if(ans){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
def resolve():
    n=int(input())
    n%=10
    if n==2 or n==4 or n==5 or n==7 or n==9:
        print('hon')
    elif n==0 or n==1 or n==6 or n==8:
        print('pon')
    else:
        print('bon')

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 9180
N = gets.to_f

1.upto(3500) do |h|
  1.upto(3500) do |n|
    denominator = (4 * h * n - N * h - N * n)
    next if denominator.zero?

    w = (N * n * h) / denominator
    if w > 0 && w - w.to_i == 0
      puts "#{h} #{n} #{w.to_i}"
      exit
    end
  end
end

Measured memory_bytes: 14364
// 解き直し.
// ABC 135解説
// https://img.atcoder.jp/abc135/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

int main(){

    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);
    LL A[N + 1], B[N];
    for(int i = 0; i < N + 1; i++) scanf("%lld", A + i);
    for(int i = 0; i < N; i++)     scanf("%lld", B + i);
    
    // 2. モンスターを倒せる数を計算.
    // Σ(f(i, i) + f(i, i + 1))
    LL ans = 0;
    LL f1 = 0, f2 = 0;
    for(int i = 0; i < N; i++){
        // f(1, 1) = min(A1, B1)
        // f(i, i) = min(A[i] - f(i - 1, i), B[i])
        f1 = min(A[i] - f2, B[i]);
        ans += f1;
        
        // f(i, i + 1) = min(A[i + 1], B[i] - f(i, i))
        f2 = min(A[i + 1], B[i] - f1);
        ans += f2;
        
    }
    
    // 3. 出力 ～ 後処理.
    printf("%lld\n", ans);
    return 0;

}

Measured memory_bytes: 1792
#include<stdio.h>

int main(void){
    int N, A, B;
    scanf("%d",&N);
    scanf("%d",&A);
    scanf("%d",&B);
    if(N==1){
        printf("Hello World");
    }else if(N==2){
        printf("%d",A+B);
    }
  return 0;
}

Measured memory_bytes: 128
# coding:utf-8

if __name__=="__main__":
  R,G,B,N = map(int, input().split())
  count = 0
  for r in range(int(N/R)+1):
    n1 = N - r*R
    for g in range(int(n1/G)+1):
      n2 = n1 - g*G
      if n2%B==0: count+= 1
  print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define H_max 200
#define W_max 200


int main(){
    int n;
    cin >> n;
    int A[4];
    REP(i,4){
        A[i]=n%10;
        n/=10;
    }
    
    if((A[0] == A[1] and A[1] == A[2]) or (A[1]== A[2] and A[2]== A[3])) cout << "Yes" << endl;
    else cout <<"No" << endl;
}

Measured memory_bytes: 256
X,K,D=map(int,input().split())
ans=0
if abs(X)>=K*D:
    ans=abs(X)-K*D
else:
    M=abs(X)//D
    if abs(X)-M*D>abs(abs(X)-(M+1)*D):
        M=M+1
    if (K-M)%2==0:
        ans=abs(abs(X)-M*D)
    else:
        ans=min(abs(X)-(M-1)*D,abs(abs(X)-(M+1)*D))
print(ans)


Measured memory_bytes: 9196
import numpy as np
import sys
import math
from functools import reduce
import fractions as fr

def gcd(*numbers):
    return reduce(fr.gcd, numbers)

n,k = map(int,input().split())
a = list(map(int,input().split()))

c = int(gcd(*a))

for i in a:
  if i - k >= 0 and (i-k) % c == 0:
    print("POSSIBLE")
    sys.exit()
    
print("IMPOSSIBLE")
 

Measured memory_bytes: 24240
#include <iostream>
#include <string.h>

using namespace std;
bool isPrime[10005];

void PrimeCalc()
{
	memset(isPrime, 1, sizeof(isPrime));
	isPrime[0] = isPrime[1] = false;
	for(int i = 2; i < 10005; ++i)
	{
		if(isPrime[i])
		{
			for(int j = 2 * i; j < 10005; j += i)
			{
				isPrime[j] = false;
			}
		}
	}
}

void solve()
{
	PrimeCalc();
	int n;
	while(cin >> n)
	{
		int count = 0;
		for(int i = 2; i < n; ++i)
		{
			if(isPrime[i] && isPrime[n - i + 1])
			{
				++count;
			}
		}
		cout << count << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1176
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int, int>P;
typedef pair<int, pair<int, int>>PP;
typedef long long ll;
ll inf = -1;

int main() {
	int n; cin >> n;
	int w[100];
	for (int i = 0; i < n; i++) {
		cin >> w[i];
	}
	int ans = 1e9;
	for (int i = 0; i < n-1; i++) {
		int s = 0, t = 0;
		for (int j = 0; j <= i; j++) {
			s += w[j];
		}
		for (int j = i + 1; j < n; j++) {
			t += w[j];
		}
		ans = min(ans, abs(s - t));
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int week;
  string N;
  cin>>N;
  if(N[0]=='S'){
    if(N[1]=='U'){
      week=7;
    }
    else{
      week=1;
    }
  }
  else if(N[0]=='M'){
    week=6;
  }
  else if(N[0]=='T'){
    if(N[1]=='U'){
      week=5;
    }
    else{
    week=3;
    }
  }
  else if(N[0]=='W'){
    week=4;
  }
  else{
    week=2;
  }
  cout<<week;
    
}


Measured memory_bytes: 256
import numpy as np
import math
K = int(input())
memo = np.zeros((K,K),int)
s = 0
for i in range(K):
  for j in range(i,K):
    for k in range(j,K):
      if i == j and j == k:
        rate = 1
      elif i == j or j == k or i == k:
        rate = 3
      else:
        rate = 6
      s += math.gcd(math.gcd(i+1,j+1),k+1) * rate
print(s)


Measured memory_bytes: 27204
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<int,int> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int,pair<int,int> > iii;
#define PI 3.141592653589793
#define mod (ll)(1000*1000*1000+7)
//# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e18
# define LG 20  
typedef pair<int,pair<int,int> > pii;
# define INF1 (int)1e9+2
# define maxn 106

ll weight;
int n;
ll w[maxn];
ll v[maxn];
ll dp[105][105][305];

ll solve(int id,int cnt,ll ew)
{
	if(id==n)
	{
		ll tw=cnt*w[0]+ew;
		if(tw<=weight)
			return 0;
		return -INF;
	}
	if(dp[id][cnt][ew]!=-1)
		return dp[id][cnt][ew];
	ll ans=-INF;
	ans=max(ans,solve(id+1,cnt,ew));
	ans=max(ans,v[id]+solve(id+1,cnt+1,ew+(w[id]-w[0])));
	//trace4(id,cnt,ew,ans);
	return dp[id][cnt][ew]=ans;
}

int main()
{
	
	
	cin >> n >> weight;
	for(int i=0;i<n;i++)
		{
			cin >> w[i] >> v[i];
		}
		memset(dp,-1,sizeof dp);
	cout << solve(0,0,0);
}

Measured memory_bytes: 26496
def comp(a, b)

	h0, w0 = a
	h1, w1 = b

	if h0**2 + w0**2 != h1**2 + w1**2
		h0**2 + w0**2 < h1**2 + w1**2
	else
		h0 < h1
	end

end

def solve(h, w)

	array = []

	(1..150).each do |x|
		((x+1)..150).each do |y|
			array.push([x,y])
		end
	end

	array.sort! { |a,b|
		if(comp(a,b))
			-1
		elsif(comp(b,a))
			1
		else
			0
		end
	}

	array.length.times do |i|
		if array[i] == [h,w]
			return array[i+1]
		end
	end

	return [-1, -1]

end

if __FILE__ == $0

	loop do
		h, w = STDIN.readline.split.map{|i|i.to_i}
		if h == 0
			break
		end
		ah, aw = solve(h, w)
		puts "#{ah} #{aw}"
	end

end

Measured memory_bytes: 6956
def string_diff(a,b)
  num = 0
  a.size.times do |i|
    num += 1 if a[i] != b[i]
  end
  num
end

s = gets.chomp
t = gets.chomp
if s.include?(t)
  puts '0'
  exit
end
ans = t.size
(0..(s.size-t.size)).each do |i|
  num = string_diff(s[i..i+t.size-1], t)
  ans = [ans, num].min
end
puts ans

Measured memory_bytes: 14308
while True:
    l = []
    l = input()
    if int(l[0]) == 0:
        break
    else:
        i = [int(a) for a in l]
        x = len(i)
        n = 0
        z = 0
        for n in range(x):
            z += i[n]
        print(z)


Measured memory_bytes: 5616
#include<stdio.h>

int main()
{
	int n;
	scanf("%d", &n);
	int i;
	long long int sum = 0;
	for (i = 1; i <= n; i++)
	{
		if (i % 3 != 0 && i % 5 != 0)
		{
			sum += i;
		}
	}
		
	printf("%lli\n", sum);
	
	return 0;
}

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

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> a(q);
  rep(i, q) {
    cin >> a[i];
    --a[i];
  }

  vector<int> p(n, k - q);
  rep(i, q) ++p[a[i]];
  vector<bool> pass(n, false);
  rep(i, n) if (p[i] > 0) pass[i] = true;
  rep(i, n) {
    if (pass[i]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 4048
#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 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  ll N;
  cin >> N;

  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  
  sort(ALL(A));

  ll cnt = 0;
  REP(i,N-2){
    FOR(j,i+1,N-1){
      auto itr = lower_bound(A.begin()+j+1,A.end(),A[i]+A[j]);
      auto itr2 = upper_bound(A.begin()+j+1,A.end(),abs(A[i]-A[j]));
      ll x = distance(itr,A.end());
      ll y = distance(itr2,A.end());
      cnt+=y-x;
      // FOR(k,j+1,N){
        // if(A[k]<A[i]+A[j]&&abs(A[i]-A[j])<A[k]){
        //   cnt++;
        // }else if(A[k]>=A[i]+A[j]){
        //   break;
        // }
      // }
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <string>
#include <cstring>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int N = 100100;
vector<int> g[N];
int col[N];
int par[N];
int q[N];
int topQ;
int n;

void dfs(int v, int p)
{
    par[v] = p;
    for (int u : g[v]) {
        if (u == p) continue;
        dfs(u, v);
    }
}

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    scanf("%d", &n);
    for (int i = 1; i < n; i++) {
        int v, u;
        scanf("%d%d", &v, &u);
        g[v].push_back(u);
        g[u].push_back(v);
    }
    dfs(1, 0);

    int H = 0;
    int V = n;
    while(V != 0) {
        V = par[V];
        H++;
    }
    H /= 2;
    V = n;
    while(V != 0) {
        if (H > 0)
            col[V] = 2;
        else
            col[V] = 1;
        H--;
        V = par[V];
    }

    for (int v = 1; v <= n; v++)
        if (col[v])
            q[topQ++] = v;

    for (int k = 0; k < topQ; k++) {
        int v = q[k];
        for (int u : g[v]) {
            if (col[u]) continue;
            col[u] = col[v];
            q[topQ++] = u;
        }
    }

    int ans = 0;
    for (int v = 1; v <= n; v++) {
        if (col[v] == 0) throw;
        if (col[v] == 1)
            ans++;
        else
            ans--;
    }
    if (ans > 0)
        printf("Fennec\n");
    else
        printf("Snuke\n");

    return 0;
}

Measured memory_bytes: 11520
import copy

def func(n):
    return n%10

N = int(input())
S = [int(input()) for i in range(N)]

S.sort()
S_sum = copy.deepcopy(S)

# 合計を計算
summation = sum(S)
if (summation % 10) != 0:
    print(summation)
elif sum(list(map(func, S))) == 0:
    print("0")
else:
    for i in S_sum:
        tmp = summation - i
        if (tmp % 10) != 0:
            print(tmp)
            break


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

int main() {

 int a=0, b=0, c=0;

 cin >> a >> b >> c;

 if(a<b && b<c) {

   cout << "Yes" << endl;

   } else {

   cout << "No" << endl;

   }

  return 0;

}


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

void solve() {
	int n; cin >> n;
	vector<long long> a(n);
	rep(i, n) scanf("%lld", &a[i]);

	vector<long long> s(n + 1, 0);
	map<long long, long long> nums;
	for (int i = 0; i < n; i++) s[i + 1] = s[i] + a[i];
	for (int i = 0; i < n + 1; i++) nums[s[i]]++;

	long long res = 0;
	for (auto it : nums) {
		long long num = it.second;
		res += num * (num - 1) / 2;
	}
	cout << res << endl;
}

int main(void) {
	solve();

	return 0;
}

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	int a[n];
	ll sum =0;
	for(int i =0 ;i<n;i++)
	{
		cin>>a[i];
		sum += a[i];
	}
	sum = (ll)ceil(double(sum)/(4*m));
	ll ans = 0;
	for(int i = 0; i<n; i++)
	{
		if(a[i]>=sum) ans++;
	}
	if(ans<m)
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::*;

mod fenwick_tree {
    use std::ops::*;
    pub struct FenwickTree<T> {
        data: Vec<T>,
        identity: T,
    }
    impl<T: Copy + Clone + AddAssign + Sub<Output = T>> FenwickTree<T> {
        pub fn new(size: usize, id: T) -> FenwickTree<T> {
            FenwickTree {
                data: vec![id; size + 1],
                identity: id,
            }
        }
        fn prefix_sum(&self, i: usize) -> T {
            let mut res = self.identity;
            let mut idx = i;
            while idx > 0 {
                res += self.data[idx];
                idx -= ((idx as isize) & -(idx as isize)) as usize;
            }
            res
        }
        pub fn update(&mut self, i: usize, x: T) {
            let mut idx = i;
            while idx < self.data.len() {
                self.data[idx] += x;
                idx += ((idx as isize) & -(idx as isize)) as usize;
            }
        }
        pub fn query(&self, l: usize, r: usize) -> T {
            self.prefix_sum(r) - self.prefix_sum(l - 1)
        }
    }
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let mut s: Vec<usize> = itr
        .next()
        .unwrap()
        .chars()
        .map(|c| c as usize - 'a' as usize)
        .collect();
    let q: usize = itr.next().unwrap().parse().unwrap();
    let mut count: Vec<fenwick_tree::FenwickTree<i64>> = (0..26)
        .map(|_| fenwick_tree::FenwickTree::new(n + 1, 0))
        .collect();
    for i in 0..s.len() {
        count[s[i]].update(i + 1, 1);
    }

    let mut out = Vec::new();
    for _ in 0..q {
        let c: usize = itr.next().unwrap().parse().unwrap();
        if c == 1 {
            let i: usize = itr.next().unwrap().parse().unwrap();
            let tmp: Vec<char> = itr.next().unwrap().chars().collect();
            let c: usize = tmp[0] as usize - 'a' as usize;
            count[s[i - 1]].update(i, -1);
            count[c].update(i, 1);
            s[i - 1] = c;
        } else {
            let l: usize = itr.next().unwrap().parse().unwrap();
            let r: usize = itr.next().unwrap().parse().unwrap();

            let mut ans = 0i64;
            for i in 0..26 {
                if count[i].query(l, r) > 0 {
                    ans += 1;
                }
            }
            writeln!(out, "{}", ans).ok();
        }
    }
    stdout().write_all(&out).unwrap();
}


Measured memory_bytes: 118008
#include <iostream>
#include <string>
#include <set>
#include <math.h>
using namespace std;

int main(int argc, const char * argv[]) {

    string divide[4] = {"dream", "dreamer", "erase", "eraser"};
    string substr;
    string S;
    cin >> S;

    reverse(S.begin(), S.end());
    for(int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

    bool can = true;
    for(int i = 0; i < S.size();){
        bool can2 = false;
        for(int j = 0; j < 4; ++j){
            substr = S.substr(i, divide[j].size());
            if( substr == divide[j]){
                can2 = true;
                i += divide[j].size();
            }
        }
        if(!can2){
            can = false;
            break;
        }

    }
    if(can){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 512
import java.util.*;

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

    int N = scan.nextInt();
    int A = scan.nextInt();
    int B = scan.nextInt();
    int max = 0;
    int min = 0;

    if(A==N){
      max=B;
      min=B;
    }else if(B==N){
      max=A;
      min=A;
    }else if(A+B>=N){
      if(A>B){
        max=B;
        min=B-(N-A);
      }else{
        max=A;
        min=A-(N-B);
      }
    }else {
      if (A>B) {
        max=B;
      }else{
        max=A;
      }
    }
    System.out.println(max+" "+min);
  }
}


Measured memory_bytes: 23252
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <chrono>
#include <random>

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 32;
const int MOD = 998244353;

bool good = false;
int k, cnt = 0;

vector<int> res;

void rec(int now, int last, int len) {
    if (good) return;
    if (now == len) {
        cnt++;
        if (k == cnt) {
            for (int i : res) cout << i;
            good = true;
        }
        return;
    }
    if (last - 1 >= 0) {
        res.push_back(last - 1);
        rec(now + 1, last - 1, len);
        res.pop_back();
    }
    res.push_back(last);
    rec(now + 1, last, len);
    res.pop_back();
    if (last + 1 < 10) {
        res.push_back(last + 1);
        rec(now + 1, last + 1, len);
        res.pop_back();
    }
}

void solve() {
    cin >> k;
    for (int len = 1;!good; len++) {
        for (int i = 1; i <= 9; i++) {
            res.push_back(i);
            rec(1, i, len);
            res.pop_back();
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //int t;
    // cin >> t;
    int t = 1;
    while (t--) solve();
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int gcd(int a, int b) {
    if (!a)
        return b;
    return gcd(b % a, a);
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int k;
    cin >> k;
    vector <vector <int>> g(k + 1, vector <int> (k + 1));
    forn (i, 1, k + 1)
        forn (j, 1, k + 1)
            g[i][j] = gcd(i, j);
    long long ans = 0;
    forn (a, 1, k + 1) {
        forn (b, 1, k + 1) {
            forn (c, 1, k + 1) {
                ans += g[g[a][b]][c];
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3760
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val N = sc.nextInt
    val AB = Array.fill(2)(sc.nextInt)

    val max = AB.min
    val min = Array(AB.sum - N, 0).max

    "%d %d".format(max, min)
  }
}


Measured memory_bytes: 25932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;
vector<int> S[MAX],cnt(MAX),par(MAX);

void init(int v){
    for(int i=0;i<v;i++){
        par[i]=i;
    }
}

void DFS(int u){
    stack<int> ST;
    ST.push(u);
    while(!ST.empty()){
        int a=ST.top();
        ST.pop();
        for(int i=0;i<S[a].size();i++){
            int b=S[a][i];
            if(cnt[b]>=2){
                cnt[b]--;
            }else{
                ST.push(b);
                par[b]=a;
            }
        }
    }
}

int main(){
    
    int N,M;cin>>N>>M;
    for(int i=0;i<N+M-1;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        S[a].push_back(b);
        cnt[b]++;
    }
    
    int s=0;
    
    for(int i=0;i<N;i++){
        if(cnt[i]==0) s=i;
    }
    
    init(N);
    
    DFS(s);
    
    for(int i=0;i<N;i++){
        if(s==i) cout<<0<<endl;
        else cout<<par[i]+1<<endl;
    }
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(i, name)in(i)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(i,v) for(auto &i:(v))
#define all(v) (v).begin(),(v).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  if (N %10 == 7 || (N/10) % 10 == 7 || (N/100) % 10 == 7) {
    print("Yes");
  } else {
    print("No");
  }
}


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

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

  vector<int> vec(N);

  for (int i = 0; i < N; i++)
    cin >> vec.at(i);

  sort(vec.begin(), vec.end());

  int ans = 0;

  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < i; j++)
    {
      for (int k = 0; k < j; k++)
      {
        if (vec.at(i) != vec.at(j) && vec.at(j) != vec.at(k) && vec.at(k) != vec.at(i) && vec.at(i) < vec.at(j) + vec.at(k))
        {
          ans++;
        }
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3588