akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/agc006/tasks/agc006_a
#include <bits/stdc++.h>
using namespace std;
#define TEMPLATE
#ifdef BTK
#define DEBUG if (1)
#else
#define CIN_ONLY if (1)
struct cww {
    cww() {
        CIN_ONLY {
            ios::sync_with_stdio(false);
            cin.tie(0);
        }
    }
} star;
#define DEBUG if (0)
#endif
#define ALL(v) (v).begin(), (v).end()
#define REC(ret, ...) std::function<ret(__VA_ARGS__)>
template <typename T>
inline bool chmin(T& l, T r) {
    bool a = l > r;
    if (a) l = r;
    return a;
}
template <typename T>
inline bool chmax(T& l, T r) {
    bool a = l < r;
    if (a) l = r;
    return a;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& it : v) is >> it;
    return is;
}
template <typename T>
inline T& unused_var(T& v) {
    return v;
}
class reverse_range {
  private:
    struct I {
        int x;
        int operator*() {
            return x - 1;
        }
        bool operator!=(I& lhs) {
            return x > lhs.x;
        }
        void operator++() {
            --x;
        }
    };
    I i, n;

  public:
    reverse_range(int n) : i({0}), n({n}) {}
    reverse_range(int i, int n) : i({i}), n({n}) {}
    I& begin() {
        return n;
    }
    I& end() {
        return i;
    }
};
class range {
  private:
    struct I {
        int x;
        int operator*() {
            return x;
        }
        bool operator!=(I& lhs) {
            return x < lhs.x;
        }
        void operator++() {
            ++x;
        }
    };
    I i, n;

  public:
    range(int n) : i({0}), n({n}) {}
    range(int i, int n) : i({i}), n({n}) {}
    I& begin() {
        return i;
    }
    I& end() {
        return n;
    }
    reverse_range operator!() {
        return reverse_range(*i, *n);
    }
};
using LL = long long;

int main() {
    int N;
    string s, t;
    cin >> N >> s >> t;
    int S = s.size();
    int T = t.size();
    int ret = 200;
    for (int i : range(min(S, T) + 1)) {
        if (s.substr(S - i, i) == t.substr(0, i)) { chmin(ret, S + T - i); }
    }
    cout << ret << endl;
    return 0;
}

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

#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define lb(v, z) lower_bound(all(v), z)
#define ub(v, z) upper_bound(all(v), z)
#define fill(a, z) memset(a, z, sizeof(a))
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define rdp(i, a, b) for (int i = (a); i >= (b); i--)
#define rlt(i, a, b) for (int i = (a); i < (b); i++)
#define cns(z) cout << z << ' '
#define cnl(z) cout << z << '\n'
#define printclock cerr << "Time : " << 1000 * (double)clock() / (double)CLOCKS_PER_SEC << "ms\n";
#define M 1000000007
#define M2 998244353
#define MAXN 300005
#define INF 1000000000000
#define endl "\n"
#define iip(t) \
	int t;     \
	cin >> t;
#define iip2(a, b) \
	int a, b;      \
	cin >> a >> b;
#define dip(a) \
	double a;  \
	cin >> a;
#define dip2(a, b) \
	double a, b;   \
	cin >> a >> b;
#define garr(ip)       \
	for (auto &x : ip) \
		cin >> x;
#define parr(ip)          \
	for (auto &x : ip)    \
		cout << x << " "; \
	cout << endl;
#define test   \
	int _t;    \
	cin >> _t; \
	while (_t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vp;

int modExp(int base, int exponent = M - 2, int MOD = M)
{
	if (exponent == 0)
		return 1;
	int curr = modExp(base, exponent >> 1);
	curr = (curr * curr) % MOD;
	if (exponent & 1)
		curr = (curr * base) % MOD;
	return curr;
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	iip2(h1, a1);
	iip2(h2, a2);
	int t1 = (h2 / a1) + (int)(h2 % a1 != 0);
	int t2 = (h1 / a2) + (int)(h1 % a2 != 0);
	cnl((t1 <= t2 ? "Yes" : "No"));
}

Measured memory_bytes: 3588
#include <stdio.h>
#include <string.h>

int main(void)
{
	int n, h, o, p;
	char s[15];
	int i;
	
	while (scanf("%d", &n) != EOF){
		h = o = p = 0;
		for (i = 0; i < n; i++){
			while(o != 3){
				scanf("%s", s);
				if (strcmp(s, "HIT") == 0){
					h++;
				}
				if (h == 4){
					p++;
					h = 3;
				}
				if(strcmp(s, "OUT") == 0){
					o++;
				}
				if (strcmp(s, "HOMERUN") == 0){
					if (h == 0){
						p++;
					}
					else {
						p += h + 1;
						h = 0;
					}
				}
			}
		}
		printf("%d\n", p);
	}
	
	return (0);
}

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

int main(){
  string str[3];
  string dif[] = {"bbb","www"};
  while(cin >> str[0] , str[0] != "0"){
    cin >> str[1];
    cin >> str[2];
    bool flg = false;;
    for(int i=0;i<3;i++){
      for(int j=0;j<2;j++){
	if(str[i] == dif[j]){
	  cout << str[i][0] << endl;
	  flg = true;
	  break;
	}
      }
      if(flg) break;
    }
    if(!flg){
      for(int i=0;i<3;i++){
	string tmp = "";
	for(int j=0;j<3;j++) tmp += str[j][i];
	for(int j=0;j<2;j++){
	  if(tmp == dif[j]){
	    cout << tmp[0] << endl;
	    flg = true;
	    break;	  
	  }
	}
	if(flg) break;
      }
    }
    if(!flg){
      string tmp = "";
      for(int i=0;i<3;i++) tmp += str[i][i];
      for(int i=0;i<2;i++){
	if(tmp == dif[i]){
	  cout << tmp[0] << endl;
	  flg = true;
	  break;	  
	}
      }
      if(!flg){
	string tmp = "";
	for(int i=0;i<3;i++) tmp += str[2-i][i];
	for(int i=0;i<2;i++){
	  if(tmp == dif[i]){
	    cout << tmp[0] << endl;
	    flg = true;
	    break;	  
	  }
	}
      }
    }
    if(!flg) cout << "NA" << endl;
  }			     
}

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

const int N = 1e5 + 5;

int n,k,ans,dp[N][3],profit[3];
map<char,char> winner = {{'s','r'},{'p','s'},{'r','p'}};
map<int, char> indexToChar = {{0, 'r'}, {1, 's'}, {2, 'p'}};
string t;

int solve(int idx, int hand) {

    if(idx>=n) return 0;

    int &ret = dp[idx][hand];

    if(ret!=-1) return ret;

    ret = 0;

    for(int nextHand=0;nextHand<3;++nextHand)
        if(hand!=nextHand) ret = max(ret,solve(idx+k,nextHand));

    if(winner[t[idx]]==indexToChar[hand]) ret += profit[hand];

    return ret;

}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> k >> profit[0] >> profit[1] >> profit[2] >> t;

    memset(dp,-1,sizeof(dp));

    for(int i=0;i<k;++i) ans += max({solve(i,0),solve(i,1),solve(i,2)});

    cout << ans << '\n';

    return 0;
}

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

