akhauriyash/Code-Regression huggingface dataset:
// HTTF.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define int LL
#define pb emplace_back
#define eb pb

using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 3010;
const int SIZE3 = 330;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;
#define endl "\n" //インタラクティブでは消す
ut N, M, K, L, Q, D, H,W;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;

VI edges[SIZE];
LL vals[SIZE], maps2[SIZE2][SIZE2], answer = zero;
LL maps[SIZE2][SIZE2];
LL DP[SIZE2][SIZE2];
bool finished[SIZE2][SIZE2];
LL A[SIZE2][SIZE2];
string s;
LL sums[SIZE2][SIZE2];
bool finished2[SIZE2][SIZE2];
LL solve2(LL, LL);
LL sum(LL n, LL x) {
	if (x == 0) return 0;
	if (finished2[n][x]) return sums[n][x];
	finished2[n][x]=true;
	return sums[n][x] = (sum(n,x-1) + solve2(n, x))%p;
}
LL sum(LL n, LL a, LL b) {
	if (a > b) return 0;
	return (p+sum(n, b) - sum(n, a - 1))%p;
}
LL solve2(LL n,LL k) {
	if (n == 0) return k==1;
	if (finished[n][k]) return DP[n][k];
	finished[n][k] = true;
	if (s[n-1] == '<') {
		DP[n][k] = sum(n - 1,1, k - 1);
	}
	else {
		DP[n][k] = sum(n - 1, k, n);
	}
//	cout << n << " " << k << " " << DP[n][k] << endl;
	return DP[n][k];
}
LL solve() {
	cin >> N;
	cin >> s;
	s += '<';
	cout << solve2(N,N+1) << endl;
	return 0;
}




//!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!!
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(0);
	solve();
	cin >> N;
	return 0;

}


Measured memory_bytes: 385792
#define scanf_s scanf
#include <string>
#include <stdio.h>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <iostream>
using namespace std;

#define MAX 100
//#define MAX_ 1000
struct Graph
{
	int id, k;
	list<int> node;
	int d = -1;
};
Graph G[MAX];
//int cou = 0;
void Breadth_cou(Graph *g,int cou)
{
	for (auto i = g->node.begin(); i != g->node.end(); ++i) {
		if (G[*i].d == -1 || G[*i].d > cou) {
			if (G[*i].d != -1) {
				Breadth_cou(&G[*i], cou + 1);
			}
			G[*i].d = cou;
		}
	}
}
void Breadth(Graph *g)
{
	if (g->k > 0) {
		Breadth_cou(g, g->d + 1);
		g->k = 0;
		for (auto i = g->node.begin(); i != g->node.end(); ++i) {
			Breadth(&G[*i]);
		}
	}
}
int main(void)
{
	int u, xk, v, n;
	scanf_s("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf_s("%d %d", &u, &xk);
		G[u - 1].id = u - 1;
		G[u - 1].k = xk;
		for (int j = 0; j < xk; ++j) {
			scanf_s("%d", &v);
			G[u - 1].node.push_back(v - 1);
		}
	}
	G[0].d = 0;
	Breadth(&G[0]);
	for (int i = 0; i < n; ++i) {
		printf("%d %d\n", G[i].id + 1, G[i].d);
	}
}

