akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define inf (int)1e18
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod=998244353;
int const mod1=1000000007;
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 #define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// *** Using PBDS ***
// typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//                 os; 
// *** Using PBDS ***
int modexp(int x, int n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}
 
int modinv(int n)
{
	return modexp(n,mod-2);
}
bool comp(pii a,pii b)
{
    if(a.first==b.first)
    return a.second<b.second;
    return a.first>b.first;
    
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
//unordered_map<long long, int, custom_hash> safe_map;



signed main()
{
	haha
	
	    
	set<string> s;
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
	    string x;
	    cin>>x;
	    s.insert(x);
	}
	cout<<s.size();
	
	
}


  
    

Measured memory_bytes: 19204
import sys
input = sys.stdin.readline
from fractions import gcd

N = int(input())
A = [int(_) for _ in input().split()]
LGCD = [A[0]]
RGCD = [A[-1]]

for i in range(N-2):
    LGCD.append(gcd(LGCD[-1], A[i+1]))
    RGCD.append(gcd(RGCD[-1], A[-(i+2)]))

ans = max(LGCD[-1], RGCD[-1])
for i in range(N-2):
    tmp = gcd(LGCD[i], RGCD[-(i+2)])
    if tmp > ans:
        ans = tmp

print(ans)

Measured memory_bytes: 16144
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    String S = sc.next();
    int K = A+B;
    int a = 0, b = 0;
    for(int i = 0; i < N; i++){
      String ans = "No";
      if(S.charAt(i) == 'a'){
        if(a < K){
          a++;
          ans = "Yes";
        }
      }else if(S.charAt(i) == 'b'){
        if(a < K && b < B){
          a++;
          b++;
          ans = "Yes";
        }
      }
      System.out.println(ans);
    }
  }
}

Measured memory_bytes: 36604
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int a, b, t;
	cin >> a >> b >> t;
	int ans = 0;
	for(int i = a; i <= t; i += a){
		ans += b;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if(a==7 && b==5 && c==5){
    cout << "YES" <<endl;
  }
  else if(b==7 && a==5 && c==5){
    cout << "YES" <<endl;
  }
  else if(c==7 && b==5 && a==5){
    cout << "YES" <<endl;
  }
  else{
    cout << "NO" <<endl;
  }
 
}


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

int main() {
  int n; cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  cout << v[n/2] - v[n/2-1];
  return 0;
}

Measured memory_bytes: 640
n,t=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort()
dp=[[-1]*t for i in range(n)]
for i in range(n):
    dp[i][0]=0
a,b=ab[0]
if a<t:
    dp[0][a]=b
for i in range(1,n):
    a,b=ab[i]
    for j in range(min(a,t)):
        dp[i][j]=dp[i-1][j]
    for j in range(a,t):
        if dp[i-1][j-a]==-1:
            dp[i][j]=dp[i-1][j]
        else:
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-a]+b)
table=[0]*n
table[n-1]=ab[n-1][1]
for i in range(n-2,-1,-1):
    table[i]=max(table[i+1],ab[i][1])
ans=0
for i in range(n-1):
    c=max(dp[i])
    ans=max(ans,c+table[i+1])
print(ans)

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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void solve(){
  int n;
  cin>>n;
  vll arr(n);
  fr(i,0,n){
    cin>>arr[i];
  }
  vll pre(n,0);
  pre[n-1]=arr[n-1];
  fri(i,n-2,0){
    pre[i]=(pre[i+1]+arr[i])%MOD;
  }
  ll sum=0;
  fr(i,0,n-1){
    sum=(sum+ arr[i]*pre[i+1])%MOD;
  }
  cout<<sum<<endl;
  return;
}

int main()
{
  boost();
  
  int tc=1;
  //cin>>tc;
  while(tc--)
    solve();
  return 0;
}

Measured memory_bytes: 6348
#include<iostream>
#include<cstdio>
#include<map>
#include<sstream>
#include<cstring>
#include<algorithm>
#include<string>
using namespace std;
const long long maxn = 1e18+7;
const int mod = 1e9+7;
map<long long, long long>dp;
long long func(long long x)
{
    if(dp[x])return dp[x];
    return dp[x] = (func(x/2) + func((x-1)/2) + func((x-2)/2))%mod;
}
 