int main()
{

    int a,b,c,p,q,r,A,B;

    cin>>a;

    p=a/100;
    q=a%100;



if ((q>0&&q<13)&&(p>0&&p<13))
        cout<<"AMBIGUOUS"<<endl;


    /* else if(p>=13&&q>=13)
         cout<<"AMBIGUOUS"<<endl;*/

       else if (p>0&&p<13)
        cout<<"MMYY"<<endl;


   else if(q>0&&q<13)
        cout<<"YYMM"<<endl;


    else
        cout<<"NA"<<endl;

    return 0;
}






Measured memory_bytes: 256
var x,y,ans:Longint;
begin
read(x,y);
ans:=0;
if x=0 then if y>0 then ans:=y else ans:=1-y else if y=0 then if x<0 then ans:=-x else ans:=x+1 else if x>0 then if y>0 then if x<y then ans:=y-x else ans:=2+x-y else if x+y>0 then ans:=1+x+y else ans:=1-x-y else if y<0 then if x<y then ans:=y-x else ans:=2+x-y else if x+y>0 then ans:=1+x+y else ans:=1-x-y;
writeln(ans);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

ll A,B;
cin >> A >> B;

ll x;
cin >> x;

ll u = A/x, v = B/x;
ll ans;
if( A%x == 0 ) ans = v-u+1;
else ans = v-u;

cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

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

  vector<int> imos(n+1, 0);
  for(int i = 0; i < n; i++){
    imos[i+1] = a[i] + imos[i];
  }

  int ans = INF;
  for(int i = 1; i < n-1; i++){
    auto f = [&](int t){
      return imos[t] >= imos[i] - imos[t];
    };
    int left = 0, right = i;
    while(right - left > 1){
      int mid = (left + right) / 2;
      (f(mid) ? right : left) = mid;
    }
    int a = imos[left], a2 = imos[i] - imos[left];
    int b = imos[right], b2 = imos[i] - imos[right];

    auto f2 = [&](int t){
      return imos[t] - imos[i] >= imos[n] - imos[t];
    };
    left = i, right = n;
    while(right - left > 1){
      int mid = (left + right) / 2;
      (f2(mid) ? right : left) = mid;
    }
    int c = imos[left] - imos[i], c2 = imos[n] - imos[left];
    int d = imos[right] - imos[i], d2 = imos[n] - imos[right];

    if(abs(a - a2) > abs(b - b2)) a = b, a2 = b2;
    if(abs(c - c2) > abs(d - d2)) c = d, c2 = d2;
    ans = min(ans, max({a, a2, c, c2}) - min({a, a2, c, c2}));
    //cout << a << " " << a2 << " : " << c << " " << c2 << " = " << max({a, a2, c, c2}) - min({a, a2, c, c2}) << endl;
  }
  cout << ans << endl;

  return 0;
}


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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
  string s ; 
  cin >> s ;
  int idx1 = s.find("A") ;
  reverse(all(s)) ;
  int idx2 = s.find("Z") ;

  printf("%d\n" , s.length()-idx2 - idx1) ;
	
  return 0 ;
}



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

namespace ConsoleApplication14
{
    class Program
    {
        static void Main(string[] args)
        {
            // 太郎のカード得点
            string strTarosCard;
            int intTarosPoint = new int() ;
            // 花子のカード得点
            string strHanakosCard;
            int intHanakosPoint = new int();

            int intInputTryNum = int.Parse(Console.ReadLine());

            for(int num = 0; num < intInputTryNum; num++)
            {
                string[] strInputCardsArray = Console.ReadLine().Split(' ');

                strTarosCard = strInputCardsArray[0];
                strHanakosCard = strInputCardsArray[1];

                if(string.Compare(strTarosCard, strHanakosCard) == 0)
                {
                    intTarosPoint += 1;
                    intHanakosPoint += 1;
                }
                else if(string.Compare(strTarosCard, strHanakosCard) > 0)
                {
                    intTarosPoint += 3;
                }
                else
                {
                    intHanakosPoint += 3;
                }
            }

            Console.WriteLine($"{intTarosPoint} {intHanakosPoint}");
        }
    }
}



