akhauriyash/Code-Regression huggingface dataset:
use std::io;

fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str
}

fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}



fn main(){

    let v = read_t_in_line::<i32>();
    let (n, a, b) = (v[0], v[1], v[2]);
    let mut result = 0;
    for i in 1..n+1 {
        let mut tmp = i;
        let mut sum = 0;
        while tmp > 0 {
            sum += tmp % 10;
            tmp /= 10;
        }
        if sum >= a && sum <= b {
            result += i;
        }
    }
    println!("{}", result);
}


Measured memory_bytes: 4352
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln endl
#define dbg(x) cerr<<#x<<" = "<<x<<endl
#define dbg2(x,y) cerr<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it<<ln;} cerr<<endl
#define dbgstlp32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cerr<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inp freopen("input.txt", "r", stdin)
#define outp freopen("output.txt", "w", stdout)
#define dbgm(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
typedef long long int  ll;
typedef long double  ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM = 2e5+5, MOD = 1e9+7, EPS = 1e-9;
int t,n,m,k,x,y;

vector<int> adj[21];

int dp[1<<21][22];

int rec(int mask,int id){
	if(mask==((1<<n) -1))
		return dp[mask][id]=1;
	if(id==n) return 0;
	if(dp[mask][id]!=-1) 
		return dp[mask][id];
	ll ans=0;
//	ans+=rec(mask,id+1);
	forstl(i,adj[id]){
		if(mask&(1<<i)) continue;
		ans+=(ll)rec(mask|(1<<i),id+1);
	}
	ans%=MOD;
	return dp[mask][id] = ans;
}

int main(){
	fastio;
	cin>>n;
	m = n;
	forn(i,n){
		forn(j,m){
			cin>>x;
		//	cout<<"ok"<<ln;
			if(x) adj[j].pb(i);
		}
	}
	forn(i,1<<21){
		forn(j,22) dp[i][j]=-1;
	}
//	cout<<"ok"<<ln;
	cout<<rec(0,0)<<ln;
	return 0;
}

Measured memory_bytes: 180608
#include<stdio.h>


long double arr[302][302][302]={0};
long long n;
long double fnc(long long a,long long b,long long c)
{	int p=a+b+c;
	int q=b+c;
	arr[0][0][0]=0;
	for(long long k=0;k<=c;k++)
	{
		for(long long j=0;j<=q;j++)
		{
			for(long long i=0;i<=p;i++)
			{	
				if(i+j+k==0)
					continue;
				// else if(i==1&&j==0&&k==0)
				// 	arr[i][j][k]=n*1.000000;

				if(i!=0)
				{
					arr[i][j][k]=((arr[i-1][j][k]*(long double)i)/(i+j+k));
				}
				if(j!=0)
				{
					arr[i][j][k]=arr[i][j][k]+(arr[i+1][j-1][k]*((long double)j))/(i+j+k);
				}
				if(k!=0)
				{
					arr[i][j][k]=arr[i][j][k]+(arr[i][j+1][k-1]*(long double)k)/(i+j+k);
				}
			
				arr[i][j][k]=arr[i][j][k]+(long double)n/(i+j+k);
		   		
			}						 
		}
	}
	return arr[a][b][c];
}

int main()
{
	scanf("%lld",&n);
	long long cntx=0,cnty=0,cntz=0;
	for(long long i=0;i<n;i++)
	{
		long long x;
		scanf("%lld",&x);
		if(x==1)
			cntx++;
		if(x==2)
			cnty++;
		if(x==3)
			cntz++;
	}
	long double sol = fnc(cntx,cnty,cntz);
	printf("%0.9Lf\n",sol);
	return 0;
}


Measured memory_bytes: 430208
A, B = map(int, input().split())

