akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  
  int N;
  scanf("%d",&N);
  std::string S;
  std::cin >> S;
  char compare = S[0];
  int ans = 1;
  for (int i=1; i<N; i++){
    if (S[i]!=compare){
      compare = S[i];
      ans++;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <array>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for (int i=(a);i>=(b);--i)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
constexpr int INF = 1100100100;

template<typename T>
class Lis {
  public:
    Lis(std::vector<T> const &s, T infty):
      n(s.size()), inf(infty),seq(s), dp(n, inf) {}
    size_t solve() {
      for (size_t i = 0; i < n; ++i) {
        *std::lower_bound(dp.begin(), dp.end(), seq[i]) = seq[i];
      }
      return std::distance(
          dp.begin(),
          std::lower_bound(dp.begin(), dp.end(), inf));
    }
  private:
    size_t const n;
    T const inf;
    std::vector<T> const seq;
    std::vector<T> dp;
};

using namespace std;

int main() {
  // cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<int> a;
  REP(i, n) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  Lis<int> lis(a, INF);
  cout << lis.solve() << endl;
  return 0;
}



Measured memory_bytes: 4212
#include <stdio.h>

class Dice3{
public:
	Dice3(){
		number = new int[6];
		checkTable = new int[101];
		for(int i = 0; i < 101; i++) checkTable[i] = -1;
	};
	~Dice3(){
		delete[] number;
		delete[] checkTable;
	};

	void setLabel(int index,int num){
		number[index] = num;
		checkTable[num] = index;
	};

	void roll(char dst){
		switch(dst){
		case 'E':
			setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
			break;
		case 'N':
			setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
			break;
		case 'S':
			setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
			break;
		case 'W':
			setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
			break;
		}
	};

	bool isValidMember(int inputed[]){
		for(int i = 0; i < 6; i++)
		{
			if(checkTable[inputed[i]] == -1)
				return false;
		}
		return true;
	}
	bool isSameDice(int inputed[]){
		char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
		for(int i = 0; i < 24; i++){
			roll(order[i]);
			for(int j = 0; j < 6; j++){
				if(inputed[j] != number[j])
					break;
				if(j == 5)
					return true;
			}
		}
		return false;
	}

private:
	void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}

private:
	int* number;
	int* checkTable;
};

int main(){
	Dice3 dice3;
	int tmp,inputed[6];
	for(int i = 0; i < 6; i++){
		scanf("%d",&tmp);
		dice3.setLabel(i,tmp);
	}
	for(int i = 0; i < 6; i++) scanf("%d",&inputed[i]);

	if(dice3.isValidMember(inputed) && dice3.isSameDice(inputed))
		printf("Yes\n");
	else{
		printf("No\n");
	}
}





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

int main(int argc, char const *argv[])
{
	int d;
	cin>>d;
	if (d==25)
	{
		cout<<"Christmas\n";
	}
	else if (d==24)
	{
		cout<<"Christmas Eve\n";
	}
	else if (d==23)
	{
		cout<<"Christmas Eve Eve\n";
	}
	else if (d==22)
	{
		cout<<"Christmas Eve Eve Eve\n";
	}
	return 0;
}


Measured memory_bytes: 256
// グラフ

#include <algorithm>
#include <array>
#include <bitset>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long
using P = pair<int, int>;
constexpr int INF = 1000000000 + 8;

class Graph {
   private:
    struct edge {
        int to;
        int cost;
        edge(int i, int c = 1) : to(i), cost(c) {}
    };
    vector<vector<edge>> edges;
    vector<int> dists;

   public:
    Graph(int n) { edges.resize(n); };
    int size() const { return edges.size(); };
    int countEdge() const {
        int count = 0;
        for (auto &&i : edges)
            for (auto &&j : i) count++;
        return count;
    }
    void addDirectedEdge(int from, int to, int cost = 1) {
        edges[from].push_back(edge(to, cost));
    }
    void addEdge(int from, int to, int cost = 1) {
        addDirectedEdge(from, to, cost);
        addDirectedEdge(to, from, cost);
    }

    void markSpots() {
        dists.assign(size(), INF);
        queue<pair<int, int>> q;
        q.push({0, 0});

        while (!q.empty()) {
            int p = q.front().first, pp = q.front().second;
            q.pop();
            if (dists[p] != INF) continue;
            dists[p] = pp;

            for (auto &&edge : edges[p]) {
                const int np = edge.to;
                if (dists[np] == INF) {
                    q.push({np, p});
                }
            }
        }
    }
    int getDists(int i) const { return dists[i]; }
    bool unreachable() const {
        for (auto &&i : dists) {
            if (i == INF) return true;
        }
        return false;
    }
};

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

    int n, m;
    cin >> n >> m;

    Graph g(n);

    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;

        g.addEdge(u, v);
    }

    g.markSpots();
    if (g.unreachable()) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        for (int i = 1; i < n; i++) {
            cout << g.getDists(i) + 1 << endl;
        }
    }
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int a = in.nextInt();
		int b = in.nextInt();
		
		int k = b - a;
		if(k % 2 == 1) System.out.println("Borys");
		else System.out.println("Alice");
	}
}

