akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    int a,b,x;
    cin>>a>>b>>x;
    double s=(double)x/a;
    double ans;
    double pi=acos(-1);
    if(s<=a*b/2.0){
        double w=2.0*s/b;
        ans=atan2(b,w)*(180/pi);
    }
    else{
        double h=2.0*(a*b-s)/a;
        ans=atan2(h,a)*(180/pi);
    }
    printf("%.10f\n",ans);
    return 0;
}

Measured memory_bytes: 4032
#include <stdio.h>

main()
{
  int info[2]={0,0};
  int math[2]={0,0};
  int scie[2]={0,0};
  int eng[2]={0,0};
  int sum[2]={0,0};

  scanf("%d%d%d%d%d%d%d%d",&info[0],&math[0],&scie[0],&eng[0],&info[1],&math[1],&scie[1],&eng[1]);

  sum[0] = info[0] + math [0] + scie[0] + eng[0];
  sum[1] = info[1] + math [1] + scie[1] + eng[1];

  

   if(sum[0] > sum[1])
    {
      printf("%d\n",sum[0]);
    }
  else if(sum[0] == sum[1])
    {
      printf("%d\n",sum[0]);
    }
  else if(sum[0] < sum[1])
    {
      printf("%d\n",sum[1]);
      }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  string X;
  cin >> X;
  stack<char> st;
  int N = X.size();
  REP(i, N) {
    if (st.empty()) {
      st.push(X[i]);
    } else {
      char c = st.top();
      if (c == 'S' && X[i] == 'T') {
        st.pop();
      } else {
        st.push(X[i]);
      }
    }
  }
  cout << st.size() << endl;
  return 0;
}

Measured memory_bytes: 644
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int dp[110] = {};
	for (int i = a; i <= b; i++) {
		dp[i]++;
	}
	for (int i = c; i <= d; i++) {
		dp[i]++;
	}
	int ans = 0;
	for (int i = 0; i <= 100; i++) {
		if (dp[i] == 2) {
			ans++;
		}
	}
	if (ans > 0) {
		cout << ans - 1;
	}
	else {
		cout << ans;
	}
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()
 
def main():
    N,M=map(int,input().split())
    city=[[] for _ in range(N)]
    s=set()
    for i in range(M):
        P,Y=map(lambda x:int(x)-1,input().split())
        s.add(P)
        city[P].append((Y,i))
    city=list(map(sorted,city))
    ans=[0]*M
    for x in s:
        for i,c in enumerate(city[x]):
            ans[c[1]]=str(x+1).zfill(6)+str(i+1).zfill(6)
    for i in range(M):
        print(ans[i])
main()

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

using LL = long long;

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

    int n; cin >> n;
    map<int, int> f;
    f[0] = 3;
    const LL MOD = 1e9 + 7;
    LL ans = 1;
    for (int i = 0; i < n; ++i) {
        int x; cin >> x;
        ans = (ans * f[x]) % MOD;
        if (f[x] > 0) {
            f[x]--;
            f[x + 1]++;
        }
    }
    cout << ans << endl;

	return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MOD 1000000007

int x,y,z,K;
ll a[1010],b[1010],c[1010];
vector<ll> ans,ret;
int main(){
  cin >> x >> y >> z >> K;
  for(int i = 0; i < x; i++) cin >> a[i];
  for(int i = 0; i < y; i++) cin >> b[i];
  for(int i = 0; i < z; i++) cin >> c[i];
  sort(a,a+x);reverse(a,a+x);
  sort(b,b+y);reverse(b,b+y);
  sort(c,c+z);reverse(c,c+z);
  for(int i = 0; i< x; i++){
    for(int j = 0; j < y; j++){
      ret.pb(a[i]+b[j]);
    }
  }
  sort(ret.begin(),ret.end());
  reverse(ret.begin(),ret.end());
  for(int i = 0; i < min(K,x*y); i++){
    for(int j = 0; j < min(K,z); j++){
      ans.pb(ret[i]+c[j]);
    }
  }
  sort(ans.begin(),ans.end());
  reverse(ans.begin(),ans.end());
  for(int i = 0; i< K; i++){
    cout << ans[i] <<endl;
  }
  return 0;
}