Measured memory_bytes: 16752
import Control.Applicative

main = do
  [a,b] <- map read.words <$> getLine :: IO [Int]
  case (a,b) of
    (a,b) | a*b < 0 -> putStrLn "Zero"
          | a > 0 && b > 0 -> putStrLn "Positive"
          | odd (min b 0 - a) -> putStrLn "Positive"
          | otherwise -> putStrLn "Negative"


Measured memory_bytes: 508
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long

int main(void)
{
  int a, b, h, m;
  double ans, angle;
  double min, hour; //1分あたりの各速度

  min = 360 / 60;
  hour = (double)360 / 720;

  scanf("%d%d%d%d", &a, &b, &h, &m);
  min = min * m;
  hour = hour * (h * 60 + m);
  if (min > hour)
    angle = min - hour;
  else
    angle = hour - min;

  ans = sqrt((a * a) + (b * b) - (2 * a * b * cos(angle * (M_PI / 180))));

  printf("%.12lf\n", ans);

  return 0;
}


Measured memory_bytes: 2596
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
	public static void main(String args[]) throws InterruptedException {
		    Scanner sc = new Scanner(System.in);	
			
			int x = sc.nextInt();
			int y = sc.nextInt();

			System.out.println(x+y/2);

		    sc.close(); }
}


Measured memory_bytes: 23764
n = int(input())
L = list(map(int,input().split()))
tf = [L[i] == i+1 for i in range(n)]

change = 0
for i in range(n):
    if tf[i] == False: continue
    if i != n-1 and tf[i+1] == True:
        tf[i] = False
        tf[i+1] = False
        change+= 1
        continue
    tf[i] = False
    change+= 1

print(change)

Measured memory_bytes: 14008
N = int(input())

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

L.sort()

ans = 0

for i in range(N-2):
    for j in range(i,N-1):
        for k in range(j,N):
            if L[i] != L[j] and L[j] != L[k]:
                if L[i]+L[j] > L[k] and L[i]+L[k] > L[j] and L[k]+L[j] > L[i]:
                    ans += 1
                
print(ans)

Measured memory_bytes: 68064
mod = 10**9 + 7

N, M = map(int, input().split())

if abs(N-M) > 1 :
    print(0)
    exit()

def factorial(n, mod) :
    temp = 1
    for i in range(1, n+1) :
        temp = (temp*i)%mod
    return temp

if N != M :
    ans = (factorial(N, mod) * factorial(M, mod)) % mod
else :
    ans = (2 * factorial(N, mod) * factorial(M, mod)) % mod

print(ans)


Measured memory_bytes: 3060
#include <iostream>
    #include <iomanip>
    using namespace std;
        
    double prob[2][3001];
        
    int main(){
        prob[0][0] = 1.0;
        prob[1][0] = 1.0;
        
        int n; cin >> n;
        
        for (int i = 1; i <= n; i++){
            double p; cin >> p;
        
            for (int a = 1; a <= i; a++){
                prob[i%2][a] = prob[(i+1)%2][a-1]*p + prob[(i+1)%2][a] * (1.0 - p);
            }
            
            prob[i%2][0] *= 1.0 - p;
            prob[(i+1)%2][0] *= 1.0 - p;
        }
        
        double tt = 0;
        
        for (int i = n/2 + 1; i <= n; i++){
            tt += prob[n%2][i];
        }
        cout << fixed << setprecision(11) <<  tt;
    }

Measured memory_bytes: 888
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
seen = {0}
i = 0
ans = 0
while True:
    i = a[i]-1
    ans += 1
    if i==1:
        print(ans)
        break
    if i in seen:
        print(-1)
        break
    seen.add(i)


Measured memory_bytes: 15908
#include<stdio.h>

struct Card{
  char mark;
  int num;
};

typedef struct Card card;

int main(void){
  int n,i,j,min,flag=0;
  card c1[36],c2[36],temp;
  char a;
  scanf("%d%c",&n,&a);
  for(i=0;i<n;i++){
    scanf("%c%d%c",&c1[i].mark,&c1[i].num,&a);
    c2[i]=c1[i];
  }
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(c1[j].num < c1[j-1].num){
        temp=c1[j];
        c1[j]=c1[j-1];
        c1[j-1]=temp;
      }
    }
  }
for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(c2[j].num < c2[min].num) min=j;
    }
    temp=c2[min];
    c2[min]=c2[i];
    c2[i]=temp;
  }
for(i=0;i<n;i++){
    if(i==n-1) printf("%c%d\n",c1[i].mark,c1[i].num);
    else  printf("%c%d ",c1[i].mark,c1[i].num);
  }
  printf("Stable\n");
  for(i=0;i<n;i++){
    if(i==n-1) printf("%c%d\n",c2[i].mark,c2[i].num);
    else  printf("%c%d ",c2[i].mark,c2[i].num);
  }
  for(i=0;i<n;i++){
    if(c1[i].mark != c2[i].mark) flag=1;
  }
  if(flag==1)printf("Not stable\n");
  else printf("Stable\n");
  return 0;
}

Measured memory_bytes: 608
#include<stdio.h>

