akhauriyash/Code-Regression huggingface dataset:
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
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; }
const long long INF = 1LL << 60;

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

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];

    sort(s.begin(),s.end());

    int ans = 0;

    rep(i,n){
        if(i == 0) ans++;
        else if(s[i] != s[i-1]) ans++;
    }

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

Measured memory_bytes: 9548
#include <bits/stdc++.h>
using namespace std;
int n, K;
string s;
int main() {
	cin >> s >> K;
	n = s.length();
	set<string> st;
	for(int j=1; j<=5; j++)
		for(int i=0; i<n-j+1; i++)
			st.insert(s.substr(i,j));
	auto it = st.begin();
	while(--K) it++;
	cout << *it;
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll x[55], y[55];

int main(){
    int n, k;
    cin >> n >> k;
    rep(i, n) cin >> x[i] >> y[i];

    ll ans = 5e18;

    if (k == 2){
        for(int a = 0; a < n-1; a++){
            for(int b = a+1; b < n; b++){
                ll xmax = max({x[a],x[b]});
                ll xmin = min({x[a],x[b]});
                ll ymax = max({y[a],y[b]});
                ll ymin = min({y[a],y[b]});
                int cnt = 0;
                rep(i, n) if (xmin <= x[i] && x[i] <= xmax && ymin <= y[i] && y[i] <= ymax) cnt++;
                if (cnt >= k) ans = min(ans, (xmax-xmin)*(ymax-ymin));
            }
        }
    }



    else if (k == 3){
        for(int a = 0; a < n-2; a++){
            for(int b = a+1; b < n-1; b++){
                for(int c = b+1; c < n; c++){
                    ll xmax = max({x[a],x[b],x[c]});
                    ll xmin = min({x[a],x[b],x[c]});
                    ll ymax = max({y[a],y[b],y[c]});
                    ll ymin = min({y[a],y[b],y[c]});
                    int cnt = 0;
                    rep(i, n) if (xmin <= x[i] && x[i] <= xmax && ymin <= y[i] && y[i] <= ymax) cnt++;
                    if (cnt >= k) ans = min(ans, (xmax-xmin)*(ymax-ymin));
                }
            }
        }
    }


    else {
        for(int a = 0; a < n-3; a++){
            for(int b = a+1; b < n-2; b++){
                for(int c = b+1; c < n-1; c++){
                    for(int d = c+1; d < n; d++){
                        ll xmax = max({x[a],x[b],x[c],x[d]});
                        ll xmin = min({x[a],x[b],x[c],x[d]});
                        ll ymax = max({y[a],y[b],y[c],y[d]});
                        ll ymin = min({y[a],y[b],y[c],y[d]});
                        int cnt = 0;
                        rep(i, n) if (xmin <= x[i] && x[i] <= xmax && ymin <= y[i] && y[i] <= ymax) cnt++;
                        if (cnt >= k) ans = min(ans, (xmax-xmin)*(ymax-ymin));
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}

int main() {
    ll N, X;
    ll x[101000];
    ll ans;
    
    cin >> N >> X;
    
    for (ll i = 0; i < N; i++) {
        cin >> x[i];
    }
    
    ans = abs(x[0] - X);
    
    for (ll i = 1; i < N; i++) {
        ans = gcd(ans, abs(x[i] - X));
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;
class Euclid_Gojyohou{
    public:
    long long int gcd(long long int a, long long int b) {
        long long int tmp;
        long long int r = 1;
        if (b > a) {
            tmp = a;
            a = b;
            b = tmp;
        }
        r = a % b;
        while (r != 0) {


            a = b;
            b = r;
            r = a % b;

        }
        return b;
    }
};


long long int a,b;
int main() {
	cout << fixed << setprecision(18);
	cin>>a>>b;
    Euclid_Gojyohou euc;
    cout<<a*b/euc.gcd(a,b);
	
} 

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map { it.toInt() }
    val cnt = mutableMapOf<Int, Int>()
    for (i in 0 until n) {
        cnt[a[i]] = (cnt[a[i]] ?: 0) + 1
    }
    val ans = cnt.map { if (it.value - it.key >= 0)  it.value - it.key else it.value }.sum()
    println(ans)
}

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

using namespace std;

#define INF (1LL << 54)

#define WHITE 0
#define GRAY  1
#define BLACK 2

int main()
{
	int n, k;

	while (true)
	{
		cin >> n >> k;

		if (n == 0 && k == 0) { break; }

		vector<vector<long long> > graph(n + 1, vector<long long>(n + 1, INF));

		for (int i = 1; i <= k; i++)
		{
			int q; cin >> q;

			if (q == 0)
			{
				int a, b;

				cin >> a >> b;

				vector<int> C(n + 1, WHITE);

				vector<long long> D(n + 1, INF);

				vector<int> P(n + 1);

				D[a] = 0;
				P[a] = -1;

				int u;

				while (true)
				{
					long long mincost = INF;

					for (int i_ = 1; i_ <= n; i_++)
					{
						if (C[i_] != BLACK && D[i_] < mincost)
						{
							mincost = D[i_];

							u = i_;
						}
					}

					if (mincost == INF)
						break;

					C[u] = BLACK;

					for (int v = 1; v <= n; v++)
					{
						if (C[v] != BLACK && graph[u][v] != INF)
						{
							if (D[u] + graph[u][v] < D[v])
							{
								D[v] = D[u] + graph[u][v];
								P[v] = u;
								C[v] = GRAY;
							}
						}
					}
				}

				cout << (D[b] != INF ? D[b] : -1) << endl;
			}
			else
			{
				int c, d, e;

				cin >> c >> d >> e;

				graph[c][d] = min((long long) e, graph[c][d]);
				graph[d][c] = min((long long) e, graph[c][d]);
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e9+7;
int d()
{
    int ret;
    scanf("%d", &ret);
    return ret;
}
long long lld()
{
    long long ret;
    scanf("%lld", &ret);
    return ret;
}
bool cmp(pair<int, int> s, pair<int, int> f)
{
    if (f.first > s.first)
        return true;
    else if (f.first == f.second && f.second < s.second)
        return true;
    else
        return false;
}
long long fact(long long n)
{
    if(n==1)
        return 1;
    return n * fact(n-1);
}
pair<int ,char>p;
pair<int ,char>p1;
pair<int ,char>p2;
int main(){
    int n=d();

    long long sum=1;
    for(long long i=1;i<=n;i++){
        sum*=i;
        sum%=N;
    }
    printf("%lld\n",sum);
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner; 

public class Main {
	
	public static void main(String arg[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[]  a = new String[N];
		String[] resultArray;
		int minj = 0;
		int[][] A = new int[N][2];
		int[][] B = new int[N][2];
		int tmp = 0;
		int num = 0;
		
		for(int i=0; i<N; i++){
			a[i] = sc.next();
			resultArray = a[i].split("");
			num = Integer.parseInt(resultArray[1]);
			A[i][0] = i;
			A[i][1] = num;
			B[i][0] = A[i][0];
			B[i][1] = A[i][1];
		}
		
		/*Bubble*/
		for (int i=0; i<N; i++){
			for (int j=N-1; j>0; j--){
				if(B[j][1] < B[j-1][1]) {
					tmp = B[j][0];
					num = B[j][1];
					B[j][0] = B[j-1][0];
					B[j][1] = B[j-1][1];
					B[j-1][0] = tmp;
					B[j-1][1] = num;
				}
			}
		}
		for(int i=0; i<N; i++){
			if(i<N-1){
				System.out.print(a[B[i][0]] + " ");
			}else{
				System.out.println(a[B[i][0]]);
			}
		}
		System.out.println("Stable");
		
		/*Selection*/
		for(int i=0; i<N; i++){
			minj = i;
			for(int j=i; j<N; j++){
				if(A[j][1] < A[minj][1]){
					minj = j;
				}
			}
			if(A[i][1]!=A[minj][1]){
				tmp = A[i][0];
				num = A[i][1];
				A[i][0] = A[minj][0];
				A[i][1] = A[minj][1];
				A[minj][0] = tmp;
				A[minj][1] = num;
			}
		}
		for(int i=0; i<N; i++){
			if(i<N-1) {
				System.out.print(a[A[i][0]] + " ");
			}else{
				System.out.println(a[A[i][0]]);
			}
		}
		for(int i=0; i<N; i++){
			if(A[i][0]!=B[i][0]) {
				System.out.println("Not stable");
				break;
			}else if(A[i][0]==B[i][0] && i !=N-1){
				continue;
			}else{
				System.out.println("Stable");
			}
		}
	}
}


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

int main(){
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int>x,y;
    for(int i=0; i<N; i++){
        int in;
        cin >> in;
        x.push_back(in);
    }
    for(int i=0; i<M; i++){
        int in;
        cin >> in;
        y.push_back(in);
    }

    for(int i=X+1;i<=Y;i++){
        if(*max_element(x.begin(), x.end()) < i && *min_element(y.begin(), y.end()) >= i){
            cout << "No War";
            return 0;
        }
    }
    cout << "War";
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
        try (Scanner sc = new Scanner(System.in);) {
            // shirai_r
            
            String a = sc.next();
            String[] b = a.split("");

            String aUpper = a.toUpperCase();
            String[] c = aUpper.split("");

            boolean flag = false;

            int countC = 0;
            for (String st : b) {
                if (st.equals("C")) {
                    countC++;
                }
            }

            int countUpper = 0;
            for (int i = 0; i < c.length; i++) {
                if (b[i].equals(c[i])) {
                    countUpper++;
                }
            }

            boolean cc = false;
            for (int i = 2; i < c.length-1; i++) {
                if (b[i].equals("C")) {
                    cc = true;
                }
            }


            if (b[0].equals("A")) {
                if (cc) {
                    if (countC == 1) {
                        if (countUpper == 2) {
                            flag = true;
                        }
                    }
                }
            }
            System.out.println(flag ? "AC" : "WA");
        }

    }

}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N= sc.nextInt(),K=sc.nextInt();
		int ans = 0;
		while(N/(int)Math.pow(K, ans)!=0) {
			
			ans++;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    string s,k,d;
    cin>>s>>k>>d;
    cout<<s[0]<<k[1]<<d[2]<<NL;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int i=0,j=0,count=0;
  char S[20]={'\0'};
  scanf("%s",S);
  while(S[i]!='\0'){
  	if(S[i]=='A' || S[i]=='G' || S[i]=='C' || S[i]=='T'){
      j++;
    }else{
      j=0;
    }
    if(j>count){
      count=j;
    }
    i++;
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 
	ll cnt1[200010]={};
	ll cnt2[200010]={};
int main() {
	string s;
	ll n,k,c;
	cin>>n>>k>>c>>s;

	ll zan=k;
	ll kan=0;
	for(ll i=0;i<n;i++){
		kan--;
		if(kan>0){
			continue;
		}
		if(s[i]=='x'){
			continue;
		}
		cnt1[i]=k-zan+1;
		zan--;
		kan=c+1;
		if(zan==0){
			break;
		}
	}
	zan=k;
	kan=0;
	for(ll i=n-1;i>=0;i--){
		kan--;
		if(kan>0){
			continue;
		}
		if(s[i]=='x'){
			continue;
		}
		cnt2[i]=zan;
		zan--;
		kan=c+1;
		if(zan==0){
			break;
		}
	}
	for(ll i=0;i<n;i++){
		if(cnt1[i]==cnt2[i]&&cnt1[i]!=0){
			cout << i+1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 6840
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <deque>
#include <map>

using namespace std;

const int CMax = 100002;
const int CInf = 2000000001;
const long long CMod = 1000000007;

int n, A[CMax];

int gcd(int a, int b)
{
    if (b != 0) return gcd(b, a % b);
    else return a;
}

string baseConverter(int base, int num) {
    string tNum = "";
    while (num > 0) {
        tNum = (char)('0' + num%base) + tNum;
        num /= base;
    }
}

bool isPalindrom(string tS) {
    int sn = (int)tS.length();
    for (int i = 0; i < sn / 2; i++) {
        if (tS[i] != tS[sn - i - 1]) return false;
    }
    return true;
}

int dist(int i, int j) {
    return  (j < i ? n + j : j) - i;
}

int main()
{
    cin >> n;

    int neg = 0, minNum = CInf;
    long long res = 0;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
        if (A[i] < 0) neg++;
        res += (long long)abs(A[i]);
        minNum = min(minNum, abs(A[i]));
    }

    if (neg % 2 > 0) res -= (long long)(minNum * 2);

    cout << res;

    cout << endl;

    return 0;
}


Measured memory_bytes: 640
n,x=map(int,input().split())
for i in range(n+1):
  for j in range(n-i+1):
    if x==10000*i+5000*j+1000*(n-i-j):
      print(i,j,n-i-j)
      exit()
    
    
print("-1 -1 -1")
  

Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.IO.Pipes;
using System.Linq;
using System.Runtime.InteropServices;

namespace Contest
{


    class Program
    {

        
        static void Main(string[] args)
        {
            var d = int.Parse(Console.ReadLine());
            var c = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[][] s = new int[d][];
            
            for(int i = 0; i < s.Length; i++)
            {
                s[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
            }

            int[] days = new int[26];

            for(int i = 0; i < d; i++)
            {
                // 最小の値で初期化
                var res = int.MinValue;
                var index = -1;
                for(int j = 0; j < s[i].Length; j++)
                {
                    // その日に一番満足度が大きくなるコンテストを探す
                    var happy = (c[j] * (days[j] + 1));
                    if (res < happy)
                    {
                        res = happy;
                        index = j;
                    }
                }


                Console.WriteLine(index + 1);
                for(int j = 0; j < days.Length; j++)
                {
                    if (index == j) days[j] = 0;
                    else days[j]++;
                }

            }
        }
    }
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	string a,b;
	cin >> a >> b;
	REV(b);
	if(a==b) cout << "YES" << endl;
	else cout << "NO" << endl;

//////////////////////////////////////////////
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define clr(x) memset(x, 0, sizeof(x))
#define sz(x) (int)x.size()

using namespace std;

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

const ll mx = 105;
const ll maxn = 1000001;
const ll mod = 1000000007;

vector<vector<int>> adj;
vector<ll> lis;


int main(){
       
 
  ll t = 1;

  //cin>>t;

  while(t--){
     ll n, i, j ,k;

     ll s, w;

     cin>>s>>w;

     if(w >= s){
         cout<<"unsafe\n";
     }
     else{
         cout<<"safe\n";
     }
  }     
        
}


Measured memory_bytes: 3624
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int x;
  cin >> x;
  if (x >= 1200) cout << "ARC" << endl;
  else cout << "ABC" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	char s[4];
	int i, p, q;
	for (int i = 0; i < 4; i++)
	{
		scanf("%c", &s[i]);
	}
	for (i = 1; i < 4; i++)
	{
		if (s[0] == s[i])
		{
			break;
		}
	}
	switch (i)
	{
	case 1:
		p = 2;
		q = 3;
		break;
	case 2:
		p = 1;
		q = 3;
		break;
	case 3:
		p = 1;
		q = 2;
		break;
	case 4:
		printf("No");
		return 0;
	}
	if (s[p] == s[q] && s[p] != s[0])
	{
		printf("Yes");
		return 0;
	}
	printf("No");
	return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    int n,k;
    cin>>n>>k;
    
    int dp[n+2][k+2],tot_sum[n+2][k+2],a[n+2];
    memset(dp,0,sizeof(dp));  memset(tot_sum,0,sizeof(tot_sum));
    
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=0;i<=n;i++) {dp[i][0] = 1;tot_sum[i][0] = 1;}
    for(int i=0;i<=k;i++) tot_sum[0][i] = 1;
    
    for(int i=1;i<=n;i++) {
        for(int j=1; j<=k; j++) {
            int l = max(0,j-a[i]) , r = j;
            dp[i][j] = (tot_sum[i-1][r] - (l != 0)*(tot_sum[i-1][l-1]))%mod;
            dp[i][j] += mod;  dp[i][j] %= mod;
            tot_sum[i][j] = (tot_sum[i][j-1] + dp[i][j])%mod;
        }
    }
    cout<<dp[n][k];
    return 0;
}

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

using namespace std;

const int N = 100100;

vector<int> adj[N];
pair<int, int> range[N];

int v[N];
bool valid = true;

bool combine(const pair<int, int>& a, pair<int, int>& b) {
	if ((a.first & 1) != (b.first & 1)) return false;
	if (a.second < 1 || b.second < 1) return false;
	if (a.first + 2 * (a.second - 1) < b.first) return false;
	if (b.first + 2 * (b.second - 1) < a.first) return false;

	int lo = max(a.first, b.first);
	int hi = min(a.first + 2 * (a.second - 1), b.first + 2 * (b.second - 1));
	b = make_pair(lo, 1 + (hi - lo) / 2);
	return true;
}

pair<int, int> dfs(int u, pair<int, int> r, int prev = -1) {
	if (v[u] != -1) {
		if (!combine(make_pair(v[u], 1), r)) {
			valid = false;
			return make_pair(1, 0);
		}
	}

	for (int v : adj[u]) {
		if (v == prev) continue;
		if (!combine(dfs(v, make_pair(r.first - 1, r.second + 1), u), r)) {
			valid = false;
			return make_pair(1, 0);
		}
	}

	range[u] = r;

	// printf("range de %d, (%d, %d)\n", 1 + u, r.first, r.second);

	return make_pair(r.first - 1, r.second+ 1);
}

void solve(int u, int prev = -1) {
	// printf("to no %d\n", 1 + u);
	if (v[u] == -1) {
		auto f = [&](int x) -> bool {
			auto r = range[u];
			if ((x & 1) != (r.first & 1)) {
				return false;
			}
			return x >= r.first && x < r.first + 2 * r.second;
		};

		// printf("range (%d, %d), possiveis {%d, %d}\n", range[u].first, range[u].second, v[prev] - 1, v[prev] + 1);

		if (f(v[prev] - 1)) v[u] = v[prev] - 1;
		if (f(v[prev] + 1)) v[u] = v[prev] + 1;

		assert(v[u]);
	}

	for (int v : adj[u]) {
		if (v == prev) continue;
		solve(v, u);
	}
}

int main() {
	memset(v, -1, sizeof v);

	int n;
	scanf("%d", &n);

	for (int i = 1; i < n; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		u--, v--;
		adj[u].emplace_back(v);
		adj[v].emplace_back(u);
	}

	int k;
	scanf("%d", &k);

	int root;
	for (int i = 0; i < k; i++) {
		int u, x;
		scanf("%d %d", &u, &x);
		v[u - 1] = x;
		root = u - 1;
	}

	dfs(root, make_pair(v[root], 1));

	if (!valid) {
		puts("No");
		return 0;
	}

	// printf("root: %d\n", root);

	puts("Yes");
	solve(root);

	for (int i = 0; i < n; i++) {
		printf("%d\n", v[i]);
	}

	return 0;
}


Measured memory_bytes: 15360
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define vbi vector<bool> 
#define mod 1000000007
#define INF 1000000000
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define ms(x,v)    memset(x, v, sizeof x)
#define endl '\n'
#define cnl cout<<endl;
#define fr(i,b) for(ll i=0; i<b;i++)
#define frr(i,a,b) for(ll i=a;i<=b;i++)
#define fb(i,b) for(ll i=b-1; i>=0; i--)
#define pi  3.141592653589793238
ll i,j;
int main(){
   
 ll n; cin>>n;
 ll x=n-1;
 ll y=(x)*(x+1);
 y=y/2;
 cout<<y<<endl;
  
return 0;
}
 

Measured memory_bytes: 256
n, m, x, y = map(int, input().split())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))

outbreak = True

for z in range(x, y+1):
    if x < z < y and max(xs) < z and min(ys) >= z:
        outbreak = False

print('War' if outbreak else 'No War')

Measured memory_bytes: 3060
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

LL pre[100005], suf[100005];
LL num[100005], sum[100005];
int n, k;

int main()
{

	scanf("%d", &n);
	scanf("%d", &k);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &num[i]);
		sum[i] = sum[i - 1] + num[i];
	}

	for (int i = 1; i <= n; i++) {
		pre[i] = pre[i - 1] + (num[i] >= 0 ? num[i] : 0);
	}
	for (int i = n; i >= 1; i--) {
		suf[i] = suf[i + 1] + (num[i] >= 0 ? num[i] : 0);
	}

	LL ans = 0;
	for (int i = 1; i + k - 1 <= n; i++) {
		LL now;
		now = pre[i - 1] + suf[i + k];
		ans = MAX(ans, now);

		now = pre[i - 1] + suf[i + k] + sum[i + k - 1] - sum[i - 1];
		ans = MAX(ans, now);
	}

	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 3328
fun main(args: Array<String>) {
    var N = readLine()!!.toLong()
    for(i in N downTo 0){
        var j = i.toDouble()
        var sq = (Math.sqrt(j)).toLong()
        
        if(sq * sq == i){
            println(i)
            break
        }
    }    
}   


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

ans = 0

for i in range(1,10):
  for j in range(0,10):
    for k in range(0,10):
      num = [str(i),str(j),str(k),str(j),str(i)]
      
      if int(''.join(num)) >= a and int(''.join(num)) <= b:
#        print(num)
        ans += 1
        
print(ans)

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

#define ll long long
#define PB push_back
#define PII pair<int, int>
#define MP make_pair
#define all(x) x.begin(), x.end()
#define REP(x, y, z) for(int x = y; x <= z; x++)
#define REPP(x, y, z) for(int x = y; x >= z; x--)
#define F first
#define S second
#define MSET(x, y) memset(x, y, sizeof(x)) 
#define EB emplace_back
#define maxn

//structure

//declaration

//functions

int main(void)
{
	#ifdef DBG
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
	#endif

    ll n;

    scanf("%lld", &n);

    if(n%2 == 1)
        printf("0\n");
    else
    {
        ll cnt = 10;
        ll ans = 0;

        while(cnt <= n)
        {
            ans += n/cnt;
            cnt *= 5;
        }

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

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
map<string,int>mp;
string key = "573";
auto cal(string s){
    if( s.size() >= 10 )return;
    rep(i,key.size()){
        string temp = s + key[i];
        mp[temp]++;
        cal(temp);
    }
    
}
signed main(){
    cal("");
    int n; cin >> n;
    int ans = 0;
    for(auto itr : mp){
        if(itr.first.find("3") == string::npos or itr.first.find("5") == string::npos or itr.first.find("7") == string::npos)
            continue;
        auto temp = stoll(itr.first);
        if(temp > n)continue;
        ++ans;
    }
    cout << ans << endl;
}




Measured memory_bytes: 10240
#include<cstdio>
#include<iostream>
#include<string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int Nans, Mans, T;
    if ( n == 0) {
        Nans = 0;
    } else {
        Nans = n * (n - 1) / 2;
    }
    if ( m == 0) {
        Mans = 0;
    } else {
        Mans = m * (m - 1) / 2;
    }
    T = Nans + Mans;
    cout << T << endl;
    return 0;
}

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

#define endl '\n'

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
  
    string s;
    cin >> s;

    int count = 0, ans = 0;

    for (char c : s) {
        if (c == 'S') {
            count = 0;
        } else {
            ++count;
        }
        ans = max(ans, count);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3496
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        while (true) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            int[] value = new int[n];
            int max = 0;
            int min = 1000;
            for (int i = 0; i < n; i++) {
                value[i] = sc.nextInt();
            }
            Arrays.sort(value);
            long total = 0;
            for (int i = 1; i < n - 1; i++) {
                total += value[i];
            }
            long ans = total / (n - 2);
            System.out.println(ans);
        }

    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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



Measured memory_bytes: 24280
#include <stdio.h>

int notin_x(int x,int p[],int n)
{
  for(int i=0; i<n; i++)
    if(p[i] == x)
      return 0;
  return 1;
}

int main(void)
{
  int x,n,a,b;
  int iscont_a = 0,iscont_b = 0;
  
  scanf("%d %d",&x,&n);
  
  if(n == 0){
    printf("%d\n",x);
    return 0;
  }
  
  a = x-1;
  b = x+1;
  
  int p[n];
  for(int i=0; i<n; i++)
    scanf("%d",&p[i]);
  
  if(notin_x(x,p,n)){
    printf("%d\n",x);
    return 0;
  }
  
  while(1){
    for(int i=0; i<n; i++){
      if(a == p[i])
        iscont_a = 1;
      if(b == p[i])
        iscont_b = 1;
    }
    if(!iscont_a){
      printf("%d\n",a);
      return 0;
    }
    else if(!iscont_b)
    {
      printf("%d\n",b);
      return 0;
    }
    a--;
    b++;
    iscont_a=0;
    iscont_b=0;
  }
  return 0;
}

Measured memory_bytes: 1728
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  if(n==1){
    cout << "Hello World" << "\n";
    return 0;
  }
  else{
    int a,b;
    cin >> a >> b;
    cout << a+b << "\n";
    return 0;
  }
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define fi first
#define se second

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

ll n,a,b;
ll h[100010];

int isok(ll c){
    ll num=a-b;
    ll c1=0;
    rep(i,n){
        if (c*b<h[i]){
            ll d=h[i]-b*c;
            if (d%num==0)c1+=d/num;
            else c1+=(d/num)+1;
        }
    }
    if (c1>c)return 0;
    else return 1;
}


int main() {
    cin>>n>>a>>b;
    //n=100000,a=1000000000,b=999999999;
    rep(i,n){
        cin>>h[i];
    }
    ll l=0,r=1e9/a*n;
    while (r-l>1){
        ll mid=(r+l)/2;
        if (isok(mid))r=mid;
        else l=mid;
    }
    //rep(i,10)cout<<isok(i)<<endl;
    if (isok(l))cout<<l<<endl;
    else cout<<r<<endl;
    

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
#define dump(a) cout << (a) << endl;
typedef long long Int;
Int mod = 1e9+7;
Int MOD = 998244353;

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < (int)s.size(); i++) {
        if (s[i] == '2') cnt++;
    }
    dump(cnt);
    return 0;  
}

Measured memory_bytes: 256
#include <math.h>
#include <iostream>

using namespace std;
 
int main() {
 
unsigned long long a;
double b;
cin >> a >> b;
unsigned long long rand = (b*1000+0.5)/10;
long long f = a*rand;
f = f/100;
cout << (unsigned long long)(f);
 
}

Measured memory_bytes: 3192
N = int(input())
li = list(map(int,input().split()))
num=-1
x=0

while(1):
    num+=1
    for i in li:
        if i%2==1:
            print(num)
            x+=1
            break
    if x==1:
        break
    for j in range(N):
        li[j]=li[j]/2


Measured memory_bytes: 40816
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        var nmx = new List<string>(Console.ReadLine().Split(' '))
            .Select(x=>int.Parse(x)).ToList();
        var a = new List<string>(Console.ReadLine().Split(' '))
            .Select(x=>int.Parse(x)).ToList();
        var l = a.FindIndex(x => nmx[2] < x);
        Console.WriteLine(Math.Min(l, a.Count - l));
    }
}

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

template<class T>
void print_vec(vector<T>& v) {
	for (T n: v) cout << n << " ";
	cout << "\n";
}

int main() {
	// freopen("./input.txt", "r", stdin);
	int N;
	cin >> N;
	vector<int> x, y, h;
	for (int i = 0; i < N; i++) {
		int xx, yy, hh;
		cin >> xx >> yy >> hh;
		x.push_back(xx);
		y.push_back(yy);
		h.push_back(hh);
	}
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			bool suc = true;
			int H;
			for (int k = 0; k < N; k++) {
				if (h[k] == 0) continue;
				H = h[k] + abs(x[k] - i) + abs(y[k] - j);
				break;
			}
			for (int k = 0; k < N; k++) {
				if (h[k] == 0) {
					if (H - abs(x[k] - i) - abs(y[k] - j) > 0) {
						suc = false;
						break;
					}
				} else {
					if (H != h[k] + abs(x[k] - i) + abs(y[k] - j)) {
						suc = false;
						break;
					}
				}
			}
			if (suc) {
				cout << i << " " << j << " " << H << "\n";
				return 0;
			}
		}
	}
	
	return 0;
}


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

#define int long long

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint>PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;
int dx[]={0,0,1,-1};
int dy[]={-1,1,0,0};

int N;
int a[100010];

signed main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>N;
    int cnt1=0,cnt2=0;
    int icnt1,icnt2;
    rep(i,0,N){
        cin>>a[i];
        if(a[i]>cnt1 && a[i]>0){
            cnt1=a[i];
            icnt1=i;
        }else if(a[i]<cnt2 && a[i]<0){
            cnt2=a[i];
            icnt2=i;
        }
    }
    cout<<2*N-2<<endl;
    if(abs(cnt1)>abs(cnt2)){
        rep(i,0,N){
            if(i==icnt1)continue;
            a[i]+=cnt1;
            cout<<icnt1+1<<" "<<i+1<<endl;
        }
        rep(i,0,N-1){
            a[i+1]+=a[i];
            cout<<i+1<<" "<<i+2<<endl;
        }
    }else{
        rep(i,0,N){
            if(i==icnt2)continue;
            a[i]+=cnt2;
            cout<<icnt2+1<<" "<<i+1<<endl;
        }
        rrep(i,0,N-1){
            a[i+1]+=a[i];
            cout<<i+2<<" "<<i+1<<endl;
        }
    }
    
    
    //rep(i,0,N)cout<<a[i]<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 384
def possible(a):
    cntOdd = 0
    for i in a:
        if (i&1)==1:
            cntOdd += 1
    if (cntOdd&1)==0:
        return True
    else:
        return False

def main():
    n = (raw_input().strip())
    a = [int(i) for i in raw_input().strip().split()]
    if possible(a):
        print 'YES'
    else:
        print 'NO'

if __name__=='__main__':
    main()


Measured memory_bytes: 11812
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ADiscountFare solver = new ADiscountFare();
        solver.solve(1, in, out);
        out.close();
    }

    static class ADiscountFare {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            out.println(in.ints() + in.ints() / 2);

        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}



Measured memory_bytes: 21332
N,M = map(int,input().split())
N_list = [0]*N
flg_list  = [0]*N
flg = False
for i in range(M):
    s,c = map(int,input().split())
    if flg_list[s-1] == 0:
        N_list[s-1] = c
        flg_list[s-1] = 1
    elif N_list[s-1] != c:
        flg = True
        break
res = 0
for i in range(N-1,-1,-1):
    res += 10**i * N_list[N-1-i]

if N == 1 and not flg:
    print(res)
elif flg or (N_list[0] == 0 and flg_list[0] == 1):
    print("-1")
elif N == len(str(res)):
    print(res)
else:
    print(res+10**(N-1))


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {

    int N, M;
    bool e[51][51] = {{false}};
    vector< pair<int, int > > g;
    cin >> N >> M;
    for(int i = 0; i < M; i++) {
        int a, b; cin >> a >> b;
        g.push_back(make_pair(a, b));
        e[a][b] = e[b][a] = true;
    }

    int ans = 0;
    for(int i = 0; i < M; i++) {
        e[g[i].first][g[i].second] = e[g[i].second][g[i].first] = false;
        int mincost[51][51];
        fill_n(*mincost, 51 * 51, 1e+8);
        for(int j = 0; j <= N; j++) mincost[j][j] = 0;
        for(int j = 0; j < M; j++)
            if(e[g[j].first][g[j].second]) mincost[g[j].first][g[j].second] = mincost[g[j].second][g[j].first] = 1;

        for(int j = 1; j <= N; j++) {
            for(int k = 1; k <= N; k++) {
                for(int l = 1; l <= N; l++) {
                    /*if(e[k][l] && e[k][j] && e[j][l])
                        mincost[k][l] = min(mincost[k][l], mincost[k][j] + mincost[j][l]);
                    else if(!e[k][l] && e[k][j] && e[j][l])
                        mincost[k][l] = min(mincost[k][l], mincost[k][j] + mincost[j][l]); */
                    mincost[k][l] = min(mincost[k][l], mincost[k][j] + mincost[j][l]);
                }
            }
        }

        int c[100] = {0};
        for(int j = 1; j <= N; j++) {
            for(int k = 1; k <= N; k++) {
                //cout << "M: " << i << ", " <<  j << " -> " << k << ": " << mincost[j][k] << endl;
                if(mincost[j][k] == 1e+8) {
                    c[k]++;
                }
            }
        }
        for(int j = 1; j <= N; j++) {
            if(c[j]) {
                ans++;
                break;
            }
        }
        e[g[i].first][g[i].second] = e[g[i].second][g[i].first] = true;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
W,H,N = map(int,input().split())
height = set([])
wigth = set([])
for i in range(N):
    x,y,a = map(int,input().split())
    if a == 1:
        for i in range(x):
            wigth.add(i)
    elif a == 2:
        for i in range(x,W):
            wigth.add(i)
    elif a == 3:
        for i in range(y):
            height.add(i)
    else:
        for i in range(y,H):
            height.add(i)
print((H-len(height))*(W-len(wigth)))

Measured memory_bytes: 9120
#include <iostream>
using namespace std;
int main(){
    int a,b,c = 0;
    cin >> a;
    for(int i = 0; i < a; i++){
        cin >> b;
        while(b % 2 == 0 || b == 0){
            b /= 2;
            c++;
        }
    }
    cout << c << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int max=-1;
		int min=1001;
		for(int i=0;i<a;i++) {
			int c=sc.nextInt();
			if(max<c)max=c;
			if(min>c)min=c;
		}
		System.out.println(max-min);
	}
}

Measured memory_bytes: 21716
//https://atcoder.jp/contests/code-festival-2016-qualc/tasks/codefestival_2016_qualC_c
//C - 二人のアルピニスト / Two Alpinists
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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; }
constexpr ll MOD=1e9+7;
int main() {
    ll N; cin>>N; 
    vector<ll> tn(N),an(N);
    for(auto&& t:tn){
        cin>>t;
    }
    for(auto&& a:an){
        cin>>a;
    }
    ll tmx=*(tn.end()-1);
    ll amx=*an.begin();
    if (tmx!=amx) {cout<<0<<endl; return 0;} 
    vector<ll> tt(N,0),aa(N,0);
    ll mx=0;
    ll tno=-1,ano=-1;
    REP(i,N){
        const auto t=tn.at(i);
        if(tno<0&&tmx==t) tno=i;
        if(mx>t) {cout<<0<<endl; return 0;}
        if(!chmax(mx,t)){
            tt.at(i)=t;
        }
    }
    mx=0;
    for(ll i=N-1;i>=0;--i){
        const auto a=an.at(i);
        if(ano<0&&amx==a) ano=i;
        if(mx>a) {cout<<0<<endl; return 0;}
        if(!chmax(mx,a)){
            aa.at(i)=a;
        }
    }
    if(tno>ano){cout<<0<<endl; return 0;}
    ll ans=1;
    REP(i,N){
        if(tt.at(i)<=0||aa.at(i)<=0){
        } else {
            ll n=min(tt.at(i),aa.at(i));
            ans *= n;
            ans %= MOD;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

//inline int read(){int t = 0;int neg=1;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1;continue;}t=t*10+c-48;}return neg*t;}
//inline int readl(){long long t = 0;long long neg=1ll;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1ll;continue;}t=t*10+c-48;}return neg*t;}

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pi> vpi;
typedef vector<plli> vplli;
const lli M=1000000007ll;

int main(){
	fast_io 
	int n;cin>>n;
	cout<<(n+1)/2;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  int b;
  cin >> a >> b;
  if (a*b % 2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
  
  
}

Measured memory_bytes: 384
import math
a,b,x = map(int,input().split())
v = a **2 * b
h = 0
ans = 0
if v == x:
    ans = 0
elif(x > v // 2):
    ans = 90 - math.degrees(math.atan(a ** 3 / ( 2 * (v - x))))
else:
    ans = 90 - math.degrees(math.atan(x / (a * b **2 // 2)))
print(ans)

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

using ll = long long;
using ull = unsigned long long;

int main() {
    int n, x, t;
    cin >> n >> x >> t;

    int total = 0;
    int time = 0;
    while (total < n) {
        total += x;
        time += t;
    }

    cout << time << "\n";
    return 0;
}


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

long long lcm(long long a, long long b) {
  long long x = a * b;
  if ( a < b){
    swap(a, b);
  }
  long long r = a % b;
  while (r!=0) {
    a = b;
    b = r;
    r = a % b;
  }
  return x / b;
}

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

  long long l = lcm(c, d);

  // a 未満で c or dで割り切れる個数
  long long cnt_a = (a-1) / c + (a-1) / d - (a-1) / l;
  // b 以下で c or dで割り切れる個数
  long long cnt_b = b / c + b / d - b / l;

  long long ans = b - a + 1 - (cnt_b - cnt_a);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 1024 * 1024)
	stdout := os.Stdout

	defer stdout.Close()

	writer := bufio.NewWriterSize(stdout, 1024 * 1024)

	todayW := readLine(reader)

	var w = map[string]string{
		"Sunny": "Cloudy",
		"Cloudy" : "Rainy",
		"Rainy" : "Sunny",
	}

	result := w[todayW]
	

	fmt.Fprintf(writer, "%s\n", result)

	writer.Flush()
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 100100100100100100;
struct edge{ll from;ll to;ll cost;};
edge G[5000];ll d[2500],V,E;
bool BellmanFord_reverse(ll s){//正の閉路が検出されたらtrue
  ll i,j;bool ne[V] = {};
  fill(d,d+V,-inf);d[s] = 0;
  for(i=0;i<V-1;i++){
    for(j=0;j<E;j++){
      if(d[G[j].from]!=-inf && d[G[j].to]<d[G[j].from]+G[j].cost){
        d[G[j].to] = d[G[j].from]+G[j].cost;
      }
    }
  }
  for(i=0;i<V;i++){
    for(j=0;j<E;j++){
      if(d[G[j].from]!=-inf && d[G[j].to]<d[G[j].from]+G[j].cost) ne[G[j].to] = true;
      if(ne[G[j].from]) ne[G[j].to] = true;
    }
  }
  return ne[V-1];
}
int main(){
  ll i,p;
  scanf("%lld%lld%lld",&V,&E,&p);
  for(i=0;i<E;i++){
    scanf("%lld%lld%lld",&G[i].from,&G[i].to,&G[i].cost);
    G[i].from--;G[i].to--;G[i].cost -= p;
  }
  if(BellmanFord_reverse(0)) printf("-1\n");
  else printf("%lld\n",max(0LL,d[V-1]));
}


Measured memory_bytes: 512