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

typedef long long ll;
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
#define rep(i, n) for(int i = 0; i < n; i++)
#define fogg(i,a,b) for(int i = (a); i <= (b); i++)
#define ford(i,a,b) for(int i = (a); i >= (b); i--)
#define test int t; cin >> t; while(t--)
#define debug(x) cout << '>' << #x << ':' << x << "\n";
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second > b.second); 
} 

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 



int main() {
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> v;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        v.pb(mp(a,b));
    }
    sort(v.begin(),v.end());
    priority_queue <int> que;
    long long int ans=0;
    int j=0;
    for(int i=m-1;i>=0;i--){

        while(v[j].first+i==m && j<n){
            que.push(v[j].second);
            j++;
        }
        if(!que.empty()){
            ans+=que.top();
            que.pop();
        }

    }
    cout << ans;
return 0;
}

Measured memory_bytes: 1908
n, m = map(int, input().split())
s = [list(map(int, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))

cnt = 0
for i in range(2**n):
    for j in range(m):
        switch = 0
        for k in range(n):
            if (i >> k & 1) and k+1 in s[j]:
                switch += 1
        if switch % 2 != p[j]:
            break
    else:
        cnt += 1

print(cnt)


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

using namespace std;
using ll = long long;

int main(){
    int x, n;
    cin >> x >> n;
    set<int> p;
    rep(i, n) {
        int pi;
        cin >> pi;
        p.insert(pi);
    }
    int j = 0;
    while(true){
        if(!p.count(x-j)){
            cout << x-j << endl;
            return 0;
        }
        else if(!p.count(x+j)){
            cout << x+j << endl;
            return 0;
        }
        j++;
    }
    return 0;
}


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader in = new FastReader();
        int n = in.nextInt();
        int k = in.nextInt();
        int[] a = new int[n+1];
        for (int i=1;i<=n;i++)
            a[i] = in.nextInt();
        Arrays.sort(a);
        int sum = 0;
        for (int i=1;i<=k;i++)
            sum += a[i];
        System.out.println(sum);
    }
}

Measured memory_bytes: 33072
/*
   AOJ - ITP11_1_a
Date: 20181016
Author: Mikoron * ♡mikoiwate351♡
*/

#include<stdio.h>
#include<string.h>

#define CMAX 101
#define TOP 1
#define FRONT 2
#define RIGHT 3
#define LEFT 4
#define BACK 5
#define BOTTOM 6


typedef struct {
        short state;
        short suf[7];
} dice_state_t;

void show_state(dice_state_t *dice);
void change_state(dice_state_t *dice, char command);
void replace_y(dice_state_t *dice);
void replace_x(dice_state_t *dice);


int main(void) {

        char command[CMAX];
        short i;

        dice_state_t dice;
        dice.state = 1;

        scanf("%hd %hd %hd %hd %hd %hd", &dice.suf[TOP], &dice.suf[FRONT], &dice.suf[RIGHT], &dice.suf[LEFT], &dice.suf[BACK], &dice.suf[BOTTOM]);
        scanf("%s", command);

        for(i = 0; i < (short)strlen(command); i++) {
                change_state(&dice,command[i]);
        }
        show_state(&dice);

        return 0;
}

void show_state(dice_state_t *dice) {
        printf("%hd\n", dice->suf[dice->state]);
}


void change_state(dice_state_t *dice, char command) {
        short i;

        switch(command) {
                case 'N':
                        replace_y(dice);
                        break;
                case 'E':
                        replace_x(dice);
                        break;
                case 'S':
                        for(i = 0; i < 3; i++) replace_y(dice);
                        break;
                case 'W':
                        for(i = 0; i < 3; i++) replace_x(dice);
                        break;
        }

}

void replace_y(dice_state_t *dice) {
        short buf;

        buf = dice->suf[TOP];
        dice->suf[TOP] = dice->suf[FRONT]; // 1 -> 2
        dice->suf[FRONT] = dice->suf[BOTTOM]; // 2 -> 6
        dice->suf[BOTTOM] = dice->suf[BACK]; // 6 -> 5
        dice->suf[BACK] = buf; // 5 -> 1
}


void replace_x(dice_state_t *dice) {
        short buf;

        buf = dice->suf[TOP];
        dice->suf[TOP] = dice->suf[LEFT]; // 1 -> 4
        dice->suf[LEFT] = dice->suf[BOTTOM]; // 4 -> 6
        dice->suf[BOTTOM] = dice->suf[RIGHT]; // 6 -> 3
        dice->suf[RIGHT] = buf; // 3 -> 1
}



Measured memory_bytes: 2140
k = int(input())

import queue

que = queue.Queue()

for i in range(1, 10):
    que.put(i)

for i in range(1, k + 1):
    ans = que.get()
    keta1 = ans % 10
    if keta1 == 0:
        append_list = [ans * 10, ans * 10 + 1]
    elif keta1 == 9:
        append_list = [ans * 10 + 8, ans * 10 + 9]
    else:
        append_list = [ans * 10 + keta1 - 1, ans * 10 + keta1, ans * 10 + keta1 + 1]
    for ite in append_list:
        que.put(ite)
print(ans)

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

long D[100000]={};
const long c = 998244353;

long mult(long d, long m){
  long mu = 1;
  for(long i=1; i<=m; i++){
    mu = (mu*d)%c;
  }
  return mu;
}

