akhauriyash/Code-Regression huggingface dataset:
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

int X;

signed main(){

    in(X);
    out(X<1200?"ABC":"ARC");

    return 0;
}


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

using namespace std;

int main(void){
  string s;
  int N;
  cin >> N;
  cin >> s;
  vector<int> va,vb,vc;
  for(int i=0;i<N;i++){
    if(s[i] == 'R'){
      va.push_back(i);
    }else if(s[i] == 'G'){
      vb.push_back(i);
    }else{
      vc.push_back(i);
    }
  }
  // Aをみたす数
  long long int sum = va.size()*vb.size()*vc.size();
  long long int tmp=0;
  //最初のいち
  for(int i=0;i<N;i++){
    //s[i]から違うのをみつける
    for(int j=1;i+j<N;j++){
      if(s[i] != s[i+j]){
	//2j+iがどうかをみる
	if(2*j+i < N && s[2*j+i] != s[i+j] && s[2*j+i] != s[i]){
	  tmp = tmp + 1;
	}
      }
    }
  }
  cout << sum - tmp << endl;
  return 0;
}


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

typedef long long int ll;
typedef pair<int,int> pii;

int main(){
    ll n,m;
    scanf("%lld %lld",&n,&m);
    if(n>=m){
        if(n%m==0) printf("0\n");
        else{
            ll minn = (n%m);
            minn = min(minn,abs(minn-m));
            printf("%lld\n",minn);
        }
    }
    else{
        printf("%lld\n",min(m-n,n));
    }
    return 0;
}


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

using namespace std;

#define SENTINEL 1000000001
int n;
int cnt;

void merge( vector<int>& S, int left, int mid, int right )
{
	int n1 = mid - left;
	int n2 = right - mid;

	vector<int> L;
	vector<int> R;
	for( vector<int>::size_type i=0; i<n1; i++ ) {
	    L.push_back( S.at( left+i ) );
	}
	for( vector<int>::size_type i=0; i<n2; i++ ) {
	    R.push_back( S.at( mid+i ) );
	}
	
	L.push_back( SENTINEL );
	R.push_back( SENTINEL );	
	vector<int>::size_type i, j;
	i = j = 0;
	for( vector<int>::size_type k=left; k<right; k++ ) {
	    cnt++;
	    if( L.at(i) <= R.at(j) ) {
	        S.at(k) = L.at( i++ );
	    } else {
	        S.at(k) = R.at( j++ );
	    }
	}
	
    return;
}
void mergeSort( vector<int>& S, int left, int right )
{
	if( left+1 < right ) {
		int mid = ( left+right )/2;
		mergeSort( S, left, mid );
		mergeSort( S, mid, right );
		merge( S, left, mid, right );
	}
	return;
}

int main()
{
	cin>>n;
	vector<int> S;
	int num;
	for( int i=0; i<n; i++ ) {
		cin>>num;
		S.push_back( num );
	}
	cnt = 0;
	mergeSort( S, 0, n );
	for( vector<int>::iterator itr = S.begin(); itr!=S.end(); itr++ ) {
		cout<<*itr;
		if( itr < S.end()-1 ) { cout<<' '; }
	}
	cout<<'\n'<<cnt<<endl;	
    return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};

ll F[110][5][2];

int main(){

  int n;
  cin >> n;
  REP(i,n)REP(j,5)REP(k,2)cin >> F[i][j][k];
  vector<vector<ll>> p(100,vector<ll>(11,0));
  REP(i,n)REP(j,11)cin >> p[i][j];
  ll res = (-1ll)*(1ll << 40);
  for(int bit = 0;bit < (1 << 5);bit++){
    vector<bool> b(5,0);
    REP(i,5)if(bit >> i & 1)b[i] = true;
    for(int bits = 0;bits < (1 << 5);bits++){
      if(bit == 0 && bits == 0)continue;
      vector<bool> a(5,0);
      REP(i,5)if(bits >> i & 1)a[i] = true;
      vector<int> many(n,0);
      REP(i,n)REP(j,5)if(b[j] && F[i][j][0])many[i]++;
      REP(i,n)REP(j,5)if(a[j] && F[i][j][1])many[i]++;
      ll sum = 0;
      REP(i,n)sum += p[i][many[i]];
      res = max(res,sum);
    }
  }

  cout << res << endl;





  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int N,H; cin >> N >> H;
  vector<int> a(N),b(N);
  for (int i = 0; i < N; i++) cin >> a[i] >> b[i];
  
  sort(a.begin(),a.end());
  
  int amax = a[N-1];
  
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (H > 0 && b[i] > amax) {
      H -= b[i];
      count++;
    }
  }
  
  if (H > 0) count += ((H + amax - 1) / amax);
  
  cout << count << endl;
}

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