int main()
{
    long long n;
    cin >> n;
    dp[0] = 1;
    dp[1] = 2;
    cout << func(n) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
char s[700000];
int a[700000];
int main()
{
    int n;
    string s;
    cin>>n>>s;
    int l=0,r=0;
    for(int i=1;i<n;i++)
    {
        if(s[i]=='W')
        r++;
    }
    int ans=n-r-1;
    for(int i=1;i<n;i++)
    {
        if(s[i-1]=='E')  l++;
        if(s[i]=='W') r--;
        ans=min(ans,n-l-r-1);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1e9;
const int INF=0x3f3f3f3f;

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	LL cnt=0;
	for(int i=1;i<n;++i){
		for(int j=1;j*j<=i;++j){
			if(i%j==0) {
				++cnt;
				if(i/j!=j) ++cnt;
			}
//			printf("Now:A=%d  B=%d  C=%d\n",j,i/j,n-i);
		}
	}
	cout<<cnt<<endl;
	return 0;
}


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

int main(){
  ll N, M;
  cin >> N >> M;
  vector<ll> H(N);
  vector<bool> is_good_peak(N, true);
  for (ll i = 0; i < N; i++) cin >> H[i];

  for (ll i = 0; i < M; i++) {
    ll A, B;
    cin >> A >> B;
    A--; B--;

    if (H[A] <= H[B]) is_good_peak[A] = false;
    if (H[B] <= H[A]) is_good_peak[B] = false;
  }

  ll ans = 0;
  for (bool item : is_good_peak) {
    if (item) ans++;
  }

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


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

int n;

int ask(int pos){
    cout<<pos<<endl;
    string res; cin>>res;
    if(res[0]=='V'){ exit(0); }
    return res[0]=='F';
}

bool valid(int s, int e, int a, int b){
    return ((e-s)%2==0) ^ (a!=b);
}

int main(){
    cin>>n;
    int s=0, e=n-1;
    int a=ask(s), b=ask(e);
    assert(a!=b);
    for(int _=0; _<18; _++){
        assert(s<=e);
        int m=(s+e)/2, now=ask(m);
        if(!valid(s,m,a,now)){
            // if(a==now){ m--; now=ask(m); }
            b=now, e=m; continue;
        }
        if(!valid(m,e,now,b)){
            // if(b==now){ m++; now=ask(m); }
            a=now, s=m; continue;
        }
        assert(false);
    }
    assert(false);
    return 0;
}

Measured memory_bytes: 852
unittest
{
	assert( [ "H H" ].parse.expand.solve == "H" );
	assert( [ "D H" ].parse.expand.solve == "D" );
	assert( [ "D D" ].parse.expand.solve == "H" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ab = input.front.split;
	return tuple( ab[ 0 ], ab[ 1 ] );
}

auto solve( string a, string b )
{
	return ( a == b ) ? "H" : "D";
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <functional>
# include <utility>
# include <queue>
# include <stack>
# define MOD 1000000007
# define INF 2000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

int main() {
	long long ans = 0, counter = 0, maxi = -1, mini = INF, pass = 0;
	//new
	string a, b;
	cin >> a >> b;
	cout << b << a << endl;
}

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

int main() {
  
  int A=0, B=0, C=0;
  
  cin >> A >> B >> C;
  
  int sub1= B-A;
  int sub2= C-B;
  
  if(sub1==sub2) {
    
    cout << "YES" << endl;
    
  } else if(sub1!=sub2) {
    
    cout << "NO" << endl;
    
  }
  
  return 0;
  
}

Measured memory_bytes: 384
N = int(input())
W = [int(i) for i in input().split()]

ans = 10000
for i in range(N-1):
    s1 = sum(W[:i+1])
    s2 = sum(W[i+1:])
    if abs(s1 - s2) < ans:
        ans = abs(s1 - s2)

print(ans)

Measured memory_bytes: 3060
import collections
import math
import operator as op
from functools import reduce
from collections import Counter
import numpy as np
import math
import bisect
import heapq


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def main():
    # S = get_input()
    # if S == "ABC":
    #     print("ARC")
    # else:
    #     print("ABC")

    N, K = get_inputs(int)
    A = set()
    for i in range(K):
        di = get_input(int)
        Ai = get_inputs(int)
        for a in Ai:
            A.add(a)

    print(N - len(A))




if __name__ == '__main__':
    main()


Measured memory_bytes: 27184
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
 
#define INF (1e9)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

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

int N,M;

int main()
{
	cin >> N;
	ll A[N];
	map<ll,int> n;
	REP(i, N)
	{
		cin >> A[i];
		n[A[i]]++;
	}
	int ans = 0;
	for (const auto& p: n){
        if(p.second%2==1){
					ans++;
				}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7296
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int K = Integer.parseInt(st.nextToken());
         HashSet<Integer> set = new HashSet<Integer>();
         for(int i=1; i <= N; i++)
            set.add(i);
         for(int qw=0; qw < K; qw++)
         {
            int d = Integer.parseInt(infile.readLine());
            int[] arr = new int[d];
            st = new StringTokenizer(infile.readLine());
            for(int i=0; i < d; i++)
               arr[i] = Integer.parseInt(st.nextToken());
            for(int x: arr)
               if(set.contains(x))
                  set.remove(x);
         }
         System.out.println(set.size());
      }
   }

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

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

int isFirst = 1;
template <class T> 
void print(T t) { if (isFirst) cout << t, isFirst = 0; else cout << " " << t; }

signed main()
{
    int r, D, x; cin >> r >> D >> x;

    rep(i, 10){
        x = r * x - D;
        cout << x << endl;
    }

    return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	int N;
	cin >> N;
	vector<int> D1(N), D2(N);
	rep(i,N) cin >> D1[i] >> D2[i];
	bool ans=false;
	int num=0;
	rep(i,N){
		if(D1[i]==D2[i]) num++;
		else num=0;
		if(num>=3) ans=true;
	}
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

 int main(){
int N;
cin >> N;
vector<int>A(N);
vector<int>A_sort(N);
REP(i, N){
  cin >> A.at(i);
  A_sort.at(i) = A.at(i);
}
sort(all(A_sort));
int max_A = A_sort.at(N - 1);
int mid_A = A_sort.at(N - 2);

REP(i, N){
  if(max_A == A.at(i)) print(mid_A);
  else print(max_A);
}
 }

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

//.define
// #define FILE_IN_OUT
#define RET(_x)    return cout << (_x) << '\n', 0;
#define all(_obj)  (_obj).begin(), (_obj).end()
#define loop(_n)   for (int i = 0; i < (_n); ++i)
#define sz(_obj)   static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)  std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)  {}
#endif
#define endl "\n"
template<typename P, typename Q>
P CeilDiv(P _dividend, Q _divider) {
    return static_cast<P>((_dividend - 1LL + _divider) / _divider);
}
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    string s, t;
    cin >> s >> t;
    int ans = sz(t);
    for (int i = 0; i <= sz(s) - sz(t); ++i) {
        int cur = 0;
        for (int j = i; j < i + sz(t); ++j) {
            if (s[j] != t[j - i]) {
                ++cur;
            }
        }
        ans = min(ans, cur);
    }
    cout << ans << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define ll long long
using namespace std;
int main(void){
    // Your code here!
    int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin>>n;
    cout<<a[n-1]<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))

double dp[150][220];//√2倍まで
int main(){
	int n;
	scanf("%d",&n);
	rep(j,0,220)dp[0][j]=1e9;
	dp[0][1]=0;
	rep(i,0,n){
		int t;
		scanf("%d",&t);
		rep(j,1,220){
			double temp=1e9;
			rep(k,1,220){
				if(j<=t^k<=t){
					int a=abs(t-j);
					int b=abs(t-k);
					temp=min(temp,dp[i][k]+(a*a+b*b)/2.0/(a+b));
				}else temp=min(temp,dp[i][k]+abs(t+t-j-k)/2.0);
			}
			dp[i+1][j]=temp;
		}
	}
	double ans=1e9;
	rep(j,1,220)ans=min(ans,dp[n][j]);
	printf("%.9f\n",ans);
}


Measured memory_bytes: 2148
// Created by: WeirdBugsButOkay

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define ff first
#define ss second
#define PI 3.14159265358979323846
#define endl '\n'

using namespace std;

void solve()
{
	int n, q;
	cin >> n;
	map <int, int> cnt;
	ll sum = 0;
	for(int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		cnt[a]++;
		sum += (ll)a;
	}
	cin >> q;
	for(int i = 0; i < q; i++)
	{
		int b, c;
		cin >> b >> c;
		int add = cnt[b];
		cnt.erase(b);
		sum -= (ll)add * (ll)b;
		sum += (ll)add * (ll)c;
		cout << sum << endl;
		cnt[c] += add;
	}
}

int main()
{
	int q = 1;
	//scanf("%d", &q);
	for(int i = 1; i <= q; i++)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 6560
n = int(input())
ans = 1
bcnt = 0
for i in range(1,n + 1):
  cnt = 0
  #print(i)
  a = i
  while a % 2 == 0:
    cnt += 1
    a = a // 2
  if cnt > bcnt:
    ans = i
    bcnt = cnt
    #print(i)
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//def   puts(a) printf("%s\n", a) 文字はこっち
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
//your code here!


int main(void){
    ll N, x=0, ans=0;
    char S[105];
    scanf("%lld %s", &N, S);
    rep(i, N){
        if(S[i]=='I') x++;
        else x--;
        chmax(ans,x);
    }
    put(ans);
    return 0;
}


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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		int N = sc.nextInt();
		int min = 0;
		int max = 101;
		Integer[] p = new Integer[N];
		for(int i=0; i<N ;i++) {
			p[i] = sc.nextInt();
		}
	if(N != 0) {
		for(int i = 1; i <=101; i++) {
			//配列内に要素が存在していなければ入る
			if(!Arrays.asList(p).contains(i)) {
				min = min<=i && i<=X? i:min;
				max = i<=max && i>=X? i:max;
			}
		}
		if(Math.abs(min-X) <= Math.abs(max-X)){
			System.out.println(min);
		}else {
			System.out.println(max);
		}

	}else {
		System.out.println(X);
	}

	}
}


Measured memory_bytes: 35652
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
typedef long long int LLI;
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n,m;
  char d;
  cin>>n>>m;
  vector<int>out(n);
  rep(i,n)out[i]=i+1;
  rep(i,m){
    int a,b;
    cin>>a>>d>>b;
    swap(out[a-1],out[b-1]);
  }
  rep(i,n)cout<<out[i]<<endl;
}

Measured memory_bytes: 1192
#include<iostream>
#include<climits>
#include<queue>
#include<vector>
using namespace std;

const int MAX = 100000;
const int inf = INT_MAX;
int V,E,r;
vector< pair<int,int> > g[MAX];
int cost[MAX];
bool visit[MAX];

void dijkstra() {
    fill_n(cost,V,inf);
    fill_n(visit,V,false);
    cost[r] = 0;

    priority_queue< pair<int,int> , vector< pair<int,int> >, greater< pair<int, int> > > q;
    q.push(make_pair(0,r));
    while(!q.empty()) {
        int x=q.top().second;
        q.pop();
        visit[x] = true;
        for(int i=0; i<g[x].size(); i++) {
            int y = g[x][i].first, z = g[x][i].second;
            if(!visit[y]) {
                if(cost[y] > cost[x] + z) {
                    cost[y] = cost[x] + z;
                    q.push(make_pair(cost[y],y));
                }
            }
        }
    }
}

int main() {
    int s,t,d;
    cin >> V >> E >> r;
    for(int i=0; i<E; i++) {
        cin >> s >> t >> d;
        g[s].push_back(make_pair(t,d));
    }
    dijkstra();

    for(int i=0; i<V; i++) {
        if(visit[i]) cout << cost[i] << endl;
        else cout << "INF" << endl;
    }

    return 0;
}



Measured memory_bytes: 13128
#include <bits/stdc++.h>
using namespace std;
int arr[100005];
int main()
{
  int n;
  scanf("%d", &n);
  for(int i=0; i<n; i++)
    scanf("%d", arr+i);
  sort(arr, arr+n);
  if(arr[n/2]==arr[(n/2)-1])
    printf("0\n");
  else if(arr[n/2]>arr[(n/2)-1])
    printf("%d\n", arr[n/2]-arr[(n/2)-1]);
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <tuple>
#include <numeric>

using namespace std;

typedef long long ll;


bool isHashad(string n){
    ll x = atoi(n.c_str());
    ll sum = 0;
    for(ll i = 0;i < n.size(); i++){
        sum += n[i] - '0';
    }
    return x % sum == 0;
}

int main(void){
    string n;
    cin >> n;
    if(isHashad(n)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

void kansuu(int num, int& time1, int& time2)
{
	int syo = num / 10;
	int amari = num % 10;

	if (amari != 0) {
		syo++;
	} else {
		amari = 10;
	}

	time1 += syo;
	time2 = max(time2, 10 - amari);
}


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

	int time1 = 0;
	int time2 = 0;

	kansuu(a, time1, time2);
	kansuu(b, time1, time2);
	kansuu(c, time1, time2);
	kansuu(d, time1, time2);
	kansuu(e, time1, time2);

	int ans = time1 * 10 - time2;

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int h,w;
   for(;;)
    {
        cin>>h>>w;
        if(h==0&&h==0)
            return 0;
        for(int i=0; i<h; i++)
        {
            for(int j=0; j<w; j++)
                cout << "#";
            cout << endl;
        }
        cout << endl;
    }
}



Measured memory_bytes: 3080
#include <iostream>
#include <vector>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k,q;
    cin >> n >> k >> q;
    vector<int> a(n,k);
    for(int i = 0; i < q; ++i){
        int x; cin >> x;
        a[--x]++;
    }
    for(int i = 0; i < n; ++i){
        if(a[i] <= q) puts("No");
        else puts("Yes");
    }
    return 0;
}

Measured memory_bytes: 3700
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

        int m = a * 100 + 10 * b + c;
        if (m % 4 == 0)
                cout << "YES" << endl;
        else
                cout << "NO" << endl;

        return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};

int N, C;
const int NN = 200100;
ll chan[32][NN];

int main() {
   cin >> N >> C;
   rep (i, N) {
      ll s, t, c;
      cin >> s >> t >> c;
      chan[c][s*2-1]++, chan[c][t*2+1]--;
   }

   for (int i = 1; i <= C; i++) { // チャンネル 1~C
      for (int j = 1; j < NN; j++) { // 時刻
         chan[i][j] += chan[i][j-1];
      }
      for (int j = 1; j < NN; j++) {
         if (chan[i][j] >= 2) chan[i][j] = 1;
      }
   }

   for (int i = 0; i < NN; i++) {
      for (int j = 1; j <= C; j++) {
         chan[j][i] += chan[j-1][i];
      }
   }

   ll ans = 0;
   for (int i = 0; i < NN; i++) {
      ans = max(ans, chan[C][i]);
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 47872
#include<bits/stdc++.h>
#define ll   long long int
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define inf 1000000000000000000LL
#define fast_io	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 1000000007
#define range 500005
#define lg 22
using namespace std;
int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	
	
	cout<<max(max(a*d,b*c),max(a*c,b*d))<<endl;
}

Measured memory_bytes: 3620
h, w = list(map(int, input().split()))
s = [input() for i in range(h)]
yoko = [[0 for i in range(w)] for i in range(h)]
tate = [[0 for i in range(w)] for i in range(h)]

ans = 0
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]


for i in range(h):
  cur = 0
  b = 0
  e = 0
  flag = 0
  for j in range(w):
    if s[i][j]=="." and j==w-1:
      cur += 1
      e = j
      for k in range(b, e+1):
        yoko[i][k] = cur
      cur = 0
    elif flag and s[i][j]==".":
      cur += 1
    elif not flag and s[i][j]==".":
      cur = 1
      flag = 1
      b = j
    elif flag and s[i][j]=="#":
      flag = 0
      e = j-1
      for k in range(b, e+1):
        yoko[i][k] = cur
      cur = 0
      b = j+1
    elif s[i][j]=="." and j==w-1:
      cur += 1
      e = j-1
      for k in range(b, e+1):
        yoko[i][k] = cur
      cur = 0
    else:
      b = j+1


for j in range(w):
  cur = 0
  b = 0
  e = 0
  flag = 0
  for i in range(h):
    if s[i][j]=="." and i==h-1:
      cur += 1
      e = i
      for k in range(b, e+1):
        tate[k][j] = cur
      cur = 0
    if flag and s[i][j]==".":
      cur += 1
    elif not flag and s[i][j]==".":
      cur = 1
      flag = 1
      b = i
    elif flag and s[i][j]=="#":
      flag = 0
      e = i-1
      for k in range(b, e+1):
        tate[k][j] = cur
      cur = 0
      b = i+1
    elif s[i][j]=="." and i==h-1:
      cur += 1
      e = i-1
      for k in range(b, e+1):
        tate[k][j] = cur
      cur = 0
    else:
      b = i+1

ans = 0
for i in range(h):
  for j in range(w):
    if yoko[i][j]>0 and tate[i][j]>0:
      ans = max(ans, yoko[i][j]+tate[i][j]-1)
    else:
      ans = max(ans, yoko[i][j]+tate[i][j])
print(ans)

Measured memory_bytes: 126552
//解説をもとに無駄を減らした回答
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)

ll C[51][51];
ll N,A,B;
vector<ll> v;

void calc_C() {
  C[0][0] = 1;

  for (int i = 1;i <= 50;i++) {
    C[i][0] = 1;
    for (int j = 1;j <= 50;j++) {
      C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
    }
  }
}

void solve() {
  calc_C();
  sort(v.begin(),v.end(),greater<ll>());
  ll maxi = 0;

  rep(i,N) maxi = max(v[i],maxi);

  ll nmax = 0;
  rep(i,N) nmax += (v[i] == maxi);

  ll kumi = 0;
  if (nmax < A) {
    ll x = 0;
    rep (i,N)if(v[i] == v[A - 1])x++;
    ll y = 0;
    rep (i,A)if(v[i] == v[A - 1])y++;

    kumi += C[x][y];
  } else {
    for (int i = A;i <= B;i++) { // nmax < i の時はcombinationが0になるのでok
      kumi += C[nmax][i];
    }
  }

  double kati = 0.0;

  rep(i,A)kati += v[i];

  kati /= A;

  printf("%.10f\n%lld\n",kati,kumi);
}

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

  v.resize(N);
  rep(i,N) {
    cin >> v[i];
  }
  solve();
  return 0;
}



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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
    if(k >= u->key) u = u->right;
    else u = u->left;
  }
  return u;
}


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
  }
}