Measured memory_bytes: 43364
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int N, K;
    cin >> N >> K;
    vector<bool> vec(N,true);
    for(int i=0; i<K; i++){
        int d;
        cin >> d;
        for(int j=0; j<d; j++){
            int a;
            cin >> a;a--;
            vec[a]=false;
        }
    }

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

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		while (str != null) {
			String[] data = str.split(",");
			int[] length = new int[10];
			int allLength = 0;
			for (int i = 0; i < 10; i++) {
				length[i] = Integer.parseInt(data[i]);
				allLength += length[i];
			}
			int v1 = Integer.parseInt(data[10]);
			int v2 = Integer.parseInt(data[11]);
			double l = (double) v1 * allLength / (v1 + v2);
			int i = 0;
			while (l > length[i]) {
				l -= length[i];
				i++;
			}
			System.out.println(i + 1);
			str = br.readLine();
		}
	}
}

Measured memory_bytes: 24016
#include <stdio.h>

int main() {
  int n;
  scanf("%d",&n);
  int a[n],i,j;
  for(i=0; i<n; i++) scanf("%d",&a[i]);

  for(i=0; i<n; i++) {
    for(j=i-1; j>=0; j--) {
      if(a[j]>a[j+1]) {
	int tmp=a[j];
	a[j]=a[j+1];
	a[j+1]=tmp;
      } else break;
    }
    for(j=0; j<n; j++) {
      if(j) printf(" ");
      printf("%d",a[j]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2100
#include <stdio.h>

int player[5];

int main(void)
{	
	int a[2] = {0} ,Min;
	int check[4] = {1, 1, 1, 1};
	int i, j;
	
	while (scanf("%d", &player[0]), player[0]){
		j = 0;
		for (i = 0; i < 4; i++){
			check[i] = 1;
		}
		check[player[0]] = -1;
		for (i = 1; i < 5; i++){
			scanf("%d", &player[i]);
			check[player[i]] = -1;
		}
		for (i = 1; i < 4; i++){
			check[0] *= check[i];
			if (check[i] == -1){
				a[j++] = i;
			}
		}
		if (check[0] == -1){
			for (i = 0; i < 5; i++){
				player[i] = 3;
			}
		}
		else if (check[3] == -1 && check[1] == -1){
			for (i = 0; i < 5; i++){
				if (player[i] == 3){
					player[i] = 1;
				}
				else {
					player[i] = 2;
				}
			}
		}
		else {
			if (a[0] > a[1]){
				Min = a[1];
			}
			else {
				Min = a[0];
			}
			for (i = 0; i < 5; i++){
				if (player[i] == Min){
					player[i] = 1;
				}
				else {
					player[i] = 2;
				}
			}
		}
		for (i = 0; i < 5; i++){
			printf("%d\n", player[i]);
		}
	}
	return (0);
}

Measured memory_bytes: 600
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
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; }




// ***************************************


int main(){

    ll N;
    cin >> N;

    vll A(N + 1, 1);

    for(ll i = 2; i <= N; i++){
        for(ll j = 1; i * j <= N; j++){
            A[i * j]++;
        }
    }

    ll ans = 0;
    FOR(k, 1, N + 1){
        ans += k * A[k];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 81248
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

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

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


Measured memory_bytes: 3604
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cctype>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvii;
typedef pair<int, int> ii;
typedef vector<ii> vii;

////////////////////////////////

void solve() {
	
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int t, x;
	cin >> t >> x;
	cout << t*x << endl;
	return 0;
}


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

int main() {
	int n,m=0;
	cin>>n;
	int a[n][3],b[n][3];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>a[i][j];
		}
	}
	for(int i=0;i<3;i++)
	{
		b[0][i]=a[0][i];
	}
	for(int i=1;i<n;i++)
	{
		b[i][0]=a[i][0]+max(b[i-1][1],b[i-1][2]);
		b[i][1]=a[i][1]+max(b[i-1][2],b[i-1][0]);
		b[i][2]=a[i][2]+max(b[i-1][1],b[i-1][0]);
	}
	for(int i=0;i<3;i++)
	{
		if(b[n-1][i]>m)
		m=b[n-1][i];
	}
		cout<<m;
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
    int n;cin>>n;
    int a[1000],b[1000],c[1000],m[1000];
    rep(i,n){
        cin >> a[i];
    }
    int sum1=0;;
    rep(i,n){
        cin >> b[i];
        sum1 += b[i];
    }
    rep(i,n-1){
        cin >>c[i];
    }
    int sum2=0;

    rep(i,n-1){
        if((a[i] + 1)==a[i+1]){
            sum2 += c[a[i]-1];
        }
    }

    //cout << c[a[2]-1] << endl;
    cout << sum1+sum2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007

ll n;

int main()
{
    Fast;

    cin>>n;
    cout<<((n-1)*n)/2;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll amari = 1e9+7;

int main(){
	int n;
	cin >> n;
	int a;
	int even = 0;
	for(int i = 0; i < n; i++){
		cin >> a;
		if(a % 2 == 0)even++;
	}
	
	if(n == 1){
		cout << 1 << endl;
		return 0;
	}
	cout << pow(3,n) - pow(2,even) << endl;
	return 0;
}

Measured memory_bytes: 256
n = input()
total = sum(list(map(int, n)))
while True:
    if int(n) == 0:
        print('Yes')
        break
    if len(str(total)) != 1:
        total = sum(list(map(int, str(total))))
    elif total == 9:
        print('Yes')
        break
    else:
        print('No')
        break

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

using namespace std;

const int N = 1e5;
int vis[N];
int check(int i){
	cout << i << endl;
    fflush(stdout);
    string ans; cin >> ans;
    if (ans == "Vacant") return 0;
    if (ans == "Male") return 1;
    return 2;
}
signed main(){
	int n; cin >> n;
	int l = 0, r = n - 1; 
	vis[l] = check(l); vis[r] = check(r);
	if(!vis[l] || !vis[r]) return 0;
	while(l != r - 1){
		int mid = l + r >> 1;
		vis[mid] = check(mid);	
		if(abs(vis[mid] - vis[l]) != ((mid - l) & 1) ) r = mid;
		else l = mid;
	}
	vis[l] = check(l);
	if(!vis[l]){ cout << l << endl; return 0; }
	vis[r] = check(r);
	if(!vis[r]){ cout << r << endl; return 0; }
	
}

Measured memory_bytes: 852
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <iostream> 
#include <iomanip>  
#include <string>
#include <sstream>  
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <cstring>
#include <cmath>
#include <cassert>


#define INF              (int)1000000007
#define EPS              1e-9
#define pb               push_back
#define mp               make_pair
#define all(c)           c.begin(), c.end()
#define forall(i,a,b)    for(int i=a;i<(b);++i)
#define trav(a,x)        for(auto & a: x)
#define in(a,b)          ((b).find(a) != (b).end())
#define sz(c)            (int)(c).size()
#define input(a)         for(auto & x : a) cin >> x;

using namespace std;

typedef vector<int>      vi;
typedef pair<int,int>    ii;
typedef vector<vi>       vvi;
typedef vector<ii>       vii;
typedef long long        ll;

#ifdef DEBUG
#define trace(...)       __f(#__VA_ARGS__, __VA_ARGS__)
#define debug(args...)   {dbg,args; clog<<endl;}
#define print_( a )      for( auto & x : a ) clog << x << ' '; clog << '\n';
#define printPair_( a )  for( auto & x : a ) clog << '(' << x.first << ',' << x.second << ')' << ' '; clog << '\n';
#else
#define trace(...)       
#define debug(args...)            
#define print_( a )               
#define printPair_( a )           
#endif

struct debugger {
  template<typename T> debugger& operator , (const T& x) {    
    clog << x << " ";    return *this;    
  }
}dbg;

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " | ";
    __f(comma + 1, args...);
}

auto ____ =[]() { std::ios::sync_with_stdio(0); cin.tie(0); return nullptr; }();

int main( int argc, char * argv[] ){
  string str; cin >> str;
  unordered_map<string, int> dic = {{"SUN", 1}, {"MON", 2}, {"TUE", 3},
                                    {"WED", 4}, {"THU", 5}, {"FRI", 6},
                                    {"SAT", 7}};
  cout << 8 - dic[str] << '\n';
  return 0;
}


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

void Main() {
  int N;
  cin >> N;
  vector<int> tasks(N);
  for (int i=0; i<N; ++i) {
    cin >> tasks[i];
  }

  sort(tasks.begin(), tasks.end());
  int ans = tasks[N / 2] - tasks[N / 2 - 1];
  cout << ans << "\n";
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  Main();
}


Measured memory_bytes: 640
use std::cmp;

const INF: u64 = std::u64::MAX;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let l: u64 = sc.read();
    let r: u64 = sc.read();
    if r - l > 10000 {
        println!("0");
    } else {
        let mut ans = INF;
        for i in l..(r + 1) {
            for j in (i + 1)..(r + 1) {
                ans = cmp::min(ans, (i * j) % 2019);
            }
        }

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

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

const ll M = 1e9 + 7;

int main()
{
	ll n,k;
	cin >> n >> k;
	ll ans = 0;
	for (ll i = k; i <= n + 1; i++) {
		ans += i * (n + 1 - i) + 1;
		ans = ans % M;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
// #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef int ll;
const ll MAXN = 5e5+5;
const ll MAX = 1e5+5;
inline ll max(ll a,ll b){return a>b?a:b;}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll powmod(ll a,ll b,ll mod){ll ret=1;while(b>0){if(b&1)ret=ret*a%mod;b>>=1;a=a*a%mod;}return ret;}
inline ll multi(ll a,ll b,ll mod){ll ret=0;while(b){if(b&1)ret=(ret+a)%mod;b>>=1;a<<=1;a%=mod;}return ret;}
inline ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll d=exgcd(b,a%b,x,y);ll tmp=x;x=y;y=tmp-a/b*x;return d;}
inline ll inverse(ll a,ll b){ll x,y;ll d=exgcd(a,b,x,y);if(d!=1)return -1;return (x%b+b)%b;}

int main(){
	LL n;
	scanf("%lld",&n);
	LL sum=n*(n+1)/2-n/3*(n/3*3+3)/2-n/5*(n/5*5+5)/2+n/15*(n/15*15+15)/2;
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
const int M=1e5+10;
int n,q,len;
char s[M];
int a[M];
int main()
{
    cin>>n>>q>>s;
    for(int i=1;i<n;i++)
        a[i]=a[i-1]+(s[i-1]=='A' && s[i]=='C');
    while(q--)
    {
        int l,r;
        cin>>l>>r;
        cout<<a[r-1]-a[l-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::vector<lint>a(n+1),b(n+1);
    for(lint i=1;i<=n;i++){
        std::cin>>a.at(i);
    }
    for(lint i=n;i>=1;i--){
        lint x=a.at(i);
        for(lint j=i;j<=n;j+=i)x^=b.at(j);
        b.at(i)^=x;
    }
    std::cout<<std::accumulate(b.begin(),b.end(),0ll)<<'\n';
    for(lint i=1;i<=n;i++){
        if(b.at(i)){
            std::cout<<i<<'\n';
        }
    }
}


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

#define int long long 
#define dou  double 
#define endl "\n"

const int MOD=1e9+7;

void solve()
{
	int a;
	cin >> a;
	cout << a + pow(a,2)+pow(a,3) << endl;
}

main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
}

Measured memory_bytes: 4168
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	int N, K;
	cin >> N >> K;
	int num = (N + 2 - 1) / 2;
	if (K <= num)cout << "YES";
	else cout << "NO";
}

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

using namespace std;
using ll = long long int;
#define vll vector<ll>

#define FOR(i, b, e) for(int i = (b); i < (e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define REV(v) reverse((v).begin(), (v).end())
#define IN(v) cin >> (v);
#define VIN(v, n) REP(i, n) cin >> v[i];
#define OUT(v) cout << (v) << endl;
#define YN(b) OUT((b) ? "YES" : "NO")
#define Yn(b) OUT((b) ? "Yes" : "No")
#define yn(b) OUT((b) ? "yes" : "no")

const ll MOD = 1000000007;

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

  long double x;
  cin >> x;
  cout << 2 * M_PI * x << endl;

  return 0;
}

Measured memory_bytes: 3788
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextInt64() int64 {
	i, err := strconv.ParseInt(io.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}


func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func absi(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func b2i(b bool) int {
	if b {
		return 1
	}
	return 0
}

type Int64s []int64
func (f Int64s) Len() int {
	return len(f)
}
func (f Int64s) Less(i, j int) bool {
	return f[i] < f[j]
}

func (f Int64s) Swap(i, j int) {
	f[i], f[j] = f[j], f[i]
}


func solve(io *Io) {
	a := io.NextInt()
	b := io.NextInt()
	c := io.NextInt()
	d := io.NextInt()

	cnt := 0
	cnt += b2i(absi(a - b) <= d)
	cnt += b2i(absi(a - c) <= d) * 2
	cnt += b2i(absi(b - c) <= d)

	ans := "No"
	if cnt >= 2 {
		ans = "Yes"
	}

	io.PrintLn(ans)
}

func main() {
	io := NewIo()
	defer io.Flush()

	solve(io)
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
	int n,m,x,i,d;
	int fro,bac;
	while(scanf("%d%d%d",&n,&m,&x)==3)
	{
		fro=0;
		bac=0;
		for(i=0;i<m;i++)
		{
			scanf("%d",&d);
			if(d<x)
			fro++;
			else
			bac++;
		}
		int res=(fro<bac?fro:bac);
		printf("%d\n",res);
	}
	return 0;
}

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();


signed main()
{
	init();
	solve();
}

ll N;
ll P;

void init()
{
	cin >> N;
	cin >> P;
}



void solve()
{
	map<ll, ll> m;
	ll a = 2;
	while (a * a <= P) {
		if (P % a == 0) {
			m[a]++;
			P /= a;
		} else {
			a++;	
		}
	}
	m[P]++;
	ll res = 1;
	for (auto x : m) {
		ll t = (x.second / N);
		rep(i, t) {
			res *= x.first;
		}
	}
	cout << res << endl;
}




Measured memory_bytes: 256
import math

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())



ans = 0
for i in [a, b, c, d, e]:
    ans += int(math.ceil(i/10)*10)

    
li = [int(str(a)[-1]), int(str(b)[-1]), int(str(c)[-1]), int(str(d)[-1]), int(str(e)[-1])]

if li == [0, 0, 0, 0, 0]:
    ans = ans + min(li)
    print(ans)
    
else:
    for j in li:
        if j==0:
            li.remove(0)
    ans = ans + min(li) - 10
    print(ans)


Measured memory_bytes: 3064
n = int(input())
t=0
x=0
y=0
for i in range(n) :
    ti, xi, yi = map(int, input().split())
    dt = abs(ti-t)
    dr = abs(xi-x) + abs(yi-y)
    if dt < dr or (dt-dr)%2 == 1 :
        print('No')
        exit()
    else :
        t = ti
        x = xi
        y = yi
else :
    print('Yes')

Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, N = MAP()
A, B = ZIP(N)
A = np.array(A)
B = np.array(B)
max_A = A.max()

dp = np.zeros(10001, dtype=np.int64)

for i in range(1, H+1):
	dp[i]=(dp[i-A]+B).min()

print(dp[H])


Measured memory_bytes: 13836
#include <bits/stdc++.h>
#include <algorithm>
#include <string>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
signed main(){
	int N;cin>>N;
  	string S;cin>>S;
  	int K;cin>>K;
  	char target;target=S[K-1];
  
  	rep(i,N){
    	if(S[i]!=target)S[i]='*';
    }
  
  	cout<<S<<endl;
  	
  
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d", &n)
	p := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &p[i])
	}
	count := 0
	for i := 1; i < n-1; i++ {
		a := p[i-1]
		b := p[i]
		c := p[i+1]
		if a < b && b < c || c < b && b < a {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mk make_pair
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define vl vector<long long int>
#define vvl vector<vector<ll> > 
#define fo(i,a,b) for(int i=a;i<b;i++)
#define rof(i,a,b)  for(int i=b;i>=a;i--)
using namespace std;
ll mod=1000000007;

int main()
{
    ll n;cin>>n;
    ll h[n];
    fo(i,0,n)   cin>>h[i];
    ll dp[n+1];
    memset(dp,0,sizeof(dp));
    dp[0]=0;
    for(ll i=1;i<n;i++)
    {
        dp[i] = abs(h[i]-h[i-1])+dp[i-1];
        if(i>1)
            dp[i] = min(dp[i],abs(h[i]-h[i-2])+dp[i-2]);
    }
    cout << dp[n-1];
}



Measured memory_bytes: 5164
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner (System.in)){
			int n = sc.nextInt();
			long[] array = new long[n];
			for (int i=0; i<n; i++) array[i] = sc.nextLong();
			int times = sc.nextInt();  //queryの数
			for (int i=0; i<times; i++) {
				int query = sc.nextInt();  //命令：0 min 1 max
				int start = sc.nextInt();
				int end = sc.nextInt();
				switch (query) {
				//min(start,end)
				case 0:
					long min = array[start];
					for (int j=start+1; j<end; j++) {
						min = Math.min(min, array[j]);
					}
					System.out.println(min);
					break;
				//max(start,end)
				case 1:
					long max = array[start];
					for (int j=start+1; j<end; j++) {
						max = Math.max(max,array[j]);
					}
					System.out.println(max);
					break;

				}
			}
		}
	}
}


Measured memory_bytes: 34872
#include<stdio.h>
void buildMaxHeap();
void maxHeapify(int);
int A[1000000];
int heap;

int main(){
  int i;

  scanf("%d", &heap);
  for(i = 1; i <= heap; i++){
    scanf("%d", &A[i]);
  }
  buildMaxHeap();

  for(i = 1; i <= heap; i++){
    printf(" %d", A[i]);
  }
  printf("\n");
  return 0;
}

int parent(int i){
  return i / 2;
}

int left(int i){
  return 2 * i;
}

int right(int i){
  return 2 * i + 1;
}

void buildMaxHeap(){
    int i;
	for (i = heap / 2; i > 0; i--){
        maxHeapify(i);
	}
}

void maxHeapify(int i){
  int l, r, largest, temp;
  l = left(i);
  r = right(i);
  if (l <= heap && A[l] > A[i]){
    largest = l;
  } else {
    largest = i;
  }
  if (r <= heap && A[r] > A[largest]){
    largest = r;
  }
  if (largest != i){
          temp = A[i];
          A[i] = A[largest];
          A[largest] = temp;
          maxHeapify(largest);
  }
  return;
}

Measured memory_bytes: 2556
B = 3.times.map { gets.split.map(&:to_i) }
h = [B[0][0] - B[0][1], B[0][1] - B[0][2]]
v = [B[0][0] - B[1][0], B[1][0] - B[2][0]]
r = (1..2).all? do |i|
  [B[i][0] - B[i][1], B[i][1] - B[i][2]] == h && [B[0][i] - B[1][i], B[1][i] - B[2][i]] == v
end
puts r ? 'Yes' : 'No'

Measured memory_bytes: 1788
N, Y = map(int, input().split())
for x in range(N+1):
    for y in range(N-x+1):
        z = N-x-y
        if 0 <= z <= 2000 and 10000*x+5000*y+1000*z == Y:
            print(x, y, z)
            exit()
print(-1, -1, -1)


Measured memory_bytes: 9080
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int a, b, c, ans;
	cin >> a >> b >> c;
	ans = b / a;
	cout << min(c, ans) << endl;

	return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n,m,s,t;
vector<int> G[111111];

int sd[111111],td[111111];
bool vis[111111];

int main(){
	cin.sync_with_stdio(false);
	cin>>n>>m>>s>>t;
	s--; t--;
	rep(i,m){
		int x,y;
		cin>>x>>y;
		x--; y--;
		G[x].pb(y); G[y].pb(x);
	}
	int maxd;
	queue<P> que;
	que.push(P(s,0));
	memset(sd,0,sizeof(sd));
	vis[s]=true;
	while(!que.empty()){
		int nv=que.front().fi,dist=que.front().se; que.pop();
		sd[dist]++;
		if(nv==t){
			maxd=dist;
		}
		rep(i,G[nv].size()){
			int next=G[nv][i];
			if(vis[next])continue;
			vis[next]=true;
			que.push(P(next,dist+1));
		}
	}

	queue<P>().swap(que);
	memset(td,0,sizeof(td));
	memset(vis,0,sizeof(vis));
	que.push(P(t,0));
	vis[t]=true;
	while(!que.empty()){
		int nv=que.front().fi,dist=que.front().se; que.pop();
		td[dist]++;
		rep(i,G[nv].size()){
			int next=G[nv][i];
			if(vis[next])continue;
			vis[next]=true;
			que.push(P(next,dist+1));
		}
	}

	ll res=0;
	rep(i,maxd-1){
		res+=(ll)sd[i]*td[maxd-i-2];
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 10964
import math 
a, b, x=map(int, input().split())
if x<a*a*b/2:
    angle=180*math.atan(a*b*b/2/x)/math.pi
    print('{:.10f}'.format(angle))
if x>=a*a*b/2:
    angle=180*math.atan((b-(x/a**2))/a*2)/math.pi
    print('{:.10f}'.format(angle))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		if(S.equals("ABC")){
			System.out.println("ARC");
		}else{
			System.out.println("ABC");			
		}
	}
}


Measured memory_bytes: 26960
function bomb(n,sum,str,before){
   if(n==N && sum==S)cnt++;
   if(n==N)return;
   var arr=str.split("").map(Number);
   arr.forEach(function(v){
      if(before<v)bomb(n+1,sum+v,str.replace(v,""),v);
   });
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var NS=Arr.shift().split(" ").map(Number);
   var N=NS[0];
   var S=NS[1];
   if(N==0 && S==0)break;
   var cnt=0;
   bomb(0,0,"0123456789",-1);
   console.log(cnt);
}

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

int val[100005];
vector<int> adj[100005];
void DFS(int v, int p){
	val[v] = 0;
	for (int j: adj[v]){
		if (j != p){
			DFS(j, v);
			int k = val[j];
			for (int i = 0; i < 20; i++){
				if (val[v] & (1<<i)){
					if (k&(1<<i)){
						val[v] |= ((1<<(i+1)) - 1);
					}
				}
				else{
					val[v] |= (k&(1<<i));
				}
			}
		}
	}
	val[v]++;
}

int main(){
	int N; cin >> N;
	for (int i = 0; i < N - 1; i++){
		int u, v; cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	DFS(1, 0);
	int lg = 0;
	while (val[1]/2){
		val[1] /= 2;
		lg++;
	}
	cout << lg << endl;
}


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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return x;}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

template<typename T>
bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>
bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

vector<ll> enum_prime(ll N){
	deque<bool> is_prime(N+1,true);
	vector<ll> P;
	for(ll i=2;i<=N;i++){
		if(is_prime[i]){
			for(ll j=i*i;j<=N;j+=i){
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	return P;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto N=in();
	ll S=0;
	//auto P = enum_prime(10000000);
	vll T(N+1,0);
	REP(i,N){
		ll V=i+1;
		for(int j=V;j<N+1;j+=i+1){
			T[j]++;
		}
	}
	REP(i,N){
		ll V=i+1;
		S += V*T[V];
	}
	out(S);
	return 0;
}


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

#define inf 2000000000  // 1e17
template <class T>
struct Dinic {
  struct edge {
    int to;
    T cap;
    int rev;
  };
  vector<vector<edge>> edges;
  vector<int> id;
  vector<int> d;
  Dinic(int n = 1) {
    edges.clear();
    edges.resize(n);
    id.resize(n);
    d.resize(n);
  }
  bool add(int start, int goal, T capacity) {
    edges[start].push_back((edge){goal, capacity, (int)edges[goal].size()});
    edges[goal].push_back((edge){start, 0, (int)edges[start].size() - 1});
    return 1;
  }
  void bfs(int st) {
    d.assign(d.size(), -1);
    queue<int> qu;
    d[st] = 0;
    qu.push(st);
    while (qu.size()) {
      int now = qu.front();
      qu.pop();
      for (auto e : edges[now])
        if (e.cap > 0 && d[e.to] < 0) {
          d[e.to] = d[now] + 1;
          qu.push(e.to);
        }
    }
  }
  T pathdfs(int now, int goal, T nf) {
    if (now == goal) return nf;
    for (int& i = id[now]; i < (int)edges[now].size(); ++i) {
      edge* e = &edges[now][i];
      if (e->cap > 0 && d[now] < d[e->to]) {
        T res = pathdfs(e->to, goal, min(nf, e->cap));
        if (res > 0) {
          e->cap -= res;
          edges[e->to][e->rev].cap += res;
          return res;
        }
      }
    }
    return 0;
  }
  T solve(int start, int goal) {
    T res = 0, nf = 0;
    while (1) {
      bfs(start);
      if (d[goal] < 0) return res;
      id.assign(id.size(), 0);
      while ((nf = pathdfs(start, goal, inf)) > 0) res += nf;
    }
    return -1;
  }
};

int h, w;
vector<string> s;
pair<int, int> st, go;

int main() {
  cin >> h >> w;
  s.resize(h);
  for (int i = 0; i < h; ++i) cin >> s[i];
  Dinic<long long> din(h * w * 2);
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j) {
      if (s[i][j] != '.') {
        if (s[i][j] == 'S')
          st = make_pair(i, j), s[i][j] = 'o';
        else if (s[i][j] == 'T')
          go = make_pair(i, j), s[i][j] = 'o';
        else
          din.add(i * w + j, (i + h) * w + j, 1);
        for (int k = 0; k < h; ++k)
          if (i != k && s[k][j] != '.') din.add((i + h) * w + j, k * w + j, 1);
        for (int k = 0; k < w; ++k)
          if (j != k && s[i][k] != '.') din.add((i + h) * w + j, i * w + k, 1);
      }
    }
  if (st.first == go.first || st.second == go.second)
    cout << "-1" << endl;
  else
    cout << din.solve((st.first + h) * w + st.second, go.first * w + go.second)
         << endl;
  return 0;
}


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

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

    int h, w, k;
    cin >> h >> w >> k;

    char C[h][w];
    int B[h + 1][w + 1] = {};
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> C[i][j];
            B[i + 1][j + 1] = C[i][j] == '1';
        }
    }

    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            B[i][j] += B[i][j - 1];
        }
    }
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            B[i][j] += B[i - 1][j];
        }
    }

    int ans = 1e9;
    for(int i = 0; i < (1 << (h - 1)); i++){
        vector<int> Cut;
        for(int j = 0; j < h - 1; j++){
            if((i >> j) & 1){
                Cut.push_back(j + 1);
            }
        }
        Cut.push_back(h);

        int cut_count = Cut.size() - 1;
        bool ook = true;

        int last_y = 0;
        for(int y = 1; y <= w; y++){
            bool ok = true;
            int last_x = 0;
            for(int c = 0; c < Cut.size(); c++){
                int o, p, q, r;
                o = B[Cut[c]][y];
                p = B[Cut[c]][last_y];
                q = B[last_x][y];
                r = B[last_x][last_y];
                
                int total = o - p - q + r;

                if(total <= k);
                else{
                    if(last_y + 1 == y){
                        ok = false; 
                        break;
                    }else{
                        last_y = y - 1;
                        cut_count++;
                    }
                }

                last_x = Cut[c];
            }
            if(ok);
            else{
                ook = false;
                break;
            }
        }

        if(ook){
            ans = min(ans, cut_count);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int N = Cin();
        Console.WriteLine(N/3);
    }
    
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int Cin()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
}


Measured memory_bytes: 11092
h, w = map(int, input().split())
n = int(input())
l = list(map(int, input().split()))
 
ans = []
for i in range(n):
  ans += [i+1]*l[i]

for i in range(h):
  temp = ans[i*w:(i+1)*w]
  if i%2 == 0:
    print(*temp)
  else:
    temp = reversed(temp)
    print(*temp)

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    if (n / 10 == 9 || n % 10 == 9)
        cout << "Yes";
    else
        cout << "No";
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,inp;
  cin>>n;
  vector <int> v,s;
  for(int i=0;i<n;i++){
  	cin>>inp;
    v.push_back(inp);
  }
  s=v;
  sort(s.begin(),s.end());
  for(int i=0;i<n;i++){
  	s[i]=s[i]-v[i];
  }
  int cnt=0;
  for(int x:s){
  	if(x!=0)cnt++;
  }
  if(cnt==2 || cnt==0)cout<<"YES";
  else cout<<"NO";
}

