akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<int> Takoyaki(n);
  rep(i, n) cin >> Takoyaki[i];

  llong ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j < n; ++j) {
      ans += Takoyaki[i]*Takoyaki[j];
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	char c;
	while (cin.get(c)){
		if      (c == 'a'){
			c = 'A';
		}
		else if (c == 'b') {
			c = 'B';
		}
		else if (c == 'c') {
			c = 'C';
		}
		else if (c == 'd') {
			c = 'D';
		}
		else if (c == 'e') {
			c = 'E';
		}
		else if (c == 'f') {
			c = 'F';
		}
		else if (c == 'g') {
			c = 'G';
		}
		else if (c == 'h') {
			c = 'H';
		}
		else if (c == 'i') {
			c = 'I';
		}
		else if (c == 'j') {
			c = 'J';
		}
		else if (c == 'k') {
			c = 'K';
		}
		else if (c == 'l') {
			c = 'L';
		}
		else if (c == 'm') {
			c = 'M';
		}
		else if (c == 'n') {
			c = 'N';
		}
		else if (c == 'o') {
			c = 'O';
		}
		else if (c == 'p') {
			c = 'P';
		}
		else if (c == 'q') {
			c = 'Q';
		}
		else if (c == 'r') {
			c = 'R';
		}
		else if (c == 's') {
			c = 'S';
		}
		else if (c == 't') {
			c = 'T';
		}
		else if (c == 'u') {
			c = 'U';
		}
		else if (c == 'v') {
			c = 'V';
		}
		else if (c == 'w') {
			c = 'W';
		}
		else if (c == 'x') {
			c = 'X';
		}
		else if (c == 'y') {
			c = 'Y';
		}
		else if (c == 'z') {
			c = 'Z';
		}
		cout.put(c);
	}
}

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

namespace ABC087A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, a, b, c;

            x = int.Parse(Console.ReadLine());
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());

            c = (x - a) % b;

            Console.WriteLine(c);

            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	int a,b;
 cin >> a >> b;
 for(int i = 0;i <= a;i++){
   for(int j = 0;j <= a - i;j++){
     if(i * 2 + j * 4 == b && i + j == a){
       cout << "Yes" << endl;
       return 0;
     }
   }
 }
   cout << "No" << endl;
    
 
return 0;
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define R 10000
#define G 10001
#define B 10002

