akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main (void) {
    char T[200001];
    scanf("%s", T);

    for (int i = 0; T[i] != '\0'; i++) {
        if (T[i] == '?') {
            T[i] = 'D';
        }
    }

    printf("%s\n", T);

    return 0;
}


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

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

#define INF 100000000

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  if(A == B && A != C){
    cout << "Yes" << endl;
  }
  else if (A == C && A != B){
    cout << "Yes" << endl;
  }
  else if (B == C && B != A){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
#define MOD int(1e9 + 7)

int main()
{
    long long A, B;
    cin >> A >> B;

    if(A * B % 2 == 0)
        cout << "Even" << endl;
    else
        cout << "Odd" << endl;
}

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

const int N = 110000;

int go[17][N];

int main() {
	int n; cin >> n;
	vector<int> a(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int L; cin >> L;
	for (int i = 1, j = 1; i <= n; i++) {
		while (j < n && a[j + 1] - a[i] <= L) j++;
		go[0][i] = j;
	}
	for (int i = 1; i < 17; i++) {
		for (int j = 1; j <= n; j++) {
			go[i][j] = go[i - 1][go[i - 1][j]];
		}
	}
	int q; cin >> q;
	while (q--) {
		int u, v; cin >> u >> v;
		if (u > v) swap(u, v);
		int ans = 0;
		for (int i = 16; i >= 0; i--) {
			if (go[i][u] >= v) continue;
			u = go[i][u];
			ans |= 1 << i;
		}
		ans++;
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 8320
import java.util.Scanner;

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

        int[] arr = new int[101];

        int count = 0;

        for (int i = 0; i < 3; i++) {

            int n = scanner.nextInt();

            if (arr[n] == 0){
                count ++;
                arr[n] = 1;
            }
        }

        System.out.println(count);

    }
}


Measured memory_bytes: 9684
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, x;
  int S=0;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> x;
    if (2*x<K) {
      S += 2*x;
    }
    else {
      S += 2*(K-x);
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 256
package main

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

const (
	NO  = "No"
	YES = "Yes"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int
	scanner.Scan()
	N, _ = strconv.Atoi(scanner.Text())
	var M int
	scanner.Scan()
	M, _ = strconv.Atoi(scanner.Text())
	var K int
	scanner.Scan()
	K, _ = strconv.Atoi(scanner.Text())
	fmt.Println(solve(N, M, K))
}
func solve(N int, M int, K int) string {
	calcK := func(n, m int) int {
		return n*M + m*N - 2*n*m
	}
	for n := 0; n <= N; n++ {
		for m := 0; m <= M; m++ {
			if calcK(n, m) == K {
				return YES
			}
		}
	}
	return NO
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int k=sc.nextInt();
		sc.nextLine();
		String s[]=new String[k];
		for(int i=0;i<k;i++){
			s[i]=sc.nextLine();
		}
		System.out.println(solve(s));
	}

	private static double solve(String[] s) {
		// TODO Auto-generated method stub
		double result=0;
		for(String str:s){
			String tmp=str.split(" ")[0];
			if(str.indexOf("JPY")>=0){

				result+=Double.parseDouble(tmp);
			}else{
				result+=Double.parseDouble(tmp)*380000;
			}
		
		}
		return result;
	}

	private static int[] nextArr(int k) {
		// TODO Auto-generated method stub
		int[] res = new int[k];
		for (int i = 0; i < k; i++) {

			res[i] = sc.nextInt();
		}
		return res;
	}

}


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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             1e9
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);
#ifdef VAMP
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cout << name << " = " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cout.write(names, comma - names) << " = " << arg1 <<" | ";
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif

const int N = 3005;
int n , s;
int ara[N];
const LL MOD = 998244353;
LL dp[N][N][2];

LL call(int pos,int sum,int state)
{
    if(sum == s){
        return n - (pos - 1) + 1;
    }
    if(pos == n + 1){
        return 0;
    }

    if(dp[pos][sum][state] != -1)return dp[pos][sum][state];
    LL ret = 0;
    if(state == 0){
        ret = ret + call(pos + 1,sum,state);
        if(ara[pos] + sum <= s)ret = ret + pos * call(pos + 1,sum + ara[pos],1);
    }else{
        ret = ret + call(pos + 1,sum,state);
        if(ara[pos] + sum <= s)ret = ret + call(pos + 1,sum + ara[pos],state);
    }

    return dp[pos][sum][state] = ret % MOD;
}
int main()
{
    #ifdef VAMP
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    cin >> n >> s;
    MEM(dp,-1);
    FOR(i,1,n)cin >> ara[i];
    cout << call(1,0,0) << "\n";
    #ifdef VAMP
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
}


Measured memory_bytes: 141696
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> A;
  tools::read(A, N);

  std::cout << (std::count_if(A.begin(), A.end(), [](const i64& A_i) { return A_i % 2 == 1; }) % 2 == 0 ? "YES" : "NO") << std::endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, 0, n) {
        string s;
        cin >> s;
        mp[s]++;
    }
    vector<pair<int, string>> v;
    for (auto i : mp) {
        v.push_back(make_pair(i.second, i.first));
    }
    sort(all(v), greater<pair<int, string>>());
    vector<string> ans;
    ans.push_back(v[0].second);
    int mx = v[0].first;
    rep(i, 1, v.size()) {
        if (v[i].first == mx) ans.push_back(v[i].second);
    }
    sort(all(ans));
    for (auto i : ans) {
        cout << i << endl;
    }
    return 0;
}


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