int main(){
	int S[13]={};
	int H[13]={};
	int C[13]={};
	int D[13]={};
	char val;
	int num,N;
	scanf("%d\n",&N);
	for(int i = 0; i < N; i++){
		scanf("%c %d\n",&val,&num);
		if(val=='S') S[num-1]=1;
		if(val=='H') H[num-1]=1;
		if(val=='C') C[num-1]=1;
		if(val=='D') D[num-1]=1;
	}
	for(int i = 0; i < 13; i++){
		if(S[i]==0) printf("S %d\n",i+1);
	}
	for(int i = 0; i < 13; i++){
		if(H[i]==0) printf("H %d\n",i+1);
	}
	for(int i = 0; i < 13; i++){
		if(C[i]==0) printf("C %d\n",i+1);
	}
	for(int i = 0; i < 13; i++){
		if(D[i]==0) printf("D %d\n",i+1);
	}
	return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	vector<int> a(n);
	vector<bool> dp(k+1,false);
	for(int &x : a)
	scanf("%d",&x);
	//for(int i=0;i<n;i++)
	//cin>>a[i];
	
	for(int stones=0;stones<=k;stones++)
	{
		for(int i=0;i<n;i++)
		{
			if(stones-a[i]>=0 && dp[stones-a[i]]==false  )
			dp[stones]=true;
			}
		}
	
		if(dp[k])
		cout<<"First";
		else
		cout<<"Second";
	
	return 0;
	}


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

using namespace std;
#define intMax 2147483647
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repp(i, a, b) for (int i = a; i >= b; i--)
#define be(a) (a.begin(), a.end())
#define rbe(p) (p.rbegin(), p.rend())
#define pb push_back

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a, b;
    cin >> a >> b;
    int c = a, ans = 1;
    if ( b == 1 ){
        cout << 0;
        return 0;
    }
    while (c < b)
    {
        c--;
        c += a;
        ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 1e5 + 5;

ll gcd(ll a, ll b){
	if(a==0){
		return b;
	}
	return gcd(b%a, a); 
}

ll lcm(ll a, ll b){
	return a*b/gcd(a, b);
}

int main(){
	IOS
	ll a, b;
	cin >> a >> b;
	cout << lcm(a, b) << '\n';
}


Measured memory_bytes: 3628
from collections import deque
s=input()
Q=int(input())
hanten = 0
mae = deque()
ushiro = deque()
for i in range(Q):
	q=input()
	if q=="1":
		hanten ^= 1
	else:
		if q[2] == "1":
			if hanten == 0:
				mae.appendleft(q[4])
			else:
				ushiro.append(q[4])
		else:
			if hanten == 0:
				ushiro.append(q[4])
			else:
				mae.appendleft(q[4])
if hanten == 0:
	print("".join(mae) + s + "".join(ushiro))
else:
	print(("".join(mae) + s + "".join(ushiro))[::-1])

Measured memory_bytes: 6516
n,m = map(int,input().split())
students = [list(map(int,input().split())) for _ in range(n)]
check_point = [list(map(int,input().split())) for _ in range(m)]

for i in range(n):
    distance = 10**9
    ans = 0
    for j in range(m):
        temp_dictance = abs(students[i][0]-check_point[j][0]) + abs(students[i][1]-check_point[j][1])
        if temp_dictance < distance:
            distance = temp_dictance
            ans = j+1
    print(ans)

Measured memory_bytes: 3064
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
	char str[100005];

	scanf("%s", str);
	int len = strlen(str);

	int point = 0;

	for(int i = 0; i < len; ++i) {
		int b_op = str[i] == 'p';
		int a_op = i % 2;
		point += (a_op - b_op);
	}

	printf("%d\n", point);

	return 0;
}


Measured memory_bytes: 256
s = input()
pos = 0
cnt = 0
acnt = 0
if len(s) < 3:
    print(0)
else:
    while(True):
        if s[pos:pos+2] == "BC" and acnt > 0:
            pos += 2
            cnt += acnt
            # print(s, s[pos:pos+2], cnt, pos)
        else:
            if s[pos] == "A":
                acnt += 1
            else:
                acnt = 0
            pos += 1
        if pos >= len(s)-1:
            break
    print(cnt)



Measured memory_bytes: 3500
#include <iostream>
using namespace std;
 
int main() {
int i,x,y;
	for (i=1;i<=3000;i++){
		cin>>x>>y;
		if (x==0&&y==0){break;}
		else if (x<y){
			cout<<x<<" "<<y<<endl;
		}
		else if (x>y){
			cout<<y<<" "<<x<<endl;
		}
		else if (x==y){
			cout<<x<<" "<<y<<endl;
		}
 
	}
}


Measured memory_bytes: 2976
/*
 * RD
*/
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#ifndef rd
#define endl '\n'
#endif
#define deb cout<<"Line: "<<__LINE__<<" plz "
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
#define pii pair<int,int>
#define sz(x) ((int)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define all(con) con.begin(),con.end()
const ll inf=1e18;
const int mod=1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//12367769,266916112,123798211
ll powm(ll a, ll b, ll m);

