akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;

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


Measured memory_bytes: 256
Module _20190423

    Sub Main()

        Dim iCount As Integer = Console.ReadLine()

        Dim sValue() As Integer

        For i As Integer = 0 To iCount - 1

            ReDim Preserve sValue(i)

            sValue(i) = Console.ReadLine()

        Next

        '値段の降順に並び替えるバブルソート
        For j As Integer = 0 To iCount - 1

            For k As Integer = iCount - 1 To j + 1 Step -1

                If CInt(sValue(k)) > CInt(sValue(k - 1)) Then

                    Dim iTemp As Integer = sValue(k)
                    sValue(k) = sValue(k - 1)
                    sValue(k - 1) = iTemp

                End If

            Next

        Next

        Dim iOtherTotal As Integer
        For l As Integer = 1 To iCount - 1

            iOtherTotal = iOtherTotal + sValue(l)

        Next

        Console.WriteLine(CInt(sValue(0) / 2) + iOtherTotal)

    End Sub

End Module


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

int main()
{
	int w,h;
	int x,y;
	int r;
	int s;
	cin >> w >> h;
	cin >> x >> y;
	cin >> r;

	if(w >= x+r && h >= y+r && x+r>0 && y+r >0)
	{
		cout << "Yes" << endl;
 	}

 	else
 	{
 		cout << "No" << endl;
 	}

 	return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
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;
}
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << "\n"; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " <<to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int n,m,a,b,c;
string s,t;

void solve(){
  cin>>a>>b;
  if(a==b)cout<<"Yes\n";
  else cout<<"No\n";
}
 
int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll MOD = 1e9+7;
ll H, N, M, L, K, W, X, Y, Z;
ll ans = 0;
int main() {
	cin >> N;
	vector<int>div(N+1, 0);
	for (int i = 2; i <= N; i++) {
		int n = i;
		for (int j = 2; j<=i; j++) {
			while (n%j == 0) {
				n /= j;
				div[j]++;
			}
		}
	}
	for (int i = 2; i <= N; i++) {
		if (div[i] >= 24) {
			for (int j = 2; j <= N; j++) {
				if (j == i)continue;
				if (div[j] >= 2)ans++;
			}
		}
		if (div[i] >= 14) {
			for (int j = 2; j <= N; j++) {
				if (j == i)continue;
				if (div[j] >= 4)ans++;
			}
		}
		if (div[i] >= 2) {
			for (int j = 2; j <= N; j++) {
				if (j == i)continue;
				if (div[j] >= 4) {
					for (int k = j + 1; k <= N; k++) {
						if (k == i)continue;
						if (div[k] >= 4)ans++;
					}
				}
			}
		}
		if (div[i] >= 74) {
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n;
  cin>>n;
  pair<int,int> data[n];
  for(int i=0;i<n;i++)
    {
      data[i]=make_pair(0,i+1);
    }
  for(int i=0;i<n*(n-1)/2;i++)
    {
      int a,b,c,d;
      cin>>a>>b>>c>>d;
      a--;
      b--;
      if(c>d)
	data[a].first+=3;
      else if(c<d)
	data[b].first+=3;
      else
	{
	  data[a].first+=1;
	  data[b].first+=1;
	}
    }
  sort(data,data+n,greater<pair<int,int> >());

  int rank=1;
  int tmp;
  int ans[n];
  for(int i=1;i<=n;i++)
    {
      if(tmp!=data[i-1].first)
	rank=i;
      tmp=data[i-1].first;
      
      ans[data[i-1].second-1]=rank;
    }
  for(int i=0;i<n;i++)
    {
      cout<<ans[i]<<endl;
    }

}

Measured memory_bytes: 1164
using System.Collections.Generic;
using static System.Console;

class Program {
    static void Main() {
        var N = NextInt();
        var T = NextInt();
        var ans = int.MaxValue;

        for (var i = 0; i < N; i++) {
            var c = NextInt();
            var t = NextInt();

            if (t <= T && ans > c) {
                ans = c;
            }
        }
        if (ans != int.MaxValue) {
            WriteLine(ans);
        } else {
            WriteLine("TLE");
        }
    }

    static int NextInt() {
        return int.Parse(NextString());
    }

    static string NextString() {
        var result = new List<char>();
        while (true) {
            int next = Read();
            if (next < 0)
                break;
            var nextChar = (char)next;
            if (!char.IsWhiteSpace(nextChar))
                result.Add(nextChar);
            else if (nextChar != '\r')
                break;
        }
        return string.Join("", result);
    }
}

Measured memory_bytes: 13268
#include<stdio.h>
int main(){
  int A[100],N,i,j,k,l,temp,count=0,minj;
  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d",&A[i]);

  /*selection sort 0-origin*/
  for(j=0;j<N-1;j++){
    minj=j;
    for(k=j;k<N;k++){
      if(A[k]<A[minj]) minj=k;
    }
    temp=A[j];
    A[j]=A[minj];
    A[minj]=temp;
    if(j!=minj) count++;
  }
  for(l=0;l<N-1;l++)printf("%d ",A[l]); printf("%d",A[N-1]);
  printf("\n%d\n",count);
  return 0;
}



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

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using PL = pair<ll,ll>;


int main()
{
	string s; ll t; cin >> s >> t;
	for(auto &i : s) i -= '0';
	ll n = s.size();
	vector<vector<vector<ll>>> dp(n + 1, vector<vector<ll>>(120, vector<ll>(2)));
	dp[0][0][0] = 1;

	for(ll i = 0; i < n; i++) {
		for(ll j = 0; j < 110; j++) {
			for(ll k = 0; k < 2; k++) {

				for(ll d = 0; d <= (k ? 9 : s[i]); d++) {
					dp[i + 1][j + (d != 0)][k || d < s[i]] += dp[i][j][k];
				}

			}
		}
	}
	cout << dp[n][t][0] + dp[n][t][1] << endl;

}

Measured memory_bytes: 896
N = int(input())
count = 0
values = []
def dfs(s):
    if s != '':
        if int(s) > N:
            return None
    values.append(s)
    dfs(s+'3')
    dfs(s+'5')
    dfs(s+'7')
dfs('')
for e in values:
    if '3' in e and '5' in e and '7' in e:
        count += 1
print(count)


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

ll modpow(ll x, ll n, ll mod = MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, H, D;
    cin >> n >> H >> D;

    ll f = 1;
    ll sumf = 0;
    for (int i = 1; i <= n; i++) {
        f = f * i % MOD;
        (sumf += f) %= MOD;
    }

    vector<ll> dp(H, 0);
    dp[0] = 1;
    ll s = 1;
    for (int i = 1; i < H; i++) {
        dp[i] = s * sumf % MOD;
        (s += dp[i]) %= MOD;
        if (i >= D) {
            s = (s + MOD - dp[i - D]) % MOD;
        }
    }
    ll ans = s * f % MOD;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 8064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        for (long i = (long) Math.sqrt(n); i >= 1; i--) {
            if (n % i == 0) {
                System.out.println(i + n / i - 2);
                break;
            }
        }
    }
}

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

    typedef long long int ll;

    #define MOD (ll)(1e9+7)
    #define endl "\n"
    #define pb push_back
    #define TEST_CASES  ll t;cin >> t;while(t--)
    #define forn(i,n) for (int i = 0; i < n; ++i)
    #define f first
    #define s second
    #define all(x) x.begin(), x.end()
    
    ll powD(ll x,ll y){
      ll res = 1;
      while(y > 0){
        if(y & 1)
          res = (res*x)%MOD;
        x = (x*x)%MOD;
        y = y>>1;
      }
      return res;
    }
  

    int main()
    {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL); 
      ll n,k;
      cin>>n>>k;
      vector<ll> a(n);
      forn(i,n){
        cin>>a[i];
        a[i]--;
      }
      ll town =0,start;
      ll r = 0;
      vector<int> visited,cnt(n,0);
      int sum = 0;
      while(1){
        if(cnt[town]){
            start = town;
            break;
        }
        cnt[town] = 1;
        town = a[town];
        sum++;
        if(sum == k){
          cout<<town+1<<endl;
          return 0;
        }
      }
      k -= sum;
      town = start;
      do{
        visited.push_back(town);
        r++;
        town = a[town];
      }while(town != start);
      ll rem = k%r;
      /*forn(i,visited.size()){
        cout<<visited[i]<<" ";
      }*/
      cout<<visited[rem]+1<<endl;
    }
    //read the question correctly (ll vs int)




