akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
int main(void)
{
    char S[3];
    scanf("%c%c%c", &S[0], &S[1], &S[2]);
    int ans = 700;
    for (int i = 0; i < 3; i++)
    {
        if (S[i] == 'o'){
            ans += 100;
        }
    }
    printf("%i\n", ans);
}

Measured memory_bytes: 128
N = int(input())
i = 0
dic = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
while i < N:
    string = input()
    dic[string] += 1
    i += 1

for key in dic:
    print('{} x {}'.format(key, dic[key]))

Measured memory_bytes: 9124
H, W = map(int, input().split())

G = []
for _ in range(H):
    g = []
    line = input()
    for i in range(W):
        g.append(line[i])
    G.append(g)

# 左に何マス行けるか
G_left = [[0] * W for _ in range(H)]
for h in range(H):
    cnt = 0
    for w in range(W):
        if G[h][w] == "#":
            cnt = 0
            G_left[h][w] = 0
        elif G[h][w] == ".":
            cnt += 1
            G_left[h][w] = cnt
# print(G_left)

# 右に何マス行けるか
G_right = [[0] * W for _ in range(H)]
for h in range(H):
    cnt = 0
    for w in range(W - 1, -1, -1):
        if G[h][w] == "#":
            cnt = 0
            G_right[h][w] = 0
        elif G[h][w] == ".":
            cnt += 1
            G_right[h][w] = cnt
# print(G_right)

# 上に何マス行けるか
G_up = [[0] * W for _ in range(H)]
for w in range(W):
    cnt = 0
    for h in range(H):
        if G[h][w] == "#":
            cnt = 0
            G_up[h][w] = 0
        elif G[h][w] == ".":
            cnt += 1
            G_up[h][w] = cnt
# print(G_up)

# 下に何マス行けるか
G_down = [[0] * W for _ in range(H)]
for w in range(W):
    cnt = 0
    for h in range(H - 1, -1, -1):
        if G[h][w] == "#":
            cnt = 0
            G_down[h][w] = 0
        elif G[h][w] == ".":
            cnt += 1
            G_down[h][w] = cnt
# print(G_down)
ans = 0
for h in range(H):
    for w in range(W):
        tmp = G_left[h][w] + G_right[h][w] + G_up[h][w] + G_down[h][w] - 3
        ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 360940
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */
void no(){
  cout << -1 << endl;
  exit(0);
}

