akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N;
int A[1000000];

int flg[1000000];

using P = pair<int, int>;
P ans[1000000];

signed main()
{
	cin >> N;
	int m = pow(2, N);
	REP(i, m) cin >> A[i];

	ans[0] = P(0, 0);

	for (int i = 1; i < m; i++)
	{
		priority_queue<P> q;
		q.push(P(A[0], 0));
		q.push(P(A[i], i));
		flg[0] = i;
		flg[i] = i;

		int bit = 1;
		while (true)
		{
			if (bit >= i) break;

			if ((i & bit) > 0)
			{
				int k = (i ^ bit);
				P m = ans[k];
				if (flg[m.first] != i)
				{
					flg[m.first] = i;
					q.push(P(A[m.first], m.first));
				}
				if (flg[m.second] != i)
				{
					flg[m.second] = i;
					q.push(P(A[m.second], m.second));
				}
			}

			bit <<= 1LL;
		}

		ans[i].first = q.top().second;
		q.pop();
		ans[i].second = q.top().second;
		q.pop();
	}

	for (int i = 1; i < m; i++)
	{
		int max = A[ans[i].first] + A[ans[i].second];;

		int bit = 2;
		while (true)
		{
			if (bit > i)
			{
				break;
			}

			if ((bit & i) > 0)
			{
				int fill = (bit - 1);
				int top = (i & (~((fill << 1) | 1)));
				int k = (top | fill);

				int a = A[ans[k].first] + A[ans[k].second];
				max = MAX(max, a);
			}

			bit <<= 1LL;
		}

		cout << max << endl;
	}
}







Measured memory_bytes: 17408
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
from copy import deepcopy
from collections import Counter


def dfs(G, i, fr, color):
    color[i] = 1
    for node in G[i]:
        if node != fr and node != -1 and color[node] == -1:
            dfs(G, node, i, color)

def main():
    n, m = list(map(int, input().strip().split()))
    G = [[] for _ in range(n)]
    for i in range(m):
        a, b = list(map(int, input().strip().split()))
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)
    ans = 0
    for i, node in enumerate(G):
        for j, edge in enumerate(G[i]):
            D = deepcopy(G)
            D[i][j] = -1
            color = [-1] * n
            dfs(D, 0, -1, color)
            c = Counter(color)[1]
            if c != n:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 49116
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;


class Program {

	static long mod = 1000000007;
	static int[] ans;
	static void Main(string[] args) {

		char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		int res = 0;

		int n = int.Parse(Console.ReadLine());
		int[] num=new int[n];
		for ( int i = 0; i < n; i++ ) {
			num[i] = int.Parse(Console.ReadLine());
		
		}

		int[] sort = (int[])num.Clone();
		Array.Sort(sort);
		Array.Reverse(sort);

		int a = sort[0];
		int b = sort[1];

		for ( int i = 0; i < n; i++ ) {
			if ( num[i] < a ) { res = a; } else if ( num[i] == a ) { res = b; }

			Console.WriteLine(res);

		}
			//Console.WriteLine(res);
			return;

	}



	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}


}

Measured memory_bytes: 18712
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring> 
using namespace std;
int n,m,x,y;
int X[10000],Y[10000],z;
bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
	cin>>n>>m>>x>>y;
	for(int i=1;i<=n;i++)cin>>X[i];
	for(int i=1;i<=m;i++)cin>>Y[i];
	for(int i=x;i<=y;i++)
	{
		int gg = 0,zz=0;
		for(int j=1;j<=n;j++)if(i>X[j])gg++;
		for(int j=1;j<=m;j++)if(Y[j]>=i)zz++;
		if(gg==n&&zz==m&&i>x&&i<=y)
		{
			cout<<"No War";
			return 0;
		}
	}
	cout<<"War";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
   ll x;
   cin>>x;int flag=0;
   for(int i=-200;i<=200;i++)
   {
       for(int j=-200;j<=200;j++)
       {
           if((pow(i,5)-pow(j,5))==x)
           {
               cout<<i<<" "<<j;
              goto ij;
           }
       }
   }
   ij:;
}


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

