akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
      	if(s.length() != 6) {
          return;
        }
      //coffee
      	String s2 = s.substring(2,3);
        String s3 = s.substring(3,4);
      	String s4 = s.substring(4,5);
      	String s5 = s.substring(5,6);
      
        if(s2.equals(s3) && s4.equals(s5)) {
        	System.out.println("Yes");
        }else {
        	System.out.println("No");
        }
    }
}

Measured memory_bytes: 23252
#include<stdio.h>

int main(){
	
	long long a;
	scanf("%lld",&a);
	
	int i = 0;
	char str[100];
	
	while(a > 0){
		int temp = a % 26;
		
		if(temp == 0){
			str[i++] = 'z';
			a = (a/26) - 1;
		}else{
			str[i++] = (temp - 1) + 'a';
			a = a/26;
		}
	}
	str[i] = '\0';
	

	for(int j = i - 1;j >= 0;j--){
		printf("%c",str[j]);
	}
	
	
	return 0;
}


Measured memory_bytes: 1640
#include <stdio.h>
#include <math.h>

int main() {
    float a, b, c, d, e, f;
    for (;;) {
        int i = scanf("%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f);
        if (i != 6) break;
        if (a * e - b * d == 0) {
            printf("%.3f %.3f\n", 1.0, 1.0);
        } else {
            c = c / a;
            b = b / a;
            a = a / a;
            f = f - d * c;
            e = e - d * b;
            d = d - d * a;
            f = f / e;
            e = e / e;
            c = c - b * f;
            b = b - b * e;
            printf("%.3f %.3f\n", c, f);
        }
    }
    return 0;
}



Measured memory_bytes: 2072
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan=new Scanner(System.in);
    		
    		int a=Integer.parseInt(scan.next());
    		int b=Integer.parseInt(scan.next());
    		int c=Integer.parseInt(scan.next());
    		int[] array= {a,b,c};
    		Arrays.parallelSort(array);
    		System.out.print(array[0]+array[1]);

    		
    	
  
    				
 
     
    }
    }

Measured memory_bytes: 22100
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll solve(ll i,ll j,vector<vector<char> > &s,vector<vector<ll> > &dp,ll m,ll n)
{
	if(dp[i][j]!=-1)
	{
		return dp[i][j];
	}
	if(s[i][j]=='#')
		return 0;
	if(i!=m-1 && j!=n-1)
	{
		dp[i][j]=(solve(i+1,j,s,dp,m,n)%1000000007+solve(i,j+1,s,dp,m,n)%1000000007)%1000000007;
	}
	return dp[i][j];
}
int main()
{
	ll m,n;
	cin>>m>>n;
	vector<vector<char> > s(m,vector<char> (n));
	for (ll i=0;i<m;i++)
	{
		for(ll j=0;j<n;j++)
		{
			cin>>s[i][j];
		} 
	}
	vector<vector<ll> > dp(m,vector<ll> (n,-1));
	for(ll i=n-1;i>=0;i--)
	{
		if(s[m-1][i]=='#')
		{
			for (ll j=0;j<=i;j++)
			{
				dp[m-1][j]=0;
			}
			break;
		}
		else
		{
			dp[m-1][i]=1;
		}
	}
	for(ll i=m-1;i>=0;i--)
	{
		if(s[i][n-1]=='#')
		{
			for (ll j=0;j<=i;j++)
			{
				dp[j][n-1]=0;
			}
			break;
		}
		else
		{
			dp[i][n-1]=1;
		}
	}
	cout<<solve(0,0,s,dp,m,n);
}

Measured memory_bytes: 9344
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using namespace std;

int main() {
    unsigned n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    int m;
    cin >> m;
    for (int i = 0; i < m; ++i) {
        int p, x, ans = 0;
        cin >> p >> x;
        for (int j = 1; j <= n; ++j) {
            ans += (p == j ? x : v[j-1]);
        }
        cout << ans << "\n";
    }
    return 0;
}

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


int main()
{
	  long long ans=0;
	
int n;   cin>>n;
	
	for(int i=1;i<=n;i++)
	{
		if(i%3!=0 && i%5!=0)
		ans+=i;
		
	}
    cout<<ans<<endl;
}




Measured memory_bytes: 3608
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