int main() {
  string s; cin >> s;
  int cnt[26] = {0};
  REP(i, s.size()){
    cnt[s[i]-'a']++;
  }
  REP(i, 26){
    if(cnt[i] == 0){
      char ch = 'a' + i;
      cout << s + ch << endl;
      return 0;
    }
  }
  //全種類出現
  
  //zyx...
  REP(i, s.size()-1){
    if(s[i] - 1 != s[i+1]) break;
    if(i == s.size()-2) no();
  }
  //それ以外
  string t = s;
  next_permutation(ALL(t));
  REP(i, s.size()){
    if(s[i] == t[i]) cout << s[i];
    else{
      cout << t[i];
      break;
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	plist := make([]int, n)
	plistorg := make([]int, n)

	for i := 0; i < n; i++ {
		plist[i] = nextInt()
		plistorg[i] = plist[i]
	}

	sort.Ints(plist)

	cnt := 0
	for i := 0; i < n; i++ {
		if plistorg[i] != plist[i] {
			cnt++
		}
	}

	if (cnt == 2) || (cnt == 0) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

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

    for(int i = 1;i <= N;i++)
    {
        if(i % 3 != 0)
        {
            if(i % 5 != 0)
            {
                ans += i;
            }
        }
    }

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

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}


int main(){
  ll n,a[200010];
  ll max1=-100,max2=-100,v;
  cin >> n;
  FOR(i,n){
    cin >> a[i];
    if(max1<a[i]){
      max2=max1;
      v=i;
      max1=a[i];
      
    }else{
      if(max2<a[i])max2=a[i];
    }
  }

  FOR(i,n){
    if(i!=v){
      cout << max1 << endl;
    }else{
      cout << max2 << endl;
    }
  }
  
}


Measured memory_bytes: 3200
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int main(){
  string s,t; cin >> s >> t;
  int ns = s.size(); int nt = t.size();
  string sd = s+s; int nsd = sd.size();
  vector<int> table[26];
  
  //テーブル作成
  rep(i,nsd){
    int alpha = sd[i] - 'a';
    table[alpha].push_back(i);
  }
  
  ll ans = 0; int p = 0; //最初の検索時のためにs最後尾からスタート
  rep(i,nt){
    int search = t[i] - 'a';
    if(table[search].size() == 0){
      puts("-1");
      return 0; //文字が存在しないので終了
    }else{
      p = *lower_bound(table[search].begin(),table[search].end(),p)+1;
      if(p >= ns){
        p -= ns;
        ans += ns;
      }
    }
  }
  ans += p;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1980
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define next(a) ( ((a)+1)%SIZE )
#define ABS(x) ( (x)>0 ? x : -(x) )
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )
#define MAX(x,y) ( (x) > (y) ? (x) : (y) )
#define INF 1000000000
#define SIZE 100000

typedef struct queue
{
	int front;
	int rear;
	int data[200];
}queue;

void init(queue* p)
{
	p->front = 0;
	p->rear = 0;
}

void enqueue(queue *p,int x)
{
	if (next(p->rear) == p->front)
		printf("OVERFLOW!\n");
	p->data[p->rear] = x;
	p->rear = next(p->rear);
}

int dequeue(queue *p)
{
	int x;

	if (p->front == p->rear)
		printf("NO DADA\n");

	x = p->data[p->front];
	p->front = next(p->front);

	return x;
}

int empty(queue *p)
{
	return p->front == p->rear;
}

void print(char* str, int a, int b)
{
	int i;

	for (i = a; i <= b; i++)
		printf("%c", str[i]);
	printf("\n");
}

void reverse(char* str, int a, int b)
{
	int i,j=0;
	char t;

	for (i = a; i <= (a + b) / 2; i++)
	{
		t = str[i];
		str[i] = str[b - j];
		str[b - j] = t;
		j++;
	}
}

void replace(char* str, int a, int b, char* temp)
{
	int i, j=0;

	for (i = a; i <= b; i++)
	{
		str[i] = temp[j];
		j++;
	}
}

double rad(int C)
{
	return M_PI * C / 180;
}

double distance(int* a, int* b, int n, int p)
{
	double sum = 0.0;

	int i, j;

	int max = 0;

	for (i = 0; i < n; i++)
	{
		sum += pow(ABS(a[i] - b[i]), p);

		if (ABS(a[i] - b[i]) > max)
			max = ABS(a[i] - b[i]);
	}

	if (p == INF)
		return max;

	return pow(sum, (double)1 / p);
}

typedef struct Dice
{
	int num[6];
}Dice;

void ROT(Dice* p,char R)
{
	int num2[6];
	int i;

	for (i = 0; i < 6; i++)
		num2[i] = p->num[i];

	if (R == 'E')
	{
		p->num[0] = num2[3];
		p->num[1] = num2[1];
		p->num[2] = num2[0];
		p->num[3] = num2[5];
		p->num[4] = num2[4];
		p->num[5] = num2[2];
	}

	if (R == 'S')
	{
		p->num[0] = num2[4];
		p->num[1] = num2[0];
		p->num[2] = num2[2];
		p->num[3] = num2[3];
		p->num[4] = num2[5];
		p->num[5] = num2[1];
	}

	if (R == 'W')
	{
		p->num[0] = num2[2];
		p->num[1] = num2[1];
		p->num[2] = num2[5];
		p->num[3] = num2[0];
		p->num[4] = num2[4];
		p->num[5] = num2[3];
	}

	if (R == 'N')
	{
		p->num[0] = num2[1];
		p->num[1] = num2[5];
		p->num[2] = num2[2];
		p->num[3] = num2[3];
		p->num[4] = num2[0];
		p->num[5] = num2[4];
	}
}

int main()
{
	Dice dice;
	int n;
	char str[150];

	int i, j;

	for (i = 0; i < 6; i++)
		scanf("%d", &dice.num[i]);

	scanf("%s", str);

	for (i = 0; i < strlen(str); i++)
		ROT(&dice, str[i]);

	printf("%d\n", dice.num[0]);

	return 0;
}



Measured memory_bytes: 2100
#include <stdio.h>

// positive only
int get_int() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return -1;
    while(47 < c && c < 58) {
        n = 10 * n + (c & 0xf);
        c = getchar_unlocked();
    }
    return n;
}
int linear_search(int key, int *arr, int N) {
    arr[N] = key;
    int i = 0;
    while(arr[i++] != key) {};
    return i > N ? 0 : 1;
}
int main(int argc, char **argv) {
    int n = get_int();
    int s[10001];
    for(int i = 0; i < n; ++i) {
        s[i] = get_int();
    }
    int q = get_int();
    int cnt = 0;
    int t;
    while(q--) {
        t = get_int();
        linear_search(t, s, n) && cnt++;
    }
    printf("%d\n", cnt);
}



Measured memory_bytes: 2072
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    while (1) {
        int h,w;
    
        scanf("%d %d",&h,&w);
    
        if(h==0 && w==0){
            break;
        }
        
        int i,j;
        for (i=0; i<h; i++) {
            for(j=0;j<w;j++){
                if((i+j) % 2 == 1){
                    printf(".");
                }
                else{
                    printf("#");
                }
            }
            printf("\n");
        }
        
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
import Data.Ratio
import Control.Monad
import Data.Maybe
import Data.List
import qualified Data.ByteString.Char8 as BS

main = abc159c

abc159c = do
  [l] <- getIntList
  print (fromRational (calcV l) :: Double)

calcV l = (l % 3)^3

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine

Measured memory_bytes: 508
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<vector>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define FOR(i,s,e) for (int i=s;i<e;i++)
#define FOE(i,s,e) for (int i=s;i<=e;i++)
#define FOD(i,s,e) for (int i=s;i>=e;i--)
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define eps 1e-9
#define mp make_pair

int n;
LL ans,tmp;

LL gcd(LL a,LL b) {
	if (a==0) return b;
	else if (b==0) return a;
	else {
		if (a>b) return gcd(a%b,b);
		else return gcd(a,b%a);	
	}
}

int main () {
	scanf("%d",&n);
	scanf("%lld",&ans);
	FOE(i,2,n) {
		scanf("%lld",&tmp);
		//printf("!%lld\n",ans);
		ans/=gcd(ans,tmp);
		//printf("%lld %lld\n",ans,tmp);
		ans*=tmp;
	}
	printf("%lld\n",ans);
	return 0;	
}

Measured memory_bytes: 128
program main
  implicit none
 
1 format(':(')
2 format('Yay!')
 
  integer a, b, c, d, e, k
  
  read(*,*) a
  read(*,*) b
  read(*,*) c
  read(*,*) d
  read(*,*) e
  read(*,*) k
  
  if (e - a > k) then 
    write(*,1)
  else
    write(*,2)
  end if
  
end program main

Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<ll, ll> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 55;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    string s, t;
    cin >> s >> t;
    cout << t << s;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
ll N;
  cin>>N;
  vector<pair<ll,ll>> vec(N);
  for(ll i=0;i<N;i++) {
ll x,y;
    cin>>x>>y;
    vec[i]=make_pair(x,y);
  }
  vector<ll> A(N);
  for(ll i=0;i<N;i++) {
A[i]=i+1;
  }
  
  double ans=0;
  do {
for(ll i=0;i<N-1;i++) {
  ll X=(vec[A[i+1]-1].first-vec[A[i]-1].first)*(vec[A[i+1]-1].first-vec[A[i]-1].first);
  ll Y=(vec[A[i+1]-1].second-vec[A[i]-1].second)*(vec[A[i+1]-1].second-vec[A[i]-1].second);

  ans+=sqrt(X+Y);
}
  }while(next_permutation(all(A)));
  
  ll t=1;
  for(ll i=1;i<=N;i++) {
    t*=i;
  }

  cout<<fixed<<setprecision(8);
  cout<<ans/t<<endl;
}


    
    
    
    
    
    
    
    
    
    
  
  

Measured memory_bytes: 3860
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define M 1000000
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;
    cin>>n;
    ll count=0;
    ll y=100;
    while(1)
    {
       y= floor(y*0.01)+y;
        count++;
        if(y>=n)
        break;
        
        
        
        
    }
    cout<<count;
    
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n, k;
    cin >> n >> k;
    string a;
    cin >> a;
    vl b(1, 1);
    REP(i, 1, n) {
        if(a[i] == a[i-1]) b.back()+=1;
        else b.push_back(1);
    }
    ll ans = 0LL;
    if(a[0] == '0') {
        ll sum = 0LL;
        int i = 0;
        int m = b.size();
        int cnt = 0;
        while(i < m && cnt < k) {
            // cout <<" " << i << " " << sum;
            sum += b[i];
            if(i+1 < m) sum += b[i+1];
            i += 2; 
            ++cnt;
            // cout << "->" << sum << endl;
        }
        ans = sum;
        int j = -1;
        while(i < m) {
            if(j >= 0) sum -= b[j];
            sum -= b[j+1];
            sum += b[i];
            if(i+1<m) sum += b[i+1];
            i += 2;
            j += 2;
            ans = max(ans, sum);
        }
    }
    else {
        ll sum = b[0];
        int i = 1;
        int m = b.size();
        int cnt = 0;
        while(i < m && cnt < k) {
            // cout << i << " " << sum << " -> ";
            sum += b[i];
            if(i+1 < m) sum += b[i+1];
            i += 2;
            ++cnt;
            // cout << sum << endl;
        }
        ans = sum;
        int j = 0;
        while(i < m) {
            // cout << i << " " << sum << " => ";
            sum -= b[j];
            sum -= b[j+1];
            sum += b[i];
            if(i+1<m) sum += b[i+1];
            i += 2;
            j += 2;
            ans = max(ans, sum);
            // cout << sum << endl;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int H,W,N;
    int i,j,k;
    scanf("%d %d",&H,&W);
    scanf("%d",&N);

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

    k=0;
    int tmp[300];
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            tmp[j]=k+1;
            if(--a[k]==0)k++;
        }
        if(i%2)for(j=0;j<W/2;j++){
            tmp[j]+=tmp[W-1-j];
            tmp[W-1-j]=tmp[j]-tmp[W-1-j];
            tmp[j]-=tmp[W-1-j];
        }
        for(j=0;j<W;j++){
            if(j)putchar(' ');
            printf("%d",tmp[j]);
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      long a = sc.nextLong();
      long b = sc.nextLong();
      long c = sc.nextLong();
      long d = sc.nextLong();
      
      // 計算
      long max = a*c;
      if(max < a*d){
        max = a*d;
      }
      if(max < b*c){
        max = b*c;
      }
      if(max < b*d){
        max = b*d;
      }
      
      // 出力
      System.out.println(max);
    }
    
}

Measured memory_bytes: 35628
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int f(int x)
{
	return pow(x, 2);
}

int main()
{
	int n;
	while (cin >> n) {
		long long int sum = 0;
		for (int i = n; i <= 600 - n; i += n)
			sum += f(i)*n;
		cout << sum << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
	
	int n;
	map<int , int> mp;
	cin >> n;
	
	for(int i = 0; i < n; i ++){
		int t;
		cin >> t;
		mp[t]++;
	}
	
	int fg = 0;
	for(auto it: mp){
		if(it.second >= 2){
			fg = 1;
			cout << "NO";
			break;
		}
	}
	
	if(!fg) cout << "YES";
	
	return 0;
}

Measured memory_bytes: 9728
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <unordered_map>
#include <map>
using namespace std;

typedef long long ll;

#include <vector>
#include <string>
#include <iostream>

using ull = unsigned long long;
struct RollingHash {
  static const ull MASK30 = (1UL << 30) - 1;
  static const ull MASK31 = (1UL << 31) - 1;
  static const ull MOD = (1UL << 61) - 1;
  static const ull OFFSET = MOD * ((1UL << 3) - 1);
  static const unsigned int BASE = 10007;
  std::vector<ull> pows, hashed;
  RollingHash(const std::string &s) {
    int sz = (int) s.size();
    pows.resize(sz+1, 0);
    hashed.resize(sz+1, 0);
    pows[0] = 1;
    for (int i = 0; i < sz; i++) {
      pows[i+1] = CalcMod(Mul(pows[i], BASE));
      hashed[i+1] = CalcMod(Mul(hashed[i], BASE) + s[i]);
      // std::cerr << s[i] << " " << i << " " << hashed[i+1] << std::endl;
    }
  }

  // [l, r) の区間のhashを求める
  ull get(int l, int r) {
    return CalcMod(hashed[r] + OFFSET - Mul(hashed[l], pows[r-l]));
  }

  static ull Mul(ull l, ull r) { 
    ull lu = l >> 31;
    ull ld = l & MASK31;
    ull ru = r >> 31;
    ull rd = r & MASK31;
    ull c = ld * ru + lu * rd;
    return ((lu * ru) << 1) + ld * rd + ((c & MASK30) << 31) + (c >> 30);
  }

  static ull Mul(ull l, unsigned int r) { 
    ull lu = l >> 31;
    ull rd = r & MASK31;
    ull c = lu * rd;
    return (l & MASK31) * rd + ((c & MASK30) << 31) + (c >> 30);
  }

  static ull CalcMod(ull x) { 
    x = (x & MOD) + (x >> 61);
    if (x >= MOD) x -= MOD;
    return x;
  }
};

int main() {
  int n; cin >> n;
  vector<string> ls(n);
  // unordered_map<string, map<char, int> > dic;
  unordered_map<ll, map<char, int> > dic;
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    cin >> ls[i];
    reverse(ls[i].begin(), ls[i].end());
  }
  sort(ls.begin(), ls.end(), [&](auto& l, auto &r){
    return l.size() < r.size();
  });
  for (auto & s: ls) {
    RollingHash rh(s);
    string t = "";
    vector<int> cnt(26, 0);
    for (int i = 0; i < s.size(); ++i) {
      char c = s[i];
      cnt[c-'a'] += 1;
    }
    for (int i = 0; i < s.size(); ++i) {
      ll h = 0;
      if (i > 0) h = rh.get(0, i);
      // if (dic.find(t) != dic.end()) { 
      if (dic.find(h) != dic.end()) { 
        // cerr << s << " " << t << endl;
        for (auto it: dic[h]) {
          if (cnt[it.first-'a'] > 0) { 
            // cerr << it.first << " " << it.second << endl;
            ans += it.second;
          }
        }
      }
      if (i < s.size()-1) {
        t += s[i];
        --cnt[s[i]-'a'];
      }
      else {
        dic[h][s[i]] += 1;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 31636
n = int(input())
d = list(map(int, input().split()))
res = 0
for i in range(n - 1):
    if d[i] == (i + 1):  # もし同じ子がいたら
        d[i], d[i + 1] = d[i + 1], d[i]
        res += 1
if d[n-1] == len(d):
    d[n-2], d[n-1] = d[n-1], d[n-2]
    res += 1
print(res)


Measured memory_bytes: 14008
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<set>
typedef long long ll;
using namespace std;
int main(){
    int n,m,a;
    ll b,ans=0;
    vector<pair<ll,int> > p;
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++){
        scanf("%d %lld",&a,&b);
        p.push_back(make_pair(b,a));
    }
    sort(p.begin(),p.end());
    set<int> s;
    for(int i=1;i<=m;i++){
        s.insert(i);
    }
    for(int i=n-1;i>=0;i--){
        decltype(s)::iterator it =s.lower_bound(p[i].second);
        if(it!=s.end()){
            ans+=p[i].first;
            s.erase(*it);
        }
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 6512
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;

const int MAXV = 100005;
const int MAXE = 150005;
const int INF = 1<<29;

struct BiparateMatching {
    int N, M, E, match[MAXV+1], dist[MAXV+1];
    int last[MAXE], prev[MAXE], to[MAXE];
    BiparateMatching(int n, int m) : N(n), M(m), E(0) {
        memset(last, -1, sizeof(last));
    }
    void add_edge(int x, int y) { // x \in [0, N), y \in [0, M)
        to[E] = y + N; prev[E] = last[x]; last[x] = E; E++;
    }
    bool bfs() {
        queue<int> q;
        for (int i=0; i<N; ++i) {
            if (match[i] == -1) {
                q.push(i); dist[i] = 0;
            } else dist[i] = INF;
        }

        bool ret = false;
        while(!q.empty()) {
            int v = q.front(); q.pop();
            for (int e = last[v]; e != -1; e = prev[e]) {
                if (match[to[e]] == -1) ret = true;
                else if (dist[match[to[e]]] == INF) {
                    dist[match[to[e]]] = dist[v] + 1;
                    q.push(match[to[e]]);
                }
            }
        }
        return ret;
    }
    bool dfs(int v) {
        for (int e = last[v]; e != -1; e = prev[e]) {
            bool update = false;
            if (match[to[e]] == -1) {
                match[to[e]] = v; match[v] = to[e];
                update = true;
            } else if (dist[match[to[e]]] == dist[v] + 1) {
                if (dfs(match[to[e]])) {
                    match[to[e]] = v; match[v] = to[e];
                    update = true;
                }
            }
            if (update) return true;
        }
        dist[v] = INF;
        return false;
    }
    int matching() {
        int ret = 0;
        memset(match, -1, sizeof(match));
        while(bfs()) {
            for (int i=0; i<N; ++i)
                if (match[i] == -1 && dfs(i)) ret++;
        }
        return ret;
    }
};

int gcd(int x, int y) {
    if (y == 0) return x;
    return gcd(y, x%y);
}

int b[501], r[501];
int main() {
    int m,n;
    while(scanf("%d %d", &m, &n), m|n) {
        BiparateMatching bm(m, n);
        for (int i=0; i<m; ++i) scanf("%d", &b[i]);
        for (int i=0; i<n; ++i) scanf("%d", &r[i]);
        for (int i=0; i<m; ++i) {
            for (int j=0; j<n; ++j)
                if (gcd(b[i], r[j]) > 1) bm.add_edge(i, j);
        }
        printf("%d\n", bm.matching());
    }
}

Measured memory_bytes: 2948
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
typedef long long ll;
const int INF = 1e9+1;
const int MOD = 2e9 + 9;
const ll LINF = 1e18;
using namespace std;

int kai(int n) {
	int w = 1;
	for(int i=1;i<=n;i++){
		w = w * i;
	}
	return w;
}

int main(){
	long long int n,m, cnt = 1;
	long long int ans = 1;
	
	cin >> n;
	m = n;
	for (int i = 0; i < m; i++) {
		if (n == 1)break;
		n = n / 2;
		ans += 2*cnt;
		cnt = 2 * cnt;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3596
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int dp[1010][1010];

int main() {
  int h, w;
  cin >> h >> w;
  char a[h][w];
  REP(i, h) REP(j, w) cin >> a[i][j];
  dp[0][0] = 1;
  REP(i, h) REP(j, w) {
    if (a[i][j] == '.') {
      dp[i + 1][j] += dp[i][j];
      dp[i + 1][j] %= MOD;
      dp[i][j + 1] += dp[i][j];
      dp[i][j + 1] %= MOD;
    }
  }
  cout << dp[h - 1][w - 1] << endl;
  return 0;
}

Measured memory_bytes: 5120
#include <iostream>
using ll = long long;
using namespace std;

/* initialize */
int n, A[500000], L[300000], R[300000], count;
/* main */
void merge(int A[],int left, int right){
    int mid = (left + right) / 2;
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; ++i)  L[i] = A[left+i];
    for (int j = 0; j < n2; ++j) R[j] = A[mid+j];
    L[n1] = R[n2] = INT32_MAX;
    int i = 0, j = 0;
    for ( int k = left; k < right; k++ ){
        count++;
        if (L[i] <= R[j]) A[k] = L[i++];
        else A[k] = R[j++];
    }
}

void mergeSort(int A[], int n, int left, int right){
    if(left+1 < right){
        mergeSort(A, n, left,(left+right)/2);
        mergeSort(A, n, (left+right)/2, right);
        merge(A, left, right);
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> A[i];
    mergeSort(A, n, 0, n);
    for (int j = 0; j < n; ++j) {
        if (j) cout << " ";
        cout << A[j];
    }
    cout << "\n";

    cout << count << "\n";
    return 0;
}


Measured memory_bytes: 6992
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)


LL a, b, c, k;

int main() {
	cin >> a >> b >> c >> k;
	if (k % 2 == 1) {
		cout << (a - b)*-1 << endl;
	}
	else {
		cout << a - b << endl;
	}
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,k;
    cin>>a>>b;
    k=(a+b)/2;
    if(abs(k-a)==abs(k-b))
        cout<<k<<endl;
    else
        cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


Measured memory_bytes: 3604
import java.awt.Point;
import java.awt.Polygon;
import java.awt.geom.Point2D;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String tmp = br.readLine();
			
			if(tmp == null){
				break;
			}
			
			String[] tmpArray = tmp.split(",");
			Point[] points = new Point[4];
			
			for(int i = 0; i < 4; i++){
				points[i] = new Point((int)(Double.parseDouble(tmpArray[i*2])*100000), (int)(Double.parseDouble(tmpArray[i*2+1])*100000));
			}
			
			boolean convex = false;
			for(int i = 0; i < 4; i++){
				Polygon triangle = new Polygon();
				for(int j = i; j < i + 4 ; j++){
					if(j%4 != (i + 2)%4){
						//System.out.println("add "+j%4);
						triangle.addPoint(points[j%4].x, points[j%4].y);
					}
				}
				if(triangle.contains(points[(i+2)%4])){
					convex = true;
					break;
				}
			}
			if(convex){
				System.out.println("NO");
			}
			else{
				System.out.println("YES");
			}
		}
	}

}

Measured memory_bytes: 27800
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    public static void Main(string[] args)
    {
        string s = Console.ReadLine();

        if (s == "Sunny")
            Console.WriteLine("Cloudy");
        else if (s == "Cloudy")
            Console.WriteLine("Rainy");
        else
            Console.WriteLine("Sunny");
    }
}


Measured memory_bytes: 11092
N = int(input())
S = input()

i = S[1:].count('E')
r = [i]

for n in range(1, N):
    if S[n] == 'E':
        i -= 1

    if S[n - 1] == 'W':
        i += 1
    r.append(i)

print(min(r))

Measured memory_bytes: 15564
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long z = sc.nextInt();
		long w = sc.nextInt();
		long[] array = new long[n];
		boolean teban = true; //真ならAの手番
		for(int j = 0;j < n;++j){
			array[j] = sc.nextLong();
		}
		if(n >= 2){
			System.out.println(Math.max(Math.abs(array[n-1] - w), Math.abs(array[n-2] - array[n-1])));
		}else{
			System.out.println(Math.abs(array[n-1] - w));
		}
	}
}

Measured memory_bytes: 27724
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main(void){

    ll N; cin>>N;
    vector<ll> A(N);
    vector<ll> sortedA(N);
    for (int i = 0; i < N; ++i) {
        cin>>A[i];
        int tmp=A[i];
        sortedA[i]=tmp-(i+1);
    }
    sort(sortedA.begin(), sortedA.end());
    ll mid = sortedA[N/2];
    ll ans=0;
    for (int i = 0; i < N; ++i) {
        ans += abs(A[i]-(mid+i+1));
    }
    cout<<ans<<endl;


}

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

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

int main()
{
    string s,t;cin >> s >> t ;
    map<string,int> m1; 
    map<string,int> m2; 

    int c1=1;
    int c2=1;
    string res1="";
    string res2="";
    for(int i=0;i<s.size();i++){
        if(m1[s.substr(i,1)]==0){
           m1[s.substr(i,1)]=c1;
           c1++;
        }
        if(m2[t.substr(i,1)]==0){
           m2[t.substr(i,1)]=c2;
           c2++;
        }
        res1 += to_string(m1[s.substr(i,1)]);
        res2 += to_string(m2[t.substr(i,1)]);
    }
    Yes(res1==res2)
}

Measured memory_bytes: 1584
x1,y1,x2,y2 =map(int,input().split())
def_x=x2-x1
def_y=y2-y1

print("U"*def_y+"R"*def_x+"D"*def_y+"L"*def_x+
      "L"+
      "U"*(def_y+1)+"R"*(def_x+1)+
      "D"+"R"+
      "D"*(def_y+1)+"L"*(def_x+1)+"U")

Measured memory_bytes: 3064
use proconio::{fastout, input};

const MOD: i64 = 998244353;
struct Combination {
    fact: Vec<i64>,
    fact_inv: Vec<i64>,
}
impl Combination {
    fn init(n: usize) -> Combination {
        let mut fact = vec![0 as i64; n];
        let mut fact_inv = vec![0 as i64; n];
        fact[0] = 1;
        fact[1] = 1;
        fact_inv[0] = 1;
        fact_inv[1] = 1;
        for i in 2..n {
            fact[i] = fact[i - 1] * i as i64 % MOD;
        }
        for i in 2..n {
            let k = i as i64;
            fact_inv[i] = fact_inv[(MOD % k) as usize] * (MOD - MOD / k) % MOD;
        }
        for i in 2..n {
            fact_inv[i] = fact_inv[i - 1] * fact_inv[i] % MOD;
        }

        Combination { fact, fact_inv }
    }

    fn get(&self, n: usize, r: usize) -> i64 {
        if n == 0 || r == 0 {
            return 1;
        }
        self.fact[n] * self.fact_inv[n - r] % MOD * self.fact_inv[r] % MOD
    }
}

fn pow_mod(x: i64, y: i64, m: i64) -> i64 {
    if x == 0 {
        if y == 0 {
            return 1;
        } else {
            return 0;
        }
    }
    if y == 0 {
        return 1;
    }
    if (y & 1) == 1 {
        x * pow_mod(x * x % m, y >> 1, m) % m
    } else {
        pow_mod(x * x % m, y >> 1, m)
    }
}

#[fastout]
fn main() {
    input! {
        n: i64,
        m:i64,
        k:i64,
    }

    let mut ans: i64 = 0;
    let ncr = Combination::init((n + 1) as usize);
    for i in 0..(k + 1) {
        let j = n - 1 - i;
        ans += pow_mod(m - 1, j as i64, MOD) * ncr.get((n - 1) as usize, i as usize) % MOD;
        ans %= MOD;
    }
    ans = ans * m % MOD;
    println!("{}", ans);
}


Measured memory_bytes: 5208
h,w,k=map(int,input().split())
ans=10**18
s=[input() for _ in range(h)]
for i in range(2**(h-1)):
    div=[0]
    for j in range(h-1):
        if (i>>j)&1:
            div.append(j)
    div.append(h-1)
    n=len(div)
    divcnt=[0]*(n-1)
    j=-1
    prev=-1
    cnt=n-2
    ok=True
    while 1:
        l=1
        j+=1
        if j==w:
            break
        for m in range(h):
            if m<=div[l]:
                #print(l,j,m)
                if divcnt[l-1]+int(s[m][j])>k:
                    j-=1
                    #print(prev)
                    if j==prev:
                        #print(divcnt)
                        ok=False
                    else:
                        prev=j
                        cnt+=1
                        #print(cnt)
                        divcnt=[0]*(n-1)
                    break
                else:
                    divcnt[l-1]+=int(s[m][j])
                if m==div[l]:
                    if l<n-1:
                        l+=1
                    else:
                      break
        if not ok:
            break
    if ok:
        ans=min(cnt,ans)
print(ans)

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

 int main(){
 int N;
 double ans = 0.0, A;
 cin >> N;
 for(int i = 1; i <= N; ++i){
 cin >> A;
ans += 1.0 / A;
 }
 ans = 1.0 / ans;
 cout << setprecision(16) << ans << endl;
 }

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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//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();}


int main(){
  int a,b;
  cin >> a >> b;
  if(b % a == 0)cout << a+b << endl;
  else cout << b-a << endl;
  return 0;
}


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

using namespace std;
const int mod = 1e9 + 7;

void add(int& a, int b) {
  a += b;
  if(a >= mod) {
    a -= mod;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int> (n));
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  vector<vector<int>> dp(n + 1, vector<int> (1 << n, 0));
  //dp[i][mask] is the num of ways to match first i men with set of women represented
  //by mask
  dp[0][0] = 1;
  for(int i = 1; i <= n; i++) {    
    for(int mask = 0; mask < (1 << n); mask++) {
      if(__builtin_popcount(mask) == i) {        
        for(int bit = 0; bit < n; bit++) {
          if((mask&(1 << bit)) && a[i - 1][bit]) {
            add(dp[i][mask], dp[i - 1][mask - pow(2, bit)]);
          }
        }
      }
    }
  }
  cout << dp[n][(1<<n) - 1] << '\n';
  return 0;
}


Measured memory_bytes: 191696
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

signed main()
{
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2<<endl;	
	return 0;
}

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

int main() {
  string s,t;
  //sを降順tを昇順に並び替えて辞書順比較をすればよいのは分かる
  cin>>s;
  cin>>t;
  
  sort(s.begin(),s.end());
  
  //sortは降順だけなのでreverseかけて昇順にするんすね
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());

  
	if(s<t){
    cout<<"Yes"<<endl;}
  
  	else{
    cout<<"No"<<endl;}
  
}

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

int main() { /* ここに書く */

    int i,N,X,sa,sb,sc;
  string A;
  cin >> N;
  A = "APPROVED";
  i = 0;
  
while(N > i){
    
    cin >> X;
    sa = X % 2;
    sb = X % 6;
    sc = X % 10;
    if(sa == 0){
      if(sb != 0 && sc != 0 ){
      A = "DENIED";
      }
    }
      i++;

  }
  
  cout << A << endl; 
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void)
{
    int n;
    cin>>n;
    int graph[n+1][n+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            graph[i][j]=0;
        }
    }
    for(int i=1;i<=n;i++)
    {
        int a,temp;
        cin>>a>>temp;
        for(int j=0;j<temp;j++)
        {
            int k;
            cin>>k;
            graph[i][k]=1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        int j;
        for(j=1;j<n;j++)
        {
            cout<<graph[i][j]<<' ';
        }
        cout<<graph[i][j]<<endl;
    }
    return 0;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define ll              long long int
#define ull             unsigned long long int
#define mod             1000000007 
#define pb              push_back
#define mp              make_pair
#define count_1(n)      __builtin_popcountll(n) //set bits
#define fr              first
#define sc              second

bool isPrime(ll n) {

  if (n == 1) {
    return false;
  }

  for (ll i = 2; i*i <=n; i++) {
    if (n % i == 0) return false;
  }

  return true;
}

 
   
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;     
    x = x % p;  
                
    if (x == 0) return 0;  
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 

int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
  
        if (arr[mid] == x) 
            return mid; 
  
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
  
        return binarySearch(arr, mid + 1, r, x); 
    } 
  
    return -1; 
} 