Measured memory_bytes: 6128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int N;
	cin >> N;
	vector<int> vec(N);
	rep(i,0,N) cin >> vec[i];
	int cnt = 0;
	rep(i,0,N-2){
		if ((vec[i] < vec[i+1] && vec[i+1] < vec[i+2]) || (vec[i] > vec[i+1] && vec[i+1] > vec[i+2]))
			cnt++;
	}
	cout << cnt << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,j,k) for(int i=j;i<=k;++i)
#define ll long long 
using namespace std;
const int N=1001000,INF=0x3f3f3f3f;
const int Mod=1e9+7;
template<class T>void read(T &x){
	x=0;char c=getchar();
	while(!isdigit(c))c=getchar();
	while( isdigit(c))x=(x<<1)+(x<<3)+(c^48),c=getchar();
}
ll n,p[N],f[N],s[N];

int main(){
	read(n);
	f[1]=1;s[1]=1;
	For(i,2,n){
		f[i]=(f[i-1]+f[i])%Mod;
		if(i>3)f[i]=(f[i]+s[i-3])%Mod;
		s[i]=(s[i-1]+f[i])%Mod;
	}
	ll ans=f[n]*n%Mod;
	For(i,1,n-1){
		ll tmp=min(i+1ll,n-1);
		ans=(ans+f[i]*(n-1)%Mod*(n-1)%Mod)%Mod;
		ans=(ans+f[i]*tmp%Mod)%Mod;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 16640
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */

typedef long long ll;

/* constant */

const int INF = 1 << 30;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */

/* function */
void printVec(vector<int> &vec);

/* main */
int main(){

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

    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    printVec(v);

    return 0;
}

void printVec(vector<int> &vec) {
    for (int i = 0; i < vec.size(); i++) {
        if (i) cout << ' ' ;
        cout << vec[i];
    } cout << '\n';

}



Measured memory_bytes: 3156
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true){
			int n = stdIn.nextInt();
			if(n==0){
				return;
			}
			int[] num = new int[n];
			for(int i=0;i<n;i++){
				num[i] = stdIn.nextInt();
			}
			int cnt = 0;
			while(true){
				boolean flag = true;
				int[] source = new int[n];
				int[] before = new int[n];
				for(int i=0;i<n;i++){
					source[i] = num[i];
					before[i] = num[i];
				}
				for(int i=0;i<n;i++){
					int cnt2 = 0;
					for(int j=0;j<n;j++){
						if(source[i]==source[j]){
							cnt2++;
						}
					}
					num[i] = cnt2;
				}
				for(int i=0;i<n;i++){
					if(source[i]!=num[i]){
						flag = false;
						break;
					}
				}
				if(flag){
					break;
				}
				cnt++;
			}
			System.out.println(cnt);
			for(int i=0;i<n-1;i++){
				System.out.print(num[i]+" ");
			}
			System.out.println(num[n-1]);
		}
	}
}