int main() {
  int r,g,b,n;
  cin>>r>>g>>b;
  n=r*100+g*10+b;
  if(n%4==0){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  
}



Measured memory_bytes: 256
# 43a
# 競プロ幼稚園には N 人の子供がいます。えび先生は、
# 子供たちを一列に並べ、一人目にはキャンディーを
# 1個,二人目には2個,..., N 人目にはN個あげることにしました。
# 必要なキャンディーの個数の合計は何個でしょう?

# Nに入力された数字を格納する
N = int(input())

# answer(計算結果を格納するところ)を定義
answer = 0


# while文で 1以上100以下の数字で値を繰り返し処理
# Nの値をanswerに＋するたびにNの値から-1するようにする
while 1 <= N <= 100:
    answer = answer + N
    N = N - 1

print(answer)

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

using namespace std;

typedef long long int i64;

int main()
{
	i64 n, w; cin >> n >> w;
	
	i64 wt[n], val[n];
	
	for (int i = 0; i < n; ++i) cin >> wt[i] >> val[i];
	
	i64 dp[n + 1][w + 1];
	
	for (int i = 0; i <= n; ++i)
	{
		for (int j = 0; j <= w; ++j)
		{
			if (i == 0 || j == 0)
			{
				dp[i][j] = 0;
			}
			
			else
			{
				if (j < wt[i - 1])
				{
					dp[i][j] = dp[i - 1][j];
				}
				
				else
				{
					dp[i][j] = max(dp[i - 1][j], val[i - 1] + dp[i - 1][j - wt[i - 1]]);
				}
			}
		}
	}
	
	cout << dp[n][w] << endl;
	
	return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	long long t;
  	cin>>t;
  	if(t>=30)
      	cout<<"Yes\n";
  	else
      	cout<<"No\n";	
	return 0;
}


Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Cicada
 */
public class Main {

	static int INF = Integer.MAX_VALUE;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		line = br.readLine();

		int H, W;
		H = parseInt(line.substring(0, line.indexOf(' ')));
		W = parseInt(line.substring(line.indexOf(' ') + 1));

		int[][] dp = new int[H + 2][W + 2];

		for (int i = 0; i < H + 2; i++) {
			for (int j = 0; j < W + 2; j++) {
				dp[i][j] = INF;
			}
		}
		dp[0][1] = 0;
		dp[1][0] = 0;

		for (int i = 0; i < H; i++) {
			line = br.readLine();
			for (int j = 0; j < W; j++) {
				dp[i + 1][j + 1] = line.charAt(j) - '0';
			}
		}

		//solve
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				dp[i][j] += Math.min(dp[i][j - 1], dp[i - 1][j]);
			}
		}
		System.out.println(dp[H][W]);
	} //end main
}

Measured memory_bytes: 24516
# -*- coding: utf-8 -*-


def run():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))[:n]
    b = sum(a) / (4 * m)

    if len(list(filter(lambda x: x >= b, a))) >= m:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    run()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
template<typename T> void read(T &num){
	char c=getchar();T f=1;num=0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){num=(num<<3)+(num<<1)+(c^48);c=getchar();}
	num*=f;
}
template<typename T> void qwq(T x){
	if(x>9)qwq(x/10);
	putchar(x%10+'0');
}
template<typename T> void write(T x){
	if(x<0){x=-x;putchar('-');}
	qwq(x);putchar('\n');
}
template<typename T> void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T> void chkmax(T &x,T y){x=x>y?x:y;}
int f[210][210];int co[210];int n;
inline bool dfs(int u,int col){
	if(co[u])return (co[u]==col);
	bool flag=true;co[u]=col;
	rep(i,1,n){
		if(f[u][i]!=1)continue;
		if(!dfs(i,3-col)){flag=false;break;}
	}
	return flag;
}

int main(){
	read(n);
	rep(i,1,n){
		rep(j,1,n){
			char ch;cin>>ch;
			f[i][j]=(ch=='0')*n+1;
			if(i==j)f[i][j]=0;
		}
	}
	if(!dfs(1,1)){write(-1);return 0;}
	
	rep(k,1,n){
		rep(i,1,n){
			rep(j,1,n)chkmin(f[i][j],f[i][k]+f[k][j]);
		}
	}
	int ans=0;
	rep(i,1,n){
		rep(j,1,n)chkmax(ans,f[i][j]);
	}
	write(ans+1);
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);

        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();        

        int add = c;
        if(a > b) add = c - (a - b);
        if(add < 0) add = 0;

        System.out.print(add);

        scan.close();
    }
}


Measured memory_bytes: 23764
/*
 * atcoder/abc119_2nd/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * 100            600
 *         400           900   1000
 *    150
 */