Measured memory_bytes: 23508
use std::io;
use std::collections::HashMap;

fn read_line() -> String {
    let mut line = String::new();

    io::stdin().read_line(&mut line)
        .expect("Failed to read line");
    return line;
}
fn to_i(s: &str) -> i64 {
    return s.trim().parse()
        .expect("Please type a number!");
}
fn read_nums() -> Vec<i64>
{
    let line = read_line();
    let items: Vec<&str> = line.split(' ').collect();

    let mut nums: Vec<i64> = Vec::new();

    for item in items {
        nums.push(to_i(item));
    }
    return nums;
}


fn main() {
    //println!("start");
    let nab = read_nums();
    let n = nab[0];
    let a = nab[1];
    let b = nab[2];
    //println!("{}",n);
    let ret;
    if n*a<b {
        ret = n*a;
    } else {
        ret = b;
    }
    print!("{}", ret);
    
    
}   

Measured memory_bytes: 4352
L = []
C = []
n,m,x = map(int,input().split())
for i in range(n):
    tmp = list(map(int,input().split()))
    c =tmp[0]
    l = tmp[1:]
    L.append(l)
    C.append(c)


import itertools
M = 100000000000
ans = 0

for i in itertools.product([0, 1], repeat=n):
    dp = [0]*m
    tm= 0 
    for I in range(n):
        if i[I] == 1:
            for j in range(m):
                dp[j] += L[I][j]
            tm += C[I]* i[I]
    if all(dp[t]>=x for t in range(m)):
        M = min(M,tm)
if M==100000000000:
    print(-1)
else:
    print(M)

Measured memory_bytes: 9248
#include<stdio.h>