int main(){
  string s;
  cin>>s;
  REP(i,s.length())s[i]='x';
  cout<<s<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int N, W, H, S, T; // S <= W, T <= H
int x, y;
char field[101][101];

int solve(int a, int b){
  int cnt = 0;
  for(int i = a ; i < a + T ; i++){
    for(int j = b ; j < b + S ; j++){
      if(field[i][j] == '*') cnt++;
      //cout << field[i][j];
    }
    //cout << endl;
  }
  //cout << endl;
  return cnt;
}

int main(){
  int ans;
  while(cin >> N, N){
    cin >> W >> H;
    memset(field, '.', sizeof(field));
    while(N--){
      cin >> x >> y;
      field[y][x] = '*';
    }
    cin >> S >> T;

    /*for(int i = 1 ; i <= H ; i++){
      for(int j = 1 ; j <= W ; j++){
	cout << field[i][j];
      }
      cout << endl;
      }
    cout << endl;*/
   
    ans = 0;
    for(int i = 1 ; i <= H - T + 1 ; i++){
      for(int j = 1 ; j <= W - S + 1 ; j++){
	ans = max(ans, solve(i, j));
      }
    }
    cout << ans << endl;
  }
  return 0;
}
    

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fbo find_by_order
#define ook order_of_key
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define MOD 998244353
#define MID (l+r)/2
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define mx 100003
#define pc(x) putchar_unlocked(x);
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int cnt(int a){
	int ret=0;
	while(a){
		ret+=a%10;
		a/=10;
	}
	return ret;
}
int jaw=1e9;
int main(){
	int n;
	cin>>n;
	for(int i=1;i<n;i++){
		int a=i;
		int b=n-i;
		jaw=min(jaw,cnt(a)+cnt(b));
	}
	cout<<jaw;
}




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

using namespace std;

string s;

int main()
{
	cin >> s;
	int co=0;
	long long ans=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='A') co++;
		else if(i+1<s.size()&&s[i]=='B'&&s[i+1]=='C')
		{
			ans+=co; i++;
		}
		else
			co=0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  if(c == a + 1 && d == 1)cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    // ABC152D
    static final long MOD = 1_000_000_007;
    // 10^9+7
    static final int MAX = 2_147_483_646;
    // intの最大値
    static final int INF = 1_000_000_000;

    // 10^9
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] ary = new int[n];
        boolean[] red = new boolean[n];
        for(int i = 0;i < n;i++){
            ary[i] = 1;
            red[i] = false;
        }
        red[0] = true;
        int m = sc.nextInt();
        for(int i = 0;i < m;i++){
            int x = sc.nextInt();
            int y = sc.nextInt();
            ary[x-1]--;
            ary[y-1]++;
            if(red[x-1])red[y-1] = true;
            if(ary[x-1]<=0)red[x-1] = false;
        }
        int ans = 0;
        for(int i = 0;i < n;i++){
            if(ary[i]>0&&red[i])ans++;
        }
        System.out.println(ans);
    }
}


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

using namespace std;

#define lli long long int
#define x first
#define y second

lli x, y, n, d, ans;

int main()
{
 //   freopen("Bao.inp","r",stdin);
    cin >> n >> d;
    for(int i = 1; i <= n; ++i)
    {
        cin >> x >> y;
        if(sqrt(pow(x,2) + pow(y,2)) <= d)
        {
            ans++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3600
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();//to String
    if (N < 10) {
      System.out.println(N);
      return;
    }
    
    long ans = 0;
    long ans2 = 0;
    while (N > 0) {
      if (N < 10) {
        ans += N -1;
        ans2 += N;
        break;
      }
      ans += 9;
      ans2 += N % 10;
      N /= 10;
    }
    System.out.println(Math.max(ans, ans2));
  }
}
    
    

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

using namespace std;
typedef long long ll;
const int N = 1e5+7;
int a[N] , b[N] , c[N];
int dp[N][4];
int n ;
int main()
{
    memset(dp , -1 , sizeof dp);
    cin >> n;
    for(int i = 1 ; i <=n ; i++)
    {
        cin >> a[i] >> b[i]  >> c[i];
    }
    dp[0][0]=0;
    dp[0][1]=0;
    dp[0][2]=0;
    dp[0][3]=0;
    for(int i = 1 ; i<=n ;i++)
    {
        dp[i][1]=max(dp[i-1][2] , dp[i-1][3])+a[i];
        dp[i][2]=max(dp[i-1][1] , dp[i-1][3])+b[i];
        dp[i][3]=max(dp[i-1][1] , dp[i-1][2])+c[i];
    }
    cout << max(max(dp[n][1],dp[n][2]),dp[n][3]) ;
    return 0;
}


Measured memory_bytes: 6332
#include<iostream>
#include<stdio.h>

using namespace std;

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

long long int lcm(long long int a,long long int b){
	return a*b/gcd(a,b);
}

int main(){
	long long int a,b;
	
	while(scanf("%lld %lld",&a,&b) != EOF){
		cout << gcd(a,b) << " " << lcm(a,b) <<  endl;
	}
	return 0;
}

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

int main() {
    int n;
    cin>>n;
    vector<int>ans(n);
    rep(i,n-1) {
        int a;
        cin>>a;
        ans[a-1]++;
    }
    for(int x:ans) {
        cout<<x<<endl;
    }
}

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

int main()
{
  int n,a;
  int s=0;
  cin >> n;
  int min=n+1;
  for (int i=1; i<=n; i++)
  {
    cin >> a;
    if (a<min)
    {
      min=a;
      s=s+1;
    }
  }
  cout << s;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int x;
int main(){
	cin>>x;
	if(x>1799)cout<<1<<endl;
	else if(x>1599)cout<<2<<endl;
	else if(x>1399)cout<<3<<endl;
	else if(x>1199)cout<<4<<endl;
	else if(x>999)cout<<5<<endl;
	else if(x>799)cout<<6<<endl;
	else if(x>599)cout<<7<<endl;
	else cout<<8<<endl;
	return 0;
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};


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

    int n;
    string s[3] = {"Sunny","Cloudy","Rainy"};
    string a;
    cin >> a;
    rep(i,3){
        if(a == s[i]){
          if(i == 2) {
            cout << s[0] << endl;
            return 0;
          }
            cout << s[i+1] << endl;
            return 0;
        }
    }

    cout << endl;
    return 0;
}


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

int main() {
  int a;
  cin >> a;
  string s;
  cin >> s;
  if (a >= 3200) cout << s << '\n';
  else puts("red");
  return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Range
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int num1 = int.Parse(input[0]);
            int num2 = int.Parse(input[1]);
            int num3 = int.Parse(input[2]);

            if (num1 < num2 && num2 < num3)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}



Measured memory_bytes: 15944
puts ($<.map{|l|(n=l.to_i)<1?0:(a=[]
n.times{|c|n,x,_,y=gets.split;a<<[-x.to_i*3-y.to_i,c,n]}
a.sort.map{|s,c,n|[n,-s]*?,}<<"")}-[0])*$/

Measured memory_bytes: 6112
#include <stdio.h>

int main() {
	int i, n, a[50], b[60], c[60], ans = 0;

	scanf("%d", &n);

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

	for (i = 0; i < n; i++)
		scanf("%d", &b[i]);

	for (i = 0; i < n -1; i++)
		scanf("%d", &c[i]);

	for (i = 0; i < n - 1; i++) {
		ans += b[a[i] -1];
		if (a[i] == (a[i + 1] - 1)) {
			ans += c[a[i] - 1];
		}
	}

	ans += b[a[n - 1] - 1];

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

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int n;
int arr[N];
map<pi , int> dp;
const int MIN = -1e18;
int fun(int idx , int k){
   //if(idx >= n && k > 0)return MIN;
   if(k ==0 && idx >= n)return 0;
   if(idx >= n)return MIN;
   //cout<<"idx :"<<idx<<" "<<"k : "<<k<<" ";
    if((n-idx+1)/2 < k)return MIN;
   if(dp.count({idx , k}) > 0)return dp[{idx , k}];
   //cout<<"idx :"<<idx<<" "<<"k : "<<k<<" "<<" n-idx :"<<n-idx<<" <= "<<2*k+1<<endl;
   //if(v[idx])return dp[idx];
  // v[idx] = true;
   int sum = 0;
   if(k > 0){
     sum = arr[idx]+fun(idx+2 , k-1);
 }
   int op2 = fun(idx+1 , k);
   return dp[{idx , k}] = max(sum , op2);
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n;
for(int i = 0 ; i < n ; i++){
		cin>>arr[i];
}
//memset(v , false , sizeof(v));
cout<<fun(0 , n/2)<<endl;
}


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

A.sort()
b = [0]*(10**6+1)

for a in A:
  b[a] += 1
  if b[a] == 1:
    for i in range(2*a,10**6+1,a):
      b[i]+=100
print(b.count(1))

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

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[] seqS = new int[n];
      String[] line = br.readLine().split(" ");
      for (int i=0; i<n; i++)
        seqS[i] = Integer.parseInt(line[i]);

      int q = Integer.parseInt(br.readLine());
      int[] seqT = new int[q];
      line = br.readLine().split(" ");
      for(int i=0; i<q; i++)
        seqT[i] = Integer.parseInt(line[i]);
      
      int cnt=0;
      for (int ref : seqT) {
        if( isExistSeachByBinary(seqS, ref) )
          cnt++;
      }

      System.out.println(cnt);
    }
  }

  static boolean isExistSeachByBinary(int[] tar, int ref) {
    int left = 0;
    int right= tar.length;
    int mid;
    while( left < right ) {
      mid  = (left + right) / 2;
      if( tar[mid] == ref ) return true;
      else if( tar[mid] > ref ) right = mid;
      else left = mid + 1;
    }

    return false;
  }
}


