akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
int a[s.size()]={0};
int num1,num2,num3;
for(int i=0;i<(s.size())-2;i++){
    if(s[i]=='1')num1=100;
    else if(s[i]=='2')num1=200;
    else if(s[i]=='3')num1=300;
    else if(s[i]=='4')num1=400;
    else if(s[i]=='5')num1=500;
    else if(s[i]=='6')num1=600;
    else if(s[i]=='7')num1=700;
    else if(s[i]=='8')num1=800;
    else if(s[i]=='9')num1=900;
if(s[i+1]=='1')num2=num1+10;
else if(s[i+1]=='2')num2=num1+20;
else if(s[i+1]=='3')num2=num1+30;
else if(s[i+1]=='4')num2=num1+40;
else if(s[i+1]=='5')num2=num1+50;
else if(s[i+1]=='6')num2=num1+60;
else if(s[i+1]=='7')num2=num1+70;
else if(s[i+1]=='8')num2=num1+80;
else if(s[i+1]=='9')num2=num1+90;
if(s[i+2]=='1')num3=num2+1;
else if(s[i+2]=='2')num3=num2+2;
else if(s[i+2]=='3')num3=num2+3;
else if(s[i+2]=='4')num3=num2+4;
else if(s[i+2]=='5')num3=num2+5;
else if(s[i+2]=='6')num3=num2+6;
else if(s[i+2]=='7')num3=num2+7;
else if(s[i+2]=='8')num3=num2+8;
else if(s[i+2]=='9')num3=num2+9;
if(num3==753){
    cout<<0;
    return 0;
}
a[i]=abs(num3-753);


}
sort(a,a+(s.size()));
for(int i=0;i<s.size();i++){
    if(a[i]!=0){
    cout<<a[i];
    return 0;
    }
}
return 0;
}

Measured memory_bytes: 256
/**                                                     **\
 *    created by:   Divianshu Bansal                     *
 *    e-mail id:    god_coder@icloud.com                 *
*                                                        */

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>


using namespace std;
using namespace __gnu_pbds;


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>new_data_set;
#define MOD 1000000007
#define int long long
#define BIG 998244353
#define pf push_front
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589