typedef long long ll;

int main() {
  ll k;
  const ll n = 50;

  while (cin >> k) {
    ll m = 0;
    if (k > 0) {
      m = (k - 1) / n + 1;
    }

    ll a[n];
    for (int i = 0; i < n; i++) {
      a[i] = (n - 1) + m;
    }

    if (k > 0) {
      ll rem = n - (((k - 1) % n) + 1);
      for (int i = 0; i < rem; i++) {
	a[i] -= (n - rem + 1);
      }
      for (int i = rem; i < n; i++) {
	a[i] += rem;
      }
    }

    cout << n << endl;
    for (int i = 0; i < n; i++) {
      if (i != 0) {
	cout << " ";
      }
      cout << a[i];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

map<pi, int> cnt;

signed main()
{
	IO_OP;
	
	int n;
	cin >> n;
	for(int i=1;i<=n;i++) {
		string s = to_string(i);
		int x = s[0]-'0', y = s.back()-'0';
		cnt[{x, y}]++;
	}	
	int ans = 0;
	for(auto p:cnt) {
		ans += (ll)p.S * cnt[{p.F.S, p.F.F}];
	}
	cout << ans << endl;
}





Measured memory_bytes: 256
# 二部探索問題

# from bisect import bisect_right as binarysearch
A, B, Q = map(int,input().split())

"""
自分で作ったやつは遅い
"""
def binarysearch(ls,x):
    n = len(ls)
    left = 0
    right = n
    pos = (right+left)//2
    while True:
        if ls[pos] < x < ls[pos+1]:
            index = pos
            break    
        elif x < ls[pos]:
            right = pos
        elif ls[pos+1] < x:
            left = pos
        pos = (right+left)//2
    return index




ss = [-10**10]+[int(input()) for _ in range(A)]+[2*10**10]
ts = [-10**10]+[int(input()) for _ in range(B)]+[2*10**10]
xs = [int(input()) for _ in range(Q)]
for x in xs:
    sind = binarysearch(ss,x)
    tind = binarysearch(ts,x)
    
    s0,s1,t0,t1 = ss[sind],ss[sind+1],ts[tind],ts[tind+1]
    # d1,d2,d3,d4 = 10**10,10**10,10**10,10**10
    # print("s",s0,x,s1)
    # print("t",t0,x,t1)
    d1 = max(x-s0,x-t0)
    d2 = min((t1-x)*2+(x-s0),(x-s0)*2+(t1-x))
    d3 = min((s1-x)*2+(x-t0),(x-t0)*2+(s1-x))
    d4 = max(s1-x, t1-x)
    print(min(d1,d2,d3,d4))


Measured memory_bytes: 17304
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 8
#define INF 1000000001
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define REP(i, n) for(int i=0; i<n; i++)
#define RER(i, n) for(int i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int	n, l[MAX_N];
int a, b, c;

signed main(){
	cin >> n;
	cin >> a >> b >> c;
	REP(i, n) cin >> l[i];
	int m = pow(4, n), ret = INF;	
	REP(i, m){
		int tmp = i, mp = 0;
		int ta = 0, tb = 0, tc = 0;
		REP(j, n){
			if(tmp%4 == 0){
				if(ta != 0) mp += 10;
				ta += l[j];
			}else if(tmp%4 == 1){
				if(tb != 0) mp += 10;
				tb += l[j];
			}else if(tmp%4 == 2){
				if(tc != 0) mp += 10;
				tc += l[j];
			}
			tmp /= 4;
		}
		if(ta == 0 || tb == 0 || tc == 0) continue;
		mp += abs(a - ta);
		mp += abs(b - tb);
		mp += abs(c - tc);
		ret = min(ret, mp);
	}
	cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1ll, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main(void) {
	ll n;
	cin >> n;
	ll v = mpower(10, n) % mod - (mpower(9, n) * 2 % mod - mpower(8, n)) % mod;
	while (v < 0)v += mod;
	printf("%lld\n", v % mod);
	return 0;
}


Measured memory_bytes: 3752
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll rec(vector<vector<ll>> &dp,const vector<ll> &s_size, ll l, ll r){
    if(dp[l][r] >= 0) return dp[l][r];
    if(l >= r) return (dp[l][r] = 0);

    ll ret = INF;
    for(int i = l; i < r; i++){
        ret = min(ret,rec(dp,s_size,l,i) + rec(dp,s_size,i+1,r) + s_size[r] - s_size[l-1]);
    }
    
    return (dp[l][r] = ret);
}

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

    vector<ll> a(n+1);
    for(int i = 1; i < n+1; i++){
        cin >> a[i];
    }

    vector<ll> s_size(n+1,0);
    for(int i = 1; i < n+1; i++){
        s_size[i] = s_size[i-1] + a[i];
    }

    vector<vector<ll>> dp(n+1,vector<ll>(n+1,-1));

    cout << rec(dp,s_size,1,n) << endl;
    
    return 0;
}

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

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

int main(){
  int N,W;
  cin >> N >> W;

 // const long long INF = 1LL << 60;
  long long weight[110], value[110];
  long long dp[110][100010];
  for(int i = 0; i < N; i++){
      cin >> weight[i] >> value[i];
  }

  for(int i = 0; i < N; i++){
    for(int sum_w = 0; sum_w <= W; sum_w++){
      	if(sum_w >= weight[i]){
     	 	chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]]+ value[i]);
      	}    
      	chmax(dp[i+1][sum_w], dp[i][sum_w]);
    }
  }

  cout << dp[N][W] << endl;
  
}

