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

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}

// 空のベクトルを二つ渡す。N (>=2) 以下の素数を primes に順番に入れる。
void prime_vectors(int N, vector<int>& primes, vector<bool>& is_prime){
    primes = {};
    is_prime = {};
    for(int i=0; i<=N; i++){
        is_prime.push_back(true);
    }

    primes.push_back(2);
    for(int j=4; j<=N; j+=2){
        is_prime[j] = false;
    }

    int i;
    for(i=3; i*i<=N; i+=2){
        if(!is_prime[i]) continue;
        primes.push_back(i);
        for(int j=2*i; j<=N; j+=i){
            is_prime[j] = false;
        }
    }

    for(; i<=N; i+=2){
        if(is_prime[i]){
            primes.push_back(i);
        }
    }
}

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n;
    cin >> n;
    vector<vector<int>> e(n);
    for(int i=0; i<n; i++){
        int u, k;
        cin >> u >> k;
        for(int j=0; j<k; j++){
            int v;
            cin >> v;
            e[i].push_back(v-1);
        }
    }

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

    queue<int> q;
    q.push(0);
    d[0] = 0;
    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(int i=0; i<e[v].size(); i++){
            if(d[e[v][i]] == -1){
                d[e[v][i]] = d[v] + 1;
                q.push(e[v][i]);
            }
        }
    }

    for(int i=0; i<n; i++){
        cout << i+1 << " " << d[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m,x,y,maxx,miny;
  cin>>n>>m>>x>>y;
  vector<int> vecx(n+1);
  vector<int> vecy(m+1);
  vecx.at(0)=x;  vecy.at(0)=y;
  
  for (int i = 0; i < n; i++) {
    cin>>vecx.at(i+1);
  }
    
  for (int i = 0; i < m; i++) {
        cin>>vecy.at(i+1);
  }
  maxx=*max_element(vecx.begin(),vecx.end());
  miny=*min_element(vecy.begin(),vecy.end());
  //cout<<maxx<<miny;
    
  
  if(maxx<miny){
    cout<<"No War";}
    else{cout<<"War";}
  
  
}
  

Measured memory_bytes: 256
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, A, B] = [long(input_raw[0]), long(input_raw[1]), long(input_raw[2])]
    print min(A, B), max(0, (A+B) - N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll x;
	cin >> x;
	ll ans = ll(x / 11) * 2;
	x %= 11;
	if (x <= 6 && x >= 1) ans++;
	if (x > 6) ans += 2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        P: i64,
        Q: i64,
        R: i64,
    }

    let times: Vec<i64> = vec![P, Q, R];

    let mut ans = std::i64::MAX;
    for i in 0..3 {
        for j in i + 1..3 {
            let t = times[i] + times[j];
            ans = min(ans, t);
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2088
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b, sum=0;
    cin >> a >> b;

    for(int i=0; i<2; i++){
        if(a < b){
            sum += b;
            b--;
        }
        else{
            sum += a;
            a--;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const int MOD = 1e9 + 7;
using namespace std;
typedef long long ll;

map<ll, int> mp;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll n, m;
	cin >> n >> m;
	if (2 * n <= m) {
		cout << n + (m - (2 * n)) / 4 << endl;
	}
	else {
		cout << m / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
nums = [int(x) for x in input().split()]
sx,sy,tx,ty = nums[0],nums[1],nums[2],nums[3]

dx = tx - sx
dy = ty - sy
ans = []
# 1th
for i in range(dy):
    ans.append("U")
for i in range(dx):
    ans.append("R")
# 2nd
for i in range(dy):
    ans.append("D")
for i in range(dx):
    ans.append("L")
# 3rd
ans.append("L")
for i in range(dy+1):
    ans.append("U")
for i in range(dx+1):
    ans.append("R")
ans.append("D")
# 4th
ans.append("R")
for i in range(dy+1):
    ans.append("D")
for i in range(dx+1):
    ans.append("L")
ans.append("U")

print("".join(ans))


Measured memory_bytes: 3192
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
flag=True
count=0
for i in range(h):
  if flag==False:
    break
  for j in range(w):
    if flag==False:
      break
    flag2=False
    if s[i][j]=="#":
      if i>0 and s[i-1][j]!="#":
        flag=False
      elif i>0 and s[i-1][j]=="#":
        flag2=True
        
      if i<(h-1) and s[i+1][j]!="#":
        flag=False
      elif i<(h-1) and s[i+1][j]=="#":
        flag2=True
        
      if j>0 and s[i][j-1]!="#":
        flag=False
      elif j>0 and s[i][j-1]=="#":
        flag2=True
      
      if j<(w-1) and s[i][j+1]!="#":
        flag=False
      elif j<(w-1) and s[i][j+1]=="#":
        flag2=True
      if flag2:
        flag=True
    else:
      count+=1
        
if h==1 and w==1:
  if s[0][0]=="#":
    flag=False
    
if count==(h*w):
  flag=True
  
if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
   
    ll n,i=0,j;
    cin>>n;
    string s;
    cin>>s;
    while(s[i]=='R' and i<n) i++;
    while(s[i]=='W' and i<n) i++;
    if(i==n) cout<<"0";
    else
    {

    	ll cn=0;
    	i = n-1;
    	while(s[i]=='W' and i>=0) i--;
        ll k = i;

    	for(j=0;j<=i;j++)
    	{
    		if(s[j]=='R') continue;
    		if(k<=j) break;
    		while(s[k]=='W' and k>j) k--;
    		
    		if(s[k]=='R')
    		{
    			cn++;
    			k--;
    		}
    		else break;
    	}
    	cout<<cn;
    	
    }
}

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

using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
#define rep(pos, len) for(int pos=0;pos<len;pos++)
#define repp(pos, len) for(int pos=1;pos<=len;pos++)
 
#define INF 1987654321
#define IINF 87654321987654321
#define MOD 1000000007

int main() {
	string s;
	cin >> s;
	if(s == "SAT")
		cout << 1;
	else if(s == "FRI")
		cout << 2;
	else if(s == "THU")
		cout << 3;
	else if(s == "WED")
		cout << 4;
	else if(s == "TUE")
		cout << 5;
	else if(s == "MON")
		cout << 6;
	else
		cout << 7;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
S = [[] for _ in range(n)]
pe = [0] * n
co = [0] * n
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    S[p] += [s]
for i, s_ in enumerate(S):
    if all(j == 'WA' for j in s_):
        continue
    for s in s_:
        if s == 'AC':
            co[i] = 1
            break
        else:
            pe[i] += 1
print(sum(co), sum(pe))


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

using namespace std;

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

#define print(a) {for(auto xxxxx : (a)) cout << xxxxx << ' '; cout << '\n';}
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin() , (a).end()
#define rall(a) (a).rbegin() , (a).rend()

ll next(){ll x; cin >> x;return x;}
const int maxn = 2e5 + 2 , intf = 2e9;
const ll inf = 2e18 , mod = 1e9 + 7;
const ld eps = 1e-9;


void solve(){
    int x , a , y , b , c;
    cin >> x >> y >> a >> b >> c;
    vector <int> p(a) , q(b) , r(c);
    for (auto &x : p)
        cin >> x;
    for (auto &x : q)
        cin >> x;
    for (auto &x : r)
        cin >> x;

    sort(rall(p));
    sort(rall(q));
    sort(rall(r));

    vector <int> lst;
    for (int i = 0; i < a && i < x; i ++){
        lst.pb(p[i]);
    }
    for (int i = 0; i < b && i < y; i ++){
        lst.pb(q[i]);
    }
    for (int i = 0; i < c; i ++){
        lst.pb(r[i]);
    }
    sort(rall(lst));
    ll ans = 0;
    for (int i = 0; i < x + y && i < lst.size(); i ++){
        ans += lst[i];
    }
    cout << ans;
}


signed main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(20);
    
    for (int t = 1; t--;) solve();

	return 0;
}
/*


*/



Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll a,b; cin>>a>>b;
    if(a*b<=0) cout<<"Zero"<<endl;
    else if(a>0 || (b-a+1)%2==0) cout<<"Positive"<<endl;
    else if(a<0 && (b-a+1)%2!=0) cout<<"Negative"<<endl;
    return 0;
}

Measured memory_bytes: 3504
#include <bits/stdc++.h>
using namespace std;
//*******************
// Mahmoud Magdy    *
//*******************
#define ll long long
#define endl "\n"

void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m ;
    cin>>m;
    return m ;
}
int main()
{
int x=D(),t=D();
if(t>=x)
    cout<<"0"<<endl;
else
    cout<<abs(t-x)<<endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
const int N=2e5+5;
struct edge{int to,nxt,w;}a[N<<2];
int n,S,T,head[N],cnt=1,dep[N],q[N],hd,tl,cur[N],fa[N],son[N];
vector<int>E[N];
void link(int u,int v){
	a[++cnt]=(edge){v,head[u],1};head[u]=cnt;
	a[++cnt]=(edge){u,head[v],0};head[v]=cnt;
}
bool bfs(){
	memset(dep,0,sizeof(dep));
	dep[q[hd=tl=1]=S]=1;
	while(hd<=tl)
		for(int u=q[hd++],e=head[u];e;e=a[e].nxt)
			if(a[e].w&&!dep[a[e].to]){
				dep[q[++tl]=a[e].to]=dep[u]+1;
				if(a[e].to==T)return true;
			}
	return false;
}
int dfs(int u,int f){
	if(u==T)return f;int res=0;
	for(int &e=cur[u];e;e=a[e].nxt)
		if(a[e].w&&dep[a[e].to]==dep[u]+1){
			int d=dfs(a[e].to,min(a[e].w,f));
			a[e].w-=d;a[e^1].w+=d;f-=d;res+=d;
			if(!f)break;
		}
	if(!res)dep[u]=0;return res;
}
int dinic(){
	int res=0;
	while(bfs())memcpy(cur,head,sizeof(cur)),res+=dfs(S,1<<30);
	return res;
}
int main(){
	scanf("%d",&n);S=n+n-1;T=S+1;
	for(int i=1,x,y;i<n;++i){
		scanf("%d",&x);
		link(S,i);link(i+n-1,T);
		while(x--){
			scanf("%d",&y);
			if(y>1)link(i,y+n-2);
			E[y].push_back(i);
		}
	}
	if(dinic()!=n-1)return puts("-1"),0;
	for(int i=1;i<n;++i)
		for(int e=head[i];e;e=a[e].nxt)
			if(!a[e].w)
				son[i]=a[e].to-n+2;
	q[hd=tl=1]=1;
	while(hd<=tl){
		int u=q[hd++];
		for(int i:E[u])
			if(!fa[i])
				fa[i]=u,q[++tl]=son[i];
	}
	for(int i=1;i<n;++i)printf("%d %d\n",fa[i],son[i]);
	return 0;
}


Measured memory_bytes: 23808
#include <iostream>
using namespace std;
#define MAX 1010
int main(void){
    int n,s[MAX],p[MAX],q[MAX],r[MAX],c[MAX],P,Q,R,C,sum; //食べていいお菓子の数sum

    while(true){
        cin >> n;
    
        if(n==0) break;

        for(int i=0;i<n;i++){
            cin >> s[i] >> p[i] >> q[i] >> r[i];
            c[i]=p[i]*4+q[i]*9+r[i]*4;
        }
        cin >> P >> Q >> R >> C;
         
        sum=0;
        
        for(int i=0;i<n;i++){
            if(p[i]<=P&&q[i]<=Q&&r[i]<=R&&c[i]<=C){
                sum +=1;
                cout << s[i]<< endl; 
            }
        }
        if(sum==0)
                cout << "NA" << endl;
    }
}



Measured memory_bytes: 3116
#!/usr/bin/env fsharpi

open System;

let readIntN ( str : string ) =
    str.Split(' ')
    |> Array.map System.Int32.Parse

let readInt1 ( str : string ) =
    readIntN str |> fun arr -> arr.[0]

let readInt2 ( str : string ) =
    readIntN str |> fun arr -> (arr.[0],arr.[1])

let readInt3 ( str : string ) =
    readIntN str |> fun arr -> (arr.[0],arr.[1],arr.[2])

let (k,s) = readInt2 <| Console.ReadLine()
seq{ for i = 0 to k do
        for j = 0 to k do
            yield (i,j) }
|> Seq.filter (fun (x,y) -> s - x - y <= k && 0 <= s - x - y)
|> fun s -> (sprintf "%d" ( Seq.length s ) )
|> Console.WriteLine



Measured memory_bytes: 18224
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, k, r, s, p, ans = 0;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    vector<bool> win(n, false);
    for(int i = 0; i < n; i++){
        if(i >= k && win[i - k] && t[i - k] == t[i]){
            continue;
        }
        win[i] = true;
        switch (t[i]){
        case 'r':
            ans += p;
            break;
        case 's':
            ans += r;
            break;
        case 'p':
            ans += s;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=nxt[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)
using namespace std;
inline int read()
{
	char ch=getchar();int ret=0,f=1;
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

inline void print(string name,int *arr,int len){
	rep(i,1,len) printf("%s[%d]=%d\n",name.c_str(),i,arr[i]);puts("");
}
inline void print(string name,int a){
	printf("%s=%d\n",name.c_str(),a);puts("");
}

typedef long long ll;
const int INF=1<<30;

int main()
{
	int a,b;cin>>a>>b;
	rep(i,-a+1,a-1) printf("%d ",i+b);
	return 0;
}


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

int main() {
  int X, N;
  cin >> X >> N;
  vector<int> p(N), excluded_p;
  for (int i = 0; i < N; i++) cin >> p.at(i);
  sort(p.begin(), p.end());
  for (int i = 0; i <= 101; i++) {
    if (!binary_search(p.begin(), p.end(), i)) excluded_p.push_back(i);
  }
  int minimum = 0xff;
  int chosen = 0xff;
  for (auto x : excluded_p) {
    int y = abs(X - x);
    if (minimum > y) minimum = y, chosen = x;
  }
  cout << chosen << endl;
}

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

int main()
{
    int n = 0 ;
    int m = 0 ;
    int k = 0 ;
    int card[200] = {0} ;

    for (int i = 1 ;i <= 200 ;i++ )
    {
        card[i - 1] = i ;
    }

    cin >> n >> m ;

    for (int i = 0 ;i < m ;i++ )
    {
        scanf("%d" ,&k ) ;

        if (k == 0)
        {
            int mem[200] = {0} ;
            int flg = 0 ;
            for (int j = 0 ;j < 2 * n ;j++ )
            {
                if ((j % 2) == 0)
                {
                    mem[j] = card[flg] ;
                    //cout << "[debug:mem[" << j << "] = " << mem[j] << "]" << endl ;
                    //cout << "[debug:card[" << flg << "] = " << card[flg] << "]" << endl ;
                }
                else if ((j % 2) == 1)
                {
                    mem[j] = card[n + flg] ;
                    //cout << "[debug:mem[" << j << "] = " << mem[j] << "]" << endl ;
                    //cout << "[debug:card[" << n+flg << "] = " << card[n+flg] << "]" << endl ;
                    flg++ ;
                    //cout << "[debug:flg = " << flg << "]" << endl ;
                }
            }
            memset(card ,0 ,sizeof(card) ) ;
            memcpy(card ,mem ,sizeof(mem) ) ;
        }
        else
        {
            int mem[200] = {0} ;

            for (int j = k ;j < 2 * n ;j++ )
            {
                mem[j - k] = card[j] ;
                //cout << "[debug:mem[" << j-k << "] = " << mem[j-k] << "]" << endl ;
                //cout << "[debug:card[" << j << "] = " << card[j] << "]" << endl ;
            }
            for (int j = 0 ;j < k ;j++ )
            {
                mem[j + ((2 * n) - k)] = card[j] ;
                //cout << "[debug:mem[" << j+((2*n)-k) << "] = " << mem[j+((2*n)-k)] << "]" << endl ;
                //cout << "[debug:card[" << j << "] = " << card[j] << "]" << endl ;
            }
            memset(card ,0 ,sizeof(card) ) ;
            memcpy(card ,mem ,sizeof(mem) ) ;
        }

        for (int i = 0 ;i < 2 * n ;i++ )
        {
            //cout << "[debug:card[" << i << "] = " << card[i] << "]" << endl ;
        }
    }

    for (int i = 0 ;i < 2 * n ;i++ )
    {
        cout << card[i] << endl ;
    }

    return 0 ;
}

Measured memory_bytes: 3096
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 
 using namespace std;
 
 const int MAX_V=500+5;
 const int INF=1000000000;
 
 int graph[MAX_V][MAX_V];
 int mincost[MAX_V];
 bool used[MAX_V];
 int V,m;
 
 int prim()
 {
   for(int i=0;i<V;i++)
   {
     mincost[i]=INF;
     used[i]=false;        
   }    
   mincost[0]=0;
   int res=0;
   while(true)
   {
     int v=-1;
     for(int u=0;u<V;u++)
     {
       if(!used[u]&&(v==-1||mincost[u]<mincost[v])) v=u;        
     }           
     if(v==-1) break;
     used[v]=true;
     res+=mincost[v];
     for(int u=0;u<V;u++)
     {
       mincost[u]=min(mincost[u],graph[u][v]);        
     }
   }
   return res;
 }
 
 int main()
 {
   while(cin>>V&&V&&cin>>m)
   {
     int p,q,d;
     char temp1,temp2;
     for(int i=0;i<V;i++)
     {
       for(int j=0;j<V;j++)
       {
         graph[i][j]=INF;        
       }        
     }
     while(m--)
     {
       cin>>p>>temp1>>q>>temp2>>d;
       graph[p][q]=(d/100-1);
       graph[q][p]=(d/100-1);          
     }                    
     int result=prim();
     cout<<result<<endl;        
   }
   //while(1);
   return 0;
 }

 
  

Measured memory_bytes: 3280
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n, q;
    cin >> n >> q;
    vector<int> a(q), b(q);
    for(int i=0; i<q; ++i){
        cin >> a[i] >> b[i];
        -- a[i];
        -- b[i];
    }

    vector<bool> v(n, false);
    v[0] = v[1] = true;
    int x = 0;
    for(int i=0; i<q; ++i){
        swap(v[a[i]], v[b[i]]);
        if(x == a[i])
            x = b[i];
        else if(x == b[i])
            x = a[i];

        bool tmp = false;
        for(int j=x-1; j<=x+1; ++j){
            if(0 <= j && j < n)
                v[j] = true;
        }
    }

    int ans = 0;
    for(int i=0; i<n; ++i){
        if(v[i])
            ++ ans;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const long long MOD = 1000000007;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

ll pow(ll c, ll N, ll r) {
  if (r >= INF + 7) {
    r %= INF + 7;
  }
  if (c == N) {
    return r;
  } else {
    return pow(c + 1, N, (c + 1) * r);
  }
}

void solve(ll N) {
  ll result = pow(1, N, 1);
  cout << result << endl;
}

int main() {
  ll N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
const int INF =100000;
int main(){
    int n,t;
    cin>>n>>t;
    vector<int> cv(n);
    vector<int> tv(n);
    for(int i=0;i<n;i++){
        cin>>cv[i]>>tv[i];
    }
    int min=INF;
    for(int i=0;i<n;i++){
        if(tv[i]<=t){
            if(min>cv[i]){
                min=cv[i];
            }
        }
    }
    if(min==INF){
        cout<<"TLE"<<endl;
    }else{
        cout<<min<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
X, Y = map(int, input().split())
A = (4*X-Y)/2
B = (Y-2*X)/2
if  A%1 == 0 and X >= abs(A) and A>=0:
  print('Yes')
elif B%1 == 0 and X >= abs(B) and B>=0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9248
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        int n = scn.nextInt(), m  = scn.nextInt(), l = scn.nextInt();
        showMatrix(createTable(n, m), createTable(m, l));
    }
    
    private static int[][] createTable(int y, int x) {
        int[][] tbl = new int[y][x];
        for(int i = 0; i < y; i++) {
            for(int j = 0; j < x; j++) {
                tbl[i][j] = scn.nextInt();
            }
        }
        return tbl;
    }
    
    private static void showMatrix(int[][] a, int[][] b) {
        for(int i = 0; i < a.length; i++) {
            StringBuilder sb = new StringBuilder();
            for(int j = 0; j < b[0].length; j++) {
                long v = 0;
                for(int k = 0; k < b.length; k++) {
                    v += a[i][k] * b[k][j];
                }
                sb.append(v + " ");
            }
            System.out.println(sb.toString().trim());
        }
    }
}

Measured memory_bytes: 53912
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;

int main(){
  double x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  double dist;
  dist = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));

  cout << fixed << setprecision(10);
  cout << dist << endl;
}



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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()


ll sum(int n);

void go(){
	string s;cin>>s;
	map<char,int> cnt;
	for(char ch : s) cnt[ch]++;
	string ans="Yes";
	for(auto p : cnt){
		if(p.second%2==1){
			ans="No";
			break;
		}
	}
	cout << ans;
}
int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}

ll sum(int n){                
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}


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

class UnionFindTree {
private:
    vector<int> parent;
    vector<int> count;
public:
    UnionFindTree(int n) : parent(n), count(n, 1) {
        // 最初は全てを根として初期化
        for(int i = 0; i < n; i++) parent[i] = i;
    }

    int get_root(const int x) {
        // データxが属する木の根を取得する
        if (parent[x] == x) return x;
        // 取得したものは直接木の根をつなぐ(経路圧縮)
        return parent[x] = get_root(parent[x]);
    }

    void unite(const int x, const int y) {
        // xとyの木を併合する
        int rx = get_root(x);
        int ry = get_root(y);
        // 元から同じ木に属している場合は何もしない
        if (rx == ry) return;
        // xの属する木をyの属する木につける
        parent[rx] = ry;
        count[ry] += count[rx];
        count[rx] = 0;
    }

    bool is_same_root(const int x, const int y) {
        return get_root(x) == get_root(y);
    }

    int get_size(const int x) {
        return count[get_root(x)];
    }

    void print() {
        for(auto elm : parent) cout << elm << " ";
        cout << endl;
        for(auto elm : count) cout << elm << " ";
        cout << endl;
    }
};

int main(){
    int n; cin >> n;
    vector<pair<int, int>> x(n), y(n);
    map<int, vector<pair<int, int>>> g;
    UnionFindTree tree(n); int64_t ans = 0;
    for (auto i = 0; i < n; i++) {
        cin >> x[i].first >> y[i].first;
        x[i].second = i; y[i].second = i;
    }
    sort(x.begin(), x.end()); sort(y.begin(), y.end());
    for (auto i = 0; i < n - 1; i++) {
        g[abs(x[i].first - x[i + 1].first)].emplace_back(x[i].second, x[i + 1].second);
        g[abs(y[i].first - y[i + 1].first)].emplace_back(y[i].second, y[i + 1].second);
    }
    for (auto & vec : g) {
        for (auto & elm : vec.second) {
            if (not tree.is_same_root(elm.first, elm.second)) {
                tree.unite(elm.first, elm.second);
                ans += vec.first;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11348
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using ld = long double;

constexpr ld PI = 3.14159265358979;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll A, ll B, ll H, ll M) {
  ld mins = 60.*H + M;
  ld angle = mins*5.5;
  ld ans = hypot(A-B*cos(angle*PI/180.), B*sin(angle*PI/180.));
  cout << fixed << setprecision(16)
       << ans << endl;
}

int main() {
  ll A;
  cin >> A;
  ll B;
  cin >> B;
  ll H;
  cin >> H;
  ll M;
  cin >> M;
  solve(A, B, H, M);
  return 0;
}


Measured memory_bytes: 4184
N = int(input())
S = list(input())
S_l = len(S)
ans = 0
cum = [[0]*3 for _ in range(N+1)]
for i,s in enumerate(S,1):
    cum[i]=cum[i-1].copy()
    if s=='R':
        cum[i][0]+=1
    elif s=='G':
        cum[i][1]+=1
    elif s=='B':
        cum[i][2]+=1


for i in range(len(S)):
  for j in range(i+1,len(S)):
    if S[i]==S[j]:
      continue
    else:
      x = 'RGB'.replace(S[i],'').replace(S[j],'')
      if x=='R':
        ans+=cum[-1][0]-cum[j][0]
        y = 2*j-i
        if y<S_l:
          if S[y]=='R':
            ans-=1
      elif x=='G':
        ans+=cum[-1][1]-cum[j][1]
        y = 2*j-i
        if y<S_l:
          if S[y]=='G':
            ans-=1
      else:
        ans+=cum[-1][2]-cum[j][2]
        y = 2*j-i
        if y<S_l:
          if S[y]=='B':
            ans-=1
 
print(ans)


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


using namespace std;

/* macros */
#define all(v)			((v).begin()), ((v).end())
#define SIZE(v)			((int)((v).size()))
#define LOG(x)			log((double)x)
#define TOLOWER(x)          transform(all(x),x.begin(),::tolower)
#define TOUPPER(x)          transform(all(x),x.begin(),::toupper)
#define ROUND(x,m)			(round((double)x/m)*m)
#define DIGITS(x)			(floor(log10((double)x))+1)
#define READSTR(x)			getline(cin,x)
#define sort_g(a,b)              sort(a, b, greater<int>());
#define IOS() ios_base::sync_with_stdio(0);cin.tie(NULL);
#define REP(i, n) for (int i = 0; i < n; i++)
#define FILE_INPUT() 	freopen( "input.txt", "r", stdin)
#define FILE_OUTPUT()   freopen( "output.txt", "w", stdout)

/*typedefs*/
typedef long long ll;
/*functions*/
bool myCmp(pair<int,int> &p1 , pair<int,int>&p2)
{
    return p1.first > p2.first;
}
unsigned long long
choose(unsigned long long n, unsigned long long k) {
    if (k > n) {
        return 0;
    }
    unsigned long long r = 1;
    for (unsigned long long d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}
int toInt(string str) {
    int num;
    istringstream iss(str); //put string in input stream
    iss>>num; return num; //read from stream as integer
}

template <class T> string toStr(T par) {
    ostringstream oss;  //output stream string
    oss<<par;    //write par to the stream
    return oss.str(); //return string of output
}



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

    ll s= A+B;
    ll d = n/s;
    ll m = n%s;

    cout<<A*d + min(m,A)<<endl;


    return 0;
}


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

using namespace std;

int main(){
	char s[11];
	int total = 0, resp = 0;
	scanf("%s%*c",s);
	strcat(s,"S");
	for(int i = 0;s[i];i++){
		if(s[i] == 'R'){
			total++;
		}else{
			resp = max(resp, total);
			total = 0;
		}
	}
	printf("%d\n",resp);
}

Measured memory_bytes: 3832
import java.util.*;

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

    if(N<=9){
    System.out.println(N);
    }else if(N<=99){
    System.out.println("9");
    }else if(N<=999){
    System.out.println(N-99+9);
    }else if(N<=9999){
    System.out.println("909");
    }else if(N<=99999){
    System.out.println(N-9999+909);
    }else{
    System.out.println("90909");    
    }
}
}

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

int main() {
  int a,b;
  cin >> a >> b;
  vector<string> s(a);
  for(int i = 0;i < a;i++){
    cin >> s[i];
  }
  
  for(int i = 0;i < b+2;i++){
    cout << '#';
  }
    cout << endl;
  for(int i = 0;i < a;i++){
    cout << '#' << s[i] << '#' << endl;
  }
  for(int i = 0;i < b+2;i++){
    cout << '#';
  }
  cout << endl;
}

Measured memory_bytes: 3556
from itertools import combinations
def is_lighted(re):
    for i in range(m):
        total = 0
        for each in ls[i]:
            if each in re:
                total+=1
        if total%2 != p[i]:
            return 0
    return 1

n,m = [int(x) for x in input().split()]
ls = []
ans = 0
for i in range(m):
    ki = [int(x) for x in input().split()]
    ls.append(ki[1:])
p = [int(x) for x in input().split()]

t = [i for i in range(1,n+1)]
for i in range(n+1):
    for each in combinations(t,i):
        if is_lighted(each):
            ans += 1

print(ans)
    


Measured memory_bytes: 3064
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define fast_io()                \
    ios::sync_with_stdio(false); \
    std::cin.tie(0);
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    fast_io();
    ll n, k, num = 0;
    cin >> n >> k;
    while(n)
    {
        num++;
        n /= k;
    }
    cout << num;


    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<cmath>
using namespace std;

int main(){
    int a, b, t;
    cin >> a >> b >> t;
    int n = (t + 0.5)/a;
    cout << n*b << endl;
}
    // for (int i = 0; i < ; i++){
        
    // }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#define ll long long
#define boostUP ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fsr(i,n) for(ll i=0;i<n;i++)
#define fcr(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define sz(arr) sizeof(arr)/sizeof(arr[0])

using namespace std;

int main(){
    ll n,k;
    cin >> n >> k;
    ll arr[n];
    fsr(i,n) cin >> arr[i];
    ll count = 0, sum = 0;
    sort(arr,arr+n);
    if(n-k <= 0){
        count = 0;
    }
    else{
        for(int i=0; i<n-k; i++){
            sum += arr[i];
        }
        count = sum;
    }
    cout << count << endl;
}



 







 

Measured memory_bytes: 5208
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 1000000007LL;
const int Maxn = 2e5 + 10;
const ll Inf = 1e9;
const ll Log = 30;

ll d[Maxn];
ll w[Maxn], c[Maxn], sat[Maxn], ind[Maxn];;
vector<pll> H[Maxn];

bool CMP(ll i, ll j){
	return d[i] < d[j];
}

vector<pll> G[Maxn];

int mk[Maxn];

void DFS(int u){
	int adj, id;
	mk[u] = 1;
	for(auto E : H[u]){
		adj = E.F; id = E.S;
		if(!mk[adj]){
			c[adj] = c[u] + id;
			DFS(adj);
		}
	}
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i++) cin >> d[i];
	ll u, v;
	for(int i = 1; i <= m; i++){
		w[i] = Inf;
		cin >> u >> v;
		if(d[u] == d[v]){
			if(min(sat[u], sat[v]) == 0){
				sat[u] = 1;
				sat[v] = 1;
				w[i] = d[u];
				H[u].pb({v, 1});
				H[v].pb({u, 1});
			}
		}
		G[u].pb({v, i});
		G[v].pb({u, i});
	}
	
	iota(ind, ind + Maxn, 0);
	sort(ind + 1, ind + n + 1, CMP);
	
	int adj, id;
	for(int i = 1; i <= n; i++){
		int ii = ind[i];
		for(auto e : G[ii]){
			adj = e.F; id = e.S;
			if(d[adj] < d[ii] && sat[ii] == 0){
				sat[ii] = 1;
				w[id] = d[ii] - d[adj];
				H[ii].pb({adj, 0});
				H[adj].pb({ii, 0});
			}
		}
		if(!sat[ii]) return cout << "-1\n", 0;
	}
	
	for(int i = 1; i <= n; i++) if(!mk[i]) DFS(i);
	for(int i = 1; i <= n; i++) cout << (c[i] & 1 ? 'W' : 'B');
	cout << '\n';
	
	for(int i = 1; i <= m; i++) cout << w[i] << '\n';
	
	return 0;
}



Measured memory_bytes: 33664
n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = []
for i in range(m):
  b,c = map(int,input().split())
  bc.append((b,c))
bc = sorted(bc,key=lambda x:x[1])
bc.reverse()
count = 0
for b,c in bc:
  count += b
  a += [c] * b
  if count >= n:
    break
a.sort()
a.reverse()
print(sum(a[:n]))

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln << "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;
struct edge {
	int to,cost;
	edge(int t, int c):to(t),cost(c) {}
};

const int inf = 1001001001;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

//--------------------------------------------------

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	int a[n], dp[n];
	rep(i,n) cin >> a[i];
	fill(dp, dp+n, inf);
	
	rep(i,n) {
		*lower_bound(dp, dp+n, a[i]) = a[i];
	}
	cout << lower_bound(dp, dp+n, inf)-dp ln;
}

Measured memory_bytes: 3932
class UnionFind:
    def __init__(self, n):
        self.par = list(range(n))
        self.rank = [0] * n
        self.size = [1] * n

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        elif self.rank[x] < self.rank[y]:
            x, y = y, x

        self.par[y] = x
        self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        return self.size[self.find(x)]


N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]

tree = UnionFind(N + 1)
for a, b in X:
    tree.unite(a, b)

res = max(tree.get_size(n) for n in range(1, N + 1))
print(res)


Measured memory_bytes: 112816
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int N, M;
	scanf("%d %d", &N, &M);
	
	int i, num;
	for (i = 0, num = 1; i < M; i++, num *= 2);
	printf("%d\n", (1900 * M + 100 * (N - M)) * num);
	fflush(stdout);
	return 0;
}

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

int main(){
    int n,a;
    cin>>n>>a;
    if(a>=499){
        cout<<"Yes"<<endl;
        return 0;
    }
    n%=500;
    if(n<=a)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

class mat {
	vector<vector<int64_t>> m;

public:
	mat( int i, int j ): m( i, vector<int64_t>( j ) ) {}
	int64_t& at( int i, int j ) { return m.at( i ).at( j ); }
};

int main() {
	int n, m, l;
	cin >> n >> m >> l;

	mat A( n, m );
	mat B( m, l );

	for( int i = 0; i < n; ++i ) {
		for( int j = 0; j < m; ++j ) {
			cin >> A.at( i, j );
		}
	}

	for( int i = 0; i < m; ++i ) {
		for( int j = 0; j < l; ++j ) {
			cin >> B.at( i, j );
		}
	}

	mat C( n, l );

	for( int i = 0; i < n; ++i ) {
		for( int j = 0; j < l; ++j ) {
			for( int k = 0; k < m; ++k ) {
				C.at( i, j ) += A.at( i, k ) * B.at( k, j );
			}
		}
	}

	for( int i = 0; i < n; ++i ) {
		for( int j = 0; j < l; ++j ) {
			cout << C.at( i, j );

			if( j < l-1 ) { cout << ' '; }
		}

		cout << endl;
	}
}



Measured memory_bytes: 3188
use std::cmp::max;
use proconio::input;

fn main() {
    input! {
        n: usize,
        an: [i64; n],
    }

    let mut prev = 0;
    let mut res = 0;
    for &a in an.iter() {
        res += max(0, prev - a);
        prev = max(a, prev);
    }

    println!("{}", res);
}


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

int main() {
    int scores[1000];
    int n;
    int min, max;
    int sum = 0;
    int minf = 0, maxf = 0;

    while(cin >> n) {
        if(n == 0) {
            break;
        }
        for(int i = 0; i < n; i++) {
            scanf("%d", &scores[i]);
            if(i == 0) {
                min = max = scores[i];
            }
            if(scores[i] < min) {
                min = scores[i];
            } else if(scores[i] > max) {
                max = scores[i];
            }
        }

        minf = 0;
        maxf = 0;
        sum = 0;
        for(int i = 0; i < n; i++) {
            if(!minf && scores[i] == min) {
                minf = 1;
            } else if(!maxf && scores[i] == max) {
                maxf = 1;
            } else {
                sum += scores[i];
            }
        }
        cout << sum / (n - 2) << endl;
    }
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)
int main(){
    ll n, r, ans;
    cin >> n >> r;
    if(n<10){
        ans = r + (100*(10-n));
    }else{
        ans = r;
    }
   
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import static java.lang.System.out;

class SortingThreeNumbers {

    private int[] data;

    SortingThreeNumbers(int... data) {
        this.data = Arrays.copyOf(data, data.length);
        sort(this.data);
    }

    @Override
    public String toString() {
        StringBuilder str = new StringBuilder();
        for (int num : data) {
            str.append(String.format("%d ", num));
        }
        return str.toString().trim();
    }

    // ?????´?£?????????????
    public static int[] sorted(int... data) {
        int[] copy = Arrays.copyOf(data, data.length); // ???????????????????£?????????????????????????????????????
        sort(copy);

        return copy;
    }

    // ??´?£?????????????
    private static void sort(int... data) {
        // bouble sort
        for (int i = 0; i < data.length; i++) {
            for (int j = 1; j < data.length - i; j++) {
                if (data[j - 1] > data[j]) {
                    int tmp = data[j - 1];
                    data[j - 1] = data[j];
                    data[j] = tmp;
                }
            }
        }
    }
}

public class Main {
    public static void main(String... args) {
        Scanner scan = new Scanner( System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();

        out.println(new SortingThreeNumbers(a, b, c));
    }
}

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

int main() {
    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string T;
    cin >> T;
    int t[n];
    rep(i, 0, n) {
        if (T[i] == 'r') t[i] = 2;
        if (T[i] == 's') t[i] = 0;
        if (T[i] == 'p') t[i] = 1;
    }
    int score[3] = {r, s, p};
    int dp[n][3] = {};
    rep(i, 0, k) {
        dp[i][t[i]] = score[t[i]];
    }
    rep(i, k, 2 * k) {
        for (int j = i; j < n; j += k) {
            rep(l, 0, 3) {
                rep(m, 0, 3) {
                    if (l == m) continue;
                    if (l == t[j]) dp[j][l] = max(dp[j][l], dp[j - k][m] + score[t[j]]);
                    else dp[j][l] = max(dp[j][l], dp[j - k][m]);
                }
            }
        }
    }
    int ans = 0;
    rep(i, 0, k) {
        int mx = 0;
        rep(j, 0, 3) {
            mx = max(mx, dp[n - 1 - i][j]);
        }
        ans += mx;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  ll n,p; cin>>n>>p;
  ll ans=1;
  for (ll i=2; i*i<=p; i++) {
    ll tmp=p;
    ll cnt=0;
    while (tmp%i==0) {
      tmp/=i;
      cnt++;
    }
    if (cnt>=n) ans=i;
  }
  if (n==1) ans=p;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

ll xorsum(ll m){
  if(m%4==0){return m;}
  if(m%4==1){return 1;}
  if(m%4==2){return m+1;}
  if(m%4==3){return 0;}
}

int main(){
  ll a,b; cin >> a >> b;
  ll ans = xorsum(a-1)^xorsum(b);
  cout << ans << endl;    
  return 0;
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n;
    cin >> n;

    double ans = 0;
    rep(i, n){
        double x;
        string u;
        cin >> x >> u;
        if(u == "JPY"){
            ans += x;
        }else{
            ans += x * 380000.0;
        }
    }

    cout << fixed << setprecision(8) << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

int main(){
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    int ans = a1 + a2 + a3;
    if(ans >= 22) cout << "bust" << endl;
    else cout << "win" << endl;


    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
int n,k,a[200005];
long long s=0;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n-k;i++)s+=a[i];
	cout<<s;
}

Measured memory_bytes: 1024
n=int(input())
x=[int(n) for n in input().split()]
a={}
for i in x:
    try:
        a[i]+=1 
    except:
        a[i]=1
c=0
for i in a:
    c+=((a[i]-1)*(a[i]))//2
    
for i in x:
    print(c-((a[i]-1)*(a[i]))//2+((a[i]-1)*(a[i]-2))//2)

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

#define ll long long

using namespace std;

int n;

int a[100005], dp[100005], k;

int main () {
    cin >> n >> k;
    for (int i = 1;i <= n;i ++) {
        cin >> a[i];
    }
    dp[1] = 0;
    dp[2] = abs (a[1] - a[2]);
    for (int i = 3;i <= n;i ++) {
        dp[i] = 1e9 + 7;
        for (int j = max (1, i - k);j <= i;j ++) {
            dp[i] = min (dp[i], dp[j] + abs (a[j] - a[i]));
        }
    }cout << dp[n];
}


Measured memory_bytes: 1024