const ll INF = 1000000000000000;
ll A, B, Q;
ll x;
vector<ll> S, T;
void solve() {
  cin >> A >> B >> Q;
  S.push_back(-INF);
  T.push_back(-INF);
  loop(a,0,A) {
    cin >> x; S.push_back(x);
  }
  loop(b,0,B) {
    cin >> x; T.push_back(x);
  }
  S.push_back(INF);
  T.push_back(INF);

  loop(q,0,Q) {
    cin >> x;
    ll n = lower_bound(S.begin(), S.end(), x) - S.begin();
    ll m = lower_bound(T.begin(), T.end(), x) - T.begin();
    ll min_ = INF;
    chmin(min_, abs(x-S[n]) + abs(S[n]-T[m]));
    chmin(min_, abs(x-S[n]) + abs(S[n]-T[m-1]));
    chmin(min_, abs(x-S[n-1]) + abs(S[n-1]-T[m]));
    chmin(min_, abs(x-S[n-1]) + abs(S[n-1]-T[m-1]));
    chmin(min_, abs(x-T[m]) + abs(S[n]-T[m]));
    chmin(min_, abs(x-T[m]) + abs(S[n-1]-T[m]));
    chmin(min_, abs(x-T[m-1]) + abs(S[n]-T[m-1]));
    chmin(min_, abs(x-T[m-1]) + abs(S[n-1]-T[m-1]));
    cout << min_ << endl;
  }
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


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

int main() {
  int N,alice,bob;
  cin >> N;
  vector<int> cards(N + 10);
  for (int i = 0; i < N; i++) cin >> cards.at(i);
  sort(cards.begin(), cards.end());
  reverse(cards.begin(), cards.end());
  for (int i = 0; i < N; i += 2) {
    alice += cards.at(i);
    bob += cards.at(i + 1);
  }
  cout << alice - bob << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


int main() {
   int n;
   cin>>n;
   vector<int>a(n);
   vector<int>b(n);
   for(int i=0;i<n;i++){
       cin>>a.at(i);
       b.at(i)=a.at(i);
   }
   sort(b.begin(),b.end());
   for(int i=0;i<n;i++){
       if(a.at(i)==b.at(n-1)){
           cout<<b.at(n-2)<<endl;
       }
       else{
           cout<<b.at(n-1)<<endl;
       }
   }






    return 0;
}


Measured memory_bytes: 3200
#include <cstdio>
#include <iostream>
#include <algorithm>

inline int Get() {
	char ch;
	while ((ch = getchar()) < '0' || ch > '9');
	int Num = ch - '0';
	while ((ch = getchar()) >= '0' && ch <= '9')
		Num = (Num << 3) + (Num << 1) + ch - '0';
	return Num;
}
const int N = 55;
const int Mod = 1e9 + 7;
int n, a[N << 1], g[N][N << 1][N << 1], ans;
int main() {
	n = Get();
	for (int i = 1; i < n * 2; ++i) a[i] = Get();
	std :: sort(a + 1, a + n * 2);
	
	g[0][1][0] = 1;
	for (int i = 1, w; i < n; ++i) 
		for (int j = 1; j < i * 2; ++j)
			for (int k = 0; k < j; ++k)
				if (w = g[i - 1][j][k]) {
					int x = j, y = k;
					if (a[n - i] != a[n - i + 1]) ++x, ++y;
					if (a[n + i] != a[n + i - 1]) ++x;
					for (int p = 0; p < x; ++p)
						(g[i][x - std :: max(abs(y - p) - 1, 0)][p <= y ? p : y + 1] += w) %= Mod;
				}
				
	for (int i = 1; i < n * 2; ++i)
		for (int k = 0; k < i; ++k) (ans += g[n - 1][i][k]) %= Mod;
	
	printf("%d\n", ans);
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int d, n;  cin >> d >> n;
	cout << (int)pow(100 , d) * ((n == 100) ? 101 : n) << endl;

	return 0;
}


Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;
const int inf = 1e9;

int n, m, dis[N], from[N];
vector<int> adj[N];

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

	cin >> n >> m;

	for(int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	for(int i = 0; i < n; i++) {
		dis[i] = inf;
	}

	dis[0] = 0;

	queue<int> q;

	q.push(0);

	while(!q.empty()) {
		int u = q.front();
		q.pop();
		for(int v : adj[u]) {
			if(dis[v] > dis[u] + 1) {
				from[v] = u;
				dis[v] = dis[u] + 1;
				q.push(v);
			}
		}
	}

	for(int i = 1; i < n; i++) {
		if(dis[i] == inf) {
			cout << "No";
			exit(0);
		}
	}

	cout << "Yes\n";

	for(int i = 1; i < n; i++) {
		cout << from[i] + 1 << "\n";
	}

	
	return 0;
}


Measured memory_bytes: 10804
n=int(input())
A=list(map(int,input().split()))
r,g,b=0,0,0
ans=1
mod=10**9+7
for i in A:
    t=[r,g,b].count(i)
    if t==0:
        print(0)
        exit()
    elif t==1:
        if r==i: r+=1
        elif g==i : g+=1
        else: b+=1
    elif t==2:
        ans*=2  ; ans%=mod
        if r!=i: g+=1
        elif g!=i : b+=1
        else: r+=1
    else:
        ans*=3 ; r+=1 ; ans%=mod

print(ans%mod)

Measured memory_bytes: 52824
n=int(input())
a=[]
b=[]
c=[]
for i in range(n):
	x,y,z=map(int,input().split())
	a.append(x)
	b.append(y)
	c.append(z)
dp=[[a[0],b[0],c[0]]]
for i in range(n-1):
	x=a[i+1]+max(dp[i][1],dp[i][2])
	y=b[i+1]+max(dp[i][0],dp[i][2])
	z=c[i+1]+max(dp[i][0],dp[i][1])
	dp.append([x,y,z])
print(max(dp[-1]))

Measured memory_bytes: 34652
#include <iostream>
#include <algorithm>
using namespace std;
#define ct(string) cout << string << endl

int main() {
    int a, b;
  	cin >> a >> b;
    if (a < b) swap(a, b);
    if (a - b > 1) ct(2*a-1);
    else ct(a+b);
}


Measured memory_bytes: 256
N = int(input())
C=list(input())
type=set(C)
L=0
R=0
RR=0
X=0
if 'R' in type and 'W' in type:
    for L in range(N):
      R=RR
      if L>=N-1-R:
        break
      if C[L]=='W':
          for ii in range(N-L-R):
            if C[N-1-R-ii]=='R':
              C[L]='R'
              C[N-1-R-ii]='W'
              X+=1
              break
            RR+=1
            if L>=N-1-R:
              break
print(X)

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


int main() {
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  int sum = 0;
  if(x>=y){
    if(a+b <= c*2){
      sum = a*x + b*y;
    }
    else if(a <= c*2){
      sum = c*2*y + a*(x-y); 
    }
    else{
      sum = c*2*x;
    }
  }
  else{
    if(a+b <= c*2){
      sum = a*x + b*y;
    }
    else if(b <= c*2){
      sum = c*2*x + b*(y-x); 
    }
    else{
      sum = c*2*y;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int n;
	cin >> n;
	int value;
	vector<int> v[n + 1];
	for(int i = 1; i <= n; i++)
	{
		cin >> value;
		v[i].push_back(value);
		cin >> value;
		v[i].push_back(value);
		cin >> value;
		v[i].push_back(value);
		
	}	
	int dp[n + 1][3];
	// dp[i][j] is the maximum point achievable in the interval
	// of 1 to i, by doing the jth task.
	for(int i = 0; i <= n; i++)
	{
		for(int j = 0; j < 3; j++)
		{
			if(i == 0)
			{
				dp[i][j] = 0;
				continue;
			}
			dp[i][j] = max(dp[i - 1][(j + 1)%3], dp[i - 1][(j + 2)%3]) + v[i][j];
			//cout << dp[i][j] << " ";
		}
		//cout << endl;
	}
	int answer = max(dp[n][0], max(dp[n][1], dp[n][2]));
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 6912
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>   
#include <stdio.h>    
 
using namespace std;
     
#define F first
#define S second
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)5e5 + 123;
const ll inf = (ll)3e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, a[N], p1[N], p2[N], sum;
string s;

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> s;
   int n = sz (s);
   for (int i = 1; i <= n; i ++) {
      if (s[i - 1] == '>') p1[i] = 0;
      else p1[i] = p1[i - 1] + 1;
    } 
    for (int i = n - 1; i >= 0; i --) {
      if (s[i] == '<') p2[i] = 0;
      else p2[i] = p2[i + 1] + 1;
    }
    for (int i = 0; i <= n; i ++)
      sum += max (p1[i], p2[i]);
   cout << sum;
}                                     

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}


Measured memory_bytes: 9116
package main

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

func check(n int, hates []string) bool {
	s := strconv.Itoa(n)
	ss := strings.Split(s, "")
	for _, x := range ss {
		for _, hate := range hates {
			if x == hate {
				return false
			}
		}
	}
	return true
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	sc := bufio.NewScanner(os.Stdin)
	l := make([]string, k)
	sc.Scan()
	l = strings.Split(sc.Text(), " ")

	// ここから解
	r := n
	for {
		if check(r, l) {
			break
		}
		r++
	}
	fmt.Println(r)
}


Measured memory_bytes: 5968
import numpy as np
MOD = 10**9 + 7
def solve(s):
    n = len(s)
    dp = np.zeros((n+1, 4), dtype=int)
    dp[0,0] = 1
    for i in range(n):
        t = 2 * int(s[i] == "?") + 1
        dp[i+1] = t * dp[i] % MOD
        if s[i] == "A":
            dp[i+1,1] += dp[i,0]
        elif s[i] == "B":
            dp[i+1,2] += dp[i,1]
        elif s[i] == "C":
            dp[i+1,3] += dp[i,2]
        else:
            dp[i+1,1:] += dp[i,:-1]
    return dp[n][3] % MOD

s = input()
print(solve(s))

Measured memory_bytes: 16800
#include <cmath>
#include <iostream>
typedef long long int ll;
typedef long double ld;

int main(void){
	ll A, res;
	ld b;
	std::cin >> A >> b;
	ld B = std::round(b * 100);
	res = A * B;
	
	std::cout << res/100 << std::endl;
	return 0;
}


Measured memory_bytes: 3792
import os, sys

def msd(n):
  d = 0
  while n > 0:
    d = n % 10
    n //= 10
  return d

def main():
  N = int(input())
  c = [[0] * 10 for _ in range(10)]
  for n in range(1, N + 1):
    l = msd(n)
    r = n % 10
    c[l][r] += 1
  #print(c)
  ans = 0
  for i in range(1, 10):
    for j in range(1, 10):
      ans += c[i][j]*c[j][i]
  print(ans)


if __name__ == '__main__':
  if sys.platform == 'ios':
    sys.stdin = open(os.path.splitext(__file__)[0] + '.txt')
  sys.setrecursionlimit(10**6)
  main()


Measured memory_bytes: 3064
//
//  main.cpp
//  Sample
//
//  Created by h3037183 on 2017/07/31.
//  Copyright ?? 2017??´ ?°????. All rights reserved.
//

#include <iostream>
using namespace std;
int main(){
    int a,b,c,i;
    cin>>i;
    for(int n=0;n<i;n++){
        cin>>a>>b>>c;
        if(a*a == b * b + c * c){
            cout<<"YES"<<endl;
        }else if(b*b == a * a + c * c){
            cout<<"YES"<<endl;
        }else if(c*c == b * b + a * a){
                cout<<"YES"<<endl;
        }else{cout<<"NO"<<endl;}
    }
    return 0;
}

Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M=100005;
int n;
int a[M];
int C[M*10];
int s[M*10];
int lowbit(int i)
{
    return i & -i;//或者是return i-(i&(i-1));表示求数组下标二进制的非0最低位所表示的值
}
void update(int i,int val)//单点更新
{
    while(i<=2*M){
        C[i]+=val;
        i+=lowbit(i);//由叶子节点向上更新树状数组C，从左往右更新
    }
}
ll sum(int i)//求区间[1,i]内所有元素的和
{
    ll ret=0;
    while(i>0){
        ret+=C[i];//从右往左累加求和
        i-=lowbit(i);
    }
    return ret;
}

bool check(int x)
{
    for(int i=1;i<=2*M;i++) C[i]=0;
    s[0]=0;
    for(int i=1;i<=n;i++)
        s[i]=s[i-1]+(a[i]>=x?1:-1);
    ll ans=0;
    for(int i=0;i<=n;i++)
    {
        ans+=sum(s[i]+M);
        update(s[i]+M,1);
    }
    return ans>=(ll)n*(n+1)/4;
}



int main()
{
    int l=0,r=0;
    ios_base::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        r=max(r,a[i]);
    }
    int ans=0;
    while(l<=r)
    {
        int mid=(l+r)/2;
        if(check(mid))
        {
              l=mid+1;
              ans=mid;
        }

        else
            r=mid-1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef double db;
const int mod = 1e9 + 7;
const int N = 1e6 + 5;
int n, m, k;
int a[N];

ll fac[N + 5];
ll inv[N + 5];
ll qpow(ll a, ll b)
{
    ll r = 1, t = a;
    while (b) {
        if (b & 1)r = (r*t) % mod;
        b >>= 1;
        t = (t*t) % mod;
    }
    return r;
}
void init()
{
    fac[0] = 1;
    for (int i = 1;i <= N;i++) fac[i] = fac[i - 1] * 1ll * i%mod;
    inv[N] = qpow(fac[N], mod - 2);
    for (int i = N - 1;~i;i--) inv[i] = inv[i + 1] * 1ll * (i + 1) % mod;
}
ll C(ll n, ll m)
{
    if (m>n) return 0;
    if (m == n || m == 0) return 1;
    return fac[n] * 1ll * inv[n - m] % mod*inv[m] % mod;
}
int main(){
    init();
    scanf("%d%d", &n, &k);
    rep(i,1,n) scanf("%d", &a[i]);
    sort(a+1,a+1+n);
    ll ans = 0;
    rep(i,1,n){
        if(i>=k)
            ans=(ans+C(i-1,k-1)*a[i]%mod)%mod;
        if(i<=n-k+1)
            ans=(ans-C(n-i,k-1)*a[i]%mod+mod)%mod;
    }
    printf("%lld\n", ans);
    return 0;
}
//
//                            _ooOoo_
//                           o8888888o
//                           88" . "88
//                           (| -_- |)
//                           O\  =  /O
//                        ____/`---'\____
//                      .'  \|     |//  `.
//                     /  \|||  :  |||//  \
//                    /  _||||| -:- |||||-  \
//                    |   | \  -  /// |   |
//                    | \_|  ''\---/''  |   |
//                    \  .-\__  `-`  ___/-. /
//                  ___`. .'  /--.--\  `. . __
//               ."" '<  `.___\_<|>_/___.'  >'"".
//              | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//              \  \ `-.   \_ __\ /__ _/   .-` /  /
//         ======`-.____`-.___\_____/___.-`____.-'======
//                            `=---='
//        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//                     佛祖保佑      永无BUG


Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const ll INF = 1e17;

int n;
ll x[15], y[15], p[15];

set<ll> sx, sy;
vector<ll> ans(20,INF);

ll dfs(int id) {
  ll dis = INF;
  if(id == n) {
    int l = sx.size() + sy.size() - 2;
    dis = 0;
    rep(i,n) {
      ll res = INF;
      auto itr = sx.lower_bound(x[i]);
      if(itr != sx.end()) res = min(res,abs(x[i]-(*itr)));
      if(itr != sx.begin()) {
        itr--;
        res = min(res,abs(x[i]-(*itr)));
      }
      itr = sy.lower_bound(y[i]);
      if(itr != sy.end()) res = min(res,abs(y[i]-(*itr)));
      if(itr != sy.begin()) {
        itr--;
        res = min(res,abs(y[i]-(*itr)));
      }
      dis += p[i]*res;
      if(dis >= ans[l]) break;
    }
    ans[l] = min(ans[l],dis);
  } else {
    dis = min(dis,dfs(id+1));
    if(sx.find(x[id]) == sx.end()) {
      sx.insert(x[id]);
      dis = min(dis,dfs(id+1));
      sx.erase(x[id]);
    }
    if(sy.find(y[id]) == sy.end()) {
      sy.insert(y[id]);
      dis = min(dis,dfs(id+1));
      sy.erase(y[id]);
    }
  }
  return dis;
}

int main(){
  cin >> n;
  rep(i,n) cin >> x[i] >> y[i] >> p[i];
  sx.insert(0);
  sy.insert(0);
  dfs(0);
  rep(i,n+1) {
    if(i > 0) ans[i] = min(ans[i],ans[i-1]);
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <string>
constexpr auto BASE = 1000000007;

using namespace std;

string S;

int main()
{
	cin >> S;
	int N = S.size();

	vector<vector<long long>> dp(N,vector<long long>(13,0));

	if(S[0]=='?'){
		for (int j = 0; j < 10; j++) {
			dp[0][j] = 1;
		}
	}
	else {
		dp[0][S[0] - '0'] = 1;
	}
	for (int i = 1; i < N; i++) {
		for (int k = 0; k < 13; k++) {
			if (S[i] == '?') {
				for (int j = 0; j < 10; j++) {
					dp[i][(k * 10 + j) % 13] += dp[i - 1][k];
				}
			}
			else {
				int c = S[i] - '0';
				dp[i][(k * 10 + c) % 13] += dp[i - 1][k];
			}
		}
		for (int k = 0; k < 13; k++) {
			dp[i][k] %= BASE;
		}

	}

	int ans = dp[N - 1][5];

	cout << ans << endl;

	return 0;
}



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

using namespace std;

template<typename C>
class fenwick {
  vector<C> t;
  int n;
public:
  fenwick(int _n) : n(_n) {
    t.resize(n);
  }
  fenwick(const vector<C>& a) : n(a.size()) {
    t.resize(n);
    for (int i = 0; i < n; ++i) {
      upd(i, a[i]);
    }
  }

  C get(int k) {
    C res = 0;
    for (k; k >= 0; k = (k & (k + 1)) - 1) {
      res += t[k];
    }
    return res;
  }

  void upd(int k, C x) {
    for (k; k < n; k |= k + 1) {
      t[k] += x;
    }
  }

  C get(int l, int r) {
    return get(r) - get(l - 1);
  }
};

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

  int n, q;
  cin >> n >> q;
  vector<int> c(n);
  vector<int> lst(n, -1), kek(n, -1);
  for (int i = 0; i < n; ++i) {
    cin >> c[i];
    --c[i];
    lst[i] = kek[c[i]];
    kek[c[i]] = i;
  }
  vector<vector<pair<int, int>>> qr(n);
  for (int i = 0; i < q; ++i) {
    int l, r;
    cin >> l >> r;
    --l, --r;
    qr[r].emplace_back(l, i);
  }
  vector<int> ans(q);
  fenwick<int> f(n);
  for (int r = 0; r < n; ++r) {
    if (lst[r] != -1) {
      f.upd(lst[r], -1);
    }
    f.upd(r, 1);
    for (auto [l, i] : qr[r]) {
      ans[i] = f.get(l, r);
    }
  }
  for (int i = 0; i < q; ++i) {
    cout << ans[i] << '\n';
  }

  return 0;
}


Measured memory_bytes: 35196
#include <stdio.h>
#include <string.h>
#define N 1000

void cm(char a[] , char b[]);
int max(int a , int b);
int c[N+1][N+1];

int main()
{
	char a[N];
	char b[N];
	int i , n;
	scanf("%d",&n);
	for(i = 1; i <= n; i++)
	{
		scanf("%s%s",a+1,b+1);
		a[0]=b[0]= ' ';
		cm(a,b);
	}
}

int max(int a , int b)
{
	if(a < b)return b;
	else return a;
}

void cm(char  a[]  , char b[])
{
	int i , j;
	int m1,m2;
	m1 = strlen(a)-1;
	m2 = strlen(b)-1;
	int ma = 0;
	for(i=0;i<m1;i++)
	{
		c[0][i]=0;
	}
	for(j=0;j<m2;j++)
	{
		c[0][j]=0;
	}
	for(int i = 1; i <=m1; i++)
	{
		for(int j = 1; j<=m2; j++)
		{
			if(a[i]==b[j])
			{
				c[i][j]=c[i-1][j-1]+1;
			}
			else
			{
				c[i][j]=max(c[i-1][j],c[i][j-1]);
			}
			ma = max(ma,c[i][j]);
				
		}
	}
	printf("%d\n",ma);
}



Measured memory_bytes: 5768
#include<bits/stdc++.h>
using namespace std;
int main(){
 
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
      int a,b;
      cin>>a>>b;
      if(b>=2*a && b<=4*a && b%2==0)cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  string s, t;
  cin >> s >> t;
  int n = s.size();
  vector<int> rs(26, -1), rt(26, -1);
  REP(i, n){
    if(rs[s[i]-'a'] < 0){
      rs[s[i]-'a'] = t[i];
    }else{
      if(rs[s[i]-'a'] != t[i]){
        cout << "No" << endl;
        return 0;
      }
    }
    if(rt[t[i]-'a'] < 0){
      rt[t[i]-'a'] = s[i];
    }else{
      if(rt[t[i]-'a'] != s[i]){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 776
from collections import Counter

N,K = map(int,input().split())
A=list(map(int,input().split()))
count = Counter(A)
count = count.most_common()
diff = len(count)-K
ans=0
if diff>0:
    for i in range(diff):
        ans+=count[len(count)-i-1][1]

print(ans)

Measured memory_bytes: 39320
#include<bits/stdc++.h>
#define SORT(v) sort(v.rbegin() , v.rend())
#define si(n) scanf( "%d" , &n)
#define sii(n , m) scanf( "%d %d" , &n , &m)
#define sl(n) scanf( "%lld" , &n)
#define sll(n , m) scanf( "%lld %lld" , &n, &m)
#define ss(cad) scanf( "%s" , cad)
#define sz(x) (int)x.size()
#define PB push_back
#define fst first
#define scn second
#define DBG(x) cerr << #x << " = " << (x) << endl
#define M 1000000007
#define N_MAX 1000010
#define EPS 1e-9

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<pi> vp;

ll vec[200100];

int main(){
	int n;
	si(n);
	ll sum = 0;
	for(int i = 0; i < n; i++){
		sl(vec[i]);
		vec[i] %= M;
		sum += vec[i];
		sum %= M;
	}
	ll ans = 0;
	for(int i = 0; i < n; i++){
		sum -= vec[i];
		sum = (sum%M+M)%M;
		ans += (vec[i]*sum)%M;
		ans %= M;
	}
	printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 5320
def s2int(a):
    dot_idx = -1
    for j in range(len(a)):
        if a[j] == '.':
            dot_idx = j
            break
    # .がないので末尾につける
    if dot_idx == -1:
        a += ".000000000"
    # .の場所に応じて後ろにつける
    else:
        while len(a) < 10+dot_idx:
            a += "0"
    tmps = ""
    for j in range(len(a)):
        if a[j] == '.':continue
        tmps += a[j]
    return int(tmps)

def Count_two_five(x):
    c2 = 0
    c5 = 0
    while x > 0 and x % 2 == 0:
        x //= 2
        c2 += 1
    while x > 0 and x % 5 == 0:
        x //= 5
        c5 += 1
    c2 = min(c2, 18)
    c5 = min(c5, 18)
    return c2, c5

N = int(input())

C2 = [0] * N
C5 = [0] * N

for i in range(N):
    C2[i], C5[i] = Count_two_five(s2int(str(input())))

Cc = [[0] * 19 for _ in range(19)]

for i in range(N):
    Cc[C2[i]][C5[i]] += 1

ans = 0
for i in range(N):
    Cc[C2[i]][C5[i]] -= 1
    l2 = max(0, 18 - C2[i])
    l5 = max(0, 18 - C5[i])
    for j in range(l2, 19):
        for k in range(l5, 19):
            ans += Cc[j][k]
    Cc[C2[i]][C5[i]] += 1

print(ans//2)

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

int main() 
{
	long long S, C;
	cin >> S >> C;
	
	long long no_of_pieces = min(S, C/2);
	
	S -= no_of_pieces;
	C -= 2*no_of_pieces;
	
	no_of_pieces += C/4;
	
	cout << no_of_pieces;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <vector>
using namespace std;

int main(){

    int N, M;
    int a[55], b[55];
    int ans;

    cin >> N >> M;
    for(int i = 0; i < M; ++i){
        cin >> a[i] >> b[i];
    }

    for(int i = 1; i <= N; ++i){
        ans = 0;
        for(int j = 0; j < M; ++j){
            if(i == a[j] || i == b[j]){
                ++ans;
            }
        }
        cout << ans << endl;
    }
}

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

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

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

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	iip(k);
	priority_queue<int, vector<int>, greater<int>> pq;
	for(int i = 1; i < 10; i++)
	{
		pq.push(i);
	}
	int ans;
	while(k--)
	{
		ans = pq.top();
		pq.pop();
		if(ans %10 == 9)
		{
			int r = ans % 10;
			pq.push(ans*10 + r - 1);
			pq.push(ans*10 + r);
		}
		else if(ans%10)
		{
			int r = ans % 10;
			pq.push(ans*10 + r - 1);
			pq.push(ans*10 + r);
			pq.push(ans*10 + r + 1);
		}
		else
		{
			pq.push(ans*10);
			pq.push(ans*10 + 1);
		}
		
	}
	cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;




int main() {

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	while (true) {
		c -= b;
		if (c <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
		a -= d;
		if (a <= 0) {
			cout << "No" << endl;
			return 0;
		}
	}


}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  int ans = 0;
  for(int i = 0; i <= N; i++) {
    int sum = 0;
    int x = i;
    
    for(int j = 0; j < 5; j++) {
      sum += x % 10;
      x /= 10;
    }
    
    if(A <= sum && sum <= B) {
      ans += i;
    }
  }
  
  cout << ans << endl;
}  

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

int main(){
  int x;
  cin >> x;
  if( x == 2 ){
    cout << 2 << endl;
    return 0;
  }
  while(true){
    for(int i=2;i<x;i++){
      if( x%i == 0 ){
        x++;
        break;
      }else if( i == x-1 ){
        cout << x << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    vector<ll> dp(n);
    dp[0] = 0;
    for (ll i = 1; i < n; i++) {
        dp[i] = 1LL<<60;
        for (ll j = 1; j <= k; j++) {
            if (i-j >= 0) chmin(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())

const int N = 1e5 + 100;
vector<vector<int>> g(N);
vector<bool> visited(N, false);

void dfs(int v) {
	visited[v] = true;
	for (auto &u : g[v]) {
		if (!visited[u]) dfs(u);
	}
}
signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v, z;
		cin >> u >> v >> z;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (!visited[i]) {
			ans++;
			dfs(i);
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 8832
import queue

k = int(input())

q = queue.Queue()
x = 0

for i in range(1, 10):
    q.put(i)

for j in range(k):
    x = q.get()
    if x%10!=0:
        q.put((x*10)+(x%10)-1)
    q.put((x*10)+(x%10))
    if x%10!=9:
        q.put((x*10)+(x%10)+1)

print(x)


Measured memory_bytes: 13108
import scala.collection.mutable
import scala.io.StdIn.{readInt, readLine}

object Main extends App {

  val n  = readInt()
  val xs = readLine().split(" ").map { _.toInt }
  readLine()
  val ys = readLine().split(" ").map { _.toInt }

  val zs = mutable.Set.empty[Int]
  for {
    i  <- 1 to n
    cs <- xs.combinations(i).map { _.sum }
  } {
    zs += cs
  }

  for {
    y  <- ys
    ans = if (zs.contains(y)) "yes" else "no"
  } {
    println(ans)
  }
}



Measured memory_bytes: 219100
using System;
using System.Numerics;
using System.Collections.Generic;
using System.Linq;

namespace d
{
    class Program
    {
        static void Main(string[] args)
        {
            var k = int.Parse(Console.ReadLine());

            var q = new Queue<BigInteger>();
            for(var i = 1; i < 10; i++){
                q.Enqueue(i);
            }

            var count = 0;
            BigInteger n = 0;
            while(count < k){
                n = q.Dequeue();
                var mod = n % 10;

                if(mod != 0){
                    q.Enqueue((n * 10) + (mod - 1));
                }

                q.Enqueue((n * 10) + mod);

                if(mod != 9){
                    q.Enqueue((n * 10) + (mod + 1));
                }

                count++;
            }

            Console.WriteLine(n);
        }
    }
}


Measured memory_bytes: 31188
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main()
{
	int n, k, d[10] = {}, t, i;

	cin >> n >> k;
	for(i = 0; i < k; i++){
		cin >> t;
		d[t]++;
	}

	for(;;n++){
		for(i = n; i > 0; i /= 10){
			if(d[i % 10])break;
		}
		if(i == 0){
			cout << n << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
	int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    
    if(A==B&&A==C&&B==C)
    	printf("No\n");
    else if(A!=B&&A!=C&&B!=C)
      	printf("No\n");
  	else
      	printf("Yes\n");

        
    return 0;
}

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

using namespace std;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD 1e9 + 7
#define PAI  3.1415
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

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

struct UnionFind {
  vi par; //par[i] : iの親番号（例）par[3] = 2 : 3の親は2

  UnionFind(int N) : par(N) { //最初は全てが根として初期化
    rep(i,N) par[i] = i;
  }

  int root(int x){ //データxが属する木の根を再帰で得る : root(x) = {xの木の根}
    if(par[x] == x)return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y){ //xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if(rx == ry)return; //xとyの根が同じ
    par[rx] = ry; //xとyの根が同じでない時、xの根rxをyの根にryにつける。
  }

  bool same(int x, int y){//2つのデータx，yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main(){

  int n;
  int tanka[5] ={5,7,5,7,7};

  while(cin >> n,n){
    vi v(100,0);
    string s;
    rep(i,n){
      cin >> s;
      v[i] = s.length();
    }

    int pos = 0,sum = 0,ans = 0;

    rep(i,n){
      sum +=  v[i];
      if(sum == v[i] && pos == 0)ans = i + 1;

      if(sum == tanka[pos]){
        pos++;
        sum = 0;
      }
      else if(sum > tanka[pos]){
        if(ans != 0)i = ans - 1;
        pos = 0;
        sum = 0;
        ans = 0;
      }
      if(pos > 4){
        pr(ans);
        break;
      }
    }

  }

  return 0;

}


Measured memory_bytes: 3148
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
	int a,b,c,i=0;
	while(cin>>a>>b)
	{
		c=a+b;
		i=0;
		while(c)
		{
			c=c/10;
			i++;
		}
		cout<<i<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b ;
  cin >> a >> b;
  
  if ( a % 2 == 0 || b % 2 == 0){
    cout << "Even" << endl;
  }
  else
    cout << "Odd" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int c[9];
    imfor(i, 9) {
        cin >> c[i];
    }
    if (c[3] - c[0] == c[4] - c[1] && c[5] - c[2] == c[3] - c[0]) {
        if (c[6] - c[0] == c[7] - c[1] && c[8] - c[2] == c[6] - c[0]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r) {
    if(l >= r) return;
    int root = pre[pos++];
    int m = distance(in.begin(), find(in.begin(), in.end(), root));
    rec(l, m);
    rec(m + 1, r);
    post.push_back(root);
}

void solve() {
    pos = 0;
    rec(0, pre.size());
    for(int i = 0; i < n; i++) {
        if(i) cout << " ";
        cout << post[i];
    }
    cout << endl;
}

int main() {
    int k;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> k;
        pre.push_back(k);
    }
    
    for(int i = 0; i < n; i++) {
        cin >> k;
        in.push_back(k);
    }
    
    solve();
    
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int h[1010];

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

    int ans = 0;
    for(int i = 0;i < n;i++){
        bool f = true;
        for(int j = 0;j < i;j++){
            if(h[j] > h[i]){
                f = false;
                break;
            }
        }
        if(f) ans++;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define N 1000000007
#define ll long long
#define ull unsigned long long
#define mem(a) memset(a,0,sizeof(a))
int s[110];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int m, n;
    cin >> n >> m;
    for(int i = 0; i < n; i++) cin >> s[i];
    double sum = 0;
    for(int i = 0; i < n; i++) sum += s[i];
    int cnt = 0;
    sum = sum/(m*4.0);
    for(int i = 0; i < n; i++){
        if(s[i]>=sum) cnt++;
    }
    if(cnt<m){
        cout << "No" << endl;
    }else{
        cout << "Yes" << 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;

int main() {
	int m, f, r;
	while (cin >> m >> f >> r, ~m || ~f || ~r) {
		if (!~m || !~f)puts("F");
		else if (m + f >= 80)puts("A");
		else if (m + f >= 65)puts("B");
		else if (m + f >= 50)puts("C");
		else if (m + f >= 30) {
			if (r >= 50)puts("C");
			else puts("D");
		}
		else puts("F");
	}
}

Measured memory_bytes: 3056