akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[222222];
int main(){
    ll n,t,b,i,j,k;
    cin>>k>>n;
    for(i=0;i<n;i++)cin>>a[i];
    ll mi=a[n-1]-a[0];
    for(i=0;i<n-1;i++){
        mi=min(mi,k-a[i+1]+a[i]);
    }
    cout<<mi;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define LL long long
#define X first
#define PB push_back
#define Y second
using namespace std;
int h , w;
vector<int> values[200005];
set<pair<int , int> > used;

int main() 
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> h >> w >> n;
    int ans = h;
    for(int i = 0; i < n; i++)
    {
        int x , y;
        cin >> x >> y;
        used.insert({x , y});
        values[y].PB(x);
    }
    
    for(int i = 1; i < 200005; i++)
    {
        values[i].PB(1000 * 1000 * 1000);
        sort(values[i].begin() , values[i].end());
    }
    int y = 1;
    for(int i = 1; i <= h; i++)
    {
        ans = min(ans , *lower_bound(values[y].begin() ,values[y].end() , i + 1) - 1);
        if(!used.count({i + 1 , y + 1}))
            y++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 20992
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

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

    sort(h.begin(), h.end());

    ll ans = 1e18;
    for (int i = 0; i <= N - K; i++) {
        ans = min(ans, abs(h[i] - h[i + K - 1]));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
use std::io;

fn main() {
    let mut buf = String::new();

    // 1行目の読み込み
    io::stdin().read_line(&mut buf).expect("Failed to read line");
    let vec_1: Vec<&str> = buf.split_whitespace().collect();
    let n: i32 = vec_1[0].parse().unwrap_or(0);
    let r: i32 = vec_1[1].parse().unwrap_or(0);
    let ans = if n >= 10 {
        r
    } else {
        r + 100 * (10-n)
    };

    println!("{}", ans);
}

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


int main(){

  int x,y,z;
  int x2,y2,z2;
  int x3,y3,z3;

  scanf("%d %d %d",&x,&y,&z);

  x2 = y;
  y2 = x;
  z2 = z;
 
  x3 = z2;
  y3 = y2;
  z3 = x2;

  printf("%d %d %d",x3,y3,z3);

  return(0);

}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  if( a == b ) {
  	cout << "Draw" << endl;
  } else if ( a == 1 ) {
    cout << "Alice" << endl;
  } else if ( b == 1 ) {
    cout << "Bob" << endl;
  } else if (a > b) {
    cout << "Alice" << endl;
  } else {
    cout << "Bob" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int is_Stable(char b[36][2], char s[36][2], int n){
	int i;
	int stable = 1;

	for (i = 0; i < n; i++) {
		if (b[i][1] == s[i][1] && b[i][0] != s[i][0]) {
			stable = 0;
		}
	}

	return stable;
}

int main(void){
	int n, i, j, k, rec,  min;
	char a[36][2], b[36][2], s[36][2], tmp[2];
	int stable = 1;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s", a[i]);
		for (k = 0; k < 2; k++) {
			b[i][k] = a[i][k];
			s[i][k] = a[i][k];
		}
	}

	//Bubble_Sort
	for (i = 0; i < n - 1; i++) {
		for (j = n - 1; j > i; j--) {
			if (b[j][1] < b[j - 1][1]) {
				for (k = 0; k < 2; k++) {
					tmp[k] = b[j][k];
					b[j][k] = b[j - 1][k];
					b[j - 1][k] = tmp[k];
				}
			}
		}
	}

	//Selection_Sort
	for (i = 0; i < n - 1; i++) {
		min = s[i][1];
		rec = i;
		for (j = i; j < n; j++) {
			//Min
			if (min > s[j][1]) {
				min = s[j][1];
				rec = j;
			}
		}
		//Change
		if (i != rec) {
			for (k = 0; k < 2; k++) {
				tmp[k] = s[i][k];
				s[i][k] = s[rec][k];
				s[rec][k] = tmp[k];
			}
		}
	}

	for (i = 0; i < n; i++) {
		printf("%c%c", b[i][0], b[i][1]);
		if (i != n - 1) {
			putchar(' ');
		}
	}
	putchar('\n');

	printf("Stable\n");

	stable = is_Stable(b, s, n);

	for (i = 0; i < n; i++) {
		printf("%c%c", s[i][0], s[i][1]);
		if (i != n - 1) {
			putchar(' ');
		}
	}
	putchar('\n');

	if (stable == 1) {
		printf("Stable\n");
	}
	else {
		printf("Not stable\n");
	}
	
	return 0;
}



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

signed main() {
  int n; cin >> n;
  vector<int> w(n);
  for(int i = 0; i < n; i++) cin >> w[i];

  int ans = 1e9;
  for(int i = 1; i < n; i++) {
      int sum_l = 0, sum_r = 0;
      for(int j = 0; j < i; j++) sum_l += w[j];
      for(int j = i; j < n; j++) sum_r += w[j];
      ans = min(ans, abs(sum_l - sum_r));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    int X, Y, Z;
    int[] V;
    int[] F;
    int[] T;
    bool input() {
        scanf("%d %d %d\n", &X, &Y, &Z);
        if (X == 0 && Y == 0 && Z == 0) return false;
        Y++;
        F = new int[Y];
        T = new int[Y];
        V = readln.chomp.split(" ").map!(to!int).array;
        foreach (i; 0 .. Z) {
            int N, E, A; scanf("%d %d %d\n", &N, &E, &A);
            F[N] = A;
            T[N] = E;
        }
        return true;
    }
    void solve() {
        double[][] memo1 = new double[][](Y, Z * 100 + 1);
        double[][] memo2 = new double[][](Y, Z * 100 + 1);
        foreach (i; 0 .. Y) {
            memo1[i][] = -1;
            memo2[i][] = -1;
        }
        double dfs2(int x, int t) {
            double dfs1(int x, int t) {
                if (x >= Y) return t;
                if (memo1[x][t] >= 0) return memo1[x][t];
                double ret = 0;
                foreach (v; V) {
                    ret += dfs2(x + v, t);
                }
                return memo1[x][t] = ret / X;
            }
            if (x >= Y) return t;
            if (memo2[x][t] >= 0) return memo2[x][t];
            if (T[x] == 0) return dfs1(x, t);
            switch (T[x]) {
                case 1: return memo2[x][t] = dfs1(x + F[x], t);
                case 2: return memo2[x][t] = dfs1(x, t + F[x]);
                case 3: return memo2[x][t] = dfs1(x, max(0, t - F[x]));
                default: assert(0);
            }
        }
        writefln("%d", cast(int)dfs2(0, 0));
    }
    while (input) solve;
}

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

namespace _1_8_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            char[] c = s.ToCharArray();
          
            for (int i = 0; i < s.Length; i++)
            {
                if (char.IsUpper(c[i]))
                {
                    c[i] = char.ToLower(c[i]);
                }
                else if (char.IsLower(c[i]))
                {
                    c[i] = char.ToUpper(c[i]);
                }
            }
            Console.WriteLine(c);
            Console.ReadKey();
        }
    }
}



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

int main(){
  string s,t;
  cin>>s>>t;
  bool b=true;
  for (int i=s.size()-t.size();i>=0;i--){
    bool a=true;
    for (int j=0;j<t.size();j++){
      if (s.at(i+j)!='?' && s.at(i+j)!=t.at(j)) a=false;
    }
    if (a){
      for (int j=0;j<t.size();j++){
        s.at(i+j)=t.at(j);
      }
      b=false;
      break;
    }
  }
  if (b) cout<<"UNRESTORABLE"<<endl;
  else{
  for (int i=0;i<s.size();i++){
    if (s.at(i)=='?') s.at(i)='a';
  }
  cout<<s<<endl;
  }
}

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

int main(){
    long N;
    long black_count = 0;
    long white_count = 0;
    long ans_count = 2e5 + 1;
    string S;

    cin >> N >> S;
    for(long i=0;i<N;i++){
        if(S[i] == '.'){
            white_count++;
        }
    }

    S = S + "-";
    for(long i=0;i<=N;i++){
        ans_count = min(ans_count, white_count+black_count);
        if(S[i] == '.'){
            white_count--;
        }
        else if(S[i] == '#'){
            black_count++;
        }
    }
    cout << ans_count << endl;

    return 0;
}

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

using namespace std;

int main(){
	int x;
	cin>>x;	
	int y=x;
	int sum=0;
	while(x>10)
	{
		sum+=x%10;
		x/=10;
	}
	sum+=x;

	if(y%sum==0) cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

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

  
  int cnt=0;

  for(int i=n;i>=1;i--){
    for(int j=2;j<=n;j++){
      int ans=j;
      while(ans<=i){
	ans*=j;
	if(ans==i){
	  cnt=i;
	  break;
	}
      }
    }
    if(cnt){
      break;
    }
  }
  if(cnt){
    cout<<cnt<<endl;
  }else{
    cout<<1<<endl;
  }
  return 0;
}


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

using namespace std;

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

	int first, num, mx = 0;
	cin >> first;
	int curr = first;
	for (int i = 1; i < n; i++)
	{
		cin >> num;
		mx = max(num - curr, mx);
		curr = num;
	}

	mx = max(k - num + first, mx);
	cout << k - mx << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<stdio.h>
#include<math.h>
#include<stdio.h>
#include<complex>
using namespace std;

#define rep(i,n) for(long long i = 0; i < n; i++)

typedef long long ll;
typedef unsigned long long int ulli;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;

const ll INF = ll(1e18) + 1;
const int intINF = 1e9 * 2 + 3;
//--------------------------------------------------

ulli gcd(ulli a, ulli b) {return (b <= 0) ? a : gcd(b, a % b);}
ulli lcm(ulli a, ulli b) {return a * b / gcd(a, b);}

bool isPrime(int n)
{
	if (n <= 3)return n > 1;
	if (n % 2 == 0)return false;
	if (n % 3 == 0)return false;
	for (int i = 5; i * i < n; i += 6) {
		if (n % i == 0 || n % (i + 2) == 0) { return false; }
	}
	return true;
}
//---------------------------------------------------



void Main()
{
	int k, n;
	cin >> k >> n;
	vi a(n);
	rep(i, n)cin >> a[i];
	int sum = k;
	vi b(n + 1);
	b[0] = a[0] + k - a[n - 1];
	for (int i = 1; i < n; i++) {
		b[i] = a[i] - a[i - 1];
	}
	int mx = -intINF;
	for (auto x : b)mx = max(mx, x);
	sum -= mx;
	cout << sum << endl;
}


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

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N,M;
vector<pair<int,int>> g[500050];

const int INF=1e9;

int V;
map<pair<int,int>,int> node;

int dijkstra(int s,int t){
    vector<int> dist(V+1,0);
    rep(i,V+1) dist[i]=INF;
    dist[s]=0;
    priority_queue<tuple<int,int>,vector<tuple<int,int>>,greater<tuple<int,int>>> PQ;
    PQ.push(mkt(0,s));

    while(!PQ.empty()){
        int cost,now;
        auto f=PQ.top();
        PQ.pop();

        cost=get<0>(f);
        now=get<1>(f);

        if(dist[now]<cost) continue;
        if(now==t) return dist[t];

        for(auto to:g[now]){
            int nex,neco;
            tie(nex,neco)=to;

            if(dist[nex]>dist[now]+neco){
                dist[nex]=dist[now]+neco;
                PQ.push(mkt(dist[nex],nex));
            }
        }
    }

    return -1;
}

int main(){
  cin>>N>>M;
  vector<vector<pair<int,int>>> v(N);
  for(int i=0;i<M;i++){
      int a,b,c;
      cin>>a>>b>>c;
      a--;b--;
      v[a].push_back(mkp(b,c));
      v[b].push_back(mkp(a,c));
  }

  for(int i=0;i<N;i++){
      node[mkp(i,-1)]=++V;
      for(int j=0;j<v[i].size();j++){
          int c=v[i][j].second;
          if(node[mkp(i,c)]==0){
              node[mkp(i,c)]=++V;
              g[node[mkp(i,-1)]].push_back(mkp(node[mkp(i,c)],1));
              g[node[mkp(i,c)]].push_back(mkp(node[mkp(i,-1)],0));
          }
      }
  }

  for(int i=0;i<N;i++){
      for(int j=0;j<v[i].size();j++){
          int a=node[mkp(i,v[i][j].second)];
          int b=node[v[i][j]];
          g[a].push_back(mkp(b,0));
      }
  }


  int ans=dijkstra(node[mkp(0,-1)],node[mkp(N-1,-1)]);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 72820
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
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(){
    string s;
    cin >> s;
    ll sum=0;
    int n=s.size();
    for(int temp=0;temp<(1<<n-1);temp++){
        ll t=s[0]-'0';
        for(int j=0;j<n-1;j++){
            if(temp&(1<<j)){
                sum+=t;
                t=s[j+1]-'0';
            }
            else{
                t=t*10+s[j+1]-'0';
            }
        }
        sum+=t;
    }
    cout << sum << endl;

    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        Integer[] digits = new Integer[n];
        Arrays.fill(digits, null);
        for (int i = 0; i < m; i++) {
            int s = scanner.nextInt()-1;
            int c = scanner.nextInt();
            if(digits[s]==null){
                digits[s]=c;
            }else{
                if(digits[s]!=c){
                    System.out.println(-1);
                    return;
                }
            }
        }
        if(digits[0]==null){
            digits[0] = n==1? 0 : 1;
        }
        if(digits[0]==0 && n!=1){
            System.out.println(-1);
            return;
        }
        for (int i = 1; i < n; i++) {
            if(digits[i]==null){
                digits[i]=0;
            }
        }
        int res = digits[0];
        for (int i = 1; i < n; i++) {
            res = res*10+digits[i];
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 25172
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int,int>;
using PLL = pair<LL, LL>;
const int INF = 1e9;
const int MXN = 0;
const int MXV = 0;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for(int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for(int i = L; i != (int)R; --i)
#define IOS cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false);

int main()
{
    IOS;
    LL x;
    cin >> x;
    LL ans = x / 500 * 1000;
    x %= 500;
    ans += x / 5 * 5;
    cout << ans << '\n';
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(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 MAX(x) *max_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0)
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000
#define PI acos(-1.0)

int main()
{
  string S; cin >> S;
  map<int, char> s;
  int N = SIZE(S);
  REP(i, N) s[i] = S[i];

  map<int, char> ans;
  ans[0] = 'C';
  ans[1] = 'O';
  ans[2] = 'D';
  ans[3] = 'E';
  ans[4] = 'F';
  ans[5] = 'E';
  ans[6] = 'S';
  ans[7] = 'T';
  ans[8] = 'I';
  ans[9] = 'V';
  ans[10] = 'A';
  ans[11] = 'L';
  ans[12] = '2';
  ans[13] = '0';
  ans[14] = '1';
  ans[15] = '6';

  int cnt = 0;
  REP(i, N) {
    if (s[i] != ans[i]) cnt++;
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c,d,i=0;

	scanf("%d%d%d%d",&a,&b,&c,&d);
	while(i<100){
		c-=b;
		if(c<=0){
			printf("Yes\n");
			return 0;
		}
		a-=d;
		if(a<=0){
			printf("No\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 1624
read h w;
a=(`grep '#'`);
for((j=0;j<w;j++))do
	f=0;
	for((k=0;k<${#a[@]};k++))do
		if [ ${a[$k]:$j:1} = "#" ];then
			f=1;
		fi
	done
	b=( "${b[@]}" $f );
done
for((i=0;i<${#a[@]};i++))do
	for((j=0;j<w;j++))do
		if [ ${b[$j]} -eq 1 ];then
			echo -n ${a[$i]:$j:1}
		fi
	done
	echo ''
done


Measured memory_bytes: 540
#include<bits/stdc++.h>
using namespace std;
char a[1005];
int main(){
	int t=0;
	cin>>a;
	int lena=strlen(a);
	for(int i=0;i<=lena;i++){
		if(a[i]=='C') t=1;
		if(a[i]=='F'&&t==1){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 44

int Fib[N];

void fib(int n){
  int i;
  Fib[0] = 1;
  Fib[1] = 1;
  for(i=2; i<=n; i++) Fib[i] = Fib[i-1] + Fib[i-2];
}

int main(){
  int n;

  scanf("%d",&n);
  fib(n);
  printf("%d\n",Fib[n]);

  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
  	cin >> n >> m;
  	vector<vector<pair<long long,long long>>> graph(n);
  	for(int i=0;i<m;i++){
    	long long a,b,c;
      	cin >> a >> b >> c;
      	a--;
      	b--;
      	c *= (-1);
      	graph[a].push_back({b,c});
    }
  	vector<long long> dist(n,1LL<<60);
  	dist[0] = 0;
  	auto bf = [&](int x){
  		for(int i=0;i<x;i++){
    		for(int j=0;j<n;j++){
        		for(auto p:graph[j]){
            		if(dist[p.first] > dist[j] + p.second){
                		dist[p.first] = dist[j] + p.second;
                	}
            	}
        	}
    	}    
    };
  	bf(n-1);
  	long long ans = dist[n-1];
  	bf(n);
  	if(ans != dist[n-1]){
    	cout << "inf" << endl;
    }
  	else{
  		cout << -ans << endl;
    }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
    ll a, b; cin >> a >> b;
    if (a>0 && b>0) {
        puts("Positive");
    } else if ((a>=0 && b<=0) || (a<=0 && b>=0)){
        puts("Zero");
    } else {
        ll c = -1 * (a+b) - 1;
        if (c % 2 == 0) {
            puts("Positive");
        } else {
            puts("Negative");
        }
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	ll ans=0;
	ans+=min(a,k);
	k-=min(k,a);
	k-=min(k,b);
	ans-=min(k,c);
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int N, W;
  cin >> N >> W;
  vector<int> v(N + 1);
  vector<int> w(N + 1);
  for (int i = 1; i < N + 1; i++) {
    cin >> v[i] >> w[i];
  }
  debug(v);
  debug(w);
  vector<vector<int>> dp(N + 1, vector<int>(W + 1));
  for (int i = 1; i < N + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      dp[i][j] = dp[i - 1][j];
      if (j >= w[i]) dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
    }
  }
  debug(dp);
  cout << dp[N][W] << endl;
  return 0;
}


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

using namespace std;


int main() {
    string s;
    cin>>s;
    for (int i = (int)(s.length()/2)*2; i >=0; i-=2) {
        if(s.substr(static_cast<unsigned long>(i / 2), static_cast<unsigned long>(i / 2)) == s.substr(0, static_cast<unsigned long>(i / 2))){
            if(i==s.length())continue;
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30) - 1;
int main()
{
    int N, X;
    int minv = INF, cnt = 0;
    cin >> N >> X;
    for ( int i = 0; i < N; i++ ) {
        int m;
        cin >> m;
        minv = min(minv, m);
        X -= m;
        cnt++;
    }
    cout << cnt + X / minv << endl;
    return ( 0 );
}


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

using namespace std;

#define ll long long

int n, m;
int w[105];
int v[105];
ll s[100005] = {0};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = m - w[i]; j >= 0; j--) {
            s[j + w[i]] = max(s[j + w[i]], s[j] + v[i]);
        }
    }
    cout << s[m] << endl;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
   int K , A , B,i,flag=0;
   cin >> K >> A >> B;
   for(i=A;i<=B;i++){
       if(i%K == 0){
           flag=1;
           break;
       }
   }
   if(flag==1) cout << "OK";
   else cout << "NG";
   
   return 0;
}

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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int max_A = min(X/500, A);
  int max_B = min(X/100, B);
  int max_C = min(X/50, C);
  int num_of_equals = 0;
  for (int a = 0; a <= max_A; ++a) {
    for (int b = 0; b <= max_B; ++b) {
      for (int c = 0; c <= max_C; ++c) {
        if (500*a + 100*b + 50*c == X) num_of_equals++;
      }
    }
  }
  cout << num_of_equals << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	long long r, s, p;
	long long n, k;
	char input[100001];
	string str;

	scanf("%lld %lld", &n, &k);
	scanf("%lld %lld %lld", &r, &s, &p);

	scanf("%s", input);
	str = input;

	long long sol = 0;

	for (long long i = 0; i < k; i++)
	{
		switch (str[i])
		{
		case 'r':
			sol += p;
			break;
		case 's':
			sol += r;
			break;
		case 'p':
			sol += s;
			break;
		}
	}

	for (long long i = k; i < n; i++)
	{
		if (str[i] == str[i - k])
		{
			str[i] = 'x';
		}

		else
		{
			switch (str[i])
			{
			case 'r':
				sol += p;
				break;
			case 's':
				sol += r;
				break;
			case 'p':
				sol += s;
				break;
			}
		}
	}

	printf("%lld\n", sol);

	return 0;
}

Measured memory_bytes: 384
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

use std::f64::consts::PI;
fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      r: f64,
    }
    puts!("{}\n", r*2.0*PI);
}


Measured memory_bytes: 2236
h,w = map(int,input().split())
s = [list(input()) for i in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][j]=='.':
            c = 0
            for iw in range(i-1,i+2):
                for jw in range(j-1,j+2):
                    if iw<0 or h<=iw or jw<0 or w<=jw:
                        continue
                    elif s[iw][jw]=="#":
                        c+=1
            s[i][j]=str(c)
for s_ in s:
    print(''.join(s_))

Measured memory_bytes: 3188
import java.util.*;
import java.io.*;
 
public class Main {
    static int ans = 0;
    static char[] str = "0123456789".toCharArray();
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        dfs(s,0,0);
        System.out.println(ans);
    }
    
    public static void dfs(String s, int index, int now){
        if(now == 3){
            ans++;
            return;
        }
        for(char c : str){
            int next = s.indexOf(c,index);
            if(next != -1){
                dfs(s,next+1,now+1);
            }
        }
        return;
    }
}

class Point{
    int x,y;
    public Point(int x, int y){
        this.x = x;
        this.y = y;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }
    
    public void close() throws Exception{
        this.reader.close();
        return;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 21588
//gcc listsirkuler.c map.c player.c mesinkata.c mesinkar.c matriks.c pcolor.c point.c stackpoint.c queue.c unit.c main.c -o main
#include <bits/stdc++.h>
#define Semangat using
#define World namespace
#define Final std;
#define WF {ios_base::sync_with_stdio(0);cin.tie(0);}
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long

const int MOD = 1e9+7;
const int MAXN = 1e5+3;
Semangat World Final

ll n,a,b;

int main(){
	cin>>n>>a>>b;
	ll d=b-a;
	if(d%2==0) puts("Alice");
	else puts("Borys");
	return 0;
}

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

//union-find木

void init(int n, vector<int> &par){
  rep(i,n) par.at(i) = i;
}

int root(int x, vector<int> &par){
  if(x == par.at(x)) return x;
  else return par.at(x) = root(par.at(x), par);
}

void unite(int x, int y, vector<int> &par){
  int rx = root(x, par);
  int ry = root(y, par);
  if(rx == ry) return;
  par.at(rx) = ry;
}

int main(){
  int n, k, l;
  cin >> n >> k >> l;
  vector<int> road(n);
  vector<int> train(n);
  init(n, road);
  init(n, train);

  rep(i,k){
    int a, b;
    cin >> a >> b;
    a--, b--;
    unite(a, b, road);
  }
  rep(i,l){
    int a, b;
    cin >> a >> b;
    a--, b--;
    unite(a, b, train);
  }
  
  using pint = pair<int,int>;
  map<pint, int> ma;
  rep(i,n){
    pint p(root(i, road), root(i, train));
    ma[p]++;
  }
  rep(i,n){
    pint p(root(i, road), root(i, train));
    cout << ma[p] << " ";
  }
  return 0;
}

Measured memory_bytes: 13568
inf = 10 ** 18
n, m, p = map(int, input().split())
edge = []
d = [inf] * n
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    c = p - c
    edge.append((a, b, c))
d[0] = 0
for i in range(n-1):
    pre = d[n-1]
    for a, b, c in edge:
        if (d[a] != inf and d[b] > d[a] + c):
            d[b] = d[a] + c
            update = True

pre = d[n-1]
for i in range(n-1):
    for a, b, c in edge:
        if (d[a] != inf and d[b] > d[a] + c):
            d[b] = d[a] + c

if pre != d[n-1]:
    print(-1)
else:
    print(max(0, -d[n-1]))

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

const int MAX = 100010;


int n;
int par[MAX];
int deep[MAX];
vector<int> G[MAX];

void init() {
    for (int i = 0; i < n; i++) {
        G[i].clear();
        par[i] = -1;
        deep[i] = 0;
    }
}

int findRoot() {
    for (int i = 0; i < n; i++) {
        if (par[i] == -1) return i;
    }
    return 0;
}

void dfs(int r, int d) {
    deep[r] = d;
    for (int i = 0; i < G[r].size(); i++) {
        dfs(G[r][i], d+1);
    }
}

int main() {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    scanf("%d", &n);
    init();
    for (int i = 0; i < n; i++) {
        int poi, k;
        scanf("%d %d", &poi, &k);
        for (int j = 0; j < k; j++) {
            int nex = 0;
            scanf("%d", &nex);
            par[nex] = poi;
            G[poi].push_back(nex);
        }
    }
    int root = findRoot();
    dfs(root, 0);
    for (int i = 0; i < n; i++) {
        printf("node %d: parent = %d, depth = %d, ", i, par[i], deep[i]);
        if (i == root) printf("root, ");
        else if (G[i].empty()) printf("leaf, ");
        else printf("internal node, ");
        printf("[");
        for (int j = 0; j < G[i].size(); j++) {
            if (j > 0) printf(", ");
            printf("%d", G[i][j]);
        }
        printf("]\n");
    }
    return 0;
}

Measured memory_bytes: 7008
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)
const ll mod = 1e9+7;

int main(){
  int n;
  cin >> n;
  vector<ll> v(n);
  rep(i,n) cin >> v[i];
  vector<ll> cumsum(n+1);
  rep(i,n+1){
    if (i == 0) continue;
    cumsum[i] = cumsum[i-1] + v[i-1];
    cumsum[i]%=mod; 
  }
  ll ans = 0;
  for (int i = 0; i < n;i++){
    ll tmp = cumsum[n] - cumsum[i+1];
    if (tmp < 0) tmp += mod;
    ans += v[i]*tmp;
    ans %=mod;
  }
  cout << ans << endl;

  



  

  return 0;
   

}


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

int main()
{
    int size = 101;
    vector<int> numbers(size, 0);
    vector<int> result;

    for (int n; cin >> n;)
        numbers[n]++;

    int max = 0;
    for (int i = 0; i < size; i++)
        if (numbers[i] == max)
            result.push_back(i);
        else if (numbers[i] > max) {
            max = numbers[i];
            result.clear();
            result.push_back(i);
        }

    for (int n: result)
        cout << n << endl;

    return 0;
}

Measured memory_bytes: 1208
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		int m = 0;
		int z = 0;
		int p = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] == 0) {
				z++;
			} else if (a[i] > 0) {
				p++;
			} else {
				m++;
			}
		}

		boolean bz = false;
		boolean bp = false;
		if (z > 0) {
			bz = true;
		}
		if (p + m == k) {
			if (m % 2 == 0) {
				bp = true;
			}
		} else if (p + m > k) {
			if (p > 0 || k % 2 == 0) {
				bp = true;
			}
		}

		int mod = 1000000007;
		long mod1 = (long) mod * mod;
		if (bp) {
			PriorityQueue<Integer> qp = new PriorityQueue<>((o1, o2) -> o2 - o1);
			PriorityQueue<Integer> qm = new PriorityQueue<>();
			for (int i = 0; i < n; i++) {
				if (a[i] > 0) {
					qp.add(a[i]);
				} else {
					qm.add(a[i]);
				}
			}

			long ans = 1;
			for (int i = 0; i < k; i++) {
				Integer np = qp.poll();
				Integer nm = qm.poll();
				if (np == null) {
					ans *= (long) nm * qm.poll() % mod;
					i++;
				} else if (nm == null) {
					ans *= np;
				} else {
					Integer np2 = qp.poll();
					Integer nm2 = qm.poll();
					if (nm2 == null || i == k - 1) {
						ans *= np;
						if (np2 != null) {
							qp.add(np2);
						}
						qm.add(nm);
					} else if (np2 == null) {
						ans *= (long) nm * nm2 % mod;
						qp.add(np);
						i++;
					} else {
						long vp = (long) np * np2;
						long vm = (long) nm * nm2;
						if (vp > vm) {
							ans *= np;
							qp.add(np2);
							qm.add(nm);
							qm.add(nm2);
						} else {
							ans *= vm % mod;
							qp.add(np);
							qp.add(np2);
							i++;
						}
					}
				}
				if (ans < 0) {
					ans += mod1;
				}
				ans %= mod;
			}
			System.out.println(ans);

		} else if (bz) {
			System.out.println(0);

		} else {
			PriorityQueue<Integer> qp = new PriorityQueue<>();
			PriorityQueue<Integer> qm = new PriorityQueue<>((o1, o2) -> o2 - o1);
			for (int i = 0; i < n; i++) {
				if (a[i] > 0) {
					qp.add(a[i]);
				} else {
					qm.add(a[i]);
				}
			}
			long ans = 1;
			for (int i = 0; i < k; i++) {
				Integer np = qp.peek();
				Integer nm = qm.peek();
				if (nm == null || np != null && np < -nm) {
					ans *= qp.poll();
				} else {
					ans *= qm.poll();
				}
				if (ans < 0) {
					ans += mod1;
				}
				ans %= mod;
			}
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 63312
# ABC 050: B – Contest with Drinks Easy
n = int(input())
t = [int(s) for s in input().split()]
m = int(input())
p = []
x = []
for _ in range(m):
    tmp = [int(s) for s in input().split()]
    p.append(tmp[0])
    x.append(tmp[1])

for i in range(m):
    print(sum(t) - t[p[i] - 1] + x[i])

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

int main()
{
  int A, B, C, D;
  int m = 0, n = 0;
  cin >> A >> B >> C >> D;
  
  while(1)
  {
    if(C > B)
    {
      C -= B;
    }
    else
    {
      cout << "Yes" << endl;
      break;
    }
    if(A > D)
    {
      A -= D;
    }
    else
    {
      cout << "No" << endl;
      break;
    }
  }
  
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);


signed main(){
    int h,w,cnt=0;
    cin>>h>>w;
    vector<vector<ll>> v(h,vector<ll>(w));
    vector<int> ans(0);
    queue<int> sub;
    for(int i=0;i < h;i++)
    {
        int x=0;
        for(int j=0;j < w;j++)
        {
            cin>>v.at(i).at(j);
            v.at(i).at(j)+=x;
            v.at(i).at(j)%=2;
            if(v.at(i).at(j)==1){
                if(j<w-1){
                    ans.pb(i+1);
                    ans.pb(j+1);
                    ans.pb(i+1);
                    ans.pb(j+2);
                    cnt++;
                }else{
                    sub.push(i+1);
                }
            }
            x=v.at(i).at(j);
        }
    }
    
    while(sub.size()>0){
        ll y = sub.front();
        sub.pop();
        if(sub.size()==0)continue;
        else{
            while(sub.front()>y){
                ans.pb(y);
                ans.pb(w);
                ans.pb(y+1);
                ans.pb(w);
                cnt++;
                y++;
            }
            sub.pop();
        }
    }

    cout << cnt << endl;
    for(int i=0;i < (int)ans.size();i++)
    {
        cout << ans.at(i);
        if(i%4==3){
            cout << endl;
        }else{
            cout  << " ";
        }
    }
}


Measured memory_bytes: 6128
N, L = map(int, input().split())
A = [int(a) for a in input().split()]

for i in range(1, N):
    if A[i-1] + A[i] >= L:
        print("Possible")
        for j in range(1, i):
            print(j)
        for j in range(N-1, i, -1):
            print(j)
        print(i)
        break
else:
    print("Impossible")

Measured memory_bytes: 14052
N = gets.to_i
A = gets.split.take(N).map(&:to_i).map(&:pred)
 
def f(a)
  a = a.dup
  res = 0
  a.each_index{|i|
    if a[i] == i
        a[i], a[i + 1] = a[i + 1], a[i]
      res += 1
    end
  }
  res
end
 
p f(A)

Measured memory_bytes: 9860
#include <stdio.h>
int main(void){
   int n;
   double a[100],ans=0;
   
   scanf("%d",&n);
   for(int i=1;i<=n;i++){
       scanf("%lf",&a[i]);
   }
   for(int i=1;i<=n;i++){
       ans+=(1/a[i]);
   }
   printf("%lf",1/ans);
   return 0;
}


Measured memory_bytes: 1720
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(void){
    string s;cin>>s;
    int q;cin>>q;
    string t;
    rep(i,q){
        int ty;
        cin>>ty;
        if(ty==1){
            swap(s,t);
        }else{
            int f;char c;
            cin>>f>>c;
            if(f==1){
                t+=c;
            }else{
                s+=c;
            }           
        }
    }
    reverse(t.begin(),t.end());
    t+=s;
    cout<<t<<endl;
    return 0;
}


Measured memory_bytes: 1128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);    
    int a,b,c;
    cin >> a >> b >> c;
    cout << ((a==b)?c:((a==c)?b:a)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 500005
using namespace std;
char s[N];
int f[N];
int main() {
    scanf("%s", s + 1);
    int n = strlen(s + 1) + 1;
    for(int i = n - 1; i; -- i)
        if(s[i] == '<') f[i] = 0;
        else f[i] = f[i + 1] + 1;
    for(int i = 1; i < n; ++ i)
        if(s[i] == '<') f[i + 1] = max(f[i + 1], f[i] + 1);
    long long ans = 0;
    for(int i = 1; i <= n; ++ i) ans += f[i];
    cout << ans << endl;
}

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

char incrementChar(char x){
    return static_cast<char>(x + 1);
}

int weekToInt(string x){
    int num;
    if(x == "SUN"){
        num = 1;
    }else if(x == "MON"){
        num = 2;
    }else if(x == "TUE"){
        num = 3;
    }else if(x == "WED"){
        num = 4;
    }else if(x == "THU"){
        num = 5;
    }else if(x == "FRI"){
        num = 6;
    }else if(x == "SAT"){
        num = 7;
    }else{
        num = 0;
    }

    return num;
}

// vector<int> v;
// auto it = v.begin();
// 
// it = v.insert(it, A + B);
// it = v.insert(it, A - B);
// it = v.insert(it, A * B);
// 
// int max = *max_element(v.begin(), v.end());
// int min = *min_element(v.begin(), v.end());


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

    int sum = 0;
    for(int i=0; i<(int)S.size(); i++){
        sum += count(S.cbegin(), S.cend(), S[i]);
    }

    if(sum == 8){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N, x = map(int, input().split())

a=list(map(int, input().split()))
ans=0
if a[0]-x>0:
    ans+=a[0]-x
    a[0]=x
for i in range(N-1):
    if a[i]+a[i+1]>x:
        ans+=a[i]+a[i+1]-x
        a[i+1]-=a[i]+a[i+1]-x


print(ans)

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

using namespace std;
typedef long long int lli;

#define all(arr) arr.begin(),arr.end()
#define f first
#define s second
#define debug1(x) cout<<x<<"\n"
#define debug2(x,y) cout<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define nl cout<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cout<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define MOD 1000000007

template <typename T>
void input(vector<T> &arr,lli n) {
  T temp;
  for(lli i=0;i<n;i++) cin>>temp, arr.push_back(temp);
}

template <typename T>
void output(vector<T> arr) {
  for(auto x:arr) cout<<x<<" ";
  cout<<endl;
}


template <typename T>
void input_set(set<T> &arr,lli n) {
  T temp;
  for(lli i=0;i<n;i++) cin>>temp, arr.insert(temp);
}

lli mul(lli a, lli b) {
  return (a%MOD*b%MOD)%MOD;
}

lli power(lli a,lli b) {
  lli ans = 1;
  while(b > 0) {
    if(b&1)
      ans = mul(ans, a);
    a = mul(a,a);;
    b >>= 1;
  }
  return ans;
}

void solve() {
  int x, y;
  cin >> x >> y;
  if((y-2*x)>=0 and (y-2*x)%2==0 and (4*x-y)>=0 and (4*x-y)%2==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

  lli testcases=1;
  while(testcases--) {
    solve();
  }
}



Measured memory_bytes: 3640
import java.util.*;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String[] tokens = in.readLine().split(" ");
		int A = Integer.parseInt(tokens[0]);
		int B = Integer.parseInt(tokens[1]);
		int result = 0;
		if ((B - 1) % (A - 1) == 0) {
			result = (B - 1) / (A - 1);
		} else {
			result = (B - 1) / (A - 1) + 1;
		}
		System.out.println(result);
	}

}


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

namespace ConsoleApp1 {
    public class Class {
        static void Main(string[] args) {
            var N = long.Parse(Console.ReadLine());
            var A = RL<long>();
            var Q = long.Parse(Console.ReadLine());

            var ans = new long[100001];
            foreach(var a in A) {
                ans[a] += a;
            }

            long As = A.Sum();

            for(var i = 0; i < Q; i++) {
                var t = RL<long>();
                var B = t[0];
                var C = t[1];
                ans[C] += (ans[B] * C) / B;

                As += (ans[B] * C) / B;
                As -= ans[B];

                ans[B] = 0;
                Console.WriteLine(As);
            }
        }

        static T[] RL<T>() where T : IComparable {
            if (typeof(T) == typeof(int)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(int.Parse).ToArray();
            }
            if (typeof(T) == typeof(long)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();
            }
            if (typeof(T) == typeof(double)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(double.Parse).ToArray();
            }
            if (typeof(T) == typeof(decimal)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(decimal.Parse).ToArray();
            }
            return (T[])(object)Console.ReadLine().Trim().Split().ToArray();
        }
    }
}


Measured memory_bytes: 51132
#include <stdio.h>
//#include <string.h>

int main(void){
  
  int x,y;

  scanf("%d %d", &x, &y);
  
 for(int i=0;i<x+1;i++){
   if(i*2+(x-i)*4==y){
    printf("Yes\n");
   
     return 0;
   }
 }

  
  printf("No\n");
  return 0;
}


Measured memory_bytes: 1660
#include <stdio.h>
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int h, n;
    cin >> h >> n;
    vector<int> dp(h+1, 1000000000);
    dp[0] = 0;
    vector<int> a(n);
    vector<int> b(n);
    for (int i=0; i<n; i++){
        cin >> a[i] >> b[i];
    }

    for (int i=0; i<dp.size(); i++){
        for (int j=0; j<n; j++){
            int _h = min(h, i+a[j]);
            dp[_h] = min(dp[_h], dp[i]+b[j]);
        }
    }

    cout << dp[h] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int sort(int *a,int *b){
*a-*b;
}
int main(Void){
int n;
  scanf("%d",&n);
  int log[n];
  for(int i=0;i<n;i++){
	scanf("%d",&log[i]);
}
  int ans[n];
  for(int i=0;i<n;i++){
		ans[log[i]-1]=i+1;
  }
  for(int i=0;i<n;i++){
	printf("%d ",ans[i]);
  }
  return 0;
}

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

int main()
{

	int n;
	cin >> n;
	vector<int> a(n);

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	reverse(a.begin(), a.end());
	for (int i = 0; i < n; i++)
	{
		cout << a[i];
		string s = (i == n - 1) ? "\n" : " ";
		cout << s;
	}
	return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    if(n%1000)cout<<((ll)1000-n%1000);
    else cout<<0;
}

Measured memory_bytes: 3632