Measured memory_bytes: 80256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

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

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

      return tokenizer.nextToken("\n");
    }

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

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

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

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

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

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    Map<String, Integer> count = new HashMap<>();
    count.put("AC", 0);
    count.put("WA", 0);
    count.put("TLE", 0);
    count.put("RE", 0);
    for (int i = 0; i < n; i++) {
      count.merge(sc.next(), 1, Integer::sum);
    }
    System.out.println("AC x " + count.get("AC"));
    System.out.println("WA x " + count.get("WA"));
    System.out.println("TLE x " + count.get("TLE"));
    System.out.println("RE x " + count.get("RE"));
  }
}

Measured memory_bytes: 50092
#include<bits/stdc++.h>
#define maxn 1005
using namespace std;
const int mod = 1e9+7;
int n,m,a[maxn][maxn],cnt,UD,LR,clr,cud;
long long k;
char s[maxn];
int Pow(int a,long long b){int s=1;for(;b;b>>=1,a=1ll*a*a%mod) b&1&&(s=1ll*s*a%mod);return s;}
struct Mat{
	int s[2][2];
	Mat(){memset(s,0,sizeof s);}
	Mat operator * (const Mat &B)const{
		Mat ret;
		for(int k=0;k<2;k++)
			for(int i=0;i<2;i++) if(s[i][k])
				for(int j=0;j<2;j++) if(B.s[k][j])
					ret.s[i][j]=(ret.s[i][j]+1ll*s[i][k]*B.s[k][j])%mod;
		return ret;
	}
}f,g;
void solve(int a,int b){
	g.s[0][0]=cnt,g.s[0][1]=a,g.s[1][1]=b,f=g;
	for(k-=2;k;k>>=1,g=g*g) if(k&1) f=f*g;
}
int main()
{
	scanf("%d%d%lld",&n,&m,&k);
	if(k<=1) return puts("1"),0;
	for(int i=1;i<=n;i++){
		scanf("%s",s+1);
		for(int j=1;j<=m;j++) a[i][j]=s[j]=='#',cnt+=a[i][j],clr+=a[i][j]&a[i][j-1],cud+=a[i][j]&a[i-1][j];
	}
	for(int i=1;i<=n;i++) LR+=a[i][1]&a[i][m];
	for(int i=1;i<=m;i++) UD+=a[1][i]&a[n][i];
	if(LR&&UD) return puts("1"),0;
	if(!LR&&!UD) return printf("%d\n",Pow(cnt,k-1)),0;
	LR?solve(clr,LR):solve(cud,UD);
	printf("%d\n",(f.s[0][0]-f.s[0][1]+mod)%mod);
}

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

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a,b,g=0;
    cin >> a >> b;
    if(a>b)
        swap(a,b);
    for (int i=0;i<b;i++)
        g=g*10+a;
    cout << g;
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(b>c) swap(b,c);
  cout << max(0,c-a-b);
}

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

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