int main(){

int N;
scanf("%d",&N);
long L[N+1];
L[0]=2;
L[1]=1;
if(N>1){
	for(int i=2;i<N+1;i++){
		L[i]=L[i-1]+L[i-2];
	}
}
printf("%ld\n",L[N]);
	
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
ll MOD=1000000007;
const double PI = acos(-1);

int main(){
  int a,b; cin>>a>>b;
  cout << max(a+b, max(a-b, a*b)) << endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,a,b;
    cin>>n>>a>>b;

    int sum=0;

    for (int i=1;i<=n;i++) {
        int sumsum=0, k=i;
        while(k>0){
            sumsum+=k%10;
            k/=10;
        }
        if(a<=sumsum&&sumsum<=b){
            sum+=i;
        }
    }

    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<iostream>

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

int main(){

	int r[4];
	int sum;
	int remain;
	int d[4] = {10,50,100,500};
	int c[4];
	int p[4];
	int flag = 0;
	int m;
	int minc[4];
	while(std::cin >> m, (m)){
		if(flag == 1){
			std::cout << std::endl;
		}
		flag = 1;
		int min = 20*4+1;
		rep(i,4){
			std::cin >> c[i];
			minc[i] = 0;
		}
		for(p[0]=0; p[0]<=c[0]; p[0]++){
			for(p[1]=0; p[1]<=c[1]; p[1]++){
				for(p[2]=0; p[2]<=c[2]; p[2]++){
					for(p[3]=0; p[3]<=c[3]; p[3]++){
						sum = 0;
						rep(i,4){
							sum += d[i] * p[i];
							r[i] = 0;
						}
						if(sum < m)continue;

						sum -= m;
						rep(i,4){
							while(sum >= d[3-i]){
								sum -= d[3-i];
								r[3-i]++;
							}
						}
						remain = 0;
						rep(i,4){
							remain += c[i] - p[i] + r[i];
						}
						if(remain < min){
							min = remain;
							rep(i,4){
								minc[i] = p[i];
							}
						}
					}
				}
			}
		}
		rep(i,4){
			if(minc[i] > 0){
				std::cout << d[i] << ' ' << minc[i] << std::endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 868
# C Vacation
N = int(input())
A = [list(map(int, input().split())) for i in range(N)]

#print(N,A)

dp = [[0] * 3 for _ in range(N)]
dp[0][0] = A[0][0]
dp[0][1] = A[0][1]
dp[0][2] = A[0][2]
#print(dp)

for i in range(1,N):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i][j] = max(dp[i][j],dp[i-1][k]+A[i][j])

print(max(dp[N-1]))

Measured memory_bytes: 76504
#include <stdio.h>

int main()
{
  int n;
  scanf("%d", &n);
  
  char s[n+1];
  scanf("%s", s);
  
  int cnt = 0;
  for (int i = 0, j = 0; i < n; i++)
    s[i] == 'R' && s[j++] == 'W' && cnt++;
  
  printf("%d", cnt);
  return 0;
}

Measured memory_bytes: 2312
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true){
			int m = scan.nextInt();
			int f = scan.nextInt();
			int r = scan.nextInt();
			if(m == -1 && f == -1 && r == -1){
				break;
			}
			if(m == -1 || f == -1){
				System.out.println("F");
			}
			else if(m + f >= 80){
				System.out.println("A");
			}
			else if(m + f >= 65){
				System.out.println("B");
			}
			else if(m + f >= 50){
				System.out.println("C");
			}
			else if(m + f >= 30){
				if(r >= 50){
					System.out.println("C");
				}
				else{
					System.out.println("D");
				}
			}
			else{
				System.out.println("F");
			}
		}

	}

}

Measured memory_bytes: 19112
using System;

namespace ABC173
{
    class Program
    {
        static void Main(string[] args)
        {
            a();
        }

        public static void a()
        {
            int n = int.Parse(Console.ReadLine());
            int a = n % 1000;
            if(a == 0)
            {
                Console.WriteLine(a);
                return;
            }
            int ans = 1000 - a;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27524
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

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

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	int n;
	cin >> n;
	map<pi, int> mp;
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		long double x;
		cin >> x;
		ll y = x * 1e9 + 0.5;
		int a = 0, b = 0;
		while(y % 2 == 0) a++, y /= 2;
		while(y % 5 == 0) b++, y /= 5;
		for(auto p:mp) {
			if(p.F.F+a >= 18 && p.F.S+b >= 18) ans += p.S;
		}
		mp[{a, b}]++;
	}
	cout << ans << endl;	
}

Measured memory_bytes: 3784
import java.util.Scanner;

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

        int A = sc.nextInt();
        int P = sc.nextInt();

        System.out.println(solve(A, P));

        sc.close();
    }

    static int solve(int A, int P) {
        return (3 * A + P) / 2;
    }
}

Measured memory_bytes: 35880
#include <cstdio>
 #include <cstdlib>
 #include <iostream>
 #include <fstream>
 #include <sstream>
 #include <set>
 #include <map>
 #include <vector>
 #include <list>
 #include <algorithm>
 #include <cstring>
 #include <cmath>
 #include <string>
 #include <stack>
 #include <queue>
 #include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
 #include <cassert>
 #include <iomanip>        //do setprecision
 #include <ctime>
 #include <complex>
 using namespace std;

 #define FOR(i,b,e) for(int i=(b);i<(e);++i)
 #define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
 #define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
 #define REP(x, n) for(int x = 0; x < (n); ++x)

 #define ST first
 #define ND second
 #define PB push_back
 #define PF push_front
 #define MP make_pair
 #define LL long long
 #define ULL unsigned LL
 #define LD long double
 #define pii pair<int,int>
 #define pll pair<LL,LL>

 const double pi = 3.14159265358979323846264;
 const int mod=1000000007;

int main(){
	int x,y,z,k;
	cin>>x>>y>>z>>k;
	vector<LL> a(x),b(y),c(z);
	FOR(i,0,x)cin>>a[i];
	FOR(i,0,y)cin>>b[i];
	FOR(i,0,z)cin>>c[i];
	vector<LL> s;
	vector<LL> ans;
	FOR(i,0,x){
		FOR(j,0,y){
			s.PB(a[i]+b[j]);
		}
	}
	cerr<<"test"<<endl;
	sort(s.begin(),s.end());
	sort(c.begin(),c.end());
	int ls=s.size(),lc=c.size();
	LL l=0,r=300LL*mod,m=(l+r)/2;
	while(l!=m){
		LL tmp=0;
		FOR(i,0,lc){
			LL rest=m-c[i];
			tmp+=s.end()-lower_bound(s.begin(),s.end(),rest);
		}
		if(tmp>=k){
			l=m;
		}else{
			r=m;
		}
		m=(l+r)/2;
	}

	FOR(i,0,lc){
		LL rest=m-c[i];
		int idx=lower_bound(s.begin(),s.end(),rest)-s.begin();
		idx=max(ls-k-1,idx);
		FOR(j,idx,ls){
			ans.PB(c[i]+s[j]);
		}
	}

	int lans=ans.size();
	sort(ans.begin(),ans.end());
	FORD(i,lans,lans-k){
		cout<<ans[i]<<endl;
	}
  return 0;
}


Measured memory_bytes: 42344
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
count = Counter(a)
a.sort(reverse=True)
ans = 0
for num in a:
    if count[num] == 0:
        continue
    else:
        #numより大きい2のべき乗の数
        p = 2 ** num.bit_length()
        if p - num == num:
            if count[p - num] > 1:
                sub = count[num] // 2
                ans += sub
                count[num] -= sub * 2
        else:
            if count[p - num] > 0:
                sub = min(count[p - num], count[num])
                ans += sub
                count[p-num] -= sub
                count[num] -= sub
print(ans)


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

#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;


//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int power(int a,int n)
{
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return a*power(a*a,n/2);
    return power(a*a,n/2);
}
const int md = 998244353;
const int inf = (int) 1e18;

/*int inverse(int x){

    return power(x,mod-2)%mod;//little fermat....
}*/


signed main()
{
    showoff;
    /*int n,ans[maxn];
    cin >> n;
    vector<pair<pair<string,int>,int> >v;
    FOR(i,1,n+1){
        int sc;
        string s;
        cin >> s >> sc;
        v.pb({{s,-sc},i});
    }
    sort(v.begin(),v.end());
    FOR(i,0,n)ans[v[i].se] = i+1;
    FOR(i,1,n+1)cout << ans[i] << "\n";*/
    int n,k,ans = 0;
    cin >> n >> k;
    vector<int>v(n+5);
    FOR(i,1,n+1)cin >> v[i];
    FOR(i,0,k+1){
        FOR(j,0,k+1){
            if(i+j > min(n,k))break;
            vector<int>pos,neg;
            int tot = 0;
            FOR(l,1,i+1)if(v[l] > 0)pos.pb(v[l]),tot += v[l];
            else if(v[l] < 0)neg.pb(v[l]),tot += v[l];
            FOR(l,1,j+1)if(v[n-l+1] > 0)pos.pb(v[n-l+1]),tot += v[n-l+1];
            else if(v[n-l+1] < 0)neg.pb(v[n-l+1]),tot += v[n-l+1];
            sort(neg.begin(),neg.end());
            FOR(l,0,min(sz(neg),k-i-j))tot -= neg[l];
            ans = max(ans,tot);
        }
    }
    cout << ans << "\n";
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...    

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S, T; cin >> S >> T;
  int A, B; cin >> A >> B;
  string U; cin >> U;
  if (U == S) {
    cout << A - 1 << " " << B << endl;
  } else {
    cout << A << " " << B - 1 << endl;
  }

  return 0;
};


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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

const int mxn = 2e5 + 5, inf = 0x3f3f3f3f;
int n, val[mxn], vec[mxn], cnt, hd[mxn], nex[mxn << 1], to[mxn << 1], tot, dp[mxn], ans[mxn];

void add_edge(int u, int v) { nex[++ tot] = hd[u]; hd[u] = tot; to[tot] = v; }

void dfs(int u, int p) {
	int ps = lower_bound(dp, dp + mxn, val[u]) - dp, old = dp[ps];
	dp[ps] = val[u];
	ans[u] = lower_bound(dp, dp + mxn, inf) - dp;
	for (int e = hd[u]; e; e = nex[e]) {
		int v = to[e];
		if (v == p) continue;
		dfs(v, u);
	}
	dp[ps] = old;
}

int main() {
	scanf("%d", &n);
	rep(i, n) scanf("%d", &val[i]), vec[cnt ++] = val[i];
	sort(vec, vec + cnt); cnt = unique(vec, vec + cnt) - vec;
	rep(i, n) val[i] = lower_bound(vec, vec + cnt, val[i]) - vec;
	rep(i, n - 1) { int u, v; scanf("%d %d", &u, &v); -- u; -- v; add_edge(u, v); add_edge(v, u); }
	memset(dp, 0x3f, sizeof(dp));
	dfs(0, -1);
	rep(i, n) printf("%d\n", ans[i]);
	return 0;
}


Measured memory_bytes: 25220
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
	int64 nn, mm;
	cin >> nn >> mm;
	UnionFind tree(nn);
    for(int64 ii = 0;ii < mm;ii++)
    {
        int xx, yy;
        cin >> xx >> yy;
        xx--;
        yy--;
        tree.unite(xx, yy);
    }
    map<int64, int64> memo;
    int64 ans = 0;
    for(int64 ii = 0;ii < nn;ii++)
    {
		int64 tmp =tree.root(ii);
		memo[tmp]++;
	}
	for(int64 ii = 0;ii < nn;ii++)
	{
		ans = max(ans, memo[ii]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 22656
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d%d",&a,&b);
    if(a<b){
      printf("a < b\n");
    }
    if(a>b){
      printf("a > b\n");
    }
    if(a==b){
      printf("a == b\n");
}

    return 0;
}

Measured memory_bytes: 580
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner reader = new Scanner(System.in);
        String []d={"Sunny","Cloudy","Rainy"};
        String input=reader.next();
       switch(input){
           case  "Sunny":
               {
                   System.out.println("Cloudy");
                   break;
               }
           case  "Cloudy":
               {
                   System.out.println("Rainy");
                   break;
               }
           case  "Rainy":
               {
                   System.out.println("Sunny");
                   break;
               }
        
       }
    }}

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int a, b, c;
	cin >> a >> b >> c;
	if(a == b and a != c or a == c and a != b or b == c and a != b) cout << "Yes";
	else cout << "No";

	return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