Measured memory_bytes: 12000
<?php
$yen = 100;
$ans = 0;
$X = trim(fgets(STDIN));  // 入力
while ($yen < $X) {
    $yen = $yen * 1.01;
    $yen = floor($yen);
    //echo $yen;
    $ans = $ans + 1;
}
echo $ans;

Measured memory_bytes: 15968
#include<cstdio>
#include<cstring>
#include<iostream>
#define cri const int
#define ll long long
#define re register
using namespace std;
int N,K,mod;
int f[152][152];
inline int mo(cri x){ return x>=mod?x-mod:x; } 
inline void solve2(){
	f[0][0]=f[1][0]=f[1][1]=f[2][0]=f[2][1]=1;
	K=(K>>1)+1;
	for(int i=3;i<=N;i++){
		for(int j=0;j<K;j++) f[i][0]=mo(f[i][0]+f[i-2][j]);
		for(int j=0;j<K-1;j++) f[i][j+1]=f[i-2][j];
	}
	int tmp1=0,tmp2=0;
	for(int i=0;i<K;i++) tmp1=mo(tmp1+f[N][i]),tmp2=mo(tmp2+f[N-1][i]);
	cout<<1ll*tmp1*tmp2%mod<<endl;
}
int dp[152][152][152];
inline void solve1(){
	dp[0][0][0]=1;
	for(int i=1;i<=N+K>>1;i++){//cout<<"i="<<i<<endl;
		if(i<=K/2) for(int j=0;j<i;j++) dp[i][0][j+1]=dp[i-1][0][j],dp[i][0][0]=mo(dp[i][0][0]+dp[i-1][0][j]);
		else if(i<=N/2){
			for(int j=0;j<=i;j++) 
				for(int k=0;k<i;k++){
					//cout<<j<<" "<<k<<endl;
					dp[i][0][0]=mo(dp[i][0][0]+dp[i-1][j][k]);
					if(j>=2) dp[i][j+1][0]=mo(dp[i][j+1][0]+dp[i-1][j][k]);
					else dp[i][0][0]=mo(dp[i][0][0]+dp[i-1][j][k]);
					dp[i][0][k+1]=mo(dp[i][0][k+1]+dp[i-1][j][k]);
					dp[i][max(j+1,k+2)][k+1]=mo(dp[i][max(j+1,k+2)][k+1]+dp[i-1][j][k]);
				}
		}
		else{
			for(int j=0;j<=i;j++) for(int k=0;k<i;k++) {
				dp[i][0][0]=mo(dp[i][0][0]+dp[i-1][j][k]);
				if(j>=2) dp[i][j+1][0]=mo(dp[i][j+1][0]+dp[i-1][j][k]);
				else dp[i][0][0]=mo(dp[i][0][0]+dp[i-1][j][k]);
			}
		}
		for(int j=K+2;j<=i+1;j++) memset(dp[i][j],0,sizeof dp[i][j]); 
	}
	int ans=0;
	for(int i=0;i<=N;i++)for(int k=0;k<=N;k++) ans=mo(ans+dp[N+K>>1][i][k]);
	cout<<ans<<endl;
}
int main(){
	cin>>N>>K>>mod;
	if(K&1) solve1();
	else solve2();
}