ll dp[105][100100];
ll w[100100]; ll v[100100];

int main(){
   int n,W;
   cin>>n>>W;
   rep(i,n)cin>>w[i]>>v[i]; rep(i,105)rep(j,100100)dp[i][j]=INF;

   dp[0][0]=0;

   for(int i=0;i<n;i++){
       for(int j=0;j<100100;j++){
            if(j-v[i]>=0)chmin(dp[i+1][j],dp[i][j-v[i]]+w[i]);

            chmin(dp[i+1][j],dp[i][j]);
       }
   }
   ll ans=0;
   rep(i,100100){
       if(dp[n][i]<=W)ans=max(ans,i);
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 85760
#include <bits/stdc++.h>
using namespace std;
const int dh[8] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dw[8] = {1, 0, -1, 0, 1, 1, -1, -1};
const char white = '.';
const char black = '#';
const int k = 50;
const int idx = 8;

vector<string> solve(int a, int b) {
    vector<string> s(2*k, string(2*k, black));
    for (int i = k; i < 2*k; i++) fill(s[i].begin(), s[i].end(), white);
    for (int i = 0; i < k-1; i += 2) {
        for (int j = 0; j < 2*k; j += 2) {
            if (a) { s[i][j] = white; a--; }
        }
    }
    for (int i = k+1; i < 2*k; i += 2) {
        for (int j = 0; j < 2*k; j += 2) {
            if (b) { s[i][j] = black; b--; }
        }
    }
    return s;
}

int main() {
    int a, b;
    cin >> a >> b;
    vector<string> ans = solve(a-1, b-1);
  	cout << 100 << " " << 100 << endl;
    for (auto& v : ans) cout << v << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
long long xx[100100];
long long dp[100100][2];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>xx[i];
		dp[i][0]=dp[i][1]=-1;
	}
	dp[0][0]=0;
	long long res=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<2;j++){
			if(dp[i][j]==-1)
				continue;
			long long cur=dp[i][j];
			for(int a=0;a<2;a++){
				for(int b=0;b<2;b++)if(a+b<=xx[i]){
					dp[i+1][b]=max(dp[i+1][b],cur+(j+a)/2+(xx[i]-a-b)/2);
				}
			}
		}
	}
	res=max(res,dp[n][0]);
	res=max(res,dp[n][1]);
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 2560
S=int(input())

MOD=10**9+7
def permutations(num,r):
    x=1
    cnt=0

    if r==0:return 1
    for i in range(num,0,-1):
        if cnt>=r:
            break

        x = x*i%MOD
        cnt+=1

    return x

def factorial(num):
    x=1
    if num==0:return 1
    for i in range(num,0,-1):
        x = x *i%MOD

    return x


ans=0
kaisuu=S//3

r=0
for i in range(kaisuu):
    n=S-3*(i+1)

    per=permutations(n+r,r)
    fac=factorial(r)
    diff=per*pow(fac,MOD-2,MOD)%MOD
    ans=(ans+diff)%MOD
    r+=1

print(ans)

Measured memory_bytes: 66228
n = int(input())
a = input()
b = input()
c = input()
count = 0

for i in range(n):
    if a[i] == b[i] and a[i] == c[i]:
        pass
    elif a[i] != b[i] and a[i] != c[i] and b[i] != c[i]:
        count += 2
    else:
        count += 1

print(count)


Measured memory_bytes: 3060
from collections import defaultdict
import sys
sys.setrecursionlimit(1000000)

d = defaultdict(list)
cost = defaultdict(int)
N = int(input())

for _ in range(N-1):
    u, v, w = map(int, input().split())
    d[u].append(v)
    d[v].append(u)
    cost[(u, v)] = w

visited = [False]*(N+1)
color = [-1]*(N+1)
color[1] = 0

def dfs(x):
    visited[x]=True
    for y in d[x]:
        if visited[y]:continue
        c = cost[(x, y) if x<y else (y, x)]
        color[y] = color[x]^1 if c%2 else color[x]  
        dfs(y)

dfs(1)
for i in color[1:]:
    print(i)

