akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) {}
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << endl; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18;
/***********************************************************************/

int32_t main() {
 
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
 
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &z: a) cin >> z;
  vector<int> ans(n), s;
  for (int i = n; i > 0; --i) {
    int cnt = 0;
    for (int j = i; j <= n; j += i) {
      cnt += ans[j - 1];
    }
    cnt &= 1;
    if (cnt != a[i - 1]) {
      ans[i - 1] = 1;
      s.push_back(i);
    }
  }
  cout << SZ(s) << '\n';
  for (int z: s) cout << z << ' ';
    
  return 0;
}


Measured memory_bytes: 3192
import java.util.Scanner;

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


		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long count = 0;
		long h = 100L;

		while(h < x) {
			h = (long)Math.floor(h * 1.01);
			count++;
		}

		System.out.println(count);

		sc.close();




	}
}


Measured memory_bytes: 35736
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> v2l;
typedef vector<bool> vb;
typedef vector<vb> v2b;

const ll AMAX = 1e13;

int dfs(vi e[], int x, int p, v2l &dp1, v2b &dp2) {
    int sz = 1;

    for (int y : e[x]) {
        if (y == p) {
            continue;
        }

        int ysz = dfs(e, y, x, dp1, dp2);
        dp1[x].resize(sz + ysz, AMAX);
        dp2[x].resize(sz + ysz, false);

        for (int i = sz - 1; i >= 0; i--) {
            for (int j = ysz - 1; j >= 0; j--) {
                if (j > 0) {
                    dp1[x][i+j] = min(dp1[x][i+j], dp1[x][i] + dp1[y][j]);
                    dp2[x][i+j] = dp2[x][i+j] || dp2[x][i] && dp2[y][j];
                }
                if (dp1[y][j] < 0 || dp2[y][j]) {
                    dp1[x][i+j+1] = min(dp1[x][i+j+1], dp1[x][i]);
                    dp2[x][i+j+1] = dp2[x][i+j+1] || dp2[x][i];
                }
            }
            dp1[x][i] = min(AMAX, dp1[x][i] + dp1[y][0]);
            dp2[x][i] = dp2[x][i] && dp2[y][0];
        }

        sz += ysz;
    }

    return sz;
}

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vi e[n];
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        e[u].push_back(v);
        e[v].push_back(u);
    }

    v2l dp1(n);
    for (int i = 0; i < n; i++) {
        dp1[i] = {a[i]};
    }

    v2b dp2(n);
    for (int i = 0; i < n; i++) {
        dp2[i] = {a[i] > 0};
    }

    dfs(e, 0, -1, dp1, dp2);

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (dp1[0][i] < 0 || dp2[0][i]) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 84608
open System

let S = stdin.ReadLine()

let rec f (s:String) i (ret: String) =
    if i = s.Length then ret
    elif s.[i] = '0' then f s (i + 1) (ret + "0")
    elif s.[i] = '1' then f s (i + 1) (ret + "1")
    elif s.[i] = 'B' then f s (i + 1) (if ret.Length > 0 then (ret.Substring(0, ret.Length - 1)) else ret)
    else ""
               
f S 0 "" |> printfn "%s"


Measured memory_bytes: 13916
#include<cstdio> 
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#define ms(i, j) memset(i, j, sizeof i)
#define LL long long
#define db double
#define fir first
#define sec second
#define mp make_pair
using namespace std;

namespace flyinthesky {

	int a[100000 + 5];

    void clean() {
    }
    int solve() {
    	
    	clean();
    	int n; cin >> n;
    	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    	int x = 0;
    	for (int i = 1; i <= n; ++i) x ^= a[i];
    	if (x == 0) puts("Yes"); else puts("No");
    
        return 0;
    }  
}
int main() {
    flyinthesky::solve();
    return 0;
}
/*
*/

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  if (A + B + C > 21) {
    cout << "bust" << std::endl;
  } else {
    cout << "win" << std::endl;
  }
  
  return 0;
}

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

using namespace std;

int main() {
    map<char, char> mp = {{'A', 'T'},
                          {'T', 'A'},
                          {'C', 'G'},
                          {'G', 'C'}};

    char ch;
    cin >> ch;
    cout << mp[ch] << endl;
    return 0;
}


Measured memory_bytes: 256
#ifndef ___Class_BIT
#define ___Class_BIT
#include <cstdlib>
#include <iostream>
template <class Type>
class BIT {
private:
	int size_; Type *v;
	inline Type sum(int r) { Type ret = 0; while (r > 0) ret += v[r], r -= r & -r; return ret; }
public:
	BIT() {};
	BIT(int size__) {
		for (size_ = 1; size_ < size__;) size_ <<= 1;
		v = (Type *)malloc(sizeof(Type) * (size_ + 4));
		for (int i = 0; i <= size_; i++) v[i] = 0;
	}
	inline void add(int i, Type x) { i++; while (i <= size_) v[i] += x, i += i & -i; }
	inline Type sum(int l, int r) { return sum(r) - sum(l); }
	bool operator[](size_t x) { return sum(x, x + 1); }
};
#endif