int n,d;
pii segtree1[400005];
pii segtree2[400005];
pii query1(int l, int r)
{
	r++;
	pii res={inf+1,inf};
	for(l+=n+1,r+=n+1; l<r; l>>=1,r>>=1)
	{
		if(l&1) res=min(res,segtree1[l++]);
		if(r&1) res=min(res,segtree1[--r]);
	}
	return res;
}
pii query2(int l, int r)
{
	r++;
	pii res={inf+1,inf};
	for(l+=n+1,r+=n+1; l<r; l>>=1,r>>=1)
	{
		if(l&1) res=min(res,segtree2[l++]);
		if(r&1) res=min(res,segtree2[--r]);
	}
	return res;
}
int a[200005];
int solve(int l, int r, int l1, int r1)
{
	if(l+1==r)
		return 0;
	pii lef=query1(l+1,r-1);
	pii rig=query2(l+1,r-1);
//	deb<<l<<" "<<r<<endl;
//	deb<<lef.fi<<" "<<lef.se<<" "<<rig.fi<<" "<<rig.se<<endl;
	ll ans=0;
	if(lef.fi+a[l1]-l1*d>rig.fi+a[r1]+r1*d)
	{
		ans+=rig.fi+a[r1]+r1*d;
		lef=rig;
	}
	else
		ans+=lef.fi+a[l1]-l1*d;
	if(a[lef.se]+lef.se*d<a[r1]+r1*d)
		ans+=solve(l,lef.se,l1,lef.se);
	else
		ans+=solve(l,lef.se,l1,r1);
	if(a[lef.se]-lef.se*d<a[l1]-l1*d)
		ans+=solve(lef.se,r,lef.se,r1);
	else
		ans+=solve(lef.se,r,l1,r1);
	return ans;
}
void solve()
{
	cin>>n>>d;
	for(int i=0; i<n; i++)
		cin>>a[i];
	a[n]=inf;
	for(int i=n+1; i<2*n+2; i++)
	{
		segtree1[i]={a[i-n-1]+(i-n-1)*d,i-n-1};
		segtree2[i]={a[i-n-1]-((i-n-1)*d),i-n-1};
	}
	for(int i=n; i>0; i--) {
		segtree1[i]=min(segtree1[i<<1],segtree1[i<<1|1]);
		segtree2[i]=min(segtree2[i<<1],segtree2[i<<1|1]);
	}
	cout<<solve(0,n,0,n)<<endl;
}
signed main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());
	auto clk=clock();
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}
ll powm(ll a,ll b, ll m) {
	ll te=1;
	while(b) {
		if(b&1) te=(te*a)%m;
		a=(a*a)%m;
		b>>=1;
	}
	return te;
}


Measured memory_bytes: 19072
n = int(input())

d = {}
for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
max_d = max(d.values())
max_d_list = [kv[0] for kv in d.items() if kv[1] == max_d]

ans = sorted(max_d_list)

for i in ans:
    print(i)


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

int n, m;

int matrix[8][8];

bool visit[8] = {false};

void init(){
    for(int i = 0; i < n; i++){
        visit[i] = false;
    }
}

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

    

    for(int y = 0; y < n; y++){
        for(int x = 0; x < n; x++){
            matrix[y][x] = 0;
        }
    }

    int a, b;

    for(int i = 0; i < m; i++){
        cin >> a >> b;
        matrix[a-1][b-1] = 1;
        matrix[b-1][a-1] = 1;
    }

    vector<int> v;
    for(int i = 0; i < n; i++){
        v.push_back(i);
    }
    sort(v.begin(), v.end());

    int count = 0;

    do {
        if(v[0] != 0){
            continue;
        }

        bool flag = true;

        for(int i = 0; i < n; i++){
            if(i == n - 1){
                continue;
            }
           
            int now = v[i];
            int next = v[i+1];

            if(matrix[now][next] != 1){
                flag = false;
                break;
            } 
        }
        if(flag == true){
            count++;
        }
    } while(next_permutation(v.begin(), v.end()));

    printf("%d\n", count);

    return 0;
}

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

public class Main {
	
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		String s = in.readString(); 
		StringBuilder ans = new StringBuilder();
		for(int i = 0; i<s.length(); i+=2) {
			ans.append(s.charAt(i));
		}
		System.out.println(ans);
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

Measured memory_bytes: 19668
#include <bits/stdc++.h>
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i,s,n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i,s,l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC int __tc; cin >> __tc; FOR(case_num,1,__tc+1)
#define TEST(x,i) ((x)&(1ll<<(i)))
#define SET(x,i) ((x)|(1ll<<(i)))
#define FLIP(x,i) ((x)^(1ll<<(i)))
#define CLEAR(x,i) ((x)&~(1ll<<(i)))
const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

template <typename T> void print_vec(const vector<T>& v) {
	for(int i = 0; i < SZ(v); i++) {
		if (i) cout << " ";
		cout << v[i];
	}
	cout << "\n";
}

inline ll floorDiv(ll x, ll y) {
	ll d = x / y;
	ll r = x % y;
	return r ? (d - ((x < 0) ^ (y < 0))) : d;
}

ll ceilDiv(ll x, ll y) {
	return -floorDiv(-x,y);
}

bool predicate(ll mid) {
	return mid>10;
}

ll bin_search(ll lo, ll hi) {
	int sign = lo < hi ? 1 : -1;
	lo*=sign;
	hi*=sign;
	hi++;
	while(lo < hi) {
		ll mid = floorDiv(lo+hi,2);
		if (!predicate(sign*mid)) {
			lo = mid+1;
		} else {
			hi = mid;
		}
	}
	return sign*lo;
}
const ll MOD = 1000000007;
const int MAXN = 100005;

int seen[MAXN];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	memset(seen,-1,sizeof seen);
	
	ll n, x, m;
	cin >> n >> x >> m;
	
	ll a = x;
	ll rep = -1;
	seen[x]=1;
	int c = 2;
	while(true){
		a = (a*a)%m;
		if (seen[a] > 0){
			rep = a;
			break;
		}
		seen[a]=c;
		c++;
	}
	c--;
	ll ans = 0;
	