# (2n)^(2n+1) == 1.
# これが何個あるか。全部 XOR して偶数なら0、奇数なら1
count1 = max(0, (B + 1) // 2 - (A + 1) // 2)
res = count1 % 2

# のこり
if A % 2 == 1:
    res ^= A
if B % 2 == 0:
    res ^= B

print(res)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (int)(s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
constexpr long long INF = 1e18;
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;}

vector<int> build_next(const string &pat) {
  vector<int> next(pat.size() + 1);
  int i = 0, j = -1;
  next[i] = j;
  while (i < pat.size()) {
    while (j >= 0 and pat[j] != pat[i]) {
      j = next[j];
    }
    i += 1;
    j += 1;
    next[i] = j;
  }
  return next;
}

int kmp_search(const string &txt, const string &pat) {
    vector<int> next = build_next(pat);
    int i = 0, j = 0;
    while (i < txt.size() and j < pat.size()) {
        while (j >= 0 and txt[i] != pat[j]) {
            j = next[j];
        }
        i += 1;
        j += 1;
    }
    if (j == pat.size()) {
        return i - j;
    } else {
        return -1;
    }
}

signed main(){
	int N;
	cin >> N;
	string s;
	cin >> s;
	auto f =[&](int x)->bool{
		if(x==0)return false;
		REP(i,N-x+1){
			string tmp = s.substr(i,x);
			if(kmp_search(s.substr(i+x,N-i-x),tmp)!=-1)return true;
		}
		return false;
	};
	int l = 0, r = N/2 + 2;
	while(r - l > 1){
		int c = (l + r) / 2;
		if(!f(c)) r = c;
		else l = c;
	}
	cout << l << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();

		if (B - A - 2 * K == 0) {
			for (int i = A; i < A + K; i++) {
				System.out.println(i);
			}
			for (int i = B - K + 1; i <= B; i++) {
				System.out.println(i);
			}

		} else if (B - A - 2 * K > 0) {
			for (int i = A; i < A + K; i++) {
				System.out.println(i);
			}
			for (int i = B - K + 1; i <= B; i++) {
				System.out.println(i);
			}
		} else {
			for (int i = A; i <= B; i++) {
				System.out.println(i);
			}
		}
	}

}

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

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var price = 700;

            foreach (var item in input)
            {
                if (item == 'o')
                    price += 100;
            }
            Console.WriteLine(price);

        }

    }

}



Measured memory_bytes: 11220
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  string s;
  cin >> s;
  int l = 0, r = s.length() - 1;
  bool ans = true;
  while (l < r) {
    if(s[l] != s[r]) ans = false;
    ++l;
    --r;
  }
  l = 0; r = s.length() / 2 - 1;
  while (l < r) {
    if(s[l] != s[r]) ans = false;
    ++l;
    --r;
  }
  
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<Edge>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N;
  cin>>N;
  vector<ll> C(N+1,0),D(N+1,0),S(N+1,0),SS(N+1,0);
  REP(i,N){
    ll A;
    cin>>A;
    C[A]++;
    D[C[A]]++;
  }
  RREP(i,N){
    S[i]=S[i-1]+D[i];
    SS[i]=S[i]/i;
  }
  
  ll X=N;
  RREP(i,N){
    while(X>0 && i>SS[X]) X--;
    co(X);
  }
  return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<string> W;
    string tmp;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        W.emplace_back(tmp);
    }
    
    for (int i = 1; i < N; i++)
    {

        if (*W[i].begin() != *(W[i - 1].end() - 1))
        {
            cout << "No" << endl;
            return 0;
        }

        for (int j = 0; j < i; j++)
        {
            if (W[i] == W[j])
            {
                cout << "No" << endl;
                return 0;
            }

        }
        
    }

    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
