akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main() {
	int r, c, k;
	int ans = 0;
	cin >> r >> c >> k;
	VV path(r, V(c, 0LL));
	int a, b;
	ll v;
	rep(i, k) {
		cin >> a >> b >> v;
		path[a-1][b-1] = v;
	}
	vector<vector<vector<ll>>> dp(r, vector<vector<ll>>(c, vector<ll>(4, -INFLL)));
	dp[0][0][0] = 0LL;
	rep(j, c) {
		rep(i, r) {
			//if (path[i][j] != 0LL) {
			for (int k = 3; k >0 ; k--) {
				if (dp[i][j][k-1] == -INFLL) {
					continue;
				}
				chmax(dp[i][j][k], dp[i][j][k - 1] + path[i][j]);
			}
			//}
			rep(k, 4) {
				if (dp[i][j][k] == -INFLL) {
					continue;
				}
				if (j + 1 < c) {
					chmax(dp[i][j + 1][k], dp[i][j][k]);
				}
				if (i + 1 < r) {
					chmax(dp[i + 1][j][0], dp[i][j][k]);
				}
			}
		}
	}
	/*
	rep(i, r) {
		rep(j, c) {
			rep(k, 4) { clog << dp[i][j][k] << " "; }
			clog << endl;
		}
		clog << endl;
	}
	*/
	cout << max({dp[r - 1][c - 1][0], dp[r - 1][c - 1][1],dp[r - 1][c - 1][2], dp[r - 1][c - 1][3]}) << endl;
}

Measured memory_bytes: 706664
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
 
using namespace std;
 
typedef pair<int,int>P;
typedef pair<P,int>pi;
 
const int MAX_N = 500005;
const int MAX_Q = 101;
 