Measured memory_bytes: 86112
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <float.h>
#include <stdlib.h>
#include <functional>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 1; i <= (int)(n); i++)
#define in cin >>
#define out cout <<
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define all(v) v.begin(),v.end()
typedef long long ll;
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
ll modpow(ll a,ll n,ll mod){
    ll res=1;
    while(n>0){
        if(n&1)res=a*res%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}
void comb(vector<vector <long long int> > &v){
  for(int i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(int k = 1;k <v.size();k++){
    for(int j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}


int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    
    while(a>0 || c>0){
        c=c-b;
        if(c<=0){
            cout << "Yes";
            break;
        }
        a=a-d;
        if(a<=0){
            cout << "No";
            break;
        }

    }


}


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

int main(){
  int N; cin >> N;
  int count=0;
  for(int i=1; i<=N; i++){
    int a; cin >> a;
    if(i%2==1&&a%2==1) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3624
using System;

namespace abc142B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int N = int.Parse(str[0]);
            int K = int.Parse(str[1]);
            int[] h = new int[N];
            string[] ltr = Console.ReadLine().Split();
            for (int i = 0; i < N; i++)
            {
                h[i] = int.Parse(ltr[i]);
            }
            int p = 0;
            for(int m = 0; m < N; m++)
            {
                if (h[m] >= K)
                {
                    p = p + 1;
                }
            }
            Console.Write(p);
        }
    }
}


Measured memory_bytes: 15968
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
void read(int &x) {
    char ch; bool ok;
    for(ok=0,ch=getchar(); !isdigit(ch); ch=getchar()) if(ch=='-') ok=1;
    for(x=0; isdigit(ch); x=x*10+ch-'0',ch=getchar()); if(ok) x=-x;
}
#define rg register
const int maxn=3010,mod=1e9+7;
char ch[maxn];
int n,m,f[maxn][maxn],tot,sum[maxn],las[maxn];
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int main()
{
    read(n),read(m);scanf("%s",ch+1);
    for(rg int i=1;i<=n+1;i++){
        sum[i]=sum[i-1],las[i]=i;
        if(ch[i]=='1')tot++,sum[i]++;
    }
    for(rg int i=1,x,y;i<=m;i++)read(x),read(y),las[x]=max(las[x],y);
    for(rg int i=1;i<=n+1;i++)las[i]=max(las[i],las[i-1]);
    f[1][sum[las[1]]]=1;
    for(rg int i=1;i<=n;i++)
        for(rg int j=0;j<=tot;j++)
            if(f[i][j]){
                int a=las[i],b=las[i+1];
                if(j)f[i+1][j+sum[b]-sum[a]-1]=add(f[i+1][j+sum[b]-sum[a]-1],f[i][j]);
                if(las[i]+1-i-j)f[i+1][j+sum[b]-sum[a]]=(f[i+1][j+sum[b]-sum[a]],f[i][j]);
        }
    printf("%d\n",f[n+1][0]);
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  vi primes;
  const int N = 300010;
  vi types(N, 2);
  rep (i, N) {
    if (i % 7 != 1 && i % 7 != 6) types[i] = 0;
  }

  types[1] = 1;
  for (int i = 2; i < N; i++) {
    if (types[i] == 2) {
      //DEBUG(i);
      primes.push_back(i);
      for (int j = 2; i*j < N; j++) {
        if (!types[j]) continue;
        if (types[i * j] != 0) types[i*j] = 1;
      }
    }
  }

  while (true) {
    int n;
    cin >> n;
    if (n == 1) return 0;

    cout << n << ": ";
    vi ans;
    for (int i = 1; i*i <= N; i++) {
      if (n % i == 0) {
        if (types[i] == 2) ans.push_back(i);
        if (i != n / i && types[n / i] == 2) ans.push_back(n / i);
      }
    }

    sort(all(ans));
    UNIQUE(ans);
    rep (i, ans.size()) {
      cout << ans[i] << " \n"[i == ans.size() - 1];
    }
  }
}



Measured memory_bytes: 4204
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;
char str1[105], str2[105];

int main()
{
	int i, j;
	int a, b;
	scanf("%d%s%s", &N, str1, str2);
	for (i = 0; i < N; ++i) {
		printf("%c%c", str1[i], str2[i]);
	}
	return 0;
}

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

int main(){
	int N;
	cin>>N;
	vector<int> A(N);
	vector<int> B(N);
	vector<int> C(N-1);

	int ans = 0;
	for(int i = 0;i<N;i++){
		cin>>A.at(i);
		A.at(i)-=1;
	}
	for(int i = 0;i<N;i++){
		cin>>B.at(i);
	}
	for(int i = 0;i<N-1;i++){
		cin>>C.at(i);
	}
	ans +=B.at(A.at(0));
	for(int i =1;i<N;i++){
		ans+=B.at(A.at(i));
		if (A.at(i-1)+1 == A.at(i)){
			ans+=C.at(A.at(i-1));
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());  
    int[] A = new int[N];
    for(int i = 0; i<N; i++){
        int index = Integer.parseInt(sc.next()) - 1;
        A[index] = i + 1;
    } 
    for(int i = 0; i<N; i++){
        System.out.print(A[i] + " ");
    }

  }
}



Measured memory_bytes: 50972
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  int res=0;
  for(int a=0;a<26;a++){
    for(int b=0;b<=(100-a*4);b++){
      if(a*4+b*7==N)++res;
    }
  }
  if(res!=0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

// Macros
#define F  first
#define S  second
#define PB push_back

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// HELPERS
//  Tedious Grid Movements
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
inline bool move_okay(int x, int y, int n, int m) { return 0 <= x and x < n and 0 <= y and y < m; }
//  Remember:
//   * vec.assign() GOOD; vec.resize() BAD
//   * comparator uses <

// Output, Common Containers
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream& os, const set<T>& v)    { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const map<T,S>& v)  { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef SANYAM1101
	#define trace(args...) do{ cerr << "Trace On! (Line: " << __LINE__ << ")\n"; d_f(string(#args), args); } while(0)
	void d_f(__attribute__((unused)) string str) {}
	template<typename Head, typename... Tails> void d_f(string str, Head H, Tails... T) { cerr << "\t" << str.substr(0, str.find(", ")) << " <=> [" << H << "]\n"; d_f(str.substr(str.find(", ") + 2), T...); }
#else
	#define trace(args...)
#endif


// CODE STARTS HERE

void solve(){
	ll n, m;
	cin >> n >> m;

	ll ans = n * (n - 1) + m * (m - 1);
	ans /= 2;
	cout << ans << "\n";
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD =998244353 ;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template<ll M = 1000000007>
struct modint{
    ll val;
    modint(): val(0){}
    template<typename T>
    explicit modint(T t){val = t%M; if(val < 0) val += M;}

    modint pow(ll k){
        modint res(1), x(val);
        while(k){
            if(k&1) res *= x;
            x *= x;
            k >>= 1;
        }
        return res;
    }
    template<typename T>
    modint& operator=(T a){ val = a%M; if(val < 0) val += M; return *this; }
    modint inv() {return pow(M-2);}
    modint& operator+=(modint a){ val += a.val; if(val >= M) val -= M; return *this;}
    modint& operator-=(modint a){ val += M-a.val; if(val >= M) val -= M; return *this;}
    modint& operator*=(modint a){ val = 1LL*val*a.val%M; return *this;}
    modint& operator/=(modint a){ return (*this) *= a.inv();}
    modint operator+(modint a) const {return modint(val) +=a;}
    modint operator-(modint a) const {return modint(val) -=a;}
    modint operator*(modint a) const {return modint(val) *=a;}
    modint operator/(modint a) const {return modint(val) /=a;}
    modint operator-(){ return modint(-val);}
    bool operator==(const modint a) const {return val == a.val;}
    bool operator!=(const modint a) const {return val != a.val;}
    bool operator<(const modint a) const {return val < a.val;}
};

using mint = modint<MOD>;

int main() {
    int n;
    cin >> n;
    vector<int> cnt(n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        cnt[x]++;
        if(i == 0 && x != 0){
            puts("0");
            return 0;
        }
    }
    if(cnt[0] != 1){
        puts("0");
        return 0;
    }
    mint ans(1);
    for (int i = 0; i < n-1; ++i) {
        if(!cnt[i] && cnt[i+1]){
            puts("0");
            return 0;
        }
        ans *= mint(cnt[i]).pow(cnt[i+1]);
    }
    cout << ans.val << "\n";
    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
 
using namespace std;
 
// template<typename... T>
// void read(T&... args) {
//     ((cin >> args), ...);
// }
 
// template<typename... T>
// void write(T&&... args) {  
//     ((cout << args << " "), ...);
// }
 
// #define deb(x) cerr << #x << " " << x <<endl;
 
// #define debs(args ...) cerr << __LINE__ << ": ", err(new istringstream(string(#args)), args), cerr << '\n'
// void err(istringstream *iss) {}
// template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) {
//     string _name;
//     *iss >> _name;
//     if (_name.back()==',') _name.pop_back();
//     cerr << _name << " = " << _val << "; ", err(iss, args ...);
// }


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

	long long n,a,b,c;
	while(cin>>n){
		vector<tuple<long long,long long,long long>>lst;	
		for(long long i=0; i<n; ++i )cin>>a>>b>>c, lst.push_back(make_tuple(a,b,c));
		vector<tuple<long long,long long,long long>>dp(n+2,make_tuple(0ll,0ll,0ll));
		dp[0]=lst[0];

		for(int i=1; i<n; ++i){
			// auto [a,b,c]=dp[i-1];
			long long a=get<0>(dp[i-1]);
			long long b=get<1>(dp[i-1]);
			long long c=get<2>(dp[i-1]);
			get<0>(dp[i])=get<0>(lst[i]) + max(b,c);
			get<1>(dp[i])=get<1>(lst[i]) + max(a,c);
			get<2>(dp[i])=get<2>(lst[i]) + max(a,b);
		}
		long long a=get<0>(dp[n-1]);
		long long b=get<1>(dp[n-1]);
		long long c=get<2>(dp[n-1]);
		// auto [a,b,c]=dp[n-1];
		cout<<max({a,b,c})<<endl; 
			
			
	}
	
    return 0;
}

Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    string s; cin >> s;
    map<char,int> x,y;
    REP(i,n) x[s[i]]++;
    
    int cnt = 0;
    int ans = 0;
    for(auto c:s) {
        x[c]--;
        if (y[c] > 0) cnt--;
        y[c]++;
        if (x[c] > 0) cnt++;
        ans = max(ans,cnt);
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var x, y int
	fmt.Scan(&x, &y)
	switch x {
	case 1, 3, 5, 7, 8, 10, 12:
		switch y {
		case 3, 5, 7, 8, 10, 12:
			fmt.Println("Yes")
			return
		}
	case 4, 6, 9, 11:
		switch y {
		case 4, 6, 9, 11:
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
eval"N,K,*A="+`dd`.split*?,
s=eval A*?+
1.upto(3e4){|j|s%j<1&&$*<<j<<s/j}
p$*.max_by{|h|t=0
K<A.map{|x|x%h}.sort.map{|x|t+=x}[~t/h]?0:h}

Measured memory_bytes: 14596
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string l; cin >> l; // bit
    ll cnt = 0, ans = 0;
    rep(i, l.size()) {
        if (l[i] == '0') continue;
        cnt++;
        ll rest = l.size() - i - 1;
        ans += (modpow(2, cnt-1) * modpow(3, rest)) % MOD;
        ans %= MOD;
    }
    ans += modpow(2, cnt);
    ans %= MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    mod=10**9+7
    n=int(readline())

    A=0
    T=1
    G=2
    C=3
    dp=[[[[0]*4 for _ in range(4)] for _ in range(4)] for _ in range(n+1)]
    dp[0][T][T][T]=1
    for i in range(1,n+1):
        for j in range(4):
            for k in range(4):
                for l in range(4):
                    for m in range(4):
                        if j==A and k==G and l==C:
                            pass
                        elif j==A and k==C and l==G:
                            pass
                        elif j==G and k==A and l==C:
                            pass
                        elif m==A and k==G and l==C:
                            pass
                        elif m==A and j==G and l==C:
                            pass
                        else:
                            dp[i][j][k][l]+=dp[i-1][m][j][k]
    ans=0
    for j in range(4):
        for k in range(4):
            for l in range(4):
                ans+=dp[n][j][k][l]
                ans%=mod

    print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 3440
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;
using ll = long long;

#define mp make_pair
#define SORT(v) sort((v).begin(), (v).end())
#define GSORT(v) sort((v).begin(), (v).end(), greater<decltype((v).front())>())
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)

int main() {
    // X, Y, Zを受け取る
    // N = X + Y + Z
    ll X[3], N = 0;
    FOR(j, 0, 3) {
        cin >> X[j];
        N += X[j];
    }

    // A_i, B_i, C_iを受け取る
    vector<vector<ll>> coin(N, vector<ll>(3, 0));
    FOR(i, 0, N) {
        FOR(j, 0, 3) {
            cin >> coin[i][j];
        }
    }

    // (gold - silver, index)の配列
    vector<pair<ll, ll>> gs(N);
    FOR(i, 0, N) {
        gs[i] = make_pair(coin[i][0] - coin[i][1], i);
    }

    SORT(gs);

    // silver[i] = 「K = Y + iにおける
    //              左グループのコイン枚数の最大値」
    vector<ll> silver(X[2] + 1, 0);
    
    // 中身は(silver - bronze, index)
    GPQ<pair<ll, ll>> sb;
    
    // まずは最初のY個を追加してしまう
    FOR(i, 0, X[1]) {
        ll id = gs[i].second;
        sb.push(make_pair(coin[id][1] - coin[id][2], id));
        silver[0] += coin[id][1];
    }

    // ここから銅の人が出始める
    FOR(i, 0, X[2]) {
        ll id = gs[i + X[1]].second;
        sb.push(mp(coin[id][1] - coin[id][2], id));

        silver[i + 1] = silver[i] + coin[id][1];

        // 先頭の人を銀の人から銅の人に変える
        auto p = sb.top();
        sb.pop();
        silver[i + 1] += (coin[p.second][2] - coin[p.second][1]);
    }

    // 逆順にして(gold - bronze)で全く同じことをする
    GSORT(gs);

    vector<ll> gold(X[2] + 1, 0);
    GPQ<pair<ll, ll>> gb;
    FOR(i, 0, X[0]) {
        ll id = gs[i].second;
        gb.push(mp(coin[id][0] - coin[id][2], id));
        gold[0] += coin[id][0];
    }

    FOR(i, 0, X[2]) {
        ll id = gs[i + X[0]].second;
        gb.push(mp(coin[id][0] - coin[id][2], id));

        gold[i + 1] = gold[i] + coin[id][0];

        auto p = gb.top();
        gb.pop();
        gold[i + 1] += (coin[p.second][2] - coin[p.second][0]);
    }

    ll ans = 0;
    FOR(i, 0, X[2] + 1) {
        // K = Y + iにおけるコインの合計枚数と比較
        ans = max(ans, silver[i] + gold[X[2] - i]);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10996
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int d,r = 0;
        double f = 0;
        
        d=a/b;
            
        r=a%b;
            
        f=(double)a/b;
        
        System.out.println(d);
        System.out.println(r);
        System.out.printf("%.5f\n",f);
        
    }
    
    
}


Measured memory_bytes: 26576
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required
// iteration and input/output stream
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define printarr(x) rep(i,0,x.size()) cout<<x[i]<<" "; cout<<endl;

#define tr(cont,it) \
for(decltype(cont.begin()) it = cont.begin(); it!= cont.end() ; it++)

using namespace std;

#define tc() int tcase; cin >> tcase ; rep(tc,1,tcase+1)
//STL shortcuts
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define MP make_pair

// Error detection
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long int ll; // 64 bit integer
typedef unsigned long long int  ull; // 64 bit unsigned integer
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;

inline void smax(int &x , int y) { x = max(x , y) ; }
inline void smin(int &x , int y) { x = min(x , y) ; }

#define MOD 1000000007
#define inf 4000000000000000000LL
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);

ll gcd(ll a,ll b){ return ((b==0)? a:gcd(b,a%b) ); }


int main()
{
    SYNC
    ll n;
    cin>>n;
    n--;
    cout<<((n+1)*n)/2;

}


Measured memory_bytes: 256
n=int(input())
c=[int(input()) for _ in [0]*n]
l=[-1]*200001
dp=[1]*n
l[c[0]]=0
mod=10**+9+7
for i in range(1,n):
	ci=c[i]
	if l[ci] not in [-1,i-1]:
		dp[i]=(dp[i-1]+dp[l[ci]])%mod
	else:
		dp[i]=dp[i-1]
	l[ci]=i
print(dp[n-1])

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

class EasyLinearPrograming
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');

        var one = long.Parse(input[0]);
        var zero = long.Parse(input[1]);
        var minus = long.Parse(input[2]);
        var times = long.Parse(input[3]);


        long total = 0;

        if(one >= times)
        {
            total = times;
        }else if (zero >= times - one)
        {
            total = one;
        }else if (minus >= times - one - zero)
        {
            total = one - (times - one  - zero);
        }
        else
        {

        }


        Console.WriteLine(total);

    }
}

Measured memory_bytes: 27520
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long i=0;i<n;i++)
int main(){
  long n,ans,memo; cin>>n;
  vector<long> p(n);
  ans=0;
  memo=1000000;
  rep(i,n) cin>>p[i];
  rep(i,n){
    if(p[i]<memo){
      ans++;
      memo=p[i];
    }  
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792