akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main()
{
    int n;
    int num;
    int i;
    int mult4,mult2;
    while (cin>>n)
    {
        mult4=mult2=0;
        for (i=0;i<n;i++)
        {
            cin>>num;
            if (num%4==0)
                mult4++;
            else if (num%2==0)
                mult2++;
        }
        if (mult2)
            n-=mult2-1;
        if(mult4>=n/2)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().strip().split())
a = list(map(int, input().strip().split()))

dp = [None] * (n+1)
dp[0] = 0
x = (0,2,5,5,4,5,6,3,7,6)
for i in range(2, n+1):
    for v in a:
        if i-x[v] >= 0 and dp[i-x[v]] != None:
            if not dp[i]:
                dp[i] = dp[i-x[v]]*10+v
            else:
                dp[i] = max(dp[i], dp[i-x[v]]*10+v)

print(dp[n])


Measured memory_bytes: 14516
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	private static Scanner sc;

	public static void main(String[] args) {
		Main instance = new Main();
		sc = instance.new Scanner();
		instance.solve();
	}

	private void solve() {
		try {
			calc();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private void calc() throws Exception{
		int N = sc.nextInt();
		int N2 = N * 2 ;
		int[] ary = new int[N2];
		for (int i = 0; i < N2; i++) {
			ary[i] = sc.nextInt();
		}
		Arrays.sort(ary);
		int result = 0;
		for(int j = 0; j < N2; j+=2){
			int num = Math.min(ary[j], ary[j+1]);
			result += num;
		}
		System.out.println(result);
	}

	private class Scanner {
		String[] s;
		int i;
		BufferedReader br;
		String regex = " ";

		public Scanner() {
			s = new String[0];
			i = 0;
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		@Override
		protected void finalize() throws Throwable {
			try {
				super.finalize();
			} finally {
				destruction();
			}
		}

		private void destruction() throws IOException {
			if (br != null)
				br.close();
		}

		public String next() throws IOException {
			if (i < s.length)
				return s[i++];
			String st = br.readLine();
			while (st == "")
				st = br.readLine();
			s = st.split(regex, 0);
			i = 0;
			return s[i++];
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public Long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public Double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 8020
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/

/*==================================================*/
/*function*/


/*==================================================*/

int main() {
    string S;
    cin>>S;

    REP(i,1,S.size()-1){
        string as = S.substr(0,S.size()-i);

        if(as.size() % 2 == 1) continue;

        bool f = true;
        REP(j,0,as.size()/2){
            if(as[j] != as[as.size()/2 + j]) f = false;
        }
        if(f){
            cout<<as.size()<<endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  string s,t;
  cin >> s >> t;
  
  sort(s.begin(),s.end());
  sort(t.rbegin(),t.rend());
  
  
  if(s < t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}
  


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

using namespace std;

#define int long long int
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define se second
#define fi first

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

const int inf = 1e18;
const int mod = 1e9 + 7;

inline int add(int x, int y) { x += y; if (x >= mod) x -= mod; return x;}
inline int sub(int x, int y) { x -= y; if (x < 0) x += mod; return x;}
inline int mul(int x, int y) { return ((x % mod) * (y % mod)) % mod;}
inline int power(int a, int b) {
    int x = 1;
    while (b) {
        if (b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline int inv(int a) { return power(a, mod - 2);}

#undef int
int main() {
#define int long long int
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    clock_t start = clock();

    int n; cin>>n;
    vector<vector<int>> a(n+1,vector<int>(4,0));
    vector<vector<int>> dp(n+1,vector<int>(4,0));
    for(int i=1;i<=n;i++) cin>>a[i][1]>>a[i][2]>>a[i][3];

    for(int i=1;i<=n;i++){
        for(int j=1;j<=3;j++){
            int val = 0;
            for(int k=1;k<=3;k++){
                if(j!=k) val = max(val,dp[i-1][k]);
            }
            dp[i][j] = a[i][j] + val;
        }
    }

    cout << max(dp[n][1],max(dp[n][2],dp[n][3])) << endl;

    clock_t end = clock();
    cerr << "Time: " << (double)(end - start) / CLOCKS_PER_SEC << " seconds" << endl;

    return 0;
}

Measured memory_bytes: 14336
"use strict"
function main(arg) {
    var data = arg.trim().split("\n")
    var str = data[0]
    data.shift()
    data.shift()
    var is_omote = true
    for (var i = 0; i < data.length; i++) {
        var row = data[i].split(' ')
        if (row[0] === '1') {
            is_omote = !is_omote
        }
        if (row[0] === '2') {
            if (row[1] === '1') {
                if (is_omote) {
                    // str.unshift(row[2])
                    str = row[2] + str
                }else {
                    // str.push(row[2])
                    str += row[2]
                }
            }
            if (row[1] === '2') {
                if (is_omote) {
                    str += row[2]
                    // str.push(row[2])
                }else {
                    str = row[2] + str
                    // str.unshift(row[2])
                }
            }
        }
    }
    if (!is_omote) {
        str = str.split('').reverse().join('')
    }
    console.log(str)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 56068
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
#include <chrono>
#include <fstream>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion


int main() {
    int n;
    cin >> n;
    vector<P> ps(n);
    rep(i, n) cin >> ps[i].first >> ps[i].second;
    sort(ps.rbegin(), ps.rend());
    cout << ps[0].first + ps[0].second << endl;
}

Measured memory_bytes: 4048
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N;
   cin >> N;
   ll a[N];
   ll sum[N + 1];
   sum[0] = 0;
   for (int i = 0; i < N; i++) {
      cin >> a[i];
      sum[i + 1] = sum[i] + a[i];
   }
   ll ans = -1;
   for (int i = 0; i < N - 1; i++) {
      ll tmp = llabs(2 * sum[i + 1] - sum[N]);
      if (ans < 0) ans = tmp;
      else chmin(ans, tmp);
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 3328
import bisect
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

l = IL()

if (l[0]*l[1])%2 == 0:
	print("Even")
else:
	print("Odd")

Measured memory_bytes: 12228
package main

import (
    "fmt"
)

func main() {
    var num, sum int
    fmt.Scan(&num, &sum)
    sum /= 1000

    //fmt.Println(num, sum)

    var done bool
    maxM := int(sum / 10)
    for m := 0; m <= maxM; m++ {
        sum2 := sum - m*10
        num2 := num - m
        maxG := int(sum2 / 5)
        if maxG > num2 {
            continue
        }
        for g := 0; g <= maxG; g++ {
            sum3 := sum2 - g*5
            num3 := num2 - g
            if sum3 == num3 {
                if !done {
                    done = true
                    fmt.Println(m, g, num3)
                }
            }
        }
    }
    if !done {
        fmt.Println(-1, -1, -1)
    }
}


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

class dice {
    int dice[6];
    string state;
public:
    void input() {
        for(int i=0; i<6; ++i) cin >> dice[i];
    }
    void output() {
        cout << dice[0];
        for(int i=1; i<6; ++i) cout << ' ' << dice[i];
        cout << endl;
    }
    void move(string state) {
        for(int i=0; i<state.length(); ++i) {
            switch(state[i]) {
                case 'N':
                    swap(dice[0], dice[1]);
                    swap(dice[1], dice[5]);
                    swap(dice[5], dice[4]);
                    break;
                case 'S':
                    swap(dice[0], dice[4]);
                    swap(dice[4], dice[5]);
                    swap(dice[5], dice[1]);
                    break;
                case 'E':
                    swap(dice[0], dice[3]);
                    swap(dice[3], dice[5]);
                    swap(dice[5], dice[2]);
                    break;
                case 'W':
                    swap(dice[0], dice[2]);
                    swap(dice[2], dice[5]);
                    swap(dice[5], dice[3]);
                    break;
                default:
                    break;
            }
        }
    }
    int getTopside() {
        string state;
        cin >> state;
        move(state);
        return dice[0];
    }
};

int main() {
    dice d;
    string state;

    d.input();
    cout << d.getTopside() << endl;

    return 0;
}

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

using namespace std;

int main()
{
 string S;
 int N,K;
 cin>>N>>K;
 cin>>S;
 int A=K-1;
if(N>=1&&K>=1&&N<=50&&K<=N ){
  if(S.length()==N){
     S[A]=tolower(S[A]);
     cout<<S;
 }
}
    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <math.h>


int ASC(const void *a, const void *b) {
	return *(int *)b - *(int *)a;//降順
}
int GCD(int a, int b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main(void)
{
	int day, homework, ans = 0, n;
	scanf("%d%d",&day,&homework);
	for (int i = 0; i < homework; i++) {
		scanf("%d",&n);
		ans += n;
	}
	ans = day - ans;
	if (ans >= 0)
		printf("%d", ans);
	else
		printf("-1");
	return 0;
}

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

signed main() {
  long long h;
  long long w;
  cin >> h >> w;
  if (h==1 || w== 1){
    cout << 1 << endl;
  }
  else if(h%2==0 || w%2==0){
    cout << h*w/2 << endl;
  }
  else cout <<  h*w/2+1 << endl;
}




  



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;

int main(){
	cin>>n;
	int t=1;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		if(t==x) t++;
	}
	if(t==1) cout<<-1<<endl;
	else cout<<n-t+1<<endl;
}

Measured memory_bytes: 384
#import math
#from functools import reduce
n = int(input())
a = list(map(int, input().split()))

#print(reduce(math.gcd, a))

b=a[0]
c=a[1]
result=1
for i in range(1,n):
    while 1:
        if b%c == 0:
            result = c
            break
        else:
            r = b%c
            b = c
            c = r
    b=result
    c=a[i]
 
print(result)

Measured memory_bytes: 14252
#include<stdio.h>
main(){
  int i,j,k,tmp,side[4];
  char way;
  scanf("%d %d %d %d %d %d\n",&side[1],&side[2],&side[3],&side[4],&side[5],&side[6]);
  while(way!='\n'){
    scanf("%c",&way);
    if(way=='W'){
      tmp=side[1];
      side[1]=side[3];
      side[3]=side[6];
      side[6]=side[4];
      side[4]=tmp;
    }
    else if(way=='E'){
      tmp=side[1];
      side[1]=side[4];
      side[4]=side[6];
      side[6]=side[3];
      side[3]=tmp;
    }
    else if(way=='N'){
      tmp=side[1];
      side[1]=side[2];
      side[2]=side[6];
      side[6]=side[5];
      side[5]=tmp;
    }
    else if(way=='S'){
      tmp=side[1];
      side[1]=side[5];
      side[5]=side[6];
      side[6]=side[2];
      side[2]=tmp;
    }
  }
  printf("%d\n",side[1]);
  return 0;
}

Measured memory_bytes: 596
import java.util.*;
import java.io.*;
import java.awt.Point;
import java.math.BigInteger;

public class Main {

	public static void main(String[] args) throws Exception {
		FastIO sc = new FastIO(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		N = sc.nextInt();
		int K = sc.nextInt();
		a = new int[N];
		for(int i = 0; i < N; i++) a[i] = sc.nextInt();
		
		if(dfs(K, 0)) pw.println("First");
		else pw.println("Second");
		pw.close();
		
	}
	
	static int N;
	static int[] a;
	
	static boolean visited[][] = new boolean[100001][2];
	static boolean canWin[][] = new boolean[100001][2];
	
	static boolean dfs(int rem, int turn) {
		if(visited[rem][turn]) return canWin[rem][turn];
		
		boolean winnable = false;
		for(int t : a) {
			if(t <= rem) if(!dfs(rem-t, 1-turn)) {
				winnable = true;
				break;
			}
		}
		
		visited[rem][turn] = true;
		return canWin[rem][turn] = winnable;
	}

	static class FastIO {

		//Is your Fast I/O being bad?

		InputStream dis;
		byte[] buffer = new byte[1 << 17];
		int pointer = 0;

		public FastIO(String fileName) throws Exception {
			dis = new FileInputStream(fileName);
		}

		public FastIO(InputStream is) throws Exception {
			dis = is;
		}

		int nextInt() throws Exception {
			int ret = 0;

			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}

			return (negative) ? -ret : ret;
		}

		long nextLong() throws Exception {
			long ret = 0;

			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}

			return (negative) ? -ret : ret;
		}

		byte nextByte() throws Exception {
			if (pointer == buffer.length) {
				dis.read(buffer, 0, buffer.length);
				pointer = 0;
			}
			return buffer[pointer++];
		}

		String next() throws Exception {
			StringBuffer ret = new StringBuffer();

			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			while (b > ' ') {
				ret.appendCodePoint(b);
				b = nextByte();
			}

			return ret.toString();
		}

	}
}


Measured memory_bytes: 35792
#include <iostream>
#include <math.h>
#include <cstring>
#include <vector>
using namespace std;

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

    long long x, yen=100, year=0;
    cin >> x;
    while(yen<x){
        yen = yen+(yen*0.01);
        year++;
    }
    cout << year << endl;

    return 0;
}

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

const int MOD = (int)1e9+7;

int main(){
	long long S;
	cin >> S;

	int aa=1e9;
	int x=(aa-S%aa)%aa;
	int y=(S+x)/aa;
	
	cout << "0 0 1000000000 1 " << x << " " << y << endl;
	
	return 0;
}


Measured memory_bytes: 256
from itertools import product
from collections import Counter

counter = Counter()

N = int(input())

for x, y, z in product(range(1, 101), repeat=3):
    counter[x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x] += 1

for i in range(1, N + 1):
    print(counter[i])


Measured memory_bytes: 11752
public class Main {

	/**
	 * ????????????????????????
	 *
	 */
	public static void main(String[] args) {
		for (int i = 1; i < 10; i++) {
			for (int j = 1; j < 10; j++) {
				System.out.println(i + "x" + j + "=" + i*j);
			}
		}
	}
}

Measured memory_bytes: 24504
N = int(input())
a = list(map(int,input().split(" ")))
ans = 0
judge =True
while judge:
    count = 0
    for i in range(N):
        if a[i]%2 != 0:
            count +=1
    if count  != N:
        for i in range(N):
            if a[i]%2 ==0:
                ans += 1
                a[i] = a[i]/2
            # print(a)
            # print(ans)
    else:
        judge = False
print(ans)

Measured memory_bytes: 4148
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <iomanip>       // fixed, setprecision
using namespace std;

int main()
{
  int N, c = 0;
  string S;
  cin >> N >> S;
  for (int i = 0; i < N - 2; i++)
  {
    if (S.substr(i, 3) == "ABC")
    {
      c++;
    }
  }
  cout << c << endl;
}


Measured memory_bytes: 3248
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define pii pair<int , int>
#define pdd pair<db , db>
#define pll pair<ll , ll>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define mod1 998244353 
#define inf 1000000000000000007
#define eps 0.000001
#define stp fixed<<setprecision(20)
#define endl '\n'



int main()
{
    fastio;
    #ifdef APNA_IO
        start_routine();
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);    
    #endif

    ll n;cin>>n;
    ll a=0,b=0;
    for(ll i=0;i<n;i++)
    {
        ll x,y;cin>>x>>y;

        if(x>=a && y>=b)
        {
            a=x,b=y;
            continue;
        }

        ll p=(a/x)+((a%x)?1LL:0LL);
        ll q=(b/y)+((b%y)?1LL:0LL);
        if(p>q) swap(p,q);
        if(p*x>=a && p*y>=b)
        {
            a=x*p,b=y*p;
            continue;
        }

        a=q*x,b=q*y;

    }
    cout<<a+b;

    #ifdef APNA_IO
        end_routine();
    #endif
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define ll long long

using namespace std;
int mod = 1000000007;

int a, b, c;
int main() {
  cin >> a >> b >> c;
  int d = abs(a-b);
  int e = abs(b-c);
  int f = abs(c-a);
  int ma = max(max(d,e),f);

  cout << d+e+f-ma << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void)
{
	int n,y,t,b[50],r,i,j,max99,max,parad;
	float kyo,g[50];
	while(1){
		max99=0;
		scanf("%d",&n);
		if(n==0){
			break;
		}
		scanf("%d",&y);
		for(i=0;i<n;i++){
			scanf("%d%d%d",&b[i],&r,&t);
			if(t==1){
				g[i]=100*(1+y*r*0.01);
			}
			else{
				kyo=1+r*0.01;
				g[i]=pow(kyo,y);
				g[i]=100*g[i];
				}
		}
		for(i=0;i<n;i++){
			if(g[i]>max99){
				max99=g[i];
				max=b[i];
			}
		}
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 688
#include <iostream>
using namespace std;
int main(){
  int N; cin >> N;
  bool jud; jud = false;
  for (int i=0; i<26; i++){
    for (int j=0; j<16; j++){
      if(4*i + 7*j == N){
        jud = true;
      }
    }
  }
  if(jud == true){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

ll A, B, C;
ll X, Y;
ll N;
ll ans = mod*mod;

int main(){
	
	cin>>A>>B>>C;
	cin>>X>>Y;
	
	N = max( X, Y );
	
	REP( i, N+1 ){
		ll a = max( 0ll, X-i );
		ll b = max( 0ll, Y-i );
		ll num = i*2*C+a*A+b*B;
		ans = min( num, ans );
	}
	
	cout<<ans<<endl;
	
}




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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
  if (n == 0) return 1;
  mint x = f(n/2);
  x *= x;
  if (n%2 == 1) x *= 2;
  return x;
}

mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,a) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  mint ans = f(n);
  ans -= 1;
  ans -= choose(n,a);
  ans -= choose(n,b);
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
X = list(map(int, input().split()))

X.sort()
dist = [0]*(M-1)

for i in range(M-1):
    dist[i] = X[i+1] - X[i]

dist.sort()
ans = 0
if N < M:
    for i in range((M-1)-(N-1)):
        ans += dist[i]

print(ans)

Measured memory_bytes: 13960
#include<bits/stdc++.h>
using namespace std;
int main(){
    map<string,int>data;
    string str;
    int n,m;
    bool f=true;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        cin >> str;
        data[str]++;
    }
    scanf("%d",&m);
    for(int i=0;i<m;i++){
        cin >> str;
        if(data.find(str)==data.end()||data[str]<=0){
            f=false;
        }
        else
            data[str]--;
    }
    if(f)
        cout << "YES" << endl;
    if(!f)
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 24960
#include<stdio.h>
int main()
{
    int a,b,s,n;
    scanf("%d %d %d %d",&a,&b,&s,&n);
    if(a>=b)
    {
    s=b*s + (a-b)*n;
    }
    else
    {
        s=a*s;
    }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int N;
	const int A = 4;
	const int B = 7;
	const int MAX = 100;

	cin >> N;

	for (int ai = 0; ai <= MAX / A; ai++) {
		for (int bi = 0; bi <= MAX / B; bi++) {
			if (ai * A + bi * B == N) {
				cout << "Yes";
				return 0;
			}
		}
	}

	cout << "No";

    return 0;
}

Measured memory_bytes: 256
N,x=list(map(int,input().split()))
if x==1 or x==2*N-1:
    print('No')
else:
    print('Yes')
    a=[]
    if N==2:
        a=[1,2,3]
    elif x==2:
        n=5
        for i in range(2*N-4):
            if i==N-2:
                a.append('\n'.join(map(str,[x+1,x,x-1,x+2])))
            else:
                a.append(n)
                n+=1
    else:
        n=5 if x==3 else 1
        for i in range(2*N-4):
            if i==N-2:
                a.append('\n'.join(map(str,[x-1,x,x+1,x-2])))
            else:
                a.append(n)
                n=x+2 if n==x-3 else n+1
    for i in range(len(a)):
        print(a[i])

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N),B(N),C(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  for(int i=0;i<N;i++){
    cin >> B.at(i);
  }
  for(int i=0;i<N;i++){
    cin >> C.at(i);
  }
  sort(A.begin(),A.end());
  sort(C.begin(),C.end());
  int64_t ans=0;
  for(int i=0;i<N;i++){
    ans+=(lower_bound(A.begin(), A.end(), B.at(i))-A.begin())
          *(C.end()-upper_bound(C.begin(), C.end(), B.at(i)));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4484
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
	char a;
	cin >> a;
	if (a == 'A')cout << "T" << endl;
	if (a == 'T')cout << "A" << endl;
	if (a == 'C')cout << "G" << endl;
	if (a == 'G')cout << "C" << endl;



	return 0;
}


Measured memory_bytes: 256
/*
E - Sequential operations on Sequence
by.YXH_XianYu
   2018.6.15
 */
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LLI long long
#define MXN 100010

LLI q[MXN],
	a[MXN],
	t[MXN],
	ans[MXN],
	ch;
int n,m;

//二分寻找
int Binary(int l, int r, LLI k){
	while(l<=r){
		int mid=(l+r)>>1;
		if(a[mid]<=k)
			l=mid+1;
		else
			r=mid-1;
	}
	return l-1;
}


int main(){
	//freopen("mothergoose.in","r",stdin);
	//freopen("mothergoose.out","w",stdout);

	scanf("%d%d",&n,&m);
	q[++q[0]]=n;
	for(int i=1;i<=m;i++){
		scanf("%lld",&ch);
		while(q[q[0]]>=ch)//q[0]=0 < ch
			q[0]--;
		q[++q[0]]=ch;
	}
	m=q[0];
	for(int i=1;i<=q[0];i++)
		a[i]=q[i];
	t[m]=1;
	for(int i=m;i>=1;i--){
		LLI k=a[i];
		int p=Binary(1,i-1,k);
		while(p){
			t[p]+=k/a[p]*t[i];
			k%=a[p];
			p=Binary(1,p-1,k);
		}
		ans[k]+=t[i];
	}
	for(int i=n;i>=1;i--)
		ans[i]+=ans[i+1];
	for(int i=1;i<=n;i++)
		printf("%lld\n",ans[i]);

	return 0;
}


Measured memory_bytes: 4864
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
 
int main(){

    ll n;
    cin >> n;

    if(n==0){
        cout << "1" << endl;

    }
    else if(n==1){
        cout <<"0" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <cmath>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
typedef vector<ll> V;
typedef vector<V> VV;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
void solve(int a){cout<<( a?"Yes":"No")<<endl;}
int main(){
	ll n;
	long long ans=30;
	cin >> n;
	for(long long i=1;i<=(int)(sqrt(n));i++){
		if(n%i==0){
			chmin(ans,(long long )(log10(n/i))+1);
		}
	}
	cout <<ans<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,k,c;
string s;
int prerk[400100],aftrk[400100];
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k>>c>>s;
	s="A"+s+"C";
	int t=1;
	for(int i=1;i<=k;i++){
		while(s[t]=='x') t++;
		prerk[t]=i;
		t+=(c+1);
	}
	for(int i=n;i>=1;i--){
		aftrk[i]=aftrk[i+1];
		if(s[i]=='o')
			aftrk[i]=max(aftrk[i],aftrk[i+c+1]+1);
	}
	for(int i=1;i<=n;i++){
		if(prerk[i]==0) continue;
		if(aftrk[i+1]+prerk[i]-1<k){
			cout<<i<<endl;
		}
	}
	return 0;
}


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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int n; cin >> n;
    vector<pair<int, int>> t;
    REP(i, n) {
        int a, b; cin >> a >> b;
        t.push_back(make_pair(b, a));
    }
    ASC(t);
    int sum = 0;
    string ans = "Yes";
    for (auto e: t) {
        sum += e.second;
        if (sum > e.first) {
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2420
S = input()
head = int(S[:2])
tail = int(S[2:])
if 0<head <=12 and 0<tail<=12:
  print("AMBIGUOUS")
elif 0<head<=12 and (tail>12 or tail==0):
  print("MMYY")
elif (head>12 or head ==0) and 0<tail<=12:
  print("YYMM")
else:
  print("NA")

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

int main(){
    string S;
    cin >> S;
    int l = S.length();
    string sub = S.substr(0,1);
    ///cout << sub << endl;
    int res = 0;
    for(int i = 0 ; i < l-1; i++){
        int j = 1;
    
        string ss = S.substr(i+1,j);
        if(sub == ss){
            while(sub == ss){
                j++;
                ss = S.substr(i,j);
            }
            i += j-1;
        }
        //cout << sub << endl;
        //cout << i << endl;
        sub = ss;
        res++;
        if(i == l-2)res++;
    }

    cout << res << endl;


    return 0;
}

Measured memory_bytes: 640
import sys
import heapq
def Dj(G,s):
    n = len(G)
    dist = [float("inf") for i in range(n)]
    vis = [-1 for i in range(n)]
    li = [(0,s)]
    dist[s]=0
    heapq.heapify(li)
    while len(li):
        d,u = heapq.heappop(li)
        if vis[u]==1:
            continue
        vis[u]=1
        for v in G[u]:
            if dist[v[1]]>dist[u] + v[0]:
                dist[v[1]] = dist[u] + v[0]
                heapq.heappush(li,(dist[u] + v[0],v[1]))
    return dist
                
    
    

def main():
    T = [int(x) for x in sys.stdin.readline().strip().split()]
    V = T[0]
    E = T[1]
    S = T[2]
    G = [[] for i in range(V)]
    for i in range(E):
        line = [int(x) for x in sys.stdin.readline().strip().split()]
        G[line[0]].append((line[2],line[1]))
    for k in Dj(G,S):
        if k ==float("inf"):print("INF")
        else:print(k)
main()

    
    



Measured memory_bytes: 93380
# -*- coding: utf-8 -*-
N = int(input())
H_list = list(map(int, input().split()))

max_counter = 0
counter = 0
now_num = 0
for i in range(N):
    this_num = H_list[i]
    if now_num >= this_num:
        now_num = this_num
        counter += 1
    else:
        now_num = this_num
        if max_counter < counter:
            max_counter = counter
        counter = 0
if max_counter < counter:
    max_counter = counter
print(max_counter)

Measured memory_bytes: 14252
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

class UnionFind {
private:
	vector<int> data;
public:
	int root(int x) { return (x == INF || data[x] < 0) ? x : data[x] = root(data[x]); }
	
	UnionFind(int size) : data(size, -1) { }
	bool is_same(int x, int y) { return root(x) == root(y); }
	lint size(int x) { return -data[root(x)]; }

	void unify(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
};


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	UnionFind UF(N);
	int u, v, len, rt0 = INF, rt1 = INF;
	queue<pair<int,int>> horyu;
	for (int i = 0; i < N - 1; i++){
		cin >> u >> v >> len;
		if (len % 2 == 0) {
			if (rt0 == INF) rt0 = u - 1;
			UF.unify(u - 1, v - 1);
		}
		else horyu.push({ u, v });
	}

	while (!horyu.empty()) {
		u = horyu.front().first;
		v = horyu.front().second;
		horyu.pop();

		if (UF.root(u - 1) == UF.root(rt0)) {
			if (rt1 == INF) rt1 = v - 1;
			else UF.unify(rt1, v - 1);
		}
		else if (UF.root(v - 1) == UF.root(rt0)) {
			if (rt1 == INF) rt1 = u - 1;
			else UF.unify(rt1, u - 1);
		}
		else if (UF.root(u - 1) == UF.root(rt1)) UF.unify(rt0, v - 1);
		else if (UF.root(v - 1) == UF.root(rt1)) UF.unify(rt0, u - 1);
		else if (rt0 == INF&&rt1 == INF) {
			rt0 = u - 1, rt1 = v - 1;
			horyu.push({ u, v });
		}
		else horyu.push({ u, v });
	}

	for (int i = 0; i < N; i++) {
		if(UF.is_same(i,rt0)) cout << '0' << "\n";
		else cout << '1' << "\n";
	}

	return 0;
}

Measured memory_bytes: 1664
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    X = [0] * (N + 1)
    
    for a in A:
        X[a] += 1
    s = 0
    for x in X:
        s += x*(x-1)//2

    for a in A:
        print(s - X[a] + 1)



    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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

int main()
{
	int a[100], n, count = 1, ans = 0;
	cin >> n >> a[0];
	for (int i = 1; i < n; i++)
	{
		cin >> a[i];
		if (a[i - 1] == a[i])
			count++;
		else if (count == 2)
		{
			ans++;
			count = 1;
		}
		else if (count > 2)
		{
			ans += count / 2;
			count = 1;
		}
		else
			count = 1;
	}
	ans += count / 2;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int[] sum1 = new int[n + 1], sum2 = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            sum1[i] = sum1[i - 1] + (s.charAt(n - i) == '#' ? 0 : 1);
            sum2[i] = sum2[i - 1] + (s.charAt(i - 1) == '.' ? 0 : 1);
        }

        debug(sum1, sum2);

        int ans = 2 * n;
        for (int i = 0; i <= n; i++) {
            ans = Math.min(ans, sum1[i] + sum2[n - i]);
        }
        System.out.println(ans);
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 67784
#include <iostream>

using namespace std;

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

  if (n>=64) ans=64;
  else if (n>=32) ans=32;
  else if (n>=16) ans=16;
  else if (n>=8) ans=8;
  else if (n>=4) ans=4;
  else if (n>=2) ans=2;
  else ans=1;
  printf("%d\n", ans);
  return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;

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

int main (){
    string s, t, u;
    cin >> s >> t >> u;

    cout << s[0] << t[0] << u[0] << endl;




    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <vector>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
using vll = vector<ll>;
const ll MOD = 1e9 + 7;

int main() {
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	int aw, as;
	double ans = -1.0;
	for (int i = 0; 100 * a * i <= f; i++) {
		for (int j = 0; 100 * a * i + 100 * b * j <= f; j++) {
			for (int k = 0; 100 * a * i + 100 * b * j + c * k <= f; k++) {
				for (int l = 0; 100 * a * i + 100 * b * j + c * k + d * l <= f; l++) {
					int w = 100 * a * i + 100 * b * j;
					int s = c * k + d * l;
					if (w * e < 100 * s) break;
					if (ans < (double)s / (w + s)) {
						ans = (double)s / (w + s);
						aw = w;
						as = s;
					}
				}
			}
		}
	}
	cout << aw + as << " " << as << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)











 
int main(){
    cout << [](){
        string s; cin >> s;
        ll n = s.size() + 1;
        vector<ll> a(n);
        for(ll i = 0, c = 0; i < n - 1; i++){
            a[i + 1] = c = (s[i] - '>'? c + 1 : 0);
        }
        for(ll i = n - 2, c = 0; i >= 0; i--){
            a[i] = max(a[i], c = (s[i] - '<'? c + 1 : 0));
        }
        return [a](){
            ll sum = 0;
            for(ll x : a) sum += x;
            return sum;
        }();
    }() << endl;
}

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

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

    long sum = 0;
    for(long i = 1; i <= n; i++)
    {
        if(i % 3 != 0 && i % 5 != 0)
        {
            sum += i;
        }
    }

    cout << sum;

    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int x[1000],n;
int main(){
    cin>>n;
    for(int i=0;i<n;i++)cin>>x[i];
    int ans=1000000000;
    for(int i=0;i<=100;i++){
        int tmp=0;
        for(int j=0;j<n;j++)tmp+=(i-x[j])*(i-x[j]);
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  ll K, N;
  cin >> K >> N;
  
  vector<ll> as(N);
  rep(i, N) cin >> as[i];

  ll ml = 0;
  rep(i, N) {
    ll a = as[i];
    ll nextA;
    if (i != N-1) {
      nextA = as[i+1];
      ml = max(ml, nextA -a);
    } else {
      ml = max(ml, as[0] + (K-as[N-1]));
    }

  }

  ll ans = K - ml;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
k=0
for i in range(n):
  if i%2==1:
    k+=a[i]
b[0]=sum(a)-k*2
for i in range(1,n):
  b[i]=2*a[i-1]-b[i-1]
yu=map(str,b) 
print(' '.join(yu))


Measured memory_bytes: 19220
#include "bits/stdc++.h"
using namespace std;

#define rep(i, n)  for (int i = 0; i < (int) (n); i++)
#define Rrep(i, n) for (int i = ((int) n - 1); i >= 0; i--)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
#define INF 2e15
#define MOD 10e9 + 7

typedef vector <int> vint;
typedef long long    ll;

ll  dp[3100][3100][4];
int w[3100][3100];

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    /*rep(i, 3100) {
        rep(j, 3100) {
            rep(k, 4) {
                dp[i][j][k] = -INF;
            }
            w[i][j] = 0;
        }
    }*/

    int R, C, K;
    cin >> R >> C >> K;

    rep(i, K) {
        int r, c, v;
        cin >> r >> c >> v;
        w[r - 1][c - 1] = v;
    }

    rep(i, R) {
        rep(j, C) {
            for (int k = 2; k >= 0; k--) { // 拾うか拾わないか
                dp[i][j][k + 1] = max(dp[i][j][k + 1], dp[i][j][k] + w[i][j]);
            }
            rep(k, 4) {
                dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k]);
                dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
            }
        }
    }
    ll ans = 0;
    rep(k, 4) ans = max(ans, dp[R - 1][C - 1][k]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 330644
#include<bits/stdc++.h>
using namespace std;
string s,t;
int n;
bool ok(string a)
{
	for(int i=0;i<n;i++)
		if(a[i]!=t[i]&&a[i]!='?')
			return false;
	return true;
}
int main()
{
	cin>>s>>t;
	n=t.size();
	for(int i=s.size()-n;i>=0;i--)
	{
		if(ok(s.substr(i,n)))
		{
			for(int j=0;j<i;j++)
			{
				if(s[j]=='?')
					cout<<'a';
				else
					cout<<s[j];
			}
			cout<<t;
			for(int j=i+n;j<s.size();j++)
			{
				if(s[j]=='?')
					cout<<'a';
				else
					cout<<s[j];
			}
			return 0;
		}
	}
	puts("UNRESTORABLE");
	return 0;
}

Measured memory_bytes: 256
s=input()
n=len(s)
n1=(n-1)//2
n2=(n+3)//2
s1=s[:n1]
s2=s[n2-1:]

for i in range(1,n1+1):
    if s[i-1]!=s[-i]:
        print('No')
        exit()
for i in range(1,n1//2+1):
    if s1[i-1]!=s1[-i]:
        print('No')
        exit()
print('Yes')

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

typedef long long ll;
char s[301];
int k;
int main() {
    //freopen("test.in","r",stdin);
    //freopen("test.out","w",stdout);
    cin >> (s + 1);
    cin >> k;
    int len = strlen(s + 1);
    set<char> st;
    for (int i = 1; i <= len; i++) {
        st.insert(s[i]);
    }
    if (st.size() == 1) {
        ll l = 1ll * len * k;
        cout << l / 2 << endl;
        return 0;
    }
    ll cnt = 0;
    int res1 = 1, res2 = 0, ed = len;
    for (int i = len - 1; i >= 0; i--) {
        if (s[i] == s[len]) res1++;
        else {
            ed = i;
            break;
        }
    }
    cnt += 1ll * res1 / 2;
    int start = 1;
    for (int i = 1; i <= len; i++) {
        if (s[i] != s[len]) {
            start = i;
            break;
        }else
            res2++;
    }
    if (s[1] == s[len])
        cnt += 1ll * res2 / 2;
    cnt += 1ll * (res1 + res2) / 2 * (k - 1);
    res1 = 1;
    for (int i = start + 1; i <= ed; i++) {
        if (s[i] != s[i - 1]) {
            cnt += 1ll * res1 / 2 * k;
            res1 = 1;
        }
        else
            res1++;
    }
    cnt += 1ll * res1 / 2 * k;
    cout << cnt << endl;
}

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

using namespace std;

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

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

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

	vector<int> cost(n + k, INT_MAX);
	cost[0] = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 1; j <= k; j++)
		{
			chmin(cost[i + j], cost[i] + abs(h[i + j] - h[i]));
		}
	}

	cout << cost[n - 1] << endl;
}

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

int main() {
   string s;
   int ans=0;
   cin >> s;
   for(int i = s.size()/2-2; i >= 0; i--){
     if(s.substr(0, i+1) == s.substr(i+1, i+1)) {ans=i*2+2; break;}
   }
   cout << ans << endl;
}


Measured memory_bytes: 256