int main() {
    double a;
    double sum = 0;
    int n;
    cin >> n;
    for(int i = 0;i < n;i++) {
        cin >> a;
        sum += 1.0 / a;
    }
    cout << 1.0 / sum << endl;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int,int> ii;

const int N = 5e5 + 5;
const int mod = 998244353;

int fac[N],inv[N],ans;
ll n,k,a,b;

inline int mul(int x,int y) {
  return (ll) x * y % mod;
}

inline int add(int x,int y) {
  return (x + y) % mod;
}

inline int comb(int n,int r) {
  return mul(fac[n],mul(inv[n - r],inv[r]));
}

int fast_pow(int x,int y) {
  if (y == 0)
    return 1;
  int res = fast_pow(x,y / 2);
  res = mul(res,res);
  if (y % 2 == 1)
    res = mul(res,x);
  return res;
}

void furkan_i_love_u() {
  fac[0] = inv[0] = 1;
  for (int i = 1 ; i < N ; i++) {
    fac[i] = mul(fac[i - 1],i);
    inv[i] = fast_pow(fac[i],mod - 2);
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  furkan_i_love_u();
  cin >> n >> a >> b >> k;
  for (int i = 0 ; i <= n ; i++) {
    if ((k - i * a) % b == 0 && k >= i * a) {
      int j = (k - i * a) / b;
      if (j > n)
        continue;
      ans = add(ans,mul(comb(n,i),comb(n,j)));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4224
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = [0]
for _ in range(N):
    A.append(int(input()))

pos = 1
ans = 0
reached_index = set()
while True:
    pos = A[pos]
    ans += 1
    if pos in reached_index:
        ans = -1
        break
    if pos == 2:
        break
    reached_index.add(pos)

print(ans)

Measured memory_bytes: 13212
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a[3];
    rep(i, 0, 3) cin >> a[i];
    int sum = 0;
    rep(i, 0, 3) sum += a[i];
    if(sum >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Stack;

//Paint Color
public class Main{

	int w, h, n, r, c;
	boolean[][] m;
	int[][] move = {{-1,0},{0,1},{1,0},{0,-1}};

	void run(){
		Scanner sc = new Scanner(System.in);
		while(true){
			w = sc.nextInt();
			h = sc.nextInt();
			if((w|h)==0)break;
			n = sc.nextInt();
			PriorityQueue<Integer> qx = new PriorityQueue<Integer>();
			PriorityQueue<Integer> qy = new PriorityQueue<Integer>();
			qx.add(0);qx.add(w);
			qy.add(0);qy.add(h);
			int[][] a = new int[n][4];
			for(int i=0;i<n;i++){
				for(int j=0;j<4;j++){
					a[i][j] = sc.nextInt();
					if(j%2==0&&!qx.contains(a[i][j])){
						qx.add(a[i][j]);
					}
					else if(j%2==1&&!qy.contains(a[i][j])){
						qy.add(a[i][j]);
					}
				}
			}
			r = qy.size()-1;
			c = qx.size()-1;
			Map<Integer, Integer> mx = new HashMap<Integer, Integer>();
			Map<Integer, Integer> my = new HashMap<Integer, Integer>();
			int id = 0;
			while(!qx.isEmpty())mx.put(qx.poll(), id++);
			id = 0;
			while(!qy.isEmpty())my.put(qy.poll(), id++);
			m = new boolean[r][c];
//			System.out.println("R:" + r + " C:" + c);
			for(int i=0;i<n;i++){
				int x1 = mx.get(a[i][0]);
				int x2 = mx.get(a[i][2]);
				int y1 = my.get(a[i][1]);
				int y2 = my.get(a[i][3]);
//				System.out.println(x1+"<"+x2+" "+y1+"<"+y2);
				for(int j=x1;j<x2;j++)for(int k=y1;k<y2;k++)m[k][j]=true;
			}
			int ans = 0;
			for(int i=0;i<r;i++){
				for(int j=0;j<c;j++){
					if(!m[i][j]){
						ans++;
						Stack<int[]> s = new Stack<int[]>();
						s.add(new int[]{i, j});
						while(!s.isEmpty()){
							int[] p = s.pop();
							if(m[p[0]][p[1]])continue;
							m[p[0]][p[1]] = true;
							for(int k=0;k<4;k++){
								int ni = p[0]+move[k][0];
								int nj = p[1]+move[k][1];
								if(0<=ni&&ni<r&&0<=nj&&nj<c)s.add(new int[]{ni,nj});
							}
						}
					}
				}
			}
			System.out.println(ans);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 20000
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ass 1e18
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x,y) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<< endl;
#define debug3(x,y,z) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<<" "<<#z<<" : "<<z<< endl;
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
	boost
	ll cnt=0,n,i,a,b,c,maxi,mini;
	cin>>n;
	ll arr[n];
	for(i=0;i<n;i++)
		cin>>arr[i];
	sort(arr,arr+n);
	a=(n+1)/2;
	if(arr[a]==arr[a-1])
		cout<<cnt;
	else
	{
		cnt=arr[a]-arr[a-1];
		cout<<cnt;
	}
	return 0;
}

Measured memory_bytes: 1024
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
#![macro_use]

use std::cmp::*;
use std::collections::*;
use std::f64::*;
use std::io::*;
use std::mem::*;
use std::num::*;
use std::slice::*;

fn main() {
    let (r, w, e) = (stdin(), stdout(), stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    // =============================================== //
    let a = io.readn::<i64>(3);

    if a[2] > a[0] + a[1] && (a[2] - a[0] - a[1]).pow(2) > 4 * a[0] * a[1] {
        println!("Yes");
    } else {
        println!("No");
    }
}

// IO
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug ) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
}


Measured memory_bytes: 4352
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		BigInteger a, b, c;
		boolean flag;
		String s;

		a = new BigInteger("0");
		b = new BigInteger("0");
		c = new BigInteger("0");
		while (sc.hasNext()) {
			s = sc.next();
			flag = true;
			for (int i = 0; i < 10; i++) {
				String s2 = s;
				s2 = s2.replace('X', (char)(i + '0'));
				int index = 0;
				a = f(s2, index);
				while (Character.isDigit(s2.charAt(index))) {
					index++;
				}
				index++;
				b = f(s2, index);
				while (Character.isDigit(s2.charAt(index))) {
					index++;
				}
				index++;
				c = f(s2, index);
				if (a == null || b == null || c == null) {
					continue;
				}
				if (a.add(b).equals(c)) {
					System.out.println(i);
					flag = false;
					break;
				}
			}
			if (flag) {
				System.out.println("NA");
			}
		}
	}

	public static BigInteger f(String s, int i) {
		BigInteger a = new BigInteger(Integer.toString(s.charAt(i) - '0'));
		i++;
		if (a.equals(BigInteger.ZERO) && i < s.length() && Character.isDigit(s.charAt(i))) {
			return null;
		}
		while (i < s.length() && Character.isDigit(s.charAt(i))) {
			a = a.multiply(BigInteger.TEN);
			a = a.add(new BigInteger(Integer.toString(s.charAt(i) - '0')));
			i++;
		}
		return a;
	}
}

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

int main()
{
    int x,flag;
    cin >> x;
    if(x >= 400 && x <= 599)flag = 8;
    if(x >= 600 && x <= 799)flag = 7;
    if(x >= 800 && x <= 999)flag = 6;
    if(x >= 1000 && x <= 1199)flag = 5;
    if(x >= 1200 && x <= 1399)flag = 4;
    if(x >= 1400 && x <= 1599)flag = 3;
    if(x >= 1600 && x <= 1799)flag = 2;
    if(x >= 1800 && x <= 1999)flag = 1;

    cout << flag << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <time.h>
#include <random>
using namespace std;

int oe[100000];
vector<int> G[100000];

struct union_find{
    vector<int> par, rank;
    union_find(int n){
        par = vector<int>(n);
        rank = vector<int>(n);
        init(n);
    }
    void init(int n){
        for(int i=0;i<n;i++){
            par[i]=i;
            rank[i]=0;
        }
    }
    int find(int x){
        if(par[x]==x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
};

bool dfs(int v){
    for(auto g:G[v]){
        if(oe[g]==-1){
            if(oe[v])oe[g]=0;
            else oe[g]=1;
            if(dfs(g)) return true;
        }else{
            if(oe[g]==oe[v]) return true;
        }
    }
    return false;
}

int main(){
    int N,M;
    fill(oe,oe+100000,-1);
    cin>>N>>M;
    union_find UF(N);
    for(int i=0;i<M;i++){
        int u,v;
        cin>>u>>v;
        u--;v--;
        UF.unite(u,v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    int64_t sep=0,uni=0,single=0;
    for(int i=0;i<N;i++){
        if(UF.find(i)==i){
            if(!G[i].size()){
                single++;
                continue;
            }
            oe[i]=0;
            if(dfs(i)){
                uni++;
            }else{
                sep++;
            }
        }
    }
    int64_t ans = single*N*2-single*single;
    ans+=uni*uni;
    ans+=2*uni*sep;
    ans+=2*sep*sep;
    // cout<<sep<<' '<<uni<<' '<<single<<endl;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <algorithm>

using std::vector;
using std::string;
int main(){
    int n,l;
    std::cin >> n >> l;
    vector<string> s_list(n);
    for(string& s: s_list) {
        std::cin >> s;
    }
    std::sort(s_list.begin(),s_list.end());
    for(string s: s_list) {
        std::cout << s;
    }
}

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

int main(void){
    int     K,A,B;
    int     cnt=0;
    scanf("%d",&K);
    scanf("%d %d",&A,&B);
    for(A; A <= B; A++){
        if(A % K == 0){
            cnt = 1;
        }
    }
    if(cnt){printf("OK\n");}else printf("NG\n");
    return(0);
}

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

//最大公約数を求める。
ll gcd(ll a, ll b){
    if(a%b == 0){
        return b;
    }else{
        return gcd(b,a%b);
    }
}



int main()
{
    ll n;
    cin>>n;
    vector<ll> t(n);
    for(int i=0;i<n;i++){
        cin>>t.at(i);
    }
    ll ans=t.at(0);
    ll memo;
    for(int i=1;i<n;i++){
        memo=gcd(ans,t.at(i));
        ans=ans*(t.at(i)/memo);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace ConsoleApp8
{   
    class Program
    {
        public static void Main(string[] args) {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]); int b = int.Parse(input[1]);decimal c=(int) a;decimal d = (int)b;
            Console.WriteLine("{0} {1} {2}",a/b,a%b,c/d);

        }
    }
}

Measured memory_bytes: 9200
#include<bits/stdc++.h>
#define ll long long int 
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m,x,y,i,flag=0;
	cin>>n>>m>>x>>y;
	ll a[n],b[m];
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<m;i++){
		cin>>b[i];
	}
	sort(a,a+n);
	sort(b,b+m);
	for(i=x+1;i<=y;i++){
		if(a[n-1]<i&&b[0]>=i){
			flag=1;
		}
	}
	if(flag==1){
		cout<<"No War";
	}
	else{
		cout<<"War";
	}
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

h,w = inpl()
s = [input() for i in range(h)]
res = [''] * (h+2)
for i in range(h+2):
    if i == 0 or i == h+1:
        res[i] = '#' * (w+2)
        continue
    res[i] = '#' + s[i-1] + '#'
for i in res:
    print(i)

Measured memory_bytes: 38384
n = int(input())

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(n):
  ai = a[i] -1
  pre_ai = -10
  if i != 0:
    pre_ai = a[i-1] -1
    
  ans += b[ai]
  if ai - pre_ai == 1:
    ans += c[pre_ai]
    
print (ans)
  

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
    int n,x;
    int i,j,k;
    
    while(1)
    {
        int cnt=0;
        scanf("%d%d",&n,&x);
        if(x==0&&n==0)
            break;
    for(i=1;i<=n;i++)
        for(j=1;j<i;j++)
            for(k=1;k<j;k++)
                if(i+j+k==x)
                    cnt+=1;
    printf("%d\n",cnt);
    }
}



Measured memory_bytes: 2124
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
    string s;cin >> s;
    string t = "";
    rep(i,3)
    {
        if(s[i] == '1')
        {
            t += "9";
        }
        else
        {
            t += "1";
        }
    }
    cout << t;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    int k, s; cin >> k >> s;
    ll ans = 0;
    rep(x, k+1) {
        rep(y, k+1) {
            //cout << x << ' '<< y << endl;
            int z = s - x - y;
            if(0 <= z && z <= k) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        List<Integer> xList = new ArrayList<>();
        List<Integer> yList = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            xList.add(sc.nextInt());
        }
        for (int i = 0; i < m; i++) {
            yList.add(sc.nextInt());
        }

        Collections.sort(xList);
        Collections.sort(yList);
        for (int i = xList.get(n - 1) + 1; i <= yList.get(0); i++) {
            if (i > x && i <= y) {
                System.out.println("No War");
                return;
            }
        }
        System.out.println("War");
    }

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s;
	cin>>s;
	for(ll i=1;i<s.size();i++){
		if(s[i-1]==s[i]){
			cout << i<<" "<< i+1<<endl;
			return 0;
		}
		if(i>=2&&s[i-2]==s[i]){
			cout << i-1<<" "<<i+1<<endl;
			return 0;
		}
	}
	cout << -1 <<" "<<-1<<endl;
	// your code goes here
	return 0;
}

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

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

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

    ll size = sizeof(d)/sizeof(*d);
    sort(d, d + size);
    cout << d[size / 2] - d[size / 2 - 1] << endl;

    return 0;
}

Measured memory_bytes: 4356
#include <stdio.h>

#define SIZE_MIN ( ( int ) 1 )
#define SIZE_MAX ( ( int ) 100 )
#define ELEMENT_MIN ( ( int ) 0 )
#define ELEMENT_MAX ( ( int ) 1000 )

typedef enum
{
	kSuccess,
	kError
}Result;

Result checkNumRange( int num, int min, int max );
void showArray( int *pArray, int size );
void execInsertionSort( int *pArray, int size );

int main( void )
{
	int i;
	int size;
	int array[SIZE_MAX];

	scanf( "%d", &size );
	if( checkNumRange( size, SIZE_MIN, SIZE_MAX ) == kError )
	{
		return -1;
	}

	for( i = 0; i < size; i++ )
	{
		scanf( "%d", &array[i] );
		if( checkNumRange( array[i], ELEMENT_MIN, ELEMENT_MAX ) == kError )
		{
			return -1;
		}
	}

	showArray( &array[0], size );
	execInsertionSort( &array[0], size );

	return 0;
}

Result checkNumRange( int num, int min, int max )
{
	return ( ( num >= min ) && ( num <= max ) ) ? kSuccess : kError;
}

void showArray( int *pArray, int size )
{
	int i;

	for( i = 0; i < size - 1; i++ )
	{
		printf( "%d ", pArray[i] );
	}
	printf( "%d\n", pArray[size - 1] );
}

void execInsertionSort( int *pArray, int size )
{
    int i;
	int j;
	int work;

	for( i = 1; i < size; i++ )
	{
		work = pArray[i];
		j = i - 1;

		while( ( j >= 0 ) && ( pArray[j] > work ) )
		{
			pArray[j + 1] = pArray[j];
			j--;
		}
		pArray[j + 1] = work;

		showArray( pArray, size );
	}
}



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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  for(int i = 0; i < 5; i++){
    int x;
    cin>>x;
    if(x==0) cout<<i+1<<endl;
  }
}

Measured memory_bytes: 3592
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// g++ hoge.cpp -std=c++17 -I . でコンパイルできる
// -fsanitize=undefinedでオーバーフロー検出
#include <bits/stdc++.h>
//#include <atcoder/all>

#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
//using namespace atcoder;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;
//https://pyteyon.hatenablog.com/entry/2019/03/11/200000#Union-Find-%E6%9C%A8%E3%81%AE%E5%AE%9F%E8%A3%85
// union by size + path having
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
bool comp(pair<ll, ll> a, pair<ll , ll> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
         return a.first < b.first; // 昇順
        //return a.first > b.first; // 降順
    }

    // それ以外はsecondで比較
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        // どちらも同じ
        return true;
    }
}


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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    ll k;
    ll g,e;
    ll q;
    cin>>n>>m;
    vector<P> p(m);
    vector<P> ps(m);
    rep(i,m){
        cin>>a>>b;
        p[i]=P(a,b);
        ps[i]=P(a,b);

    }
    sort(all(p),comp);
    map<P,ll> mp;

    ll si=p[0].first;
    ll ctr=1;
    rep(i,m){
        if(si!=p[i].first){
            ctr=1;
            si=p[i].first;
        }
        mp[p[i]]=ctr;
            ctr++;
    }
    rep(i,m){
            cout<<setfill('0')<<right<<setw(6)<<ps[i].first;
            cout<<setfill('0')<<right<<setw(6)<<mp[ps[i]]<<endl;
    }
    return 0;
}


Measured memory_bytes: 12656
{-# LANGUAGE BangPatterns #-}
import Data.Int
import Data.Monoid
import qualified Data.Vector.Unboxed as V

solve :: V.Vector Int -> [Int] -> Maybe [Int]
solve v res | V.null v = Just res
solve v res = case V.find (\(i,x) -> i == x) (V.reverse (V.indexed v)) of
                Nothing -> Nothing
                Just (i,x) -> solve (V.take i v <> V.drop (i + 1) v) (i : res)

main = do
  n <- readLn :: IO Int -- 1 <= n <= 100
  bs <- map (subtract (1 :: Int) . read) . words <$> getLine
  let cond = and $ zipWith (>=) [0..] bs
  if cond
    then case solve (V.fromListN n bs) [] of
           Just xs -> mapM_ (print . (+1)) xs
           Nothing -> putStrLn "-1"
    else putStrLn "-1"


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,x,y;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>x>>y;
	cout<<min(x,y)<<' '<<max(0,x+y-n)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define X first
#define Y second
#define PB push_back
#define ll long long
#define pii pair<ll,ll>
#define MEM(x,y) memset(x,y,sizeof(x))
#define bug(x) cout<<"debug "#x" is "<<x<<endl;
#define FIO ios::sync_with_stdio(false);
#define ALL(x) x.begin(),x.end()
#define LOG 20
#define lson(x) ((x)<<1)
#define rson(x) ((x)<<1|1)
using namespace std;
#define vi vector<int>
const int maxn = 2e5+7;
const ll mod=998244353;
ll a[maxn],b[maxn],c[maxn];
int main(){
    FIO
    int t;
    ll n,m,A,B,C;
    multiset<ll> sa,sb;
    cin>>n>>m>>A>>B>>C;
    for(ll i=0;i<A;i++){
        cin>>a[i];
        sa.insert(a[i]);
        if(sa.size()>n)sa.erase(sa.begin());
    }
    for(ll i=0;i<B;i++){
        cin>>b[i];
        sb.insert(b[i]);
        if(sb.size()>m)sb.erase(sb.begin());
    }
    for(ll i=0;i<C;i++){
        cin>>c[i];
        if(*sa.begin()<=*sb.begin()&&*sa.begin()<c[i]){
            sa.erase(sa.begin());
            sa.insert(c[i]);
        }
        else if(*sa.begin()>*sb.begin()&&*sb.begin()<c[i]){
            sb.erase(sb.begin());
            sb.insert(c[i]);
        }
    }
    ll ans=0;
    for(ll i:sa)ans+=i;
    for(ll i:sb)ans+=i;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 12032
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        int n = int.Parse(Console.ReadLine());
        var b = Console.ReadLine().Split().Select(int.Parse).ToList();

        var ans = new List<string>();
        //bool[] skip = new bool[n];
        for (int i = 0; i < n; i++)
        {
            var j = 1;
            for (int k = n - i - 1; k >= 0; k--)
            {

                if (b[k] == k + j)
                {
                    ans.Add(b[k].ToString());
                    b.RemoveAt(k);
                    break;
                }
            }
        }

        if (b.Count() > 0)
        {
            Console.WriteLine(-1);
        }
        else
        {
            ans.Reverse();
            foreach (var item in ans)
            {
                Console.WriteLine(item);
            }
        }
    }
}

Measured memory_bytes: 28256
#include <cmath>
#include <iostream>
#include <vector>

int main()
{
	int n = 0;
	std::cin >> n;
	int inputX = 0;
	int inputY = 0;
	std::vector<int> vx(n);
	std::vector<int> vy(n);
	for (int i = 0; i < n; ++i)
	{
		std::cin >> inputX >> inputY;
		vx.at(i) = inputX;
		vy.at(i) = inputY;
	}
	double average = 0.0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = i + 1; j < n; ++j)
		{
			average += std::sqrt(std::pow((vx.at(i)-vx.at(j)),2)+ std::pow((vy.at(i) - vy.at(j)), 2));
		}
	}
    printf("%lf",average * 2 / n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define maxN 503
using namespace std;
int main(){
  fastio;
  ll ans=-1;
  for(ll i=0;i<5;++i){
    ll x=0;
    cin>>x;
    if(x==0)
        ans=i+1;
  }
  cout<<ans;
  return 0;
}


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

using namespace std;

int main(){
	int a, b; cin >> a >> b;
	if(a >= 13){
		cout << b << endl; 
	}else if(a >= 6){
		cout << b / 2 << endl;
	}else{
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from math import comb

    n, p = map(int, readline().split())
    a = list(map(int, readline().split()))

    zero = 0
    one = 0

    for x in a:
        if x % 2 == 0:
            zero += 1
        else:
            one += 1

    ans = 0
    q = 2 ** zero

    if p == 0:
        for x in range(0, one + 1, 2):
            ans += q * comb(one, x)
    else:
        for x in range(1, one + 1, 2):
            ans += q * comb(one, x)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define emp emplace
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 100010;

int dp[N], h[N];

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

	int n, k; cin >> n >> k;
	for (int i = 1; i <= n; i++) cin >> h[i];

	memset(dp, 0x3f, sizeof dp);
	dp[1] = 0;
	for (int i = 2; i <= n; i++) {
		for (int j = 1; j <= k; j++) {
			if (i-j < 1) continue;
			dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]), dp[i]);
		}
	}
	cout << dp[n] << endl;

	return 0;
}