Measured memory_bytes: 8672
#include<iostream>
using namespace std;
long long K,A,B;
long long temp;
long long ans;
int main()
{
	cin>>K>>A>>B;
	if(B<=(A+2))
	{
		ans=K+1;
	}
	else
	{
		if(K<=A)
		{
			ans=K+1;
		}
		else
		{
			temp=(K-A+1)/2;
			ans=temp*(B-A)+(K-A+1)%2+A;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int, int>
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vi d(n);
  REP(i, n) { cin >> d[i]; }
  sort(ALL(d));
  int ans = 0;
  REP(i, n - 2) {
    FOR(j, i + 1, n - 1) {
      FOR(k, j + 1, n) {
        if (d[k] < d[i] + d[j] && d[i] < d[k] + d[j] && d[j] < d[i] + d[k]) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
// clang-format on

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, a, b;
  cin >> n >> a >> b;
  vector<int> x(n);
  REP(i, n) cin >> x[i];

  ll ans = 0;
  for (int i = 1; i < n; i++) {
    if (a * (x[i] - x[i - 1]) >= b) {
      ans += b;
    } else {
      ans += a * (x[i] - x[i - 1]);
    }
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

const auto MOD = (long long) 1e9 + 7;

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

    long long ansX = 0;
    for (int i = 0; i < n; ++i) {
        long long x;
        cin >> x;
        ansX += (2 * i - n + 1) * x;
        ansX %= MOD;
    }

    long long ansY = 0;
    for (int i = 0; i < m; ++i) {
        long long y;
        cin >> y;
        ansY += (2 * i - m + 1) * y;
        ansY %= MOD;
    }

    cout << (ansX * ansY) % MOD << endl;
    return 0;
}


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

int main() 
{
  int n, m; cin >> n >> m;
  vector<vector<int>> v(m);
  vector<int> p(m);
  rep(i, m){
    int k; cin >> k;
    v[i].resize(k);
    rep(j, k){
      cin >> v[i][j];
    }
  }
  int ans = 0;
  rep(i, m) cin >> p[i];
  for(int bit = 0; bit < (1 << n); bit++){
    bool f = true;
    rep(i, m){
      int cnt = 0;
      rep(j, v[i].size()){
        if(bit & (1 << (v[i][j]-1)))cnt++;
      }
      if(cnt % 2 != p[i])f = false;
    }
    if(f)ans++;
  }
  cout << ans << endl;
  system("pause");
}


Measured memory_bytes: 504
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
        int[] l = new int[m];
        int[] r = new int[m];

        for(int i=0; i<m; i++){
          l[i] = sc.nextInt();
          r[i] = sc.nextInt();
        }
        int lMax = l[0];
        int rMin = r[0];
        for(int i=1; i<m; i++){
          if(lMax < l[i]) lMax = l[i];
          if(rMin > r[i]) rMin = r[i];
        }
        if(rMin-lMax<0) System.out.println("0");
        else System.out.println(rMin-lMax+1);
	}
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];
    ll ans = 0;
    for (int i = 29; i >= 0; i--) {
        int t = (1 << (i+1)) - 1;
        for (int j = 0; j < N; j++) A[j] &= t;
        sort(A.begin(), A.end());
        ll cnt = 0;
        for (int j = 0; j < N; j++) {
            B[j] &= t;
            auto it1 = lower_bound(A.begin(), A.end(),  (1 << i) - B[j]);
            auto it2 = lower_bound(A.begin(), A.end(),  (1 << (i+1))- B[j]);
            cnt += distance(it1, it2);
            auto it3 = lower_bound(A.begin(), A.end(),  (3 << i) - B[j]);
            cnt += distance(it3, A.end());
        }
        ans += ((cnt%2) << i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
    }

    if c - a - b < 0 {
        println!("No");
        return;
    }

    if (c - a - b).pow(2) > 4 * a * b {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2128
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())

    C = [[0 for _ in range(0, 10)] for _ in range(0, 10)]
    for k in range(1, N + 1):
        k = str(k)
        head_k = int(k[0])
        tail_k = int(k[-1])
        C[head_k][tail_k] += 1

    res = 0
    for i in range(0, 10):
        for j in range(0, 10):
            res += C[i][j] * C[j][i]

    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40552
#include<stdio.h>
#define INF (1<<29)
#define rep(i,n) for(i=0;i<(n);i++)
int main(){
	int i,j,k,n;
	int t[16][17];
	int dp[1<<16];
	int min;
	while(scanf("%d",&n)==1&&n){
		rep(i,n)rep(j,n+1)scanf("%d",&t[i][j]);
		rep(i,1<<n)dp[i]=INF;
		dp[0]=0;
		rep(i,(1<<n)-1){
			rep(j,n){
				if(i&1<<j)continue;
				min= t[j][0];
				rep(k,n){
					if((i&1<<k) && t[j][k+1]<min)min=t[j][k+1];
				}
				if(dp[i]+min < dp[i|1<<j])
					dp[i|1<<j] = dp[i]+min;
			}
		}
		printf("%d\n",dp[(1<<n)-1]);
	}
}

Measured memory_bytes: 664
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int N; cin >> N;
    string S; cin >> S;
    map<char,int>m;
    rep(i,N){
        m[S[i]]++;
    }
    int ans=1;
    for(auto p:m){
        ans=ans*(p.second+1)%1000000007;
    }
    cout << ans-1 << endl;

    return 0;
}

Measured memory_bytes: 512
# encoding: utf-8
import sys

N = int(input())

# p ** a
ptab = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101]
atab = [1] * (N + 1) # prime factor upper == N ?

# create atab
memo = [None] * (N + 1)
pidx = 0
cnt = 0
for i in range(2, N + 1):
    tmp = i
    # for p in range(2, N + 1):
    for p in ptab:
        # escape
        if tmp in ptab:
            atab[tmp] += 1
            break
        elif tmp < 2: break
        elif tmp % p > 0: continue
        # solve a
        for a in range(1, N):
            cnt += 1
            if tmp % (p ** (a + 1)) > 0: break
        # update atab
        tmp = tmp // (p ** a)
        atab[p] += a
        # print("#", i, p, cnt)

# remove 1
atab_small = []
for maxa in atab:
    if maxa > 1: atab_small.append(maxa)
N = len(atab_small)
# print("#", atab_small)

def count(pos, val):
    if pos == N or val == 75: return 0
    ret = 0
    for atmp in range(1, atab_small[pos] + 1): # include a + 1
        if atmp not in [1, 3, 5, 15, 25, 75]: continue
        val_tmp = val * atmp
        if val_tmp < 75: ret += count(pos + 1, val_tmp)
        elif val_tmp == 75: ret += 1
        else: break
    return ret

print(count(0, 1))


Measured memory_bytes: 3064
N,K=map(int,input().split())
plist=list(map(int,input().split()))

exp_list=[]
for p in plist:
  exp_list.append((p+1)/2.0)

#print(exp_list)
part_sum=sum(exp_list[:K])
ps_list=[part_sum]
for i in range(K,N):
  part_sum+=exp_list[i]-exp_list[i-K]
  ps_list.append(part_sum)
  
#print(ps_list)
print(max(ps_list))

Measured memory_bytes: 25060
// A
// DeP
#include <cstdio>
#include <algorithm>
using namespace std;

int H, W, N;

int main() {
    scanf("%d%d%d", &H, &W, &N);
    if (H < W) swap(H, W);
    printf("%d\n", N / H + (N % H != 0));
    return 0;
}

Measured memory_bytes: 128
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    cin >> N;
    if(N == 1)  cout << "Hello World" << endl;
    else {
        int a,b;
        cin >> a >> b;
        cout << a+b <<endl;
    }
}


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

int main()
{
  i64 m, f, b;
  cin >> m >> f >> b;
  if (m + f < b)
    cout << "NA" << endl;
  else
    cout << max(0LL, b - m) << endl;
  return 0;
}



Measured memory_bytes: 3120
#include<stdio.h>
#include<math.h>
#include<limits.h>
#include<assert.h>
#include<stdbool.h>
#include<stddef.h>
#include<stdint.h>
#include<string.h>
#include<unistd.h>
#include<stdlib.h>
#include<iostream>
#include<bits/stdc++.h>
#include<ctype.h>
#include<time.h>
typedef long long ll;
#define pi 3.14159
using namespace std;
int main()
{ 
ll x,y;scanf("%lld%lld",&x,&y);
    printf("%lld",x*y/__gcd(x,y));
    
return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static long N;
        static long K;
        static long[] A;
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            N = NK[0];
            K = NK[1];
            A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            double L = 0;
            double R = A.Max();

            while (0.000001 < R - L)
            {
                double mid = (R + L) / 2;
                if (check(mid))
                {
                    R = mid;
                }
                else
                {
                    L = mid;
                }
            }

            Console.WriteLine(Ceiling(L));
        }

        static bool check(double mid)
        {
            long ans = 0;
            for (int i = 0; i < N; i++)
            {
                ans += (long)(A[i] / mid);
            }

            return ans <= K;
        }
    }


}


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