int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        ll ans=max(a*c,max(a*d,max(b*c,b*d)));
        cout<<ans;
        
    
}

Measured memory_bytes: 3648
a,b,c=map(int,input().split())

if a==b==c and a%2==0:
    print(-1)
else:
    num=0
    while True:
        if a%2==1 or b%2==1 or c%2==1:
            break
        num+=1
        l0=(b+c)/2
        l1=(c+a)/2
        l2=(a+b)/2
        a,b,c=l0,l1,l2
    print(num)

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

/*#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")   */


//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 2e6 + 51, MOD = 1e9 + 7, mod = 998244353, INF = 2e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;



signed main() {
    #ifdef Flash
     freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m, ans = 0;
    cin >> n >> m;
    cout << (m - 1) * (m) / 2 + (n - 1) * n / 2;

}


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

int main() {
  string S, T; cin >> S >> T;
  if (((int)S.size() + 1) != (int)T.size()) {
    cout << "No" << endl;
    return 0;
  }
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) != T.at(i)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
using ll = long long;
using P = pair<int,int>;

// code starts
int main()
{
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  vector<int> c(n);
  int i,j;
  rep(i,n)
  {
    cin >> p[i];
    p[i]--;
  }
  rep(i,n) cin >> c[i];
  vector<vector<ll>> sums(n);
  rep(i,n)
  {
    int now = i;
    now = p[now];
    sums[i].emplace_back(c[now]);
    while(now != i)
    {
      now = p[now];
      int sz = sums[i].size();
      ll base = sums[i][sz-1];
      sums[i].emplace_back(base+c[now]);
    }
  }
  ll ans = -1020304050;
  rep(i,n)
  {
    int sz = sums[i].size();
    rep(j,sz)
    {
      ll kans = sums[i][j];
      //cout << kans << endl;
      int left = k-j-1;
      if(left < 0) continue;
      int times = left/sz;
      kans += max((ll)0,sums[i][sz-1]*times);
      
      ans = max(ans,kans);
    }
  }
  cout << ans << endl;
}


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