Measured memory_bytes: 51580
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int ans = 0;
	int n;
	cin >> n;
	while (n--)
	{
		int l, r;
		cin >> l >> r;
		ans += r - l + 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    // input from txt （提出時にこの箇所は削除すること）
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
    
    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    /////////////////////
    // Write code below /
    /////////////////////

    int A,B;
    string op;
    cin>>A>>op>>B;
    if(op=="+"){
        cout<<A+B<<endl;
    }
    else if(op=="-"){
        cout<<A-B<<endl;
    }
    
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n,a[100]; cin>>n;
	rep(i,n) cin>>a[i];

	int sum=accumulate(a,a+n,0);
	int ans=0;
	rep(i,n) if(abs(n*a[i]-sum)<abs(n*a[ans]-sum)) ans=i;
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin>>n;
  int cnt=0;
  while(1){
    if(n==2||n==3){
      cout<<cnt+1<<endl;
      break;
    }
    if(n%3==0)n=n/3;
    else n=(n/3)+1;
    cnt++;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5+5,mod=1e9+7;
vector<ll> adj[N];
ll n,dp[N][2];
void dfs(ll node,ll pr){
    dp[node][0]=dp[node][1]=1;
    for(auto &v:adj[node]){
        if(v==pr)continue;
        dfs(v,node);
        dp[node][0]*=(dp[v][0]+dp[v][1])%mod;
        dp[node][0]%=mod;

        dp[node][1]*=dp[v][0];
        dp[node][1]%=mod;
    }
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n;
    for(ll i=0,u,v;i<n-1;i++)cin>>u>>v,adj[u].push_back(v),adj[v].push_back(u);
    dfs(1,1);
    cout<<(dp[1][0]+dp[1][1])%mod;
}

Measured memory_bytes: 12800
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int[][] map = new int[n][2];
			for (int i = 0; i < n; i++) {
				int sum = 0;
				int num = scanner.nextInt();
				for (int j = 0; j < 4; j++) {
					sum += scanner.nextInt() * 60;
					sum += scanner.nextInt();
				}
				map[i][0] = num;
				map[i][1] = sum;

			}
			Arrays.sort(map, new Comparator<int[]>() {
				@Override
				public int compare(int[] a, int[] b) {
					return a[1] - b[1];
				}
			});
			System.out.println(map[0][0]);
			System.out.println(map[1][0]);
			System.out.println(map[map.length - 2][0]);
		}
	}
}

Measured memory_bytes: 72536
import sys

n = int(sys.stdin.buffer.readline())
z, w = [0]*n, [0]*n
for i, a in enumerate(sys.stdin.buffer.readlines()):
    x, y = map(int, a.split())
    z[i] = x+y
    w[i] = x-y
