akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

const inf = 1 << 60
const mod int = 1e9 + 7

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()

	l := make([]int, n*2)
	for i := 0; i < n*2; i++ {
		l[i] = ri()
	}

	sort.Ints(l)

	ans := 0
	for i := 0; i < n*2; i += 2 {
		ans += l[i]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
N,L= map(int, input().split())

list= [(L+i) for i in range(N)]

# print(list)

tmp=list[0]

rem=0

for i in range(1,N):
  if(abs(tmp)<abs(list[i])):
    rem= tmp
    break
  else:
    tmp= list[i]
  if(i== N-1):
    rem= list[i]

print(sum(list)- rem)



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

typedef long long ll;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

typedef long double D;
typedef complex<D> P;

#define X real()
#define Y imag()

const D eps=1e-8;
const D inf=1e12;
const D PI=acos(-1);

namespace std{
  bool operator<(const P& a,const P& b){
    return a.X==b.X?a.Y<b.Y:a.X<b.X;
  }
}
bool cmp_x(const P& a,const P& b){ return a.X==b.X?a.Y<b.Y:a.X<b.X; }
bool cmp_y(const P& a,const P& b){ return a.Y==b.Y?a.X<b.X:a.Y<b.Y; }
bool cmp_a(const P& a,const P& b){ return arg(a)==arg(b)?norm(a)<norm(b):arg(a)<arg(b); }
D cross(P a,P b){ return (conj(a)*b).Y; }
D dot(P a,P b){ return (conj(a)*b).X; }
D toRag(D deg){ return deg*PI/180.0; }
P rot(P base,P a,D theta){ return base+polar(abs(a-base),arg(a-base)+theta); }

struct L : public vector<P> { // line and segment
  L(const P& a,const P &b){
    push_back(a);
    push_back(b);
  }
};

enum{OUT,ON,IN};
int contains(vector<P> poly,P p) {
  int n=poly.size();
  bool in=false;
  for(int i=0;i<n;i++){
    P a=poly[i]-p, b=poly[(i+1)%n]-p;
    if(a.Y>b.Y)swap(a,b);
    if(a.Y<=0&&0<b.Y){
      if(cross(a,b)<0)in=!in;
    }
    if(cross(a,b)==0&&dot(a,b)<=0)return ON;
  }
  return in?IN:OUT;
}

P extreme(vector<P> ps,L l) {
  int k=0;
  for(int i=1;i<ps.size();i++){
    if(dot(ps[i],l[1]-l[0])>dot(ps[k],l[1]-l[0]))k=i;
  }
  return ps[k];
}

D area2(vector<P> poly){
  int n=poly.size();
  D A=0;
  for(int i=0;i<n;i++){
    A+=cross(poly[i],poly[(i+1)%n]);
  }
  return A/2.0;
}

int main(){
	cin.sync_with_stdio(false);
  int n;
  vector<P> ps;
  cin>>n;
  rep(i,n){
    D x,y;
    cin>>x>>y;
    ps.push_back(P(x,y));
  }
  printf("%.1Lf\n", area2(ps));
	return 0;
}

Measured memory_bytes: 3300
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
#define MAX 100010
#define aout(a) REP(i,sizeof(a)) cout << a[i] << " "; cout << endl;
#define vout(v) REP(i,v,size()) cout << v[i] << " "; cout << endl;
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(){
  string s; cin>>s;
  int ans = 0;
  if(s[0] == 'R'){
    ans++;
  }
  if(s[1] == 'R'){
    ans++;
  }
  if(s[2] == 'R'){
    if(s[1] == 'R'){
      ans++;
    }
    else{
      ans=1;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 3624
#include<iostream>
#include <iomanip>
using namespace std;
int main()
{
	int i;
	char op[100];
	int a[100],b[100];
	for(i=0;i<100;)
	{
		cin>>a[i]>>op[i]>>b[i];
	
			if(op[i]=='?')
			break;
			i++;
	}
	for(int k=0;k<i;k++)
		{
			
			if(op[k]=='+')
				cout<<a[k]+b[k]<<endl;
			if(op[k]=='-')
				cout<<a[k]-b[k]<<endl;
				if(op[k]=='*')
					cout<<a[k]*b[k]<<endl;
					if(op[k]=='/')
						cout<<a[k]/b[k]<<endl;

	}
}

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

int main() {
    // insert code here...
    int M=0,N;
    cin >> N>>M;
    int a[M];
    int sum =0;
    for(int i=0;i<M;i++){
        cin >> a[i];
        sum+= a[i];
    }
    if(N>=sum)
        cout<< N-sum <<endl;
    else
        cout <<-1 <<endl;
    
}



Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE

//FUNCTION
void solve(void)
{
  int H,W,K;
  cin>>H>>W>>K;
  vector<vector<int> > DP (H+1,vector<int>(W,0));
  DP[0][0] = 1;
  for (int h = 0; h < H; h++)
  {
      for (int b = 0; b < (1<<(W-1)); b++)
      {
        vector<int> bit(W-1,0);
        for (int i = 0; i < W-1; i++)
        {
          if((b>>i)&1)bit[i] = 1;
        }
        // DEBUG(bit);
        int adjacent_check = 0;
        for (int i = 0; i < W -2; i++)
        {
          if(bit[i] == 1 && bit[i+1] == 1)adjacent_check = 1;
        }

        if(adjacent_check) continue;
        vector<int> changed(W,0);
        for (int w = 0; w < W-1; w++)
        {
          if(bit[w] == 1)
          {
            DP[h+1][w+1] += DP[h][w];
            DP[h+1][w] += DP[h][w+1];
            DP[h+1][w+1] %= MOD;
            DP[h+1][w] %= MOD;
            changed[w] = 1;
            changed[w+1] = 1;
          } 
        }
          for (int w = 0; w < W; w++)
          {
            if(changed[w] == 0)
            {
              DP[h+1][w] += DP[h][w];
              DP[h+1][w] %= MOD;
            }
          }
        
        
        
      }
      // DEBUG(DP);
      // DEBUG(" \n");
      
    
    
  }
  cout<<DP[H][K-1]<<endl;
  
  

  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.array;
import std.string;
import std.algorithm;

void main() {
	int n;
	n = to!int(chomp(readln()));
	int [] a;
	for(int i = 0; i < n; i++) {
		a ~= to!int(chomp(readln()));
	}
	sort(a);
	a ~= -1;
	int res = 0;
	int cnt = 1;
	for(int i = 1; i < a.length; i++) {
		if(a[i] == a[i-1]) {
			cnt++;
		}
		else {
			if(cnt % 2 == 1) res++;
			cnt = 1;
		}
	}
	writeln(res);
}


Measured memory_bytes: 3580
def main():
  N, K = (int(_) for _ in input().split())
  MOD = 10 ** 9 + 7
  res = 0
  for k in range(K, N+2):
    res += k * (N - k + 1) + 1
    res %= MOD
  print(res)
  return

if __name__ == '__main__':
  main()
  

Measured memory_bytes: 9168
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include <cmath>
#include<stdio.h>
#include<queue>
#include<stack>
#include<set>
#define MAX 1000000000000000000LL
long long inf=1000000007;
using namespace std;
int main(){
    string a;
    cin>>a;
    if(a[0]==a[2])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <array>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)


typedef long long int ll;
typedef double D;      // ??§?¨?????????????double???long double?????????
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;


const int INF = (1<<30) - 1;
const D EPS = 1e-9;

#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

int N, M, K;

int dfs(int cur, vector<int> nums){
    if(cur == 0){
        int s = 0;
        for(int i=0; i<nums.size(); i++)
            s += nums[i];
        return s-K > 0 ? s-K: 1;
    }
    
    int ans = 0;
    nums.push_back(-1); //dummy;
    for(int i=1; i<=M; i++){
        nums[nums.size()-1] = i;
        ans += dfs(cur-1, nums);
    }
    return ans;
}

void solve(){
    double d = dfs(N, {});
    for(int i=0; i<N; i++)
        d /= M;
    printf("%.7lf\n", d);
}

//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.precision(16);
    
    while(cin>>N>>M>>K, N|M|K)
        solve();
    
    return 0;
}

Measured memory_bytes: 1224
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

const int MR = 2e5 + 10;

char s[MR];

bool done[MR];

const int N = 2e5;  // limit for array size
int n;  // array size
int t[2 * N];

void build() {  // build the tree
	for (int i = n - 1; i > 0; --i) t[i] = t[i << 1] + t[i << 1 | 1];
}

void modify(int l, int r, int value) {
	for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
		if (l & 1) t[l++] += value;
		if (r & 1) t[--r] += value;
	}
}

int query(int p) {
	int res = 0;
	for (p += n; p > 0; p >>= 1) res += t[p];
	return res;
}

int main()
{
	scanf("%s", s);
	n = strlen(s);

	map<int, int> M;

	REP(i, n)
		M[s[i]]++;

	int sum = 0;
	for (const auto &p : M)
		sum += p.second % 2;

	if (sum != n % 2)
	{
		printf("-1\n");
		return 0;
	}

	map<char, deque<int>> Q;
	REP(i, n)
		Q[s[i]].push_back(i);

	int posback = n - 1, ile = 0, shift = 0, posfront = 0;
	LL res = 0;
	FORD(i, n, 0)
	{
		if (done[i])
			continue;

		if (Q[s[i]].size() == 1)
		{
			// mamy goscia, ktory powinien stac na srodku
			res += posback - n / 2;
			Q[s[i]].clear();
			continue;
		}

		// usun dana pozycje z kolejki
		Q[s[i]].pop_back();

		// zobacz, czy cos musisz przesunac
		if (Q[s[i]].front() + shift + query(Q[s[i]].front()) > posfront)
		{
			res += (Q[s[i]].front() + shift + query(Q[s[i]].front())) - posfront;
			// odznacz, ktore litery juz nie maja tego przesuniecia w oryginalnym stringu
			modify(Q[s[i]].front() + 1, n, -1);
			// odznacz, ze to pole jest zrobione - w oryginalnym stringu
			done[Q[s[i]].front()] = 1;
			// zwieksz aktualne przesuniecie
			shift++;
		}

		// wyrzuc pozycje, ktora dopasowales
		Q[s[i]].pop_front();

		// zmniejsz pozycje, ktora ukladasz
		posback--; posfront++;
		// kolejna ulozona litera
		ile++;

		// spr czy juz nie ulozyles polowy
		if (ile == n / 2)
			break;
	}

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

	return 0;
}

Measured memory_bytes: 2304
import java.util.*;
import java.awt.Point;

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

		while(true){
			w = sc.nextInt();
			h = sc.nextInt();
			if(w == 0 && h == 0) break;

			t = new int[h][w];
			Point p = null;
			Point b = null;

			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					t[i][j] = sc.nextInt();
					if(t[i][j] == 4){
						p = new Point(j,i);
						t[i][j] = 0;
					}
					else if(t[i][j] == 2){
						b = new Point(j,i);
						t[i][j] = 0;
					}
				}
			}

			PriorityQueue<State> open = new PriorityQueue<State>();
			HashSet<State> closed = new HashSet<State>();
			State ans = null;
			open.add(new State(p,b,0));

			while(!open.isEmpty()){
				State st = open.poll();
				if(closed.contains(st)) continue;
				closed.add(st);

				if(t[st.b.y][st.b.x] == 3){
					ans = st;
					break;
				}

				open.addAll(st.nexts());
			}

			System.out.println(ans == null ? -1 : ans.cost);
		}
	}

	private static int w,h;
	private static int[][] t;
	private static int[] dx = {0,1,0,-1};
	private static int[] dy = {-1,0,1,0};

	private static boolean reachable(Point s,Point g,Point b){
		t[b.y][b.x] = 2;

		Queue<Point> open = new LinkedList<Point>();
		HashSet<Point> closed = new HashSet<Point>();
		open.add(s);

		while(!open.isEmpty()){
			Point p = open.poll();
			if(closed.contains(p)) continue;
			closed.add(p);
			if(p.equals(g)){
				t[b.y][b.x] = 0;
				return true;
			}

			for(int i=0;i<4;i++){
				int nx = p.x + dx[i];
				int ny = p.y + dy[i];

				if(nx>=0 && nx<w && ny>=0 && ny<h && (t[ny][nx]==0 || t[ny][nx]==3)){
					open.add(new Point(nx,ny));
				}
			}
		}

		t[b.y][b.x] = 0;

		return false;
	}

	private static class State implements Comparable<State>{
		Point p,b;
		int cost;

		State(Point p,Point b,int cost){
			this.p = new Point(p.x,p.y);
			this.b = new Point(b.x,b.y);
			this.cost = cost;
		}

		List<State> nexts(){
			List<State> sts = new ArrayList<State>();

			for(int i=0;i<4;i++){
				int nx1 = b.x + dx[i];
				int ny1 = b.y + dy[i];
				int nx2 = b.x + dx[(i+2)%4];
				int ny2 = b.y + dy[(i+2)%4];
				Point np1 = new Point(nx1,ny1);
				Point np2 = new Point(nx2,ny2);

				if(nx1>=0 && nx1<w && ny1>=0 && ny1<h &&
					 nx2>=0 && nx2<w && ny2>=0 && ny2<h &&
					 t[ny1][nx1]!=1 && t[ny2][nx2]!=1 && reachable(p,np1,b)){
					sts.add(new State(b,np2,cost+1));
				}
			}

			return sts;
		}

		public boolean equals(Object o){
			State st = (State)o;
			return p.equals(st.p) && b.equals(st.b);
		}

		public int hashCode(){
			return p.x + p.y * 10 + b.x * 100 + b.y * 1000;
		}

		public int compareTo(State st){
			return this.cost - st.cost;
		}
	}
}