#include "string.h"
#include "algorithm"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())


vector<pair<ll,int>> factorize(ll n) {
    vector<pair<ll,int>> res;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i != 0) continue;
        res.emplace_back(i,0);
        while (n % i == 0) {
            n /= i;
            res.back().second++;
        } 
    }
    if (n != 1) res.emplace_back(n,1);
    return res;
}

int main (){
  ll n;cin>>n;
  vector<pair<ll,int>> v=factorize(n);
  cout<<n<<':';
  REP(i,v.size()){
    REP(j,v[i].second){
      cout<<' '<<v[i].first;
    }
    
  }
  cout<<endl;
}


Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cmath>
#include<map>
#include<set>
using namespace std;
const int INF = 1 << 29;
const double EPS = 1e-9;

typedef long long ll;

#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

int N;
ll A[100001];
ll B[100001];
ll C[100001];
ll D[100001];
ll E[100001];
ll F[100001];

int main(int argc, char * argv[])
{
    ios::sync_with_stdio(false);
	cin >> N;
	rep(i,N) {
		cin >> A[i];
		B[i] = A[i];
		if (i%2==0) C[i/2] = A[i];
		else D[i/2] = A[i];
	}
	sort(B,B+N);
	sort(C,C+N/2+N%2);
	sort(D,D+N/2);
	ll cnt = 0;
	rep(i,N){
		if (i%2==0){
			if (!binary_search(C,C+N/2+N%2, B[i])) cnt++;
		}
		else{
			if (!binary_search(D,D+N/2,B[i])) cnt++;
		}

	}

	cout << cnt/2 << endl;

    return 0;
}