int main() {
  int N;
  cin>>N;
  string S;
  cin>>S;
  string L;
  for(int i=0; i<N/2; i++){
    L += S[i];
  }
  if(S==L+L){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
void main() {
    int d = readln.chomp.to!int;
    string s = "Christmas";
    string t = " Eve";
    while (d < 25) {
        s ~= t;
        ++d;
    }
    s.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

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


void input()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
    #endif
}
#define endl "\n"
#define ll long long int
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define tll tuple<ll,ll,ll>
#define mt make_tuple
#define INF LONG_LONG_MAX
#define mod 1000000007
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define cases ll t; cin>>t; while(t--)
#define array(a,n) vll a(n); rep(i,0,n) cin>>a[i];
#define sortall(a) sort(a.begin(),a.end())
#define printall(a) rep(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;

// --------------- My Template End --------------- //
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    input();
   ll n,i=0,k=0,ans=0,curr,freq=0;
   cin>>n;
   array(b,n);
   vll a;
   map<ll,ll>m;
   rep(i,0,n)
   {
   		m[b[i]]++;
   		if(m[b[i]]==1)
   			a.pb(b[i]);
   }
  // sortall(b);
  //  printall(b);
   sortall(a);
   i=a.size()-1;
   curr=a[i];
   freq=m[a[i]]*2-1;
   i--;
   while(k<n-1)
   {
   	if(freq==0)
   	{
   		curr=a[i];
   		freq=2*m[a[i]];
   		i--;
   	}
  	//cout<<curr<<" "<<freq<<endl;
   	ans+=curr;
   	k++;
   	freq--;
   }

   cout<<ans<<endl;
}




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

using namespace std;

#define MAXN 100010
typedef long long LL;

int n, a[MAXN], sz[MAXN];
int sta[MAXN];
vector<int> adj[MAXN];

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

void DFS(int u, int fa)
{
    sta[++sta[0]] = u;
    if(u == n){
        memcpy(a, sta, sizeof(a));
    }
    sz[u] = 1;
    for(auto &v: adj[u]){
        if(v == fa) continue;
        DFS(v, u);
        sz[u] += sz[v];
    }
    --sta[0];
}

void Work()
{
    int i = (a[0] + 1) / 2 + 1, j, k;
    j = sz[a[i]]; k = sz[1] - j;
    printf("%s\n", k > j ? "Fennec" : "Snuke");
}


int main( int argc , char * argv[] ){
//	freopen( "input.txt" , "r" , stdin );
//	freopen( "output.txt" , "w" , stdout );
	Init();
	DFS(1, 0);
	Work();
	return 0;
}


Measured memory_bytes: 11520
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>
 
using namespace std;
typedef long long int ll;
 
#define C cout<<
#define E <<endl
#define CE cout<<endl
 
ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[1010];
bool r,ra,rb,rc[200010];
string s,sa,sb,sc;
char ca,cb,cc,cd[1010][1010];
vector<ll> va,vb,vc,vd,ve,vaa,vbb;
set<int> st;
 
 
 
template<typename MAIN> ostream & operator<<(ostream & osys,const vector<MAIN> target){ for(MAIN it:target)osys<<it<<" "; return osys; }
 
int main(){
    cin>>a>>b;
    m=2018;
    for(ll i=a;i<=b and i<=a+2019;i++){
        for(ll j=i+1;j<=b and j<=a+2019;j++){
            m=min(m,i*j%2019);
        }
    }
    C m E;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    string S;
    cin >> S;
    if(S[0] == 'R'){
        if(S[1] == 'R'){
            if(S[2] == 'R'){
                cout << 3 << "\n";
            }else{
                cout << 2 << "\n";
            }
        }else{
            cout << 1 << "\n";
        }
    }else{
        if(S[1] == 'R'){
            if(S[2] == 'R'){
                cout << 2 << "\n";
            }else{
                cout << 1 << "\n";
            }
        }else{
            if(S[2] == 'R'){
                cout << 1 << "\n";
            }else{
                cout << 0 << "\n";
            }
        }
    }
}

Measured memory_bytes: 3648
# coding:utf-8


def main():
    S = input()
    RED = "0"
    BLUE = "1"
    red_count = 0
    blue_count = 0
    ans = 0

    for si in S:
        if si == RED:
            red_count += 1
        else:
            blue_count += 1

    if red_count == 0 or blue_count == 0:
        ans = 0
    else:
        ans = 2 * min(red_count, blue_count)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
    	long long n,m=0;
    	cin>>n;
    	long long x,y,z;
    	vector<pair<long long,pair<long long,long long> > > v;
    	for(long long i=0;i<n;i++){
    	    cin>>x>>y>>z;
    	    m=max(m,y+x);
    	    v.push_back(make_pair(x+y,make_pair(x,z)));
    	}
    	sort(v.begin(),v.end());
    	long long dp[m+1]={0};
    	long long ans=0;
    	for(long long i=0;i<n;i++){
    	    for(long long j=v[i].first;j>=v[i].second.first;j--){
    	        dp[j]=max(dp[j],dp[j-v[i].second.first]+v[i].second.second);
    	        ans=max(dp[j],ans);
    	    }
    	}cout<<ans;
    	
    }

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String s="";
		while((s=br.readLine())!=null){
			StringTokenizer st=new StringTokenizer(s," ");
			System.out.println(new BigInteger(st.nextToken()).gcd(new BigInteger(st.nextToken())));
		}
	}

}