	ll s = 0;
	
	for (ll i = 1; i < m; i++){
		if (seen[i] > 0) {
			if (seen[i]<seen[rep]) {
				ans+=i;
			} else {
				s+=i;
			}
		}
	}
	
	n-=seen[rep]-1;
	c-=seen[rep]-1;
	
	ans+=n/c*s;
	n%=c;
	a = rep;
	for (int i = 0; i < n; i++){
		ans+=a;
		a = (a*a)%m;
	}
	cout << ans << "\n";
	
}


Measured memory_bytes: 4036
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

S = input()
N = len(S)

ans = 0
for i in range(N):
    if S[i] not in ["A", "C", "G", "T"]:
        continue
    s = S[i]
    for j in range(i+1, N):
        if S[j] not in ["A", "C", "G", "T"]:
           break 
        s += S[j]
    ans = max(ans, len(s))
print(ans)

Measured memory_bytes: 3064
void main() {
	auto ip = readAs!(int[]), N = ip[0], T = ip[1];
	int[] times;
	foreach(i; 0..N) {
		auto ip2 = readAs!(int[]), c = ip2[0], t = ip2[1];
		if(t <= T) times ~= c;
	}
	if(times.length != 0) writeln(times.reduce!min);
	else writeln("TLE");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
E = 0
D = 0
C = 0
while True :
    a, b, c = map(int, input().split())
    if a + b <= c or b + c <= a or c + a <= b :
        break
    
    x = max(a, b, c)
    z = min(a, b, c)
    y = a + b + c - x - z
    if x**2 == y**2 + z**2 :
        C += 1
    elif x**2 < y**2 + z**2 :
        E += 1
    else :
        D += 1
        
print(C+E+D, C, E, D)


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

#define M_PI 3.14159265358979323846

using namespace std;

//typedef
//-------------------------#include <bits/stdc++.h>

#define M_PI 3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}
inline int readInt()
{
    int x;
    scanf("%d", &x);
    return x;
}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//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) int((a).size())
#define SQ(a) ((a) * (a))
#define EACH(i, c) for (typeof((c).begin()) 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, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-8;

#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const int INF = 2147483647;

const int dxy[5] = {-1, 0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);

    vector<vector<int>> G(100010);
    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);
    }

    int S, T;
    cin >> S >> T;
    S--;
    T--;

    vector<vector<int>> d(N, vector<int>(5, (1 << 30)));
    d[S][0] = 0;

    queue<pair<int, int>> q;
    q.push({S, 0});

    while (q.size())
    {
        auto p = q.front();
        q.pop();

        int v = p.first, s = p.second;

        for (int i = 0; i < G[v].size(); i++)
        {

            int u = G[v][i];
            if (d[u][(s + 1) % 3] == (1 << 30))
            {
                if (s + 1 == 3)
                {
                    d[u][0] = d[v][s] + 1;
                }
                else
                {
                    d[u][s + 1] = d[v][s];
                }
                q.push({u, (s + 1) % 3});
            }
        }
    }
    if (d[T][0] == 1 << 30)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << d[T][0] << endl;
    }
    return 0;
}


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