#include <cstdio>
#pragma warning(disable : 4996)
int n, q, c, x, y;
int main() {
	scanf("%d%d", &n, &q);
	BIT<int> b(n);
	for (int i = 0; i < q; i++) {
		scanf("%d%d%d", &c, &x, &y);
		if (!c) b.add(x - 1, y);
		else printf("%d\n", b.sum(x - 1, y));
	}
	return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  int n;
  cin >> n;
  cout << (n%2==0 ? n : 2*n) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    /* 変数宣言，ちゃんと初期化しよう */
    int N = 0;
    int ans = 0;
    
    /* 変数宣言終わり */
    
    /* 入力を受け付ける部分*/
    
    // %dはdecimalの略．つまり，入力を10進数として扱うよという意味．
    scanf("%d", &N);
    
    /* 入力を受け付ける部分終わり*/
    
    
    /* 何か処理*/
    if(N % 111  == 0){
        ans = N;
    }else{
        ans = N / 111 * 111 + 111;
    }
        
   
    
    for(int i = 0; i < 10; i++){ 
      // i = 0,1,2,3,4,5,6,7,8,9のとき処理される
      
    }
    
    /* 何か処理終わり*/
    
    
    /* 出力する部分*/
    
   printf("%d", ans) ; // %dの部分にansの値が表示される
    
    /* 出力する部分*/
    
    
    
    return 0;
}






Measured memory_bytes: 128
#include <stdio.h>

int edge[55];

int main(){

	int N, M;

	scanf("%d %d",&N,&M);

	int a, b;

	int i;

	for (i = 0; i < M; i++) {
		scanf("%d %d",&a,&b);
		edge[a]++;
		edge[b]++;
	}

	for (i = 1; i <= N; i++) {
		printf("%d\n",edge[i]);
	}

	return 0;
}

Measured memory_bytes: 128
//OPTIMIZATIONS
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
//#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//OPTIMIZATIONS
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long uu;
typedef long long int lll;
typedef unsigned long long int uuu;
using namespace std;