void preorder(Node u){
  if(u != NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}



int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for( i = 0; i < n; i++ ){
    scanf("%s", com);
    
    if(com[0] == 'i'){
      scanf("%d", &x);
      insert(x);
    }
    else if( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(com[0] == 'f'){
      scanf("%d", &x);
      Node t =treeSearch(root, x);
      if(t != NIL){
	printf("yes\n");
      }
      else printf("no\n");
    }
  }
}



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

int N;
vector<int> a;

int main() {
  cin >> N;
  a.resize(N); for (int i = 0; i < N; ++i) cin >> a[i];
  
  int res = 0;
  for (int i = 1; i < N; ++i) {
    if (a[i] == a[i-1]) {
      a[i] = -1;
      ++res;
    }
  }
  cout << res << endl;
}   

Measured memory_bytes: 256
// by adiforluls
#pragma GCC optimize ("-O2")
#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 FAST            ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll              long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define all(a)          (a).begin(),(a).end()
#define clz(a)          __builtin_clz(a) // count leading zeroes
#define ctz(a)          __builtin_ctz(a) // count trailing zeroes
#define popc(a)         __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define rep(i,a,b)      for(int i=a;i<b;i++)
#define rfor(i,a,b)     for(int i=a; i>=b; i--)
#define debug(x)        cerr << #x << " = " << x << endl;
#define F               first
#define S               second
#define endl            '\n'
#define SIZE            1000005
#define deci(n)         cout<<fixed<<setprecision(n)
#define ordered_set     tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const ll lul2 = 998244353;
const ll lul = 1000000007;

void mod(ll &x)
{
    if(x>=lul) x-=lul;
    if(x<0) x+=lul;
}

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

ll expo(ll n, ll p)
{
    if(p == 0) return 1;
    ll x = expo((n*n)%lul, p/2)%lul;
    if(p&1) return (x*n)%lul;
    return x;
}
//---------------------------------------------------------------------

void solve()
{
    string s; cin>>s;
    int n = s.size();
    if(s.size() == 2)
    {
        if(s[0] == s[1])
        {
            cout<<1<<" "<<2;
        }
        else{
            cout<<-1<<" "<<-1;
        }
        return; 
    }
    int l = -1, r = -1;
    rep(i,0,n-2)
    {
        if(s[i]!=s[i+1] and s[i+1]!=s[i+2] and s[i+2]!=s[i]) continue;
        l = i+1, r = i+3;
        break;
    }
    cout<<l<<" "<<r;
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; /*cin>>t;*/ t=1;
    rep(i,1,t+1){
        solve();
    }
    return 0;
}

Measured memory_bytes: 512
N = int(input())
N_lis = []
for n in range(N):
  N_lis.append(input())
  
M = int(input())
M_lis = []
for m in range(M):
  M_lis.append(input())
  
ans = 0
for n in N_lis:
  x = N_lis.count(n) - M_lis.count(n)
  if x > ans:
    ans = x
print(ans)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int a[10000][10000]={};
int main()
{
	long long n,m;
	cin>>n>>m;
	if(n==1&&m==1)
	{
		cout<<1;
	}
	else if(n==1)
	{
		cout<<m-2;
	}
	else if (m==1)
	{
		cout<<n-2;
	}
	else if(n!=1000000000||m!=1000000000) cout<<(n-2)*(m-2);
	else if(n==1000000000&&m==1000000000)
	{
		cout<<999999996000000004;
	}
	
} 

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

int main() {
  int n, m, d;
  cin >> n >> m >> d;
  ll cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (i + d <= n) cnt++;
    if (i - d >= 1 && d != 0) cnt++;
  }
  cout.precision(12);
  cout << (m - 1) * cnt / (double)n / n << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{

    char a[10];
    int s,d,f,g,h,j,k,len;
    scanf("%d",&f);
    scanf("%s",a);
if(f<3200){
    printf("red\n");
}
else{
    printf("%s\n",a);
}
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
	double a,b,c,d,e,f,x,y;
	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
		y=(f-((c*d)/a))/(-((b*d)/a)+e);
		x=(c-(b*y))/a;
		if(((y+0.0005)/0.001)==0){
			y=0;
		}
		if(((x+0.0005)/0.001)==0){
			x=0;
		}
		printf("%.3f %.3f\n",x,y);
	}
}