int main() {
    char c;
    cin >> c;

    switch (c) {
    case 'a':
    case 'i':
    case 'u':
    case 'e':
    case 'o':
        cout << "vowel" << endl;
        break;
    default:
        cout << "consonant" << endl;
        break;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <memory>
#include <utility>

template <class Key, class T> class splay_associative_array {
public:
	using key_type = Key;
	using value_type = T;
	using reference = value_type &;

private:
	class node_type {
	public:
		typename splay_associative_array::key_type key;
		typename splay_associative_array::value_type value;
		::std::unique_ptr<node_type> left, right;
		node_type(const key_type &key) : key(key), value(), left(), right() {}
	};
	using pointer = ::std::unique_ptr<node_type>;

	pointer root;

public:
	splay_associative_array() : root() {}

	reference operator[](const key_type &key) {
		pointer left, right;
		pointer *next_l = &left, *next_r = &right;
		while (1) {
			if (!root)
				root = ::std::make_unique<node_type>(key);
			if (!(root->key <= key)) {
				if (!root->left)
					root->left = ::std::make_unique<node_type>(key);
				if (!(root->left->key <= key)) {
					*next_r = ::std::move(root->left);
					root->left = ::std::move((*next_r)->right);
					(*next_r)->right = ::std::move(root);
					next_r = &(*next_r)->left;
					root = ::std::move(*next_r);
				}
				else if (!(key <= root->left->key)) {
					*next_r = ::std::move(root);
					next_r = &(*next_r)->left;
					*next_l = ::std::move(*next_r);
					next_l = &(*next_l)->right;
					root = ::std::move(*next_l);
				}
				else {
					*next_r = ::std::move(root);
					next_r = &(*next_r)->left;
					root = ::std::move(*next_r);
				}
			}
			else if (!(key <= root->key)) {
				if (!root->right)
					root->right = ::std::make_unique<node_type>(key);
				if (!(root->right->key <= key)) {
					*next_l = ::std::move(root);
					next_l = &(*next_l)->right;
					*next_r = ::std::move(*next_l);
					next_r = &(*next_r)->left;
					root = ::std::move(*next_r);
				}
				else if (!(key <= root->right->key)) {
					*next_l = ::std::move(root->right);
					root->right = ::std::move((*next_l)->left);
					(*next_l)->left = ::std::move(root);
					next_l = &(*next_l)->right;
					root = ::std::move(*next_l);
				}
				else {
					*next_l = ::std::move(root);
					next_l = &(*next_l)->right;
					root = ::std::move(*next_l);
				}
			}
			else {
				*next_l = ::std::move(root->left);
				root->left = ::std::move(left);
				*next_r = ::std::move(root->right);
				root->right = ::std::move(right);
				return root->value;
			}
		}
	}
};

#include <iostream>

int main() {
	using i64 = long long;
	int n;
	::std::cin >> n;

	splay_associative_array<i64, i64> mp;
	i64 sum = 0, ans = 0;
	mp[0] = 1;

	while (n--) {
		int a;
		::std::cin >> a;
		
		sum += a;
		ans += mp[sum]++;
	}

	::std::cout << ans << ::std::endl;

	return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

int main()
{
    int a, b;
    char op;
    cin >> a >> op >> b;
    int x;
    while(op != '?'){
        if(op == '+'){
            x = a + b;
        }else if(op == '-'){
            x = a - b;
        }else if(op == '*'){
            x = a * b;
        }else if(op == '/'){
            x = a / b;
        }else{
            
        }
        cout << x << endl;
        cin >> a >> op >> b;
    }
        
    //int ;
//  cout <<  << endl;
//  printf("%f\n",x);
}


Measured memory_bytes: 3084
#include <iostream>
#include <string>
using namespace std;
int main(void){
int a,b,c,d;
    cin>>a>>b>>c;
    d=a*100+b*10+c;
    if(d%4==0){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    
}


Measured memory_bytes: 256
/*Author : Kartik Bansal
 *Date : 07/09/19
 *Time : 16:14 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
#define tc int t ;cin>>t ;while(t--)
#define pb push_back
#define FOR(i,n) for(int i =0;i<n;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin() , v.end()
#define sort(v) sort(all(v))
#define vi  vector<int>
#define vll  vector<long long >
#define inf INT_MAX
#define minf INT_MIN
int32_t main()
{
  ios::sync_with_stdio(0) ;
  cin.tie(0) ; cout.tie(0) ;


int a,b,c ,d ;
cin>>a>>b>>c>>d ;
int dx = c-a ;
int dy = d-b ;
cout<<string(dx , 'R')<<string(dy , 'U') ;
cout<<string(dx , 'L')<<string(dy , 'D') ;
cout<<'D'<<string(dx+1 , 'R')<<string(dy+1 , 'U')<<'L' ;
cout<<'U'<<string(dx+1 , 'L')<<string(dy+1 , 'D')<<'R' ;  


// cout<<string(2 , 'r') ;


  return 0 ;
}


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

#define ll long long
#define F first
#define S second
#define ii pair < int , int >
#define ever (;;)

const int N = 3010;

int n,a[N];
ll dp[N][N];

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);

    for(int len=1;len<=n;len++)
        for(int i=1;i<=n-len+1;i++)
        {
            int l = i;
            int r = i+len-1;

            dp[l][r] = max( a[l] - dp[l+1][r]  , a[r] - dp[l][r-1] );
        }

    printf("%lld\n",dp[1][n]);
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int lowlink(int c, int u, int p, int& num, vector<vector<PII>>& G, VI& ord, VI& low){
  int res = 0;
  ord[u] = low[u] = num++;
  
  for(auto&& e: G[u]){
	int to = e.FF;
	if(to == p) continue;
	if(ord[to] < 0){
	  res += lowlink(c, to, u, num, G, ord, low);
	  low[u] = min(low[u], low[to]);
	  if(ord[u] < low[to] && c == e.SS)
		++res;
	}
	else{
	  low[u] = min(low[u], ord[to]);
	}
  }

  return res;
}

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

  int N, M;
  cin >> N >> M;
  vector<vector<PII>> G(N);
  vector<vector<PII>> es(10001);
  REP(i,M){
	int u, v, c;
	cin >> u >> v >> c;
	--u;
	--v;
	es[c].EB(u, v);
  }

  int ans_num = 0, ans_sum = 0;
  for(int c=1;c<=10000;++c){
	for(auto&& e: es[c]){
	  G[e.FF].EB(e.SS, c);
	  G[e.SS].EB(e.FF, c);
	}
	int b = 0;
	
	VI ord(N,-1), low(N,-1);
	REP(i,N){
	  if(ord[i] >= 0) continue;
	  int n = 0;
	  b += lowlink(c, i, -1, n, G, ord, low);
	}
	ans_num += b;
	ans_sum += b * c;
  }
  cout << ans_num << " " << ans_sum << endl;

  return 0;
}

Measured memory_bytes: 4928
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
string a, b;
int main(){
    cin >> a >> b;
    int c = stoi(a+b);
    int d = sqrt(c);
    if(c == d*d) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}
         

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

class LazySegTree{
private:
	int n;
	vector<ll> node, lazy;
	vector<bool> lazyFlag;
public:
	LazySegTree(vector<ll> v){
		int sz = v.size();
		n = 1; while(n < sz) n *= 2;
		node.resize(2*n-1, 0);
		lazy.resize(2*n-1, 0);
		lazyFlag.resize(2*n-1, false);
		REP(i, sz) node[i+n-1] = v[i];
		for(int i = n-2;i >= 0;i--) node[i] = node[2*i+1]+node[2*i+2];
	}

	void eval(int k, int l, int r){
		if(lazyFlag[k]){
			node[k] += lazy[k] * (r-l);
			if(r-l > 1){
				lazy[2*k+1] += lazy[k];
				lazy[2*k+2] += lazy[k];
				lazyFlag[2*k+1] = lazyFlag[2*k+2] = true;
			}
			lazy[k] = 0;
			lazyFlag[k] = false;
		}
	}

	void add(int a, int b, ll x, int k=0, int l=0, int r=-1){
		if(r < 0) r = n;
		eval(k, l, r);
		if(b <= l || r <= a) return;

		if(a <= l && r <= b){
			lazy[k] += x;
			lazyFlag[k] = true;
			eval(k, l, r);
		}else{
			add(a, b, x, k*2+1, l, (l+r)/2);
			add(a, b, x, k*2+2, (l+r)/2, r);
			node[k] = node[k*2+1] + node[k*2+2];
		}
	}

	ll query(int a, int b, int k=0, int l=0, int r=-1){
		if(r < 0) r = n;
		eval(k, l, r);

		if(b <= l || r <= a) return 0;
		if(a <= l && r <= b) return node[k];

		return query(a, b, k*2+1, l, (l+r)/2) + query(a, b, k*2+2, (l+r)/2, r);
	}
};

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, q;
	cin >> n >> q;
	LazySegTree sg(vector<ll>(n, 0));
	REP(i, q){
		int k;
		cin >> k;
		if(k == 0){
			int s, t, x;
			cin >> s >> t >> x;
			sg.add(s-1, t, x);
		}else{
			int s, t;
			cin >> s >> t;
			cout << sg.query(s-1, t) << endl;
		}
	}
}

Measured memory_bytes: 7844
n = int(input())
w = list(map(int, input().split()))
s = 0
for i in w:
    s += i
mindiff = s
s2 = 0
for i in w:
    s2 += i
    if abs(s - s2 - s2) < mindiff:
        mindiff = abs(s - s2 - s2)
print(mindiff)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <functional>
#include <random>
using namespace std;

const int MOD = 1e9 + 7;
const int INF = 999999999;

long long b, mon, mmon;
int main() {
	string h;
	cin >> h;
	for (int i = 0; i < h.length(); ++i) {
		if (h[i] == 'B') {
			b += i;
			++mon;
		}
	}
	for (int i = 0; i < mon; ++i) {
		mmon += h.length() - i - 1;
	}
	cout << mmon - b << endl;
}

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

int main ()
{


int x ;
int z;
cin >> x>>z;
if (x*z>=x-z&&x*z>=x+z){
    cout << x*z;
}
else if (x-z>=x*z&&x-z>=z+x){
    cout << x-z;
}
else if (x+z>=x-z&&x+z>=x*z)
cout << x+z;




return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll x, a, b; cin >> x >> a >> b;
    cout << ((abs(x-a)>abs(x-b)) ? "B" : "A") << endl;
}

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

  
int main () 
{ 
    //stack <int> s; 
    double n;
    cin>>n;
    double c=2*3.14159*n;
    cout<<c<<endl;
         
    
     /*for(int i=1;i<=n;i++)
     cout<<a[i]<<" ";
     cout<<endl;*/
  
    return 0; 
} 

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

int main() {
int n, k;
  string s;
  cin >> n >> k >> s;
  if(s.at(k-1) == 'A') s.at(k-1) = 'a';
  if(s.at(k-1) == 'B') s.at(k-1) = 'b';
  if(s.at(k-1) == 'C') s.at(k-1) = 'c';
  cout << s << endl;
}

Measured memory_bytes: 256
"""
これは、Nを構成する素因数の種類の数はいくつか？という問題と等価では？
いや、ちょっと違うな。
2の素因数が3つあれば、2,4で割れる。
Nを素因数分解して、各素因数の数をカウント。
"""
from collections import Counter
N = int(input())
primes = []
d = 2
while d**2 <= N:
    if N%d == 0:
        primes.append(d)
        N //= d
    else:
        d += 1
if N != 1:
    primes.append(N)
count = Counter(primes)


ans = 0
for v in count.values():
    f = 1
    while v >= f:
        ans += 1
        v -= f
        f += 1

print(ans)


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


int main(int argc, char* argv[])
{
    int t;
    cin >> t;
    int x = 0;
    for (int i = 1; i < t+1; i++)
    {
        x = i;
        if(x%3 == 0)
        {
            cout << " " << i;
            continue;
        }else
        {
            while(x)
            {
                if(x%10 == 3)
                {
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 3104
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt(), G = sc.nextInt();
		long[] p = new long[D]; long[] c = new long[D];
		for(int i = 0; i < D; i++) {
			p[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		/* コンプリートする問題の組み合わせを全列挙して、Greedyに問題を解く */
		long ans = Long.MAX_VALUE;
		for(int S = 0; S < (1<<D); S++) {
			// コンプリートする問題の組み合わせがSのとき
			long score = 0, solved = 0;
			// コンプリートする問題は全部とく
			for(int i = 0; i < D; i++) {
				if(((S >> i) & 1) == 1) {
					score += c[i] + p[i] * (long)(100 * (i + 1));
					solved += p[i];
				}
			}
			if(score >= G) {
				ans = Math.min(ans, solved);
				continue;
			}
			// コンプリートしてもまだ足りない時 -> コンプリートしてないやつの上から順に解いていく
			for(int i = D - 1; i >= 0; i--) {
				if(((S >> i) & 1) == 0) {
					// コンプリートしてないやつ
					long prob = p[i];
					while(prob > 1 && score < G) {
						prob--;
						score += 100 * (i + 1);
						solved++;
					}
				}
				if(score >= G) {
					ans = Math.min(ans, solved);
					break;
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23636