print(max(abs(max(z)-min(z)), abs(max(w)-min(w))))


Measured memory_bytes: 38948
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
typedef pair<P, int> T;
char table[1000][1000];
char done[1000][1000];
int H,W,N;
vector<P> cur;
vector<P> nex;
T search(T s, char goal)
{
	cur.clear();
	int dist=s.second;
	cur.push_back(s.first);
	int dx[4]={-1,0,0,1};
	int dy[4]={0,-1,1,0};
	while(true){
		nex.clear();
		dist++;
		for(int i=0;i<cur.size();i++){
			int x=cur[i].first;
			int y=cur[i].second;
			for(int j=0;j<4;j++){
				int xx=x+dx[j];
				int yy=y+dy[j];
				if(0<=xx&&xx<H&&
				   0<=yy&&yy<W&&
				   done[xx][yy]!=goal){
					done[xx][yy]=goal;
					if(table[xx][yy]=='X')
					{
					}
					else if(table[xx][yy]==goal){
						return T(P(xx,yy), dist);
					}
					else
					{
						nex.push_back(P(xx,yy));
					}
				}
			}
		}
		nex.swap(cur);
	}
}
int main() {
	cur.reserve(1000*1000);
	nex.reserve(1000*1000);
	//cin >> H >> W >> N;
	scanf("%d %d %d", &H, &W, &N);
	T s;
	for(int i=0;i<H;i++){
		scanf("%s", table[i]);
		for(int j=0;j<W;j++){
			if(table[i][j]=='S'){
				s=T(P(i,j),0);
			}
		}
	}
	for(int i=0;i<N;i++){
		s=search(s,'0'+i+1);
	}
	printf("%d\n", s.second);
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N, W;
    cin >> N >> W;
    vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
    rep(i, N) {
        ll w, v;
        cin >> w >> v;
        rep(j, W + 1) {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if (j + w <= W) {
                dp[i + 1][j + w] = max(dp[i + 1][j + w], dp[i][j] + v);
            }
        }
    }
    cout << dp[N][W] << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 83136
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<cstdio>
#include<algorithm>
using namespace std;

#define LL long long

inline LL read(){
	LL x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const LL INF=9999999;
const LL MAXN=100010;

LL N; LL a[MAXN+1];
LL c[MAXN*3+1];

inline LL lowbit(LL x){
	return x&(-x);
}
inline void Add(LL k,LL x){
	while(k<=MAXN*2) c[k]+=x,k+=lowbit(k);
	return ;
}
inline LL Query(LL k){
	LL res=0;
	while(k) res+=c[k],k-=lowbit(k);
	return res;
} LL s[MAXN+1],ans,M;
inline bool check(LL x){
	for(LL i=0;i<=2*N;i++) c[i]=0; LL ret=0; Add(N,1);
	for(LL i=1;i<=N;i++){
		s[i]=s[i-1]+((a[i]>=x)?1:-1);
		ret+=Query(s[i]+N); Add(s[i]+N,1);
	}
	return ret>=M-((M>>1)+1);
} LL b[MAXN+1];

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(); LL tot; M=N*(N+1)>>1;
	for(LL i=1;i<=N;i++) b[i]=a[i]=read(); sort(b+1,b+N+1); tot=unique(b+1,b+N+1)-b-1;
	for(LL i=1;i<=N;i++) a[i]=lower_bound(b+1,b+tot+1,a[i])-b;
	LL l=1,r=tot; 
	while(l<=r){
		LL mid=(l+r)>>1; if(check(mid)) l=mid+1,ans=mid;
		else r=mid-1;
	} printf("%lld\n",b[ans]);
	return 0;
}


Measured memory_bytes: 4992
N, M = map(int, input().split())
graph = [[] for _ in range(N + 1)]
for _ in range(M):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)
ans = 0


def dfs(v, history):
    if len(history) == N:
        global ans
        ans += 1
    else:
        children = graph[v]
        for child in children:
            if child not in history:
                dfs(child, history + (child,))


def solve():
    dfs(1, (1,))
    print(ans)


if __name__ == '__main__':
    solve()


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