Measured memory_bytes: 12000
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))
n = int(input())

for i in range(n):
    b = int(input())
    for i in range(3):
        if a1[i]==b:
            a1[i]=0
    for i in range(3):
        if a2[i]==b:
            a2[i]=0
    for i in range(3):
        if a3[i]==b:
            a3[i]=0
            
flag = 0
if sum(a1)==0:
    flag = 1
if sum(a2)==0:
    flag = 1
if sum(a3)==0:
    flag = 1
    
if a1[0]+a2[0]+a3[0]==0:
    flag = 1
if a1[1]+a2[1]+a3[1]==0:
    flag = 1
if a1[2]+a2[2]+a3[2]==0:
    flag = 1
    
    
if a1[0]+a2[1]+a3[2]==0:
    flag = 1
if a1[2]+a2[1]+a3[0]==0:
    flag = 1
    
if flag:
    print('Yes')
else:
    print('No')

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


class Baseball{
	int out;
	std::string runner;
	int score;
public:
	Baseball(){
		out = 0;
		runner.clear();
		score = 0;
	}
	
	int get_score(){ return score;}
	void event_out(){ ++out;}
	void event_hit();
	void event_homerun();
	void play_game();
};


void Baseball::event_hit(){
	int place;
	if((place = runner.find("3", 0)) != -1){
		runner.erase(place);
		++score;
	}
	
	if((place = runner.find("2", 0)) != -1){
		runner.replace(place, 1, "3");
	}
	
	if((place = runner.find("1", 0)) != -1){
		runner.replace(place, 1, "2");
	}
	
	runner.insert(0, "1");
}