Measured memory_bytes: 15080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main() {
    int a[5][205], dp[5][105];

    int n;
    cin >> n;
    for(int i=1; i<=2; i++) for(int j=1; j<=n; j++) cin >> a[i][j];
    for(int i=1; i<=2; i++) {
        for(int j=1; j<=n; j++) {
            dp[i][j] = max(dp[i][j-1], dp[i-1][j]) + a[i][j];
        }
    }
    cout << dp[2][n];
}


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

int a;
int b;

void input() {
    cin >> a;
    cin >> b;
}

int main() {
    input();

    if (a == b){
        cout << "a == b" << endl;
    } else if(a < b){
        cout << "a < b" << endl;

    } else{
        cout << "a > b" << endl;

    }
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int cnt = 0;
    vector<int> ab;
    rep(i,n){
        if(a[i]<0) cnt++;
        ab.push_back(abs(a[i]));
    }
    sort(ALL(ab));
    if(cnt % 2 == 0){
        ll ans = 0;
        rep(i,n) ans += ab[i];
        cout << ans << endl;
    }else{
        ll ans = 0;
        ans -= ab[0];
        for(int i = 1; i < n; i++){
            ans += ab[i];
        }
        cout << ans << endl;
    }
}

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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> T(N);

  for (size_t i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    for (int j = 1; j <= N; j++) {
      if(a==j || b==j) T.at(j-1)++;
    }
  }
  for (int i = 0; i < N; i++) {
    cout << T.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX_V 1000000
int prime[MAX_V+1] = {0};
int primeSum[MAX_V+2] = {0};
int main(){
    int i, k, n;

    for(i = 2; i <= MAX_V; i++){
        prime[i] = 1;
    }
    for(i = 2; i * i <= MAX_V; i++){
        if(prime[i]){
            for(k = 2*i;k <= MAX_V; k += i){
                prime[k] = 0;
            }
        }
    }

    for(i = 0; i < MAX_V + 2; i++){
        primeSum[i] = primeSum[i-1] + prime[i];
    }

    while(scanf("%d", &n) != EOF){
        printf("%d\n",primeSum[n]);
    }
    return 0;
}

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

struct seg {
  ll idx, l, r, next;
};

int main(void) {
  ll N, Q;
  cin >> N >> Q;
  vector<string> S(N);
  REP(i, 0, N) cin >> S[i];

  vector<seg> segments(5 * 100000);
  ll s = 0;

  vector<ll> head(N);
  REP(i, 0, N) {
    segments[s].idx = i;
    segments[s].l = 0;
    segments[s].r = S[i].length();
    segments[s].next = -1;
    head[i] = s++;
  }

  REP(i, 0, Q) {
    ll T;
    cin >> T;

    if (T == 1) {
      ll A, B, C, D;
      cin >> A >> B >> C >> D, A--, B--, C--, D--;

      ll a = head[A], b = B;
      while (b >= segments[a].r - segments[a].l) {
        b -= segments[a].r - segments[a].l;
        a = segments[a].next;
      }

      ll c = head[C], d = D;
      while (d >= segments[c].r - segments[c].l) {
        d -= segments[c].r - segments[c].l;
        c = segments[c].next;
      }

      ll segA = s++, segC = s++;
      segments[segA].idx = segments[a].idx;
      segments[segA].r = segments[a].r;
      segments[segA].l = segments[a].l + b;
      segments[segA].next = segments[a].next;
      segments[segC].idx = segments[c].idx;
      segments[segC].r = segments[c].r;
      segments[segC].l = segments[c].l + d;
      segments[segC].next = segments[c].next;

      segments[a].r = segments[segA].l;
      segments[a].next = segC;
      segments[c].r = segments[segC].l;
      segments[c].next = segA;
    }

    if (T == 2) {
      ll A, B;
      char C;
      cin >> A >> B >> C, A--, B--;

      ll a = head[A], b = B;
      while (b >= segments[a].r - segments[a].l) {
        b -= segments[a].r - segments[a].l;
        a = segments[a].next;
      }

      S[segments[a].idx][segments[a].l + b] = C;
    }

    if ((i + 1) % 310 == 0 || i + 1 == Q) {
      vector<string> T(N);
      REP(j, 0, N) {
        T[j] = "";
        ll a = head[j];
        while (a != -1) {
          T[j] += S[segments[a].idx].substr(segments[a].l, segments[a].r - segments[a].l);
          a = segments[a].next;
        }
      }
      S = T;

      s = 0;
      REP(j, 0, N) {
        segments[s].idx = j;
        segments[s].l = 0;
        segments[s].r = S[j].length();
        segments[s].next = -1;
        head[j] = s++;
      }
    }
  }

  REP(i, 0, N) cout << S[i] << endl;
}


Measured memory_bytes: 30320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define Graph vector<vector<int>>
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<
#define AA(i) cout<<i<<endl;
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;

int main(){
    int i,N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    ll ans=0;

    rep(i,N-1){
        if(A[i]>A[i+1]){
            ans += A[i] - A[i+1]; 
            A[i+1] = A[i];
        }
    }
    AA(ans);
    return 0;
}

Measured memory_bytes: 4840
n, m = map(int, input().split())
l, r = map(int, input().split())
for i in range(m-1) :
  L, R = map(int, input().split())
  l = max(l, L)
  r = min(r, R)

ans = 0
for i in range(1,n+1) :
  if l <= i <= r :
    ans += 1
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int max[7];
	int min[7];
	int dif[7];
	int i;
	
	for (i = 0; i < 7; i++){
		scanf("%d %d", &max[i], &min[i]);
		if (min[i] < 0){
			dif[i] = max[i] + -1 * min[i];
		}
		else {
			dif[i] = max[i] - min[i];
		}
	}
	
	for (i = 0; i < 7; i++){
		printf("%d\n", dif[i]);
	}
	
	return (0);
}