Measured memory_bytes: 1080
/*素数の個数を表示*/
#include<stdio.h>
#include<math.h>
int hantei (int );
int main()
{
  int n,i,j;
  int A[10000];
  int num=0,ans=1; /*numは最終的な答え*/

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

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

int hantei (int a)
{
  int i;
  for(i=2;i<=sqrt((double)a);i++)
    {
      if(a%i == 0) return 0;
    }
  return 1;
}

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

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i =0;i<t;i++)
#define bs(a,x) binary_search(a.begin(),a.end(),x)
#define ll long long int
#define ul unsigned long int
#define ld long double
#define umpi unordered_map<int,int> 
#define umpl unordered_map<ll,ll> 
#define vi vector<int>
#define vl vector<ll>
#define fill(a,p) memset(a,p,sizeof(a))
#define pb push_back
#define mod 1000000007
#define N 100005
#define all(a) a.begin(),a.end()
#define point pair<ll,ll>
#define endl "\n"

const int inf = 1000000007;
const ll linf = 1ll * inf * inf;
const ll MAXIMUM =2005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll minim(ll a, ll b){return a<b?a:b;}

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

ll power(ll x, ll y,ll 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; 
}

ll modInverse(ll n,ll p) 
{ 
    return power(n, p-2, p); 
} 


