akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

#define bit(b, i) (((b) >> (i)) & 1)

LL l, n = 20;
vector<array<LL, 3>> v, w;

int main() {
	cin >> l;
	
	inc(i, n - 1) {
		v.PB({ i, i + 1, 0 });
		v.PB({ i, i + 1, 1 << i });
	}
	inc(i, n) {
		if(bit(l, i)) { v.PB({ i, n + 1, l & ((1 << i) - 1) }); }
	}
	
	int vs = v.size();
	inc(i, vs) {
	inc(j, vs) {
		if(v[i][1] == n - 1 && v[j][0] == n - 1) { v.PB({ v[i][0], v[j][1], v[i][2] + v[j][2] }); }
	}
	}
	inc(i, v.size()) {
		if(v[i][0] == n - 1 || v[i][1] == n - 1) { continue; }
		w.PB(v[i]);
	}
	
	inc(i, w.size()) { setmin(w[i][1], n - 1); }
	
	int m = w.size();
	cout << n << " " << m << "\n";
	inc(i, m) { cout << w[i][0] + 1 << " " << w[i][1] + 1 << " " << w[i][2] << "\n"; }
	
	return 0;
}


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

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			if(n == 0){
				break;
			}
			int[] p = new int[n];
			for(int i = 0;i < n;i++){
				p[i] = scan.nextInt();
			}
			Arrays.sort(p);
			long wait = 0;
			long sum = 0;
			for(int i = 1;i < n;i++){
				wait += p[i-1];
				sum += wait;
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 45200
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = (int) (N / (1.08));
		if (((int) ((ans - 1) * 1.08) == N)){
			System.out.println(ans - 1);
		}else if ((int) ((ans + 1) * 1.08) == N){
			System.out.println(ans + 1);
		}else if ((int) (ans * 1.08) == N){
			System.out.println(ans);
		}else{
			System.out.println(":(");
	    }
    }
}

Measured memory_bytes: 35684
dic = {}
dic["A"] = "BD"
dic["B"] = "ACE"
dic["C"] = "BF"
dic["D"] = "AEG"
dic["E"] = "BDFH"
dic["F"] = "CEI"
dic["G"] = "DH"
dic["H"] = "EGI"
dic["I"] = "FH"

results = []

for i in range(1000):
	pwd = input()
	frag = 1
	for j in range(len(pwd) - 1):
		if pwd[j] in dic[pwd[j + 1]]:
			a = 1
		else:
			frag = 0
			break
	if frag:
		results.append(pwd)

for i in range(len(results)):
	print(results[i])

Measured memory_bytes: 7628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>

using namespace std;


int main()
{
	int N, Q;
	string S;
	cin >> N >> Q >> S ;

	vector<int> sums(N+1, 0);


	for (int si = 2; si <= N; si++) {
		if (S[si - 2] == 'A' && S[si - 1] == 'C') {
			sums[si] = sums[si-1] + 1;
		}
		else {
			sums[si] = sums[si-1];
		}
	}


	int l, r, ans;
	for (int ni = 0; ni < Q; ni++) {
		cin >> l >> r;
		ans = sums[r] - sums[l];
		cout << ans << endl;
	}


	return 0;
}



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