Measured memory_bytes: 1024
// input macro
// ref: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_mut)]
fn main() {
    // 入力
    input!(
        n: usize,
        k: usize,
        a: [isize; n],
    );


    // 各bitの報酬
    let mut zer_rew: Vec<isize> = vec![0;40];
    let mut one_rew: Vec<isize> = vec![0;40];

    for idx in 0..40 {
        let mask: isize = 1<<idx;
        for &ai in a.iter() {
            if ai & mask > 0 {
                zer_rew[39-idx] += mask;
            }
            else {
                one_rew[39-idx] += mask;
            }

        }
    }


    // 桁DP
    let mut dp: Vec<Vec<isize>> = vec![vec![std::isize::MIN, 0]; 41];

    for idx in 0..40 {
        if k & (1 << (39-(idx as isize))) > 0 {
            dp[idx+1][1] = dp[idx][1] + one_rew[idx];

            dp[idx+1][0] = std::cmp::max(dp[idx][0] + one_rew[idx],
                                         dp[idx][0] + zer_rew[idx]);
            dp[idx+1][0] = std::cmp::max(dp[idx+1][0],
                                         dp[idx][1] + zer_rew[idx]);
        }
        else {
            dp[idx+1][1] = dp[idx][1] + zer_rew[idx];

            dp[idx+1][0] = std::cmp::max(dp[idx][0] + one_rew[idx],
                                         dp[idx][0] + zer_rew[idx]);
        }
    }

    println!("{}", std::cmp::max(dp[40][0], dp[40][1]));
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,K,Q;
    cin >> N >> K >> Q;
    vector<int> A(Q);
    for(int i=0; i<Q; i++){
        cin >> A.at(i);
    }
    vector<int> score(N);
    for(int i=0; i<N; i++){
        score.at(i)=K;
    }
    vector<int> point(N);
    for(int i=0; i<Q; i++){
        point.at(A.at(i)-1)++;
    }
    int sum=0;
    for(int i=0; i<N; i++){
        sum+=point.at(i);
    }
    for(int i=0; i<N; i++){
        score.at(i)-=(sum-point.at(i));
        if(score.at(i)<=0){
            cout << "No" << endl;
        }
        else 
            cout << "Yes" << endl;
    }
}