int main(){
    int n,m,Q;cin >> n >> m >> Q;
    vector<int> L(m),R(m);
    vector<vector<int>> sum(n+1,vector<int>(n+1,0));
    for(int i=0;i<m;i++){
        cin >> L[i] >> R[i];
        sum[L[i]][R[i]]++;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            sum[i][j]+=sum[i][j-1]+sum[i-1][j];
            sum[i][j]-=sum[i-1][j-1];
        }
    }
    vector<int> ans(Q);
    for(int i=0;i<Q;i++){
        int p,q;cin >> p >> q;
        ans[i]=sum[q][q]-sum[q][p-1]-sum[p-1][q]+sum[p-1][p-1];
    }
    for(int i=0;i<Q;i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 3840
# -*- coding: utf-8 -*-
import sys
from collections import deque
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
A=list(map(int,input().split()))
edge=[[] for _ in range(N)]
for i in range(N-1):
    edge[i].append((i+1,1,1))
for i in range(N):
    for j in range(i+1,N):
        if A[i]<A[j]:
            edge[i].append((j,A[i],A[j]))
que=deque([0])
d=[0]*N
d[0]=1000
while que:
    v=que.popleft()
    for nv,be,af in edge[v]:
        tmp=d[v]//be
        if d[nv]<d[v]-tmp*be+tmp*af:
            d[nv]=d[v]-tmp*be+tmp*af
            que.append(nv)
print(d[-1])

Measured memory_bytes: 68568
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MOD 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who forgive themselves, and are able to accept their true nature...THEY ARE THE STRONG ONES

    int n, k;
    cin >> n >> k;
    int sol = 0;
    while(n)
    {
        n /= k;
        sol++;
    }
    cout << sol;
    
    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
	int dx = abs(sx - tx), dy = abs(sy - ty);
	if (sx <= tx&&sy <= ty) {
		rep(i, 0, dx)
			cout << "R";
		rep(i, 0, dy)
			cout << "U";
		rep(i, 0, dx)
			cout << "L";
		rep(i, 0, dy)
			cout << "D";
		cout << "D";
		rep(i, 0, dx + 1)
			cout << "R";
		rep(i, 0, dy + 1)
			cout << "U";
		cout << "L";
		cout << "U";
		rep(i, 0, dx + 1)
			cout << "L";
		rep(i, 0, dy + 1)
			cout << "D";
		cout << "R";
		cout << endl;

	}
	else if (sx <= tx&&sy >= ty) {
		rep(i, 0, dx)
			cout << "R";
		rep(i, 0, dy)
			cout << "D";
		rep(i, 0, dx)
			cout << "L";
		rep(i, 0, dy)
			cout << "U";
		cout << "U";
		rep(i, 0, dx + 1)
			cout << "R";
		rep(i, 0, dy+1)
			cout << "D";
		cout << "L";
		cout << "D";
		rep(i, 0, dx+1)
			cout << "L";
		rep(i, 0, dy+1)
			cout << "U";
		cout << "R";
		cout << endl;
	}
	else if (sx >= tx&&sy <= ty) {
		rep(i, 0, dx)
			cout << "L";
		rep(i, 0, dy)
			cout << "U";
		rep(i, 0, dx)
			cout << "R";
		rep(i, 0, dy)
			cout << "D";
		cout << "D";
		rep(i, 0, dx + 1)
			cout << "L";
		rep(i, 0, dy + 1)
			cout << "U";
		cout << "R";
		cout << "U";
		rep(i, 0, dx + 1)
			cout << "R";
		rep(i, 0, dy + 1)
			cout << "D";
		cout << "L";
		cout << endl;

	}
	else if (sx >= tx&&sy >= ty) {
		rep(i, 0, dx)
			cout << "L";
		rep(i, 0, dy)
			cout << "D";
		rep(i, 0, dx)
			cout << "R";
		rep(i, 0, dy)
			cout << "U";
		cout << "U";
		rep(i, 0, dx + 1)
			cout << "L";
		rep(i, 0, dy + 1)
			cout << "D";
		cout << "R";
		cout << "D";
		rep(i, 0, dx + 1)
			cout << "R";
		rep(i, 0, dy + 1)
			cout << "U";
		cout << "L";
		cout << endl;
	}
	return 0;
}

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

long long int l, r;
long long int mod = 1e9 + 7;
long long int memo[65][3][3][3] = { 0 };

int getBit(long long int nr, long long int pos)
{
    return ((1LL << pos) & nr) > 0;
}

long long int f(int pos, int flagx, int flagy, int msb)
{
    if (pos == -1)
        return 1;
    if (memo[pos][flagx][flagy][msb] != -1)
        return memo[pos][flagx][flagy][msb];

    long long int cur = 0;
    //x0  y0
    int lbit = getBit(l, pos);
    int rbit = getBit(r, pos);
    if (flagx || lbit == 0)
        cur += f(pos - 1, flagx, rbit ? rbit : flagy, msb);
    //x0 y1
    if ((flagx || lbit == 0) && (flagy || rbit == 1) && msb)
        cur += f(pos - 1, flagx, flagy, msb);
    //x1 y1
    if (flagy || rbit == 1)
        cur += f(pos - 1, !lbit ? 1 : flagx, flagy, 1);

    cur %= mod;
    memo[pos][flagx][flagy][msb] = cur;
    return cur;
}