void Baseball::event_homerun(){
	score += runner.size() + 1;
	runner.clear();
}

void Baseball::play_game(){
	std::string event;
	while(std::cin >> event){
		if(event == "HIT"){
			event_hit();
		}
		else if(event == "HOMERUN"){
			event_homerun();
		}
		else if(event == "OUT"){
			event_out();
			if(out == 3){
				break;
			}
		}
	}
}

int main(){
	int game_num;
	std::cin >> game_num;
	for(int i = 0; i < game_num; ++i){
		Baseball baseball;
		baseball.play_game();
		std::cout << baseball.get_score() << std::endl;
	}
	
	return 0;
}

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

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

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

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

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


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

LL dp[20010];
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  LL N, M, K;
  cin >> N >> M >> K;
  VL xs(N);
  REP(i,N) cin >> xs[i];

  dp[0] = 0;
  REP(i,N){
	LL mx = xs[i], mn = xs[i];
	LL best = dp[i] + K;
	for(int j=1;j<=min(M,i+1ll);++j){
	  maxi(mx, xs[i+1-j]);
	  mini(mn, xs[i+1-j]);
	  mini(best, dp[i+1-j] + K + (mx - mn) * j);
	}
	dp[i+1] = best;
  }

  cout << dp[N] << endl;

  return 0;
}

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

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

    vector<int>vc;
    for(int i=0;i<k;i++)
    {
        int a;
        cin>>a;
        vc.push_back(a);
    }

    int f1= k-vc[n-1]+vc[0];
    int maxi=f1;

    for(int i=0;i<n-1;i++)
    {
        int diff= vc[i+1]-vc[i];
        maxi=max(maxi,diff);
    }

    cout<<k-maxi<<endl;