int main()
{
    lol r{0}, g{0}, b{0};
    lol result{0};
    lol n; cin >> n;
    vector<int> a(n+2, 0);
    a[0] = -1;
    a[n+1] = -1;
    FOR(i, 1, n)
    {
        char ch; cin >> ch;
        if(ch == 'R')
        {
            //cout << "r=" << r << endl;
            r++;
            a[i] = 1;
        }
        else if(ch == 'G')
        {
            //cout << "g=" << g << endl;
            g++;
            a[i] = 2;
        }
        else
        {
            b++;
            a[i] = 3;
        }
        
    }
    result = r*g*b;
    FOR(i, 1, n)
    {
        lol j = 1;
        while(a[i-j] != -1 && a[i+j] != -1)
        {
            //cout << a[2] << endl << a[3] << endl << a[4] << endl;
            if((a[i-j] != a[i+j]) && (a[i-j] != a[i]) && (a[i+j] != a[i]))
                result--;
            j++;
        }
    }
    

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

int main(){
    int N; cin >> N;
    long long a[100010],b[100010],ans = 0;
    for (int i = 0; i < N+1; i++) cin >> a[i];
    for (int i = 0; i < N; i++) cin >> b[i];
    for (int i = 0; i < N; i++){
        if (b[i] >= a[i]+a[i+1]){
            ans += a[i] + a[i+1];
            a[i] = 0;
            a[i+1] = 0;
        } else if (b[i] <= a[i]){
            a[i] -= b[i];
            ans += b[i];
        } else {
            ans += b[i];
            b[i] -= a[i];
            a[i+1] -= b[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
//*************************************************************************
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
#include<regex>

#include<map>
using namespace std;

int main(){
	map<int,int> m;
	int n;
	cin>>n;
	for (int i=0;i<n;i++){
		int k;
		cin>>k;
		if (m[k]) m[k]=0;
		else m[k]=1;
	}
	int ans=0;
	for (auto i=m.begin();i!=m.end();i++){
		if (i->second==1) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
using ll = long long;

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
	#define lcout(a) cout << a;
	#define lcoutln(a) cout << a << endl;
	#define lcerr(a) cerr << a;
	#define lcerrln(a) cerr << a << endl;
#else
	#define lcout(a) 
	#define lcoutln(a) 
	#define lcerr(a) 
	#define lcerrln(a) 
#endif

int main()
{
	CIN(int, a);
	CIN(int, b);
	a--;
	b--;
	cout << a*b << endl;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
s=sum(b)
for i in range(n-1):
  if a[i]+1==a[i+1]:
    s+=c[a[i]-1]
print(s)

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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a + b >  c + d) cout << "Left" << endl;
    if(a + b == c + d) cout << "Balanced" << endl;
    if(a + b <  c + d) cout << "Right" << endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Monad

solve :: Int -> Int -> [Int] -> Int
solve n m xs = sum xs - xs!!(n-1) + m

main = do
  _ <- getLine
  xs <- map (read::String->Int) . words <$> getLine
  n <- read <$> getLine
  replicateM n $ do 
    [p, x] <- map (read::String->Int) . words <$> getLine
    putStrLn . show $ solve p x xs

Measured memory_bytes: 1148
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <map>
#include <set>
using namespace std;

int main()
{
	int32_t N, M;
	cin >> N >> M;

	vector<int32_t> a(N), b(N);
	for (int32_t i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
	}

	vector<int32_t> c(M), d(M);
	for (int32_t i = 0; i < M; i++) {
		cin >> c[i] >> d[i];
	}

	for (int32_t i = 0; i < N; i++) {
		int32_t min_dist = numeric_limits<int32_t>::max();
		int32_t min_index = -1;
		for (int32_t j = 0; j < M; j++) {
			int32_t dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (min_dist > dist) {
				min_dist = dist;
				min_index = j;
			}
		}
		cout << min_index + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
def kaijo(n):
    k=1
    for i in range(n):
        k*=i+1
    return k
def yaku(n):
    b=2
    l=[]
    while n>1:
        while n%b==0:
            l.append(b)
            n//=b
        b+=1
    ls=set(l)
    ans=[(i,l.count(i)) for i in ls]
    return ans
            

def resolve():
    n=int(input())
    l=yaku(kaijo(n))
    s=1
    for i in l:
        s*=i[1]+1
    print(s%(10**9+7))

resolve()

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

using namespace std;
#define inf 0x3f3f3f3f3f3f3f3f
#define FASTIO cin.sync_with_stdio (0); cin.tie (0); cin.exceptions (cin.failbit); cout.tie(0);
typedef vector<int> vi;
typedef long long ll;
main(){
    FASTIO;
    ll N, W;
    cin >> N >> W;
    vector<ll> dp(123456, inf);
    for (ll i = 0; i < N; ++i){
        ll w, v;
        cin >> w >> v;
        if (i == 0) dp[v] = w;
        else{
        for (ll valor = 123456 - v - 1; valor >= 0; valor--){
            dp[valor + v] = min(dp[valor + v], w + dp[valor]);
        }
        dp[v] = min(dp[v], (ll)w);
        }
    }
    for (ll i = 123455; i > -1; --i){
        if (dp[i] <= W){
            cout << i << '\n';
            return 0;
        }
    }
}

Measured memory_bytes: 1280
from sys import stdin
from collections import defaultdict

N = int(stdin.readline().rstrip())
S = [stdin.readline().rstrip() for i in range(N)]

D = defaultdict(int)

for s in S:
    D[s] += 1

ans = sorted(D.items(), key=lambda x: (-x[1], x[0]))

for a in ans:
    if a[1] < ans[0][1]:
        break
    print(a[0])



Measured memory_bytes: 109236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
const ll md = 1000000007;

ll add(ll a, ll b, ll mod = md) {
    return (a%mod + b%mod + mod)%mod;
}

ll mul(ll a, ll b, ll mod = md) {
    return (a%mod * b%mod + mod)%mod;
}

ll power(ll x, ll n, ll mod = md) {
    ll res = 1;
    x %= mod;
    while (n) {
        if (n & 1)  res = (res*x)%mod;
        n = n/2;
        x = (x*x)%mod;
    }
    return res;
}

ll power2(ll x, ll n) {
    ll res = 1;
    while (n) {  
        if (n & 1) res = (res*x);
        n = n/2;
        x = (x*x);
    }  
    return res;
}

ll lg(ll k, ll e) {
	ll i, x = k;
	for(i = 0; ; i++, x = x*k) {
		if(x > e) {
			break;
		}
	}
	return i;
}

ll dp[200][200][2];

ll fn(int n, int k, string s, int pos, int num, int tight) {
	if (pos == n) {
		if(num == k) {
			return 1;
		} else {
			return 0;
		}
	} else if (dp[pos][num][tight] != -1) {
		return dp[pos][num][tight];
	}
	if (tight == 1) {
		ll res = 0;
		for(int i = 0; i <= s[pos] - '0'; i++) {
			if(i == s[pos] - '0') {
				if(i == 0) {
					res = (res + fn(n, k, s, pos+1, num, 1))%md;
				} else {
					res = (res + fn(n, k, s, pos+1, num+1, 1))%md;
				}
			} else {
				if(i != 0) {
					res = (res + fn(n, k, s, pos+1, num+1, 0))%md;
				} else {
					res = (res + fn(n, k, s, pos+1, num, 0))%md;
				}
			}
		}
		dp[pos][num][tight] = res;
		return res;
	} else {
		ll res = 0;
		for(int i = 0; i <= 9; i++) {
			if(i != 0) {
				res = (res + fn(n, k, s, pos+1, num+1, 0))%md;
			} else {
				res = (res + fn(n, k, s, pos+1, num, 0))%md;
			}
		}
		dp[pos][num][tight] = res;
		return res;
	}
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // 	freopen("input.txt", "r", stdin);
    // #endif

    // ll a, r, m, x, l, cnt = 0;
    // cin >> a >> r >> l >> m;
    // bool inf = false;
    // if(abs(r) > 1) {
    // 	cnt = lg(abs(r), l/abs(a)) + 1;
    // } else {
    // 	inf = true;
    // }
    // for(int i = 0; i < m; i++) {
    // 	cin >> x;
    // 	if(inf && x == a) {
    // 		inf = false;
    // 		break;
    // 	} else if(!inf) {
    // 		ll ind = lg(r, x/a);
	   //  	if(abs(x) <= l && a*power2(r, ind) == x) {
	   //  		cnt--;
	   //  	}
    // 	}
    // }
    // if(inf) {
    // 	cout << "inf\n";
    // } else {
    // 	cout << cnt << "\n";
    // }
    ll a, b;
    cin >> a >> b;
    cout << a*b << "\n";
    return 0;
}

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

using namespace std;

const int MOD = 1e9 + 7, maxn = 1e5 + 500;
int a[maxn], cnt[maxn];

int main(){
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        cnt[a[i]] ++;
    }
    if (n % 2 == 0){
        for (int i = 1; i < n; i += 2){
            if (cnt[i] != 2){
                cout << 0 << endl;
                return 0;
            }
        }
        for (int i = 0; i < n; i += 2){
            if (cnt[i] > 0){
                cout << 0 << endl;
                return 0;
            }
        }
        long long k = 1;
        for (int i = 1; i <= n / 2; i++){
            k *= 2;
            k %= MOD;
        }
        cout << k << endl;
        return 0;
    }
    else {
        if (cnt[0] != 1){
            cout << 0 << endl;
            return 0;
        }
        for (int i = 2; i < n; i += 2){
            if (cnt[i] != 2){
                cout << 0 << endl;
                return 0;
            }
        }
        for (int i = 1; i < n; i += 2){
            if (cnt[i] > 0){
                cout << 0 << endl;
                return 0;
            }
        }
        long long k = 1;
        for (int i = 1; i <= n / 2; i++){
            k *= 2;
            k %= MOD;
        }
        cout << k << endl;
        return 0;
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

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

  vector<ll> a(3);  
  rep(i, 0, 3) cin >> a[i];
  sort(all(a));
  
  ll x = (a[2]-a[1]) + (a[2]-a[0]);
  
  if(x%2==0)
    cout << x/2 << "\n";
  else
    cout << (x+1)/2 +1 << "\n";

}

Measured memory_bytes: 256
from bisect import bisect_left

S = input()
T = input()

memo = {}
for i, s in enumerate(S):
    if s not in memo:
        memo[s] = [i]
    else:
        memo[s].append(i)

cnt = 0
pre = -1
for t in T:
    if t not in memo:
        print(-1)
        quit()
    m = bisect_left(memo[t], pre + 1)
    if m >= len(memo[t]):
        cnt += 1
        pre = memo[t][0]
    else:
        pre = memo[t][m]

print(cnt * len(S) + pre + 1)

Measured memory_bytes: 7540
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"log"
	"os"
	"strconv"
)

// const abcd = "abcdefghijklmnopqrstuvwxyz"
// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var dr = [...]int{0, 1, 1, 1, 0, -1, -1, -1, 0}
var dc = [...]int{1, 1, 0, -1, -1, -1, 0, 1, 0}

func main() {
	log.SetFlags(log.Lshortfile)
	nextReader = NewScanner()
	A := nextInt()
	B := nextInt()
	fmt.Println(A*B - (A + B - 1))
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func printInts(out []int, str string) {
	var bb bytes.Buffer
	for i := range out {
		bb.WriteString(strconv.Itoa(out[i]))
		bb.WriteString(str)
	}
	fmt.Println(bb.String())
}

var nextReader func() string

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#include <bits/stdc++.h>

#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF ll(1e9)
#define INFL ll(1e18)
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int ctoi(char c) {return c - '0';}

class ACoffee {
public:
	void solve(std::istream& in, std::ostream& out) {
	    string S; in >> S;
	    string ans = "No";
	    if (S[2] == S[3] && S[4] == S[5]) ans = "Yes";
	    out << ans << '\n';
	}
};


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

	ACoffee solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
using namespace std;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
                
    #ifndef _LOCAL          
    #endif // _LOCAL

    int x;
    cin >> x;
    cout << (1 ^ x);

    return 0;
}

Measured memory_bytes: 3660
a,b,h,m=map(int,input().split())
theta_b=6*m
theta_a=30*h+m/2
import math
theta=(theta_b-theta_a)*math.pi/180
l=((a**2)+(b**2)-2*a*b*math.cos(theta))**(1/2)
print(l)


Measured memory_bytes: 9496
#include<cstdio>
#include<algorithm>
int cnt[200001]={};
int main(){
    int n,k,a;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&a);
        cnt[a]++;
    }
    std::sort(cnt,cnt+n+1);
    int ans=0;
    for(int i=n-k;i>=0&&cnt[i]>0;i--){
        ans+=cnt[i];
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int A, B, C, D;

int main()
{
	in >> A >> B >> C >> D;
	if (A + B < C + D)
	{
		out << "Right" << std::endl;
	}
	else if (A + B == C + D)
	{
		out << "Balanced" << std::endl;
	}
	else
	{
		out << "Left" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int min(int b,int c)
{
	int M;
	if(b!=0 && c!=0)
	{
	   M=b;
	   if(M>c) M=c;
	}
	else
	{
		if(b==0)
		{
			return c;
		}
		else
		{
			return b;
		}
	}
	return M;
}

int main(void)
{
	int i,j,n,m,s[21],dp[21][50001];
	
	scanf("%d%d",&n,&m);
	s[0]=0;
	for(i=1;i<=m;i++)
	{
		scanf("%d",&s[i]);
	}
	for(i=0;i<=n;i++)
	{
		dp[0][i]=0;
	}
	for(i=1;i<=m;i++)
	{
		for(j=0;j<=n;j++)
		{
			if(s[i]<=j)
			{
				dp[i][j]=min(dp[i][j-s[i]]+1,dp[i-1][j]);
			}
			else
			{
				dp[i][j]=dp[i-1][j];
			}
		}
	}
	printf("%d\n",dp[m][n]);
	return 0;
}

Measured memory_bytes: 4700
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    D = [list(map(int, input().split())) for i in range(N)]
    cnt = 0
    for a, b in D:
        if a == b:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()

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

int main() {
   int a,b,c;
  string s;
  cin>>s;
  c=0;
  bool t=1;
  vector<int> vec(a);
  for(int i=0;i<s.size();i+=2){
  	if(s.at(i)!='R'&&s.at(i)!='U'&&s.at(i)!='D'){
      t=0;}
  }
  
  for(int i=1;i<s.size();i+=2){
  	if(s.at(i)!='L'&&s.at(i)!='U'&&s.at(i)!='D'){
      t=0;}
  }
  
  if(t)
  cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
  
}
 

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


int sumDigits (int n) {
    int sum = 0;
    while (n > 0) {
        sum += n%10;
        n /= 10;
    }
    return sum;
}
int main()
{
    int N;
    cin >> N;

    int min = N;
    for (int i=2; i<N; i++) {
        int sum =  sumDigits(i) + sumDigits(N-i);
        if (sum < min) min = sum;
        
    }
    cout << min << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<queue>
using namespace std;
typedef pair<int ,int> PP;
int wa[1000001];
int main(void)
{
	priority_queue<PP> qu;
	int i,j,q,n,flg,a,v,x,y;
	scanf("%d %d",&n,&q);
	for(i=1;i<=n;i++)	wa[i]=0;
	for(i=0;i<q;i++)	{
		scanf("%d %d",&a,&v);
		wa[a]+=v;
		qu.push(PP(wa[a],-a));
		while(1)	{
			x=qu.top().first;
			y=-qu.top().second;
			if(wa[y]==x)	{
				printf("%d %d\n",y,x);
				break;
			}
			else {
				qu.pop();
			}
		}
	}
	return 0;
}


Measured memory_bytes: 5840
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setbitc(x) __builtin_popcount(x)
#define init(x,a) memset(x,a,sizeof(x))
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
ll n,m,k,ar[N],br[N];
string s,s1;
//Variables End

int main()
{
    ios
    int ti=1;
    //cin>>ti;
    while(ti--)
    {
		cin>>n;
		vi in(n),ans(n);
		rep(i,0,n)cin>>in[i];
		map<ll,ll> ma;
		rep(i,0,n)ma[in[i]]++;
		ll tot=0;
		for(auto i:ma)
		{
			tot+=((i.S*(i.S-1))/2);
		}
		rep(i,0,n)
		{
			ll t=ma[in[i]]-1;
			ans[i]=tot-t;
		}        

		for(auto i:ans)cout<<i<<endl;
    }
    return 0;
        
}

Measured memory_bytes: 13440
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	//a := make([]int, n)
	m := make(map[int]struct{})
	for i := 0; i < n; i++ {
		var t int
		fmt.Scan(&t)
		_, e := m[t]
		if e {
			delete(m, t)
		} else {
			m[t] = struct{}{}
		}
	}
	fmt.Println(len(m))
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int a, p; scanf("%d%d", &a, &p);
	
	printf("%d\n", (a * 3 + p) / 2);
	return 0;
}


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

int main() {
	int w, a, b, x;
	cin >> w >> a >> b;
	if (a < b) {
		x = b - (w + a);
	}
	else if(a > b){
		x = a - (w + b);
	}
	else {
		x = 0;
	}

	if (x <= 0) {
		x = 0;
	}

	cout << x << endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7
MAX = (10 ** 5) * 2 + 2


def input():
    return sys.stdin.readline().strip()


def main():
    N, K = map(int, input().split())
    ans = 0
    M = N
    m = 0
    for i in range(1, N + 2):
        if i < K:
            M += N - i
            m += i
            continue
        else:
            ans += M - m + 1
            ans %= MOD
            M += N - i
            m += i

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
const int N=1E3+7;
const int INF=1e9+7;
int mp[N][N];
int arr[N];
int n,m,k;
vector<int>ve;
int cal(int x,int y,int j){//用来计算第从x到y行第j列的值。
    int sum=0;
    for(int i=x;i<=y;i++)
        sum+=mp[i][j];
    return sum;
}
int check(){
    int c=ve.size(),sum=0;
    for(int k1=1;k1<c;k1++) arr[k1]=0;
    bool flag=0;
    for(int j=1;j<=m;j++){

        for(int k1=1;k1<c;k1++){
            arr[k1]+=cal(ve[k1-1]+1,ve[k1],j);
            if(arr[k1]>k){
                sum++;
                flag=1;
                break;
            }
        }
        if(!flag) continue ;
        flag=0;
        for(int k1=1;k1<c;k1++){
            arr[k1]=cal(ve[k1-1]+1,ve[k1],j);
            if(arr[k1]>k) return INF;
        }
    }
    return sum;
}
int main(){
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            char x;
            cin>>x;
            if(x=='1') mp[i][j]=1;
            else mp[i][j]=0;
        }
    }
    int c=(1<<(n-1))-1;
    int ans=INF;
    for(int i=0;i<=c;i++){
        ve.push_back(0);
        for(int j=0;j<n-1;j++)
            if((1<<j)&i) ve.push_back(j+1);
        ve.push_back(n);
        int x=ve.size();
        ans=min(ans,x-2+check());
        ve.clear();
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);
int main(){
    int l,r,d;cin>>l>>r>>d;
    int ans =0;
    rep2(i,l,r+1){
        if(i%d==0)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
char n[N];
int k;
int dp[N][5];
int main() {
	scanf("%s", n);
	scanf("%d", &k);
	int sz = strlen(n);
	reverse(n, n + sz);
	dp[0][0] = 1;
	for(int i = 1; i < sz; ++i) {
		dp[i][0] = 1;
		for(int j = 1; j <= k; ++j) {
			dp[i][j] = dp[i - 1][j] + (9 * dp[i - 1][j - 1]);
		}
	}
	int ans = 0;
	for(int i = sz - 1, j = k; i >= 0 and j >= 0; --i, --j) {
		if(j == 0) {
			ans++;
			break;
		}
		int num = n[i] - '0';
		if(num == 0) {
			j++;
			continue;
		}
		int l = 1;
		if(i == 0) l = 0;
		ans += (num - l) * dp[i][j - 1] + dp[i][j];
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
/*
	Problem: Moderate Differences
	Source: AtCoder Grand Contest 017 B
	Author: fts2001 (the_silliest)
 */
using namespace std;
int n,a,b,c,d;
long long t;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>a>>b>>c>>d;
    if(!c && !d){
        if(a==b)cout<<"YES\n";
        else cout<<"NO\n";
        return 0;
    }
    t=abs(b-a);
    for(int i=1-n;i<=n-1;i++){
        long long tmp=t-1ll*i*c;
        if(tmp%d==0){
            long long j=tmp/d;
            if(abs(i)+abs(j)<=n-1 && (n-abs(i)-abs(j))%2){
                cout<<"YES\n";
                return 0;
            }
        }
        else if(tmp%d>=c){
            long long j=tmp/d;
            if(abs(i)+abs(j)+1<=n-1 && (n-abs(i)-abs(j)-1)%2){
                cout<<"YES\n";
                return 0;
            }
        }
    }
    cout<<"NO\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
    char l[6][6]={{0}};
    for(int i=0;i<5;i++){
        for(int j=0;j<5;j++)
            l[i][j]='a'+i*5+j;
    }
    strcpy(l[5],"z.?! ");

    char str[256];
    while(scanf("%s",str)!=EOF){
        if(strlen(str)&1){
            puts("NA");
            continue;
        }
        bool flag=true;
        char ans[128]={0};
        for(int i=0;str[i];i+=2){
            int v1=str[i]-'0'-1,v2=str[i+1]-'0'-1;
            if(v1<0||v1>=6||v2<0||v2>=5){
                puts("NA");
                flag=false;
                break;
            }
            ans[i/2]=l[v1][v2];
        }
        if(flag)printf("%s\n",ans);
    }
    return 0;
}

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

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    int x = -1;
    if(c == -1 or d == -1){
        if(a > b) x = 2;
        else if(a < b) x = 1;
        else x = 0;
    }else{
        if(c > d) x = 1;
        else if(c < d) x = 2;
        else x = 0;
    }

    string s = "";
    if(x == 1){
        s = "Alice";
    }else if(x == 2){
        s = "Bob";
    }else{
        s = "Draw";
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 3180
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut graph = vec![vec![]; n];
    for i in 0..m {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        graph[a].push((b, i));
        graph[b].push((a, i));
    }

    if m % 2 == 1 {
        println!("-1");
        return;
    }

    let mut edges: Vec<Option<(usize, usize)>> = vec![None; m];
    let mut vis = vec![false; n];
    dfs(0, 0, &graph, &mut edges, &mut vis);
    for i in 0..m {
        let (from, to) = edges[i].unwrap();
        sc.write(format!("{} {}\n", from + 1, to + 1));
    }
}

fn dfs(
    v: usize,
    p: usize,
    graph: &Vec<Vec<(usize, usize)>>,
    edges: &mut Vec<Option<(usize, usize)>>,
    vis: &mut Vec<bool>,
) {
    vis[v] = true;
    for &(next, _) in graph[v].iter() {
        if !vis[next] {
            dfs(next, v, graph, edges, vis);
        }
    }

    for &(next, edge_id) in graph[v].iter() {
        if next == p {
            continue;
        }
        if edges[edge_id].is_none() {
            edges[edge_id] = Some((v, next));
        }
    }

    let mut out = 0;
    for &(_, i) in graph[v].iter() {
        if let Some((from, _)) = edges[i] {
            if from == v {
                out += 1;
            }
        }
    }

    for &(next, edge_id) in graph[v].iter() {
        if next == p {
            if out % 2 == 0 {
                edges[edge_id] = Some((p, v));
            } else {
                edges[edge_id] = Some((v, p));
            }
        }
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 27644
inputs = readlines.map{ |line| line.chomp.to_i }

train_normal = inputs[0]
train_super = inputs[1]
buss_normal = inputs[2]
buss_super = inputs[3]

# choose cheeper 
train = (train_normal > train_super) ? train_super : train_normal
buss = (buss_normal > buss_super) ? buss_super : buss_normal

puts train + buss

Measured memory_bytes: 1788
import java.util.Scanner;

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

		System.out.println(s.equals(t.substring(0, t.length() - 1)) ? "Yes" : "No");
	}
}

Measured memory_bytes: 35680
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1000000007;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
struct union_find{//rank,経路圧縮で高速化
  vi par;//parは添字の親（または自分が根の時自身）を示す。
  vi rank;//rankは木の高さ（根についてのみ実装）
  union_find(int n){
    par.assign(n,0);
    rank.assign(n,0);
    REP(i,n) par[i]=i;
  }
  int find(int a){//根を探す
    if(par[a]==a) return a;
    else return par[a] = find(par[a]);//根に直接つける
  }
  void unite(int a,int b){//小さい方の木の根に大きい方の根を上書きする
    int roota,rootb;
    roota = find(a),rootb = find(b);
    if(roota==rootb) return;
    if(rank[roota]>rank[rootb]){
      par[rootb] = roota;
    }else if(rank[roota]<rank[rootb]){
      par[roota] = rootb;
    }else{
      rank[roota]++;
      par[rootb] = roota;
    }
  }
};
int main(){
  cioacc();
  int n,m;
  cin >> n >> m;
  union_find uf(n);
  REP(i,m){
    int tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    uf.unite(tmp1,tmp2);
  }
  int q;
  cin >> q;
  REP(i,q){
    int tmp1,tmp2;
    cin >> tmp1 >> tmp2;
    if(uf.find(tmp1)==uf.find(tmp2)) cout << "yes" << endl;
    else cout << "no" << endl;
  }
}



Measured memory_bytes: 3540
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>

int main() {
	int n, x, y; std::cin >> n >> x >> y; --x, --y;
	std::vector<int> min_distance(n, 0);
	for (auto i = 0; i < n; ++i) {
		for (auto j = i + 1; j < n; ++j) {
			int distance = std::min({ j - i, std::abs(x - j) + std::abs(y - i) + 1, std::abs(y - j) + std::abs(x - i) + 1 });
			min_distance[distance]++;
		}
	}
	for (auto k = 1; k < n; ++k) {
		std::cout << min_distance[k] << '\n';
	}
}


Measured memory_bytes: 888
import java.util.*;
import java.math.BigInteger;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), i = 0, l = -1, b = -1;
		Map<Integer, Integer> m = new HashMap<Integer, Integer>();
		Queue<Integer> maxQueue = new PriorityQueue<Integer>(new Comparator<Integer>(){
			public int compare (Integer a, Integer b) {
				return b-a;
			}
		});
		while (N-->0) {
			int a = sc.nextInt();
			m.put(a, m.get(a)==null ? 1 : m.get(a)+1);
			maxQueue.add(a);
		}
		while (!maxQueue.isEmpty()) {
			int k = maxQueue.poll();
			if (m.get(k)>=2) {
				if (l==-1) {
					l = k;
					m.put(k, m.get(k)-2);
					maxQueue.poll();
					continue;
				}
				if (b==-1) { b=k; break; }
			}
		}
		System.out.println((l==-1||b==-1) ? 0 : new BigInteger(""+l).multiply(new BigInteger(""+b)));
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 66980
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S,T;
    cin >> N >> S >> T;
    string ans = "";
    for(int i=0;i<N;i++){
        ans += S[i];
        ans += T[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#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>;

const int N = 3000, T = 3000;

int n, t, a[N + 1], b[N + 1];

int dp1[N + 2][T]; // 1-i
int dp2[N + 2][T]; // i-n

int main() {
  cin >> n >> t;
  for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];
  rep(i, n+2) rep(j, t) dp1[i][j] = 0;
  rep(i, n+2) rep(j, t) dp2[i][j] = 0;
  
  for (int i = 1; i <= n; i++) rep(j, t) {
    dp1[i][j] = max(dp1[i][j], dp1[i - 1][j]);
    if (j - a[i] >= 0) dp1[i][j] = max(dp1[i][j], dp1[i - 1][j - a[i]] + b[i]);
  }

  for (int i = n; i >= 1; i--) rep(j, t) {
    dp2[i][j] = max(dp2[i][j], dp2[i + 1][j]);
    if (j - a[i] >= 0) dp2[i][j] = max(dp2[i][j], dp2[i + 1][j - a[i]] + b[i]);
  }

  int ans = 0;
  for (int i = 1; i <= n; i++) rep(j, t) {
    ans = max(ans, dp1[i - 1][j] + dp2[i + 1][t - 1 - j] + b[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 74004
#include<bits/stdc++.h>
using namespace std;
signed main(){
 string a;
  int c=1,b[100000]={};
  cin>>a;
  for(int i=0;i<a.size();i++){
    b[a[i]]++;
  }
  for(int i=0;i<1000;i++){
    if(b[i]%2==1) c=0;
  }
  if(c) cout<<"Yes";
  else cout<<"No";
  cout<<"\n";
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void){
	int n,m,l;
	int i,j,k;

	scanf("%d %d %d",&n,&m,&l);
	/*C99kikaku deha hairetutyou ni hensuu siyo kanou
	  {0}syokika ha fukano rasii..*/
	int A[n][m],B[m][l];
	long int C[n][l];

	//torikomi
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&A[i][j]);
		}
	}
	for(i=0;i<m;i++){
		for(j=0;j<l;j++){
			scanf("%d",&B[i][j]);
		}
	}
	
	//keisan
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			C[i][j]=0;			//kokode syokika
			for(k=0;k<m;k++){
				C[i][j]+=A[i][k]*B[k][j];
			}
		}
	}

	//hyouji
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			printf("%ld",C[i][j]);       //%d ha ketabusoku %ld nisuru
			if(j!=(l-1)) printf(" ");
			else printf("\n");
		}
	}
	return 0;
}

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

int main(){
    string s,t;
    cin>>s>>t;
    bool able=false;
    for(int k=0;k<2;k++){
        int sindex=0;
        int tindex=0;
        bool isok=true;
        for(int i=0;i<s.size();i++){
            if((i+k)%2==0){
                for(;sindex<s.size();sindex++){
                    if(s[i]==s[sindex]) break;
                }
                if(sindex==s.size()) isok=false;
                sindex++;
            }       
            else{
                for(;tindex<t.size();tindex++){
                    if(s[i]==t[tindex]) break;
                }
                if(tindex==t.size()) isok=false;
                tindex++;
            }

        }
        able=able||isok;
    }
    cout<<(able ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 3224
import java.util.Scanner;
public class Main {
    static long counter = 0;
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int [] ls = new int[n];
        for(int x = 0; x < n; x++){
            ls[x] = scan.nextInt();
        }
        merge_sort(ls, 0, n);
        System.out.println(counter);
    }
    public static void merge_sort (int[] lst, int left, int right) {
        if(left + 1 < right){
            int mid = (left + right)/2;
            merge_sort(lst, left, mid);
            merge_sort(lst, mid, right);
            merge(lst, left, mid, right);
        }
    }
    public static void merge(int[] A, int left, int mid, int right) {
        int n1 = mid - left;
        int n2 = right - mid;
        int[] L = new int[n1 + 1];
        int[] R = new int[n2 + 1];
        for (int i = 0; i < n1; i++) {
            L[i] = A[left + i];
        }
        for (int i = 0; i < n2; i++) {
            R[i] = A[mid + i];
        }
        L[n1] = R[n2] = Integer.MAX_VALUE;
        int l = 0;
        int r = 0;
        for(int i = left; i < right; i++){
            if (L[l] <= R[r]){
                A[i] = L[l++];
                counter = counter + r;
            }
            else{
                A[i] = R[r++];
            }
        }
    }
}


Measured memory_bytes: 100536
#include <bits/stdc++.h>
using namespace std;
int main() {
  long N;
  cin >> N;
  vector<long> A(N);
  map<long,long> c;
  for (long i = 0 ; i < N; i++) {
    cin >> A.at(i);
    c[A.at(i)]++;
  }
  
  long sum = 0, n;
  for(auto i = c.begin(); i != c.end(); ++i) {
    n = i->second;
    sum += n * (n-1) / 2;
  }
  for (long i = 0 ; i < N; i++) {
    cout << sum - (c[A.at(i)] - 1)<< endl;
  }
  return 0;
}


Measured memory_bytes: 11008
#include<iostream>
#include"math.h"
using namespace std;
int main(){
  int nowx=0,nowy=0,nowt=0;
  int x,y,t,n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>t>>x>>y;
    int temp=0;
    temp+=(abs(x-nowx)+abs(y-nowy));
    if((t-nowt)-temp<0){
      cout<<"No";
      return 0;
    }else if(((t-nowt)-temp)%2!=0){
      cout<<"No";
      return 0;
    }else{
      nowx=x;nowy=y;nowt=t;
    }
  }
  cout<<"Yes";
  return 0;
}

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

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

using namespace std;


signed main(){
  int N;
  int cake=4;
  int donuts=7;
  int sum;
  int flag=0;
  cin>>N;
  for(int i=0;i<26;i++){
    for(int j=0;j<15;j++){
      sum = 4*i+7*j;
      if(sum==0) continue;
      if(sum>100) continue;
      if(sum==N) flag=1;
    }
  }
  if(flag==1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N1 200001
#define N2 11


int compare_char(const void *a, const void *b) {
  return (strcmp(*(const char **)a, *(const char **)b));
}

int main() {

//	int n = 7;
	int n;
	scanf("%d", &n);

	char **data;
	data = (char **)malloc(sizeof(char *) * N1);
	for(int i = 0; i < N1; i++){
		data[i] = (char *)malloc(sizeof(char) * N2);
	}

	for(int i = 0; i < n; i++) {
		scanf("%s", data[i]);
	}


//	char data1[7][11] = {"beet", "vet", "beet", "bed", "vet", "bet", "beat"};

//	for(int i = 0; i < n; i++) {
//		memcpy(data[i], data1[i], sizeof(data1[i]));
//	}

	int **ans;
	ans = (int **)malloc(sizeof(int *) * N1);
	for(int i = 0; i < N1; i++){
		ans[i] = (int *)malloc(sizeof(int) * N2);
		*ans[i] = 0;
	}

	qsort(data, n, sizeof(data[0]), compare_char);


	for(int i = 0; i < n; i++) {
		if(strcmp(data[i], data[i+1]) == 0){
			*ans[i] = *ans[i] + 1;
			*ans[i+1] = *ans[i] + 1;
		}
	}


	int max = 0;

	for(int i = 0; i < n; i++) {
		if(max < *ans[i]){
			max = *ans[i];
		}
	}

	for(int i = 0; i < n; i++) {
		if(max == *ans[i]){
			printf("%s\n",data[i]);
		}
	}


	for(int i = 0; i < n; i++) {
		free(data[i]);
		free(ans[i]);
	}
	free(data);
	free(ans);

	return 0;

}


Measured memory_bytes: 23788
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>
#include <queue>

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0; }

typedef long long ll;
using namespace std;

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

    int n = 1;
    while (true) {
        if (s == 1 || s == 2 || s == 4) {
            cout << n + 3 << endl;
            return 0;
        } else {
            if (s % 2) {
                s = 3 * s + 1;
            } else {
                s /= 2;
            }
            n++;
        }
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
typedef long long ll;
using namespace std; 
int main()
{
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   for (int i = 1; i < 1000; ++i)
   {
       if (i%2==1)
       {
           c=c-b;
       }
       else
       {
        a=a-d;
       }
       if (c<1)
       {
           cout<<"Yes"<<endl;
           break;
       }
       else
        if (a<1)
        {
            cout<<"No"<<endl;
            break;
        }
   }
    return 0;
}


Measured memory_bytes: 3640