int main() {
    int r , D , X; 
    cin >> r >> D >> X; // 2 ≤ r ≤ 5 , 1 ≤ D ≤ 100 , D < X ≤ 200  
    for(int a = 1 ; a <= 10 ; a++){
        int x = r*X - D;
        cout << x << endl;
        X = x;
    }
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

// 逆元のmod MOD
ll rev_mod(ll num){
	ll pow_num = MOD - 2;
	ll mod_num = MOD;
	ll pow_cur = num;
	ll ret = 1;
	while(pow_num > 0){
		if(pow_num % 2 == 1){
			ret *= pow_cur;
			ret %= mod_num;
		}
		pow_cur *= pow_cur;
		pow_cur %= mod_num;
		pow_num /= 2;
	}
	return ret;
}

int main(){
    int h, n;
    cin >> h >> n;
	int sum = 0;
	rep(i, n){
		int a;
		cin >> a;
		sum += a;
	}
	if(sum >= h){
    	cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int a[3][3];

void bw(string str,int n){
  for(int i=0;i<3;i++){
    if(str[i] == 'b') a[n][i] = 1;
    else if(str[i] == 'w') a[n][i] = 2;
    else if(str[i] == '+') a[n][i] = 0;
  }
}

int main(){
  int i,j,tate1,tate2,yoko1,yoko2,na1,na2,nan1,nan2,ans;
  string str;
  while(1){
    cin >> str;
    if(str == "0") break;
    bw(str,0);

    for(i=1;i<3;i++){
      cin >> str;
      bw(str,i);
    }

    ans = 0;
    for(i=0;i<3;i++){
     nan1 = nan2 = na1 = na2 = tate1 = yoko1 = tate2 = yoko2 = 0;
      for(j=0;j<3;j++){
	if(a[i][j] == 1) yoko1++;
	else if(a[i][j] == 2) yoko2++;
	if(a[j][i] == 1) tate1++;
	else if(a[j][i] == 2) tate2++;
	if(a[j][j] == 1) na1++;
	else if(a[j][j] == 2) na2++;
	if(a[2-j][j] == 1) nan1++;
	else if(a[2-j][j] == 2) nan2++;
      }
      if(yoko1 == 3 || tate1 == 3 || na1 == 3 || nan1 == 3){
	ans = 1;
	break;
      }
      else if(yoko2 == 3 || tate2 == 3 || na2 == 3 || nan2 == 3){
	ans = 2;
	break;
      }
    }

    if(ans == 2) cout << "w" << endl;
    else if(ans == 1) cout << "b" << endl;
    else cout << "NA" << endl;

  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
int main()
{
	SPEED;
	//fileio;
	int a, b;
	cin >> a >> b;
	cout << a*b;
	return 0;
}


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


int dp[1005][10005];
int main() {
  int N, W;
  cin >> N >> W;
  vector<int> vs, ws;
  int v, w;
  for (int i = 0; i < N; i++)
  {
    cin >> v >> w;
    vs.push_back(v);
    ws.push_back(w);
  }

  for (int i = 0; i < N; i++)
  {
    v = vs[i];
    w = ws[i];
    for (int j = 0; j < W+1; j++)
    {
      if (j-w >= 0) { 
        dp[i+1][j] = max(dp[i+1][j-w]+v, dp[i][j]);
      }
      else {
        dp[i+1][j] = dp[i][j];
      }
    }
  }
  
  cout << dp[N][W] << endl;

}


Measured memory_bytes: 7076
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#include<map>
#define MEM(var,val) memset(var,(val),sizeof(var))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define nitro   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define tc ll tes;cin>>tes;while(tes--)
#define inf 10000000000
vll taro[3000];
vll jiro[3000];
vll v;ll n;
ll jirof(ll l ,ll r);
ll tarof(ll l ,ll r);
ll jirof(ll l,ll r)
{
    if(l>=n||r<0)return inf;
    if(l==r)
        return -v[l];
        if(jiro[l][r]!=-1)
            return jiro[l][r];
        jiro[l][r]=MIN(-v[l]+tarof(l+1,r),-v[r]+tarof(l,r-1));
        return jiro[l][r];

}
ll tarof(ll l,ll r)
{
    if(l>=n||r<0)return -inf;
    if(l==r)
        return v[l];
        if(taro[l][r]!=-1)
            return taro[l][r];
        taro[l][r]=MAX(v[l]+jirof(l+1,r),v[r]+jirof(l,r-1));
        return taro[l][r];

}
int main()
{
nitro;
for(int i=0;i<3000;i++)
{
    taro[i].resize(3000,-1);
    jiro[i].resize(3000,-1);
}
cin>>n;
v.resize(n);
for(int i=0;i<n;i++)
    cin>>v[i];
cout<<tarof(0,n-1);





   }




Measured memory_bytes: 141440
#include<stdio.h>

int main()
{
	int n,k,h,b,s;
	s = 0;
	scanf("%d %d",&n,&k);
	for(h = 0;h < n;h++)
	{
		scanf("%d",&b);
		if(b >= k)
		{
			s = s + 1;
		}
	}
	printf("%d",s);
	return 0;
 } 

Measured memory_bytes: 256
#include<iostream>
long long int gcd(long long a,long long b){
  if(b==0){
    return a;
  }
  else{
    return gcd(b,a%b);
  }
}
int main(){
  long long int a,b;
  scanf("%lld %lld\n",&a,&b);
  printf("%lld\n",a/gcd(a,b)*b);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
long long n,m,x,y,cnt1,cnt2;
vector<long long> g[111111];
bool col[111111],used[111111],f;
void dfs(long long i,bool c)
{
	col[i]=c;
	used[i]=1;
	for (int j=0;j<g[i].size();j++)
	{
		int to=g[i][j];
		if (used[to])
		{
			if (col[to]==col[i]) f=1;
			continue;
		}
		dfs(to,!c);
	}
}
int main()
{
	scanf("%lld%lld",&n,&m);
	for (int i=1;i<=m;i++)
	{
		scanf("%lld%lld",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);  
	}
	dfs(1,0);
	if (f) printf("%lld\n",n*(n-1)/2-m);
	else
	{
		for (int i=1;i<=n;i++) 
		{
			if (col[i]) cnt1++;
			else cnt2++;
		}
		printf("%lld\n",cnt1*cnt2-m);
	}
	return 0;
} 

Measured memory_bytes: 7680
using System;
using System.Linq;

class Program
{
    static void Main(string[] args){
        int n = int.Parse(Console.ReadLine());
        int count = 0;
        for (int i = 0; i < n; i ++) {
            int X = int.Parse(Console.ReadLine());
            if (PrimeNumber(X) == true) count ++;
        }
        Console.WriteLine(count);
    }
    static bool PrimeNumber(int x) {
        for (int i = 2; i <= Math.Sqrt(x); i ++) {
            if (x%i==0) return false;
        }
        return true;;
    }
}


Measured memory_bytes: 17932
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const ll INF = 1000000000000000000;
const double PI = acos(-1);

int main()
{
    int n;
    int a[200000];
    cin >> n;
    rep(i, n) cin >> a[i];

    int sum = 0;
    rep(i, n) {
        sum ^= a[i];
    }
    rep(i, n) {
        int ans = sum ^ a[i];
        if (i == n - 1) cout << ans << endl;
        else cout << ans << " ";
    }
    return 0;
}

Measured memory_bytes: 4328
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const ll MOD = 1e9 + 7;
const int MAXN = 2e6 + 10;
ll fact[MAXN];
ll powd[MAXN];
ll b_pow(ll x, ll m) {
	if (m == 1LL) return x % MOD;
	if (m == 0LL) return 1LL;
	if (m % 2LL == 0LL) {
		return b_pow((x*x) % MOD, m / 2LL) % MOD;
	} else {
		return (x * b_pow((x*x) % MOD, m / 2LL)) % MOD;
	}
} 

ll inverse(ll x) {
	if (x == 0) return 1LL;
	return b_pow(x, MOD - 2) % MOD;
}
ll nCk(ll n, ll k) {
	if (n < k) return 0LL;
	return (((fact[n] % MOD) * inverse(fact[n-k]))% MOD * inverse(fact[k])) % MOD; 
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	fact[0] = 1;
	powd[0] = 1;
	for (ll i = 1; i < MAXN - 1; i++) {
		fact[i] = fact[i-1] * i;
		fact[i] %= MOD;
		powd[i] = powd[i - 1] * 25;
		powd[i] %= MOD;
	}
	
	ll n;
	cin >> n;
	string S;
	cin >> S;
	ll k = S.size();
	ll r = 0;
	n += k;
	for (int j = 0; j <= n - k; j++) {
		//db(nCk(n, j + k)*powd[n - k - j]);
		r += nCk(n, j + k)*powd[n - k - j];
		r %= MOD;
	}
	cout << r << endl;
}



Measured memory_bytes: 35480
#include <stdio.h>
 
int main() {
    int n;
    scanf("%d", &n);
    int ctr[10001] = {0};
    for (int i = 1; i <= 100; i++) {
        for (int j = 1; j <= 100; j++) {
            for (int k = 1; k <= 100; k++) {
                int temp = i * i + j * j + k * k + i * j + j * k + i * k;
                if (temp <= 10000) {
                    ctr[temp]++;
                }
            }
        }
    }
    for (int i = 1; i <= n; i++){
        printf("%d\n", ctr[i]);
    }
    return 0;
}

Measured memory_bytes: 1720
#include<stdio.h>
   
int main(){
    int i,j,n,Max,key,key2,count=1;
    int A[200001];
       
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&A[i]);
    }
     
   Max=A[2]-A[1];
 key2=A[n];
for(i=n;i>=2;i--){
	
		if(key2<=A[i]){
	for(j=i,count=1;j>1;j--){
 // if(count==1){
 if(Max<A[i]-A[j-1]){
           Max=A[i]-A[j-1];
			key=A[j-1];}
			// count++;
             
	else if(count==1){
    if(key>A[j-1]){
	if(Max<A[i]-A[j-1]){
 	Max=A[i]-A[j-1];
	key=A[j-1];}}

    	key2=A[i];
    }
          count=1;  
             
}
		}}
         
            printf("%d\n",Max);
            return 0;
        }
    

Measured memory_bytes: 1376
%cnt = ();

while(<>){
	next if($. == 1);
	chomp;
	@tmp = split(//,$_);
	@tmp = sort(@tmp);
	$word{join("",@tmp)}++;
}

$cnt = 0;
foreach $key (keys(%word)){
	if($word{$key} > 1){
		$cnt = $cnt + (($word{$key} * ($word{$key} - 1)) / 2);
	}
}

print $cnt;


Measured memory_bytes: 19072
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
	cin>>n;
for(int i=1;i<=n;i++)
{
  if((int)(i*1.08)==n)
  {
    cout<<i<<"\n";
	return 0;
  }
}
cout<<":("<<"\n";
}


Measured memory_bytes: 3672
#include "math.h"
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main(int argc, char const *argv[]) {
  int n, h;
  cin >> n >> h;
  vector<int> a;
  vector<int> b;
  int in_a, in_b;
  int a_max = 0;
  for (int i = 0; i < n; i++) {
    cin >> in_a >> in_b;
    if (a_max < in_a) {
      a_max = in_a;
    }
    a.push_back(in_a);
    b.push_back(in_b);
  }
  sort(b.begin(), b.end());
  int b_num = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (b[i] >= a_max) {
      b_num++;
      h -= b[i];
      // cout << h << endl;
      if (h <= 0) {
        // cout << "end" << endl;
        break;
      }
    } else {
      break;
    }
  }
  // cout << a_max << endl;
  // cout << h << endl;
  if (h <= 0) {
    // cout << "yes" << endl;
    cout << b_num << endl;
  } else {
    // cout << "no" << endl;
    // cout << (double)h / a_max << endl;
    int ans = h / a_max;
    if (h % a_max != 0) {
      ans++;
    }
    cout << b_num + ans << endl;
    // cout << b_num + (int)(((double)h / a_max) + 0.9) << endl;
    // cout << b_num + ceil((double)(h) / a_max) << endl;
  }
  return 0;
}

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

int main()
{
	int n, m, x;
	cin >> n >> m >> x;
	int s = 0, t = 0;
	for(auto i = 0; i < m; ++i){
		int a;
		cin >> a;
		if(a < x) ++s;
		else ++t;
	}
	cout << min(s, t) << endl;
	return 0;
}

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

using namespace std;

int mod=1e9+7;  ///A simpler way to write 1,000,000,007

int main()
{
    int n,k;
    cin >> n >> k;
    int a[n+1];
    for(int i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    int dp[n+1][k+1];
    dp[0][0]=1;
    for(int i=1;i<=k;i++)  /// Set the initial values
    {
        dp[0][i]=0;
    }
    for(int i=1;i<=n;i++)
    {
        int sums[k+1];
        sums[0]=dp[i-1][0];
        for(int j=1;j<=k;j++)
        {
            sums[j]=(sums[j-1]+dp[i-1][j])%mod;  ///Calculate the prefix sums for i-1
        }
        for(int j=0;j<=k;j++)
        {
            int tr=sums[j];  ///Sum of dp[i-1][0...j]
            int unreachable=j-a[i]-1;  ///We need to subtract the sum of the first "unreachable" elements (dp[i-1][0...unreachable])
            if(unreachable>=0)
            {
                tr=(tr-sums[unreachable]+mod)%mod;  ///Add mod to make sure that "tr-sums[unreachable]" is not negative.
            }
            dp[i][j]=tr;
        }
    }
    printf("%i\n",dp[n][k]);
    return 0;
}


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

const int maxn = (5e5 + 12);
long long fen[maxn], a[maxn], b[maxn], n, m, low, high, mid;
vector <int> v;

void add(long long idx) {
	for ( ; idx < maxn; idx += (idx & -idx))
		fen[idx]++;
}

long long get(long long idx) {
	long long ret = 0;
	for (; idx; idx -= (idx & -idx))
		ret += fen[idx];
	return ret;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		v.push_back(a[i]);
	}
	
	sort(v.begin(), v.end());
	v.resize(distance(v.begin(), unique(v.begin(), v.end())));
	m = v.size();
	
	high = m;
	while(high - low > 1) {
		mid = (high + low) >> 1;
		long long now = 0ll;
//		cout << v[mid] << '\n';
		for (int i = 0; i < n; i++) {
			if(v[mid] > a[i]) b[i] = 1ll;
			else b[i] = -1ll;
		}
		for (int i = 0; i < maxn; i++)
			fen[i] = 0;
		b[0] += n + 2;
//		cout << b[0] << ' ';
		add(n + 2);
		now = get(b[0] - 1);
		add(b[0]);
		for (int i = 1; i < n; i++) {
			b[i] += b[i - 1];
//			cout << b[i] << ' ';
			now += get(b[i] - 1);
			add(b[i]);
		}
		if (now > ((n * (n + 1) / 2) / 2))
		   high = mid;
		else
			low = mid;
//		cout << v[mid] << ' ' << now << '\n';
//		cout << '\n';
	}
	cout << v[low];
	return 0;
}


Measured memory_bytes: 11256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define maxn 1000
ll D;
ll ans=0;
ll pw10[20];
int num[20];
int num1[20];
void dfs(int l,int r,ll tmp,ll cnt,bool z){
	if(l>r){
		if(tmp==D)ans+=cnt;
		return;
	}
	if(l==r){
		if(tmp==D)ans+=10*cnt;
		return;
	}
	if(abs(tmp-D)>pw10[r+1]) return;
	int now=z?0:-9;
	for(int i=now;i<=9;++i)dfs(l+1,r-1,tmp+(pw10[r]-pw10[l])*i,z?cnt*num1[i+10]:cnt*num[i+10],0);
}
int main(){
	cin>>D;
	pw10[0]=1;
	for(int i=1;i<=19;++i)
		pw10[i]=pw10[i-1]*10LL;
	ll tmp=D;
	int cnt=0;
	for(int i=0;i<10;++i)
		for(int j=0;j<10;++j)
			num[i-j+10]++;
	for(int i=1;i<10;++i)
		for(int j=1;j<=i;++j)
			num1[i-j+10]++;
	while(tmp>0)cnt++,tmp/=10;
	for(int i=cnt-1;i<=19;++i)dfs(0,i,0,1,1);
	cout<<ans<<"\n";
	return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int main()
{
  int i = 0, n = 0;
  fscanf(stdin, "%d", &n);
  while (++i <= n) {
    int x = i;
    if (x % 3 == 0 || x % 10 == 3) {
      fprintf(stdout, " %d", i);
    }
    else {
      for (x /= 10; x > 0; x /= 10) {
        if (x % 10 == 3) {
          fprintf(stdout, " %d", i);
          break;
        }
      }
    }
  }
  fprintf(stdout, "\n");
  return 0;
}

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

int *n;
int ans=0;
int N,i;

int main(){
    //入力
	cin>>N;
	n=new int[N];
	for(int i=0; i<N; ++i){
		cin>>n[i];
	}

	sort(n,n+N);

	while(i<N){
		int cnt=0,next=n[i];
		while(i<N && n[i]==next){
			cnt++,i++;
		}
		ans+=cnt%2;
	}

	cout<<ans<<endl;
	delete[]n;
	return 0;
}

Measured memory_bytes: 640
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

int N, A, B, C;
vector<int> L;

int dfs(int i, int a, int b, int c)
{
	if (i == N)
	{
		if (a == 0 || b == 0 || c == 0) return 1000000000;

		//延ばすのも縮めるのも同じMP
		//1本だけのときにも+10してしまっているので、-30引く。
		return abs(A - a) + abs(B - b) + abs(C - c) - 30;
	}
	
	auto ans = dfs(i + 1, a, b, c);
	chmin(ans, dfs(i + 1, a + L[i], b, c) + 10);
	chmin(ans, dfs(i + 1, a, b + L[i], c) + 10);
	chmin(ans, dfs(i + 1, a, b, c + L[i]) + 10);

	return ans;
}

int main()
{	
	
	cin >> N >> A >> B >> C; 

	L.resize(N);
	rep(i, N) cin >> L[i];

	cout << dfs(0, 0, 0, 0) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm> 
#include <iostream> 
using namespace std; 
long long int N;
long long int y;
long long int a;
long long int b;
long long int r=1;
long long int T[101];
int main(){
cin>>N;
for(int i=1;i<=N;i++){
cin>>T[i];
}
for(int i=1;i<=N;i++){
for(int j=i+1;j<=N;j++){
if(T[i]>T[j]){
y=T[i];
T[i]=T[j];
T[j]=y;
}
}
}
if(T[N-1]>500000000000000000){
cout<<T[N]<<endl;
return 0;
}
for(int i=2;i<=N;i++){
a=T[i];
b=T[i-1];
r=a%b;
while(r!=0){
T[i]=T[i-1];
T[i-1]=r;
r=T[i]%T[i-1];
}
T[i]=a/T[i-1]*b;
}
cout<<T[N]<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
int t[100][100];
int u[100][100];
int W,H,ans;
bool inField(int y,int x){
  if(y<0||y>=H)return false;
  if(x<0||x>=W)return false;
  return true;
}
int dfs(int y,int x){
  int res=0;
  u[y][x]=0;
  for(int i=0;i<4;i++){
    int ny=y+dy[i];
    int nx=x+dx[i];
    if(!inField(ny,nx))continue;
    if(u[ny][nx]==0)continue;
    res=max(res,dfs(ny,nx));
  }
  u[y][x]=1;
  return res+1;
}

int calc(int y,int x){
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      u[i][j]=t[i][j];
    }
  }
  return dfs(y,x);
}

int main(){
  while(cin>>W>>H&&W&&H){
    ans=0;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin>>t[i][j];
      }
    }
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	if(t[i][j]==0)continue;
	ans=max(ans,calc(i,j));
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<ctime>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long LL;
int main(){
	int n, s, w, counter = 0;
	scanf("%d", &n);
	for(int i = 1;i <= 9;i++){
		for(int j = 0;j <= 9;j++){
			s = i * 1000 + i * 100 + i * 10 + j;
			if(s == n)
				counter++;
		}
	}
	for(int a = 0;a <= 9;a++){
		for(int b = 1;b <= 9;b++){
			w = b * 1000 + a * 100 + a * 10 + a;
			if(w == n)
				counter++;
		}
	}
	if(counter != 0)
		printf("Yes\n");
	else
		printf("No\n");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 144, task d, 2020/09/010
//ms,
/*
*/

int main(void){
  int64_t a, b, x;
  double theta1, theta2;
  double deg;
  cin >>a >>b >>x;
  
  theta1 = atan(2.0*b/a - 2.0*x/a/a/a);
  if(b-a*tan(theta1)>=0) deg=theta1*180.0/M_PI;
  else{
    theta2=atan(a*b*b/2.0/x);
    deg=theta2*180.0/M_PI;
  }

  printf("%2.15f", deg);
  return 0;
}
/*
*/


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    if(n % 2 == 0)
        cout << n / 2 << endl;
    else
        cout << (n / 2) + 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
  int a, n;
  scanf("%d",&n);
  int seq[n];
  for(int i=0;i<n;i++){
    scanf("%d",&a);
    seq[i] = a;
  }
  int count,tmp;
  int ans = 0;
  
  for(int i=0;i<n;i++){
    count=0;
    tmp=seq[i];
    while(1){
      if(tmp%2==0){
        tmp = tmp/2;
        count++;
      }
      else {
        break;
      }
    }
    if(i==0){
      ans=count;
    }
    else{
      if(count<ans)
        ans=count;
    }
  }    
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
///Mn kotr el labawy mb2t4 nawy
#include<bits/stdc++.h>

#define ll long long
using namespace std;
const int N = 2e5 + 5;
const int MOD =  998244353;
int get(string s){
  if(s == "SUN")return 0;
  if(s == "SAT")return 6;
  if(s == "FRI")return 5;
  if(s == "THU")return 4;
  if(s == "WED")return 3;
  if(s == "TUE")return 2;
  if(s == "MON")return 1;
}
int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  string s;
  cin >> s;
  cout << 7 - get(s) << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

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

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> v(N); rep(i, 0, N) { cin >> v[i]; }
	vector<int> c = { 0 };
	rep(i, 0, N - 1) {
		if (v[i] == v[i + 1]) {
			c.emplace_back(i + 1);
		}
	}
	dump(c);
	c.emplace_back(N);
	if (c.size() <= 3) {
		cout << N << endl;
	}
	else {
		int ans = 0;
		rep(i, 0, c.size() - 3) {
			chmax(ans, c[i + 3] - c[i]);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3524
#include<stdio.h>
int main(){
	int n,i,j,k,m,card[4][13];
	char r;
	for(i=0;i<4;i++){
		for(j=0;j<13;j++){
			card[i][j]=0;
		}
	}
	scanf("%d",&n);
	for(k=0;k<n*2;k++){
		scanf("%c %d",&r,&m);
		if(r=='S')card[0][m-1]=1;
		else if(r=='H')card[1][m-1]=1;
		else if(r=='C')card[2][m-1]=1;
		else if(r=='D')card[3][m-1]=1;
	}
	for(i=0;i<4;i++){
		for(j=0;j<13;j++){
			if(card[i][j]==0){
				if(i==0)printf("S %d",j+1);
				else if(i==1)printf("H %d",j+1);
				else if(i==2)printf("C %d",j+1);
				else if(i==3)printf("D %d",j+1);
				printf("\n");
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2120