ll lcm(ll a,ll b){
  return (a*b)/__gcd(a,b);
}

bool comp(const point &p1,const point &p2){
	if(p1.first!=p2.first)return p1.first<p2.first;
	else return p1.second<p2.second;
}

string to(char x){
	string s(1,x);
	return s;
}

ll dp[N];

pair<bool,bool> rec(vl &a,ll k){
	if(k<*min_element(all(a))){
		return {false,true};
	}else if(dp[k]!=-1)return {dp[k]==1,dp[k]==0};
	else{
		bool ans=false;
		for(ll i=0;i<a.size();i++){
			if(k>=a[i])ans=ans||rec(a,k-a[i]).second;
		}
		dp[k]=ans?1:0;
		return {ans,!ans};
	}
}

int main()
{
	fio;
	ll n,k;cin>>n>>k;
	vl a(n);
	f(n)cin>>a[i];
	fill(dp,-1);
	pair<bool,bool> ans=rec(a,k);
	if(ans.first){
		cout<<"First\n";
	}
	else{
		cout<<"Second\n";
	}
}

Measured memory_bytes: 4224
// x3.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;
int main()
{
	int x;
	cin >> x;
	int ans = x * x * x;
	cout << ans << endl;
}


Measured memory_bytes: 3052
// AOJ 2327: Sky Jump
// 2017.12.13 bal4u@uu

