akhauriyash/Code-Regression huggingface dataset:
public class Main {

public static void main(String[] args) {
  int a, b, c, tmp;
  java.util.Scanner scanInt = new java.util.Scanner(System.in);
  a = scanInt.nextInt();
  b = scanInt.nextInt();
  c = scanInt.nextInt();
  
  tmp = a;
  a = b;
  b = tmp;
  
  tmp = a;
  a = c;
  c = tmp;
  
  System.out.println(a + " " + b + " " + c);
  
}
}


Measured memory_bytes: 21332
n, x = list(map(int,input().split()))
a = list(map(int, input().split()))

a.sort()

cnt = 0
for i in range(len(a)):
    score = a[i]
    if i == n - 1:
        if x != score:
            break
    if x >= score:
        x -= score
        cnt += 1
print(cnt)

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

inline int Input() {
	char c = getchar(); int x = 0, z = 1;
	for(; c < '0' || c > '9'; c = getchar()) z = c == '-' ? -1 : 1;
	for(; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x * z;
}

const int maxn(105);

int n;
string s[maxn];

int main() {
	n = Input(), cin >> s[1];
	for (int i = 2; i <= n; ++i) {
		cin >> s[i];
		for (int j = 1; j < i; ++j) if (s[i] == s[j]) return puts("No"), 0;
		if (s[i][0] != s[i - 1][int(s[i - 1].size()) - 1]) return puts("No"), 0;
	}
	return puts("Yes"), 0;
}

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

int main()
{
    int h[200];
  
        int n;
        scanf("%d", &n);
        for (int i = 0; i < n; i++)
            scanf("%d", &h[i]);
        h[n] = 0;
        int i = 0;
        int ans = 0;
        int min = 0;


        for (i; i < n;) {
            if (h[i] < h[i + 1]) {
                i++;
            }
            else {
                ans += h[i]-min;
                ++i;
                min = h[i];
            }
        }
        cout << ans;

    }



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int mn=min(n,m);
    int mx=max(n,m);
    for(int i=0;i<mx;i++) cout<<mn;
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
/////////////////////////////////TEST CASES////////////////////////////////////
/*
*/
/////////////////////////////////////CODE//////////////////////////////////////		
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = a ; i > b ; i--)
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PI 3.14159265
typedef long long ll;
#define vl vector<ll> 
#define IN(inp) ll inp;cin>>inp;
#define pb push_back
#define all(a) a.begin(),a.end()
#define FR(i,a) for(auto i:a)
#define what(A) cout<<#A<<" is "<<A<<endl;
ll MAX = 100000000000;
ll MOD = 1000000007;
void solve()
{
	string s, t;
	cin >> s >> t;
	ll ans = 0, cnt = 0;
	FOR(i, 0, s.length()-t.length()+1)
	{
		cnt = 0;
		FOR(j, 0, t.length())
		{
			if (s[j + i] == t[j])
				cnt++;
		}
		ans = max(ans, cnt);
	}
	cout << t.length() - ans;
}
int main()
{
	fastio
		//freopen("input.txt", "rt", stdin);
		//freopen("output.txt", "wt", stdout);
		ll test = 1;
	//cin >> test;
	while (test--)
	{
		solve();
	}
}

Measured memory_bytes: 3608
#include<iostream>
#include<map>
#include<string>
#include<vector>
using namespace std;
int inf = 10000000;
int n;
vector<int> a;
int partition(int p, int r){
  int x = a[r-1];
  int i = p-1;
  for(int j=p; j<r; j++){
    if( a[j] <= x ){
      // i = i + 1;
      swap(a[++i], a[j]);
    }
  }
  // swap(a[i+1], a[r]);
  return i;
}

int main(){
  cin >> n;
  a.resize(n);
  for(int i=0; i<n; i++) cin >> a[i];

  int p = partition(0, n);

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

  return 0;
}

Measured memory_bytes: 3048
import sys

s1 = []
s2 = []
area = []

for i, c in enumerate(sys.stdin.readline()[:-1]):
    if c == '\\':
        s1.append(i)
    elif c == '/' and len(s1) > 0:
        j = s1.pop()
        a = i - j
        while s2:
            if s2[-1] > j:
                s2.pop()
                a += area.pop()
            else:
                break
        s2.append(j)
        area.append(a)

print(sum(area))
print(len(area), *area)

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