int main() {
  int N = 0;
  int l = 0; 
  int r = 0;
  int hito = 0;
  cin >> N;
  for(int i = 0; i < N; i++){
  	cin >> l >> r;
    hito += (r - l) + 1;
  }
    cout << hito << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	int a, b;
	cin >> a >> b;
	for (int i = 1; i <= 10000; i++){
		int p = i*0.08, q = i*0.1;
		if (p == a && q == b){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


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

int main(int argc, char **argv)
{

  vector<long long> count(1000000, 0);
  int N;
  long long K;
  cin >> N >> K;
  for (int i = 0; i < N; ++i) {
    int a, b;
    cin >> a >> b;
    count[a] += b;
  }
  long long tmp_count = 0;
  int val = 0;
  // int pre_val = 0;
  while (tmp_count < K) {
    val++;
    tmp_count += count[val];
    // if (count[val] > 0) pre_val = val;
  }
  cout << val << endl;

  return 0;
}


Measured memory_bytes: 8064
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int D = sc.nextInt();
    
    String[] ans = new String[25+1];
    ans[25] = "Christmas";
    ans[24] = "Christmas Eve";
    ans[23] = "Christmas Eve Eve";
    ans[22] = "Christmas Eve Eve Eve";
    
    System.out.println(ans[D]);
  }
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    int p = sqrt(n);
    cout << p * p << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;

#define rep(i, n) for(int i = 0, i##_len=(n); i < i##_len; i++)
#define all(x) (x).begin(), (x).end()
#define SIZE(x) ((int)(x).size())

int main(void)
{
  // code begin

  int n, d;
  cin >> n >> d;

  cout << ceil((double)n / (2 * d + 1)) << endl;
}


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

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

int main(){
    ll n,k,ans=1e18*4; cin>>n>>k;
    vector<pair<ll,ll>> d(n);
    rep(i,n){
        ll x,y; cin>>x>>y;
        d[i]=mk(x,y);
    }
    ll xi,xj,yi,yj,x,y;
    for(ll pi=0;pi<n-1;pi++)for(ll pj=pi+1;pj<n;pj++){
        for(ll qi=0;qi<n-1;qi++)for(ll qj=qi+1;qj<n;qj++){
            tie(xi,ignore)=d[pi]; tie(xj,ignore)=d[pj];
            tie(ignore,yi)=d[qi]; tie(ignore,yj)=d[qj];
            if(xi>xj) swap(xi,xj);
            if(yi>yj) swap(yi,yj);
            ll cnt=0;
            rep(i,n){
                tie(x,y)=d[i];
                if(xi<=x && x<=xj && yi<=y && y<=yj) cnt++;
            }
            if(cnt>=k) ans=min(ans,(xj-xi)*(yj-yi));
        } 
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){

        string s,p,tmp = "";
        cin >> s;
        cin >> p;
        if(s.find(p) != string::npos){
                cout << "Yes\n";
                return 0;
        }

        for(int i = 1; i <= p.length(); i++){
                for(int j = (s.length() - i); j < (s.length() + p.length() - i); j++){
                        if(j < s.length()){
                                tmp.append(1,s.at(j));
                        }
                        else{
                                tmp.append(1,s.at(j - s.length()));
                        }


                }
                if(p.compare(tmp) == 0){
                        cout << "Yes\n";
                        return 0;
                }
                else tmp.erase(tmp.begin(),tmp.end());

        }

        cout << "No\n";

        return 0;
}

Measured memory_bytes: 1188
str = gets.split
N,K = str[0].to_i, str[1].to_i
a = 0
if K > N*(N-1)/2 - (N-1)
    puts "-1"
    exit
else
    a = N*(N-1)/2 - (N-1) - K
end
puts a+N-1
for x in 2..N do
    print "1 ",x
    puts
end
i = 2
j = 3
while a > 0
    print i," ",j
    puts
    a -= 1
    if j < N
        j += 1
    else
        i += 1
        j = i+1
    end
end

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

using namespace std;

int main() {
    string s;
    cin >> s;

    int len = s.length();

    if (s[0] == s[len - 1]) {// 最終的なsの長さは奇数
        if (len % 2 == 0) {//奇数回取れる
            cout << "First" << endl;
        } else {
            cout << "Second" << endl;
        }
    } else {// 最終的なsの長さは偶数
        if (len % 2 == 0) {//偶数回取れる
            cout << "Second" << endl;
        } else {
            cout << "First" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    long long a[n];
    for (int i = 0; i < n; ++i){
        cin >> a[i];
    }
    long long s1, a1 = 0, s2, a2 = 0;
    if (a[0] > 0){
        s1 = a[0];
        s2 = -1;
        a2 = a[0] + 1;
    }
    else if (a[0] < 0){
        s1 = 1;
        s2 = a[0];
        a1 = 1 - a[0];
    }
    else {
        s1 = 1;
        s2 = -1;
        a1 = 1;
        a2 = 1;
    }
    for (int i = 1; i < n; ++i){
        if (s1 > 0){
            if (s1 + a[i] >= 0){
                a1 += s1 + a[i] + 1;
                s1 = -1;
            }
            else
                s1 += a[i];
        }
        else {
            if (s1 + a[i] <= 0){
                a1 += 1 - s1 - a[i];
                s1 = 1;
            }
            else
                s1 += a[i];
        }
    }
    for (int i = 1; i < n; ++i){
        if (s2 > 0){
            if (s2 + a[i] >= 0){
                a2 += s2 + a[i] + 1;
                s2 = -1;
            }
            else
                s2 += a[i];
        }
        else {
            if (s2 + a[i] <= 0){
                a2 += 1 - s2 - a[i];
                s2 = 1;
            }
            else
                s2 += a[i];
        }
    }
    cout << min(a1,a2) << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

vector<vector<int>> G;

int solve(int u){
    int k = G[u].size();
    if(k == 0) return 0;
    vector<int> s(k);
    rep(i,k){
        s[i] = solve(G[u][i]);
    }
    sort(s.begin(),s.end());
    int res = 0;
    rep(i,k){
        res = max(res,s[i]+k-i);
    }
    return res;
}

int main(){
    int N; cin >> N;
    G.resize(N);
    repr(i,1,N){
        int a; cin >> a;
        a--;
        G[a].push_back(i);
    }
    int ans = solve(0);
    cout << ans << endl;

}

    



Measured memory_bytes: 16640
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
ll const MOD=1000000007;

int N;
int a[100];
int cnt[9];

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

    rep(i,N){
        if(a[i]<=399) cnt[0]++;
        else if(a[i]<=799) cnt[1]++;
        else if(a[i]<=1199) cnt[2]++;
        else if(a[i]<=1599) cnt[3]++;
        else if(a[i]<=1999) cnt[4]++;
        else if(a[i]<=2399) cnt[5]++;
        else if(a[i]<=2799) cnt[6]++;
        else if(a[i]<=3199) cnt[7]++;
        else cnt[8]++;
    }
    //rep(i,9) cout<<i<<' '<<cnt[i]<<endl;

    int mini=0, maxi=0;
    rep(i,8){
        if(cnt[i]>0) mini++;
    }
    maxi=mini+cnt[8];
    if(mini==0) mini=1;

    cout<<mini<<' '<<maxi<<endl;
}

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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var n = Read().ToInt();
            var res = new List<Tuple<int, Tuple<int, int>>>();
            for (int i = 0; i < n; i++)
            {
                var a = Read().ToInt();
                for (int j = 0; j < a; j++)
                {
                    var r = ReadSplit();
                    res.Add(new Tuple<int, Tuple<int, int>>(i, new Tuple<int, int>(r[0].ToInt() - 1, r[1].ToInt())));
                }
            }

            var max = 0;
            var count = 0;
            for (int i = 0; i < 1 << n; i++)
            {
                bool hasError = false;
                count = 0;
                var tmp = new bool[n];

                for (int j = 0; j < n; j++)
                {
                    if ((i >> j & 1) == 1)
                    {
                        tmp[j] = true;
                        count++;
                    }
                    else
                    {
                        tmp[j] = false;
                    }
                }
                for (int j = 0; j < n; j++)
                {
                    if (!tmp[j]) continue;
                    foreach (var item in res.Where(x => x.Item1 == j))
                    {
                        var cur = tmp[item.Item2.Item1];
                        var jud = item.Item2.Item2;
                        
                        if (cur != (jud == 1))
                        {
                            hasError = true;
                            count = 0;
                            break;
                        }
                     }
                }
                if (!hasError)
                {
                    max = Math.Max(max, count);
                }
            }
            WriteRead(max);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }
    }
}


public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))


        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 17448
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define fr(i,f,t) for(ll i=(f);i<t;i++)
#define fb(i,f,t) for(ll i=(f);i>=t;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    vector<int> vec(n,0);
    vector<int> data(n+1,0);
    for(int i=0;i<n-1;i++){
    	cin>>vec[i];
    	data[vec[i]]++;
    }
    for(int i=1;i<=n;i++){
    	cout<<data[i]<<endl;
    }
    return 0;
}

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