#define watch(x) cerr << "\n" \
                      << (#x) << " is " << (x) << endl
#define cel(x, y) 1 + ((x - 1) / y)
const double PI = 3.141592653589793238463;
const int MOD = 1000000007;
const long long int INF = 0x3f3f3f3f3f3f3f3f;

/*
$alil03

URL: url

Solution Begins here
*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lll x;
    cin >> x;
    if(x == 0)
        cout << 1;
    else
    {
        cout << 0;
    }      
}

Measured memory_bytes: 3612
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;
//const ll INF = 1e18;

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

ll cal_gcd(ll a, ll b) {
	ll m = max(a, b);
	ll n = min(a, b);
	while (m%n != 0) {
		ll b = m % n;
		m = n;
		n = b;
	}
	return n;
}

int main() {
	int k, a, b;
	cin >> k >> a >> b;
	bool ok = false;
	for (int i = 1; i*k <= b; i++) {
		if (a <= i * k&&b >= i * k) {
			ok = true;
			break;
		}
	}
	if (ok)cout << "OK" << endl;
	else cout << "NG" << endl;
	return 0;
}

Measured memory_bytes: 3592
using System;

namespace ALDS1_2_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int n = int.Parse(str);

            string[] strs = Console.ReadLine().Split(' ');
            int[] A = new int[n];
            for (int i = 0; i < n; ++i)
            {
                A[i] = int.Parse(strs[i]);
            }

            int count = 0;

            for (int i = 0; i < n; ++i)
            {
                int minj = i;
                for (int j = i; j < n; ++j)
                {
                    if (A[j] < A[minj])
                    {
                        minj = j;
                    }
                }
                if(i!=minj)
                {
                    count += 1;
                    int temp = A[i];
                    A[i] = A[minj];
                    A[minj] = temp;
                }
            }
            
            Output(A);
            Console.WriteLine("{0}", count);
        }

        static private void Output(int[] A)
        {
            for (int i = 0; i < A.Length; ++i)
            {
                Console.Write("{0}", A[i]);
                if (i < A.Length - 1)
                {
                    Console.Write(" ");
                }
                else
                {
                    Console.Write("\n");
                }
            }
        }
    }
}

Measured memory_bytes: 5624
# -*- coding: utf-8 -*-
K = int(input())
 
# lcm & gcd not math library
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
ans = 0
for i in range(1, K + 1):
    for j in range(1, K + 1):
        gcd_ij = gcd(i, j)
        for k in range(1, K + 1):
            ans += gcd(gcd_ij, k)

print(ans)

Measured memory_bytes: 9104
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

const LL MOD = 1e9 + 7;

LL dp[1005][1005] = {0};

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

    LL h,w;
    cin>>h>>w;

    VS s(h);
    REP(i,h){
        cin>>s[i];
    }

    dp[0][0] = 1;
    REP(i,h)REP(j,w){
        if(s[i][j] == '#')continue;

        dp[i][j+1] += dp[i][j];
        dp[i+1][j] += dp[i][j];
        dp[i][j+1] %= MOD;
        dp[i+1][j] %= MOD;
    }

    PUTS(dp[h-1][w-1]);
}

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

int main()
{
	std::ios::sync_with_stdio(false);
	
	cin>>n;
	ll a[n+1];
	ll prod=1;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]==0)
		{
			cout<<"0";
			return 0;
		}
	}
	
	for(ll i=1;i<=n;i++)
	{
	  if(a[i]<=1000000000000000000/prod)
	   prod*=a[i];
	  else
	  {
	  	cout<<"-1";
	  	return 0;
	  }
	}
	cout<<prod;
	 
	return 0;
}

Measured memory_bytes: 4372
#include <iostream>
#include <list>
#define ll long long
using namespace std;

int main() {
    ll a, b;
    char c;
    cin >> a >> b;
    list< list < char > > bigger;
    list<char> smaller;
    for(ll i = 0; i < a; i++) {
        for(ll j = 0; j < b; j++){
            cin >> c;
            smaller.push_back(c);
        }
        smaller.push_back('#');
        smaller.push_front('#');
        bigger.push_back(smaller);
        smaller.clear();
    }
    for(ll j = 0; j < b; j++){
        smaller.push_back('#');
    }
    smaller.push_back('#');
    smaller.push_front('#');
    bigger.push_front(smaller);
    bigger.push_back(smaller);
    for(auto i: bigger) {
        for(auto j:i) cout << j;
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 640
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())

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
n,m,k = mi()

nakama = [0] * n
d = UnionFind(n)
for i in range(m):
    a,b = mi()
    a -= 1
    b -= 1
    d.union(a,b)
    nakama[a] += 1
    nakama[b] += 1
teki =[[] for _ in range(n)]
for i in range(k):
    a,b = mi()
    a -= 1
    b -= 1
    teki[a].append(b)
    teki[b].append(a)
ans = [0] * n
for i in range(n):
    ans[i] = d.size(i) -1 -nakama[i]
    for j in teki[i]:
        if d.same(i,j):
            ans[i] -= 1
print(*ans)



Measured memory_bytes: 31860
#include<stdio.h>
int main()
{
  int n,y,sen,gosen,man;
  scanf("%d %d",&n,&y);
  for(sen=0;sen<=n;sen++){
    for(gosen=0;gosen<=n;gosen++){
      man=n-sen-gosen;
      if(sen*1000+gosen*5000+man*10000==y&&
         sen+gosen+man==n&&man>=0){        
  printf("%d %d %d",man,gosen,sen); return 0; }
    }    
  }
  printf("-1 -1 -1");
    return 0;
  }


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


int count(int n, int m) {
    int tail = m%10;
    if(tail==0) return 0;
    while(m>=10) m = m/10;
    int head = m;

    int enu[6];
    int keta = 1;
    for(int i=0; i<6; i++) {
        enu[i] = n%10;
        n = n/10;
        if(n!=0) keta++;
    }

    int ans = 0;
    if(head==tail) ans++;

    if(keta==1) return ans;
    if(keta==2) {
        if(tail<enu[1] || (tail==enu[1] && head<=enu[0])) ans++;
        return ans;
    }
    if(keta==3) {
        ans++;
        if(tail<enu[2]) ans+=10;
        else if(tail==enu[2]) {
            if(head>enu[0]) ans+=enu[1];
            else ans+=enu[1]+1;
        }
        return ans;
    }
    if(keta==4) {
        ans += 11;
        if(tail<enu[3]) ans+=100;
        else if(tail==enu[3]) {
            if(head>enu[0]) ans+=enu[2]*10+enu[1];
            else ans+=enu[2]*10+enu[1]+1;
        }
        return ans;
    }
    if(keta==5) {
        ans += 111;
        if(tail<enu[4]) ans+=1000;
        else if(tail==enu[4]) {
            if(head>enu[0]) ans += enu[3]*100+enu[2]*10+enu[1];
            else ans += enu[3]*100+enu[2]*10+enu[1]+1;
        }
        return ans;
    }
    if(keta==6) {
        ans += 1111;
        if(tail<enu[5]) ans+=10000;
        else if(tail==enu[5]) {
            if(head>enu[0]) ans += enu[4]*1000+enu[3]*100+enu[2]*10+enu[1];
            else ans += enu[4]*1000+enu[3]*100+enu[2]*10+enu[1]+1;
        }
        return ans;
    }
    return 0;
}

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

    int answer = 0;
    for(int m=1; m<=n; m++) {
        answer += count(n, m);
    }

    cout<<answer<<endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define INF (ll)2e9
#define MOD ((ll)1e9+7)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define bit(n) (1LL<<(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;
}

template<class InputIterator>
InputIterator adv(InputIterator x, typename std::iterator_traits<InputIterator>::difference_type n) {
    advance(x, n);
    return x;
}

class mod {
    static ll fact[];
public:

    template<class... A>
    static ll mul(A... args) {
        ll res = 1;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = (res * i) % MOD;
        }
        return res;
    }

    static ll power(ll base, ll exp) {
        if (exp == 0) return 1;
        if (exp & 1) {
            return mul(base, power(base, exp - 1));
        } else {
            ll p = power(base, exp / 2);
            return mul(p, p);
        }
    }

    static ll factorial(int n) {
        if (fact[n] != 0) return fact[n];
        if (n == 0) return 1;
        return fact[n] = mul(n, factorial(n - 1));
    }

    static ll inverse(int n) {
        return power(n, MOD - 2);
    }

    static ll comb(int n, int r) {
        if (r < 0 || r > n) return 0;
        return mul(factorial(n), inverse(factorial(n - r)), inverse(factorial(r)));
    }

    template<class... A>
    static ll div(ll dividend, A... args) {
        ll res = dividend;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = mul(res, inverse(i));
        }
        return res;
    }

    template<class... A>
    static ll add(A... args) {
        ll res = 0;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = (res * i) % MOD;
        }
        return res;
    }

    template<class... A>
    static ll sub(ll l, A... args) {
        ll res = l;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = (res - i + MOD) % MOD;
        }
        return res;
    }
};

ll mod::fact[(int) 1e6 + 1];

int ni() {
    int i;
    cin >> i;
    return i;
}

ll nll() {
    ll l;
    cin >> l;
    return l;
}

int main() {
    string s;
    cin >> s;
    int N = s.length();
    vector<int> vec[26];
    REP(i, N) {
        vec[s[i]-'a'].push_back(i);
    }
    REP(c, 26) {
        FOR(i, 1, SZ(vec[c])) {
            if (vec[c][i] - vec[c][i-1] <= 2) {
                cout << vec[c][i-1]+1 << " " << vec[c][i]+1 << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1" << endl;
    return 0;
}

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

#define endl '\n'

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(15);
}
deque<int> p ;
long long N ; 
void solve(long long N){
    if(N == 0){
        return ;
    }
    if(N%2ll == 0){
        solve(N - 1) ;
        int k = p.size() ;
        p.push_front(k+1) ;
        // cout << "pushback " << (k+1) << endl ;
    }
    else{
        solve( (N - 1)/2ll) ;
        int k = p.size() ;
        p.push_back(k+1) ;
        // cout << "pushfront " << (k+1) << endl ;
    }
    // cout << "@ N = " << N << endl ;
}
vector<int> ans ;
int main(int argc,char* argv[]) { 
    io() ;
    #ifndef ONLINE_JUDGE
      //  freopen("inp.txt", "r", stdin) ;
        // freopen("out.txt", "w", stdout);
    #endif
    cin >> N ;
    solve(N)  ;
    while(!p.empty()){
        int f = p.front() ;
        p.pop_front() ;
        ans.push_back(f) ;
    }
    int sz = 2*ans.size() ;
    cout << sz << endl ;
    for(auto x:ans) cout << x << " " ;
    for(int i = 1 ; i <= ans.size() ; i++) cout << i << " " ;

    return 0 ; 
}

Measured memory_bytes: 256
import bisect
import os
import sys
from collections import deque

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(N)]

seq = deque()
for a in A:
    i = bisect.bisect_left(seq, a)
    if i == 0:
        seq.appendleft(a)
    else:
        seq[i - 1] = a
        while i < len(seq) and seq[i - 1] > seq[i]:
            seq[i], seq[i - 1] = seq[i - 1], seq[i]
            i += 1
print(len(seq))


Measured memory_bytes: 8068
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
using namespace std;
int x[900][900], H, W, K, sx, sy, dist[900][900];
int main() {
	cin >> H >> W >> K;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			char c; cin >> c;
			if (c == 'S') { sx = i; sy = j; }
			if (c == '#') { x[i][j] = 1; }
		}
	}
	for (int i = 0; i < 900; i++) { for (int j = 0; j < 900; j++)dist[i][j] = 999999; }
	queue<pair<int, int>>Q; Q.push(make_pair(sx, sy)); dist[sx][sy] = 0;
	while (!Q.empty()) {
		int a1 = Q.front().first, a2 = Q.front().second; Q.pop();
		int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
		for (int i = 0; i < 4; i++) {
			int cx = a1 + dx[i], cy = a2 + dy[i];
			if (cx <= 0 || cy <= 0 || cx > H || cy > W || x[cx][cy] == 1)continue;
			if (dist[cx][cy] > dist[a1][a2] + 1) { Q.push(make_pair(cx, cy)); dist[cx][cy] = dist[a1][a2] + 1; }
		}
	}
	int minx = 999999;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (dist[i][j] <= K) {
				int I = min({ i - 1,j - 1,H - i,W - j }); I = (I + K - 1) / K;
				minx = min(minx, I + 1);
				if (dist[i][j] == 0 && I == 0) { minx = min(minx, 0); }
			}
		}
	}
	cout << minx << endl;
	return 0;
}

Measured memory_bytes: 6400
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  vector<int> x(3);
  for(int i=0;i<x.size();++i) cin >> x[i];
  int k;
  cin >> k;
  sort(x.rbegin(),x.rend());
  for(int i=0;i<k;++i){
    x[0]*=2;
  }
  auto sum = 0;
  for(auto i:x) sum+=i;
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

MOD = pow(10, 9) + 7

dp = [[0 for i in range(K+1)] for j in range(N+1)]
dp[0][0] = 1

for i in range(N):
    S = [0] * (K+1)
    S[0] = dp[i][0]
    # 累積和
    for j in range(1, K+1):
        S[j] = (dp[i][j] + S[j - 1]) % MOD

    for j in range(K+1):
        if j-1 >= A[i]:
            dp[i+1][j] = (S[j] - S[j-1-A[i]]) % MOD
        else:
            dp[i+1][j] = S[j]

print(dp[N][K])


Measured memory_bytes: 171400
#include <iostream>
#include <cmath>

int main()
{
	int a, b, C;
	std::cin >> a >> b >> C;
	long double S = 0.5 * a * b * sin(C * M_PI / 180);
	long double L = a + b + sqrt(a*a + b*b - 2.0 * a * b * cos(C * M_PI / 180));
	long double h = b * sin(C * M_PI / 180);
	
	std::cout << std::fixed << S << std::endl << L << std::endl << h << std::endl;
		
	return 0;
}




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

int main()
{
	const int s[24][3] = { {1, 2, 3}, {1, 3, 5}, {1, 5, 4}, {1, 4, 2},
				{2, 1, 4}, {2, 4, 6}, {2, 6, 3}, {2, 3, 1},
				{3, 1, 2}, {3, 2, 6}, {3, 6, 5}, {3, 5, 1},
				{4, 1, 5}, {4, 5, 6}, {4, 6, 2}, {4, 2, 1},
				{5, 1, 3}, {5, 3, 6}, {5, 6, 4}, {5, 4, 1},
				{6, 2, 4}, {6, 4, 5}, {6, 5, 3}, {6, 3, 2} };
	
	int a[6] = { 0 }, b[6] = { 0 }, n = 0;

	for (int i = 0; i < 6; i++)
		cin >> a[i];

	for (int i = 0; i < 6; i++)
		cin >> b[i];

	for (int i = 0; i < 24; i++) {
		if (a[0] == b[s[i][0] - 1]) {
			if (a[1] == b[s[i][1] - 1]) {
				if (a[2] == b[s[i][2] - 1]) {
					if (a[3] == b[6 - s[i][2]]) {
						if (a[4] == b[6 - s[i][1]]) {
							if (a[5] == b[6 - s[i][0]]) {
								n = 1;
							}
						}
					}
				}
			}
		}
	}

	if(n == 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int arr[n];
    int ind = 0;
    while(ind < n)
        cin >> arr[ind++];
    int op1 = 0;
    vector<int> arr2;
    for (int i = 0; i < n; ++i)
        arr2.push_back(arr[i]);
    sort(arr2.begin(), arr2.end());
    for (int i = 0; i < n; ++i) {
        auto bs = lower_bound(arr2.begin(), arr2.end(), arr[i]);

        int x = (bs - arr2.begin());
        if (i % 2 != x % 2)
            op1++;
    }
    cout << op1/2 << "\n";
}

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

typedef long long ll;

main()
{
    int n, sum = 0;
    cin >> n;
    int arr[n];
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    sort(arr, arr+n);
    for(int i = 0; i < n-1; i++){
        sum = sum + arr[i];
    }
    if(arr[n-1] < sum){
        cout << "Yes";
    }
    else{
        cout << "No";
    }

}





///promy_pompom
//hello world


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

int main() {
	int ans = 0;
	int N,Y;
	cin >> N >> Y;

	for (int i = 0; i < N+1; ++i){
		for (int j = 0; j < N+1; ++j){
			int k = Y - i*10000 - j* 5000;
			if (k >= 0 and i + j + k/1000 == N){
				cout << i << " " << j<< " " << k/1000 << endl;
				ans++;
				return 0;
			}
		}
	}
	if (ans == 0){
		cout << -1 << " " << -1 << " " << -1 << endl;
		return 0;
	}
}	

Measured memory_bytes: 256
from sys import stdin
from copy import deepcopy
from functools import reduce
from fractions import gcd
import math
import itertools
from collections import Counter
from itertools import chain  ##list(chain.from_iterable(l)) ##flatten
from heapq import heappush, heappop
import bisect

"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) ## 横一列
A = [int(input()) for _ in range(N)] ## 縦一列
lst = [list(map(int,input().split())) for i in range(M)] ## 二次元
"""

N = int(input())
A = list(map(int,input().split())) ## 横一列

A.sort(reverse=True)

LIMIT = int(1e18)

if 0 in A:
  print(0)
  exit()

ans = 1
for i in range(N):
  ans = ans * A[i]
  if ans > LIMIT:
    ans = -1
    break

print(ans)

Measured memory_bytes: 88184
n, m = map(int, input().split())
h = list(map(int,input().split()))
x = [0 for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    x[a-1] = max(x[a-1], h[b-1])
    x[b-1] = max(x[b-1], h[a-1])

ans = 0
for i in range(n):
    if h[i] > x[i]:
        ans += 1

print(ans)

Measured memory_bytes: 20108
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
const string mas[10][10] = { /*気合い！！ n < 10 だし！*/
  {"  1"},
  {"  1  2",
   "  3  4"},
  {"  1  2  6",
   "  3  5  7",
   "  4  8  9"},
  {"  1  2  6  7",
   "  3  5  8 13",
   "  4  9 12 14",
   " 10 11 15 16"},
  {"  1  2  6  7 15",
   "  3  5  8 14 16",
   "  4  9 13 17 22",
   " 10 12 18 21 23",
   " 11 19 20 24 25"},
  {"  1  2  6  7 15 16",
   "  3  5  8 14 17 26",
   "  4  9 13 18 25 27",
   " 10 12 19 24 28 33",
   " 11 20 23 29 32 34",
   " 21 22 30 31 35 36"},
  {"  1  2  6  7 15 16 28",
   "  3  5  8 14 17 27 29",
   "  4  9 13 18 26 30 39",
   " 10 12 19 25 31 38 40",
   " 11 20 24 32 37 41 46",
   " 21 23 33 36 42 45 47",
   " 22 34 35 43 44 48 49"},
  {"  1  2  6  7 15 16 28 29",
   "  3  5  8 14 17 27 30 43",
   "  4  9 13 18 26 31 42 44",
   " 10 12 19 25 32 41 45 54",
   " 11 20 24 33 40 46 53 55",
   " 21 23 34 39 47 52 56 61",
   " 22 35 38 48 51 57 60 62",
   " 36 37 49 50 58 59 63 64"},
  {"  1  2  6  7 15 16 28 29 45",
   "  3  5  8 14 17 27 30 44 46",
   "  4  9 13 18 26 31 43 47 60",
   " 10 12 19 25 32 42 48 59 61",
   " 11 20 24 33 41 49 58 62 71",
   " 21 23 34 40 50 57 63 70 72",
   " 22 35 39 51 56 64 69 73 78",
   " 36 38 52 55 65 68 74 77 79",
   " 37 53 54 66 67 75 76 80 81"},
};