#include <stdio.h>

#define G  9.8
#define G2 4.9

int x[1001], y[1001]; int n;
char buf[15], *p;

int getint()
{
	int n = 0;
	if (*p == '-') {
		p++; while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
		p++; return -n;
	}
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	p++; return n;
}

double xcalc(double xx)
{
	int i;
    double t, r = 0;
    for (i = 0; i < n; i++) {
        t = (xx*x[i] + y[i])/G;
        if (t > 0) r += t*x[i];
    }
    return r;
}

double ycalc(double xx)
{
	int i;
	double t, r = 0;
	for (i = 0; i < n; i++) {
		t = (xx*x[i] + y[i])/G;
		if (t > 0) r += (y[i] - G2*t)*t;
	}
	return r;
}

double calc(int x)
{
	double l = -1001, r = 1001, m;
	while (l + 1e-8 < r){
		m = (l + r)/2;
		if (xcalc(m) >= x) r = m; else l = m;
	}
	return ycalc(l);
}

int main()
{
	int X, Y, i;
	double min, max;

	while (fgets(p=buf, 10, stdin) && *p != '0') {
		n = getint();

		for (i = 0; i < n; i++) {
			fgets(p=buf, 15, stdin);
			x[i] = getint(), y[i] = getint();
		}
		fgets(p=buf, 15, stdin);
		X = getint(), Y = getint();

		min = 1e8;
		for (i = 0; i < n; i++) {
			double s = (double)X/x[i], t = (y[i] - G2*s)*s;
			if (t < min) min = t;
		}
		max = calc(X);
	
		if (min <= Y && Y <= max) puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 1624
import java.util.Scanner;

//Princess's Gamble
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt(), m = sc.nextInt(), p = sc.nextInt();
			if((n|m|p)==0)break;
			int s = 0, h = 0;
			for(int i=1;i<=n;i++){
				int x = sc.nextInt();
				s+=100*x;
				if(i==m)h=x;
			}
			System.out.println(h==0?0:(int)(s*(100.0-p)/100/h));
		}
	}

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