int main()
{
    std::cin >> l >> r;

    for (int i = 0; i < 64; ++i)
    {
        for (int j = 0; j < 2; ++j)
        {
            for (int k = 0; k < 2; ++k)
            {
                for (int q = 0; q < 2; ++q)
                    memo[i][j][k][q] = -1;
            }
        }
    }
    std::cout << f(62, 0, 0, 0);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>

int main()
{
    int N, H, W;
    std::cin >> N >> H >> W;

    std::cout << (N - H + 1) * (N - W + 1) << std::endl;

    return 0;
}

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

namespace AtCoder.Contests.ABC170
{
    /// <summary>
    /// 
    /// </summary>
    static class B
    {
        static void Main(string[] args)
        {
            var x = NextInt();
            var y = NextInt();

            if (y % 2 != 0)
            {
                Console.WriteLine("No");
                return;
            }
            if (y < 2*x)
            {
                Console.WriteLine("No");
                return;
            }
            if (y > 4 * x)
            {
                Console.WriteLine("No");
                return;
            }
            Console.WriteLine("Yes");
        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


Measured memory_bytes: 27532
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int64_t N;
    cin>>N;
    int64_t ans=1;
    for(int i=1;i<=N;i++){
      ans=ans*i%1000000007;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll N, L;
    cin >> N >> L;
    vector<ll> A(N);
    rep(i, N) { cin >> A[i]; }
    int s = -1;
    rep(i, N - 1) {
        if(A[i] + A[i + 1] >= L)
            s = i;
    }
    if(s == -1) {
        cout << "Impossible" << endl;
    } else {
        cout << "Possible" << endl;
        for(int i = 0; i < s; i++) {
            cout << i + 1 << endl;
        }
        for(int i = N - 2; i > s; i--) {
            cout << i + 1 << endl;
        }
        cout << s + 1 << endl;
    }

    return 0;
}

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

using namespace std;

int main()
{
	int k, s;
	cin >> k >> s;
	int ans = 0;
	for (int x = 0; x <= k; x++)
		for (int y = 0; y <= k; y++)
			if (0 <= s - x - y && s - x - y <= k)
				ans++;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, i;
	int min, max;
	int r[200000];
	
	scanf("%d\n", &n);
	
	for (i = 0; i < n; i++) {
		scanf("%d\n", &r[i]);
	}
	
	max = -2000000000;
	min = r[0];
	
	for ( i = 1; i < n; i++) {
		if (r[i] - min > max) {
			max = r[i] - min;
		}
		
		if (r[i] < min) {
			min = r[i];
		}
	}
	
	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 1380
#include <stdio.h>
                                                                                                
  
int main(void){
                                                                                                
   
    int n,t;

    int f = 0;
   
      
    scanf("%d", &n);
   

    for( t = n ; t > 0 ; t = t / 10 ){

        f += t % 10;

        }


    if( n % f == 0 ) printf("Yes\n");

    else printf("No\n");


    return 0;
                                                          
}

Measured memory_bytes: 128
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> L >> R >> N >> M;
	vector<int>v(L);
	for (int i = 0; i < L; i++)cin >> v[i];
	v.push_back(N);
	sort(v.begin(), v.end());
	vector<int>w(R);
	for (int i = 0; i < R; i++)cin >> w[i];
	w.push_back(M);
	sort(w.begin(), w.end());
	if (v.back() < w.front()) {
		cout << "No War\n";
	}
	else {
		cout << "War\n";
	}
	return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k; cin>>n>>k;
  ll mod=1;
  rep(i,100){
    mod=(mod*10)%MOD;
  }
  set<ll> s;
  rep(i,n+1){
    s.insert((mod+i)%MOD);
  }
  ll m=s.size();
  
  ll ans=0;
  ireps(i,k,n+1){
    ll min=(i-1)*i/2;
    ll max=(n+1)*n/2-(n-i+1)*(n-i)/2;
    ans=(ans+max-min+1)%MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 12976
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>

const int MaxN = 2000 + 5;
const int INF = 0x7F7F7F7F;

int N, K, Q, V;
int A[MaxN], D[MaxN];

void init() {
  scanf("%d %d %d", &N, &K, &Q);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &A[i]);
    D[i] = A[i];
  }
  std::sort(D + 1, D + 1 + N);
}

void solve() {
  int ans = INF;

  for (int x = 1; x <= N; ++x) {
    for (int i = 1; i <= N; ++i)
      if (A[i] < D[x]) A[i] = -1;
    std::priority_queue<int> pq, pq2;
    while (!pq.empty()) pq.pop();
    while (!pq2.empty()) pq2.pop();
    int num = 0, num2 = 0;
    for (int i = 1; i <= N; ++i) {
      if (A[i] == -1) {
        while (num >= K) {
          pq2.push(pq.top());
          pq.pop();
          num--; num2++;
        }
        while (!pq.empty()) pq.pop();
        num = 0;
      } else pq.push(-A[i]), num++;
    }
    while (num >= K) {
      pq2.push(pq.top());
      pq.pop();
      num--; num2++;
    }
    while (!pq.empty()) pq.pop();
    num = 0;

    int y = 0;
    if (num2 < Q) continue;
    for (int i = 1; i <= Q; ++i) {
      y = std::max(y, -pq2.top());
      pq2.pop();
    }
    ans = std::min(ans, y - D[x]);
  }

  printf("%d\n", ans);
}

int main() {
  init();
  solve();
  return 0;
}

Measured memory_bytes: 256
// 解き直し.
// https://img.atcoder.jp/hitachi2020/editorial.pdf
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
#define a first
#define b second
#define all(x) x.begin(), x.end()
const LL UPPER = 202020202020202020;
const int LIMIT = 29;
LL dp[202020][LIMIT], zCum[202020];
int cnt[LIMIT];

struct store{
    LL a, b;
    bool operator < (const store& rhs) const{
        return a * (rhs.b + 1) > rhs.a * (b + 1);
    }
};

int main(){
    
    // 1. 入力情報.
    int N;
    LL T, a, b;
    scanf("%d %lld", &N, &T);
    vector<store> v1;
    vector<LL> v2;
    rep(i, N){
        scanf("%lld %lld", &a, &b);
        if(a == 0){
            v2.pb(b);
        }else{
            store s;
            s.a = a;
            s.b = b;
            v1.pb(s);
        }
    }
    
    // 2. sort.
    sort(all(v1));
    sort(all(v2));
    // for(auto &p : v1) printf("a=%lld b=%lld\n", p.a, p.b);
    
    // 3. 累積和.
    int l2 = v2.size();
    rep(i, l2) zCum[i + 1] = zCum[i] + v2[i] + 1;
    // rep(i, l2 + 1) printf("%lld ", zCum[i]);
    // puts("");
    
    // 4. 初期化.
    rep(i, 202020) repx(j, 1, LIMIT) dp[i][j] = UPPER;
    
    // 5. dp更新.
    int l1 = v1.size();
    dp[0][0] = 0;
    repx(i, 1, l1 + 1){
        rep(j, min(LIMIT, i + 1)){
            if(j){
                LL t = min(T + 1, v1[i - 1].a * (dp[i - 1][j - 1] + 1) + v1[i - 1].b + dp[i - 1][j - 1] + 1);
                if(i > j) dp[i][j] = min(dp[i - 1][j], t);
                else      dp[i][j] = t;
            }
        }
    }
    // rep(i, l1 + 1){
    //     rep(j, min(LIMIT, i + 1)) printf("%lld ", dp[i][j]);
    //     puts("");
    // }
    
    // 6. いくつのお店を回ることができるか？
    rep(i, min(LIMIT, l1 + 1)){
        // a >= 1 となるお店を, i個回る場合について, それぞれ計算.
        LL res = T - dp[l1][i];
        if(res >= 0){
            int at = upper_bound(zCum, zCum + l2 + 1, res) - zCum;
            cnt[i] = i + (at - 1);
            // printf("at=%d cnt[%d]=%d\n", at, i, cnt[i]);
        }
    }
    
    // 7. 出力.
    int ans = 0;
    rep(i, LIMIT) ans = max(ans, cnt[i]);
    printf("%d\n", ans);
    return 0;
    
}

Measured memory_bytes: 52340
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
LL a,b,c,ans,hb;
int main(){
	scanf("%lld%lld",&a,&b);
	for (hb=1ll<<61;hb>0&&(a&hb)==(b&hb);hb>>=1) a&=a^hb,b&=b^hb;
	if (hb==0) return puts("1"),0;
	for (c=1;c<=b-hb;c<<=1);
	ans=hb+hb-a+min(0ll,c-a);
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

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

    int orderToStudent[100000]; // Order -> Student
    int order;
    for (int i=0; i<n; i++) {
        cin >> order;
        orderToStudent[order] = i+1;
    }

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

    return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        if (T.startsWith(S)){
          System.out.println("Yes");
        }else {
          System.out.println("No");
        }
    }
}

Measured memory_bytes: 35588
<?php
ini_set('memory_limit', -1);
list($v, $e, $r) = explode(" ", trim(fgets(STDIN)));
$edges = array_fill(0, $v, []);
for ($i = 0; $i < $e; $i++) {
    list($s, $t, $d) = explode(" ", trim(fgets(STDIN)));
    $edges[$s][] = [$t, $d];
}
$INF = 10 ** 10;
$visited = array_fill(0, $v, false);
$dist = array_fill(0, $v, $INF);
$dist[$r] = 0;
$queue = new SplPriorityQueue();
$queue->insert([$r, 0], 0);
while (!$queue->isEmpty()) {
    list($node, $score) = $queue->extract();
    if ($visited[$node]) {
        continue;
    }
    $visited[$node] = true;
    foreach ($edges[$node] as $edge) {
        list($to, $cost) = $edge;
        $newScore = $score + $cost;
        if ($newScore < $dist[$to]) {
            $dist[$to] = $newScore;
            $queue->insert([$to, $newScore], -$newScore);
        }
    }
    //unset($edges[$node]);
}

foreach ($dist as $result) {
    if ($result === $INF) {
        echo "INF\n";
    } else {
        echo $result . "\n";
    }
}


Measured memory_bytes: 436696
N = int(input())

def dfs(a):
    if int(a) > N:
        return 0    
    if '7' in a and '5' in a and '3' in a:
        ans = 1
    else:
        ans = 0
    ans += dfs(a+'7')
    ans += dfs(a+'5')
    ans += dfs(a+'3')
    return ans

print(dfs('0'))

Measured memory_bytes: 3060
#include <iostream>
int main(int argc, char const *argv[]) {
  int K, S, ans = 0;
  std::cin >> K >> S;
  for (size_t x = 0; x <= K; x++) {
    for (size_t y = 0; y <= K; y++) {
      int z = S - x - y;
      if(0 <= z && z <= K) ans++;
    }
  }
  std::cout<< ans <<"\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n,k;
ll f(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return 0;
    ll tmp=((a-1)/b)*2+((a%b)==0);
    //cout<<a<<b<<tmp<<endl;
    return f(b,a%b)+tmp*b;
}
int main(void){
    cin>>n>>k;
    cout<<f(n-k,k)+n<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  ll K;
  cin>>K;
  int N = S.size();
  for(int i=0;i<S.size();++i) {
    if('z'-S[i]+1<=K) {
      K -= ('z'-S[i]+1)%26;
      S[i] = 'a';
    }
  }
  K %= 26;
  if(S[N-1]+K<='z') S[N-1] += K;
  else S[N-1] = S[N-1]+K-'z'+'a'-1;
  cout<<S<<endl;
}



Measured memory_bytes: 3736
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  lint A, B, M; cin >> A >> B >> M;
  vector<lint> a(A);
  vector<lint> b(B);
  for(int i = 0; i < A; i++)
    cin >> a[i];
  for(int i = 0; i < B; i++)
    cin >> b[i];
  lint ans = INF;
  for(int i = 0; i < M; i++) {
    lint x, y, c; cin >> x >> y >> c;
    x--;
    y--;
    ans = min(ans, a[x] + b[y] - c);
  }

  sort(ALL(a));
  sort(ALL(b));
  ans = min(ans, a[0] + b[0]);
  cout << ans << endl;

  return 0;
}


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

typedef struct{
  int id;
  int parent;
  int degree;
  int *child;
  int depth;
}Tree;



int main(){
  Tree T[100000];
  int n, i, j, k, c=0;

  scanf("%d",&n);
  if( n<1 || 100000<n ){
    exit(0);
  }
  
  for( i=0 ; i<n ; i++ ){
    T[i].id = i;
    T[i].parent = -1;
  }
       
  for( i=0 ; i<n ; i++ ){
    scanf("%d",&k);
    	  
    scanf("%d",&T[k].degree);
    
    if( T[k].degree != 0 ){
      T[k].child = (int *)malloc(sizeof(int) * T[k].degree);
      
      for( j=0 ; j<T[k].degree ; j++ ){
	scanf("%d",&T[k].child[j]);
	T[T[k].child[j]].parent = k;
      }
    }
  }

  for( i=0 ; i<n ; i++ ){
    if( T[i].parent == -1){
      T[i].depth = 0;
      break;	
    }
  }

  for( i=0 ; i<n ; i++ ){
    c=0;
    k=i;

    while( k != -1 ){
      k = T[k].parent;
      c++;
    }
    T[i].depth = c-1;
  }

  for( i=0 ; i<n ; i++ ){
    printf("node %d: parent = %d, depth = %d, ", T[i].id, T[i].parent, T[i].depth);

    if(T[i].depth == 0){
      printf("root, ");
    }
    else{
      if(T[i].degree == 0){
	printf("leaf, ");
      }
      else{
	printf("internal node, ");
      }
    }

    printf("[");
    for( j=0 ; j<T[i].degree ; j++ ){
      if(j == T[i].degree-1){
	printf("%d",T[i].child[j]);
	free(T[i].child);
      }
      else{
	printf("%d, ",T[i].child[j]);
      }
    }
    printf("]\n");
  }

  return 0;
}
		       
  

Measured memory_bytes: 4208
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 
 
int32_t main()
{
    fast;
    int x; cin >> x;
    if(x >= 400 and x <= 599) cout << 8;
    else if(x >= 600 and x <= 799) cout << 7;
    else if(x >= 800 and x <= 999) cout << 6;
    else if(x >= 1000 and x <= 1199) cout << 5;
    else if(x >= 1200 and x <= 1399) cout << 4;
    else if(x >= 1400 and x <= 1599) cout << 3;
    else if(x >= 1600 and x <= 1799) cout << 2;
    else if(x >= 1800 and x <= 1999) cout << 1;
    
    
    
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(int)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << (H - h) * (W - w) << endl;
	return 0;
}
/* --------------------------------------- */


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	in >> N;

	std::vector<std::pair<LL, LL>>ans;
	for (LL i = 1; i <= N; ++i)
	{
		for (LL j = i + 1; j <= N; ++j)
		{
			if (N % 2 == 0 && j == N - i + 1) continue;
			if (N % 2 == 1 && j == N - i) continue;
			ans.push_back(std::pair<LL, LL>(i, j));
		}
	}

	out << ans.size() << std::endl;
	rep(i, ans.size()) out << ans[i].first << " " << ans[i].second << std::endl;
}


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const int N = 2e5+234;
const long long inf = 1e17;

long long a[N];

void solve() {
	int n; scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%lld", a+i);
		if (i == 0) continue;
		a[i] += a[i-1];
	}
	long long ans = inf;
	for (int i = 0; i < n-1; ++i) {
		ans = min(ans, abs(a[i]-(a[n-1]-a[i])));
	}
	printf("%lld", ans);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 1792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author hamaron
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>

using namespace std;

class CDaydream {
public:
    void solve(std::istream &in, std::ostream &out) {
        vector<string> candidateWords = { "dream", "dreamer", "erase", "eraser" };
        string target;
        in >> target;
        int lastPos = target.size() - 1;
        while (true) {
            bool foundMatchInThisLoop = false;
            for (auto& word: candidateWords) {
                size_t foundPos = target.rfind(word);
                if (foundPos != string::npos && foundPos == (target.size() - word.size())) {
                    foundMatchInThisLoop = true;
                    target = foundPos == 0 ?
                             "" : target.substr(0, target.size() - word.size());
                    break;
                }
            }

            if (!foundMatchInThisLoop) {
                out << "NO";
                return;
            }

            if (target.size() == 0) {
                out << "YES";
                return;
            }
        }
    }
};


int main() {
	CDaydream solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int ans = 0;
  int a = min(A, B);
  int b = max(A, B);
  A = a;
  B = b;
  b = min(B, C);
  int c = max(B, C);
  B = b;
  C = c;
  a = min(A, B);
  b = max(A, B);
  A = a;
  B = b;
  rep(i, X) {
    C *= 2;
  }
  cout << A + B + C << endl;
}


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

int main() {
  int sum = 0;
  int n;
  for (int i=0; i<3; i++) {
    cin >> n;
    sum += n;
  }
  if (sum > 21)
    cout << "bust";
  else
    cout << "win";
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
/*
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};
*/
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
//ll MOD = 1000000007;
ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

//デバッグ
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll N;
vector<ll> A;

void solve(){
  ll sum = 0;
  rep(i, N) sum += A[i];
  bitset<2000010> bset;
  bset[0] = 1;
  rep(i, N){
    bset = bset | (bset<<A[i]);
  }
  for(ll i = (sum+1)/2;;i++){
    if(bset[i] == 1){
      cout << i << endl;
      return;
    }
  }
}

int main(){
  cin >> N;
  A.resize(N);
  rep(i, N) cin >> A[i];
  solve();
}


Measured memory_bytes: 1280
package main

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

//FOR I/O : STARTS
var Reader *bufio.Reader = bufio.NewReader(os.Stdin)
var Writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func Printf (f string, a ...interface{}) { fmt.Fprintf(Writer, f, a...) }
func Scanf (f string, a ...interface{}) { fmt.Fscanf(Reader, f, a...) }
func Println (a ...interface{}) { fmt.Fprintln(Writer, a...)}
func Scanln (a ...interface{}) { fmt.Fscanln(Reader, a...)}
//I/O ENDS HERE

func Abs(x int) int {
    if x < 0 {
        return -x
    }
    return x
}

func Min(x, y int) int {
    if x < y {
        return x
    } else {
        return y
    }
}

func Max(x, y int) int {
    if x >= y {
        return x
    } else {
        return y
    }
}

func Ceil(x, y int64) int64 {
    //returns x/y
    if x%y == 0 {
        return x/y
    } else {
        return int64(x/y)+1
    }
}

func main() {
    defer Writer.Flush()

    var n, k, d int
    Scanf("%d %d\n", &n, &k)

    var arr [105][105]bool

    for i := 1; i <= k; i += 1 {
        Scanf("%d\n", &d)
        var temp int
        for j := 0; j < d; j += 1 {
            Scanf("%d ", &temp)
            arr[temp][i] = true
        }
    }

    //find ans
    cnt := 0

    for i := 1; i <= n; i += 1 {
        flag := false
        for j := 1; j <= k; j += 1 {
            if arr[i][j] {
                flag = true
                break
            }
        }
        if !flag  {
            cnt += 1
        }
    }

    Println(cnt)

}


Measured memory_bytes: 1892
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s[0] == s[1] && s[1] == s[2]) cout << "Yes";
    else if (s[1] == s[2] && s[2] == s[3]) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int x;
    bool f=1;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        if(x%2==0&&x%5!=0&&x%3!=0)f=0;
    }
    if(!f)printf("DENIED\n");
    else printf("APPROVED\n");
}