int main(){
  int n;

  int q = 1;
  while(cin >> n, n){
    cout << "Case " << q++ << ":" << endl;
    for(int i = 0; i < n; i++){
      cout << mas[n - 1][i] << endl;
    }
  }
}

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

using namespace std;

#define ll long long

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

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

	vector < ll > sortedA(A);

	sort(sortedA.begin(), sortedA.end(), greater < ll > ());

	for (int i = 0; i < N; i++) {
		if (A[i] == sortedA[0]) {
			cout << sortedA[1] << endl;
		} else {
			cout << sortedA[0] << endl;
		}
	}

	return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}


int main() {
    int N; cin >> N;
    vector<int> a(N); REP(i, N) cin >> a[i];

    int red = 0;
    map<string, int> m;

    REP(i, N) {
        if(1 <= a[i] && a[i] <= 399) {
            m["灰"]++;
        } else if(400 <= a[i] && a[i] <= 799) {
            m["茶"]++;
        } else if(800 <= a[i] && a[i] <= 1199) {
            m["緑"]++;
        } else if(1200 <= a[i] && a[i] <= 1599) {
            m["水"]++;
        } else if(1600 <= a[i] && a[i] <= 1999) {
            m["青"]++;
        } else if(2000 <= a[i] && a[i] <= 2399) {
            m["黄"]++;
        } else if(2400 <= a[i] && a[i] <= 2799) {
            m["橙"]++;
        } else if(2800 <= a[i] && a[i] <= 3199) {
            m["赤"]++;
        } else {
            red++;
        }
    }

    int cnt = 0;
    for(auto itr = m.begin(); itr != m.end(); ++itr) {
        int i = itr->second;
        if(i > 0) cnt++;
    }

    if(8 - cnt < red) {
        cout << cnt << " " << red + cnt << endl;
    } else if(cnt == 0) {
        cout << 1 << " " << red << endl;
    } else {
        cout << cnt << " " << red + cnt << endl;
    }
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias pred)(int n) {
    foreach(i; 0..n) pred();
}
auto rep(alias pred, T = typeof(pred()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = pred();
    return res;
}

void main() {
  int H, W;
  readf("%d %d\n", &H, &W);
  string[][] ary = H.rep!(() => readln.split);
  foreach(i; 0..H) foreach(j; 0..W) {
    if (ary[i][j] == "snuke") {
      writeln(('A'+j).to!char, i+1);
    }
  }
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int Sum(const string&s){
  int n = (int)s.size();
  int sum = 0;
  for(int i = 0; i < n; ++i)sum += s[i] - '0';
  return sum;
}

int main(){
  char c; cin >> c;
  bool f = c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o';
  cout << (f ? "vowel" : "consonant") << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn = 1010;
int n;
LL x[maxn],y[maxn],u[maxn],v[maxn],bs[35];

LL power_int(int a, int b) {
  LL x = 1;
  while (b > 0) {x *= a;b--;}
  return x;
}

void work() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i];

  LL parity = (x[0] + y[0]) % 2;

  for (int i = 0; i < n; i++) if ((x[i] + y[i] - parity) % 2 != 0) {cout<<"-1"<<endl;return;}

    if (parity == 0) {
      cout << 32 << endl;
      for (int i = 30; i > -1; i--) {
        cout << power_int(2, i) << " ";
      }
      cout << 1 << endl;
      for (int i = 0; i < n; i++) {
        x[i]++;
      }
    }
    else {
      cout << 31 << endl;
      for (int i = 30; i > -1; i--) {
        cout << power_int(2, i) << " ";
      }
      cout << endl;
    }

    for (int i = 0; i < n; i++) {
      u[i] = x[i] + y[i];
      v[i] = x[i] - y[i];
    }

    for (int i = 0; i < n; i++) {
      for (int j = 30; j > -1; j--) {
        if (u[i] > 0 && v[i] > 0) {
          cout << 'R';
          u[i] -= power_int(2, j);
          v[i] -= power_int(2, j);
        }
        else if (u[i] > 0 && v[i] < 0) {
          cout << 'U';
          u[i] -= power_int(2, j);
          v[i] += power_int(2, j);
        }
        else if (u[i] < 0 && v[i] > 0) {
          cout << 'D';
          u[i] += power_int(2, j);
          v[i] -= power_int(2, j);
        }
        else {
          cout << 'L';
          u[i] += power_int(2, j);
          v[i] += power_int(2, j);
        }
      }
      if (parity == 0) cout << 'L';
      cout << endl;
    }
}
int main(){
    work();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 200000;
int N;
ll A[Nmax];

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

	for(int i=1; i<N; i++) A[i] += A[i-1];

	ll ans = 1e18;
	for(int i=0; i<N-1; i++){
		ans = min(ans, abs(A[i]-(A[N-1]-A[i])));
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int a1,a2,a3;
	cin>>a1>>a2>>a3;
	if(a1+a2+a3>=22){
		cout<<"bust"<<endl;
	}
	else{
		cout<<"win"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	scn := newScanner()
	W := scn.nextInt()
	H := scn.nextInt()
	p := make([]int, W)
	q := make([]int, H)
	for i := 0; i < W; i++ {
		p[i] = scn.nextInt()
	}
	for i := 0; i < H; i++ {
		q[i] = scn.nextInt()
	}
	sort.Ints(p)
	sort.Ints(q)
	var i, j, ans int
	for i < H || j < W {
		if i == H {
			ans += p[j]
			j++
		} else if j == W {
			ans += q[i]
			i++
		} else {
			if q[i] < p[j] {
				ans += (W - j + 1) * q[i]
				i++
			} else {
				ans += (H - i + 1) * p[j]
				j++
			}
		}
	}
	fmt.Println(ans)
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) nextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) nextInt() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) nextInt64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

bool custom(pair<int, int> a, pair<int, int> b){
  return a.second > b.second;
}
int main(){
  int n, m;
  cin >> n >> m;
  vector<int> card(n);
  for(int i = 0; i < n; ++i) cin >> card[i];
  sort(card.begin(), card.end());
  vector<pair<int, int>> xy(m);
  for(int i = 0; i < m; ++i) cin >> xy[i].first >> xy[i].second;
  sort(xy.begin(), xy.end(), custom);
  int index = 0;
  int j;
  bool flag = true;
  for(int i = 0; i < m; ++i){
    for(j = index; j < index + xy[i].first && j < n; ++j){
      if(card[j] > xy[i].second){
        flag = false;
        break;
      }
      card[j] = xy[i].second;
    }
    if(!flag) break;
    index = j;
  }
  long long sum = 0;
  for(auto a: card) sum += a;
  cout << sum << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime> 
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int N = 2e5 + 7;

int used[N];
vector<int> g[N];

void dfs(int cur, int &c) {
	c++;
	used[cur] = 1;
	for (auto t : g[cur]) {
		if (!used[t]) {
			dfs(t, c);
		}
	}
}

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

	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (!used[i]) {
			int c = 0;
			dfs(i, c);
			ans = max(ans, c);
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 20968
from collections import defaultdict


n, m = map(int, input().split())

edges = defaultdict(list)

for i in range(m):
    l, r, d = map(int, input().split())
    edges[l-1].append([r-1, d])
    edges[r-1].append([l-1, -d])

seen = [float('INF')] * n

for start in range(n):
    if seen[start] != float('INF'):
        continue

    seen[start] = 0
    todo = []
    while edges[start]:
        to, dist = edges[start].pop()
        seen[to] = dist
        todo.append([to, dist])

    while todo:
        node, dist = todo.pop()

        while edges[node]:
            to, add_dis = edges[node].pop()

            if seen[to] == float('INF') or seen[to] == dist+add_dis:
                seen[to] = dist + add_dis
                todo.append([to, dist+add_dis])

            else:
                print('No')
                exit()

print('Yes')

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


int n;
int a[1005][2];
int sum;



int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i][1];
		cin>>a[i][2];
	}
for(int i=1;i<=n;i++){
		sum=sum+a[i][2]-(a[i][1]-1);
		

	}
	cout<<sum;	
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N, K;
    cin >> N >> K;

    string S;
    cin >> S;
    
    int cntOK = 0;
    if(S[0] == 'L'){
        bool flagL = true;
        int cntRB = 0; 
        for(int i = 1; i < N; i++){
            if(S[i] == 'L' && flagL){
                flagL = true;
            }
            
            else if(S[i] == 'L' && !flagL){
                flagL = true;
                cntRB++;
            }
            else if(S[i] =='R'){
                flagL = false;
            }

            if(S[i] == S[i-1]) cntOK++;
        }

        if(K <= cntRB) cntOK += 2*K;
        else cntOK = N-1;

    } else {
        bool flagR = false;
        int cntLB = 0; 
        for(int i = 1; i < N; i++){
            if(S[i] == 'R' && flagR){
                flagR = true;
            }
            
            else if(S[i] == 'R' && !flagR){
                flagR = true;
                cntLB++;
            }
            else if(S[i] =='L'){
                flagR = false;
            }

            if(S[i] == S[i-1]) cntOK++;
        }

        if(K <= cntLB) cntOK += 2*K;
        else cntOK = N-1;
    }
    cout << cntOK << endl;

    return 0;
}


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