Measured memory_bytes: 3200
fun main() {
    val n = nextIntList().sorted()
    println(
        if (n[0] == 5 && n[1] == 5 && n[2] == 7) {
            "YES"
        } else {
            "NO"
        }
    )
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

fun gcd(x: Int, y: Int): Int {
    fun innerGcd(x: Int, y: Int): Int {
        return if (x % y == 0) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

fun gcd(x: Long, y: Long): Long {
    fun innerGcd(x: Long, y: Long): Long {
        return if (x % y == 0L) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

// classes
class UnionFindTree(val size: Int) {
    private val r = sizedArray(size, -1)
    fun root(x: Int): Int {
        if (r[x] < 0) return x
        return root(r[x])
    }

    fun unite(x: Int, y: Int) {
        var rx = root(x)
        var ry = root(y)
        if (rx == ry) return
        if (r[rx] > r[ry]) {
            rx = ry.also { ry = rx }
        }
        r[rx] += r[ry]
        r[ry] = rx
    }

    fun size(x: Int) = -r[root(x)]

    override fun toString(): String {
        return r.joinToString(separator = ", ")
    }
}

Measured memory_bytes: 38792
n, x, y = map(int, input().split())
li = [0 for i in range(n-1)]
x -= 1
y -= 1
for i in range(n-1):
  for j in range(i+1, n):
    a = min(j-i, abs(x-i)+abs(y-j)+1)
    li[a-1] += 1
for x in li:
  print(x)

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, 
    dy[] = {0, 1, 0, -1};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)


int main() {
    int n, a[105];
    cin >> n;
    REP(i,n){
        cin >> a[i];
    }
    int j=1, cnt = 0;
    while(j<n){
        if(a[j]==a[j-1]){
            cnt++;
            j+=2;
        }
        else{
            j++;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,sz;
    cin >> n >> sz;
    int m=1000*n;
    vector<ll> dp(m+1,(1ll<<60));
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        int w,v;
        cin >> w >> v;
        for(int j=m-v;j>=0;j--) dp[j+v]=min(dp[j+v],dp[j]+w);
    }
    int res=0;
    for(int i=0;i<=m;i++) if(dp[i]<=sz) res=i;
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 1024
using System;

public class AtCoder{
	public static void Main(){
		string[] s;
		s = NextS();
		
		int n, m;
		n = int.Parse(s[0]);
		m = int.Parse(s[1]);
		long a = n;
		long b = m;
		if(a > b){
		    b = n;
		    a = m;
		}
		if(a * b <= 0) Console.WriteLine("Zero");
		else{
		    if(a>0 || (b-a)%2 == 1) Console.WriteLine("Positive");
		    else Console.WriteLine("Negative");
		}
	}

	public static void DebugWL(object x){ System.Diagnostics.Debug.WriteLine(x); }
	public static string[] NextS(){ return Console.ReadLine().Trim().Split(' '); }
}


Measured memory_bytes: 13140
import java.util.*;
import java.math.*;

class Main{
	public static void main(String args[]){
		Scanner s=new Scanner(System.in);
		int a,b,c;
		while(s.hasNext()){
			a=s.nextInt();
			b=s.nextInt();
			c=s.nextInt();
			BigDecimal bd=new BigDecimal(a);
			bd=bd.setScale(c+5);
			bd=bd.divide(new BigDecimal(b),RoundingMode.HALF_DOWN).remainder(new BigDecimal(1));
			int sum=0;
			String str=bd.toPlainString();
			//System.out.println(str);
			for(int i=0;i<c;i++)sum+=str.charAt(2+i)-'0';
			System.out.println(sum);
		}
	}
}

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

int N, V, P;
ll M;

bool solve(int i, vector<ll> &A) {
    ll r = M * (V - P);
    ll x = A[i] + M;
    if (x < A[P - 1]) return false;
    for (int j = P - 1; j < N; j++) {
        if (j == i) continue;
        r -= min(x - A[j], M);
        if (r <= 0) return true;
    }
    return false;
}

int binary_search(int ok, int ng, vector<ll> &A) {
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (solve(mid, A)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    return ok;
}

int solve(vector<ll> &A) {
    int res;
    if (V < P) {
        for (int i = N - 1; i >= P; i--) {
            if (A[i] + M >= A[P - 1]) return i + 1;
        }
        return P;
    } else {
        return binary_search(P - 1, N, A) + 1;
    }
}

int main() {
    cin >> N >> M >> V >> P;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end(), greater<ll>());
    cout << solve(A) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

void mD(char C, int *D) {
  switch (C) {
    int t;
  case 'N':
    t = D[0]; D[0] = D[1]; D[1] = D[5]; D[5] = D[4]; D[4] = t;
    break;
  case 'S':
    t = D[0]; D[0] = D[4]; D[4] = D[5]; D[5] = D[1]; D[1] = t;
    break;
  case 'E':
    t = D[0]; D[0] = D[3]; D[3] = D[5]; D[5] = D[2]; D[2] = t;
    break;
  case 'W':
    t = D[0]; D[0] = D[2]; D[2] = D[5]; D[5] = D[3]; D[3] = t;
    break;
  }
  return;
}

int main(void) {
  int D[6], d;
  char C[101];int c;
  for(d=0;d<6;d++)
    scanf("%d",&D[d]);
  scanf("%s",C);
  for (c=0;c<strlen(C);c++) {
    mD(C[c], D);
  }
  printf("%d\n",D[0]);

  return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
max_priority_queue<tuple<ll, int>> mque;

vector<pair<ll, ll>> AB;
int main()
{

    cin >> N;
    for (int i = 0; i < N; i++)
    {
        ll a, b;
        cin >> a >> b;
        AB.emplace_back(mp(a, b));
        mque.emplace(mt(a + b, i));
    }
    set<int> used;
    bool turn = true;
    ll result = 0;
    while (used.size() < N)
    {
        auto p = mque.top();
        mque.pop();
        ll v;
        int idx;
        tie(v, idx) = p;
        if (used.count(idx) > 0)
        {
            continue;
        }
        if (turn)
        {
            result += AB[idx].first;
        }
        else
        {
            result -= AB[idx].second;
        }
        used.insert(idx);
        // cout << result << " " << used.size() << endl;
        turn = !turn;
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 8036
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n, k;
	string s;
	cin >> n >> k >> s;
	
	for(int i = 0; i < s.size(); ++i) {
		
		if( i == k - 1 ) cout << (char)(s[i] - 'A' + 'a');
		else cout << s[i]; 
	}
	
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=1e9+7;
vector<int> G[100005];
int sz[100005],dep[100005],pre[100005];
void dfs(int v,int par,int d){
	sz[v]=1;
	pre[v]=par;
	dep[v]=d;
	rep(k,G[v].size()){
		int u=G[v][k];
		if(u==par)continue;
		dfs(u,v,d+1);
		sz[v]+=sz[u];
	}
}
int main(){
	int n,x,y;
	scanf("%d",&n);
	rep(k,n-1){
		scanf("%d%d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	dfs(1,0,0);
	int cur=n;
	rep(k,(dep[n]-1)>>1)cur=pre[cur];
	if((sz[cur]<<1)>=n)printf("Snuke\n");
	else printf("Fennec\n");
	return 0;
}

Measured memory_bytes: 14720
from bisect import bisect_left

N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
MOD = 10**9 + 7

if len(A) != len(set(A)) or len(B) != len(set(B)):
    print(0)
    exit()

A.sort()
B.sort()
setA = set(A)
setB = set(B)

ans = 1
for i, x in enumerate(range(1, N * M + 1)[:: -1]):
    if x in setA and x in setB:
        continue
    elif x in setA:
        ans *= (M - bisect_left(B, x))
    elif x in setB:
        ans *= (N - bisect_left(A, x))
    else:
        ans *= (M - bisect_left(B, x)) * (N - bisect_left(A, x)) - i
    ans %= MOD

print(ans)

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

using namespace std;

int main() {
	static const int INF = 1e9 + 7;
	int n;
	cin >> n;
	string str1, str2;
	cin >> str1;
	cin >> str2;
	int dp[26] = {};
	dp[str1[0] - 'a']++;
	for (int i = 1; i < n - 1; i++) {
		dp[str1[i] - 'a'] += dp[str2[i] - 'a'];
		dp[str1[i] - 'a'] %= INF;
	}
	cout << dp[str2[n - 1] - 'a'] << "\n";
}


Measured memory_bytes: 3340
import sys
input = sys.stdin.readline
from operator import or_


def read():
    N = int(input().strip())
    S = input().strip()
    Q = int(input().strip())
    return N, S, Q


class SegmentTree():
    
    def __init__(self, size, op=min, init_value=10**8):
        """初期化"""
        self.size = size
        self.op = op
        self.init_value = init_value
        n = 2 ** ((size-1).bit_length())
        treesize = n * 2
        st = [init_value for i in range(treesize)]
        self.st = st

    @classmethod
    def from_array(cls, a, op=min, init_value=10**8):
        st = cls(len(a), op=op, init_value=init_value)
        for i, x in enumerate(a):
            st.update(i, x)
        return st

    def update(self, key, value):
        """値の更新"""
        offset = len(self.st) // 2
        k = offset + key
        self.st[k] = value
        k >>= 1
        while k > 0:
            self.st[k] = self.op(self.st[k * 2], self.st[k * 2 + 1])
            k >>= 1

    def _query_bottomup(self, a, b):
        """区間[a, b) に対する累積操作
        """
        offset = len(self.st) // 2
        a += offset
        b += offset - 1
        s = self.init_value
        while a < b:
            if a & 1 == 1:
                s = self.op(s, self.st[a])
                a += 1
            a >>= 1
            if b & 1 == 0:
                s = self.op(s, self.st[b])
                b -= 1
            b >>= 1
        if a == b:
            s = self.op(s, self.st[a])
        return s

    def _query_topdown(self, a, b, k, l, r):
        """区間[a, b) に対する累積操作
        k: 着目しているノード (1-indexed)
        l: 探索区間 st[l, r) の左端 (0-indexed)
        r: 探索区間 st[l, r) の右端 (0-indexed)
        """
        if r <= a or b <= l:
            return self.init_value
        if a <= l and r <= b:
            return self.st[k]
        mid = (l + r) // 2
        lv = self._query_topdown(a, b, k * 2, l, mid)
        rv = self._query_topdown(a, b, k * 2 + 1, mid, r)
        return self.op(lv, rv)

    def query(self, a, b):
        """区間[a, b) に対する累積操作"""
        if a > b:
            raise ValueError("a must be less than equal b.")
        return self._query_topdown(a, b, k=1, l=0, r=len(self.st)//2)
        # return self._query_bottomup(a, b)


def solve_online(N, S, Q):
    tree = SegmentTree(N, op=or_, init_value=0)
    C = [ord(s) - ord("a") for s in S]
    for i in range(N):
        c = ord(S[i]) - ord("a")
        tree.update(i, 1 << c)

    for _ in range(Q):
        op, a, b = input().strip().split()
        if op == "1":
            i, c = int(a)-1, ord(b) - ord("a")
            tree.update(i, 1 << c)
        elif op == "2":
            l, r = int(a)-1, int(b)-1
            b = tree.query(l, r+1)
            s = 0
            while b > 0:
                if b & 1 == 1:
                    s += 1
                b >>= 1
            print(s)


if __name__ == '__main__':
    inputs = read()
    outputs = solve_online(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 116044
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define pi pair<int, int>
#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const ll inf=0x3f3f3f3f;
const int N=100;
struct edge
{
    int v;
    ll s,t;
    int ne;
}e[N<<1];
int n,m,cnt,head[N];
ll s,dis[N],c[N],d[N],dp[N][3000];

void add(int u,int v,ll w,ll t)
{
    e[++cnt]={v,w,t,head[u]};
    head[u]=cnt;
    e[++cnt]={u,w,t,head[v]};
    head[v]=cnt;
}

void bfs()
{
    if(s>=2500) s=2500;
    dp[1][s]=0;
    for(int up=1;up<=n+2;++up){
        for(int i=1;i<=n;++i){
            for(int j=head[i];j;j=e[j].ne){
                for(int now=0;now<=2500;++now){
                    if(now-e[j].s>=0){
                        dp[i][now-e[j].s]=min(dp[i][now-e[j].s],dp[e[j].v][now]+e[j].t);
                //dp[e[j].v][now-e[j].s]=min(dp[e[j].v][now-e[j].s],dp[i][now]+e[j].t);
                    //dp[e[j].v][now]=min(dp[e[j].v][now],dp[i][now-e[j].s]+e[j].t);
                    }
                }
            }


            for(int now=0;now<=2500;now++){
                if(now-c[i]>=0){
                    dp[i][now]=min(dp[i][now-c[i]]+d[i],dp[i][now]);
                }
            }
        }
    }
}
void solve()
{
   cin>>n>>m>>s;
   //scanf("%d%d%lld",&n,&m,&s);
   mem(dp,inf);
   rep(i,1,m)
   {
       int u,v;ll a,b;
       cin>>u>>v>>a>>b;
       //scanf("%d %d %lld %lld",&u,&v,&a,&b);
       add(u,v,a,b);
   }
   rep(i,1,n) cin>>c[i]>>d[i];
   bfs();
   for(int i=2;i<=n;++i){
        ll ans=1e18;
        for(int now=0;now<=2500;++now) ans=min(ans,dp[i][now]);
        printf("%lld\n",ans);
   }
}
int main()
{
	solve();
}


Measured memory_bytes: 6132
from bisect import bisect
from operator import itemgetter

n, a, b = map(int, input().split())
ppp = map(int, input().split())
qqq = map(itemgetter(0), sorted(enumerate(ppp, start=1), key=itemgetter(1)))

dp = [(0, 0)]
for i in qqq:
    s = bisect(dp, (i,))
    ndp = [(j, cost + b) for j, cost in dp[:s]]
    stay_cost = dp[s - 1][1]
    ndp.append((i, stay_cost))
    remain = iter(dp[s:])
    for j, cost in remain:
        if stay_cost > cost + a:
            ndp.append((j, cost + a))
            break
    ndp.extend((j, cost + a) for j, cost in remain)
    dp = ndp
print(dp[-1][1])


Measured memory_bytes: 4852
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string str;//="abcdefgh";
    cin>>n>>str;
    if(str.size()&1)
    {
        cout<<"No"<<endl;
        return 0;
    }
    int ll=str.size()/2;
    //cout<<str.substr(0,ll)<<" "<<str.substr(ll,ll)<<endl;
    if(str.substr(0,ll)==str.substr(ll,ll))
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


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

int main() {
    int n;
    int a[2][100];
    int dp[101] = {0};
    int tmp = 0;
    int ans = 0;
    
    cin >> n;
    
    rep(i, 2) {
        rep (ii, n) {
            cin >> a[i][ii];
        }
    }
    
    for (int i = (n - 1); i >= 0; i--) {
        dp[i] = dp[i + 1] + a[1][i];
    }
    
    rep(i, n) {
        tmp += a[0][i];
        ans = max(ans, tmp + dp[i]);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ff(i, x, y) for(int i=x; i<=y; i++)
#define fs(i, x, y) for(int i=x; i>=y; i--)
using namespace std;
typedef long long ll;
int vis[200010];
int main() {
    int n;
    scanf("%d", &n);
    int mx = 0;
    ff(i, 1, n) {
        int now;
        scanf("%d", &now);
        vis[now] = vis[now-1] + 1;
        mx = max(mx, vis[now]);
    }
    int ans = n - mx;
    printf("%d", ans);
    return 0;
}


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

int main() {
  int n;
  cin >>n;
  
  int count =0;
  for(int i=n; i>0;i--){
    string s = to_string(i);
    if(s.size()==1  || s.size()==3 || s.size() ==5 ) count++;
  }
  
  cout << count <<endl;
}


Measured memory_bytes: 256
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    string s;
    cin>>s;
    int x=s.size();
    for(int i=0;i<x;i++)cout << 'x';
    cout << endl;
    return 0;
}
///Alhamdulillah


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

using namespace std;

typedef long long int64;

int main()
{
  int N;
  scanf("%d", &N);

  unordered_map< int64, int > dp;
  dp[0] = -1;
  int64 now = 0;
  int ret = 0;
  for(int i = 0; i < N; i++) {
    int D;
    scanf("%d", &D);
    now += D;
    if(dp.count(now)) ret = max(ret, i - dp[now]);
    else dp[now] = i;
  }
  printf("%d\n", ret);
}

Measured memory_bytes: 10964
#include<iostream>
#include<vector>
//#include <boost/multi_array.hpp>
using namespace std;

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

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

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

const long long INF = 1LL << 60;

const int SIZE = 100010;

ll dp[SIZE][3];
ll h[SIZE][3];

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

    rep(i, n) {
        rep(j, 3) {
            cin >> h[i][j];
        }
    }

    rep(i, n) {
        rep(j, 3) {
            rep (k, 3) {
                if (j != k) {
                    chmax(dp[i + 1][k], dp[i][j] + h[i][k]);
                }
            }
        }
    }

    ll res = 0;
    rep(j, 3) {
        chmax(res, dp[n][j]);
    }   
    cout << res << endl;

    return 0;
}

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

int rnk[26],par[26];

void init(int n){
	for(int i = 0;i < n;i++){
		rnk[i] = 0;
		par[i] = i;
	}
}

int find(int x){
	if(par[x] == x) return x;
	return par[x] = find(par[x]);
}

void unite(int x,int y){
	x = find(x);
	y = find(y);
	if(x == y) return;
	if(rnk[x] < rnk[y]) par[x] = y;
	else {
		par[y] = x;
		if(rnk[x] == rnk[y]) rnk[x]++;
	}
}

int main(){
	int n;
	while(cin >> n,n){
		int in[26] = {},out[26] = {},num;
		init(26);
		for(int i = 0;i < n;i++){
			string s;
			cin >> s;
			in[s[0] - 'a']++;
			out[s[s.length() - 1] - 'a']++;
			unite(s[0] - 'a',s[s.length() - 1] - 'a');
		}
		for(int i = 0;i < 26;i++){
			if(in[i] || out[i]) num = find(i);
		}
		bool flag = true;
		for(int i = 0;i < 26;i++){
			if(in[i] && num != find(i)) flag = false;
			if(in[i] != out[i]) flag = false;
		}
		if(!flag) cout << "NG" << endl;
		else cout << "OK" << endl;
	}
	return 0;
}

Measured memory_bytes: 3140
N, A, B = [int(x) for x in input().split(' ')]
absdist = abs(A - B)
maxdist1 = max(A-1, B-1)
maxdistN = max(N-A, N-B)

if absdist % 2 == 1:
    edgedist = min(A-1, B-1, N-A, N-B)
    returndist = (absdist + 1) // 2 + edgedist
    print(min(maxdist1, maxdistN, returndist))
else:    
    print(absdist // 2)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    string T;
    cin >> S >> T ;
    char a=S.size();
    char b=T.at(a);
    if(S+b==T)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout<<endl
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vpii vector<pair<int,int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string> 
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; }
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }

int h, w;
vs maze;
vvi dist;
int inf = 1001000;
int dy[4] = { 0,-1,0,1 };
int dx[4] = { 1,0,-1,0 };

queue<int> que_x;
queue<int> que_y;

void bfs(int y, int x)
{
	rep(i, 4)
	{
		int ny = y + dy[i];
		int nx = x + dx[i];
		if (0 <= ny && ny < h && 0 <= nx && nx < w
			&& maze[ny][nx] == '.' && dist[ny][nx]>dist[y][x] + 1)
		{
			dist[ny][nx] = dist[y][x] + 1;
			que_y.push(ny);
			que_x.push(nx);
		}
	}
}

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

	cin >> h >> w;
	maze = vs(h);
	rep(i, h)cin >> maze[i];
	dist = vvi(h, vi(w, inf));
	int ans = 0;
	rep(i, h)rep(j, w)
	{
		if (maze[i][j] == '#')continue;
		dist[i][j] = 0;
		que_y.push(i);
		que_x.push(j);
		while (!que_y.empty())
		{
			int y_now = que_y.front(); que_y.pop();
			int x_now = que_x.front(); que_x.pop();
			bfs(y_now, x_now);
		}
		int tmp = 0;
		rep(i, h)rep(j, w)
		{
			if (dist[i][j] < inf)chmax(tmp, dist[i][j]);
		}
		chmax(ans, tmp);

		dist = vvi(h, vi(w, inf));
	}
	co(ans);
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#define N 5005
#define inf 0x3f3f3f3f3f3f3f3fll
inline long long min(long long x,long long y){return x<y?x:y;}
inline long long max(long long x,long long y){return x<y?y:x;}
int a[N],b[N],i,j,n,o,p;long long f[2][N],x;
int main()
{
	scanf("%d%d%d",&n,&o,&p),x=f[1][0]=inf;
	for(i=1;i<=n;i++)scanf("%d",a+i),f[0][b[a[i]]=i]=f[1][i]=inf;
	for(i=1;i<=n;i++)for(j=0;j<=n;f[i&1^1][j++]=inf)
	if(a[i]>j)f[i&1][a[i]]=min(f[i&1][a[i]],f[i&1^1][j]),f[i&1][j]=min(f[i&1][j],f[i&1^1][j]+o);
	else f[i&1][j]=min(f[i&1][j],f[i&1^1][j]+p);
	for(i=0;i<=n;i++)x=min(x,f[n&1][i]);
	return 0*printf("%lld\n",x);
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    
    HashMap<String, Integer> m = new HashMap<String, Integer>(7);
    m.put("SUN", 7);
    m.put("MON", 6);
    m.put("TUE", 5);
    m.put("WED", 4);
    m.put("THU", 3);
    m.put("FRI", 2);
    m.put("SAT", 1);

    System.out.println(m.get(S));
  }
}

Measured memory_bytes: 21844
// スタックサイズ: 100MB

#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1e18;
const double EPS = 1e-10;
const ll mod = 1e9 + 7;
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }




int main() {
	fastio;

	ll N;
	cin >> N;
	vll W(N);
	rep(i, N) cin >> W[i];

	ll ans = INF;
	rep(i, N) {
		ll tmp = abs(accumulate(W.begin(), W.begin() + i, 0) - accumulate(W.begin() + i, W.end(), 0));
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
/*************************************************************************
  >         File: C.cc
  >       Author: lyyllyyl
  >         Mail: riho.yoshioka@yandex.com
  > Created Time: Sat 15 Oct 2016 08:29:45 PM CST
*************************************************************************/
#include <bits/stdc++.h>
using LL = long long;
constexpr int N = 444;
std::vector<int> color[N];
std::map<std::vector<int>, int> has;
int corner[8];
int use[4][4] = {
  {0, 3, 6, 5},
  {0, 5, 4, 1},
  {1, 4, 7, 2},
  {2, 7, 6, 3}
};

void Add(std::vector<int> color) {
  for (int i = 0; i < 4; ++i) {
    has[color]++;
    std::rotate(color.begin(), color.begin() + 1, color.end());
  }
}

void Hide(std::vector<int> color) {
  for (int i = 0; i < 4; ++i) {
    has[color]--;
    std::rotate(color.begin(), color.begin() + 1, color.end());
  }
}

void Dfs(int dep, LL& ans, LL res = 1) {
  if (dep == 4) ans += res;
  else {
    std::vector<int> tmp(4);
    for (int i = 0; i < 4; ++i) tmp[i] = corner[use[dep][i]];
    if (has.count(tmp)) {
      int cnt = has[tmp];
      Hide(tmp);
      Dfs(dep + 1, ans, res * cnt);
      Add(tmp);
    }
  }
}

LL solve(int a, int b) {
  for (int i = 0; i < 4; ++i) {
    corner[i] = color[a][i];
    corner[i + 4] = color[b][i];
  }
  LL ans = 0;
  for (int i = 0; i < 4; ++i) {
    Dfs(0, ans);
    std::rotate(corner + 4, corner + 5, corner + 8);
  }
  return ans;
}

int main() {
  std::ios::sync_with_stdio(0);
#ifdef HOME
  std::string file(__FILE__);
  freopen((file.substr(0, file.find('.')) + ".in").c_str(), "r", stdin);
#endif
  int n;
  std::cin >> n;
  for (int i = 0; i < n; ++i) {
    color[i].resize(4);
    for (int j = 0; j < 4; ++j) {
      std::cin >> color[i][j];
    }
    Add(color[i]);
  }
  LL answer = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      Hide(color[i]), Hide(color[j]);
      answer += solve(i, j);
      Add(color[i]), Add(color[j]);
      //std::cerr << "# i << ' ' << j << ' ' << answer # is " << i << ' ' << j << ' ' << answer << std::endl;
    }
    Hide(color[i]);
  }
  std::cout << answer << std::endl;
  std::cerr << "---------------------------" << std::endl;
  std::cerr << "Time used: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec." << std::endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;

const double pi = acos(-1);

int io(int x){
  int a=1;
  for(int i=0;i<x;i++){
    a*=10;
  }
  return a;
}

int main(){
  int N;
  cin>>N;
  if(N%1000==0){cout<<0<<endl;return 0;}
  cout<<1000-N%1000<<endl;
}
  


Measured memory_bytes: 3548
import math

class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y
    def __add__(self, other):
        return Point(self.x + other.x, self.y + other.y)
    def __sub__(self, other):
        return Point(self.x - other.x, self.y - other.y)
    def __mul__(self, other):
        return Point(self.x * other, self.y * other)
    def __floordiv__(self, other):
        return Point(self.x / other, self.y / other)
    def __repr__(self):
        return str(self.x) + ' ' + str(self.y)

class Vector(Point):
    pass

class Line:
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2

class Segment(Line):
    pass

def points_to_vector(p1, p2):
    x = p1.x - p2.x
    y = p1.y - p2.y
    return Vector(x, y)

def vector(p):
    return Vector(p.x, p.y)

def dot(v1, v2):
    return v1.x * v2.x + v1.y * v2.y

def cross(v1, v2):
    return v1.x * v2.y - v1.y * v2.x

def norm(v):
    return v.x**2 + v.y**2

def distance(v):
    return math.sqrt(norm(v))

def project(s, p):
    base = points_to_vector(s.p1, s.p2)
    hypo = points_to_vector(p, s.p1)
    r = dot(hypo, base) / norm(base)
    return s.p1 + base * r

def reflect(s, p):
    return p + (project(s, p) -p) * 2

# def get_distance(s1, s2):
#     #TODO: Define intersect()
#     if insersect(s1, s2):
#         return 0
#     d1 = get_distance_sp(s1, s2.p1)
#     d2 = get_distance_sp(s1, s2.p2)
#     d3 = get_distance_sp(s2, s1.p1)
#     d4 = get_distance_sp(s2, s1.p2)
#     return min(d1, min(d2, min(d3, d4)))

def get_distance_pp(p1, p2):
    return distance(p1 - p2)

def get_distance_lp(l, p):
    return distance(cross(l.p2 - l.p1, p - l.p1)) / distance(l.p2 - l.p1)

def get_distance_sp(s, p):
    if dot(s.p2 - s.p1, p - s.p1) < 0:
        return distance(p - s.p1)
    elif dot(s.p1 - s.p2, p - s.p2) < 0:
        return distance(p - s.p2)
    else:
        return get_distance_lp(s, p)

def ccw(p0, p1, p2):
    EPS = 1e-10
    COUNTER_CLOCKWISE = 1
    CLOCKWISE = -1
    ONLINE_BACK = 2
    ONLINE_FRONT = -2
    ON_SEGMENT = 0
    v1 = p1 - p0
    v2 = p2 - p0
    if cross(v1, v2) > EPS:
        return COUNTER_CLOCKWISE
    elif cross(v1, v2) < -EPS:
        return CLOCKWISE
    elif dot(v1, v2) < -EPS:
        return ONLINE_BACK
    elif norm(v1) < norm(v2):
        return ONLINE_FRONT
    else:
        return ON_SEGMENT

def intersect_p(p1, p2, p3, p4):
    return ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 and ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0

def intersect_s(s1, s2):
    return intersect_p(s1.p1, s1.p2, s2.p1, s2.p2)


import sys
# sys.stdin = open('input.txt')

q = int(input())
for i in range(q):
    temp = list(map(int, input().split()))
    points = []
    for j in range(0, 8, 2):
        points.append(Point(temp[j], temp[j+1]))
    s1 = Segment(points[0], points[1])
    s2 = Segment(points[2], points[3])
    if intersect_s(s1, s2):
        print(1)
    else:
        print(0)


Measured memory_bytes: 5744
import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int a = sc.nextInt();
        String op = sc.next();
        int b = sc.nextInt();
        if (op.equals("+")) {
            System.out.println(a+b);
        } else {
            System.out.println(a-b);
        }
    }
}


Measured memory_bytes: 9044
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

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

		int c1 = sc.nextInt();
		int c2= sc.nextInt();
		int c3 = sc.nextInt();
		int c4 = sc.nextInt();
		int c5 = sc.nextInt();
		int c6 = sc.nextInt();
		int c7 = sc.nextInt();
		int c8 = sc.nextInt();
		int c9 = sc.nextInt();

		int flag = 0;

		ArrayList<Integer> Aarray = new ArrayList<Integer>();
		for (int i = 0; i < 3; i++) {
			Aarray.add(0);
		}
		ArrayList<Integer> Barray = new ArrayList<Integer>();
		for (int i = 0; i < 3; i++) {
			Barray.add(0);
		}

		loop: for (int i = 0; i < 100; i++) {
			Aarray.set(0, i);
			Barray.set(0, c1 - Aarray.get(0));
			Barray.set(1, c2 - Aarray.get(0));
			Barray.set(2, c3 - Aarray.get(0));

			for (int j = 0; j < 2; j++) {
				Aarray.set(1, c4 - Barray.get(j));

				for (int k = 0; k < 2; k ++) {
					Aarray.set(2, c7 - Barray.get(k));

					if (Aarray.get(1) + Barray.get(1) == c5
							&& Aarray.get(1) + Barray.get(2) == c6
							&& Aarray.get(2) + Barray.get(1) == c8
							&& Aarray.get(2) + Barray.get(2) == c9) {

						flag ++;
						break loop;
					}
				}
			}

		}
		if (flag == 1) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 23892
//21
#include<cstdio>
#include<algorithm>
using namespace std;

const int maxn = 100001;

int n;
int a[maxn], b[maxn];
pair<int, int> ord1[maxn], ord2[maxn];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d%d", &a[i], &b[i]);
	}
	for (int i = 1; i <= n; i++) {
		ord1[i] = make_pair(min(a[i], b[i]), i);
		ord2[i] = make_pair(max(a[i], b[i]), i);
	}
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += min(a[i], b[i]);
	}
	sort(ord1 + 1, ord1 + 1 + n);
	sort(ord2 + 1, ord2 + 1 + n);
	int x = 0;
	for (int i = 1; i <= n; i++) {
		if (ord1[n - i + 1].second == ord2[i].second || ord1[n - i + 1].first < ord2[i].first) break;
		x++;
		ans += ord2[i].first - ord1[n - i + 1].first;
	}
	if (!x) {
		long long suma = 0;
		long long sumb = 0;
		for (int i = 1; i <= n; i++) {
			suma += a[i];
			sumb += b[i];
		}
		long long cur = ans;
		ans = min(sumb, suma);
		for (int i = 1; i <= n; i++) {
			if (ord1[i].second != ord2[1].second) ans = min(ans, cur + ord2[1].first - ord1[i].first);
			if (ord2[i].second != ord1[n].second) ans = min(ans, cur + ord2[i].first - ord1[n].first);
		}
	}
	printf("%lld", ans);
	return 0;
}

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

int main(){
	int a ; cin >> a ;
	a %= 7 ;
	if(a==0) cout << "thu" << endl ;
	if(a==1) cout << "fri" << endl ;
	if(a==2) cout << "sat" << endl ;
	if(a==3) cout << "sun" << endl ;
	if(a==4) cout << "mon" << endl ;
	if(a==5) cout << "tue" << endl ;
	if(a==6) cout << "wed" << endl ;
}


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

#define rep(i,a,b) for (int i = (a); i < (b); i++ )

int main() {
    int a, s, d, f;
    cin >> a >> s >> d >> f;

    int ans;
    ans = min(a, f) - max(f - a - s, 0);
    cout << ans << endl;






}


Measured memory_bytes: 3644
n, a, b = gets.strip.split.map(&:to_i)
result = 0
 
(1..n).each do |i|
  j = i
  sum = 0
  while j > 0
    sum += j % 10
    j = j / 10
  end
  if sum >= a && sum <= b
    result += i
  end
end
 
puts result

Measured memory_bytes: 1788
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  cout << (x - z) / (y + z) << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#define N 105
#define fi(a, b, c) for(int a = (b); a < (c); a++)
#define FI(a, b, c) for(int a = (b); a <= (c); a++)
using namespace std;

int n, a[N], ans, tot;

int main(){
	scanf("%d", &n);
	fi(i, 0, n) scanf("%d", &a[i]); 
	
	tot = ans = 1;
	fi(i, 0, n){
		ans *= 3;
		if(a[i] & 1) tot *= 1;
		else tot *= 2;
	}
	
	printf("%d\n", ans - tot); 
}

Measured memory_bytes: 128
#include <iostream>
#include <climits>
#include <cmath>
#define MAX_N 200
using namespace std;
int main(void){
    int n;
    int ans = INT_MAX;
    cin >> n;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        int cnt = 0;
        while(a % 2 == 0){
            a /= 2;
            cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long lld;
#define MX 111111

vector<lld > gr[MX];
lld Babu[MX];
lld Band[MX];

void dfs(lld s,lld dis,lld level[],lld par=-1){
	
	level[s]=dis;
	for(lld i=0;i<gr[s].size();i++){
		lld to=gr[s][i];
		if(to!=par){
			dfs(to,dis+1,level,s);
		}
	}
}

int main(){
	
	lld n;
	cin>>n;
	
	for(lld i=0;i<n-1;i++){
		lld a,b;
		cin>>a>>b;
		gr[a].push_back(b);
		gr[b].push_back(a);
	}
	dfs(1,0,Babu);
	dfs(n,0,Band);
	lld ans=0;
	for(lld i=1;i<=n;i++){
		if(Babu[i]<=Band[i]){
			ans++;
		}
		else{
			ans--;
		}
	}
	cout<<(ans>0?"Fennec\n":"Snuke\n");
}

Measured memory_bytes: 15360
n = gets.to_i
s = gets.chomp

result = s.count("R") * s.count("G") * s.count("B")

n.times do |i|
  j = i + 1
  while j < n
    k = 2 * j - i
    if j < k && k < n && s[i] != s[j] && s[j] != s[k] && s[k] != s[i]
      result -= 1
    end
    j += 1
  end
end

puts result

Measured memory_bytes: 14320
/*     ####   ####  #               ####  #        ##   #    # #    # ###### #####
      #      #    # #              #      #       #  #  ##  ## ##  ## #      #    #
       ####  #    # #               ####  #      #    # # ## # # ## # #####  #    #
           # #  # # #                   # #      ###### #    # #    # #      #####
      #    # #   #  #              #    # #      #    # #    # #    # #      #   #
       ####   ### # ###### #######  ####  ###### #    # #    # #    # ###### #    #
*/
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef vector<long long> VLL;
typedef vector<string> VS;
typedef vector<pair<LL, LL> > VP;
 
 
#define For(in) for (LLi i = 0; i < (n); i++)
#define FOR(in) for(LLi i=1; i <= (n); i++)
#define pb push_back
#define sr(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define uniq(v) v.erase(unique(v.begin(), v.end()), v.end());
#define exit(); return 0;
#define no "NO"
#define yes "YES"
#define con continue;
 

 
 
int main()
{
	
	char c;
	cin>>c;
	if(c=='a' || c=='e' || c=='i' || c=='o' || c== 'u')
	cout<<"vowel"<<endl;
	else cout<<"consonant"<<endl;
			
			
			
			
    exit()
 
 
}


Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

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

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

ll INF = 1000000000000000000;

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

  vector<ll> as;

  rep(i, n) {
    ll tmp; cin >> tmp;
    as.emplace_back(tmp);
  }

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

  ll prod = 1;
  for (auto a : as) {
    __int128 res = ((__int128)prod) * ((__int128)a);

    if (res > INF) {
      cout << -1 << endl;
      return 0;
    }

    prod = (ll)res;
  }

  cout << prod << endl;

  return 0;
}

Measured memory_bytes: 3848
#include<stdio.h>

int main(){
    int i, a[10], temp;
    int first=0, second=0, third=0;

    for(i=0; i<10; i++) {
        scanf("%d", &a[i]);
        if(first < a[i]) {
              third=second;
              second=first;
              first=a[i];
        } else if(second < a[i]) {
              third=second;
              second=a[i];
        } else if(third < a[i]) {
              third=a[i];
        }
    }
    printf("%d\n%d\n%d\n", first, second, third);

    return 0;
}

Measured memory_bytes: 600