Measured memory_bytes: 2560
/// Code By t_bone_289
/// An Immature Programmer.... I'm still developing !!
/// 29/03/20
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 998244353
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll powmod(ll base, ll exp, ll MOD) {
    ll res = 1;
    while (exp > 0) {
        if (exp % 2 == 1) res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return (res % MOD);
}

ll mpow(ll base, ll exp) {
    ll res = 1;
    while (exp > 0) {
        if (exp % 2 == 1) res = (res * base);
        base = (base * base);
        exp /= 2;
    }
    return (res);
}

ll SUM = 3100;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    ll s;
    cin >> s;
    vector<ll> v(n + 1);
    for (ll i = 1; i <= n; i++) {
        cin >> v[i];
    }
    vector<vector<ll> > dp(n + 1, vector<ll>(SUM + 1, 0));
    ll ans = 0;
    for (ll i = 1; i <= n; i++) {
        dp[i][v[i]] = i;
        for (ll j = 0; j <= SUM; j++) {
            dp[i][j] = (dp[i][j] + dp[i - 1][j]) % M;
            if (j - v[i] >= 0) {
                dp[i][j] = (dp[i][j] + dp[i - 1][j - v[i]]) % M;
            }
        }
        ans = (ans + dp[i][s]) % M;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 73088
import sys

x =lambda:list(map(int,sys.stdin.readline().strip().split()))
n,m=x()
adjac = {i:[] for i in range(1,n+1)}

for _ in range(m):
    a,b = x()
    adjac[a].append(b)
    adjac[b].append(a)

comp = 0

visited = {i:False for i in range(1,n+1)}

for i in range(1,n+1):

    if not visited[i]:
        queue = [i]
        count=1
        visited[i] = True
        while len(queue)!=0:
            h=queue[0]
            queue.pop(0)
            arr = adjac[h]
            # print(arr,i)
            for j in arr:
                if not visited[j]:
                    # print(j,h)
                    visited[j]=True
                    queue.append(j)
                    count+=1
        comp=max(comp,count)
print(comp)

Measured memory_bytes: 84412
s = input()
ok = True
for i in range(len(s)):
    if i % 2 == 0 and s[i] == 'L':
        ok = False
        break
    elif i % 2 == 1 and s[i] == 'R':
        ok = False
        break

if ok:
    print("Yes")
else:
    print("No")    


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (int) 1e9+7
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define vi vector<int>
ll xpow(ll a, ll b)
{
	if (b == 0)
		return 1;
	if (b % 2 == 0)
	{
		ll k = xpow(a, b / 2);
		return k * k;
	}
	if (b % 2 != 0)
		return a * xpow(a, b - 1);
}
int main()
{

#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out1.txt", "w", stdout);
#endif
	fio;
	int a;
	cin >> a;
	cout << a + a*a + a*a*a << endl;
	return 0;
}

Measured memory_bytes: 3648
#include<cstdio>
#include<algorithm>
long long a[200005];
long long b[200005];

long long min(long long a,long long b){ return a>b?b:a; }

long long abs(long long u){ return u>0?u:-u; }

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++){
        scanf("%lld",&a[i]);
        b[i] = a[i]-(long long)i;
    }
    std::sort(b+1,b+1+n);
    long long cur = 0;
    for(int i = 1; i <= n; i++){
        cur += abs(a[i]-(b[1]+i));
    }
    long long ans = cur;
    for(int i = 2; i <= n; i++){
        ans = min(ans,cur);
        long long diff = b[i]-b[i-1];
        long long change = diff*(long long)(i-1-(n-i+1));
        cur += change;
        //printf("cur = %lld\n",cur);
    }
    ans = min(ans,cur);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4832
#include<bits/stdc++.h>
using namespace std;
char s[100010];
int main()
{
    scanf("%s",s);
    int len,cnt_0=0,cnt_1=0;
    len=strlen(s);
    for(int i=0;i<len;i++){
        if(s[i]=='0') cnt_0+=1;
        else cnt_1+=1;
    }
    int ans;
    ans=min(cnt_0,cnt_1);
    ans*=2;
    cout<<ans;
    return 0;
}


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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A=in();
    int B=in();
    if(A<10&&B<10){
        cout<<A*B<<endl;
    }else{
        cout<<-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 3584
#1にしなきゃいけない
from math import*

n,k=map(int,input().split())
a=list(map(int,input().split()))
#b=a.index(1)
#print(n,k,b)

#l=b
#r=n-b-1
print((n-1+k-1-1)//(k-1))


Measured memory_bytes: 13812
N=int(input())	
li = list(map(int,input().split()))	

flag = True

for i in range(N-1):
  if (li[i] - li[i+1]) >= 2:
    print('No')
    flag = False
    break
  if li[i] < li[i+1] and  (li[i] - li[i+1]) <= -1:
    li[i+1] -= 1
  if (li[i] - li[i+1]) >= 1:
    print('No')
    flag = False
    break

if flag:
  print('Yes')

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


int findSumOfDigits(int n)
{
	int sum = 0;
	while (n > 0)
	{
		sum += n % 10;
		n /= 10;
	}

	return sum;
}

int main()
{
	int N,A,B;
	cin >>N>>A>>B;
	int total = 0;
	
	for (int i = 1; i <= N; i++)
	{
		int sum = findSumOfDigits(i);
		if (sum >= A && sum <= B)
		{
			total += i;
		}
	}
			cout << total << endl;

}


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

typedef long long ll;
const ll InF = 1e15;

int main() {
 int n;
 cin>>n;
 vector<ll> a(n);
 for (int i = 0; i < n; i++) cin>>a[i];
 sort(a.begin(),a.end());
 vector<pair<ll,ll>> ps;
 int k = 0;
 for (int i = 0; i < n - 1; i++) {
   if (a[i] < 0 && a[i + 1] < 0) {
     ps.emplace_back(a[n - 1],a[i]);
     k++;
     a[n - 1] = a[n - 1] - a[i];
   } else break;
 }
 ll res = a[k];
 for (int i = k + 1; i < n; i++) {
   if (i == n - 1) {
     ps.emplace_back(a[i],res);
     res = a[i] - res;
   } else {
     ps.emplace_back(res,a[i]);
     res -= a[i];
   }                            
 }
 cout<<res<<endl;
 for (int i = 0; i < n - 1; i++) {
   cout<<ps[i].first<<" "<<ps[i].second<<endl;;
 }
 return 0;
}

Measured memory_bytes: 4336
def get_path(current, goal, edges, path)
  next_edges = edges.select{ |e| e[0,2].include?(current) }
  next_nodes = next_edges.map{ |e| e[0,2].select{|x| x!=current}.first }


  next_nodes.map do |n|
    if n == goal
      path + [n]
    elsif path.include?(n)
      nil
    else
      get_path(n, goal, edges, path + [n])
    end
  end
end

def cost_of_paths(start, goal, edges, edges_cost)
  paths = []
  i = 0

  get_path(start, goal, edges, [start]).flatten.each do |x|
    if x.nil?
      i += 1
      next
    elsif x == goal
      paths[i] << x
      i += 1
    elsif paths[i].nil?
      paths[i] = [x]
    else
      paths[i] << x
    end
  end

  a = paths.compact.map do |path|
    cost = 0
    path.each.with_index do |x,i|
      cost += edges_cost[[path[i], path[i+1]]] unless i == path.size-1
    end
    cost
  end
  a.min
end

n = gets.to_i
m = gets.to_i

edges = []
edges_cost = {}

m.times do
  a, b, c, d = gets.chomp.split(',').map(&:to_i)
  edges << [a, b, c, d]
  edges_cost[[a,b]] = c
  edges_cost[[b,a]] = d
end

start, goal, money, tree_cost = gets.chomp.split(',').map(&:to_i)

total_cost = cost_of_paths(start, goal, edges, edges_cost) + cost_of_paths(goal, start, edges, edges_cost) + tree_cost

p money - total_cost

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


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

    ll ans = 0;
    for(int i = 1; i < n; i++){
        for(int j = 1; i * j < n; j++){
            ll t = i * j;
            if(0 <= n - t) ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 2
#define pi 3.1415926535
using namespace std;
struct __INIT{
    __INIT(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout<<fixed<<setprecision(15);
    }
}__init;

//hh:mm:ss
ll strtobyo(string s){
    ll hh = (s[0]-'0')*10+s[1]-'0';
    ll mm = (s[3]-'0')*10+s[4]-'0';
    ll ss = (s[6]-'0')*10+s[7]-'0';
    return 60*60*hh+60*mm+ss;
}

int main(void){
    while(true){
        ll n;
        cin>>n;
        if(n == 0) break;
        vl imos(60*60*24+1,0);
        rep(i,n){
            string s,t;
            cin>>s>>t;
            ll times = strtobyo(s);
            ll timet = strtobyo(t);
            imos[times]++;
            imos[timet]--;
        }
        rep1(i,60*60*24+1) imos[i] += imos[i-1];
        ll maxi = *max_element(all(imos));
        cout<<maxi<<endl;
    }
}


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

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (i % 2 && s[i] == 'R' || i % 2 == 0 && s[i] == 'L') {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
'use strict'
function main(input) {
  let tmp = input.split('\n');
  let k = parseInt(tmp[0].split(' ')[1], 10);
  let stones = tmp[1].split(' ').map(element => parseInt(element, 10));

  let dp = Array(stones.length).fill(Infinity);
  dp[0] = 0;
  for (let i = 0; i < stones.length; i++) {
    for(let j = i + 1; j <= i + k; j++) {
      if (j < stones.length) {
      	dp[j] = Math.min(dp[j], dp[i] + Math.abs(stones[i] - stones[j]))
       }
    }
  }
   console.log(dp[stones.length - 1])
}




main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 27732
# coding: utf-8
N = input()
N = int(N)

ans = "No"
for A in range(1, 10):
    for B in range(1, 10):
        if( A*B == N ):
            ans = "Yes"
            break
        else:
            ans = "No"
    if( ans == "Yes" ):
        break
    
print( ans )


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>

using namespace std;
#define ll          long long
#define endl        "\n"
#define inf         10000000002
#define pb          push_back
#define pf          push_front
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(a)      a.begin(),a.end()
#define mp          make_pair
#define MAX         10000000
#define yes         cout<<"YES"<<endl
#define no          cout<<"NO"<<endl
#define bye         return 0

int main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      cout.tie(NULL);
      //freopen("inputNew.txt", "r", stdin);

      ll N;
      cin>>N;

      ll sum=0;
      for(ll i=1; i<=N; i++){
            for(ll j=i; j<=N; j+=i){
                  sum+=j;
            }
      }

      cout<<sum<<endl;

      bye;
}


Measured memory_bytes: 3596
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
ans=0
for i in range(n):
  j=bisect.bisect_left(a,b[i])
  k=n-bisect.bisect_right(c,b[i])
  ans+=j*k
print(ans)

Measured memory_bytes: 105572
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<queue>
#include<functional>
#include<limits.h>
#include<string.h>
#include<algorithm> 
using namespace std;

int x[108], y[108], h[108];
signed main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> h[i];
	}
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			int Q = 0;
			for (int k = 0; k < n; k++) {
				if (h[k]) {
					Q = h[k] + abs(x[k] - i) + abs(y[k] - j);
				}
			}
			for (int k = 0; k < n; k++) {
				if (max(0, Q - abs(x[k] - i) - abs(y[k] - j))!=h[k]) {
					break;
				}
				if (k + 1 == n) {
					cout << i << " " << j << " " << Q << endl;
				}
			}
		}
	}
}

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

int main()
{
    ll N;

    cin >> N;

    ll A[N];
    ll sum = 0;
    ll modulo = 1000000007;
    ll res = 0;

    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    for (int i = 0; i < N; i++)
    {
        sum += A[i];
        sum %= modulo;     //Die Summe begrenzen 
    }

    for (int j = 0; j < N; j++)
    {
        sum -= A[j];
        
        if (sum < 0 ) sum+=modulo; // When the first case of the table is 1000000008 then with % modulo it will 
                                  // be 1 instead of 1000000008 which will make the sum negative so in this case we have to add to the sum the amount that we lost which is 1000000007 


        res += A[j] * sum; // for sure when multiplying the 100000000 with a big numer it will stay supportable since we use long long int as a variable 

        res %= modulo;
    }

    cout << res;

    return 0;
}

Measured memory_bytes: 5184
import collections
n,m=map(int,input().split())
a = []
for i in range(n):
    b = list(map(int, input().split()))
    a.append(b)
c=[]
for i in range(n):
    c.extend(a[i][1:])
co=collections.Counter(c)
s=0
for i in range(m+1):
    if co[i]==n:
        s+=1
print(s)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;

int main(){
  int k;
  cin >> k;
  string s = "";
  rep(i, k) s += "ACL";
  cout << s << endl;
  
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
#include <map>
#include <queue>
#include <set>
#include <stack>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i, m, n) for (ll(i) = (ll)(m); i < (ll)(n); ++i)
#define rep2(i, m, n) for (ll(i) = (ll)(n)-1; i >= (ll)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using Edge = pair<int, long long>;
using Graph = vector<vector<Edge>>;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef vector<vector<vector<ll>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
// constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
template <class T> inline void print(T x) { cout << x << '\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;
}

long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }

vector<pair<long long, long long>> prime_factorize(long long N) {
    vector<pair<long long, long long>> res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}
bool is_prime(ll x) {
    if (x <= 1) return false;
    for (ll i = 2; i * i <= x; i++)
        if (x % i == 0) return false;
    return true;
}
// ~~~~~~~~~~~~~~memo~~~~~~~~~~~~~~
// for (int i = 0; i < n; ++i)
// v ector<long long> v(n), c(n);
// cout << res << endl;
// cout << res << '\n';
// int型の2次元配列(h×w要素の)の宣言
// vector<vector<int>> data(h, vector<int>(w));
// rotate(s.begin(), s.begin() + 1, s.end());
// sort(all(a),greater<int>());
// s.substr(0,2) 先頭から2文字切り出す
// for (auto it = mp.rbegin();it != mp.rend(); ++it)
// vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(w + 1, vector<int>(k+1, 0)));

// ll dp[1005][3] = {99999999};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    ll n = s.size();
    vec a(n + 1, 0), b(n + 1, 0);
    ll cnt = 0;
    rep(i, 0, n) {
        if (s[i] == '<') {
            cnt++;
        } else {
            cnt = 0;
        }
        a[i + 1] = cnt;
    }
    cnt = 0;
    for (ll i = n - 1; 0 <= i; --i) {
        if (s[i] == '>') {
            cnt++;
        } else {
            cnt = 0;
        }
        b[i] = cnt;
    }
    ll res = 0;
    rep(i, 0, n+1) {
        res += max(a[i],b[i]);
    }
    print(res);
    return 0;
}