Measured memory_bytes: 256
a, b, c = map(int, input().split())

if a <= b and b <=c:
    print(a,b,c)
elif a <= c and c <= b:
    print(a,c,b)
elif b <= a and a <= c:
    print(b,a,c)
elif b <= c and c <= a:
    print(b,c,a)
elif c <= a and a <= b:
    print(c,a,b)
elif c <= b and b <= a:
    print(c,b,a)


Measured memory_bytes: 5596
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for ( int i=1; i<=int(n); i++ )  
#define MP make_pair
#define PB push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef pair<LL, int> pii;
typedef long double LD;
const int INF = 0x3f3f3f3f;

template <class T>  
inline bool RD(T &ret) {  
        char c; int sgn;  
        if (c = getchar(), c == EOF) return 0;  
        while (c != '-' && (c<'0' || c>'9')) c = getchar();  
        sgn = (c == '-') ? -1 : 1 , ret = (c == '-') ? 0 : (c - '0');  
        while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0');  
        ret *= sgn;  
        return 1;  
}  
template <class T>  
inline void PT(T x) {  
        if (x < 0) putchar('-') ,x = -x;  
        if (x > 9) PT(x / 10);  
        putchar(x % 10 + '0');  
}

const int N = 3e3 + 100;
set<int> from[N];
set<int> to[N];
int val[N];
queue<int> que;
int deg[N], ans[N];