int power(int x, int y) {
    int r = 1, z = x;
    while (y) {
        if (y & 1)r *= z;
        z *= z; y = y >> 1;
    }
    return r;
}
int powerm(int x, int y, int p) {
    int r = 1;
    while (y) {
        if (y & 1)r = (r * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return r % p;
}
int modinv(int x, int m) {
    return powerm(x, m - 2, m);
}
int logarithm(int a, int b) {
    int x = 0;
    while (a > 1) {
        x++;
        a /= b;
    }
    return x;
}
int max3(int a, int b, int c) {
    return max(a, max(b, c));
}
int min3(int a, int b, int c) {
    return min(a, min(b, c));
}
int32_t main() {
    fast;
    char x;
    cin >> x;
    int val = x - 'A';
    if (val >= 0 && val < 26) {
        cout << "A";
    }
    else {
        cout << "a";
    }
    return 0;
}

Measured memory_bytes: 3532
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();
    let t: String = read();

    let mut s_chars: Vec<char> = s.chars().collect();
    let mut t_chars: Vec<char> = t.chars().collect();
    s_chars.sort();
    t_chars.sort();
    let s_sorted: String = s_chars.into_iter().collect();
    let t_sorted: String = t_chars.into_iter().rev().collect();

    // println!("{}", s_sorted);
    // println!("{}", t_sorted);

    let mut res = "";
    for (s, t) in s_sorted.as_bytes().iter().zip(t_sorted.as_bytes().iter()) {
        // println!("{} {}", s, t);
        if s < t {
            res = "Yes";
            break
        } else if s > t {
            res = "No";
            break
        }
    }

    if res == "" {
        if s_sorted.len() >= t_sorted.len() {
            res = "No";
        } else {
            res = "Yes";
        }
    }

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


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1 << 17;

class SegTree{

public:

	int n;
	int dat[2 * MAX_N - 1];
    int dummy = 2147483647;

	SegTree(int _n){
		init(_n);
	}

	void init(int n_){
		n = 1;
		while(n < n_) n *=2;
		rep(i, 2 * n - 1) dat[i] = dummy;
	}

	void update(int k, int a){
		k += n-1;
		dat[k] = a;
		while(k > 0){
			k = (k - 1) / 2;
			dat[k] = min(dat[k*2+1], dat[k *2+2]);
		}
	}

	// min of [a, b)
	// node k, corresponding [l, r)
	int query(int a, int b){
		return _query(a, b, 0, 0, n);
	}

	int _query(int a, int b, int k, int l, int r){
		if(r <= a || b <= l) return dummy;
		if(a <= l && r <= b) return dat[k];
		else{
			int vl = _query(a, b, k*2+1, l, (l+r)/2);
			int vr = _query(a, b, k*2+2, (l+r)/2, r);
			return min(vl, vr);
		}
	}
};

int main() {

	int n, q;
	cin >> n >> q;

	SegTree st(n);
	rep(i, q){
		int c, x, y; cin >> c >> x >> y;
		if(c == 0) st.update(x, y);
		if(c == 1) cout << st.query(x, y+1) << endl;
	}
}

Measured memory_bytes: 4120
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    string str = to_string(n);
    int len = str.length();
    int sum = 0;
    for(int i = 0; i < len; i++){
        string chn = to_string(str[i]-48);
        int x = stoi(chn);
        sum+=x;
    }
    if(n % sum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

int main(){

  int a,b;
  
  cin >> a >> b;
  
  if(a >= 10 || b >= 10){
    cout << -1 << endl;
    return 0;
  }
  
  cout << a * b <<  endl;
    
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define I_O		ios::sync_with_stdio(false),cin.tie(0)
#define ll		long long
#define ff		first
#define ss		second
#define mod 		1000000007
#define rep(i,n)	for(ll i=1;i<=n;i++)
#define repv(i,a,n)	for(ll i=a;i<=n;i++)
#define pb 		push_back
#define newl		'\n'
#define deb(x)		cout<<x<<" "
int main() 
{  
	I_O;
	string s,t;	cin>>s>>t;
	int cnt = 0;
	for(int i=0;s[i]!='\0';i++)
	{
		if(s[i] != t[i])	cnt++;
	}
	cout<<cnt;
} 


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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,m;cin>>n>>m;
  string s;cin>>s;
  vector<vector<ll>>g(n);
  vector<ll>v(n);
  rep(i,0,n)v[i]=s[i]-'A';
  vector<vector<ll>>cnt(n,vector<ll>(2,0));
  rep(i,0,m){
    ll a,b;cin>>a>>b;a--;b--;
    g[a].PB(b);
    if(a!=b)g[b].PB(a);
    cnt[a][v[b]]++;
    if(a!=b)cnt[b][v[a]]++;
  }
  vector<bool>t(n,true);
  queue<ll>que;
  judge=false;
  rep(i,0,n)que.push(i);
  while(!que.empty()){
    ll k=que.front();
    que.pop();
    if(!t[k])continue;
    if(cnt[k][0]<=0||cnt[k][1]<=0){
      t[k]=false;
      for(auto to:g[k]){
        cnt[to][v[k]]--;
        que.push(to);
      }
    }
  }
  rep(i,0,n)if(t[i])judge=true;
  ans1(judge);
  return 0;
}

Measured memory_bytes: 25168
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second

using namespace std;

std::vector<pair<long,long>> v;
int n;
int solve(int h)
{
	int arr[h+1];
	arr[0]=0;
	for(int i=1;i<=h;i++)
	{
		arr[i]=INT_MAX;
		for(auto x : v)
		{
			int p = i- x.F;
			if(p<0) p=0;
			arr[i] = min(arr[i],arr[p]+x.S);
			
		}
	}
	return arr[h];
		
}


int32_t main()
{
	
	
	long h; cin>>h>>n;
	
	v.resize(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>v[i].F>>v[i].S;

	}
//	sort(v.begin(), v.end());

//	for(auto x: v) cout<<x.F<<" "<<x.S<<endl;
	int ans = solve(h);
	cout<<ans;

	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
vector<int> E[5050];
ll G[5050];
int C[5050];
ll dp[5050][5050][2];
ll mo=1000000007;
ll tmp[5050][2]={};

void dfs(int cur,int pre) {
	C[cur]=1;
	dp[cur][1][0]=1;
	
	FORR(e,E[cur]) if(e!=pre) {
		int x,y;
		dfs(e,cur);
		ZERO(tmp);
		for(x=1;x<=C[cur];x++) {
			for(y=1;y<=C[e];y++) {
				// con
				(tmp[x+y][0] += dp[cur][x][0]*dp[e][y][0]+dp[cur][x][1]*dp[e][y][1])%=mo;
				(tmp[x+y][1] += dp[cur][x][0]*dp[e][y][1]+dp[cur][x][1]*dp[e][y][0])%=mo;
				// rem
				(tmp[x][1] += dp[cur][x][0]*dp[e][y][0]%mo*G[y]+dp[cur][x][1]*dp[e][y][1]%mo*G[y])%=mo;
				(tmp[x][0] += dp[cur][x][0]*dp[e][y][1]%mo*G[y]+dp[cur][x][1]*dp[e][y][0]%mo*G[y])%=mo;
			}
		}
		swap(tmp,dp[cur]);
		C[cur]+=C[e];
	}
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	G[2]=1;
	for(i=3;i<=5030;i++) G[i]=G[i-2]*(i-1)%mo;
	
	cin>>N;
	FOR(i,N-1) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	
	dfs(0,-1);
	ll ret=0;
	for(i=1;i<=N;i++) {
		ret+=dp[0][i][0]*G[i]%mo;
		ret-=dp[0][i][1]*G[i]%mo;
	}
	cout<<(ret%mo+mo)%mo<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 396544
import java.util.Scanner;

class Main {

	public static long nCm(int n, int m){
		long ans = 1;
		for(int i = 0; i < m; i++){
			ans *= (long)(n - i);
			ans /= (long)(i + 1);
		}
		return ans;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int p = sc.nextInt();

		int a;
		int even = 0;
		int odd = 0;		
		for(int i=0; i<n; i++){
			a = sc.nextInt();
			if(a % 2 == 0){
				even++;
			}else if(a % 2 == 1){
				odd++;
			}
		}

		long oddComb = 0;
		long evenComb = 0;
		for(int i=0; i<=even; i++){
				evenComb += nCm(even,i);
		}
		if(p == 0){
			for(int i=0; i<=odd; i+=2){
				oddComb += nCm(odd,i);
			}

		}else if(p ==1){
			if(odd == 0){
				oddComb = 0;
			}else{
				for(int i=1; i<=odd; i+=2){
					oddComb += nCm(odd,i);
				}
			}
		}
		long ans = evenComb * oddComb;

		System.out.print(ans);
	}

}


Measured memory_bytes: 22228
// Problem : A - Range Flip Find Route
// Contest : AtCoder Grand Contest 043
// URL : https://atcoder.jp/contests/agc043/tasks/agc043_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		FastReader scan = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		Task solver = new Task();
		//int t = scan.nextInt();
		int t = 1;
		for(int i = 1; i <= t; i++) solver.solve(i, scan, out);
		out.close();
	}

	static class Task {

		public void solve(int testNumber, FastReader sc, PrintWriter pw) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int[][] grid = new int[n][m];
			for(int i=0;i<n;i++){
				String str = sc.nextLine();
				for(int j=0;j<m;j++){
					grid[i][j]=str.charAt(j)=='.'?0:1;
				}
			}
			int[][] bfs = new int[n][m];
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					bfs[i][j]=100000;
				}
			}
			bfs[0][0]=0;
			if(grid[0][0]==1)bfs[0][0]++;
			
			int[] q = new int[1000000];
			int qpt = 1;
			int qpo = 0;
			while(qpo<qpt){
				int pop = q[qpo++];
				int x = pop/1000;
				int y = pop%1000;
				//pw.println(x+" "+y);
				if(y<m-1&&bfs[x][y]+(grid[x][y+1]*(1-grid[x][y]))<bfs[x][y+1]){
					q[qpt++]=pop+1;
					bfs[x][y+1]=bfs[x][y]+(grid[x][y+1]*(1-grid[x][y]));
					//pw.println(1+" "+x+" "+y+" " +(grid[x][y+1]*(1-grid[x][y])));
				}
				if(x<n-1&&bfs[x][y]+(grid[x+1][y]*(1-grid[x][y]))<bfs[x+1][y]){
					q[qpt++]=pop+1000;
					bfs[x+1][y]=bfs[x][y]+(grid[x+1][y]*(1-grid[x][y]));
					//pw.println(2+" "+x+" "+y+" "+(grid[x+1][y]*(1-grid[x][y])));
				}
				
			}
			for(int[] x : bfs){
				//pw.println(Arrays.toString(x));
			}
			pw.println(bfs[n-1][m-1]);
		}
	}

	static void shuffle(int[] a) {
		Random get = new Random();
		for (int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			int temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}

	static void shuffle(long[] a) {
		Random get = new Random();
		for (int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			long temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastReader(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

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

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

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

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

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

}

Measured memory_bytes: 26580
#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 lp(i,n) for(int i = 0; i <n;i++)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define sz(v) ((int)((v).size()))
typedef long long ll;
typedef unsigned long long ull;
template<class T> using ordered_set=tree<
T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)4e4+5;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
// int n,m,k;
// int col[N],row[N];
//  vector<int>a(n),b(m);
// void get_row(){
//       int start = 0,end=0;
//     while(idx<n){

//     }
// }
// void get_col(){
//     int start = 0,end=0;
//     while(idx<m){
//         range(i,idx,n-1){
//             if(!a[])idx++;
//         }
//     }
// }
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    
    // scanf("%d %d %d",&n,&m,&k);
    // a=vector<int>(n),b=vector<int>(m);
    // range(i,0,n-1){
    //     scanf("%d",&a[i]);
    // }    
    // range(i,0,m-1){
    //     scanf("%d",&b[i]);
    // }
    string s;
    cin>>s;
    bool ok = 0;
    lp(i,sz(s)){
        if(s[i]-'0'==7)ok=1;
    }
    ok?puts("Yes"):puts("No");
   
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int A, B;
    cin >> A >> B;
    cout << max(A + B, max(A - B, A * B)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <utility>
#define REP(i,A) for(int i=0;i<A;i++)

using namespace std;
using ll = long long int;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<ld>;
using pi = pair<int, int>;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);

	int N;
	cin >> N;

	vi arrived(N+2);
	arrived[1] = 1;
	vector<set<pi>> from(N+2);

	vi iro(N + 2);
	iro[1] = 0;
	queue<int> q;
	q.push(1);
	REP(i,N - 1) {
		int u, v, w;
		cin >> u >> v >> w;

		from[u].insert(make_pair(v, w));
		from[v].insert(make_pair(u, w));
	}

	while (!q.empty()) {
		int ver=q.front();
		q.pop();
		for (auto p : from[ver]) {
			if (!arrived[p.first]) {
				arrived[p.first] = 1;
				q.push(p.first);
				if (p.second % 2 == 0) {
					iro[p.first] = iro[ver];
				}
				else {
					iro[p.first] = iro[ver] + 1;
				}
			}
		}

	}

	for (int i = 1; i <= N; i++) {
		if (iro[i] % 2 == 0) {
			cout << 0 << endl;
		}
		else {
			cout << 1 << endl;
		}
	}
return 0;
}

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

int main() {
  int N,K,tmp,ans=0;
  cin >> N >> K;
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
    cin >> tmp;
    if(tmp >= K) ans++;
  }
  cout << ans;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

const int mod = 1e9 + 7;

int main() {

	string L;
	cin >> L;

	int n = L.size();

	// dp[上からi桁目まで][0:一致, 1:未満]
	vector<vector<long long>> dp(n + 1, vector<long long>(2, 0));
	dp[0][0] = 1;
	dp[0][1] = 0;

	// (1,1)は駄目
	for (int i = 1; i <= n; i++) {
		if (L[i-1] == '0') {
			dp[i][0] = dp[i-1][0]; // (0,0)

			dp[i][1] = dp[i-1][1] * 3; // (1,0), (0,1), (0,0)
		} else {
			dp[i][0] = dp[i-1][0] * 2; // (1,0), (0,1)

			dp[i][1] = dp[i-1][1] * 3; // (1,0), (0,1), (0,0)
			dp[i][1] += dp[i-1][0]; // (0,0)
		}
		dp[i][0] %= mod;
		dp[i][1] %= mod;
	}

	int ans = (dp[n][0] + dp[n][1]) % mod;

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


Measured memory_bytes: 5760
from heapq import heappush, heappop
n = int(input())
q = []
for _ in range(n):
    a, b = map(int, input().split())
    heappush(q, (b, a))

time = 0
while q:
    deadline, cost = heappop(q)
    time += cost
    if deadline < time:
        print('No')
        break
else:
    print('Yes')


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

using namespace std;

typedef pair<int, int> P;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	map<P, int> memo;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		if (a > b) swap(a, b);
		memo[P(a, b)]++;
	}

	vector<int> cnt(n, 0);
	for (auto p : memo) {
		if (p.second % 2 == 0) continue;
		P tar = p.first;
		cnt[tar.second]++;
		if (tar.first != 0) cnt[tar.first]++;
	}

	bool flag = true;
	for (int i = 1; i < n; i++) {
		if (cnt[i] % 2 == 1) {
			flag = false;
			break;
		}
	}

	cout << (flag ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 6912
#include <iostream>
using namespace std;
int main() {
	int n, i, j, num;
	char mark, markList[4] = { 'S','H','C','D' };
	bool card[4][13];
	for (i = 0; i < 4; i++) {
		for (j = 0; j < 13; j++) {
			card[i][j] = true;
		}
	}
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> mark >> num;
		switch (mark) {
			case 'S':
				card[0][num - 1] = false;
				break;
			case 'H':
				card[1][num - 1] = false;
				break;
			case 'C':
				card[2][num - 1] = false;
				break;
			case 'D':
				card[3][num - 1] = false;
				break;
		}
	}
	for (i = 0; i < 4; i++) {
		for (j = 0; j < 13; j++) {
			if (card[i][j]) {
				cout << markList[i] << ' ' << j+1 << endl;
			}
		}
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if ( a==b+c || b==a+c || c==a+b ){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 3596
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	string s;
	cin>>s;
	int l=s.length();
	int f=0,ff,ans=0;
	if(s[0]=='B')f=1;
	FOR(i,1,l){
		if(s[i]=='B')ff=1;
		if(s[i]=='W')ff=0;
		if(f!=ff){
			ans++;
			f=ff;
		}
	}
	cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 512
def main():
    import bisect
    n = int(input())
    m = [10 ** 5 for _ in range(n + 1)]
    m[0] = 0
    a = [6 ** i for i in range(7)]
    b = [9 ** i for i in range(6)]
    c = sorted(a + b)
    for i in range(1, n + 1):
        j = bisect.bisect_right(c, i)
        k = [1 + m[i - x] for l, x in enumerate(c) if l < j]
        m[i] = min(k)

    print(m[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3864
#include "bits/stdc++.h"

using namespace std;
typedef pair<bool,string> P;

vector<P> parse(string s)
{
	vector<P> ret;
	int i=0;
	while(i<s.size())
	{
		if(s[i]=='\"')
		{
			string tmp;
			i++;
			while(s[i]!='\"')
			{
				tmp+=s[i];
				i++;
			}
			ret.push_back(P(true,tmp));
			i++;
		}else{
			string tmp;
			while(i<s.size() && s[i]!='\"')
			{
				tmp+=s[i];
				i++;
			}
			ret.push_back(P(false,tmp));
		}
	}
	return ret;
}

int main()
{
	while(1)
	{
		string s1;
		string s2;
		cin>>s1;
		if(s1==".")
			break;
		cin>>s2;
		if(s1==s2)
			cout<<"IDENTICAL"<<endl;
		else{
			vector<P> p1=parse(s1);
			vector<P> p2=parse(s2);
			if(p1.size()!=p2.size())
				cout<<"DIFFERENT"<<endl;
			else{
				bool f=true;
				int cnt=0;
				for(int i=0;i<p1.size();i++)
				{
					if(p1[i].first!=p2[i].first)
					{
						f=false;
						break;
					}else{
						if(p1[i].first)
						{
							if(p1[i].second!=p2[i].second)
								cnt++;
						}else{
							if(p1[i].second!=p2[i].second)
							{
								f=false;
								break;
							}
						}
					}
				}
				if(!f)
					cout<<"DIFFERENT"<<endl;
				else if(cnt==1)
					cout<<"CLOSE"<<endl;
				else
					cout<<"DIFFERENT"<<endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3128
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
 
//#include <x86intrin.h>
#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;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, x[N];

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n;
   for (int i = 1; i <= n; i ++) cin >> x[i];
   int res = mod;
   for (int i = 0; i <= 1000; i ++) {
      int ans = 0;
      for (int j = 1; j <= n; j ++) ans += (x[j] - i) * (x[j] - i);
      res = min (res, ans);                                
   }
   cout << res;
}

int main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
#define ll long long
map<int, int> ma;
  
signed main() {
  int n;
  string s;
  cin >> n >> s;
  rep(i,n) ma[s[i]-'0']++;
  int ans = 0;
  rep(i,10){
    rep(j,10) {
      rep(k,10) {
        int now = 0;
        int search = i;
        rep(si,n) {
          if(now==0) {search = i;}
          else if(now==1) {search = j;}
          else {search = k;}
          int sn = s[si]-'0';
          if(now==2&&sn==search) {
            //cout << i<<" "<<j<<" "<<k << endl;
            ans++;
            break;
          }
          if(sn==search)now++;
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3692
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <sstream>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
struct Point
{
  double x,y;
  Point(){x=0;y=0;}
  Point(double d_x,double d_y){x=d_x,y=d_y;}
  double operator*(Point obj){return obj.x*x+obj.y*y;}
  double operator%(Point obj){return obj.y*x-obj.x*y;}
  Point operator*(double b){Point tmp;tmp.x=x*b;tmp.y=y*b;return tmp;}
  Point operator/(double b){Point tmp;tmp.x=x/b;tmp.y=y/b;return tmp;}
  Point operator+(Point obj){Point tmp;tmp.x=x+obj.x;tmp.y=y+obj.y;return tmp;}
  Point operator-(){Point tmp;tmp.x=-x;tmp.y=-y;return tmp;}
  Point operator-(Point obj){Point tmp;tmp.x=x-obj.x;tmp.y=y-obj.y;return tmp;}
  Point operator-=(Point obj){x-=obj.x;y-=obj.y;return *this;}
  Point operator+=(Point obj){x+=obj.x;y+=obj.y;return *this;}
  Point operator/=(double b){x=x/b;y=y/b;return *this;}
  Point operator*=(double b){x=x*b;y=y*b;return *this;}
  double size(){return hypot(x,y);}
  Point unit(){return Point(x/size(),y/size());}
  Point normal(){return Point(y,-x);}
  double atan(){return atan2(y,x);}
};

bool operator<(Point a,Point b){return a.x!=b.x?a.x<b.x:a.y<b.y;}
bool operator>(Point a,Point b){return b<a;}
bool operator<=(Point a,Point b){return !(b<a);}
bool operator>=(Point a,Point b){return !(a<b);}
bool operator==(Point a,Point b){return (a-b).size()<eps;}
bool operator!=(Point a,Point b){return !(a==b);}

bool equal(double a,double b){return abs(a-b)<eps;}
double cross(Point a,Point b){return a%b;}
double dot(Point a,Point b){return a*b;}

int ccw(Point a,Point b,Point c)
{
  b=b-a;
  c=c-a;
  if(b%c>0) return +1;
  else if(b%c<0)return -1;
  else if(b*c<0) return +2;
  else if(b.size()<c.size()) return -2;
  else return 0;
}

int main(int argc,char const* argv[])
{
  int n;
  ll ans=0;
  cin >> n;
  int cost[n][n];
  for(int i=0;i<n;i++)
    {
      for(int j=0;j<n;j++)
	{
	  cin >> cost[i][j];
	}
    }
      for(int i=0;i<n;i++)
	{
	  for(int j=0;j<n;j++)
	    {
	      if(j==i) continue;
	      ans+=min(cost[i][j],cost[j][i]);
	    }
	}
      cout << ans/2 << endl;

  return 0;
}



Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef pair<int,int> PII;
const int mod = 1e9+7,INF = 1e9;
const int mx = 1e6+5;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin>>n;
    int a[n];
    ll sum =0;
    map<int,int>mp;
    for(int i=0;i<n;i++)
        {
            cin>>a[i];
            sum+=a[i];
            mp[a[i]]++;
        }
    int q;
    cin>>q;
    while(q--)
    {
        int b,c;
        cin>>b>>c;
        sum = sum+(c-b)*(mp[b]);
        cout<<sum<<endl;
        mp[c]+= mp[b] ;
        mp[b] =0;

    }
    return 0;
}



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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);

    int a;
    int t = 0;
    int cnt = 0;
    int ans = 0;
    Rep(i,N){
        Scd(a);
        if( a <= t ) cnt++;
        else {
            ans = max( ans, cnt );
            cnt = 0;
        }
        t = a;
    }

    printf ("%d\n", max( ans, cnt ) );

    return 0;
}





Measured memory_bytes: 256
import java.math.*;
import java.util.*;
  
  

public class Main {

	static int n,m;
	static String map[];
	static boolean flag[][];
	static class pair{
		int x,y;
		pair(int a ,int b){
			this.x=a;
			this.y=b;
			}
	}
	static int dx[]= {-1,0,1,0},dy[]= {0,-1,0,1};
	public static void main(String[] args) {
          
        
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()) {
        	n=scan.nextInt();
	        m=scan.nextInt();
	        scan.nextLine();
	        if(n==0&&m==0)break;
	        map=new String [n];
	        for(int i=0;i<n;i++) {
	        	map[i]=scan.nextLine();
	        }
	        Stack<pair> stemp=new Stack<Main.pair>();
	        stemp.add(new pair(0,0));
	        flag=new boolean[n][m];
	        int res=dfs(stemp);
	        System.out.println(res);
        }
        
        
        
        
	}
	private static int dfs(Stack<pair> s) {
		int cnt=0;
		for(int w=0;w<n;w++) {
			for(int k=0;k<m;k++) {
				if(!flag[w][k]) {
					s.add(new pair(w,k));
					while(!s.isEmpty()) {
						pair p=s.peek();
						s.pop();
						for(int i=0;i<4;i++) {
							int nx=p.x+dx[i],ny=p.y+dy[i];
							char nc=map[p.x].charAt(p.y);
							if(nx>=0&&nx<n&&ny>=0&&ny<m&&map[nx].charAt(ny)==nc&&flag[nx][ny]==false) {
								s.add(new pair(nx,ny));
								flag[nx][ny]=true;
							}
						}
					}
					cnt++;
				}
			}
		}
		
		return cnt;
	}
	
	
	
	
}


Measured memory_bytes: 28684
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int g,t,wq[100003];
    bool k=true;
    scanf("%d",&t);
    for(g=0;g<t;g++)
        scanf("%d",&wq[g]);
    for(g=t-2;g>=0;g--)
        if(wq[g]>wq[g+1])wq[g]--;
    for(g=1;g<t&&k;g++)if(wq[g]<wq[g-1])
        k=false;
    if(k)printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 640
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	num, _ := strconv.Atoi(sc.Text())
	nodes := make(map[int]*node)

	for i := 0; i < num; i++ {
		sc.Scan()
		id, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		nodeNum, _ := strconv.Atoi(sc.Text())
		n := node{id, make([]int, 0), 0, 0}
		for j := 0; j < nodeNum; j++ {
			sc.Scan()
			nid, _ := strconv.Atoi(sc.Text())
			n.nexts = append(n.nexts, nid)
		}
		nodes[id] = &n
	}

	s := Stack{}
	for i := 1; i < len(nodes)+1; i++ {
		if nodes[i].s != 0 {
			continue
		}
		walk(i, &nodes, s)
	}
	for i := 1; i < len(nodes)+1; i++ {
		fmt.Printf("%v %v %v\n", (*nodes[i]).id, (*nodes[i]).s, (*nodes[i]).e)
	}
}

var time int

func walk(nid int, nodes *map[int]*node, s Stack) {
	n := (*nodes)[nid]
	if n.s != 0 {
		return
	}
	time++
	n.s = time
	s.Push(n)
	for _, v := range n.nexts {
		walk(v, nodes, s)
	}
	time++
	n.e = time
}

type node struct {
	id    int
	nexts []int
	s     int
	e     int
}

// Stack is Stack
type Stack struct {
	stack []interface{}
}

// Push new value
func (stack *Stack) Push(val interface{}) {
	stack.stack = append(stack.stack, val)
}

// Pop new value
func (stack *Stack) Pop() interface{} {
	val := stack.stack[len(stack.stack)-1]
	stack.stack = stack.stack[0 : len(stack.stack)-1]
	return val
}



Measured memory_bytes: 1148
def main():
    s = input()

    for i, (a, b) in enumerate(zip(s, s[1:]), start=1):
        if a == b:
            print(i, i + 1)
            return

    for i, (a, b) in enumerate(zip(s, s[2:]), start=1):
        if a == b:
            print(i, i + 2)
            return

    print(-1, -1)


if __name__ == '__main__':
    main()

# xx
# xyx


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll a[122];

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

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

int main() {
	cin >> n;
	ll ans = 1;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		ans = lcm(ans, a[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define ump unordered_map
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define len length()

//use (__int128)to extend ll range
double doINF = 1.0/0.0 ;
ostream_iterator <int> outp(cout," ");
inline ll modadd(ll n,ll m,ll mod){
    ll sum = ((n+m)%mod+mod)%mod;
    return sum;
} 
inline ll modsub(ll n,ll m, ll mod){
    ll diff = ((n-m+mod)%mod+mod)%mod;
    return diff;
}
inline ll modpro(ll n,ll m,ll mod){
    ll pro = ((n*m)%mod+mod)%mod;
    return pro;
}
inline ll pow(int x,int y){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}
inline ll powmod(ll x,ll y,ll mod){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = modpro(res , x,mod);
        y = y >> 1;
        x = modpro(x , x,mod);
    }
    return res;
}
ll min(ll a, ll b){
   if(a>b){
       return b;
   }
   return a;
}

ll max(ll a, ll b){
   if(a>b){
       return a;
   }else return b;
}
 
bool pairdec(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 		if(a.fi!=b.fi)
       	return (a.fi> b.fi);
		else return a.se>b.se;  
} 
ll power(ll x, ll y, ll mod) 
{ 
    ll res = 1; 
    x = x%mod; 
    while (y > 0) { 
        if (y & 1) 
            res = (res * x) % mod; 
  
        y = y >> 1;
        x = (x * x) % mod; 
    } 
    return res; 
} 
ll modInverse(ll a, ll mod) 
{ 
    return  powmod(a, mod - 2, mod); 
} 
ll modFact(ll n, ll mod) 
{ 
    if (n >=mod) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) %mod; 
  
    return result; 
} 
//cout<<setprecision(9)<<fixed<<sum<<endl; --- precision for double numbers
//copy(v.beg,v.en,outp);
//-----comparision for pairs------
 
bool comp(const pair<int,int>pia,const pair<int,int>pib)
{
	if(pia.fi==pib.fi) return pia.se>pib.se;
	else return pia.fi>pib.fi;
}

const ll N=1e9+7;
int main()
{
  long double sum;
  cin>>sum;
  cout<<setprecision(9)<<fixed<<sum/3*sum/3*sum/3<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include<queue>

using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n; ++i)
#define ALL(a) (a).begin(),(a).end()
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)

#define MOD 1000000007
int main(){
    int a, b;
    cin >> a >> b;
    int n = 50;
    char g[2*n][2*n];
    rep(i, 2*n)rep(j, 2*n){
        if(i < n)g[i][j] = '#';
        else g[i][j] = '.';
    }
    int ca, cb;
    ca = cb = 0;
    rep(i, 2*n)rep(j, 2*n){
        if(i < n-1){
            if(i%2 == 0 && j%2 == 0 && ca < a-1)g[i][j] = '.', ca++;
        }
        else if (i > n){
            if(i%2 == 0 && j%2 == 0 && cb < b-1)g[i][j] = '#', cb++;
        }
    } 
    cout << 2*n << " " << 2*n << endl;
    rep(i,2*n){
        rep(j, 2*n)cout << g[i][j];cout << endl;
    }


}

Measured memory_bytes: 256
def is_prime2(q,k=100):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    for i in range(3,k):
        x,y = q,i
        while y:
            x, y =  y, x % y
        if x != 1: continue
        if pow(i, q-1, q) != 1:
            return False
    return True

c = int(input())
for i in range(c, 10**6):
    if is_prime2(i):
        print(i)
        break


Measured memory_bytes: 38384
#include<cstdio>
int main(){
	int n,k,x,y,sum=0;
	scanf("%d\n%d\n%d\n%d",&n,&k,&x,&y);
	if(1<=n&&k<=10000&&1<=y&&y<x&&x<=10000){
	if(n>=k){
	for(int i=1;i<=k;i++) sum += x;
    for(int j=k+1;j<=n;j++) sum += y;
    }
    else if(n<k){
    for(int i=1;i<=n;i++) sum += x;
	}
    printf("%d\n",sum);	
    }
    return 0;	
	}

Measured memory_bytes: 128
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))

counter=0
for i in range(N):
  if A[i]>B[i]:
    counter+=B[i]
  else:
    counter+=A[i]
    B[i]-=A[i]
    if A[i+1]>B[i]:
      counter+=B[i]
      A[i+1]-=B[i]
    else:
      counter+=A[i+1]
      A[i+1]=0
      
print(int(counter))

Measured memory_bytes: 19116
/*input
3
10 40 70
20 50 80
30 60 90
*/
/**
    Author: Kristopher Paul
    Date Created: 11-01-2020
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
#include<stdio.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
//#define MOD 998244353
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

//Uncomment for File I/O
/*
#define cin fin
#define cout fout

ifstream fin("input.in");
ofstream fout("input.out");
*/

using namespace std;
//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    int n;
    cin >> n;
    int a[n][3];
    int dp[n][3];
    FOR(i,0,n){
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    FOR(i,1,n){
        FOR(j,0,3){
            dp[i][j] = 0;
        }
        FOR(j,0,3){
            FOR(k,0,3){
                if(j == k){
                    continue;
                }
                remax(dp[i][j],dp[i-1][k]+a[i][j]);
            }
        }
    }
    cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}



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

char S[100];
char T[100];
int main() {
	scanf("%s%s", S, T);
	int s = strlen(S);
	int t = strlen(T);
	for (int i = s - t; i >= 0; i--) {
		bool flag = false;
		for (int j = 0; j < t; j++) {
			if (S[i + j] == '?' || S[i + j] == T[j]) {

			}
			else {
				flag = true;
			}
		}
		if (!flag) {
			for (int j = 0; j < t; j++) {
				S[i + j] = T[j];
			}
			for (int i = 0; i < s; i++) {
				if (S[i] == '?')S[i] = 'a';
			}
			printf("%s", S);
			return 0;
		}
	}
	printf("UNRESTORABLE");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
void solve(){
    ll n;
    cin>>n;
    vector<ll>v(n);
    for(ll i=0;i<n;i++)cin>>v[i];
    sort(v.begin(),v.end());
    ll cur=n-1;
    ll ans=v[cur--];
    bool flag=true;
    for(ll i=n-3;i>=0;i--){
        if(flag){
            ans+=v[cur];
            flag=false;
        }
        else{
            ans+=v[cur--];
            flag=true;
        }
    }
    cout<<ans<<endl;
    return;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}



Measured memory_bytes: 4780
n = int(input())
A = list(map(str, input().split()))

A_odd = A[::2]
A_even = A[1::2]
if n % 2 == 1:
    can = A_odd[::-1] + A_even
else:
    can = A_even[::-1] + A_odd

ans = ' '.join(can)
print(ans)


Measured memory_bytes: 26948
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl


namespace atcoder {
	template<typename T>
	T ncr(T left, T right) {
		right = min(left - right, right);
		T ans = 1;
		for (T i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000007;
	const int tenfive = 100000;
}

using namespace atcoder;

int main() {
	int n;
	ulli k;
	cin >> n >> k;
	vector<ulli> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	//for (ulli i = 0; i <= k; i++) {
	//	ulli ans = 0;
	//	for (int j = 0; j < n; j++) {
	//		ans += v[j] ^ i;
	//	}
	//	cout << i << " : " << ans << endl;
	//}
	vector<bitset<40>> b(n);
	for (int i = 0; i < n; i++) {
		b[i] = bitset<40>(v[i]);
	}
	bitset<40> val(k);
	int maxbit = 0;

	for (int i = 39; i >= 0; i--) {
		if (val[i]) {
			maxbit = i;
			break;
		}
	}
	bool anyOK = false;
	for (int i = maxbit; i >=0; i--) {
		int c = 0;
		for (int j = 0; j < n; j++) {
			if (!b[j][i]) {
				c++;
			}
			else {
				c--;
			}
		}
		if (c < 0) {
			if (!anyOK && val[i])
				anyOK = true;
			val.reset(i);
		}
		else if (anyOK) {
			val.set(i);
		}
	}
	ulli ans = 0;
	for (int i = 0; i < n; i++){
		ans += v[i] ^ val.to_ullong();
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792