return 0;


}


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

int main() {
  int N;
  cin >> N;
  if ((N / 1000 == N % 1000 / 100 && N % 1000/ 100 == N % 1000 % 100 / 10) ||
    (N % 1000 % 100 / 10 == N % 1000 % 100 % 10 && N % 1000/ 100 == N % 1000 % 100 / 10))  {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
# include "iostream"
# include "cstdio"

using namespace std;

const int maxm=1e5+10;
const int Max=1e5;
const int Inf=0x3f3f3f3f;

int Stack1[maxm],Stack2[maxm],N;
int Ans1[maxm][2],Ans2[maxm][2];
int DP[maxm];

int main(){
	register int i,Ans=Inf;
	int x;
	scanf("%d",&N);
	for(i=1;i<=N;i++){
		scanf("%d",&x);
		if(i&1) Stack1[x]++;
		else Stack2[x]++;
	}
	N>>=1;
	for(i=0;i<=Max;i++){
		Ans1[i][0]=Ans1[i][1]=N-Stack1[i];
		Ans2[i][0]=Ans2[i][1]=N-Stack2[i];
	}
	for(i=1;i<=Max;i++){
		Ans=min(Ans,Ans1[i][0]+Ans2[i-1][0]);
		Ans2[i][0]=min(Ans2[i][0],Ans2[i-1][0]);
	}
	for(i=1;i<=Max;i++){
		Ans=min(Ans,Ans2[i][1]+Ans1[i-1][1]);
		Ans1[i][1]=min(Ans1[i][1],Ans1[i-1][1]);
	}
	printf("%d",Ans);
	return 0;
}

Measured memory_bytes: 2560
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

#[allow(unused_macros)]
macro_rules! echo {
    ($($e:expr),+) => ( { $(println!("{}", $e))+ } );
}

// (() のようなカッコで構成された文字列を受け取って
// (最終的な増減, 一番低いときいくつ下がるか) を返す
fn process(s: &str) -> (isize, isize) {
    let mut sum = 0;
    let mut lowest = 0;
    for c in s.chars() {
        match c {
            '(' => {
                sum += 1;
            }
            _ => {
                sum -= 1;
            }
        }

        lowest = std::cmp::min(lowest, sum);
    }

    (sum, lowest)
}

fn main() {
    input! {
        n: usize,
        s: [String; n],
    }

    let ss = s.iter().map(|s| process(s)).collect::<Vec<_>>();
    let mut positives = ss.iter().filter(|(sum, _)| *sum >= 0).collect::<Vec<_>>();
    let mut r_negatives = ss
        .iter()
        .filter(|(sum, _)| *sum < 0)
        .map(|(sum, pos)| (-sum, -sum + pos))
        .collect::<Vec<_>>();

    positives.sort_by_key(|e| -e.1); // 最下点までの下げ幅の小さい順
    r_negatives.sort_by_key(|e| -e.1); // 最下点までの下げ幅の小さい順

    let mut p_sum = 0;

    for p in positives {
        if p_sum + p.1 < 0 {
            echo!("No");
            return;
        }

        p_sum += p.0;
    }

    let mut n_sum = 0;

    for n in r_negatives {
        if n_sum + n.1 < 0 {
            echo!("No");
            return;
        }

        n_sum += n.0;
    }

    if p_sum != n_sum {
        echo!("No");
        return;
    }

    echo!("Yes");
}


Measured memory_bytes: 86200
#include<stdio.h>
 
int main(void){
    char name[200];
    char flag1[26];
    char flag2[26];
    int i;
    int j;
    int N;
    int x;
    int a=0;

    scanf("%d",&N);
    scanf("%s",name);
    for(i=0;i<N;i++){
        for(j=0;j<26;j++){
            flag1[j]=0;
            flag2[j]=0;
        }
        for(j=0;j<i;j++){
            flag1[(int)(name[j]-'a')]=1;
        }
        for(j=i;j<N;j++){
            flag2[(int)(name[j]-'a')]=1;
        }
        x=0;
        for(j=0;j<26;j++){
            x+=(flag1[j]*flag2[j]);
        }
        if(a<x)a=x;
    }
    printf("%d\n",a);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    VI p(N); REP(i,N) cin >> p[i];
    int acc = 0;
    REP(i,N){
        if(p[i] != i+1) acc++;
    }
    if(acc == 0 || acc == 2){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    int N;
    cin >> N;
    vector<ull> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    ull over = pow(10, 18);
    ull ans = 1;
    for(int i = 0; i < N; i++) if(A[i] == 0){
        puts("0");
        return 0;
    }
    for(int i = 0; i < N; i++){
        over /= A[i];
        if(over == 0){
            puts("-1");
            return 0;
        }
        ans *= A[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 4032
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long n,m,i,j,k,dp[55][55][2555],num[55],ans;
int main()
{
	cin>>n>>m;
	for (i=1;i<=n;i++)
	{
		cin>>num[i];
	}
	dp[0][0][0]=1;
	for (i=1;i<=n;i++)
	{
		for (j=0;j<=n;j++)
		{
			for (k=0;k<=2500;k++)
			{
				dp[i][j][k]=dp[i-1][j][k];
				if (j&&k>=num[i])
				{
					dp[i][j][k]+=dp[i-1][j-1][k-num[i]];
				}
			}
		}
	}
	for (i=1;i<=n;i++)
	{
		ans+=dp[n][i][i*m];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 56448
#include <cstdio>
#include <algorithm>
#include <complex>
#include <vector>

using namespace std;

typedef long double ldb;
typedef complex<ldb> P;
struct L {
  P a,b;
  L(){}
  L(P a,P b):a(a),b(b){}
  ldb len(){return abs(a-b);}
  P vec(){return b-a;}
};

const ldb eps = 1e-8;
const ldb pi = acos(-1);
int sig(ldb a) {return (a<-eps)?-1:(a>eps)?1:0;}
bool eq(ldb a,ldb b){return abs(a-b)<eps;}
ldb dot(P a, P b) {
  return (a.real() * b.real() + a.imag() * b.imag());
}
ldb cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}
enum CCW{FRONT = 1, RIGHT = 2, BACK = 4, LEFT = 8, ON = 16};
int ccw(L s, P p) {
  P a = s.vec();
  p -= s.a;
  ldb cr = cross(a, p);
  if (eq(cr, 0)) {
    if (sig(dot(a, p)) < 0) return BACK;
    if (sig(norm(a) - norm(p)) < 0) return FRONT;
    return ON;
  }
  return (cr > 0) ? LEFT : RIGHT;
}

bool cmp(const P& a,const P& b)
{
  /*
  if( eq(a.real(),b.real()) ) return a.imag()<b.imag();
  return a.real()<b.real();
  */
  if( eq(a.imag(),b.imag()) ) return a.real()<b.real();
  return a.imag()<b.imag();
}

vector<P> convex_hull(vector<P> p)
{
  if( p.size() <= 1 ) return p;
  sort(p.begin(),p.end(),cmp);
  int k = 0;
  int n = p.size();
  vector<P> ret(n*2);
  //sitagawa
  for( int i = 0; i < n; i++ ) {
    while( k > 1 && ccw(L(ret[k-2],p[i]),ret[k-1])==LEFT ) k--;
    ret[k++] = p[i];
  }
  int t = k;
  //uegawa
  for( int i = n-2; i >= 0; i-- ) {
    while( k > t && ccw(L(ret[k-2],p[i]),ret[k-1])==LEFT ) k--;
    ret[k++] = p[i];
  }
  ret.resize(k-1);
  return ret;
}

int main(void)
{
  int n;
  scanf("%d",&n);
  vector<P> p(n);
  for( int i = 0; i < n; i++ ) {
    ldb x,y;
    scanf("%Lf%Lf",&x,&y);
    p[i] = P(x,y);
  }
  vector<P> cv = convex_hull(p);
  printf("%d\n",cv.size());
  for( int i = 0; i < int(cv.size()); i++ ) {
    printf("%.0Lf %.0Lf\n",cv[i].real(),cv[i].imag());
  }
  return 0;
}

Measured memory_bytes: 13472
N, M = map(int, input().split())
broken_step = [0]*(N+1)
for i in range(M):
    broken_step[int(input())] = 1
broken_step.extend([0,0,0])

mod = 1000000007

dp = [0]*(N+5)
dp[0] = 1

for n in range(N):
    if broken_step[n+1] == 0:
        dp[n+1] += dp[n]*1
    else:
        dp[n+1] = 0
    if broken_step[n+2] == 0:
        dp[n+2] += dp[n]*1
    else:
        dp[n+2] = 0
print(dp[N]%mod)

Measured memory_bytes: 473064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

double startTime;
double getCurrentTime() {
	return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}

char s[12];
int n;

int main()
{
	startTime = (double)clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%s", s);
	n = strlen(s);
	bool ok = n % 2 == 0;
	for (int i = 0; i < n; i++)
		ok &= s[i] == "hi"[i & 1];
	if (ok)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}


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

int main(void){
   int c[3][3];
   for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
         cin>>c[i][j];
      }
   }
   int a[3];
   int b[3];
   for(int i=0;i<3;i++){
      b[i]=c[0][i]-c[0][0];
   }
   for(int i=0;i<3;i++){
      a[i]=c[i][0]-b[0];
   }
   bool flag=true;
   for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
         if(a[i]+b[j]!=c[i][j]){
            flag=false;
            break;
         }
      }
   }
   if(flag) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   return 0;
}



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

using namespace std;

#define REP(i, N) for (int (i) = 0; (i) < (N); ++(i))
#define READALL(c) for (auto &e : c) { cin >> e; }
#define PRINTALL(c) for (const auto &e : c) { cout << e << "\t"; } cout << "\n";

template <typename T>
using V = vector<T>;

typedef long double ld;

int main() {
	int64_t N, T;
	cin >> N >> T;
	V<int64_t> times(N);
	READALL(times);
	int64_t ans = 0, lastt = -1, end_time = -1;
	set<pair<int64_t, int>> S;
	for (int64_t t : times) {
		S.emplace(t, 0);
	}
	while (S.size()) {
		int64_t time;
		int type;
		tie(time, type) = *S.begin();
		S.erase(S.begin());
		if (lastt != -1) {
			ans += time-lastt;
		}
		if (type == 1) {
			lastt = -1;
			end_time = -1;
		} else {
			lastt = time;
			if (end_time != -1) {
				S.erase(make_pair(end_time, 1));
			}
			end_time = time + T;
			S.emplace(end_time, 1);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
#define N 100005
int va[N];
int num[20];
int a[20],sz,b[1001000];
int dp[1001000];
int solve(int s)
{
	if(dp[s]) return dp[s];
	dp[s]=1;
	for(int i=s;i;)
	{
		i=(i-1)&s;
		if(i==0) continue;
        if(b[i]==0) dp[s]=max(dp[s],solve(i)+solve(s^i));
	}
	return dp[s];
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<n;++i)
	{
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		va[u]^=w; va[v]^=w;
	}
	for(int i=0;i<n;++i) ++num[va[i]];
	int cnt=num[0];
	for(int i=1;i<=15;++i)
	{
		cnt+=num[i]/2;
		if(num[i]&1) a[sz++]=i;
	}
	for(int s=0;s<(1<<sz);++s)
		for(int i=0;i<sz;++i)
			if(s>>i&1)
				b[s]^=a[i];
	if(sz)cnt+=solve((1<<sz)-1);
	printf("%d\n",n-cnt);
	return 0;
}


Measured memory_bytes: 4480
#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);
	int a,b;
	cin>>a>>b;
	cout<<a*b<<"\n";
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		cout<<"3C";
		if(n%39==0)cout<<39<<endl;
		else if(n%39<10)cout<<0<<n%39<<endl;
		else cout<<n%39<<endl;
	}
}

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

int main(){
    int n,i,j,sum=0;
    cin >> n;
    int t[n];
    for (i=0;i<n;i++){
        cin >> t[i];
        sum += t[i];
    }
    int m;
    cin >> m;
    int drink[m][2];
    for (i=0;i<m;i++){
        for(j=0;j<=1;j++){
            cin >> drink[i][j];
        }
    }

    for (i=0;i<m;i++){
        int num = drink[i][0]-1;
        sum = sum - t[num] + drink[i][1];
        cout << sum << endl;
        sum = sum +t[num] - drink[i][1];
    }
}



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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);

int main() {
    ll a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

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

//INSERT ABOVE HERE
signed main(){
  Int n,x;
  cin>>n>>x;
  vector<Int> c(n),t(n);
  for(Int i=0;i<n;i++) cin>>c[i]>>t[i];

  const Int INF = 1e9;
  Int ans=INF;
  for(Int i=0;i<n;i++)
    if(t[i]<=x) chmin(ans,c[i]);

  if(ans>=INF) cout<<"TLE"s<<endl;
  else cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
 
	void submit() {

        int N = nextInt();
        int[] P = new int[N];
        
        for(int i=0; i<N; i++){
            P[i] = nextInt();
        }

        int count = 1;

        if(N==1){
     	    out.println(count);
     	    return;
        }
        
        int min=P[0];
        for(int i=1; i<N; i++){
            if(min >= P[i]){
                min = P[i];
                count++;
            }
        }
     	out.println(count);
	}

	void preCalc() {
 
	}
 
	void stress() {
 
	}
 
	void test() {
 
	}
 
	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}
 
	static final Random rng = new Random();
 
	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}
 
	public static void main(String[] args) throws IOException {
		new Main();
	}
 
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
 
	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}
 
	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
 
	int nextInt() {
		return Integer.parseInt(nextToken());
	}
 
	long nextLong() {
		return Long.parseLong(nextToken());
	}
 
	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 47316
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define REP(I,N) for(int I=0;I<N;++I)
#define REPP(I,A,B) for(int I=A;I<B;++I)
#define RI(X) scanf("%d",&X)
#define RII(X,Y) scanf("%d%d",&X,&Y)
#define RIII(X,Y,Z) scanf("%d%d%d",&X,&Y,&Z)
#define DRI(X) int X;scanf("%d",&X)
#define DRII(X,Y) int X,Y;scanf("%d%d",&X,&Y)
#define DRIII(X,Y,Z) int X,Y,Z;scanf("%d%d%d",&X,&Y,&Z)
#define MS0(X) memset(X,0,sizeof(X))
#define MS1(X) memset(X,-1,sizeof(X))
#define RS(X) scanf("%s",X);
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;

PII x[100009];
PII v[100009];
int p[100009];

int fp(int x){
	return x==p[x]?x:p[x]=fp(p[x]);
}

void mg(int x,int y){
	x=fp(x),y=fp(y);
	p[x]=y;
}

int main(){
	DRI(n);
	REP(i,n){
		RII(x[i].F,x[i].S);
		v[i]=MP(x[i].F,i);
	}
	sort(v,v+n);
	vector<pair<int,PII> > elist;
	REP(i,n-1)elist.PB(MP(v[i+1].F-v[i].F,MP(v[i].S,v[i+1].S)));
	REP(i,n){
		v[i]=MP(x[i].S,i);
	}
	sort(v,v+n);
	REP(i,n-1)elist.PB(MP(v[i+1].F-v[i].F,MP(v[i].S,v[i+1].S)));
	LL ans=0;
	iota(p,p+n,0);
	sort(ALL(elist));
	for(auto cur:elist){
		if(fp(cur.S.F)==fp(cur.S.S))continue;
		ans+=cur.F;
		mg(cur.S.F,cur.S.S);
	}
	printf("%lld",ans);
}


Measured memory_bytes: 6388
from bisect import bisect_left
D = int(input())
C = list(map(int, input().split()))  # 低下
S = [list(map(int, input().split())) for _ in range(D)]
Last = [-1] * 26
def calc_pena(day):
    res = 0
    for l, c in zip(Last, C):
        res += (day-l)*c
    return res
T2 = [[-1] for _ in range(26)]
def change(day, contest):
    diff = 0
    contest_old = T[day]
    T[day] = contest
    idx = bisect_left(T2[contest_old], day)
    diff -= C[contest_old] * (T2[contest_old][idx+1] - day) * (day - T2[contest_old][idx-1])
    del T2[contest_old][idx]
    idx = bisect_left(T2[contest], day)
    diff += C[contest] * (T2[contest][idx] - day) * (day - T2[contest][idx-1])
    T2[contest].insert(idx, day)
    diff += S[day][contest] - S[day][contest_old]
    return diff

T = []
ans = 0
for day, s in enumerate(S):
    best_gain = -999999
    best_gain_contest = None
    pena = 0
    for cont, (l, c, s_) in enumerate(zip(Last, C, s)):
        p = (day-l)*c
        pena += p
        if best_gain < s_ + p:
            best_gain = s_ + p
            best_gain_contest = cont
    T.append(best_gain_contest)
    Last[best_gain_contest] = day
    ans += best_gain - pena
# print(T)
# print(ans)
# ans = 0
# Last = [-1] * 26
# for i, (s, t) in enumerate(zip(S, T)):
#     Last[t] = i
#     ans += s[t]
#     ans -= calc_pena(i)
#     T2[t].append(i)

print("\n".join(str(a+1) for a in T))


Measured memory_bytes: 9336
N = int(input())
S = input()
MOD = 10**9 + 7

# dp[j] (i番目のiteration時点): 
#   左から(i+1)番目まで並べ終えたときに、最も右の数が、
#   そのときに残っている(N-i)個の数の中で(j+1)番目に小さい数である場合の数
dp = [1] * N
cum = [[i for i in range(1, N+1)], [0]*N]

for i in range(1, N):
  idx = i%2
  if S[i-1] == '<':
    for j in range(N-i):
      dp[j] = cum[idx-1][j]
      if j == 0:
        cum[idx][0] = dp[j]
      else:
        cum[idx][j] = (cum[idx][j-1] + dp[j]) % MOD
  
  else:
    for j in range(N-i):
      dp[j] = (cum[idx-1][N-i] - cum[idx-1][j]) % MOD
      if j == 0:
        cum[idx][0] = dp[j]
      else:
        cum[idx][j] = (cum[idx][j-1] + dp[j]) % MOD

print(dp[0])

Measured memory_bytes: 43356
#include "bits/stdc++.h"
using namespace std;
 
// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
 
/*
--------------------------------------------
 
	type
 
--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;
 
/*
--------------------------------------------
 
	container
 
--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
 
/*
--------------------------------------------
 
	repetition
 
--------------------------------------------
*/
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPS(i,n) for(int i=0; i<(n); i++)
#define REPinit(a,n) for(int i=a; i<(n); i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)
 
//algorithm
//#define SORT(c) sort((c).begin(),(c).end())
 
/*
--------------------------------------------
 
	constant
 
--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
/*
 
	Optimizer
 
*/
//#pragma GCC optimize("Ofast")


/*
 
	Utility Algorithm
 
*/
template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

LL euclideanAlgorithm(LL a, LL b) {
    LL a_tmp = a;
    LL b_tmp = b;

    if (a_tmp > b_tmp) {
        swapAlgorithm<LL>(a_tmp, b_tmp);
    }

    LL r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

LL getLCM(LL a, LL b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

/*
  Code
*/

double eauclidDistance(pair<double, double>& x1, pair<double, double>& x2) {
  return sqrt((x1.first - x2.first) * (x1.first - x2.first) + (x1.second - x2.second) * (x1.second - x2.second));
}

void swap(int& a, int& b) {
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
}

int main(int argc, char const *argv[])
{
  int A,B,C;
  cin >> A >> B >> C;
  if((A+B)>=C) cout << "Yes";
  else cout << "No";
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void printBST(int[] arr) {
		int i = 1;
		while(i < arr.length) {
			System.out.print("node " + i + ": key = " + arr[i] + ",");
			if(i > 1) {
				System.out.print(" parent key = " + arr[i/2] + ", ");
				if(i * 2 < arr.length) {
					System.out.print("left key = " + arr[i * 2] + ", ");
				}
				if(i * 2 +1 < arr.length) {
					System.out.print("right key = " + arr[i * 2 + 1] + ", ");
				}
			}
			else {
				if(arr.length > 3) {
					System.out.print(" left key = " + arr[i*2] + ", right key = " + arr[i * 2 + 1] + ", ");
				}
				else {
					
				}
			}
			System.out.println();
			i++;
		}
		
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int sizeOfArray = in.nextInt();
		int[] arr = new int[sizeOfArray + 1];
		arr[0] = 0;
		for(int i = 1; i < arr.length; i++) {
			arr[i] = in.nextInt();
		}
		in.close();
		printBST(arr);
	}
}



Measured memory_bytes: 27380
#include <bits/stdc++.h>
using namespace std;
int main()
{
    
    int  t;
    cin>>t;
    
    
    
     if(t>1000)
    { int val = t%1000;
     
     if(val==0)
     cout<<val<<endl;
     else
     cout<<1000-val;
    }
    else
    {
        
      cout<<(1000-t);
    }
    
}

Measured memory_bytes: 3624
#include <iostream>
#include <map>

using namespace std;

long n;
int k;
map<int, int> mapd;

bool isOK(long n)
{
	while (n > 0)
	{
		int x = n % 10;
		n /= 10;

		if (mapd[x])
			return false;
	}

	return true;
}

int main()
{
	cin >> n >> k;
	for (int i = 0; i < k; ++i)
	{
		int x;
		cin >> x;
		mapd[x] = 1;
	}

	while (!isOK(n))
		++n;

	cout << n << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  int n,m;
  cin>>n>>m;
  priority_queue<int> memo;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    memo.push(a);
  }
  for(int i=0;i<m;i++){
    int a=memo.top();
    memo.pop();
    a/=2;
    memo.push(a);
  }
  ll ans=0;
  for(int i=0;i<n;i++){
    int a=memo.top();
    memo.pop();
    ans+=a;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3868
#include <list>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);

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

	int ans = 100000;
	REP(i, n) {
		ans += ceil(ans*0.05/1000)*1000;
	}
	cout << ans << endl;
	
	return 0;
}

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

int main(){
    
    long long int inf=10000007;
    long long int N;
    cin>>N;
    vector<int> dp(N+1,inf);
    dp[0]=0;

    int use[]={1,6,36,216,1296,7776,46656,9,81,729,6561,59049};

    for(long long int i=0;i<N+1;i++){
        for (int j=0;j<12;j++){
            if(i+use[j]<=N){
                dp[i+use[j]]=min(dp[i]+1,dp[i+use[j]]);}
        }
    }
    cout<<dp[N]<<endl;
            
    return 0;}

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

int main(int argc, char *argv[]) {
    int q;
    cin >> q;
    ll sumb = 0, sumleft = 0, sumright = 0;
    bool left = 0;
    ll cntleft = 0, cntright = 0;
    priority_queue<ll> pql;
    priority_queue<ll,vector<ll>,greater<ll>> pqr;
    while (q--) {
        int command;
        cin >> command;
        if (command == 1) {
            ll a,b;
            cin >> a >> b;
            sumb += b;
            if (!left) {
                left = 1;
                cntleft++;
                pql.push(a);
                sumleft += a;
            } else {
                left = 0;
                cntright++;
                pqr.push(a);
                sumright += a;
            }
            while (!pqr.empty() && pql.top() > pqr.top()) {
                ll l = pql.top();
                ll r = pqr.top();
                pql.pop();
                pqr.pop();
                pqr.push(l);
                pql.push(r);
                sumleft += -l + r;
                sumright += -r + l;
            }

        } else if (command == 2) {
            ll mid = pql.top();
            cout << mid << " " << sumb + (sumright - cntright * mid) + (cntleft * mid - sumleft) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3828