void updatewin(int u) {
	for(auto v : from[u]) {
		if(ans[v] != -1) continue;
		if(val[v] > val[u]) {
			deg[v] --;
			from[v].insert(u);
			if(deg[v] == 0) que.push(v);
		}
	}
}

void updatefail(int u) {
	for(auto v : from[u]) {
		if(ans[v] != -1) continue;
		if(val[v] > val[u]) {
			ans[v] = 1; 
			updatewin(v);	
		}
	}
}
int main() {
	memset(ans, -1, sizeof(ans));
	int n;
	cin >> n;
	for(int i = 1; i <= n; i ++) scanf("%d", &val[i]);	
	for(int i = 1; i < n; i ++) {
		int u, v;
		scanf("%d %d", &u, &v);
		if(val[u] <= val[v]) {
			from[u].insert(v);
			to[v].insert(u);
		}
		if(val[u] >= val[v]) {
			from[v].insert(u);
			to[u].insert(v);
		}	
	}
	for(int u = 1; u <= n; u ++) {
		int sz = 0;
		for(auto v : to[u]) {
			if(from[u].count(v) == 0) deg[u] ++;
		}
		if(deg[u] == 0) que.push(u);
	}
	while(! que.empty() ) {
		int u = que.front();
		que.pop();
		ans[u] = 0;
		updatefail(u);
	}
	vector<int> res;
	for(int i = 1; i <= n; i ++) 
		if(ans[i] == 1) res.push_back(i);
	for(int i = 0; i < SZ(res); i ++) 
		printf("%d%c", res[i], i == SZ(res) - 1 ? '\n' : ' ');

}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n,x = 0; cin>>n;
	vector<int> num(n);
	for(int i=0;i<n;i++){
		cin>>num[i];
		x ^= num[i];
	}
	for(int i=0;i<n;i++) cout<<(x^num[i])<<' ';
}

Measured memory_bytes: 3972