typedef long long ll;

int N;
ll F[1000010] = {1},R[1000010];
ll mem[1000010];
ll mod = 1000000007;
ll ans;

ll pow_mod(ll a,ll b)
{
    if(b == 0)return 1;
    ll res = pow_mod(a * a % mod, b / 2);
    if(b & 1)res = res * a % mod;
    return res;
}

ll con(int a,int b)
{
    if(a < b)return 0;
    return F[a] * R[b] % mod * R[a - b] % mod;
}

int main()
{
    scanf("%d",&N);

    if(N == 2)
    {
        printf("1\n");
        return 0;
    }

    for(int i = 1; i < 1000010; i++)F[i] = F[i - 1] * i % mod;
    for(int i = 0; i < 1000010; i++)R[i] = pow_mod(F[i],mod - 2);

    for(int i = 0; i < N; i++)
    {
        if((N + 1) / 2 > i)continue;
        mem[i] = con(i - 1,N - 1 - i) * F[i] % mod * F[N - 1 - i] % mod;
        ans += (mem[i] - mem[i - 1]) * (ll)i % mod;
        ans = (ans + mod) % mod;
    }

    printf("%lld\n",ans);
    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz+1, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};


int main() {
    int n,m;
    cin>>n>>m;
    int x,y,z;
    UnionFind uf(n);
    rep(i,m){
        cin>>x>>y>>z;
        uf.unite(x,y);
    }
    set<int> se;
    rep(i,n){
        se.insert(uf.find(i+1));
    }
    cout<<se.size()<<endl;
    

    return 0;
}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int s1 = a * b;
    int s2 = c * d;
    if (s1 > s2) {
        cout << s1 << endl;
    } else {
        cout << s2 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstring>
#include <stdio.h>
#include <algorithm>
#include <sstream>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <cstdlib>
#include <cmath>

typedef long long ll;

#define reps(i, s, e) for (ll i = s; i < e; ++i)
#define rep(i, n) reps(i, 0, n)
#define rreps(i, s, e) for (ll i = e-1; i >= s; --i)
#define rrep(i, n) rreps(i, 0, n)

// const ll LL_INF = 1LL<<60;

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

using namespace std;

ll A;
int k;
vector<ll> l;
vector<ll> r;
char ch[20000];
vector<ll> height;

inline void strip_l(int& start, const int& end) {
    reps(i, start, end) {
        if (ch[i]=='/' || ch[i]=='_') start++;
        else break;
    }
}

inline void strip_r(const int& start, int& end) {
    rreps(i, start, end) {
        if (ch[i]=='\\' || ch[i]=='_') end--;
        else break;
    }
}

inline int calc_l(int& start, const int& end) {
    double area = 0;
    int depth = 0;
    reps(i, start, end) {
        if (depth==1 && ch[i]=='/') {
            area += (2*depth-1)/2.;
            start = i+1;
            break;
        } 
        else if (ch[i]=='/') area += (2*(depth--)-1)/2.;
        else if (ch[i]=='_') area += depth;
        else if (ch[i]=='\\') area += (2*(depth++)+1)/2.;
    }
    l.push_back(ll(area));
    return area;
}

inline int calc_r(const int& start, int& end) {
    double area = 0;
    int depth = 0;

    rreps(i, start, end) {
        if (depth==1 && ch[i]=='\\') {
            area += (2*depth-1)/2.;
            end = i;
            break;
        } 
        else if (ch[i]=='\\') area += (2*(depth--)-1)/2.;
        else if (ch[i]=='_') area += depth;
        else if (ch[i]=='/') area += (2*(depth++)+1)/2.;
    }
    r.push_back(ll(area));
    return area;
}


int main() {
    scanf("%s", ch);
    int start = 0;
    int end = strlen(ch);
    height.assign(end, 0LL);

    // 端の文字列を削除
    strip_r(start, end);
    strip_l(start, end);

    reps(i, 1, end) {
        if(ch[i]=='/') height[i] = height[i-1] + 1;
        else if(ch[i]=='_') height[i] = height[i-1];
        else height[i] = height[i-1] - 1;
    }

    while(end - start >= 1) {
        // 先頭から
        if (height[start] < height[end-1]) {
            A += calc_l(start, end);
            strip_l(start, end);
        } else {
            A += calc_r(start, end);
            strip_r(start, end);
        }
    }

    cout << A << endl;
    cout << l.size()+r.size();

    rep(i, l.size()) cout << " " << l[i];
    rrep(i, r.size()) cout << " " << r[i];
    cout << endl;
}


Measured memory_bytes: 3296