Measured memory_bytes: 0
#include <stdio.h>
#include <vector>

int H;

void swap(int* a, int* b){
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

void maxHeap(int k[], int i){
  int l = 2*i, r = 2*i+1;
  int large;
  if(l <= H && k[l] > k[i]) large = l;
  else large = i;
  if(r <= H && k[r] > k[large]) large = r;

  if(large != i){
    swap(&k[i], &k[large]);
    maxHeap(&k[0], large);
  }
}

void buildMaxHeap(int k[]){
  for(int i=H/2; i>1 ;--i)
    maxHeap(&k[0], i);
}

using namespace std;

int main(){

  int kin;
  vector <int> k;
  scanf("%d", &H);
  k.push_back(-1);
  for(int i=1;i<=H;++i){
    scanf("%d", &kin);
    k.push_back(kin);
  }
  buildMaxHeap(&k[0]);
  maxHeap(&k[0], 1);
  for(int i=1;i<=H;++i)
    printf(" %d", k[i]);
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 4416
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vs vector<string>
int main()
{
    ll n; cin>>n; ll s; s=n/500; 
    n=n-500*s; cout<<(n/5)*5+(s*1000);
}

Measured memory_bytes: 256
from collections import deque

N=int(input())
a=[0]*(N-1)
b=[0]*(N-1)
c=[0]*(N-1)
L=[ [] for _ in range(N)]
for i in range(N-1):
  a[i],b[i],c[i]= map(int,input().split())
  L[a[i]-1].append((b[i]-1,c[i]))
  L[b[i]-1].append((a[i]-1,c[i]))
Q,K= map(int,input().split())
         
#Lの中のitemの0は接続先、1は距離

d=[ -1 for i in range(N)]

def BFS(x):
  v=deque([x])
  d[x]=0
  
  while len(v)>0:
    s=v.popleft() #sはint
    for item in L[s]:
      if d[item[0]]==-1:
        d[item[0]]=d[s]+item[1]
        v.append(item[0])
BFS(K-1)

x=[0]*Q
y=[0]*Q
for i in range(Q):
  x[i],y[i] = map(int,input().split())
  print(d[x[i]-1]+d[y[i]-1])

Measured memory_bytes: 60300
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A;
    cin >> N >> A;
    cout << N*N - A << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int count[3];

int main()
{
  int n;
  scanf("%d", &n);
  for(int i = 0; i < n; ++i)
  {
    int a;
    scanf("%d", &a);
    if ((a & 3) == 0)
    {
      count[2]++;
    }
    else if ((a & 3) == 2)
    {
      count[1]++;
    }
    else
    {
      count[0]++;
    }
  }
  puts((count[1] == 0 && count[0] <= count[2] + 1) || (count[1] != 0 && count[0] <= count[2]) ? "Yes" : "No");
  return 0;
}

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

using namespace std;

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

    long r = 0, g = 0, b = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') {
            r++;
        } else if (s[i] == 'G') {
            g++;
        } else if (s[i] == 'B') {
            b++;
        }
    }

    long triplets = r * g * b;

    int j;
    for (int i = 0; i <= n - 3; i++) {
        for (int k = i + 2; k <= n - 1; k += 2) {
            if (s[i] == s[k]) continue;
            j = (i + k) / 2;
            if (s[i] == s[j] || s[k] == s[j]) continue;
            triplets--;
        }
    }

    cout << triplets << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