Measured memory_bytes: 600
package main

import "fmt"

func comb(n, x int) [][3]int {
	c := [][3]int{}
	if x > (n-1)*3 || x < 6 {
		return c
	}

	for i := 1; i < n-1; i++ {
		if i > x/3 {
			break
		}
		for j := i+1; j < n; j++ {
			if j > (x-i)/2 {
				break
			}
			rem := x-(i+j)
			if rem > j && rem <= n {
				c = append(c, [3]int{i, j, rem})
			}
		}
	}
	return c
}

func main() {
	var n, x int

	for {
		fmt.Scan(&n, &x)
		if n == 0 && x == 0 {
			break
		}
		fmt.Println(len(comb(n, x)))
	}
}



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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < 3; i++)
		if (s[i] == t[i])
			ans ++;
	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

double dfs(int n, double d, double x){
    if(n == 0) return 0.0;
    double ret = d/2.0 + x*(n-1)/4.0;
    ret += dfs(n-1, d*(1.0+n)/n + 3.0*x/(2.0*n), x*(2.0+n)/n);
    return ret;
}

int main(){
    int N;
    double d, x;
    cin >> N >> d >> x;
    d = 2*d+x, x = 4*x;
    cout << sp(15) << dfs(N, d, x) << endl;
}

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

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

    vector<int> d(N, 0);
    for (auto &x: d) cin >> x;
    sort(d.begin(), d.end(), greater<int>());
    // for (auto &x: d) cout << x << ", ";

    int num = 1;
    for (size_t i=1; i<d.size(); ++i) {
        if (d[i] < d[i-1]) ++num;
    }

    cout << num << endl;
}