Measured memory_bytes: 11672
# 参考: https://qiita.com/y-tsutsu/items/aa7e8e809d6ac167d6a1

import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache, reduce
from copy import deepcopy

# 多次元配列
# dp = [[0] * 3 for _ in range(5)]

# 入力を受け取る
N = int(input())
S, T = input().split()

ans = ""
for i in range(N):
    ans += S[i] + T[i]

print(ans)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int w,a,b;
    cin >> w >> a >> b;
    cout << max(a - b - w, max(b - a - w, 0)) << endl;
}

Measured memory_bytes: 764
var N,M,x,y,z,w,i:integer;
begin
 read(N,M);
 x:=0;y:=100000;
for i := 1 to M do
begin
 read(z,w);
 if x <= z then x:= z;
 if w <= y then y:= w;
 end;
 if y >= x then write(y-x+1) else write(0);
end.


Measured memory_bytes: 128
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++)
{
	cin>>a[i];
	
}
long long int sum=0;
 sort(a, a+n); 
for(int i=0;i<k;i++)
{
	sum+=a[i];
}
cout<<sum<<endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for (int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
typedef long long ll;

int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a[i];
  cout << *max_element(all(a)) - *min_element(all(a)) << endl;
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c == 17) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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


int main() {
    long long n;
    string s;
    long long a[]={0,0,0,0,0};
    cin >> n;
    for(int i=0; i<n; i++){
        cin>>s;
        if(s[0]=='M')a[0]++;
        else if(s[0]=='A')a[1]++;
        else if(s[0]=='R')a[2]++;
        else if(s[0]=='C')a[3]++;
        else if(s[0]=='H')a[4]++;
    }

    long long ans = a[0]*a[1]*a[2] + a[0]*a[1]*a[3] + a[0]*a[1]*a[4]
                    +a[0]*a[2]*a[3] + a[0]*a[2]*a[4] + a[0]*a[3]*a[4]
                    +a[1]*a[2]*a[3] + a[1]*a[2]*a[4] + a[1]*a[3]*a[4]
                    +a[2]*a[3]*a[4];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    int n = 0;
    int m = 0;

    String s = "NO";
    if (a == 5 && b == 5 && c == 7) {
      s = "YES";
    }
    if (a == 5 && b == 7 && c == 5) {
      s = "YES";
    }
    if (a == 7 && b == 5 && c == 5) {
      s = "YES";
    }
    
    System.out.println(s);
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define res register int
#define ll long long
#define N 100000
#define inf 0x3f3f3f3f
using namespace std;
int n,w,s,e;
char a[N];

inline bool check() 
{
    if(w&&e&&n&&s)return 1;
    if(w&&e&&!n&&!s)return 1;
    if(!w&&!e&&n&&s)return 1;
    if(!w&&!e&&!n&&!s)return 1;
    return 0;
}

int main()
{
	scanf("%s",a);
	for(res i=0;i<=strlen(a)-1;i++)
	if(a[i]=='N') n++;
	else if(a[i]=='S') s++;
	else if(a[i]=='E') e++;
	else w++;
    puts(check()?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256