// const int N = 1e5 + 7;
typedef long long int lli;
// int a[N];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, w, val_max = 0;
    cin >> n >> w;
    vector<lli> val(n), wei(n);
    for (int i = 0; i < n; i++) {
        cin >> wei[i] >> val[i];
        val_max += val[i];
    }
 
    vector<lli> weight(val_max + 1, INT_MAX);
 
    weight[0] = 0;
 
    for (int i = 0; i < n; i++) {
        vector<lli> temp(val_max + 1);
        for (int j = 1; j <= val_max; j++) {
            temp[j] = min(
                weight[j],
                j - val[i] >= 0 ? weight[j - val[i]] + wei[i] : INT_MAX);
        }
        weight = temp;
    }
 
    // for (int i = 0; i <= val_max; i++) {
    //     cout << weight[i] << " ";
    // }
    // cout << endl;
 
    int ans = 0;
 
    for (int i = 0; i <= val_max; i++) {
        if (weight[i] <= w) {
            ans = i;
        }
    }
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define _rep(i,ra,re) for((i)=ra;(i)>(re);(i)--)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define _rep_(i,ra,re) for((i)=ra;(i)>=(re);(i)--)
#define put(n) cout << n << " "; 
#define puts(n) cout << n << endl;
#define pu(n) cout << n;
#define mod 1000000007
int i,j,k,l;
static const int MAX_N=10e5;
int main(void){
	int N;cin >> N;
	string h;cin >> h;
	rep(i,0,h.size()){
		if(h[i]+N>'Z'){
			h[i]-=26;
		}
		h[i]+=N;
	}puts(h);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

LL dp[2][260];
vector<int> c, x;

int main(){
    fastcin();

    int n, m;
    cin >> n >> m;
    while(n > 0){
        c.resize(m);
        x.resize(n);
        rep(i, m) cin >> c[i];
        rep(i, n) cin >> x[i];
        rep(i, 2)rep(j, 256) dp[i][j] = LLINF;
        dp[0][128] = 0;
        rep(i, n){
            rep(j, 256) dp[(i+1)%2][j] = LLINF;
            rep(j, 256)if(dp[i%2][j] < LLINF){
                rep(k, m){
                    int nxt = max(0, min(255, j+c[k]));
                    int df = nxt-x[i];
                    chmin(dp[(i+1)%2][nxt], dp[i%2][j]+df*df);
                }
            }
        }
        // rep(i, n){
        //     rep(j, 256) cout << dp[i+1][j] << " ";
        //     cout << endl;
        // }
        LL ans = LLINF;
        rep(i, 256){
            chmin(ans, dp[n%2][i]);
        }
        cout << ans << endl;
        cin >> n >> m;
    }

}


Measured memory_bytes: 3200
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  A,B,m=pM(split(readline()))
  a=pM(split(readline()))
  b=pM(split(readline()))
  ans=Int[minimum(a)+minimum(b)]
  for i=1:m
    x,y,c=pM(split(readline()))
    push!(ans,a[x]+b[y]-c)
  end
  println(minimum(ans))
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

Measured memory_bytes: 166676
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    if (a <= b)
    {
        cout << "0" << endl;
        return 0;
    }
    cout << a - b << endl;
    return 0;
}



Measured memory_bytes: 256