Measured memory_bytes: 1792
using System;

namespace abc167_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);
            int k = int.Parse(input[3]);

            if(a >= k)
            {
                Console.WriteLine(k); ;
            }
            else if(a < k && k-a <= b)
            {
                Console.WriteLine(a);
            }
            else
            {
                Console.WriteLine(a * 2 - k + b);
            }
            Console.Read();
        }
    }
}


Measured memory_bytes: 27472
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>

using namespace std;
using ll = long long int;
using vec = vector<int>;

#define rep(n) for(int i = 0; i < (n); ++i)
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
const int INF = 2147483647;
const ll  MOD = 1000000007;

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

    int z = a - b;

    int ans = c - z;

    if(ans >= 0) cout << ans;
    else         cout << 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,m,dp[1<<14];
    ll a[100010],b[2000],c[2000][30];
    cin>>n>>m;
    rep(i,m){
        cin>>a[i]>>b[i];
        rep(j,b[i]){
            cin>>c[i][j];
        }
    }
    rep(i,1<<14){
        dp[i]=LLINF;
    }
    dp[0]=0;
    rep(i,m){
        ll now=0;
        rep(j,b[i]){
            now|=1<<(c[i][j]-1);
        }
        rep(j,1<<n){
            dp[j|now]=min(dp[j|now],dp[j]+a[i]);
        }
    }
    if(dp[(1<<n)-1]==LLINF) dp[(1<<n)-1]=-1;
    cout<<dp[(1<<n)-1]<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    string ans = string(sz(s), 'x');
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};