int main() {
  int A;
  cin >> A;
  vector<int64_t> lucas(A + 1);
  lucas.at(0) = 2;
  lucas.at(1) = 1;
  
  for (int i = 2; i <= A; i++) {
    lucas.at(i) = lucas.at(i - 1) + lucas.at(i - 2);
  }
  cout << lucas.at(A) << endl;
}


Measured memory_bytes: 3632
using System;

class Search
{
    public bool LinearSearch(int[] a, int n, int key) {
        a[n] = key;
        int i=0;
        while (a[i] != key) {
            i++;
        }
        return i != n;
    }
}

class A
{
    public static void Main() {
        int n, q, count=0;
        int[] s;
        Search search = new Search();
        s = new int[100001];
        n = int.Parse(Console.ReadLine());
        string[] data = Console.ReadLine().Split(' '); 
        for (int i = 0; i < n; i++) {
            s[i] = int.Parse(data[i]);
        }
        q = int.Parse(Console.ReadLine());
        string[] data2 = Console.ReadLine().Split(' ');
        for (int i = 0; i < q; i++) {
            if (search.LinearSearch(s, n, int.Parse(data2[i]))) {
                count++;
            }
        }
        Console.WriteLine(count);
    }
}


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

typedef long long int   ll;
#define int             ll
#define PI              3.1415926535897932384626433832795

#define pb              push_back
#define rep0            for(int i=0;i<n;i++)
#define rep1            for(int i=1;i<=n;i++)
#define inputar0(ar)    for(int i=0;i<n;i++)cin>>ar[i]
#define inputar1(ar)    for(int i=1;i<=n;i++)cin>>ar[i]