int main(){
    int a[3];
    int max = 0;
    int min = 1000;
    for(int i = 0; i < 3; i++){
        cin >> a[i];
    }

    int k  = 0;

    for(int i = 0; i < 3; i++){
        if(max < a[i]){
            max = a[i];
            k = i;
        }
    }

    for(int i = 0; i < 3; i++){
        if(min > a[i] && k != i){
            min = a[i];
        }
    }

    cout << max - min << endl;
}

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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  uint64_t g = gcd(m,n);
  if(m%g==0) return (m/g)*n;
  if(n%g==0) return (n/g)*m;
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

/* 
  //エラトステネスのふるい
  int maxNum = 100000;
  char isNotPrime[maxNum+1] = {};
  isNotPrime[0]=isNotPrime[1]=1;
  for(int i=2;i<maxNum;i++){
    if(isNotPrime[i]==1) continue;
    int num = i+i;
    while(num<=maxNum){
      isNotPrime[num]=1;
      num += i;
    }
  }
*/
// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

// 降順ソート vector<int> v;
// sort(v.begin(),v.end(),greater<int>());

signed main() {
  ll n,a,b;
  cin >> n >> a >> b;
  
  ll prevX = -1;
  ll x;
  ll cost = 0;
  for(int i=0;i<n;i++){
    cin >> x;
    if(prevX<0){
      prevX = x;
      continue;
    }
    if((x-prevX)*a>b){
      cost += b;
    }
    else{
      cost += (x-prevX)*a;
    }
    prevX = x;
  }

  cout << cost << endl;
  return 0;
}



Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define M 1000000007

using namespace std;
typedef long long int ll;


int main()
{

 ll val;
 cin>>val;
 ll start = 100;
 ll year=0;
 while(start<val)
    {
        year++;
        start = start + start*.01;

    }
    cout<<year<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define lout cout
#else
stringstream devnull;
#define lout devnull
#endif
template <class C>
inline void vcin(C &a);
template <class C>
inline void vcout(const C a, const string separate = "\n");

int main()
{
  while (true)
  {
    int n;
    cin >> n;
    if (n == 0)
    {
      break;
    }
    vector<int> s(n);
    vcin(s);
    sort(s.begin(), s.end());
    s.erase(s.begin());
    s.pop_back();
    cout << accumulate(s.begin(), s.end(), 0) / s.size() << endl;
  }
  return 0;
}

template <class C>
inline void vcin(C &c)
{
  for (auto &a : c)
  {
    cin >> a;
  }
}
template <class C>
inline void vcout(const C c, const string separate)
{
  for (auto it = c.begin(); it != c.end(); it++)
  {
    if (it != c.begin())
      cout << separate;
    cout << *it;
  }
}



Measured memory_bytes: 3160