int main(void)
{
    int N, X;
    cin >> N >> X;

    vector<int> L(N + 1, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> L.at(i);
    }

    vector<int> D(N + 1, 0);
    for (int i = 1; i < N + 1; i++)
    {
        D.at(i) = D.at(i - 1) + L.at(i - 1);
        // cout << D.at(i) << endl;
    }

    int counter = 0;
    for (int i = 0; i < N + 1; i++)
    {
        if (D.at(i) <= X)
            counter++;
    }
    cout << counter << endl;
    return (0);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main()
{
	int A, B, C, X;
	cin >> A >> B >> C >> X;

	int ans = 0;
	for (int i = 0; i <= A; i++)
	{
		for (int j = 0; j <= B; j++)
		{
			for (int k = 0; k <= C; k++)
			{
				int sum = 500 * i + 100 * j + 50 * k;
				if (sum == X)
					ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <bitset>

using namespace std;

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

const int inf = 1e8;
typedef bitset<110> hasrefrig;

template<typename T>
inline bool chmin(T& t, T f) { if (t <= f) return false; t = f; return true; }

int solve(int M, int A, int H, const hasrefrig& rf, vector<vector<int>>& cost) {
    auto wf = [](vector<vector<int>>& v){
        rep(k, v.size()) rep(i, v.size()) rep(j, v.size()) {
            if (v[i][k] < inf && v[k][j] < inf) chmin(v[i][j], v[i][k] + v[k][j]);
        }
    };
    wf(cost);
    rep(i, cost.size()) rep(j, cost.size()) {
        if (!rf[i] || !rf[j] || M < cost[i][j]) cost[i][j] = inf;
    }
    wf(cost);
    if (cost[A][H] == inf) throw "Help!";
    return cost[A][H] + max(0, cost[A][H] - M);
}

int main() {
    int N, M, L, K, A, H;
    while (cin >> N >> M >> L >> K >> A >> H, N | M | L | K | A | H) {
        hasrefrig rf; rf.set(A); rf.set(H);
        for (int x; L--; rf.set(x)) cin >> x;
        vector<vector<int>> cost(N, vector<int>(N, inf));
        for (int X, Y, T; K--; cost[X][Y] = cost[Y][X] = T) cin >> X >> Y >> T;
        try {
            cout << solve(M, A, H, rf, cost) << endl;
        }
        catch (char const *mes) {
            cout << mes << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1320
s = str(input())
n = len(s)
a_less = [0] * (n+1)
a_greater = [0] * (n+1)

for i in range(n):
    if s[i] == '<':
        a_less[i+1] = a_less[i] + 1

for i in range(n)[::-1]:
    if s[i] == '>':
        a_greater[i] = a_greater[i+1] + 1

a = [x if x > y else y for x, y in zip(a_less, a_greater)]

print(sum(a))

Measured memory_bytes: 31908
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int n, t, c[max], h[max];
    int min=INT_MAX, flag=0;
    
    scanf("%d%d", &n, &t);
    rep(i, n){
        scanf("%d%d", &c[i], &h[i]);
        if (h[i]<=t&&min>c[i]) {
            min=c[i];
            flag++;
        }
    }
    
    if (flag) {
        printf("%d\n", min);
    } else {
        printf("TLE\n");
    }
    
    return 0;
}


Measured memory_bytes: 1744
N = int(input())
x_u = [list(map(str, input().split())) for i in range(N)]
ans = 0
for i in range(N):
	if x_u[i][1] == 'BTC':
		ans += float(x_u[i][0]) * 380000
	else:
		ans += float(x_u[i][0])
print(ans)


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
int n;
int a1,a2;

int main()
{
    cin>>n;
    char c;
    for (int i=1; i<=n; ++i)
    {
        scanf("%c",&c);
        if (c!='R' && c!='B')
            scanf("%c",&c);
        if (c=='R') a1++;
        else a2++;
    }
    if (a1>a2)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}



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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

        ll L, R;
        std::cin >> L >> R;

        ll ans = (L * R) % 2019;
        [&]() {
            for (ll i = L; i < R; i++) {
                for(ll j = i + 1; j <= R; j++) {
                    ans = min(ans, (i * j) % 2019);
                    if(ans == 0) return;
                }
            }
        }();

        std::cout << ans << std::endl;
    }
    catch(const exception& e) {
        std::cout << e.what() << std::endl;
        exit(1);
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h> 
int main(void) 
{ 
    int n, d, x, a[1000], i, j, s=0;
    
    scanf("%d%d%d",&n,&d,&x);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    
    for(i=0;i<n;i++){
        j=1;
        while(j<=d){
            s++;
            j+=a[i];
        }
    }
    s=s+x;
    printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 1712
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val s = List.fill(n)(sc.nextInt())
  val sum = s.sum
  if (sum % 10 != 0) {
    println(sum)
  } else {
    val t = s.filter(_ % 10 != 0)
    println(sum - t.minOption.getOrElse(sum))
  }
}


Measured memory_bytes: 55696
N, K = map(int, input().split())
R = N - K
mod = pow(10, 9) + 7

fact = [0] * 2001
inv = [0] * 2001
inv_cal = [0] * 2001

fact[:2] = [1, 1]
inv[1] = 1
inv_cal[:2] = [1, 1]

for i in range(2, 2001):
    fact[i] = fact[i-1] * i % mod
    inv[i] = mod - (mod // i) * inv[mod % i] % mod
    inv_cal[i] = inv_cal[i-1] * inv[i] % mod

def comb(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fact[n] * (inv_cal[k] * inv_cal[n-k] % mod) % mod

for k in range(1, K+1):
    print(comb(R+1, k) * comb(K-1, k-1) % mod)

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

ll N,C,K,T[100010];

int main(void)
{
    ll i;
    cin >> N >> C >> K;

    for(i = 0; i < N; i ++) {
        cin >> T[i];
    }

    sort(T, T+N);

    ll bc=1, br=0, t0 = T[0];  

    for(i = 0; i < N; i++) {
        br ++;
        if(T[i] - t0 > K || br > C) {
            bc++;
            br = 1;
            t0 = T[i];
        }
//        cout << i << ":" << bc << " " << br << " " << t0 << endl;
    }
    cout << bc << endl;
}


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

int main(void)
{
    
    int N,Sum;
    
    cin >> N;
    Sum = 0;
    
    int i,A[N][2];
    
    for(i=0;i<N;i++){
        cin >> A[i][0] >> A[i][1];
        Sum = Sum + A[i][1] - A[i][0] + 1;
    }
    
    cout << Sum << endl;
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt(), b = scanner.nextInt();
			System.out.println(((a <= 8) & (b <= 8)) ? "Yay!" : ":(");
		}
	}
}


Measured memory_bytes: 35572
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
import fractions
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())[:-1]
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]

a,b,c,d=map(int,input().split())
e=fractions.gcd(c,d)
f=c*d//e
ans1=a-1
ans1-=(a-1)//c
ans1-=(a-1)//d
ans1+=(a-1)//f
ans2=b
ans2-=b//c
ans2-=b//d
ans2+=b//f
print(ans2-ans1)


Measured memory_bytes: 5060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5+7;
const ll inf=1e17;
int a,b,q;
ll s[N],t[N],x;
int binary(ll *p,int m)
{
    int l=1,r=m;
    while(l<=r)
    {
        int mid=(l+r)>>1;
        if(p[mid]<=x)
            l=mid+1;
        else
            r=mid-1;
    }
        return l;
}
int main()
{
    scanf("%d%d%d",&a,&b,&q);
    int j,k;
    for(int i=1;i<=a;i++)
        scanf("%lld",&s[i]);
    for(int i=1;i<=b;i++)
        scanf("%lld",&t[i]);
        s[0]=-1*inf,s[a+1]=inf;
        t[0]=-1*inf,t[b+1]=inf;
    for(int i=1;i<=q;i++)
    {
        ll ans=0;
        scanf("%lld",&x);
        j=binary(s,a);
        k=binary(t,b);
        ans=min(max(s[j],t[k])-x,x-min(s[j-1],t[k-1]));
        ans=min(ans,min(2*t[k]-s[j-1]-x,t[k]-2*s[j-1]+x));
        ans=min(ans,min(2*s[j]-t[k-1]-x,s[j]-2*t[k-1]+x));
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 2816
N, M = map(int, input().split())
slist = [list(map(int, input().split()))[1:] for _ in range(M)]
plist = list(map(int, input().split()))

def count_on_switch(switch_array: list, on: set):
    return sum([int(sw in on) for sw in switch_array])

ans = 0
# print("---")
for i in range(2**N):
    on = set()
    for j in range(N):
        if ((i >> j) & 1):
             on.add(j+1)
    temp = 0
    for _ in range(M):
        cou_on = count_on_switch(slist[_], on)
        # print(i, cou_on)
        if cou_on % 2 != plist[_]:
            break
    else:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int A, B, C;

int calc_score(vector<int> a, int num)
{
  int score = 0;
  int aa = 0;

  if (a.size() == 0)
  {
    // invalid
    return 10000;
  }

  aa += a[0];
  for (int i = 1; i < a.size(); i++)
  {
    aa += a[i];
    score += 10;
  }

  score += std::abs(aa - num);

  return score;
}

int dfs(vector<int> a, vector<int> b, vector<int> c, vector<int> l, int pos)
{
  if (pos == l.size())
  {
    // calculate the score
    int score = 0;
    score += calc_score(a, A);
    score += calc_score(b, B);
    score += calc_score(c, C);

    return score;
  }

  vector<int> a2 = a;
  a2.emplace_back(l[pos]);
  vector<int> b2 = b;
  b2.emplace_back(l[pos]);
  vector<int> c2 = c;
  c2.emplace_back(l[pos]);

  int num = dfs(a2, b, c, l, pos + 1);
  num = std::min(dfs(a, b2, c, l, pos + 1), num);
  num = std::min(dfs(a, b, c2, l, pos + 1), num);
  num = std::min(dfs(a, b, c, l, pos + 1), num);

  return num;
}

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

  vector<int> l(N);
  rep(i, N)
  {
    cin >> l[i];
  }

  vector<int> a, b, c;
  int pos = 0;
  int num = dfs(a, b, c, l, pos);

  cout << num << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i=0, i##_limit=(n); i<i##_limit; ++i)
#define FOR(i, a, b) for (int i=(a), i##_limit=(b); i<i##_limit; ++i)
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long;
using pi = pair<int, int>;

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

    map<ll, int> pd;
    pd[1]++;

    ll minv = min(A, B);
    for (ll i=2; i*i <= minv; ++i)
    {
        while (minv%i == 0)
        {
            pd[i]++;
            minv /= i;
        }
    }
    if (minv != 1) pd[minv]++;

    ll ret = 0;
    for (auto p : pd) if (A%p.first==0 && B%p.first==0) ++ret;

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<double, double> P;
int bit[40001], n;
 
int sum(int i){
	int s=0;
	while(i>0){
		s+=bit[i];
		i-=(i&(-i));
	}
	return s;
}
 
void add(int i){
	while(i<=n){
		bit[i]+=1;
		i+=(i&(-i));
	}
}
int main()
{
  cin>>n;
  double a[40000], b[40000], c[40000];
  for(int i=0; i<n; i++) cin>>a[i]>>b[i]>>c[i];
  P p[40000];
  int ord[100000];
  int inv[100000];
  double x1=-2e8, x2=2e8;
  for(int t=0; t<70; t++){
    double x=(x1+x2)/2;
    for(int i=0; i<n; i++){
      p[i]=P(a[i]/b[i], c[i]/b[i]-x*a[i]/b[i]);
    }
    sort(p, p+n);
    for(int i=0; i<n; i++) ord[i]=i;
    sort(ord, ord+n, [&](int x, int y){return p[x].second<p[y].second;});
    for(int i=0; i<n; i++) inv[ord[i]]=i;
    fill(bit, bit+n+1, 0);
    int ct=0;
    for(int i=0; i<n; i++){
      int s=inv[i];
      ct+=(i-sum(s));
      add(s+1);
    }
    if(ct<(1+(ll)n*((ll)n-1)/2)/2) x1=x;
    else x2=x;
  }
  printf("%.10lf ", x1);
  x1=-2e8, x2=2e8;
  for(int t=0; t<70; t++){
    double x=(x1+x2)/2;
    for(int i=0; i<n; i++){
      p[i]=P(b[i]/a[i], c[i]/a[i]-x*b[i]/a[i]);
    }
    sort(p, p+n);
    for(int i=0; i<n; i++) ord[i]=i;
    sort(ord, ord+n, [&](int x, int y){return p[x].second<p[y].second;});
    for(int i=0; i<n; i++) inv[ord[i]]=i;
    fill(bit, bit+n+1, 0);
    int ct=0;
    for(int i=0; i<n; i++){
      int s=inv[i];
      ct+=(i-sum(s));
      add(s+1);
    }
    if(ct<(1+(ll)n*((ll)n-1)/2)/2) x1=x;
    else x2=x;
  }
	printf("%.10lf\n", x1);
	return 0;
}


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

int dfs( vector<int> &arr, vector<bool> & isVisited, vector<int> & res, int src)
{
    if(isVisited[src])
        return src;
    
    isVisited[src] = true;
    res.push_back(src);
    return dfs(arr, isVisited, res, arr[src] - 1);
}

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

    vector<int> arr(n);
    vector<int> res;
    vector<bool> isVisited(n, false);

    for(int i=0;i<n;i++)
    {
        cin>> arr[i];
    }

    int pos = dfs(arr,isVisited, res, 0);

    vector<int> offset;
    vector<int> cycle;
    bool flag = false;
    for(int i=0;i<res.size();i++)
    {
        if(res[i] == pos || flag)
        {
            flag = true;
            cycle.push_back(res[i]);
        }
        else
        {
            offset.push_back(res[i]);
        }
    }
/*
    for(int i=0;i<res.size();i++)
        cout<<res[i]<<" ";
    cout<<endl;
    for(auto it:offset)
        cout<<it<<" ";
    cout<<endl;

    for(auto it:cycle)
        cout<<it<<" ";
    cout<<endl;
*/
    if( k < (ll)(offset.size()))
        cout<<1 + offset[k]<<endl;
    else
    {
        k -= (offset.size());
        ll val = k %((ll)(cycle.size()));
        cout<<(1 + cycle[val])<<endl; 
    }

    return 0;                          
}


Measured memory_bytes: 15468
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define vv vector
#define pp pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define fastio                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);
typedef pair<ll, ll> pll;
typedef vv<ll> vll;
typedef vv<pll> vpll;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//adds two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set]
//(2)set.order_of_key(k)[count of elements strictly less than k]
#define LG(args...)                               \
	{                                             \
		string _s = #args;                        \
		replace(_s.begin(), _s.end(), ',', ' ');  \
		stringstream _ss(_s);                     \
		err(istream_iterator<string>(_ss), args); \
		cerr << endl;                             \
	}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "(" << *it << ":" << a << ") ";
	err(++it, args...);
}
//:::::::::::::::::::::::::::::::::::::::::::::
const ll INF = 9e18;
const ll MOD = 1e9 + 7;
// #define dbg
#define ld long double

const ll maxn = 303;
ld dp[maxn][maxn][maxn];

int main(){
	fastio;
	ll n;
	cin>>n;
	vll a(n);
	ll c1=0,c2=0,c3=0;
	for(auto& i: a){
		cin>>i;
		if(i==1)
			c1++;
		else if(i==2)
			c2++;
		else
			c3++;
	}

	for(ll k=0; k<=maxn; k++){
		for(ll j=0; j<=maxn; j++){
			for(ll i=0; i<=maxn; i++){

				if(i+j+k > n)
					continue;
				if(i+j+k == 0){
					dp[i][j][k]=0;
					continue;
				}

				dp[i][j][k] = (n+0.0)/(i+j+k);
				auto p =[&](ld o){
					return o/(i+j+k);
				};
				if(i)
					dp[i][j][k] += p(i)*dp[i-1][j][k];
				if(j)
					dp[i][j][k] += p(j)*dp[i+1][j-1][k];
				if(k)
					dp[i][j][k] += p(k)*dp[i][j+1][k-1];
			}
		}
	}

	// for(ll i=0; i<=n; i++){
	// 	for(ll j=0; j<=n; j++){
	// 		for(ll k=0; k<=n; k++){
	// 			LG(i,j,k, dp[i][j][k])
	// 		}
	// 	}
	// }
	cout.precision(10);
	cout<<dp[c1][c2][c3];

}

Measured memory_bytes: 214096
s = input()
n = len(s)
ans = 0
for i in range(1 << (n-1)):
    formula = s[0]
    for j in range(n-1):
        if (i >> j) & 1 == 1:
            formula += s[j+1]
        else:
            formula += '+' + s[j+1]
    ans += eval(formula)
print(ans)
                                     


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    int ac=0, wa=0, tle=0, re=0;
    while(N--) {
        string s;
        cin >> s;
        if(s == "AC") {
            ac++;
        } else if(s == "WA") {
            wa++;
        } else if(s == "TLE") {
            tle++;
        } else {
            re++;
        }
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}


Measured memory_bytes: 3632
data State = N | I | R deriving Eq

main :: IO ()
main = do
  _ <- readLn :: IO Int
  ls <- fmap read . words <$> getLine :: IO [Int]
  print $ solve 0 1 ls
solve :: Int -> Int -> [Int] -> Int
solve c _ [] = c
solve c idx (h:tl) = solve c' idx' tl' where
  s = if h == idx then if head' tl == idx + 1 then R else I else N
  c' = if s == N then c else c + 1
  idx' = if s == R then idx + 2 else idx + 1
  tl' = if s == R then tail' tl else tl

tail' :: [a] -> [a]
tail' [] = []
tail' ls = tail ls

head' :: [Int] -> Int
head' [] = -1
head' ls = head ls


Measured memory_bytes: 29180
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#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;
int main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  int dx = tx-sx,dy=ty-sy;
  cout<<string(dx,'R')<<string(dy,'U');
  cout<<string(dx,'L')<<string(dy,'D');
  cout<<'D'<<string(dx+1,'R')<<string(dy+1,'U')<<'L';
  cout<<'U'<<string(dx+1,'L')<<string(dy+1,'D')<<'R'<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,s[1000],p[1000],q[1000],r[1000],flg,sum[1000],P,Q,R,C,i;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=0;i<n;i++){
			sum[i]=0;
			scanf("%d %d %d %d",&s[i],&p[i],&q[i],&r[i]);
			sum[i]=p[i]*4+q[i]*9+r[i]*4;
		}
		scanf("%d %d %d %d",&P,&Q,&R,&C);
		flg=0;
		for(i=0;i<n;i++){
			if(p[i]<=P&&q[i]<=Q&&r[i]<=R&&sum[i]<=C){
				printf("%d\n",s[i]);
				flg=1;
			}
		}
		if(flg==0){
			printf("NA\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2044
#include <stdio.h>
#include <math.h>
#define NUM 100001  // NUM以下の素数を求める

int main(void){
    // Your code here!
int Q;
scanf("%d", &Q);
int L[Q];
int R[Q];
  unsigned prime[NUM];
  int i;
for (int i = 0; i < Q; ++i) {
  scanf("%d" "%d", &L[i],&R[i]);
}
  int  j;
  unsigned sq_num = (int)sqrt((double)NUM);

  // 1が立っているものが素数
  // 0が立っているものが合成数（素数ではない）

  for (i = 0; i < NUM; i++)
    prime[i] = 1;  // 全ての数に1を立てる
  prime[0] = 0;    // 1は素数ではない

  for (i = 1; i < sq_num; i++) {
    if (prime[i] == 1)          // prime[i]が素数なら
      for (j = (i+1); (i+1) * j <= NUM; j++)
        prime[(i+1) * j - 1] = 0;  // 素数の倍数は素数ではない
  }



int nita[NUM]= {};
  for (i = 1; i < NUM; i++){
    if(prime[i-1]==1 && prime[(i)/2] ==1 && i != 2){
        nita[i] = nita[i-1] + 1;}
    else{
        nita[i] = nita[i-1];}
}
int a;
//  for (i = 0; i < 100; i++){
//    printf("%d\n",nita[i]);
//}
  for (i = 0; i < Q; i++){
    a = nita[R[i]] - nita[L[i]-1];
    printf("%d\n",a);
}
return 0;
}

Measured memory_bytes: 2048
#define DEBUG
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
 
#define F first
#define S second 
#define pb push_back
#define endl "\n"

#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }

#ifdef DEBUG
    #define dbg(s) {s;}
#endif

#ifndef DEBUG
    #define dbg(s)
#endif

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int grand(int x) { // from [0, x-1]
    return uniform_int_distribution<int>(0, x - 1)(rng);
}

#define int ll
#define i32 int32_t

#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 

#define all(v) (v).begin(),(v).end()

typedef long long ll;
typedef long double ld;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;

int getInt () {
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}


ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 

const ll mod = 1e9 + 7;

ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % mod;
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
}

const int maxn = 1e6 + 7;

const ll inf = 1e9 + 7;


i32 main() {
    //freopen("<file>.in", "r", stdin);
    //freopen("<file>.out", "w", stdout);

    IOS;
    int t1,t2,a1,a2,b1,b2;
    cin>>t1>>t2>>a1>>a2>>b1>>b2;
    
    a1 = t1*a1;
    b1 = t1*b1;
    a2 = t2*a2;
    b2 = t2*b2;

    if(a1>b1)
    {
        swap(a1,b1);
        swap(a2,b2);
    }

    if(a1+a2 == b1+b2)
    {
        cout<<"infinity"<<endl;
        return 0;
    }

    if(a1+a2 < b1+b2)
    {
        cout<<"0"<<endl;
        return 0;
    }

    int x1 = b1-a1;
    int y1 = a1+a2-b1-b2;

    int k = (y1+x1-1)/y1;
    int ans = k+k-1;

    if(k*y1 == x1)
        ans++;

    cout<<ans<<endl;
   
    
}





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

int main(void)
{
	int n, r;
	int p, c;
	int card[50], card_next[50];
	int i, j, a;
	
	
	while (1){
		scanf("%d%d", &n, &r);
		if (n == 0 && r == 0){
			break;
		}
		
		for (i = 0; i < n; i++){
			card[i] = i + 1;
		}
		
		for (i = 0; i < r; i++){
			scanf("%d%d", &p, &c);

			a = 0;
			for (j = 0; j < n - (p - 1) - c; j++){
				card_next[a++] = card[j];
//printf("<%d>", j);
			}
			for (j = n - p + 1; j < n; j++){
				card_next[a++] = card[j];
//printf("[%d]", j);
			}
			for (j = n - (p - 1) - c; j < n - (p - 1); j++){
				card_next[a++] = card[j];
//printf("(%d)", j);
			}
			memcpy(card, card_next, sizeof(card));
		}
		printf("%d\n", card[n - 1]);
	}
	return (0);
}
	

Measured memory_bytes: 600
if __name__ == '__main__' :
    N = int(input())
    ws = []
    for i in range(0,N):
        ws.append(input())

    if len(ws) != len(set(ws)):
        print('No')
        exit()
        
    before = ws[0][0]
    for w in ws:
        if before != w[0]:
            print('No')
            exit()
        else:
            before = w[len(w)-1]
                  
    print('Yes')

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

template <typename T>
class SegmentTree
{
private:
  using Fn = function<T(T, T)>;
  int N;
  vector<T> dat;
  T unit;
  Fn func;

public:
  SegmentTree() {}
  SegmentTree(int n_, Fn func_, T unit_) : func(func_), unit(unit_)
  {
    N = 1;
    while (N < n_)
      N *= 2;
    dat.assign(2 * N - 1, unit);
  }
  SegmentTree(vector<T> v, Fn func_, T unit_) : func(func_), unit(unit_)
  {
    N = 1;
    int sz = v.size();
    while (N < sz)
      N *= 2;
    dat.resize(2 * N - 1);
    for (int i = 0; i < N; ++i)
      dat[i + N - 1] = (i < sz ? v[i] : unit);
    for (int i = N - 2; i >= 0; --i)
      dat[i] = func(dat[i * 2 + 1], dat[i * 2 + 2]);
  }

  // k 番目の要素を a に変更
  void update(int k, T a)
  {
    k += N - 1;
    dat[k] = a;
    while (k > 0)
    {
      k = (k - 1) / 2;
      dat[k] = func(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }

  // k 番目の要素を取得
  T get(int k) { return dat[k + N - 1]; }

  // 区間 [l, r) のgcdを取得
  T query(int l, int r)
  {
    T vl = unit, vr = unit;
    for (l += (N - 1), r += (N - 1); l < r; l >>= 1, r >>= 1)
    {
      if ((l & 1) == 0)
        vl = func(vl, dat[l]);
      if ((r & 1) == 0)
        vr = func(vr, dat[--r]);
    }
    return func(vl, vr);
  }
};

int gcd(int m, int n) {//最大公約数
    if (n == 0)return m;
    return gcd(n, m % n);
}//gcd

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
  }
  auto f = [](int a, int b) {return gcd(a,b);};
  SegmentTree<int> sg(a,f,0);
  int max_ans=1;
  rep(ai,n){
    int ans;
    int x=sg.get(ai);//hozon
    sg.update(ai,0);//ai=0
    ans=sg.query(0,n);//gcd
    max_ans=max(max_ans,ans);
    sg.update(ai,x);//modosu
  }
  cout<<max_ans<<endl;
}

Measured memory_bytes: 2048
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;
typedef long long ll;

int main(void)
{
    long long n, a, b;
    cin >> n >> a >> b;
    long long ans = 0;
    int pos = 0;
    REP(i, n)
    {
        int x;
        cin >> x;
        if (i == 0)
        {
            pos = x;
        }
        else
        {
            ans += min(a * (x - pos), b);
            pos = x;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>

using namespace std;

typedef long long ll;

ll powmod(ll a,ll b,ll m)
{
	if(!b) return 1;
	ll x=powmod(a,b/2,m); x=(x*x)%m;
	if(b&1) x=(x*a)%m;
	return x;
}

const int MOD=1e9+7;

int hash_naive(const string& s,int l,int r,const vector<int>& ps)
{
	int res=0;
	for(int i=l;i<r;i++)
		res=(res+(ll)s[i]*ps[i-l])%MOD;
	return res;
}

int main()
{
	const int P=20130830;
	const int Q=powmod(P,MOD-2,MOD);
	
	vector<int> ps(300000,1);
	for(int i=1;i<ps.size();i++)
		ps[i]=(ll)ps[i-1]*P%MOD;
	
	for(int n,m;cin>>n>>m && n|m;){
		string s; cin>>s;
		
		set<pair<int,int> > hs; // len,hash
		int l=0,r=1;
		int hash=s[0];
		while(m--){
			string t; cin>>t;
			if(t=="L++")
				hash=((ll)hash-s[l++]+MOD)%MOD*Q%MOD;
			if(t=="L--")
				hash=((ll)hash*P+s[--l])%MOD;
			if(t=="R++"){
				hash=(hash+(ll)s[r]*ps[r-l])%MOD;
				r++;
			}
			if(t=="R--"){
				r--;
				hash=(hash-(ll)s[r]*ps[r-l]%MOD+MOD)%MOD;
			}
			hs.insert(make_pair(r-l,hash));
		}
		
		cout<<hs.size()<<endl;
	}
}

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

int main() {
  int N;
  cin >> N;
  vector<int> V(N), C(N);
  for (int i=0; i<N; i++) {
    cin >> V[i];
  }
  for (int i=0; i<N; i++) {
    cin >> C[i];
  }
  
  int M=0;
  int m=0;
  for (int b=0; b<(1<<N); b++) {
    bitset<20> s(b);
    m=0;
    for (int i=0; i<N; i++) {
      if (s.test(i)) {
        m+=(V[i]-C[i]);
      }
    }
    M=max(M, m);
  }
  cout << M << endl;
}


Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<random>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

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

    string s;
    cin >> s;

    string ans = "Yes";
    if (s.length() % 2)ans = "No";
    else {
        SORT(s);
        for (int i = 0; i < s.length(); i += 2) {
            if (s[i] != s[i + 1])ans = "No";
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
using namespace std;
using namespace std::chrono;
 

signed main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);
  
  int n;
  cin >> n;
  Vi x[n], y[n];
  int a[n];
  int g, h;
  for (int i = 0; i < n; i++){
    cin >> a[i];
    for (int j = 0; j < a[i]; j++){
      cin >> g >> h;
      g--;
      x[i].pb(g);
      y[i].pb(h);
    }
  }

  int max_ = 0;
  for (int i = 0; i < pow(2, n); i++){
    bool d[n];
    int c = i;
    int ones = 0;

    for (int j = 0; j < n; j++)
      d[j] = c % 2, c /= 2, ones += d[j];

    bool compatible = true;
    for (int j = 0; j < n; j++){
      if (!d[j])
	continue;
      for (int r = 0; r < a[j]; r++){
	if (d[x[j][r]] != y[j][r]){
	  compatible = false;
	  break;
	}
      }
    }
    if (compatible)
      max_ = max(max_, ones);
  }
  cout << max_ << endl;
  
}


Measured memory_bytes: 512
function Main(input) {
	input = input.split("\n");
	var N = input[0];
	var arr = input[1].split(" ").map(Number);
	var ans = Number.MAX_SAFE_INTEGER;
	var max = Math.max.apply(null,arr);
	
		for(var i=1;i<=max;i++){
			var sum = 0;
			for(var j=0;j<arr.length;j++){
				sum += Math.pow(Math.abs(arr[j]-i),2);
			}
         // console.log(i,sum)
			if(sum<ans) ans = sum;
		}
console.log(ans);

}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 21064
x, y =map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
import math

N, K = map(int, input().split())

p = (N-(K-1)) / N
if p < 0:
    p = 0
k = K
single_p = 1 / 2

while k >= 1:
    half = k / 2
    case = min(math.ceil(k), N+1) - math.ceil(half)
    # print(p, single_p, k, case)
    if case > 0:
        p += case / N * single_p
    single_p /= 2
    k /= 2

print(p)


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

public class Program
{
    static void Main()
    {
        string s = Console.ReadLine();
        string[] str = { "dream", "dreamer", "eraser", "erase" };

        s = new string(s.Reverse().ToArray());
        for (int i = 0; i < str.Length; i++)
        {
            str[i] = new string(str[i].Reverse().ToArray());
        }
        bool ans = true;
        
        while(s.Length != 0)
        {
            bool flag = false;
            for (int j = 0; j < str.Length; j++)
            {
                if(s.Length >= str[j].Length && s.Substring(0,str[j].Length) == str[j])
                {
                    flag = true;
                    s = s.Remove(0, str[j].Length);
                }
            }
            
            if (!flag)
            {
                ans = false;
                break;
            }
        }

        Console.WriteLine(ans ? "YES" : "NO");
    }
}

Measured memory_bytes: 30876
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define ll long long
using namespace std;

int A[2222];
int minn[2222][2222];

int main() {
    int N;
    ll x;
    cin>>N>>x;
    
    ll answer = 0;
    for(int i=0;i<N;i++) {
        cin>>A[i];
        answer += A[i];
    }

    
    
    for(int i=0;i<N;i++) {
        for(int d=0;d<=N-1;d++) {
            if (d==0)
                minn[i][d]=A[i];
            else
                minn[i][d]=min(minn[i][d-1], A[(i-d+N)%N]);
        }
    }
    
    ll ans = -1;
    for(int ms=0;ms<=N-1;ms++) {
        ll curr = (ll)ms * x;
        for(int i=0;i<N;i++)
            curr += minn[i][ms];
        if (ans == -1 || ans > curr)
            ans = curr;
    }
    
    cout << ans << endl;
    
    
    
}

Measured memory_bytes: 17664
#include<cstdio>

int main(){
    int H,W;
    for(int i = 0;; i++){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0){
            break;
        }
        for(int j = 1; j <= H; j++){
            for(int k = 1; k <= W; k++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


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

int main(){
  int n,m;
  cin >>n>>m;
  int c[m];
  for(int i=0;i<m;i++){
    cin>>c[i];
  }
  int l[n+1][m];
  for(int i=0;i<=n;i++){
    for(int j=0;j<m;j++){
      if(i==0){
	l[i][j]=0;
      }else if(j==0){
	if(c[0]>i){
	  l[i][j]=i;
	}else{
	  l[i][j]=l[i-c[0]][j]+1;
	}
      }else if(c[j]>i){
	l[i][j]=l[i][j-1];
      }else{
	l[i][j]=min(l[i][j-1],l[i-c[j]][j]+1);
      }
    }
  }
  cout << l[n][m-1]<<endl;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end()
#define P pair<int , int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

#define MAX_N 2005
ll C[MAX_N][MAX_N];
void precalc(){
  for(ll i = 0 ; i < MAX_N ; i++)  C[i][0] = 1;
  for(ll i = 1; i < MAX_N ; i++){
    for(ll j = 1; j < MAX_N ; j++){
      C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
    }
  }
}
int main(void){
  ll n, k, r;
  cin >> n >> k >> r;
  r = n - k;
  precalc();
  for(ll i = 1; i <= k ; i++){
    ll ans = C[r + 1][i] * C[k - 1][i - 1] % MOD;
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 31616
#include <stdio.h>
#include<limits.h>
void MatrixChain( int );
#define MAX 100


int m[MAX][MAX];
int p[MAX];

int main(){
int n,i,SUB;

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

MatrixChain(n);
printf("%d\n",m[1][n]);

return 0;
}

void MatrixChain(int n){
int  i,j,k,l,o;
for(i=1;i<=n;i++)m[i][i]=0;
for(l=2;l<=n;l++){
for(i=1;i<=n-l+1;i++){
j=i+l-1;
m[i][j] = INT_MAX;
for(k=i;k<=j-1;k++){
o=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
if(o<m[i][j])m[i][j]=o;
}
}
}
}

Measured memory_bytes: 1860
fun main(args: Array<String>) {
    var nums=readLine()!!.split(" ").map { it.toInt() }
    if((nums[0]==nums[1] &&nums[0]!=nums[2]) || (nums[2]==nums[1] &&nums[0]!=nums[2]) || (nums[0]!=nums[1] &&nums[0]==nums[2])){
        println("Yes")
    }else{
        println("No")
    }


}

Measured memory_bytes: 37812
#include<stdio.h>
int main()
{
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  
  if(a/d>c/b) printf("Yes");
  if(a/d==c/b)
  {
  	if(a%d==0&&c%b!=0) printf("No");
  	else printf("Yes");
  }
  if(a/d==c/b-1)
  {
  	if(a%d!=0&&c%b==0) printf("Yes");
	else printf("No");  
  }
  if(a/d<c/b-1) printf("No");
  
  return 0;
}

Measured memory_bytes: 1708
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N; 
  cin >> N;

  vector<int> A(N+1);
  REP(i, N+1) cin >> A[i];

  vector<int> B(N);
  REP(i, N) cin >> B[i];

  int ans = 0;
  REP(i, N){
    int MIN = min(A[i], B[i]);
    ans += MIN;
    A[i] -= MIN; B[i] -= MIN;

    MIN = min(B[i], A[i+1]);
    ans += MIN;
    B[i] -= MIN; A[i+1] -= MIN;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <math.h>


int main(void)
{	
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	
	if(c>=a && c<=b){
		puts("Yes");
	} else{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		boolean ok = true;
		if(S[0] == S[1] && S[1] == S[2] && S[2] == S[3])
			ok = false;
		int[] Snum = new int[4];
		for(int i = 0; i < 4; i++) {
			for(int j = 0; j < 4; j++) {
				if(S[i] == S[j])
					Snum[i]++;
			}
		}
		for(int i = 0; i < 4; i++)
			if(Snum[i] != 2)
				ok = false;
		System.out.println(ok ? "Yes" : "No");

	}

}


Measured memory_bytes: 20564
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x;
	cin>>x;
	for(int i=-10;i<1000;i++){
		for(int j=-80;j<1000;j++){
			if(pow(i,5)-pow(j,5)==x) {
				cout<<i<<" "<<j<<endl;return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define vout(v) for(int i=0;i<(int)v.size()-1;i++){cout<<v[i]<<" ";}cout<<v[v.size()-1]<<"\n";
#define debg(a) cerr<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
vector <ll> dp;

const string YES = "Yes";
const string NO = "No";
#define judge(f) cout<<(f?YES:NO)<<"\n";

const ll dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const ll dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

bool check(long long H, long long W, std::vector<std::string> s, ll i, ll j){
    for (ll k = 0; k < 4; k++) {
        if(i+dy[k]<0 || i+dy[k]>=H || j+dx[k]<0 || j+dx[k]>=W) continue;
        if(s[i+dy[k]][j+dx[k]]=='#'){
            return true;
        }
    }
    return false;
}

void solve(long long H, long long W, std::vector<std::string> s){
    bool f = true;
    for (ll i = 0; i < H; i++) {
        for (ll j = 0; j < W; j++) {
            if(s[i][j]=='.') continue;
            f = check(H,W,s,i,j);
            if(f==true) continue;
            if(f==false) {judge(f);return;}
        }
    }
    judge(f);
    return;
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    std::vector<std::string> s(H);
    for(int i = 0 ; i < H ; i++){
        std::cin >> s[i];
    }
    solve(H, W, std::move(s));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL unsigned long long
#define MOD 1000000007
#define inf 1999999999



int main() {
	int n;
	cin >> n;
	bool flg = false;
	for (int i = 1; i < 10; i++)for (int j = 1; j < 10; j++)
		if (i*j == n)flg = true;
	cout << (flg ? "Yes" : "No") << endl;
	return 0;
}


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

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

  if((B-A)%2 == 0){
    cout << (B-A)/2 << endl;
  }else{
    cout << (B-A)/2 +1 +min(N-B,A-1) << endl;  
  }
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a;
set<ll>s;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        s.insert(a);
    }
    cout<<s.size()<<endl;
}


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

int main() {
int N;
cin >> N;
int a=1;
vector<int> vec(N);
  for(int i=0;i<N;i++){
	cin >>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  for(int i=1;i<N;i++){
    if(vec.at(i)<vec.at(i-1)){
      a++;
    }
  }
  cout <<a <<endl;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#define rep(i, n) for(int i = 0; i < (int)(n); 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 (b < a) { a = b; return 1; } return 0; }

int main()
{
	int A, B, count, socket;

	cin >> A >> B;
	count = 0;
	socket = A;

	if (B != 1) 
	{
		count++;
		while (socket < B)
		{
			socket += A - 1;
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256