int main(){
  long N;
  cin >> N;
  long d; cin >> d;
  if(d!=0){
    cout << "0" << endl;
    return 0;
  }
  long max=0;
  for(long i=1; i<N; i++){
    cin >> d;
    if(d==0){
      cout << "0" << endl;
      return 0;
    }
    D[d]++;
    if(d>max) max=d;
  }
  for(long i=1; i<=max; i++){
    if(D[i]==0){
      cout << "0" << endl;
      return 0;
    }
  }
  long count=1;
  for(long i=2; i<=max; i++){
    count=(count*mult(D[i-1], D[i]))%c;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <utility>
#include <map>

int calcAnswer(std::multimap< int, int > &input, int money) {
    int sum = 0;
    for (std::multimap< int, int >::reverse_iterator itr = input.rbegin(); itr != input.rend(); itr++) {
        if (itr->second > money) {
            sum += itr->first * (itr->second - money);
            money = 0;
        } else {
            money -= itr->second;
        }
    }
    return sum;
}

int main(void) {
    while (1) {
        int n, m;
        std::cin >> n >> m;

        if (n == 0 && m == 0) {
            break;
        }

        std::multimap< int, int > input;

        for (int i = 0; i < n; i++) {
            int length, danger;
            std::cin >> length >> danger;
            input.insert(std::make_pair(danger, length));
        }

        std::cout << calcAnswer(input, m) << std::endl;
    }

    return 0;
}

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

int main(void) {
    char s[200*16];
    char *tok;
    int nn;
    int n[200] = {};
    int i = 0;
    int flag = 0;
    int loop = 0;
    scanf("%d", &nn);
    /* scanf("%s", s); */
    /* tok = strtok(s, " "); */
    /* while (tok != NULL) { */
    /*     n[i] = atoi(tok); */
    /*     i++; */
    /*     tok = strtok(NULL, " "); */
    /* } */
    for (i = 0; i < nn; i++) {
        scanf("%d", &n[i]);
    }

    while (1) {
        for (i = 0; i < nn; i++) {
            if (n[i]%2) {
                goto end;
            }
            n[i] /= 2;
        }
        loop++;
    }

 end:
    printf("%d\n", loop);
    return 0;
}


Measured memory_bytes: 128
S = input().strip()

def is_palindrome(S):
	N = len(S)
	H = N // 2
#	print(S, S[:H], "".join(reversed(S[N - H:])))
	if S[:H] != "".join(reversed(S[N - H:])):
		return False
	return True


def check(S):
	N = len(S)
	if not is_palindrome(S):
		return False
	if not is_palindrome(S[:(N - 1) // 2]):
		return False
	if not is_palindrome(S[(N + 3) // 2 - 1:]):
		return False
	return True

if check(S):
	print("Yes")
else:
	print("No")


Measured memory_bytes: 3060
#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 ROP(i, n)       for(int i = 1 ; i <= n ; i++)

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

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

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int a, b;  cin >> a >> b;
	if(a < b){  REP(i, b)  cout << a;  cout << endl;  }
	else     {  REP(i, a)  cout << b;  cout << endl;  }

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const int N = 2e5 + 10;
VI adj[N];

const ll mod = 1e9 + 7;

ll add(ll a, ll b) {
  return (a + b) % mod;
}
ll mul(ll a, ll b) {
  return a * b % mod;
}
ll pwr(ll a, ll n) {
  ll r = 1;
  for (; n > 0; n >>= 1) {
    if (n & 1) r = mul(r, a);
    a = mul(a, a);
  }
  return r;
}

ll fact[N], invf[N];
void prec() {
  fact[0] = invf[0] = 1;
  for (int i = 1; i < N; i++) {
    fact[i] = mul(fact[i - 1], i);
    invf[i] = pwr(fact[i], mod - 2);
  }
}
ll choose(int n, int r) {
  if (n < r || r < 0) return 0;
  return mul(fact[n], mul(invf[r], invf[n - r]));
}

int sz[N];
ll dp[N], ans[N];

void compute(int u, int p) {
  dp[u] = 1;
  sz[u] = 0;
  for (int v: adj[u]) {
    if (v == p) continue;
    compute(v, u);
    sz[u] += sz[v];
    dp[u] = mul(dp[u], choose(sz[u], sz[v]));
    dp[u] = mul(dp[u], dp[v]);
  }
  sz[u]++;
}
void solve(int u, int p, int n) {
  if (u == p) {
    ans[u] = dp[u];
  } else {
    ans[u] = ans[p];
    ans[u] = mul(ans[u], choose(n - 1, n - sz[u]));
    ll term = choose(n - 1, sz[u]);
    ans[u] = mul(ans[u], pwr(term, mod - 2));
  }

  for (int v: adj[u]) {
    if (v != p) solve(v, u, n);
  }
}

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  prec();

  int n; cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v; cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  compute(1, 1);
  solve(1, 1, n);
  for (int u = 1; u <= n; u++) {
    cout << ans[u] << '\n';
  }

  return 0;
}


Measured memory_bytes: 20980
s=input()
flag=False
s=s.upper()
for i in range(len(s)):
    if i%2==0:
        if s[i]=='L':
            flag=True
            break
    else:
      if s[i]=='R':
          flag=True
          break
if flag:
    print('No')
else:
   print('Yes')


Measured memory_bytes: 3064
/*
Á·Ï°Ìâ£ºConvenient Location_AOJ 0189 
*/

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;

const int MAX_V=17, INF=0x3f3f3f3f;

struct edge {
	int to, cost;
};
typedef pair<int, int> P;//ÀûÓÃfirst±íÊ¾×î¶Ì¾àÀë£¬second±íÊ¾¶¥µãµÄ±àºÅ 

vector<edge> G[MAX_V]; //ÏÂ±ê³äµ±from
int d[MAX_V];
int sum[MAX_V];

void dijkstra(int s)
{
	//°´ÕÕfirst´ÓÐ¡µ½´óË³ÐòÅÅÁÐ£¬ÏÈÈ¡³ö×î¶Ì¾àÀëºÍ¶ÔÓ¦µÄ¶¥µã 
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d+10, INF);
	d[s]=0;
	que.push(P(0,s));
	
	while(que.size()) //¸´ÔÓ¶ÈÎªO(|E|Xlog|V|) 
	{
		P p = que.top();
		que.pop();
		int v=p.second;
		if(d[v]<p.first)
			continue;
		for(int i=0; i<G[v].size(); i++)
		{
			edge e=G[v][i];
			if(d[e.to]>d[v]+e.cost)
			{
				d[e.to]=d[v]+e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}



int main()
{
	int E;
	while(scanf("%d", &E)!=EOF)
	{
		if(E==0)
			break;
		
		memset(sum, 0, sizeof(sum));
		for(int i=0; i<10; i++)
			G[i].clear();
		
		for(int i=0; i<E; i++)
		{
			int f,t,c;
			scanf("%d%d%d", &f, &t, &c);
			G[f].push_back((edge){t,c});
			G[t].push_back((edge){f,c});
		}
		
		for(int i=0; i<10; i++)
		{
			dijkstra(i);
			for(int j=0; j<10; j++)
			{
				if(d[j]!=INF)
					sum[i]+=d[j];
			}
		}
		
		int ans1, ans2=0x3f3f3f3f;
		for(int i=0; i<10; i++)
		{
			if(sum[i]!=0&&ans2>sum[i])
			{
				ans2=sum[i];
				ans1=i;
			}
		}
		
		printf("%d %d\n", ans1, ans2);
		
		
	}
	
	return 0;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int main(){
  int n;
  cin>>n;
  int a=n%10;
  n/=10;
  int b=n%10;
  int c=n/10;
  if(c*10+c>=b*10+a) cout<<c*100+c*10+c<<endl;
  else cout<<(c+1)*100+(c+1)*10+(c+1)<<endl;
}

Measured memory_bytes: 256
N = int(input())
S = input()
counter = []
num = 0
for s in S:
    if  s == 'I':
        num += 1
        counter.append(num)
    elif s == 'D':
        num -= 1
        counter.append(num)

arg_max = max(counter)
if arg_max <= 0:
    print(0)
else:
    print(arg_max)


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

int main(){
	string number;
	int sum;
	
	while(1){
		cin >> number;
		
		if(number == "0"){
			break;
		}
		
		sum = 0;
		for(int i = 0; i < number.size(); i++){
			sum += number[i] - '0';
		}
		
		cout << sum << endl;
	}
    return 0;
}

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

int main()
{
  int a, b, N, sum = 0;
  cin >> N;
  for (int i = 0; i < N; ++i)
  {
    cin >> a >> b;
    sum += b - a + 1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#light "off"
open System;;
open System.IO;;

let reader = new StreamReader(new BufferedStream(Console.OpenStandardInput ()))
let writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput ()))

let skipSpaces () = while reader.Peek () <= int ' ' do reader.Read () |> ignore done;;
let read f = skipSpaces (); [|while reader.Peek () > int ' ' do yield char (reader.Read ()) done |] |> System.String |> f;;
let readint () = skipSpaces (); let s = if reader.Peek() = int '-' then (ignore (reader.Read()); -1) else 1 in let mutable ans = 0 in while reader.Peek () > int ' ' do ans <- ans * 10 + (reader.Read () - int '0'); done; s * ans;;
let write (s : string) = writer.Write s;;
let writeln (s : string) = writer.WriteLine s;;

let S = read string;;
let N = S.Length;;

let mutable i = 0;;
let ans = Array.create N 0;;

while i < N do
  let j = i in
  i <- {i..N} |> Seq.find (fun i -> i = N || S.[i] <> 'R');
  let k = i in
  i <- {i..N} |> Seq.find (fun i -> i = N || S.[i] <> 'L');
  let a, b = k - j, i - k in
  ans.[k-1] <- ((a + 1) / 2 + b / 2);
  ans.[k] <- (a / 2 + (b + 1) / 2);
done;;

ans |> Array.map string |> String.concat " " |> writeln;;

reader.Close();;
writer.Close();;

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

int main() {
  int a;
  int b;
  int c;
  cin >> a >> b;
  c = (a % 2) * (b % 2);
  if (c == 1){
    cout << "Odd" << endl;
  }
  if (c == 0){
    cout << "Even" << endl;
  }
}

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

int main(){
    ll N; cin >> N;
    vector<double> p(N+10);
    for(int i=0;i<N;i++){
        cin >> p[i];
    }

    vector<vector<double> > dp(3030, vector<double>(3030) );
    dp[0][0] = 1;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N-i;j++){
            dp[i+1][j] += dp[i][j]*p[i+j];
            dp[i][j+1] += dp[i][j]*(1-p[i+j]);
        }
    }
    double ans = 0;
    for(int i=0;i<=N;i++){
        if(i>N-i) ans += dp[i][N-i];
    }
    cout << fixed << setprecision(10);
    cout << ans << endl;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll N;
  scanf("%lld", &N);

  ll negative_num = 0;

  ll sum = 0;
  ll m = 2LL << 32LL;
  vector<ll> list(N);
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    list[i] = abs(v);

    if (v < 0) {
      negative_num++;
    }

    m = min(m, abs(v));

    sum += abs(v);
  }

  ll ans;
  if (negative_num % 2 == 0) {
    ans = sum;
  } else {
    ans = sum - m * 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#include <cstdio>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef std::vector<int> VI;
typedef std::pair<int,int> P;
int read()
{
    int x=0,flag=1; char c=getchar();
    while((c>'9' || c<'0') && c!='-') c=getchar();
    if(c=='-') flag=0,c=getchar();
    while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return flag?x:-x;
}

const int maxn=3e5+5;
int nx[maxn],ny[maxn],n,m,N;
P xx[maxn],yy[maxn];
set<P> s;

int main()
{
    n=read(),m=read(); N=read();
    REP(i,1,N)
    {
        int x=read(),y=read();
        nx[x]++; ny[y]++;
        s.insert(P(x,y));
    }
    REP(i,1,n) xx[i]=P(nx[i],i);
    REP(i,1,m) yy[i]=P(ny[i],i);
    sort(xx+1,xx+n+1,greater<P>());
    sort(yy+1,yy+m+1,greater<P>());

    int maxx=xx[1].first,maxy=yy[1].first,flag=0;
    for(int i=1;xx[i].first==maxx;i++)
    {
        if(flag) break;
        for(int j=1;yy[j].first==maxy;j++)
        {
            if(!s.count(P(xx[i].second,yy[j].second)))
            {
                flag=1;
                break;
            }
        }
    }
    int ans=xx[1].first+yy[1].first;
    if(flag) cout<<ans;
    else cout<<ans-1;

    return 0;
}


Measured memory_bytes: 24716
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>

typedef long long ll;
using namespace std;

int main()
{
	int n;
	cin >> n;
	
    int a1[100005] = {};
	int m1 = 0;
	int p1 = 0;
	int a2[100005] = {};
	int m2 = 0;
	int p2 = 0;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		if (i % 2 == 0) {
			a1[tmp]++;
			if (a1[tmp] > m1) {
				m1 = a1[tmp];
				p1 = tmp;
			}
		}
		if (i % 2 == 1) {
			a2[tmp]++;
			if (a2[tmp] > m2) {
				m2 = a2[tmp];
				p2 = tmp;
			}
		}
	}
	if (p1 == p2) {
		int M1 = 0;
		int M2 = 0;
		for (int i = 0; i <= 100000; i++) {
			if (i == p1) continue;
			M1 = max(M1, a1[i]);
			M2 = max(M2, a2[i]);
		}
		cout << n - max(m1 + M2, m2 + M1) << endl;
	}
	else {
		cout << n / 2 - m1 + n / 2 - m2 << endl;
	}
	return 0;

}

Measured memory_bytes: 1024
def dp():
    n,w = map(int,input().split())
    lis = (map(int,input().split()) for i in range(n))
    
    dpp = [0] * (w + 1)
    for weight, value in lis:
        for j in range(w,weight-1,-1):
            dp = dpp[j-weight] + value
            if dpp[j] < dp:
                dpp[j] = dp
    return max(dpp)
print(dp())


Measured memory_bytes: 7668
#include<iostream>
#include<cstdio>
using namespace std;
long long n,k,a0,a1,ans;
int main()
{
	cin>>n>>k;
	ans=0;
	a1=0;
	for(int i=1;i<=n;i++)if(!(i%k))a1++;
	ans+=(a1*a1*a1);
	if(!(k&1))
	{
		a0=(k>>1);
		a1=0;
		for(int i=0;i<=(n-a0);i++)if(!(i%k))a1++;
	    ans+=(a1*a1*a1);
	}
	cout<<ans<<endl;
	return 0;
} 

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

int main()
{
    vector<pair<int, int>> times(5);
    for (size_t i = 0; i < 5; i++)
    {
        int time, remainder;
        cin >> time;
        remainder = time % 10;
        times[i] = make_pair(remainder, time);
    }
    sort(times.begin(), times.end());

    int ans = 0;
    bool waitFlg = false;
    for (size_t i = 0; i < 5; i++)
    {
        ans += times[i].second;
        if (times[i].first != 0)
        {
            if (waitFlg)
            {
                ans += 10 - times[i].first;
            }
            else
            {
                waitFlg = true;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    ll H,W;cin>>H>>W;
    if(H%3==0 or W%3==0)cout<<0<<endl;
    else{
        ll ans=min(H,W);
        ll a,b,c;
        for(ll i=0;i<H;i++){
            a=i*W;
            b=(H-i)*(W/2);
            c=H*W-a-b;
            if(a>b)swap(a,b);
            if(b>c)swap(b,c);
            if(a>b)swap(a,b);
            ans=min(ans,c-a);
        }
        for(ll i=0;i<W;i++){
            a=i*H;
            b=(W-i)*(H/2);
            c=H*W-a-b;
            if(a>b)swap(a,b);
            if(b>c)swap(b,c);
            if(a>b)swap(a,b);
            ans=min(ans,c-a);
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final long a = scanner.nextLong();
        final long b = scanner.nextLong();

        if(a == 0){
            System.out.println(get(b));
            return;
        }

        final long fa = get(a - 1);
        final long fb = get(b);
        System.out.println(fa ^ fb);
    }

    private static long get(final long a) {
        final long mod = a % 4;
        switch ((int) mod) {
            case 0:
                return a;
            case 1:
                return 1;
            case 2:
                return a ^ 1;
            case 3:
                return 0;
        }

        throw new RuntimeException();
    }
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll K;
    cin >> K;
    queue<ll> q;
    for (ll i = 1; i <= 9; ++i)
    {
        q.push(i);
    }
    ll count = 0;
    while(true)
    {
        ll num = q.front();
        q.pop();
        count++;
        if (count == K)
        {
            cout << num << endl;
            break;
        }
        ll res = num % 10;
        if (res - 1 >= 0)
        {
            q.push(10 * num + res - 1);
        }
        q.push(10 * num + res);
        if (res + 1 <= 9)
        {
            q.push(10 * num + res + 1);
        }
    }
}


Measured memory_bytes: 5136
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define F first
#define S second

int dp[100001][13];
int mod=1e9+7;

signed main(){
  string s;
  cin>>s;

  dp[0][0] = 1;

  r(i,s.size()){
    if(s[i]=='?'){
      r(j,13){
        r(k,10){
          int x=k;
          dp[i+1][(j*10+x)%13] += dp[i][j];
          dp[i+1][(j*10+x)%13] %= mod;
        }
      }
    }
    else{
      r(j,13){
        int x=s[i]-'0';
        dp[i+1][(j*10+x)%13] += dp[i][j];
        dp[i+1][(j*10+x)%13] %= mod;
      }
    }
  }

  cout<<dp[s.size()][5]<<endl;

}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    vector<int> a(n);
    for (auto i = 0; i < n; i++) cin >> a[i];

    int64_t ans = INT64_MAX;
    for (auto i = 0; i < (1 << n); i++) {
        if((int)bitset<16>(i).count() != k) continue;
        int64_t tmp = 0;
        int64_t prev_height = a[0];
        for (auto j = 1; j < n; j++) {
            if(i & (1 << j)) {
                if(prev_height + 1 < a[j]) prev_height = a[j];
                else {
                    prev_height++;
                    tmp += prev_height - a[j];
                }
            }
            else prev_height = max(prev_height, (int64_t)a[j]);
        }
        // cout << bitset<15>(i) << " " << tmp << " " << ans << endl;
        ans = min(ans, tmp);
    }


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	string a,b;
	cin >> a >> b;
	cout << b+a << endl; 
}

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

int main() {
 int A, B;
 cin >> A >> B;
 if (A == B)
   cout << "Draw" << endl;
 else if (A == 1)
   cout << "Alice" << endl;
 else if (B ==1)
   cout << "Bob" << endl;
 else if (A > B)
   cout << "Alice" << endl;
 else
   cout << "Bob" << endl;
}

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

void solve(){
    int n,k;
    cin>>n>>k;
    vector<int> mat(n);
    for(int &x:mat) cin>>x;
    vector<int> dp(n,INT_MAX);
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=1;j<=k;j++)
        if(i+j<n) dp[i+j]=min(dp[i+j],dp[i]+abs(mat[i]-mat[i+j]));
    }
    cout<<dp[n-1];
}

int main() {
	// your code goes here
	//freopen("inptmp0.txt","r",stdin);
	int T;
	
	//cin>>T;
	T=1;
	while(T--){
	    solve();
	}
	return 0;
}


Measured memory_bytes: 4040
#include<iostream>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if((x-r)<0||(x+r)>W){
        cout<<"No"<<endl;
    }else if((y-r)<0||(y+r)>H){
        cout<<"No"<<endl;
    }else if((x-r)>=0&&(x+r)<=W){
        if((y-r)>=0&&(y+r)<=H){ 
        cout<<"Yes"<<endl;    
        }
    }else{cout<<"No"<<endl;}
    
    return 0;
}


Measured memory_bytes: 3104
#include<stdio.h>

int main()
{
  int n,i,j,k,p,mini;  /* miniは最小値保存用 */
  int r[100],c[100],m[101],M[101][101];
  
  scanf("%d",&n);

  for(i=0;i<n;i++)
    scanf("%d%d",&r[i],&c[i]);

  m[0] = r[0];
  
  for(i=1;i<=n;i++)
    m[i] = c[i-1];

  n++;

  for(i=0;i<n;i++)
    M[i][i] = 0;
  
  for(p=2;p<n;p++) {
    for(i=1;i<n-p+1;i++) {
      j = i + p - 1;
      M[i][j] = 1000000000;
      for(k=i;k<=j-1;k++) {
	mini = M[i][k] + M[k+1][j] + m[i-1] * m[k] * m[j];
	if(mini < M[i][j])
	  M[i][j] = mini;
      }
    }
  }

  printf("%d\n",M[1][n-1]);

  return 0;
}



Measured memory_bytes: 2144
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    int h, w; cin >> h >> w;
    char table[h][w]; rep(i, h) rep(j, w) cin >> table[i][j];
    char ans[h][w];
    rep(i, h) rep(j, w) {
        int c = 0;
        rep(k, 8) {
            int ny = i + dy[k];
            int nx = j + dx[k];
            if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if (table[ny][nx] == '#') c++;
        }
        ans[i][j] = c + '0';
    }
    rep(i, h) rep(j, w) if (table[i][j] == '#') ans[i][j] = '#';
    rep(i, h) {
        rep(j, w) {cout << ans[i][j];}
        cout << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int M = scan.nextInt();
    int min = scan.nextInt();
    int max = scan.nextInt();
    for (int i = 1; i < M; i++) {
      int l = scan.nextInt();
      int r = scan.nextInt();
      if (l > min) {
        min = l;
      }
      if (r < max) {
        max = r;
      }
    }
    int result = max - min + 1;
    System.out.println(result > 0 ? result : 0);
  }
}


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

#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 all(x) (x).begin(),(x).end()
#define pb emplace_back

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '0') cnt++;
    }
    cout << min(cnt,(int)s.size()-cnt)*2 << endl;

    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <queue>
using namespace std;

int main(void){
	int i,j,k,n;
	string str;
	while(getline(cin,str)){
		for(i=0;i<str.size();i++){
		if('a' <= str[i] && str[i] <= 'z') str[i] -= 'a' - 'A';
		}
		cout << str << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
 
#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(x,b) (0<=(x)&&(x)<(b))
using namespace std;
 
int H, W;
int board[128][128];
char point;
 
void dfs(int y, int x){
  board[y][x] = '.';
  int dy[] = {0,-1,0,1}, dx[] = {-1,0,1,0};
  rep(i, 4){
    int ny = y + dy[i], nx = x + dx[i];
    if(BW(ny,H) && BW(nx, W) && board[ny][nx] == point)
      dfs(ny, nx);
  }
  return;
}
 
int main(){
  char in[128];
  while(scanf("%d%d", &H, &W) && H+W){
    rep(i, H){
      scanf("%s", in);
      rep(j, W) 
    board[i][j] = in[j];
    }
     
    int res = 0;
    rep(i, H) rep(j, W){
      if(board[i][j] != '.'){
    point = board[i][j];
    dfs(i, j);
    res++;
      }
    }
    printf("%d\n", res);
  }
  return 0;
}


Measured memory_bytes: 3928
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define clr(x,y) memset(x,y,sizeof(x))
#define in(a) a=read()
#define out(a) printf("%d\n",a)
inline ll read(){
    char c=getchar();ll f=1,x=0;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+(c-'0'),c=getchar();
    return x*f;
}
#define mod 1000000007
void MOD(int &x){if(x>=mod)x-=mod;}
#define maxn 100010
#define inf (1<<30)
int a[maxn];
int check(int x){
	int ans=0;
	while(x){
		ans++;x/=10;
	}
	return ans;
}
int main(){
	int n;
	in(n);
	int ans=0;
	FOR(i,1,n)
		if(check(i)%2==1)ans++;
	out(ans);
}

Measured memory_bytes: 256
#include <cstdio>
#define rep(i,j,k) for (i=j;i<=k;i++)
using namespace std;
const int N=1e5+5;
int n,u,v,i,j,x,End,l,r,q[N];
int En,fst[N],flg[N],dgr[N],nxt[N*2],to[N*2];
void add(int u,int v) {
	En++; nxt[En]=fst[u]; fst[u]=En; to[En]=v;
}
int fs(int x) {
	int j;
	for (j=fst[x];j;j=nxt[j])
		if (!flg[to[j]]) return to[j];
}
int main()
{
//	freopen("agress.in","r",stdin);
//	freopen("agress.out","w",stdout);
	scanf("%d",&n);
	rep(i,1,n-1)
	{
		scanf("%d%d",&u,&v);
		add(u,v); add(v,u);
		dgr[u]++; dgr[v]++;
	}
	rep(i,1,n)
		if (dgr[i]==1)
			q[++r]=i;
	for (l=1;l<=r;l++)
	{
		if (flg[q[l]]) continue;
		x=fs(q[l]);
		flg[x]=1;
		End=0;
		for (j=fst[x];j;j=nxt[j])
			if (!flg[to[j]] && dgr[to[j]]==1) End++,flg[to[j]]=1;
		if (End>1) {
			printf("First\n");
			return 0;
		}
		for (j=fst[x];j;j=nxt[j])
		if (!flg[to[j]])
		{
			dgr[to[j]]--;
			if (!dgr[to[j]]) {
				printf("First\n");
				return 0;
			}
			if (dgr[to[j]]==1) q[++r]=to[j];
		}
	}
	printf("Second\n");
	return 0;
}

Measured memory_bytes: 3072
N = int(input())
for i in range(N):
    Ball = list(map(int, input().split()))
    B = 0
    C = 0
    x = 'YES'
    for j in range(10):
        if B < Ball[j]:
            B = Ball[j]
        elif C < Ball[j]:
            C = Ball[j]
        else:
            x = 'NO'
    print(x)


Measured memory_bytes: 5588
////=====BIsmillahir Rahmanir Rahim =====////

/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
         Comilla University

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define fi 2*acos(0.0)
#define ee 2.71828
#define ll  long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define edl printf("\n")
#define infinity 1e16
#define mod 1000000007
#define cn continue
#define csprint1 printf("Case %lld: ", cs++)
#define csprint2 printf("Case %lld:\n", cs++)
#define sf(a) scanf("%lld", &a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define all(v) v.begin(),v.end()
#define pfn(a) printf("%lld\n",a)
#define pfs(a) printf("%lld ",a)

using namespace __gnu_pbds;
using namespace std;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<pl> vpi;
typedef vector<pl> vpl;
typedef tree<pair<ll, int> , null_type, less<pair<ll, int> >, rb_tree_tag, tree_order_statistics_node_update> ost;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a <<","<< spc;
    err(++it, args...);
    cout<<edl;
}
///Bit manipulation

bool checkbit(int mask,int bit){return mask & (1<<bit);}
int setbit(int mask,int bit){ return mask | (1<<bit) ; }
int clearbit(int mask,int bit){return mask & ~(1<<bit);}
int togglebit(int mask,int bit){return mask ^ (1<<bit);}
int bitno(int mask) {return (int)__builtin_popcount(mask);}

/*----------------------Graph Moves----------------*/
const int fx[]={+1,-1,+0,+0};
const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

///=====================================///

const int  maX=1e5+10;
ll M = 10000007;
int main() {
    ll n,k;sff(n,k);
    ll ara[n];
    for(ll i=0;i<n;i++)sf(ara[i]);
    ll sum=0;
    ll dp[maX];
    dp[n-1]=0;
    for(ll i=n-2;i>=0;i--){
        dp[i]=infinity;
        //cout<<i<<spc;
        for(ll j=1;j<=k;j++){
            if(i+j>=n)continue;
            dp[i]=min(dp[i],dp[i+j]+abs(ara[i]-ara[i+j]));
           // cout<<dp[i]<<spc;
        }
       // edl;
    }
    pfn(dp[0]);
return 0;
}


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

int main() {
  string s,t="LRUD";
  cin >> s;
  int even=0,odd=0;
  for(int i=0;i<s.size();i++){
  	if(i%2==0){
      if(s.at(i)=='R' ||
         s.at(i)=='U' ||
         s.at(i)=='D'   ){
        even++;
      }
    }else{
      if(s.at(i)=='L' ||
         s.at(i)=='U' ||
         s.at(i)=='D'   ){
      	 odd++;
      }
    }
  }
    if(even+odd == s.size()){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int k; // 3
	int x; // 7
	int a; 
	
	int i;
	
	scanf("%d", &k);
	scanf("%d", &x);
	
	a = k--;
	for (i = 0; i < (a * 2) - 1; i++) {
		printf("%d ", x + i - k);
	}
	return (0);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(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 INF = 1e18;
#define foreach(ix,a) for(auto& (ix) : (a)) 
vl edge[220000];
ll seen[110000];
ll sizee[220000];
int n;
void dfs(string v,char a){    
    if(v.length()==n)cout<<v<<endl;
    else{ for(char x ='a';x<=a;x++){
        string s =v+x;
        char v= x+1;
        dfs(s,max(a,v));
    }}
}
int main(){
   cin>>n;
   dfs("",'a');
}

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

struct UnionFind{
	vector<int> par;
	vector<int> sizes;
	UnionFind(int n):par(n),sizes(n,1){
		for(int i=0;i<n;i++)par[i] = i;
	}
	int find(int x){
		if(x == par[x])return x;
		return par[x] = find(par[x]);
	}
	void unite(int x,int y){
		x = find(x);y = find(y);
		if(x == y)return;
		if(sizes[x] < sizes[y])swap(x,y);
		par[y] = x;
		sizes[x] += sizes[y];
	}
	bool same(int x,int y){
		return find(x) == find(y);
	}
	int size(int x){
		return sizes[find(x)];
	}
};

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

	vector<vector<int>> L(N);
	UnionFind uf(M+1);

	for(int i=0;i<N;i++){
		int K;cin >> K;
		int ol = -1;
		for(int j=0;j<K;j++){
			int l;cin >> l;
			if(j == 0)ol = l;
			L[i].push_back(l);

			uf.unite( l, ol);
		}
	}

	// vector<set<int>> st(M+1);
	// for(int i=1;i<=M;i++){
	// 	st[uf.find(i)].insert(i);
	// }

	set<int> st;
	bool ok = true;
	for(int i=0;i<N;i++){
		if( i == 0 )for(int j=0;j<L[i].size();j++){
			st.insert( uf.find(L[i][j]) );
		}else{
			bool tmp = false;
			for(int j=0;j<L[i].size();j++){
				if( st.find(uf.find( L[i][j])) != st.end() )tmp = true;
			}
			if(!tmp)ok = false;
		}
	}
	cout << (ok ? "YES" : "NO") << endl;
	return 0;
}

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

using namespace std;

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

#define pii pair<int, int>
#define mp make_pair

typedef long long ll;

const int N = 1e5 + 100;
int a[N];


int main()
{
	USE_IOSTREAM;
	
	int n, sum, i;
	
	cin >> n >> sum;

	for (i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	
	ll ans = 0;
	if (a[1] > sum)
	{
		ans += a[1] - sum;
		a[1] = sum;
	}
	for (i = 2; i <= n; i++)
	{
		if (a[i] + a[i - 1] > sum)
		{
			ans += a[i] + a[i - 1] - sum;
			a[i] = sum - a[i - 1];
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
s = input()
N = len(s)

j = N-1
xi = 0
xj = 0
res = 0
for i in range(N):
    if s[i] == 'x':
        xi += 1
        continue
    while j>=i:
        if s[j] == 'x':
            xj += 1
            j -= 1
            continue

        if s[i] != s[j]:
            print(-1)
            exit()
        res += abs(xj-xi)
        j -= 1
        break
    xi = xj = 0
print(res)

Measured memory_bytes: 9200
#include <cstdio>
#include <utility>
#include <vector>

using namespace std;

int main ()
{
  int n, x;
  vector<int> data(100);

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    data.insert(data.begin(), x);
  }

  for (int i = 0; i < n; i++) {
    if (i == n - 1) {
      printf("%d\n", data[i]);
    } else {
      printf("%d ", data[i]);
    }
  }

  return 0;
}

Measured memory_bytes: 2788
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e12;
int N = 5 + 1e5;


int main()
{
	string s, t;
	int a, b;
	cin >> s >> t >> a >> b;
	string u; cin >> u;
	if (u == s) a--;
	if (u == t) b--;
	cout << a <<" "<< b;
}

Measured memory_bytes: 3596
a,b,c,d=[int(x) for x in input().split()]
def gauss(n1,n2):
    if n1-n2>=0:
        return n1-n2
    else:
        return n2-n1
if gauss(a,c)<=d or (gauss(a,b)<=d and gauss(b,c)<=d):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
/*
time:
wa:
反省:
考察:
*/
int main() {
    int a[4], b[4];
    int c[5] = {0};
    int c1 = 0, c2 = 0;
    for(int i = 0; i < 3; i++) {
        cin >> a[i] >> b[i];
        c[a[i]]++;
        c[b[i]]++;
    }
    for(int i = 1; i <= 4; i++){
        if(c[i] == 1) c1++;
        else if(c[i] == 2) c2++;
    }
    if(c1 == 2 && c2 == 2) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner scn = new Scanner(System.in);
    int D = scn.nextInt();
    int T = scn.nextInt();
    int S = scn.nextInt();
    
//    System.out.println(D);
//    System.out.println(T);
//    System.out.println(S);
  	
    if ((T * S) < D) {
      System.out.println("No");
    } else {
      System.out.println("Yes");
    }
  }
}

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

long long int gcd(long long int a, long long int b){
    return b ? gcd(b,a%b) : a;
}

ll lcm(ll a, ll b){
    return a / gcd(a,b) * b;
}

int main(){
    ll a,b;
    cin >> a >> b;

    cout << lcm(a,b) << endl;
    return 0;
}   

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

#define FOR(i,a,b) for(int i=(a);i<(b);++(i))
#define REP(i,n) FOR(i,0,n)

#define dump(x) cerr << #x << " = " <<(x)<<endl;
#define debug(x) cerr << #x << " = " <<(x) << "(L" << __LINE__ << ")" << __FILE__ << endl;

#define BIT_ON(x,b) ((x)|=(b))
#define BIT_OFF(x,b) ((x)&=~(b))
#define BIT_IS_ON(x,b) (((x)&(b))==(b))


using namespace std;

int main(void){
  string s;
  cin >> s;
  s[3] = 56;
  cout << s << endl;;
  return 0;
}



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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader bf = null;
		bf = new BufferedReader(new InputStreamReader(System.in));
		int A,B,C,ans = 0;
		String str = bf.readLine();
		String[] strarr = str.split(" ");
		A = Integer.parseInt(strarr[0]);
		B = Integer.parseInt(strarr[1]);
		C = Integer.parseInt(strarr[2]);
		if(A + B + 1 >= C) {
			ans = B + C;
		} else {
			ans = A + 2*B + 1;
		}
		System.out.println(ans);
	}
}

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

int main()
{
  int k,a,b;
  cin>>k>>a>>b;
  for(int i=a;i<=b;i++)
    if(i%k==0)
    {
      cout<<"OK";
      return 0;
    }
  cout<<"NG";
  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a[3],i;
	for(i=0;i<3;i++)
		cin>>a[i];
	sort(a,a+3);
	if(a[0]==a[1]&&a[1]!=a[2])
		cout<<"Yes";
	else if(a[1]==a[2]&&a[0]!=a[1])
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int b,x=1,y=0,vy=0,z=0;
    cin>>b>>b;
    int c[b],d[b],vz=b;
    for(int i=0;i<b;i++){
        cin>>c[i]>>d[i];
        if(y<c[i]) y=c[i];
    }
    while(1){
        vy=y;
        y=0;
        for(int i=0;i<vz;i++){
            if(vy>=d[i]){
                c[z]=c[i];
                d[z]=d[i];
                if(y<c[i]) y=c[i];
                z++;
            }
        }
        if(z) x++;
        else break;
        vz=z;
        z=0;
    }
    cout<<x<<endl;
}


Measured memory_bytes: 1024
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e3 + 10;
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	cout << string(m + 2, '#') << endl;
	while (n--)
	{
		string str;
		cin >> str;
		cout << "#" << str << '#' << endl;
	}
	cout << string(m + 2, '#') << endl;

	return 0;
}

Measured memory_bytes: 256
#! /usr/bin/env python3

# from fractions import gcd
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

N = int(input())
A = [int(_) for _ in input().split()]

c = Counter(A)
for i in range(1, N+1):
    if c[i]:
        print(c[i])
    else:
        print(0)

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

void dfs(ll x, ll p, vector<ll>&par, vector<ll>&vis, vector<vector<ll>>&g, vector<vector<bool>>&ed)
{
	vis[x]=1;
	par[x]=p;
	for(ll y : g[x])
	{
		if(vis[y]==1)
		{
			set<ll>cyc;
			ll cur=x;
			while(cur!=y)
			{
				cyc.insert(cur);
				cur=par[cur];
			}
			cyc.insert(cur);
			bool ok=1;
			// only el of set
			ll n=g.size()-1;
			for(ll z : cyc)
			{
				ll cnt=0;
				for(ll i=1; i<=n; i++) if(cyc.count(i)) cnt+=ed[z][i];
				if(cnt>1) {ok=0; break;}
			}
			if(ok)
			{
				cout<<cyc.size()<<endl;
				for(ll z : cyc) cout<<z<<endl;
				exit(0);
			}
		}
		else 
		{
			dfs(y, x, par, vis, g, ed);
		}
	}
	vis[x]=2;
}

void solve()  
{
	ll n, m; cin>>n>>m;
	vector<vector<ll>>g(n + 1);
	vector<vector<bool>>ed(n+1, vector<bool>(n+1, 0));
	for(ll i=0; i<m; i++) { ll x, y; cin>>x>>y; g[x].push_back(y); ed[x][y]=1; }
	vector<ll>par(n+1);
	vector<ll>vis(n+1, 0);
	for(ll i=1; i<=n; i++) if(vis[i]==0) { vis[i]=1; dfs(i, i, par, vis, g, ed); }
	cout<<-1<<endl;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
	ll T = 1;
	//cin>>T; 
	while(T--)
	    solve();
	return 0;
}


Measured memory_bytes: 768