#define hell            freopen("input.txt","r", stdin);freopen("output.txt", "w", stdout);freopen("error.txt", "w",stderr);
#define fastasF_boi()   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
//#define cerr            if(false)cerr

int mod=1000000007;
int maxn=200001;
int binpow(int a,int b,int mod){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
int binpow(int a,int b){int res=1;while(b>0){if(b%2){res=(res*a);b--;}a=(a*a);b/=2;}return res;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}
int mulmod(int a,int b){return ((a%mod)*(b%mod))%mod;}
int addmod(int a,int b){return (((a%mod)+(b%mod))+mod)%mod;}

void solve(){
    string s;cin>>s;
    int num=0;
    for(auto it:s)
        num+=int(it-'0');
    if(num==0 or num%9==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

signed main(){
//    hell;

    fastasF_boi();
    int t=1;
//    cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
}



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

int main(){
	string n;
	cin>>n;
	ll res = 0;
	for(ll i = 0;i<n.size();i++){
		res += (n[i]-'0');
	}
	if(res%9 == 0){
		puts("Yes");
	}
	else{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 3752
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))

sys.setrecursionlimit(10 ** 9)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors


def main():
    N, X = MAP()
    x = LIST()

    if N == 1:
        print(abs(x[0] - X))
        sys.exit()

    for d in make_divisors(max(x)-min(x)):
        for i in range(N):
            if abs(X - x[i]) % d != 0: break
        else:
            print(d)
            sys.exit()


if __name__ == '__main__':
    main()

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

using namespace std;
const long long INF = 1LL <<60;  

int main(void){
  long res=0;
  long i,j,k;
  string tmp;
  long n,d;
  
  cin>>n;
  cin>>tmp;
  long r[n];
  
  if(tmp[0]=='R'){
    r[0]=1;
  }
  else{
    r[0]=0;
  }
  for(i=1;i<n;i++){
    if(tmp[i]=='R'){
      r[i]=r[i-1]+1;
    }
    else{
      r[i]=r[i-1];
    }
  }
  res=r[n-1]-r[r[n-1]-1];

  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 5312
#include <stdio.h>
#define N 1000100
int amari[N];
int keta[N];
int main() {
	int p, q;
	while(scanf("%d %d", &p, &q) != EOF) {
		int i;
		for(i = 0; i < N; ++ i) amari[i] = -1;
		int count;
		amari[p] = 0;
		for(count = 0; ; ) {
			p *= 10;
			keta[count ++] = p / q;
			p = p % q;
			if(p == 0) {
				for(i = 0; i < count; ++ i) printf("%d", keta[i]);
				printf("\n");
				break;
			}
			if(amari[p] != -1) {
				for(i = 0; i < count; ++ i) printf("%d", keta[i]);
				printf("\n");
				for(i = 0; i < amari[p]; ++ i) printf(" ");
				for(i = amari[p]; i < count; ++ i) printf("^");
				printf("\n");
				break;
			}
			amari[p] = count;
		}
	}
	return 0;
}

Measured memory_bytes: 6372
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<double> a(n);
    double sum = 0;
    for(int i = 0;i < n;i++){
          cin >> a[i];
          sum += a[i];
    }
    double ave = sum / n;
    double t = 101;
    int ans = -1;
    for(int i = a.size() - 1;i >= 0;i--){
          if(t >= abs(ave - a[i])){
                 t = abs(ave - a[i]);
                 ans = i;
          }
    }
    cout << ans << endl;
    
}


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

int main()
{
    int n;
    cin >> n;
    int l[n], r[n], sum = 0;

    for (size_t i = 0; i < n; i++)
    {
        cin >> l[i] >> r[i];
        sum += r[i] - l[i] + 1;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long int ll;

int main() {
  int N;
  cin>>N;
  
  vector<string> str_v(N);
  for(int i=0;i<N;++i){
    cin>>str_v[i];
  }
  
  ll ans=0;
  unordered_map<string,int> mp;
  for(int i=0;i<N;++i){
    sort(str_v[i].begin(),str_v[i].end());
    ans+=mp[str_v[i]];
    ++mp[str_v[i]];
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 17700
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>

using namespace std;

int main() {
 vector<int> vec(3);
  cin >> vec.at(0) >> vec.at(1) >> vec.at(2);
  sort(vec.begin(), vec.end());
  cout << vec.at(0)+vec.at(1)+vec.at(2)*10 << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


#include <bits/stdc++.h>
using namespace std;
signed main(){
    int N,K;
    cin>>N>>K;
    vector<int> x(N); 
    REP(i,N) cin>>x[i];
    int ans=0;
    REP(i,N){
        ans += min(x[i],K-x[i])*2;
    }
    cout<<ans<<endl;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

const long long INF = 1001001001;

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

	vector <ll> h(N);
	for (int ii = 0; ii < N; ++ii){
		cin >> h[ii];
	}

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

	ll ans = INF;
	for (int ii = 0; ii < N; ++ii){
		if (ii+K-1 >= N){
			break;
		}
		ll tmp = h[ii+K-1] - h[ii];
		ans = min(ans, tmp);
	}	

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  string s; cin >> s;
  ll n = SZ(s);
  if(n==2) cout << s << endl;
  else{
    reverse(ALL(s));
    cout << s << endl;
  } 
}

Measured memory_bytes: 256
require 'prime'
M = 10 ** 9 + 7
N = gets.to_i

d = {}
Prime.instance.each(N) do |pr|
  d[pr] = 0
end
(2 .. N).each do |n|
  n.prime_division.each do |n,e|
    d[n] += e
  end
end
ans = d.values.inject(1) do |s, v|
  (s * (v + 1)) % M
end

puts ans

Measured memory_bytes: 2300
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;


int main() {
  int n,k,d;
  cin >> n >> k;
  std::vector<int> v(n,0);
  rep(i,k) {
    cin >> d;
    for(int j=0; j<d; j++){
      int dd;
      cin >> dd;
      v[dd-1] = 1;
    }
  }
  debug(v);
  int count = 0;
  rep(i, v.size()) {
    if (v[i] == 0) count += 1;
  }
  cout << count << endl;
}


Measured memory_bytes: 3172
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, A, B = map(int, input().split())

ans = 0
L = list(map(int, input().split()))

diff = [0]*N
for i in range(N):
    diff[i] = L[i]-L[i-1]

for i in range(1, N):
    if diff[i]*A >= B:
        ans += B
    else:
        ans += diff[i]*A
print(ans)


Measured memory_bytes: 14172
import java.util.*;

public class Main {// Main
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		int n =a.length();
		int m = b.length();
		int[][] dp = new int[n+1][m+1];
		
		
		for(int i = n-1 ;i >=0 ; i--) {
			for(int j = m-1 ;j >=0 ;j--) {
				if(a.charAt(i)==b.charAt(j)) {
					dp[i][j]= dp[i+1][j+1]+1;
				}else {
					dp[i][j] = Math.max(dp[i+1][j], dp[i][j+1]);
				}
			}
		}
		
		int row = 0 ; 
		int col = 0;
		String ans ="";
		while(row!=n && col!=m) {
			int cur = dp[row][col];
			int right = dp[row][col+1];
			int down = dp[row+1][col];
			int diagonal = dp[row+1][col+1];
			 if(cur == right) {
				col++;
			}else if(cur==down){
				row++;
			}else if(cur==diagonal+1) {
					ans+=a.charAt(row);
					row++;
					col++;
				}
		}
		
		
		
		
		
		
		
		
		
  System.out.println(ans);
	}

}

Measured memory_bytes: 88568
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int                 long long   
#define double              long double
#define endl                "\n"
#define pb                  push_back
#define PI                  3.1415926535897932384626433832795l
#define F                   first
#define S                   second
#define mp                  make_pair
#define f(i,n)              for(int i=0;i<n;i++)
#define fastio              ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)              (v).begin(),(v).end()
#define rall(v)             (v).rbegin(),(v).rend()
#define gcd(a,b)            __gcd((a),(b))
#define fill(a,value)       memset(a,value,sizeof(a));
#define minn(v)             *min_element(v.begin(), v.end());
#define maxx(v)             *max_element(v.begin(), v.end());
#define print(x)            cout<<(x)<<endl;
#define sum(v)+x            accumulate(v.begin(), v.end(),x);
#define debug(x)            cout<<#x<<'='<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;

signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    int n;
    cin>>n;
    vi a(n+1),b(n);
    f(i,n+1)cin>>a[i];
    f(i,n)cin>>b[i];
    int ans=0;
    f(i,n)
    {
        int x=min(a[i],b[i]);
        ans+=x;
        int y=b[i]-x;
        if(y>0)
        {
            int z=min(a[i+1],y);
            ans+=z;
            a[i+1]-=z;
        }
        
    }
    print(ans)
    
    
    
    return 0;
}

Measured memory_bytes: 4736
import java.util.*;

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

        for (int i = 1; i < 1000; i++) {
            for (int j = 2; j < 1000; j++) {
                if (Math.pow(i, j) > X) {
                    break;
                } else {
                    if (ans < Math.pow(i, j)) {
                        ans = (int)Math.pow(i, j);
                    }
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
n = int(input())
a = [[0 for i in range(n)] for j in range(2)]
for i in range(2):
  a[i] = list(map(int,input().split()))

ans=0
tmp1=0
tmp2=0
for i in range(n):
  tmp1+=a[0][i]
  tmp2=tmp1
  for j in range(i,n):
    tmp2+=a[1][j]
  if tmp2>=ans:
    ans=tmp2
print(ans)
  

Measured memory_bytes: 3064
#include <cstdio>

constexpr long long MOD = 1000000007;

template<typename T>
T gcd(T a, T b)
{
	if (a < b) return gcd(b, a);
	T r;
	while (r = a % b)
	{
		a = b;
		b = r;
	}
	return b;
}

inline long long mod(long long a, long long m)
{
	long long res = a % m;
	if (res < 0) res += m;
	return res;
}

long long extGCD(long long a, long long b, long long &p, long long &q)
{
	if (b == 0)
	{
		p = 1;
		q = 0;
		return a;
	}
	long long d = extGCD(b, a % b, q, p);
	q -= a / b * p;
	return d;
}

long long modinv(long long a, long long m) {
	long long x, y;
	extGCD(a, m, x, y);
	return mod(x, m);
}

#include <cstdio>
#include <map>

std::map<int ,int> lcm;

std::map<int, int> prime_factor(int n)
{
	std::map<int, int> r;
	for (long long i = 2; i * i <= n; ++i)
	{
		if (n % i == 0)
		{
			while (n % i == 0)
			{
				r[i]++;
				n /= i;
			}
			if (lcm[i] < r[i]) lcm[i] = r[i];
		}
	}
	if (n != 1)
	{
		r[n] = 1;
		if (lcm.count(n) == 0) lcm[n] = 1;
	}
	return r;
}

long long power(long long a, long long b)
{
	long long r = 1;
	while (b > 0)
	{
		if ((b & 1) != 0) r = (r * a) % MOD;
		a = (a * a) % MOD;
		b >>= 1;
	}
	return r;
}

int main()
{
	int n;
	scanf("%d", &n);
	std::map<int, int> fac[10000];
	int a[10000];
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", a + i);
		fac[i] = prime_factor(a[i]);
	}
	long long lcmm = 1;
	for (auto &p : lcm)
	{
		lcmm = lcmm * power(p.first, p.second) % MOD;
	}

	long long ans = 0;
	for (int i = 0; i < n; ++i)
	{
		ans = (ans + lcmm * modinv(a[i], MOD)) % MOD;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3072
fun pow10mod2019List():List<Int> {
    val result = (1..200000).map { 0 }.toMutableList() 
    result[0] = 1
    for(i in 1 until 200000) {
        result[i] = (result[i-1] * 10) % 2019
    }
    return result
}

fun solve(input: String, memo_list: List<Int>): Long {
    val _input = input.reversed()
    val len = input.length
    
    val mod_list = (1..len).map { 0 }.toMutableList()
    mod_list[0] = (_input[0] - '0').toInt()
    val mod_map: MutableMap<Int,Long> = mutableMapOf()
    mod_map[0] = 1L
    mod_map[mod_list[0]] = mod_map.getOrDefault(mod_list[0], 0L) + 1L
    for(i in 1 until len) {
        mod_list[i] = (mod_list[i - 1] + (memo_list[i] * (_input[i] - '0').toInt()) % 2019) % 2019
        mod_map[mod_list[i]] = mod_map.getOrDefault(mod_list[i], 0L) + 1L
    }
    // mod_map.forEach { i, v -> 
    //     println("${i} -> ${v}")
    // }
    return mod_map.values.map {it -> it * (it-1)/2}.fold(0L) {a,b -> a+b}
}
fun main(args: Array<String>) {
    val S = readLine()!!
    val memo_list = pow10mod2019List()
    solve(S, memo_list).run(::println)
}

Measured memory_bytes: 63224
#include <iostream>
#include <map>
#include <queue>
using namespace std;
typedef pair<int,int> P;

int w, h;
int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};
char cell[20][20];
bool used[20][20];

int main(){
	while(cin >> w >> h){
		if(w == 0 && h == 0) break;
		queue<P> que;
		for(int i = 0; i < 20; i++){
			for(int j = 0; j < 20; j++) used[i][j] = 0;
		}
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> cell[i][j];
				if(cell[i][j] == '@'){
					que.push(P(i,j));
					used[i][j] = 1;
				}
			}
		}
		while(!que.empty()){
			P p = que.front(); que.pop();
			for(int i = 0; i < 4; i++){
				int px = p.second+dx[i],py = p.first+dy[i];
				if(0<=px&&px<w&&0<=py&&py<h&&cell[py][px]=='.'&&used[py][px]==false){
					used[py][px] = true;
					que.push(P(py,px));
				}
			}
		}
		int ans = 0;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(used[i][j]) ans++;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1216
line1=input().split()
h=int(line1[0])
w=int(line1[1])
karta=[]
for i in range(h):
    karta.append(input())

out=[]
for i in range(h):
    out.append("")
    for j in range(w):
        if karta[i][j]=="#":
            out[i]+="#"
        else:
            count=0
            if i>0:
                if karta[i-1][j]=="#":
                    count+=1
                if j>0:
                    if karta[i-1][j-1]=="#":
                        count+=1
                if j<w-1:
                    if karta[i-1][j+1]=="#":
                        count+=1
            if i<h-1:
                if karta[i+1][j]=="#":
                    count+=1
                if j>0:
                    if karta[i+1][j-1]=="#":
                        count+=1
                if j<w-1:
                    if karta[i+1][j+1]=="#":
                        count+=1
            if j>0:
                if karta[i][j-1]=="#":
                    count+=1
            if j<w-1:
                if karta[i][j+1]=="#":
                    count+=1
            out[i]+=str(count)
for i in range(h):
    print(out[i])


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

int main(){
    string N;
    cin >> N;
    long long sum=0;
    rep(i,N.length()){
        sum+=(int)(N[i]-'0');
    }
    if(sum%9==0){ cout << "Yes" << endl;}
    else{ cout << "No" << endl;}
}

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

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

Measured memory_bytes: 3692
import java.util.Scanner;
public class Main {
  public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int n = sc.nextInt();
   int ac=0,wa=0,tle=0,re=0;
   for(int i=0;i<n;i++){
    switch(sc.next()){
      case "AC":
        ac++;
        break;
      case "WA":
        wa++;
        break;
      case "TLE":
        tle++;
        break;
      case "RE":
        re++;
        break;
      default:
        break;
    }
   }

   System.out.println("AC x "+ac);
   System.out.println("WA x "+wa);
   System.out.println("TLE x "+tle);
   System.out.println("RE x "+re);
  }
}

Measured memory_bytes: 59656
import math
a,b,h,m = map(int,input().split())
zisin = (h * 60 + m) / 2
hunsin = m * 6
xzahyou = ((math.sin(math.radians(zisin)))*a - (math.sin(math.radians(hunsin)))*b) ** 2
yzahyou = ((math.cos(math.radians(zisin)))*a - (math.cos(math.radians(hunsin)))*b) ** 2
print((xzahyou + yzahyou) ** (1/2))


Measured memory_bytes: 9516
# UnionFindでつなげていく
# [所属する木の頂点数]-[1（自分）]-[自分とブロック関係にある人の数]

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):
        return len(self.roots())
 
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
 
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
    def show_parents(self):
      print(self.parents)

# ここまでUnionFind
N,M,K=map(int,input().split())

UF=UnionFind(N)
from collections import defaultdict
dic=defaultdict(set)
friends=[0]*N
for i in range(M):
  a,b=map(int,input().split())
  UF.union(a-1,b-1)
  friends[a-1]+=1
  friends[b-1]+=1

for i in range(N):
  dic[UF.find(i)].add(i)

block=defaultdict(set)
for i in range(K):
  c,d=map(int,input().split())
  block[c-1].add(d-1)
  block[d-1].add(c-1)

# UF.show_parents()
# 同じ木に所属する人数のうち、ブロック関係にない人数
ans=[0]*N
for i in range(N):
  candi=dic[UF.find(i)]
  #print("i",candi,"block",block[i])
  ans[i]=len(candi)-friends[i]-1
  for b in block[i]:
    if UF.same(i,b):
      ans[i]-=1
  if ans[i]<0:
    ans[i]=0
print(*ans)


Measured memory_bytes: 124292
from sys import stdin,stdout
from collections import defaultdict
import math
from bisect import bisect
input=stdin.readline
#def print(x):stdout.write(str(x)+'\n')
s=input().strip()
t=input().strip()
n=len(s)
m=len(t)
ans=m
for i in range(n-m+1):
    c=0
    for j in range(min(m,n)):
        if s[i+j]!=t[j]:
            c+=1
    ans=min(c,ans)
print(ans)
        

Measured memory_bytes: 9348
import java.util.*;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] w = new int[n];
		int[] t = new int[n];
		int sumW = 0;
		int sumT = 0;
		for(int i = 0; i < w.length; i++) {
			w[i] = sc.nextInt();
			sumW += w[i];
		}
		for(int i = 0; i < w.length; i++) {
			sumT += w[i];
			t[i] = Math.abs((sumW-sumT) - sumT);
		}
		int min = 100000;
		for(int i = 0; i < t.length ; i++) {
			if(t[i] < min) {
				min = t[i];
			}
		}
		System.out.println(min);
	}
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int dig(int x){
	for(int i = 31; i >= 0; i--){
		if((x >> i) & 1) return i;
	}
}

int mask(int d){
	return (1 << (d+1)) - 1;
}

void print(int x){
	for(int i = 10; i >= 0; i--){
		cout << ((x & (1 << i)) >> i);
	}
	cout << endl;
}

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

	int n;
	cin >> n;

	int a[n];
	rep(i, n) cin >> a[i];

	int x = 0;
	rep(i, n) x ^= a[i];
	// print(x);

	if(x == 0){
		cout << 0 << endl;
		return 0;
	}

	int b[n];
	rep(i, n) b[i] = dig(a[i] ^ (a[i]-1));
	bool u[n] = {};

	int ans = 0;
	for(int i = 31; i >= 0; i--){
		if(x & (1 << i)){
			bool updated = false;
			rep(j, n){
				if(!u[j] && b[j] == i){
					updated = true;
					x ^= a[j] ^ (a[j]-1);
					u[j] = true;
					ans++;
					break;
				}
			}
			if(!updated){
				cout << -1 << endl;
				return 0;
			}
		}

	}
	if(x == 0){
		cout << ans << endl;
	}else{
		cout << -1 << endl;
	}

}


Measured memory_bytes: 1152
N, M, C = map(int, input().split())
B= list(map(int, input().split()))
cnt = 0
for j in range(N):
    A= list(map(int, input().split()))
    i=0
    sum=0
    for i in range(M):
        sum = sum + B[i]*A[i]
    sum = sum + C
    if sum > 0:
        cnt += 1

print(cnt)

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

void tansaku(vector<vector<ll>>& path, vector<bool>& check, ll num);

int main(){
  ll N, M;
  cin >> N >> M;
  
  vector<vector<ll>> path(N + 1, vector<ll>(0));
  for (ll i = 0; i < M; i++){
    ll a, b, z;
    cin >> a >> b >> z;
    path.at(a).push_back(b);
    path.at(b).push_back(a);
  }
  
  vector<bool> check(N + 1, false);
  ll ans = 0;
  for (ll i = 1; i <= N; i++){
    if (check.at(i) == true){
      continue;
    }
    check.at(i) = true;
    tansaku(path, check, i);
    //cout << i << endl;
    ans++;
  }
  
  cout << ans << endl;
}

void tansaku(vector<vector<ll>>& path, vector<bool>& check, ll num){
  for (ll i : path.at(num)){
    if (check.at(i) == false){
      check.at(i) = true;
      tansaku(path, check, i);
    }
  }
  check.at(num) = true;
}

Measured memory_bytes: 14644
package main

import (
	"fmt"
	"math"
)

func intMin(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func main() {
	var S string
	fmt.Scan(&S)

	cnt := []int{0, 0}
	for i, rn := range S {
		s := string(rn)
		if s == "0" {
			if i%2 == 1 {
				cnt[0]++
			} else {
				cnt[1]++
			}
		} else {
			if i%2 == 0 {
				cnt[0]++
			} else {
				cnt[1]++
			}
		}
	}

	fmt.Println(intMin(cnt[0], cnt[1]))
}


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

int main()
{
    char ch;
    int count[26] = {0};
    while(cin >> ch){
        if(islower(ch)){
            count[ch -'a']++;
        } else if(isupper(ch)){
            count[ch -'A']++;
        }
    }
    for(int i = 0;i < 26;i++){
        cout << char(i +'a') << " : " << count[i] << endl;
    }
    return 0;
}

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

int32_t main(){
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	int mx = 0;
	map<string, int> mp;
	for(int i=0; i<n; ++i){
		string st;
		cin >> st;
		if(mp.find(st)==mp.end())
			mp[st] = 1;
		else
			++mp[st];
		mx = max(mx, mp[st]);
	}
	vector<string> vs;
	for(auto x:mp){
		if(x.second==mx) vs.push_back(x.first);
	}
	sort(vs.begin(), vs.end());
	for(auto s:vs)
		cout << s << endl;
}

Measured memory_bytes: 26224
import java.io.*;
import java.util.*;

public class Main {


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

        FastReader fs = new FastReader();
        out = new PrintWriter(new BufferedOutputStream(System.out));

       String s = fs.next();

       long ans = 0 ;
       long mod = 9 ;

       for(int i=0; i<s.length() ; i++ ){
           long dig = s.charAt(i) - 48 ;
           ans = (ans%mod + dig%mod)%mod;
       }

       if(ans == 0){
           out.println("Yes");
       }else{
           out.println("No");
       }

        out.close();

    }

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
    //--------------------------------------------------------
}



Measured memory_bytes: 36236