Measured memory_bytes: 256
N = int(input())
A = map(int, input().split())

if N%2 == 0:
    count = [(2 if i%2 == 1 else 0) for i in range(N)]
else:
    count = [(2 if i%2 == 0 else 0) for i in range(N)]
    count[0] = 1

for a in A:
    count[a] -= 1
    if count[a] < 0:
        print(0)
        break
else:
    print(2**(N//2)%(10**9+7))

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

int main () {
  vector<char> line(1110) ;
  string a , b ;
  cin >> a >> b ;
  
  for(int i = 0 ; i < a.size() * 2 ; ) {
    line[i] = a[ i/2 ] ;
    i += 2 ;
  }
  for(int i = 1 ; i < a.size() * 2 ; ) {
    line[i] = b[ i/2 ] ;
    i += 2 ;
  }
  for(int i = 0 ; i < a.size() + b.size() ; i++ ) {
    cout << line[i] ;
  }
  cout << endl ;
}

Measured memory_bytes: 256
#include <cstdio>
int main(){
	int n;
	scanf("%d", &n);
	bool dp[n + 1];
	dp[0] = true;
	for (int i = 1; i <= n; i++){
		dp[i] = false;
	}
	for (int i = 0; i <= n; i++){
		if (dp[i]){
			for (int j = 100; j <= 105; j++){
				if (i + j > n){
					break;
				}
				dp[i + j] = true;
			}
		}
	}
	if (dp[n]){
		printf("1\n");
	}else{
		printf("0\n");
	}
}

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


int main()
{
	int a, b;
	cin >> a >> b;
	if (a + b < 24) {
		cout << a + b << endl;
	}
	else
		cout << a + b - 24 << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tokenizer = null;
    int totalCases, testNum;

    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    void solve() throws IOException {

    }

    void execute() throws IOException {
        int n = ni();
        int[] h = new int[n];
        int[] dp = new int[n + 1];
        for (int i = 0; i < n; i++) {
            h[i] = ni();
        }
        dp[1] = 0;
        dp[2] = Math.abs(h[1] - h[0]);
        for (int i = 3; i < n + 1; i++) {
            dp[i] = Math.min(dp[i - 1] + Math.abs(h[i - 1] - h[i - 2]), dp[i - 2] + Math.abs(h[i - 1] - h[i - 3]));

        }
        out.print(dp[n]);

        out.close();
    }

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

    void debug(Object... os) {
        System.out.println(Arrays.deepToString(os));
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String ns() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(br.readLine());
        }
        return tokenizer.nextToken();
    }

    String nline() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    boolean input() throws IOException {
        return true;
    }

}


Measured memory_bytes: 36808
import math

N = int(input())
TAX_RATE = 1.08
X = N / TAX_RATE
f = math.floor(X)
c = math.ceil(X)
if math.floor(f * TAX_RATE) == N:
    print(f)
elif math.floor(c * TAX_RATE) == N:
    print(c)
else:
    print(":(")


Measured memory_bytes: 3064
n = int(input())
x = [int(i) for i in input().split()]
sortx = sorted(x)

mid_left = sortx[(n//2)-1]
mid_right = sortx[(n//2)]

for i in range(n):
    if x[i] <= mid_left:
        print(mid_right)
    else:
        print(mid_left)

Measured memory_bytes: 25220