Measured memory_bytes: 3596
#include <stdio.h>

int bubbleSort(int A[], int N) {
	int sw, flag, i, j, e;
	sw = 0; flag = 1;

	while (flag) {
		flag = 0;
		for (i = 0; i < N; i++) {
			for (j = N - 1; j > i; j--) {
				if (A[j] < A[j - 1]) {
					e = A[j]; A[j] = A[j - 1]; A[j - 1] = e;
					flag = 1;
					sw++;
				}
			}
		}
	}

	return sw;

}

int main() {
	int A[100], N, sw, i;
	scanf("%d", &N);

	for (i = 0; i < N; i++)
		scanf("%d", &A[i]);

	sw = bubbleSort(A, N);

	for (i = 0; i < N; i++) {
		if (i > 0) printf(" ");
		printf("%d", A[i]);
	}
	
	printf("\n%d\n", sw);

	return 0;
}

Measured memory_bytes: 2708
#include<stdio.h>

int main(){
    int n[100],a,i;
    scanf("%d",&a);

    for(i = 0; i < a; i++){
        if(i == a - 1){
            scanf("%d",&n[a-1]);
            break;
        }
        scanf("%d ",&n[i]);
    }

    for(i = 0; i < a; i++){
        if(i == a - 1){
            printf("%d",n[0]);
            break;
        }
        printf("%d ",n[a-1-i]);
    }

    puts(""); 

    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
#include <array>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vsort(x) sort(x.begin(),x.end())

using int64 = uint64_t;

using namespace std;

int main() {
	string s;
	cin >> s;
	rep(i, 0, s.length()) {
		s[i] = (((s[i] - 'A') + 23) % 26) + 'A';
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

using Graph = vector<vector<int>>;

vector<int> line;

void add(const Graph &tree, int v, int p) { 
	for (auto nv : tree[v]) {
		if (nv == p)continue;
		line[nv] += line[v];
		add(tree, nv, v);
	}
}

int main() {
    int n, q, a, b, p, x;
    cin >> n >> q;
    line.resize(n);
    Graph tree(n); 
    rep(i, n-1){
        cin >> a >> b;
        tree[a-1].push_back(b-1);
        tree[b-1].push_back(a-1);
    }
    rep(i, q){
        cin >> p >> x;
        line[p-1] += x;
    }
    add(tree, 0, -1);
    rep(i, n)cout << line[i] << " ";
    cout << endl;
}

Measured memory_bytes: 26624
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define line cout<<"------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
#define inf (int)1e9+7
using namespace std;
int n,m;
vector<int> v[100009];
bool visit[100009];
int maxi=-1;
int dp[100009];
void dfs(int s,int l)
{
    visit[s]=true;
    for(auto x: v[s])
    {
        if(visit[x]==false)
        {
            dfs(x,l+1);
        }
        dp[s]=max(dp[s],dp[x]+1);
    }
    maxi=max(maxi,dp[s]);
}
int  main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
    }
    for(int i=1;i<=n;i++)
    {
        if(visit[i]==false)
        {
            dfs(i,0);
        }
    }
    cout<<maxi<<endl;
}


Measured memory_bytes: 8192
import Data.List (foldl')
type Score = (Int,Int)
turn :: Score -> [String] -> Score
turn (x,y) [s0,s1] = case s0 `compare` s1 of
                         GT -> (x+3,y)
                         LT -> (x,y+3)
                         EQ -> (x+1,y+1)

main = do
    _ <- getLine
    getContents >>=
        (\(x,y) -> putStrLn . unwords . map show $ [x,y]) .
            foldl' turn (0,0) . map words . lines

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;

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

    string ans = "No";
    REP(i,1,10){
        REP(j,1,10){
            if(i * j == n){
                ans = "Yes";
            }
        }
    }
    OP(ans);
}


Measured memory_bytes: 256