vector<pi> S,T;
vector<int> ans;
int n,Q;
 
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        S.push_back(pi(P(x,y),i));
        T.push_back(pi(P(y,x),i));
    }
    sort(S.begin(),S.end());
    sort(T.begin(),T.end());
    scanf("%d",&Q);
    rep(i,Q){
        int sx,tx,sy,ty;
        scanf("%d%d%d%d",&sx,&tx,&sy,&ty);
        int lx = lower_bound(S.begin(),S.end(),pi(P(sx,sy),0)) - S.begin();
        int hx = upper_bound(S.begin(),S.end(),pi(P(tx,ty),n)) - S.begin();
        int ly = lower_bound(T.begin(),T.end(),pi(P(sy,sx),0)) - T.begin();
        int hy = upper_bound(T.begin(),T.end(),pi(P(ty,tx),n)) - T.begin();
        int wx = hx - lx;
        int wy = hy - ly;
        if(wx < wy){
            for(int i=lx;i<hx;i++){
                int y = S[i].first.second;
                if(sy <= y && y <= ty){ 
                    ans.push_back(S[i].second);
                }
            }
        }else{
            for(int i=ly;i<hy;i++){
                int x = T[i].first.second;
                if(sx <= x && x <= tx){
                    ans.push_back(T[i].second);
                }
            }
        }
        sort(ans.begin(),ans.end());
        rep(i,ans.size()){
            printf("%d\n", ans[i]);
        }
        printf("\n");
        ans.clear();
    }
    return 0;
}

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

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    using T = tuple<int, int, int, int>;
    vector<T> q;
    for(int i = 0; i < Q; ++i) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--;
        q.emplace_back(a, b, c, d);
    }
    vector<int> A;
    auto score = [&]() -> int {
        int res = 0;
        for(auto &[a, b, c, d] : q) {
            if(A[b] - A[a] == c) res += d;
        }
        return res;
    };
    auto dfs = [&](auto &&dfs, int lst) -> int {
        if(A.size() == N) return score();
        int res = 0;
        for(int i = lst; i <= M; ++i) {
            A.push_back(i);
            res = max(res, dfs(dfs, i));
            A.pop_back();
        }
        return res;
    };
    cout << dfs(dfs, 1) << '\n';
    return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  for (int n = 0; n < 10000; ++n) {
    int za = n*8/100;
    int zb = n*10/100;
    if (a == za && b == zb) {
      cout << n << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int p[20];

int main() {

	int n, i, count=0;
	scanf("%d",&n);

	for (i=0; i<n; i++) {
		scanf("%d",&p[i]);
	}

	for (i=1; i<n-1; i++) {

		if (p[i-1]>p[i] && p[i]>p[i+1])
			count++;
		else if (p[i-1]<p[i] && p[i]<p[i+1])
			count++;
	}

	printf("%d",count);

	return 0;
}


Measured memory_bytes: 128
class PriorityQueue
  def initialize(array = [])
    @data = []
    array.each{|a| push(a)}
  end

  def push(element)
    @data.push(element)
    bottom_up
  end

  def pop
    if size == 0
      return nil
    elsif size == 1
      return @data.pop
    else
      min = @data[0]
      @data[0] = @data.pop
      top_down
      return min
    end
  end

  private

  def swap(i, j)
    @data[i], @data[j] = @data[j], @data[i]
  end

  def size
    @data.size
  end

  def parent_idx(target_idx)
    (target_idx - (target_idx.even? ? 2 : 1)) / 2
  end

  def bottom_up
    target_idx = size - 1
    return if target_idx == 0
    parent_idx = parent_idx(target_idx)
    while (@data[parent_idx] > @data[target_idx])
      swap(parent_idx, target_idx)
      target_idx = parent_idx
      break if target_idx == 0
      parent_idx = parent_idx(target_idx)
    end
  end

  def top_down
    target_idx = 0

    # child がある場合
    while (has_child?(target_idx))

      a = left_child_idx(target_idx)
      b = right_child_idx(target_idx)

      if @data[b].nil?
        c = a
      else
        c = @data[a] <= @data[b] ? a : b
      end

      if @data[target_idx] > @data[c]
        swap(target_idx, c)
        target_idx = c
      else
        return
      end
    end
  end

  # @param Integer
  # @return Integer
  def left_child_idx(idx)
    (idx * 2) + 1
  end

  # @param Integer
  # @return Integer
  def right_child_idx(idx)
    (idx * 2) + 2
  end

  # @param Integer
  # @return Boolent
  def has_child?(idx)
    ((idx * 2) + 1) < @data.size
  end
end



class PriorityQueue
  attr_accessor :data, :size
 
  def initialize(array = [])
    @data = []
    array.each { |a| push(a) }
  end
 
  def push(element)
    current = @data.size
    while current > 0
      p = parent(current)
      break if @data[p] <= element
      @data[current] = @data[p]
      current = p
    end
    @data[current] = element
  end
 
  def pop
    ret = @data[0]
    x = @data[-1]
    current = 0
    while have_child?(current)
      a = left_child(current)
      b = right_child(current)
      a = b if b < @data.size - 1 && @data[b] <= @data[a]
      break if @data[a] >= x
      @data[current] = @data[a]
      current = a
    end
    @data[current] = x
    @data.pop
 
    ret
  end
 
  def size
    @data.size
  end
 
  def front
    @data[0]
  end
 
  def empty?
    @data.empty?
  end
 
  private
  def parent(num)
    (num - 1) / 2
  end
 
  def left_child(num)
    num * 2 + 1
  end
 
  def right_child(num)
    num * 2 + 2
  end
 
  def have_child?(num)
    left_child(num) < @data.size - 1
  end
end


N, M = gets.chomp.split(' ').map(&:to_i)

AB = []
N.times do |i|
  AB[i] = gets.chomp.split(' ').map(&:to_i)
end

group_by_day = Hash[AB.group_by{|v|v[0]}.sort]

day_fee = Array.new(M){[]}
group_by_day.each do |k,v|
  day_fee[k-1] = v.map{|j| j[1]}
end

# require 'pry'
# binding.pry

ans = 0
pq = PriorityQueue.new
day_fee.each_with_index do |fees, idx|
  break if idx > M - 1
  fees.each do |fee|
    pq.push(fee*(-1))
  end
  ans += pq.pop.to_i
  # p pq
  # p pq.pop*(-1)
end

puts ans*(-1)


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

namespace ConsoleApp36 {
    class Program {
        static void Main(string[] args) {
            var s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int A = s[0];
            int B = s[1];
            int X = s[2];

            int sum = A + B;

            if (A > X || X > sum) {
                Console.WriteLine("NO");
            } else {
                Console.WriteLine("YES");
            }
        }
    }
}


Measured memory_bytes: 13268
class UnionFind:
    def __init__(self, n):
        self.p = [i for i in range(n)]
        self.components = n  # 連結成分の数

    def root(self, x):
        if self.p[x] == x:
            return x
        else:
            self.p[x] = self.root(self.p[x])
            return self.p[x]
    
    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            self.p[x] = y
            self.components -= 1
    
    def same(self, x,y):
        return (self.root(x) == self.root(y))

N = int(input())
MAX = 100010
UF = UnionFind(2*MAX)

for _ in range(N):
    x, y = map(int,input().split())
    UF.unite(x,y+MAX)


cnt_x, cnt_y = [0]*(2*MAX), [0]*(2*MAX)

for i in range(MAX):
    cnt_x[UF.root(i)] += 1

for i in range(MAX,2*MAX):
    cnt_y[UF.root(i)] += 1

print(sum([cnt_x[i]*cnt_y[i] for i in range(2*MAX)]) - N)

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

typedef long long ll;
using namespace std;

int n;

int d[1000000];
struct edge{
    int to;
    int cost;
};

void dfs(int node, const vector<vector<edge> >&v, int pcolor){
    d[node] = pcolor;
    for(int i = 0; i < v[node].size(); i++){
        int next_node = v[node][i].to;
        if(d[next_node] == -1){
            int color = pcolor;
            if(v[node][i].cost % 2 == 1) {color = 1 - color;}
            dfs(next_node, v, color);
        }
    }
}
int main(){
    cin >> n;
    vector<vector<edge> > tree(n);
    for(int i = 0; i < n; i++) {d[i] = -1;}
    for(int i = 0; i < n-1; i++){
        int u, v, w;
        cin >> u >> v >> w;
        edge e = {v-1, w};
        edge re = {u-1, w};
        tree[u-1].emplace_back(e);
        tree[v-1].emplace_back(re);
    }

    dfs(0, tree, 0);

    for(int i = 0; i < n; i++){
        cout << d[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 8192
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int R;

int main()
{
    while (scanf("%d",&R)!=EOF)
    {
        if (R<1200) puts("ABC");
        else if (R<2800) puts("ARC");
        else puts("AGC");
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    public static void process()throws IOException
    {
        int l = ni(), r = ni(), d = ni();
        int ld = (l-1)/d, rd = r/d;
        pn(rd - ld);
    }
 
    static final long mod = (long)1e9+7l;
    
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc = new FastReader();
 
        long s = System.currentTimeMillis();
        int t = 1;
        //t = ni();
        while(t-- > 0)
            process();
 
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }

    static void trace(Object... o){ System.err.println(Arrays.deepToString(o)); };
    static void pn(Object o){ out.println(o); }
    static void p(Object o){ out.print(o); }
    static int ni()throws IOException{ return Integer.parseInt(sc.next()); }
    static long nl()throws IOException{ return Long.parseLong(sc.next()); }
    static double nd()throws IOException{ return Double.parseDouble(sc.next()); }
    static String nln()throws IOException{ return sc.nextLine(); }
    static long gcd(long a, long b)throws IOException{ return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{ return (b==0)?a:gcd(b,a%b); }
    static int bit(long n)throws IOException{ return (n==0)?0:(1+bit(n&(n-1))); }
    
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 36492
#include <iostream>
#include <vector>

using namespace std;

int main() {
    string s;
    cin >> s;
    int result = 0;
    for (int i = 0; i <s.size(); i++) {
        int t = 0;
        while (i < s.size() and s[i] == 'R') {
            t++;
            i++;
        }
        if (t > result) {
            result = t;
        }
    }
    cout << result;
    return 0;
};

Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll a,b,c,i,j,k=0,z=0;
    string s,d;
    cin>>a;
    if(a%2==1)
    {
        k=0;
    }
    else
    {
        while(a!=0)
        {
            if(z==0)
            {
                k=k+(a/10);
                a=a/10;
                z=1;
            }
            else
            {
                k=k+(a/5);
                a=a/5;
            }
        }
    }
    cout<<k<<endl;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  int sum = 0;
  int cur = 1;
  while (sum <= n) {
    sum += cur++;
  }
  int diff = sum - n;
  int to = diff == 0? cur: cur - 1;
  for (int i = 1; i <= to; ++i) {
    if (i != diff) cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int minus = 0;
    long min = 1000000000;
    long ans = 0;
    for(int i = 0; i < N; i++){
      long n = Long.parseLong(sc.next());
      if(n < 0){
        minus++;
      }
      ans += Math.abs(n);
      if(Math.abs(n) < min){
        min = Math.abs(n);
      }
    }
    if(minus % 2 == 1){
      ans -= min*2;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 46776
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int A[1000005];
int main()
{
    int n;

    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&A[i]);
    for(int i=1;i<=n;i++)
    {
        printf("node %d: ",i);
        printf("key = %d, ",A[i]);
        if(i/2 >= 1)
            printf("parent key = %d, ",A[i/2]);
        if(2*i <= n)
            printf("left key = %d, ",A[2*i]);
        if(2*i+1 <= n)
            printf("right key = %d, ",A[2*i+1]);
        printf("\n");
    }
    return 0;
}

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

int main()
{
	int N;
	cin >> N;
	int res = 0;
	for (int i = 1; i <= N; i += 2) {
		int cnt = 0;
		for (int j = 1; j <= i; j++) {
			cnt += (i % j == 0);
		}
		res += (cnt == 8);
	}
	cout << res << endl;
	return 0;
}


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

int main(){
	int h, n, p, m, k;
	scanf("%d%d%d%d%d", &h, &n, &p, &m, &k);
	vector<int> v(h, -1);
	for(int i = 0; i < m; ++i){
		int a, b;
		scanf("%d%d", &a, &b);
		v[a - 1] = b - 1;
	}

	int rst = h - m;
	vector<vector<double> > dp1(k + 1, vector<double>(n)), dp2;
	dp2 = dp1;
	dp1[k][p - 1] = 1;
	for(int g = h - 1; g >= 0; --g){
		if(v[g] == -1){
			dp2[0] = dp1[0];
			for(int i = 1; i <= k; ++i){
				double pr1 = (double)i / rst;
				double pr2 = pr1 / (n - 1);
				for(int j = 0; j < n; ++j){
					dp2[i][j] = dp1[i][j] * (1 - pr1);
				}
				dp2[i - 1][0] += (dp1[i][0] * (n - 2) + dp1[i][1]) * pr2;
				dp2[i - 1][n - 1] += (dp1[i][n - 1] * (n - 2) + dp1[i][n - 2]) * pr2;
				for(int j = 1; j < n - 1; ++j){
					dp2[i - 1][j] += (dp1[i][j] * (n - 3) + dp1[i][j - 1] + dp1[i][j + 1]) * pr2;
				}
			}
			dp1.swap(dp2);
			--rst;
		}
		else{
			for(int i = 0; i <= k; ++i){
				swap(dp1[i][v[g]], dp1[i][v[g] + 1]);
			}
		}
	}
	double ans = *max_element(dp1[0].begin(), dp1[0].end());
	printf("%.9f\n", ans);
}

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

int main(){
    int n,k;cin >> n>>k;
    int arr[100001];
    for(int i=0;i<n;i++) cin >>arr[i];
    ll ans[100001];
    for(int i=0;i<n;i++) ans[i]=0;
    ans[0]=0;
    //ans[1]=arr[0];
    for(int i=1;i<n;i++){
        ll mini=10000000001;
        for(int j=0;j<min(k,i);j++){
            mini=min(mini,ans[i-j-1]+abs(arr[i]-arr[i-j-1]));
        }
        ans[i]=mini;
    }
    cout <<ans[n-1]<<endl;
}



Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define ll long long
#define ull  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 305;
int dp[N][N][N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s;
    cin >> s;
    int k;
    cin >> k;
    int ans = 0;
    int n = s.length();
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            for (int l = 0; l <= k; l++){
                int p1 = i - 1;
                int p2 = n - j;
                if (s[p1] == s[p2]){
                    dp[i][j][l] = dp[i - 1][j - 1][l] + 1;
                }
                dp[i][j][l] = max({dp[i][j][l], dp[i - 1][j][l], dp[i][j - 1][l]});
                dp[i][j][l] = max(dp[i][j][l], dp[i - 1][j - 1][l]);
                if (l != 0) dp[i][j][l] = max(dp[i][j][l], dp[i - 1][j - 1][l - 1] + 1);
                if (i + j < n) ans = max(ans, 1 + 2 * dp[i][j][l]);
                if (i + j <= n) ans = max(ans, 2 * dp[i][j][l]);
                if (i + j <= n + 1) ans = max(ans, 2 * dp[i][j][l] - 1);
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 110464
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

r,g,b=MI()
if (10*g+b)%4==0:
    print("YES")
else:
    print("NO")

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

ll mod = 998244353;

ll modpower(ll a, ll r){ //a^r
    ll x = 1;
    while (r > 0) {
        if (r & 1) x = x * a % mod;
        r >>= 1;
        a = a * a % mod;
    }
    return x;
}

ll modinv(ll a){
    return modpower(a, mod-2);
}

vector<ll> fact(300001, 1);
vector<ll> invfact(300001, 1);
ll modconv(ll n, ll k){
	if (k > n || k < 0) return 0;
	return fact[n] * invfact[k]%mod * invfact[n-k] % mod;
}

int main(){
    ll N, A, B, K;
    cin >> N >> A >> B >> K;
    
    for (int i = 2; i <= 300000; i++) fact[i] = (fact[i-1]*i)%mod;
    invfact[300000] = modinv(fact[300000]);
    for (int i = 299999; i >= 1; i--) invfact[i] = (invfact[i+1]*(i+1))%mod;
    ll ans = 0;
    for (ll i = 0; i <= N; i++) {
        if ((K-A*i)%B != 0) continue;
        ll j = (K-A*i)/B;
        if (j < 0 || j > N) continue;
        ans = (ans + modconv(N, i)*modconv(N, j))%mod;
    }
    cout << ans << endl;
    return 0;
}


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

int d[222222];
int main() {
	string s;
	cin >> s;
	int b = 0;
	for (int i = s.length(); i--;) {
		if (s[i] == 'B') {
			if (i + 1 < s.length() && s[i + 1] == 'C')
				d[i] = d[i + 1] + 1;
			else d[i] = 0;
			b = 1;
			continue;
		}
		if (b) d[i] = d[i + 1];
		else d[i] = 0;
		if (s[i] == 'C') b = 0;
	}
	long r = 0;
	for (int i = 0; i < s.length(); i++)
		if (s[i] == 'A') r += d[i];
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 1412
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;


class Graph{
public:
    Graph(long long int o_n):edge(o_n,vector<long long int>(o_n,linf/3)){
        n = o_n;
        REP(i,n){
            edge[i][i] = 0;
        }
    }

    void add_edge(long long int a,long long int b,long long int c){
        edge[a][b] = c;
        edge[b][a] = c;
    }
    void wf(){
        REP(k,n){
            REP(i,n){
                REP(j,n){
                    edge[i][j] = min(edge[i][j], edge[i][k] + edge[k][j]);
                }
            }
        }
    }

    long long int get_cost(long long int a,long long int b){

        return edge[a][b];
    }
private:
    long long int n;

    vector<vector<long long int>> edge;
};


int main(){

    long long int n,m,l;
    cin>>n>>m>>l;
    unique_ptr<Graph> graph1(new Graph(n));
    long long int tmpa, tmpb, tmpc;
    REP(i,m){
        scanf("%lld %lld %lld", &tmpa, &tmpb, &tmpc);
        graph1->add_edge(tmpa-1, tmpb-1, tmpc);
    }

    graph1->wf();
    unique_ptr<Graph> graph2(new Graph(n));
    REP(i,n){
        REP(j,n){
            if(i!=j){
                if(graph1->get_cost(i,j)<=l){
                    graph2->add_edge(i, j, 1);
                }
            }
        }
    }
    graph2->wf();

    long long int q;
    cin >> q;
    REP(i,q){
        scanf("%lld %lld", &tmpa, &tmpb);
        if(graph2->get_cost(tmpa-1,tmpb-1)<linf/3){
            cout << graph2->get_cost(tmpa-1, tmpb-1)-1 << endl;
        }else{
            cout << -1 << endl;
        }
    }


    return 0;
}


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

public class Main{
	// main????????????
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		for(; ;){
			String oneline = br.readLine();
			if(oneline == null){
				break;
			}
			String[] line = oneline.split(" ");
			int data1 = Integer.parseInt(line[0]);
			int data2 = Integer.parseInt(line[1]);
			
			int digit = digitChk(data1, data2);
			
			System.out.println(digit);
		}
	}
	
	private static int digitChk(int a, int b){
		int sum = a+b;
		int digit = 0;	// digit
		
		for(; sum>0; digit++){
			sum /= 10;
		}
		
		return (digit);
	}

}

Measured memory_bytes: 24264
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;
using ll = long long;
const int MM = 2e5+5;

int n;
ll a[MM], ans;
map<ll, ll> mp;

int main(){
    scan(n);
    for(int i = 1; i <= n; i++){
        scan(a[i]);
        ans += mp[i-a[i]];
        mp[a[i]+i]++;
    }
    print(ans);
    
    return 0;
}

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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)


int a,b;

int main(){
  cin >> a >> b;
  cout << (a-1)*(b-1) <<endl;
}


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

int main() {

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

	while(a > 0 && c > 0) {
		c -= b;
		if(c <= 0) continue;
		a -= d;
	}

	if(a <= 0) cout << "No\n";
	else cout << "Yes\n";

	return 0;
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000

using namespace std;
typedef long long ll;
typedef pair<ll ,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;


int n;
int main(){
	cin >> n;
	set<int> s;
	rep(i, 0, n){
		int t;cin >> t;
		s.insert(t);
	}
	if(s.size() == n)cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 9600
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld double 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define BOOST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define sl(a) a.size()
#define mod 1000000007 
#define lcm(a,b) (a*b)/__gcd(a,b)
#define MAX1 100006
#define f first
#define s second
#define pi 2*acos(0.0)
void solve()
{
    ll x,y,a,b;  cin>>x>>y>>a>>b;
    ll lc=(a*b)/(__gcd(a,b));
    cout<<(y-x+1)-((y/a)-((x-1)/a))-((y/b)-((x-1)/b))+((y/lc)-((x-1)/lc));
}
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt","r",stdin);
    //for getting error from error.txt
    freopen("error.txt", "w", stderr);
    // for writing output to output.txt
    freopen("output.txt","w",stdout);
    #endif
    BOOST
    int T=1;  //cin>>T;
    while(T--) solve();
    cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<"\n";
    cerr<<"My CLOCKS_PER_SEC= "<<CLOCKS_PER_SEC<<"\n";
    return 0;
}


Measured memory_bytes: 3780
#include <stdio.h>

int main(){
 int x[100],i, j, temp;
 for(i = 0;i < 10;i++){
  scanf("%d",&x[i]);
}

for (i = 0; i < 9; i++) {
  for (j = 9; j > i; j--) {
            if (x[j - 1] > x[j]) {  /* 前の要素の方が大きかったら */
                temp = x[j];        /* 交換する */
    x[j] = x[j - 1];
    x[j - 1]= temp;
  }
}
}

for(i = 9;i > 6;i--){
  printf("%d\n",x[i]);
}
return 0;
}

Measured memory_bytes: 600
package main

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

type node struct {
	prev *node
	next *node
	value int
}

type doublyLinkedList struct {
	first *node
	last *node
	size int
}

func (l doublyLinkedList) String() string {
	elems := make([]string, l.size)
	node := l.first
	for i := 0; i < l.size; i++ {
		elems[i] = strconv.Itoa(node.value)
		node = node.next
	}
	return strings.Join(elems, " ")
}

func newDoublyLinkedList() *doublyLinkedList {
	return &doublyLinkedList{
		first: nil,
		last: nil,
		size: 0,
	}
}

func (l *doublyLinkedList) insert(value int) {
	node := &node{prev: nil, next: nil, value: value}
	if l.first == nil {
		l.first = node
		l.last = node // last should be nil if first is nil
	} else {
		node.next = l.first
		l.first.prev = node
		l.first = node
	}
	l.size++
}

func (l *doublyLinkedList) delete(value int) {
	node := l.first
	for node != nil && node.value != value {
		node = node.next
	}
	if node != nil {
		if node.prev == nil {
			l.first = node.next
		} else {
			node.prev.next = node.next
		}
		if node.next == nil {
			l.last = node.prev
		} else {
			node.next.prev = node.prev
		}
		l.size--
	}
}

func (l *doublyLinkedList) deleteFirst() {
	if l.first != nil {
		if l.last == l.first {
			l.first = nil
			l.last = nil
		} else {
			l.first = l.first.next
			l.first.prev = nil
		}
		l.size--
	}
}

func (l *doublyLinkedList) deleteLast() {
	if l.last != nil {
		if l.first == l.last {
			l.first = nil
			l.last = nil
		} else {
			l.last = l.last.prev
			l.last.next = nil
		}
		l.size--
	}
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}

	l := newDoublyLinkedList()

	for i := 0; i < n; i++ {
		command := nextText(sc)
		switch command {
		case "insert":
			v, err := nextInt(sc)
			if err != nil {
				panic(err)
			}
			l.insert(v)
		case "delete":
			v, err := nextInt(sc)
			if err != nil {
				panic(err)
			}
			l.delete(v)
		case "deleteFirst":
			l.deleteFirst()
		case "deleteLast":
			l.deleteLast()
		default:
			panic(fmt.Errorf("invalid command: %s\n", command))
		}
	}

	fmt.Println(l)
}

func nextText(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextInt(sc *bufio.Scanner) (int, error) {
	return strconv.Atoi(nextText(sc))
}


Measured memory_bytes: 48644
my($K,$S)=split(/ /,<>);

my $c=0;
for my $x(0..$K){
for my $y(0..$S-$x){
  next if $y > $K;
  my $z = $S - $x - $y;
  next if $z > $K;
  $c++;
}
}
print($c);

Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  string s;
  cin>>s;
  int n=s.size()-1;
  ll ans=0;
  rep(bit,1<<n){
    ll res=0;
    ll part=0;
    rep(i,n){
      if(bit &(1<<i)){
        part+=stoll(s.substr(res,i-res+1));
        res=i+1;
      }
    }
    part+=stoll(s.substr(res,s.size()-res));
    ans+=part;
  }
  cout<<ans<<endl;
}
        

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <list>
#include <numeric>
using namespace std;
 
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
#define rep(i, N) for (int i = 0; i < (int)(N); i++)
#define pb push_back
 
int INF = INT_MAX / 10;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int H, W; cin >> H >> W;
	vector<string> a(H);
	rep(y, H) cin >> a[y];
	int ans = 0;
	for (int x = 0; x + 1 < W; x++) {
		vector<vector<int> > cost(H + 1, vector<int>(H + 1));
		for (int i = 0; i <= H; i++)
			for (int j = 0; j <= H; j++)
				if (i && j)
					cost[i][j] = cost[i - 1][j - 1] + (a[i - 1][x] == a[j - 1][x + 1]);
		vector<vector<int> > dp(H + 1, vector<int>(H + 1, INT_MAX));
		dp[0][0] = 0;
		for (int i = 0; i <= H; i++)
			for (int j = 0; j <= H; j++) {
				if (i) dp[i][j] = min(dp[i][j], dp[i - 1][j] + cost[i][j]);
				if (j) dp[i][j] = min(dp[i][j], dp[i][j - 1] + cost[i][j]);
			}
		ans += dp[H][H];
	}
	cout << ans << endl;
}


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

long gcm(long i, long j){
    if(i%j>0) return gcm(j, i%j);
    else return j;
}

int main() {
    int N; cin >> N;
    long P=1, T;
    for(int i=0; i<N; ++i){
        cin >> T;
        P /= gcm(P, T);
        P *= T;
    }
    cout << P << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<functional>
#include<map>
using namespace std;
int main()
{
	int x, y, z, i, j;
	cin >> x >> y >> z;
	cout << (x-z)/(y+z) << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;

int main() {
    int n,m;
    cin >> n >> m;
    if(n == m) cout <<"Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
s=input()
a=list("abcdefghijklmnopqrstuvwxyz")
if len(s)!=26:nokori=sorted(set(a)-set(s),key=a.index);print(s+nokori[0])
else:
 for i in range(2,27):
  if s[-i]<s[-i+1]:
    break
  if i==26:
   print(-1)
   exit()
 t=sorted(s[-i+1:])
 for j in t:
  if j>s[-i]:break
 print(s[:-i]+j)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, AB):
    AB.sort(key=lambda x: x[1])
    c = 0
    for a, b in AB:
        if c + a <= b:
            c += a
        else:
            return 'No'
    
    return 'Yes'


def main():
    N = read_int()
    AB = [read_int_n() for _ in range(N)]
    print(slv(N, AB))


if __name__ == '__main__':
    main()


Measured memory_bytes: 55932
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> inline bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> inline bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    in>>n;
    vector<ll> a(n);
    for(auto&i:a) in>>i;
    if(n&1){
        if(n==3) return cout<<max({a[0],a[1],a[2]})<<endl,0;
        auto c=vector(3,vector(n,-(1ll<<60)));
        c[0][0]=a[0];
        c[1][1]=a[1];
        c[0][2]=a[0]+a[2];
        c[2][2]=a[2];
        c[1][3]=max(a[0]+a[3],a[1]+a[3]);
        for(int i=4;i<n;++i){
            chmax(c[0][i],c[0][i-2]+a[i]);
            chmax(c[1][i],max(c[1][i-2]+a[i],c[0][i-3]+a[i]));
            chmax(c[2][i],max({c[2][i-2],c[1][i-3],c[0][i-4]})+a[i]);
        }
        cout<<max({c[2][n-1],c[1][n-2],c[0][n-3]})<<endl;
    }
    else{
        if(n==2) return cout<<max({a[0],a[1]})<<endl,0;
        auto c=vector(2,vector(n,-(1ll<<60)));
        c[0][0]=a[0];
        c[1][1]=a[1];
        c[0][2]=a[0]+a[2];
        for(int i=3;i<n;++i){
            chmax(c[0][i],c[0][i-2]+a[i]);
            chmax(c[1][i],max(c[1][i-2],c[0][i-3])+a[i]);
        }
        cout<<max({c[1][n-1],c[0][n-2]})<<endl;
    }
}


Measured memory_bytes: 11052
<?php
fscanf(STDIN, "%d %d", $A, $B);
$ans = -1;
for ($i = $B * 10; $i < ($B + 1) * 10; $i++) {
    if ($A === intval($i * .08)) {
        $ans = $i;
        break;
    }
}
printf("%d", $ans);


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

using ll = long long;

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)

using namespace std;

//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve()
{
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    auto max = max_element(a.begin(), a.end());
    auto min = min_element(a.begin(), a.end());
    int maxIndex = distance(a.begin(), max);
    int minIndex = distance(a.begin(), min);
    if (a[maxIndex] >= 0 && a[minIndex] >= 0)
    {
        cout << n - 1 << "\n";
        REP(i, n - 1) cout << i + 1 << " " << i + 2 << "\n";
    }
    else if (a[maxIndex] < 0 && a[minIndex] < 0)
    {
        cout << n - 1 << "\n";
        REP(i, n - 1) cout << n - i << " " << n - i - 1 << "\n";
    }
    else
    {
        cout << 2*n-1 << "\n";
        if (abs(a[maxIndex]) >= abs(a[minIndex]))
        {
            REP(i, n) cout << maxIndex+1 << " " << i+1 << "\n";
            REP(i, n - 1) cout << i + 1 << " " << i+2 << "\n";
        }
        else
        {
            REP(i, n) cout << minIndex+1 << " " << i+1 << "\n";
            REP(i, n-1) cout << n-i << " " << n-i-1 << "\n";
        }
    }
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
read = sys.stdin.read
import numpy as np

n, t = map(int, input().split())
m = map(int, read().split())
AB = sorted(zip(m, m))
A, B = zip(*AB)
dp = np.zeros((n+1, t), dtype=np.int64)
for i, (a, b) in enumerate(AB):
  np.maximum(dp[i, a:], dp[i, :-a]+b, out=dp[i+1, a:])
maxB = np.maximum.accumulate(B[::-1])[::-1]
ans = (dp[1:-1, -1]+maxB[1:]).max()
print(ans)

Measured memory_bytes: 97576
N,Y = list(map(int, input().split()))
for i in reversed(range(min(N+1, Y//10000+1))):
    for j in reversed(range(min(N-i+1, (Y-10000*i)//5000+1))):
        k = N-i-j
        if i*10000 + j*5000 + k*1000 == Y:
            print(i, j, k)
            exit()

print(-1, -1, -1)

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

#define ll long long int
#define maxval (int)1e5
#define maxn 100

int dp[maxval+1][maxn+1];
bool solved[maxval+1][maxn+1];

ll getminwgt(int val, int index, int *w, int *v, int n){
	if(val<=0){
		return 0;
	}
	else if(index==n){
		return INT_MAX;
	}
	else if(solved[val][index]){
		return dp[val][index];
	}
	else{
		solved[val][index] = 1;
		dp[val][index] = min(getminwgt(val, index+1, w, v, n), w[index] + getminwgt(val-v[index], index+1, w, v, n));
		return dp[val][index];
	}
}

ll test(int *w, int *v, int n, int c){
	for(int i = maxval; i>=0; i--){
		if(getminwgt(i,0,w,v,n)<=c){
			return i;
		}
	}
	return 0;
}

int main(){
	#ifndef ONLINE_JUDGE
	freopen("/home/afzalrao/Desktop/Academics/2nd Year/3rd Sem/ESO207/CP/Text Files/input.txt", "r", stdin);
	freopen("/home/afzalrao/Desktop/Academics/2nd Year/3rd Sem/ESO207/CP/Text Files/output.txt", "w", stdout);
	#endif
	int n, *w, *v, c;
	cin >> n >> c;
	w = new int[n]; v = new int[n];
	for(int i = 0; i < n; i++){
		cin >> w[i] >> v[i];
	}
	for(int i = 0; i < maxval+1; i++){
		for(int j = 0; j < maxn + 1; j++){
			solved[i][j] = 0;
		}
	}
	cout << test(w,v,n,c);
	return 0;
}

Measured memory_bytes: 52892
using System;
using System.Linq;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var a = int.Parse(_[0]);
            var b = int.Parse(_[1]);

            var count = 0;
            for(var i = a; i <= b; i++){
                var s1 = i.ToString();
                var s2 =  string.Join("",s1.Reverse());
                if(s1.Equals(s2)){
                    count++;
                }
            }

            Console.WriteLine(count);
        }
    }
}


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

int main(){
  int W, H;
  while(cin >> W >> H, W){
    vector<string> C(H);
    for(int i = 0; i < H; ++i)
      cin >> C[i];
    string dp[H][W];
    for(int i = 0; i < H; ++i){
      for(int j = 0; j < W; ++j){
	if(C[i][j] < '0' || C[i][j] > '9') continue;
	string s = string(1,C[i][j]), t = string(1,C[i][j]);
	if(i > 0 && dp[i-1][j] != "0") s = dp[i-1][j] + C[i][j];
	if(j > 0 && dp[i][j-1] != "0") t = dp[i][j-1] + C[i][j];
	if(s.size() == t.size()) dp[i][j] = max(s,t);
	else{
	  if(s.size() > t.size()) dp[i][j] = s;
	  else dp[i][j] = t;
	}
      }
    }
    string ans = "";
    for(int i = 0; i < H; ++i){
      for(int j = 0; j < W; ++j){
	if(ans.size() == dp[i][j].size()) ans = max(ans,dp[i][j]);
	else{
	  if(ans.size() < dp[i][j].size()) ans = dp[i][j];
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

#include <iostream>
#include <vector>
// #include <map>
#include <string>
#include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

int main() {
	string w, s;
	cin >> w;

	int sum = 0;
	while (1) {
		cin >> s;
		if (s == "END_OF_TEXT") {
			break;
		}
		transform(s.begin(), s.end(), s.begin(), ::tolower);
		if (s == w) {
			sum++;
		}
	}
	cout << sum << endl;
	return 0;
}



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

int main() {
    int n; cin >> n;
    for (int i = 1; i < 50000; i++)
    {
        if ((i * 108) / 100 == n) {
            cout << i << endl;
            return 0;
        }
    }

    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define rep1(i,n) for (int i=1; i<=(int)(n); i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fst first
#define scd second
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string s; cin >> s;
  int n = s.size(), ans = 0;
  stack<char> S,T;
  rep(i,n) S.push(s[n-1-i]);
  while(!S.empty()) {
    char si = S.top(); S.pop();
    if (!S.empty() && si != S.top()) {
      S.pop();
      ans += 2;
    } else {
      T.push(si);
    }
    while (!T.empty() && !S.empty() && T.top() != S.top()) {
      T.pop(); S.pop();
      ans += 2;
    }
  }
  while (!T.empty()) {
    char ti = T.top(); T.pop();
    if (!T.empty() && T.top() != ti) {
      T.pop();
      ans += 2;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3740
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
using namespace std;
 
#define ll long long

int main() {
	char a; cin >> a;
	if(a=='A') cout << 'T' << endl;
	if(a=='T') cout << 'A' << endl;
	if(a=='C') cout << 'G' << endl;
	if(a=='G') cout << 'C' << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
using ll = long long;
ll inf = 100000000007ll;

int main(void)
{
  int n;
  cin >> n;
  vector<deque<ll>> a(n,deque<ll>(n-1));
  for(auto &v:a) for(ll &x:v) cin >> x;
  for(auto &v:a) for(ll &x:v) --x;
  set<ll> s;
  REP(i,n) s.insert(i);
  ll answer = 0;
  while(true) {
    set<ll> news;
    for(auto x:s) {
      if(!a[x].empty() && a[a[x].front()].front() == x) {
        news.insert(x);
        news.insert(a[x].front());
      }
    }
    for(auto x:news) {
      a[x].pop_front();
    }
    if(news.empty()) break;
    s=news;
    ++answer;
  }
  for(auto v:a) {
    if(!v.empty()) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << answer << endl;
  return 0;
}


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

template<typename T> struct WG{
  using P = tuple<int, int, T>;
  int n; T inf = 2000000000000000000;
  vector<bool> negative_loop;
  vector<P> edges;
  vector<T> ans;
  WG(int n_){
    n = n_;
    ans.resize(n, inf);
    negative_loop.resize(n, false);
  }
  void add_edge(int from, int to, T cost){
    P edge = make_tuple(from, to, cost);
    edges.push_back(edge);
  }
  void bellmanford(int start){
    ans[start] = 0;
    for(int i = 0; i < n*2; ++i){
      for(int j = 0; j < edges.size(); ++j){
        int from = get<0>(edges[j]);
        int to = get<1>(edges[j]);
        T cost = get<2>(edges[j]);
        if(ans[from] < inf && ans[to] > ans[from] + cost){
          ans[to] = ans[from] + cost;
          if(i > n-2) negative_loop[to] = true;
        }
        if(negative_loop[from]) negative_loop[to] = true;
      }
    }
  }
};

int main(){
  int n, m; cin >> n >> m;
  WG<long> g(n);
  rep(i, m){
    int a, b; long c; cin >> a >> b >> c; --a; --b;
    g.add_edge(a, b, -1*c);
  }
  g.bellmanford(0);
  if(g.negative_loop[n-1]) cout << "inf\n";
  else cout << g.ans[n-1] * -1<< "\n";
  return 0;
}


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

int main(){
int r, D, x;
cin >> r >> D >> x;
int next_x = x;
for(int i = 0; i < 10; i++){ 
     int ans;

     ans = r * next_x - D;

     cout << ans << endl;
     next_x = ans;
}

}

Measured memory_bytes: 256
s = input()
odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']
b = True
k = 0
for i in range(len(s)):
    k += 1
    if k%2 == 0:
        if s[i] in even:
            continue
        else:
            b = False
            break
    else:
        if s[i] in odd:
            continue
        else:
            b = False
            break

if b:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename key>
using ordered_set = tree<key, null_type, less<key>, rb_tree_tag, tree_order_statistics_node_update>;
#define F first
#define S second
#define T second.first
#define C second.second
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
#define all(v) v.begin(),v.end()
#define OO 0x3f3f3f3fLL
#define INF 0x3f3f3f3f3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef pair<ll,pair<ll,ll>> piii;
const int N = 4e5+5, M= 20, mod = 998244353;
const double EPS = 1e-10;



int main(){
    FIO
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    if(n>=30)cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 3584
package main

import (
    "fmt"
    "sort"
)

func main() {
    var a, b, c, d, e int

    fmt.Scan(&a, &b, &c, &d, &e)

    var s = []int{}
    var sum = 0
    for _, order := range []int{a, b, c, d, e} {
        if order%10 == 0 {
            sum += order
        } else {
            sum += (order/10) * 10

            s = append(s, order%10)
        }
    }

    sort.Ints(s)
    for i, k := range s {
        if i ==0 {
            sum += k
        } else {
            sum += 10
        }
    }

    fmt.Println(sum)
}


Measured memory_bytes: 512