const int MAX=510000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n,k;
  cin >> n >> k;
  vector<int> p(n),c(n);
  rep(i,n){
    cin >> p[i];
    p[i]--;
  }
  rep(i,n) cin >> c[i];
  ll ans = -INF;
  rep(i,n){
    int now=i;
    vector<int> s;
    ll sum = 0;
    while(true){
      now=p[now];
      s.push_back(c[now]);
      sum += c[now];
      if(now==i)break;
    }
    int l=s.size();
    ll t = 0;
    rep(j,l){
      t += s[j];
      if(j+1>k)break;
      ll res = t;
      if(sum > 0){
        ll d = (k-j-1)/l;
        res += sum*d;
      }
      chmax(ans,res);    
    }
  }
  cout << ans << endl;
  return 0;
}


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

const int INF = 1e+9;
int DP[128][128];
int main() {
	int D, N;
	while(cin >> D >> N && (D || N)){
		int a[128], e[128], r[128];
		for(int i = 0; i < N; ++i)
			scanf("%d%d%d", &a[i], &e[i], &r[i]);
		for(int i = 0; i <= D; ++i)
			for(int j = 0; j <= 100; ++j)
				DP[i][j] = INF;
		DP[D][0] = 0;
		for(int i = D; i > 0; --i){
			for(int j = 0; j <= 100; ++j){
				for(int k = 0; k < N; ++k){
					if(j >= r[k])
					DP[max(0, i - a[k])][min(100, j + e[k])] = min(DP[max(0, i - a[k])][min(100, j + e[k])], DP[i][j] + 1);
				}
			}
		}
		int ans = INF;
		for(int i = 0; i <= 100; ++i)
			ans = min(ans, DP[0][i]);
		if(ans == INF){
			cout << "NA" << endl;
		}
		else{
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1296
if __name__ == "__main__":
    while True:
        w, h = map(int, input().split())
        if w == 0 and h == 0:
            break
        c = []
        for _ in range(h):
            hi = list(map(int, input().split()))
            c.append(hi)
        
        visited = []
        for _ in range(h):
            hi = [False] * w
            visited.append(hi)
        
        st = []
        ans = 0

        for s_row in range(h):
            for s_col in range(w):
                if c[s_row][s_col] != 0 and not visited[s_row][s_col]:
                    st = [(s_row, s_col)]
                    while st:
                        now = st.pop()
                        for i in range(-1, 2):
                            for j in range(-1, 2):
                                if now[0] + i >= 0 and now[0] + i < h and now[1] + j >= 0 and now[1] + j < w and not visited[now[0] + i][now[1] + j] and c[now[0] + i][now[1] + j] != 0:
                                    visited[now[0] + i][now[1] + j] = True
                                    st.append((now[0] + i, now[1] + j))
                    ans += 1
        print(ans)


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

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

    int len = s.length();
    vector<char> ans;
    for( int i = 0; i < len; ++i ){
        if( s[i] != 'B' ) ans.push_back(s[i]);
        else if( !ans.empty() ) ans.pop_back();
    }

    for( auto itr = ans.begin(); itr != ans.end(); ++itr )
        cout << *itr;
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.Math;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    
    int A[] = new int[N];
    
    for (int i = 0; i < N; i++) A[i] = sc.nextInt();
    
    Arrays.sort(A);
    
    boolean flg = false;
    
    for (int i = 0; i + 1 < N; i++) if (A[i] == A[i + 1]) flg = true;
    
    
    if (flg) {
      System.out.println("NO");
    } else {
      System.out.println("YES");
    }
  }
}

Measured memory_bytes: 64776
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

// 入力
int N, M;
vector<vector<int> > G; // グラフ


// memorization

int dp[101010];

// f = 0 (if v is a leaf), else f = max{(f(nv) + 1}

int f(int v){
    
    if (dp[v] != -1) return dp[v];
    
    int result = 0;
    
    for (auto nv : G[v]) chmax(result, f(nv) + 1);
    
    return dp[v] = result;
}


int main(){
    
    cin >> N >> M;
    
    G.assign(N, vector<int>());
    
    for (int i = 0; i < M; i++){
        
        int x, y;
        cin >> x >> y;
        
        x--, y--;
        G[x].push_back(y); // 有向グラフ
    }
    
    
    // initialization
    
    for (int v = 0; v < N; v++) dp[v] = -1;
    
    
    int ans = 0;
    
    for (int v = 0; v < N; v++) chmax(ans, f(v));
    
    cout << ans << endl;
}








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

// N!を素因数分解してmapに表示
unordered_map<long long, int> prime_factor(long long N){
    unordered_map< long long, int> ret;
    for(long long n = 1; n <= N; n++){
        ll tmpn = n;
        for(long long i = 2; i * i <= n; i++){
            while(tmpn % i == 0){
                ret[i]++;
                tmpn /= i;
            }
        }
        if(tmpn != 1) ret[tmpn]++;
    }
    return ret;
}

int main(){
    ll N; cin >> N;
    unordered_map<ll,int> ret = prime_factor(N);
    int cnt = 0;

    //a^2b^4c^4パターン
    for(auto e: ret){
        for(auto f: ret){
            if(e == f) continue;
            for(auto g: ret){
                if(e == g || f == g) continue;
                if(f.first > g.first) continue;
                
                if(e.second >= 2 && f.second >= 4 && g.second >= 4) cnt++;
            }
        }
    }
    
    //a^4b^14パターン
    for(auto e: ret){
        for(auto f: ret){
            if(e == f) continue;

            if(e.second >= 14 && f.second >= 4) cnt++; 
        }
    }

    // a^3b^25パターン
    for(auto e: ret){
        for(auto f: ret){
            if(e == f) continue;

            if(e.second >= 24 && f.second >= 2) cnt++;
        }        
    }

    // a^74パターン
    for(auto e: ret){
        if(e.second >= 74) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <iostream>
using namespace std;
int main()
{
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;

    return 0;
}


Measured memory_bytes: 256