akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
const ll mod=1e+9;
typedef pair<int,int> P;
#define fi first
#define se second
int main(){
ios::sync_with_stdio(false);
   cin.tie(0);
int a,b,c;
cin>>a>>b>>c;
cout<<min(a*b,c)<<endl;

}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


class SegTree:
    def __init__(self, v, op, e) -> None:
        self._n = len(v)
        self.log = (self._n - 1).bit_length()
        self.size = 1 << self.log
        self.d = [e for _ in range(2 * self.size)]
        self.op = op
        self.e = e
        for i in range(self._n):
            self.d[self.size + i] = v[i]
        for i in reversed(range(1, self.size)):
            self.__update__(i)

    @classmethod
    def init_e(cls, n: int, op, e) -> 'SegTree':
        return cls([e for _ in range(n)], op, e)

    def set(self, p: int, x) -> None:
        p += self.size
        self.d[p] = x
        for i in range(1, self.log + 1):
            self.__update__(p >> i)

    def get(self, p: int):
        return self.d[p + self.size]

    def prod(self, l: int, r: int):
        sml = self.e
        smr = self.e
        l += self.size
        r += self.size

        while l < r:
            if l & 1:
                sml = self.op(sml, self.d[l])
                l += 1
            if r & 1:
                r -= 1
                smr = self.op(self.d[r], smr)
            l >>= 1
            r >>= 1
        return self.op(sml, smr)

    def all_prod(self):
        return self.d[1]

    def max_right(self, l: int, f):
        if l == self._n:
            return self._n
        l += self.size
        sm = self.e
        while True:
            while l & 1 == 0:
                l >>= 1
            if not f(self.op(sm, self.d[l])):
                while l < self.size:
                    l <<= 1
                    if f(self.op(sm, self.d[l])):
                        sm = self.op(sm, self.d[l])
                        l += 1
                return l - self.size
            sm = self.op(sm, self.d[l])
            l += 1
            if (l & -l) == l:
                return self._n

    def min_left(self, r: int, f):
        if r == 0:
            return 0
        r += self.size
        sm = self.e
        while True:
            r -= 1
            while r > 1 and r & 1:
                r >>= 1
            if not f(self.op(self.d[r], sm)):
                while r < self.size:
                    r = (r << 1) + 1
                    if f(self.op(self.d[r], sm)):
                        sm = self.op(self.d[r], sm)
                        r -= 1
                return r + 1 - self.size
            sm = self.op(self.d[r], sm)
            if (r & -r) == r:
                return 0

    def __update__(self, k: int) -> None:
        self.d[k] = self.op(self.d[k << 1], self.d[(k << 1) + 1])


n, q = map(int, input().split())
a = list(map(int, input().split()))
seg = SegTree(a, max, -1)

for _ in range(q):
    t, x, y = map(int, input().split())
    if t == 1:
        seg.set(x - 1, y)
    elif t == 2:
        print(seg.prod(x - 1, y))
    else:
        print(seg.max_right(x - 1, lambda v: v < y) + 1)


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


public class Main {
    private static int MOD = 1000000007;


    public static void main(String[] args) throws IOException {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        String str = br.readLine();
        int n = Integer.parseInt(str);
        long total = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                total += i;
            }
        }
        System.out.println(total);
    }
}


Measured memory_bytes: 25672
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N,A,B ;
  cin >> N >> A >> B ;
  int F=A*N ;

  if (F<B){
   cout << F << endl ; 
  }
  else if (F==B){
   cout << B << endl ; 
  }
  else if (F>B){
   cout << B << endl ; 
  }
  
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back

#define N 100010
#define MOD 1000000007

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	int ans = (h) * W +  (w) * H;
	ans = H * W - ans + h * w;
	cout << ans << '\n';	
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> x(N), y(N);
  int array[N];

  for(int i = 0; i < N; i++) {
    array[i] = i;
  }
  for(int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
  }
  long double dis = 0;
  do{
    for(int i = 0; i < N - 1; i++) {
      dis += sqrt((x[array[i]] - x[array[i + 1]]) * (x[array[i]] - x[array[i + 1]]) + (y[array[i]] - y[array[i + 1]]) * (y[array[i]] - y[array[i + 1]]));
    }
  }while(next_permutation(array, array + N));
  int s = 1;
  for(int i = 1; i <= N; i++) {
    s *= i;
  }

  cout << fixed << setprecision(10) << dis / s;


 return 0;
}

Measured memory_bytes: 256
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
typedef long long ll;
const int MYINF = 1e9+7;

static int A[128];
int N, swap_count;

void swap(int i, int j) {
	int tmp;
	tmp = A[i];
	A[i] = A[j];
	A[j] = tmp;
	swap_count++;
}

void selection_sort() {
	int i, j, mini;
	for (i = 0; i < N; i++) {
		mini = i;
		for (j = i; j < N; j++) {
			if (A[j] < A[mini]) mini = j;
		}
		if (i != mini) swap(i, mini);
	}
}

int main(int argc, char **argv)
{
	int i;
	const char *sp = "";
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	selection_sort();
	for (i = 0; i < N; i++) {
		printf("%s%d", sp, A[i]);
		sp = " ";
	}
	putchar('\n');
	printf("%d\n", swap_count);
	return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	int x,n;
	cin>>x>>n;


	set<int> s;

	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		s.insert(x);
	}


	int r,l;

	for(int i=x;;i++)
	{
		if(s.count(i)==0)
		{
			r=i;
			break;
		}
	}

	for(int i=x-1;;i--)
	{
		if(s.count(i)==0)
		{
			l=i;
			break;
		}
	}


	if(abs(r-x)<abs(x-l))
	{
		cout<<r<<endl;
	}
	else
	{
		cout<<l<<endl;
	}





	return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

int main() {
  std::cout << std::fixed << std::setprecision(10);
  int N;
  string S;
  map<string, int> mp;
  map<char, int> seen1;

  cin >> N >> S;
  string tmp = "@@@";
  for(int i=0; i<N-2; ++i) {
    tmp[0] = S[i];
    if(seen1.count(S[i])) {
      continue;
    }
    seen1[S[i]]++;

    map<char, int> seen2;
    for(int j=i+1; j<N-1; ++j){
      tmp[1] = S[j];

      if(seen2.count(S[j])) {
        continue;
      }
      seen2[S[j]]++;

      map<char, int> seen3;
      for(int k=j+1; k<N; ++k) {
        tmp[2] = S[k];
        mp[tmp]++;
        seen3[S[k]]++;
        if(seen3.size() == 10) {
          break;
        }
      }
    }
  }
  cout << mp.size() << endl;

  return 0;
}


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

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

    int A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    int B[N];
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }

    int C[N - 1];
    for (int i = 0; i < N - 1; i++) {
        cin >> C[i];
    }

    int score = 0;
    int beforeDishNo = -1;
    for (int i = 0; i < N; i++) {
        score += B[A[i] - 1];
        if (A[i] - beforeDishNo == 1) {
            score += C[A[i] - 2];
        }
        beforeDishNo = A[i];
    }

    cout << score << endl;

    return 0;
}

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


signed main() {
	int H, W;
	cin >> H >> W;
	vector<vector<int>>c(10, vector<int>(10));
	rep(i, 10)rep(j, 10)cin >> c[i][j];
	rep(k, 10)rep(i, 10)rep(j, 10)c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
	int sum = 0;
	rep(i, H)rep(j, W) {
		int A;
		cin >> A;
		if (A == -1)continue;
		else sum += c[A][1];
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a,b;
	scanf("%d %d", &a, &b);
	if(a>b)
		printf("%d\n", a+a-1);
	else if(a==b)
		printf("%d\n", 2*a);
	else
		printf("%d\n", b+b-1);
}

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

int v[26];

int main(){

  string str;
  cin >> str;
  int l = str.size();

  for (int i = 0; i < l; i++){
    v[str[i] - 'a'] += 1;
  }


  if (l != 26) {
    cout << str;
    for (int i = 0; i < 26; i++){
      if (v[i] == 0){
        printf("%c\n", 'a'+i);
        return 0;
      }
    }
  } else {
    for (int i = l-1; i >= 0; i--){
      for (int j = str[i]-'a'+1; j < 26; j++){
        if (v[j] == 0) {
          str[i] = j + 'a';
          for (int k = 0; k <= i; k++){
            printf("%c", str[k]);
          }
          printf("\n");
          return 0;
        }
      }
      v[str[i]-'a'] = 0;
    }
    printf("-1\n");
    return 0;
  }

  return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x, y; cin >> x >> y;
    auto f = [&](long long a, long long b) -> long long {
        if (a <= b) return b - a;
        else return 1e16;
    };
    long long ans = f(x, y);
    ans = min(ans, f(-x, y) + 1);
    ans = min(ans, f(-x, -y) + 2);
    ans = min(ans, f(x, -y) + 1);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int dist[100100][3];

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int> > to(n);
  rep(i,m){
    int u,v;
    cin >> u >> v;
    u--; v--;
    to[u].push_back(v);
  }
  int s,t;
  cin >> s >> t;
  s--; t--;
  queue<i_i> q;
  q.push(i_i(s,0));
  rep(i,n)rep(j,3) dist[i][j]=inf;
  dist[s][0]=0;
  while(q.size()){
    int v=q.front().first;
    int r=q.front().second;
    q.pop();
    int nr=(r+1)%3;
    rep(i,to[v].size()){
      int nv=to[v][i];
      if(dist[nv][nr]==inf){
        dist[nv][nr]=dist[v][r]+1;
        q.push(i_i(nv,nr));
      }
    }
  }
  if(dist[t][0]==inf){
    cout << -1 << endl;
    return 0;
  }
  int ans=dist[t][0]/3;
  cout << ans << endl;
}

Measured memory_bytes: 9984
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


//const int mod=1000000007;
const int mod=998244353;

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}


int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r;
    cin >> n >> m;
    ll dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    vll v(n+1);
    for(int i=1; i<=n; i++){
        cin >> v[i];
    }
    for(int i=1; i<=n; i++){
        if(v[i]<=m){
            dp[i][v[i]]+=binpow(2,i-1,mod);
        }
        for(int j=0; j<=m; j++){
            dp[i][j]+=2*dp[i-1][j];
            dp[i][j]%=mod;
        }
        for(int j=v[i]; j<=m; j++){
            dp[i][j]+=dp[i-1][j-v[i]];
            dp[i][j]%=mod;
        }
    }
    cout << dp[n][m] << el;
    return 0;
}


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


int n,m,d[1003],t[1010005],ans;

int main(){
	while(1){
	scanf("%d%d",&n,&m);
	if(n + m == 0)break;
	ans = 0;
	for(int i = 1;i <= n;i++){
		scanf("%d",&d[i]);
	}

	int co = 0;

	for(int i = 0;i <= n;i++){
		for(int j = 0;j <= n;j++){
			t[co++] = d[i] + d[j];
		}
	}
	sort(t,t + co);

	for(int i = 0;i <= n;i++){
		for(int j = i;j <= n;j++){
			int tmp = d[i] + d[j];
			if(tmp > m)continue;
			int lb = 0,ub = co;
			while(ub - lb > 1){
				int mid = (ub + lb)/2;
				if(t[mid] + tmp <= m)lb = mid;
				else ub = mid;
			}
			ans = max(ans,tmp+t[lb]);
		}
	}

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


Measured memory_bytes: 5124
n=int(input())
A=list(map(int,input().split()))
ans=1
flag=True

if 0 in A:
  flag=False
  print(0)
else:
  for i in range(n):
    ans*=A[i]
    if ans>10**18:
      print(-1)
      flag=False
      break
    else:
      pass

if flag:
  print(ans)

Measured memory_bytes: 87796
A = int(input())
C = []
for i in range(A):
    B = list(map(str,input().split()))
    C.append(B)
D = input()
for i in range(A):
    if C[i][0] == D:
        F = i
E = A - F - 1
F += 1
total = 0
for i in range(F,A):
    total += int(C[i][1])
print(total)

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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
std::vector<std::string> split(const std::string &str, const char delemiter) {std::vector<std::string> res;std::stringstream ss(str);std::string buffer; while( std::getline(ss, buffer, delemiter) ) res.push_back(buffer); return res;}
int msb(int x) {return x?31-__builtin_clz(x):-1;}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    ll N,K; cin >> N >> K;
    vector<ll> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i];
    for(int i = K; i < N; ++i) {
        Yn(A[i-K]<A[i]);
    }    
    return 0;
}


Measured memory_bytes: 4792
package main

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

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

func main() {
	var n int
	fmt.Scan(&n)
	m := 100000 + 1
	a := make([]int, m)
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		s.Scan()
		v, _ := strconv.Atoi(s.Text())
		a[v]++
	}

	// a[0] + a[1]
	// a[i - 1] + a[i] + a[i + 1]
	// a[n - 2] + a[n - 1]
	ans := max(a[0]+a[1], a[m-2]+a[m-1])
	for i := 1; i < m-1; i++ {
		ans = max(ans, a[i-1]+a[i]+a[i+1])
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1920
#include<iostream>
#include<cstdio>
#include<list>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#include<cmath>
#include<set>
using namespace std;
#define LL long long
int main() 
{
	string s;
	cin>>s;
	int flag1,flag2;
	flag1=flag2=0;
	for(int i=0;i<3;i++)
	{
		if(s[i]=='A')
			flag1=1;
		if(s[i]=='B')
			flag2=1;
	}
	if(flag1&&flag2)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

}




Measured memory_bytes: 888
#include <stdio.h>
int main(){
  int n, m, a, sum = 0;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &a);
    sum += a;
  }
  if (sum > n) {
    printf("-1");
  }
  else {
    printf("%d", n-sum);
  }
  return 0;
}

Measured memory_bytes: 1700
s = input()
l = []
for x in s:
    l.append(int(x))
o = 0
for i in range(len(l)-1):
    if l[i] == l[i+1]:
        o += 1
        l[i+1] = 0 if l[i+1] == 1 else 1
    
print(o)

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

using namespace std;

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

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

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N)
  cin >> A[i];
  vector<ll> sum(N + 1);
  REP(i, N)
  sum[i] = A[i];
  REP(i, N)
  sum[i + 1] += sum[i];
  ll ans = 1ll * 1e15;
  // 区間を 0 ... div1, div1+1 ... div2, div2+1 ... div3, div3+1 ... N-1 に分割
  int div1 = 0, div3 = 2;
  for (int div2 = 1; div2 <= N - 3; ++div2)
  {
    while (div1 + 1 < div2)
    {
      ll diff1 = abs(sum[div2] - 2 * sum[div1]);
      ll diff2 = abs(sum[div2] - 2 * sum[div1 + 1]);
      if (diff1 > diff2)
        div1++;
      else
        break;
    }
    while (div3 + 1 < N - 1)
    {
      ll diff1 = abs(sum[N - 1] - 2 * sum[div3] + sum[div2]);
      ll diff2 = abs(sum[N - 1] - 2 * sum[div3 + 1] + sum[div2]);
      if (diff1 > diff2)
        div3++;
      else
        break;
    }
    ll p = sum[div1];
    ll q = sum[div2] - sum[div1];
    ll r = sum[div3] - sum[div2];
    ll s = sum[N - 1] - sum[div3];
    ll mx = max(max(p, q), max(r, s));
    ll mn = min(min(p, q), min(r, s));
    ans = min(ans, mx - mn);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
def cross_product(a,b):
  return (a.conjugate()*b).imag
try:
    while True:
        P = list(map(float,input().split()))
        a, b, c, p = [complex(P[i*2],P[i*2+1]) for i in range(4)]
        S = cross_product(p-a,p-b)
        T = cross_product(p-b,p-c)
        U = cross_product(p-c,p-a)
        if S*T > 0 and T*U >0:
            print('YES')
        else:
            print('NO')
except EOFError:
    pass



Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i,N)
  {
    cin >> a[i];
  }
  int count = 0;
  rep(i,N)
  {
    if(i%2==0)
    {
      if(a[i]%2==1)
      {
        count ++;
      }
    }
  }
  cout << count << endl;
  return 0;
}


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

int main(){
    char s[1010];
    char t[1010];

    scanf("%s", &s);
    scanf("%s", &t);

    int lent = strlen(t);
    int lens = strlen(s);
    int count=0;
    int total=1000;

    for(int i=0;i<=(lens-lent);i++){
        count = 0;
        for(int j=0;j<lent;j++){
            if(s[i+j] != t[j]){
                count++;
            } 
        }
        if(count < total ){
            total = count;
        }
    }
    cout << total << endl;
}

Measured memory_bytes: 3752
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
const int MAX = 1000+5;
int DP[MAX][MAX];
string s1,s2;
int LCS(){
	memset(DP,0,sizeof(DP));
	int l1 = s1.size(),l2 = s2.size();
	int maxl = 0;
	s1 = ' '+s1;
	s2 = ' '+s2;
	for(int i = 1;i <= l1;i++)	DP[i][0] = 0;
	for(int j = 1;j <= l2;j++)	DP[0][j] = 0;
	for(int i = 1;i <= l1;i++){
		for(int j = 1;j <= l2;j++){
			if(s1[i] == s2[j])
				DP[i][j] = DP[i-1][j-1] + 1;
			else
				DP[i][j] = max(DP[i-1][j],DP[i][j-1]);
			maxl = max(DP[i][j],maxl);
		}
	}
	return maxl;
}
int main(int argc, char const *argv[])
{
	int T;
	cin >> T;
	while(T--){
		cin >> s1 >> s2;
		cout << LCS() << endl;
	}
	return 0;
}


Measured memory_bytes: 7096
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
	LL a, b, c;
	scanf("%lld%lld%lld", &a, &b, &c);
	LL ans = 4e18;
	ans = min(ans, a*b*( (c+1)/2 - c/2) );
	ans = min(ans, a*c*( (b+1)/2 - b/2) );
	ans = min(ans, b*c*( (a+1)/2 - a/2) );
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# モジュールのインポート
import math

# 標準入力を取得
n = int(input())

# 求解処理
ans = []
t = n
while True:
    is_prime = True
    for i in range(2, int(math.sqrt(t)) + 1):
        if t % i == 0:
            ans.append(i)
            t /= i
            is_prime = False
            break
    if is_prime:
        ans.append(t)
        break
ans = map(int, ans)

# 結果出力
print(f"{n}:", " ".join(map(str, ans)))


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

#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define endl '\n'
// #define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, a, b;

int32_t main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	cin >> n >> a >> b;
	cout << min(n*a, b) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<sstream>

using namespace std;

const int MAX = 1010;
bool fail[MAX];

bool isOK(const string& s, int n){
  if(n % 15 == 0) return s == "FizzBuzz";
  if(n % 5 == 0) return s == "Buzz";
  if(n % 3 == 0) return s == "Fizz";

  stringstream ss(s);
  int a;
  ss >> a;
  return a == n;
}

int main(){

  int m,n;
  while(cin >> m >> n && m+n){
    memset(fail,false,sizeof(fail));
    fail[0] = true;

    int rem = m;
    int player = 1;
    for(int i = 1; i <= n; i++){
      string s;
      cin >> s;
      if(rem == 1) continue;
      while(fail[player]) player = (player+1)%(m+1);
      if(!isOK(s,i)){
	fail[player] = true;
	rem--;
      }
       player = (player+1)%(m+1);
    }

    bool f = false;

    for(int i = 1; i <= m; i++){
      if(fail[i]) continue;
      if(f) cout << " ";
      cout << i;
      f = true;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1228
N, M, C = map(int, input().split())
 
B = list(map(int, input().split()))
 
ans = 0
 
src = []

for i in range(N):
  src.append(list(map(int, input().split()))) 
  
for i in range(N):
  d = C
  for n in range(M):
    d += src[i][n]*B[n]
  if (d > 0):
    ans+= 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <set>

using namespace std;

typedef set<string> ss;

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

    int n;
    cin >> n;

    ss s;
    while (n--) {
        string t;
        cin >> t;
        s.insert(t);
    }

    cout << s.size() << endl;

    return 0;
}


Measured memory_bytes: 19236
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	while(true) {
		int x, y, s;
		cin>>x>>y>>s;
		ll ans = 0;
		if(x==0&&y==0&&s==0) return 0;
		else {
			vector<int> dp(s);
			for(int i = 1; i < s; ++i) {
				if(i * (100 + x) / 100 < s) {
					dp[i * (100 + x) / 100] = i;
				}
			}
			for(int i = 1; i < s; ++i) {
				ans = max(ans, (ll)dp[i] * (100 + y) / 100 + dp[s - i] * (100 + y) / 100);
			}
		}
		cout<<ans<<endl;
	}
}

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

signed main(){
  int X,N;
  cin>>X>>N;
  if(N==0){
    cout<<X<<endl;
    return 0;
  }
  vector<int> A(N);
  rep(i,N)cin>>A[i];
  sort(begin(A),end(A));
  int num=0;
  rep(i,100){
    if(X==A[i])num=i;
  }
  int ans=0;
  rep(i,100){
    int uans=1000,dans=1000;
    if((A[num+i])!=X+i){
      uans=X+i;
    }
    if((A[num-i])!=X-i){
      dans=X-i;
    }
    if(uans!=1000||dans!=1000){
      ans=min(uans,dans);
      break;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define dcout cout << fixed << setprecision(15)
#define rep(i, a) for(int i = 0; i < a; i++)
#define arep(i, x) for(auto i : x)
#define all(v) v.begin(), v.end()
#define int long long
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
using namespace std;
signed main() {
    string s;
    cin >> s;
    int a = 0;
    int b = 0;
    rep(i, s.size()) {
        if(s[i] == '0')
            a++;
        else
            b++;
    }
    cout << min(a, b) * 2;

    return 0;
}

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

string a,b,c;
long al,bl,cl;
void aa(void);
void bb(void);
void cc(void);

void aa(){
    if(al==a.length()){
        cout<<"A";
        return;
    }
    if(a.at(al)=='a') {
        al++;
        aa();
    }
    else if(a.at(al)=='b') {
        al++;
        bb();
        
    }
    else if(a.at(al)=='c'){  // 'c' 일 경우
        al++;
        cc();
    }
}
void bb(){
    if(bl==b.length()){
        cout<<"B";
        return;
    }
    if(b.at(bl)=='a') {
        bl++;
        aa();
    }
    else if(b.at(bl)=='b') {
        bl++;
        bb();
        
    }
    else if(b.at(bl)=='c'){  // 'c' 일 경우
        bl++;
        cc();
    }
}
void cc(){
    if(cl==c.length()){
        cout<<"C";
        return;
    }
    if(c.at(cl)=='a') {
        cl++;
        aa();
    }
    else if(c.at(cl)=='b') {
        cl++;
        bb();
        
    }
    else if(c.at(cl)=='c'){  // 'c' 일 경우
        cl++;
        cc();
    }
}

int main(){
    cin>>a>>b>>c;
    aa();
    
    return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  string s;
  cin >> n >> s;
  if(n < 3200) cout << "red" << endl;
  else cout << s << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
N, C = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
mod = 10**9+7

acc = [[0] for _ in range(401)]
for i in range(401):
    for j in range(1, 401):
        acc[i].append(((acc[i][-1] + pow(j, i, mod)) % mod))

dp = [[0 for _ in range(C+1)] for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
    for candy_cur in range(C+1):
        for candy_plus in range(C - candy_cur+1):
            dp[i+1][candy_cur + candy_plus] = (dp[i+1][candy_cur + candy_plus] + (dp[i][candy_cur]\
                                               * ((acc[candy_plus][B[i]] - acc[candy_plus][A[i]-1])%mod)%mod)) % mod

print(dp[-1][C])


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

class AGC002
{
    static void Main(string[] args) {
        var spl = Console.ReadLine().Split();
        long N = long.Parse(spl[0]);
        long M = long.Parse(spl[1]);
        var boxes = Enumerable.Range(0, (int)N).Select(_ => new Tuple(1, false)).ToArray();
        boxes[0].redVisited = true;
        for(int mm = 0; mm < M; mm++) {
            spl = Console.ReadLine().Split();
            long x = long.Parse(spl[0])-1;
            long y = long.Parse(spl[1])-1;
            boxes[x].count--;
            boxes[y].count++;
            if (boxes[x].redVisited) boxes[y].redVisited = true;
            if (boxes[x].count==0) boxes[x].redVisited = false;
        }
        Console.WriteLine(boxes.Count(box => box.count != 0 && box.redVisited));
    }
    private class Tuple
    {
        public long count;
        public bool redVisited;
        public Tuple(long a, bool rv) {
            count = a;
            redVisited = rv;
        }
    }
}

Measured memory_bytes: 12844
from collections import defaultdict
n = int(input())
h = 'MARCH'
d = [0] * 5
for _ in range(n):
    s = input()
    if s[0] in h:
        d[h.find(s[0])] += 1

ans = 0
for i in range(5):
    for j in range(i, 5):
        if i == j:
            continue
        for k in range(j, 5):
            if i == k or j == k:
                continue
            ans += d[i] * d[j] * d[k]
print(ans)


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

vector<vector<int> >vec;
vector<int>v;
int n,m,l,d,cur,dep;
char b;

void go(){
    cur=m,dep=0;
    while(dep<d){
        for(int i=0;i<vec[dep].size();i++){
            if(vec[dep][i]==cur){
                cur=vec[dep][i]+1;
                break;
            }
            if(vec[dep][i]+1==cur){
                cur=vec[dep][i];
                break;
            }
        }
        dep++;
    }
}

int main(){
    while(cin>>n,n){
        vec.clear();
        cin>>m>>l>>d;
        for(int i=0;i<d;i++){
            vec.push_back(v);
            for(int j=1;j<n;j++){
                cin>>b;
                if(b=='1')
                    vec[i].push_back(j);
            }
        }
        go();
        if(cur==l){
            cout<<0<<endl;
            goto ne;
        }
        for(int j=0;j<d;j++){
            for(int i=1;i<n;i++){
                if(binary_search(vec[j].begin(),vec[j].end(),i-1)||binary_search(vec[j].begin(),vec[j].end(),i)||binary_search(vec[j].begin(),vec[j].end(),i+1))continue;
                vec[j].push_back(i);
                go();
                if(cur==l){
                    cout<<j+1<<" "<<i<<endl;
                    goto ne;
                }
                vec[j].pop_back();
            }
        }
        cout<<1<<endl;
    ne:;
    }
    
}

Measured memory_bytes: 1216
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    String S = sc.next();
    int wrong =0,count =0;
    char [] number = new char[10];
    char c = '0';
    for (int i = 0; i <10 ; i++){
      number[i] = c++;
    }
    if (S.charAt(A) == '-') {
      for (int i=0; i<S.length(); i++) {
        for (int j=0; j<10; j++) {
          if (S.charAt(i) == number[j]) count++;
        }
      }
    }   
    if(count == S.length() -1) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

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

long long N,M; string s,t; map<long long,long long> aku_nyerah;

long long fpb(long long a, long long b){
	if(b==0){
		return a;
	}else{
		return fpb(b,a%b);
	}
}

int main(){
	cin>>N>>M>>s>>t;
	long long len=N*M/fpb(N,M),fac=fpb(N,M); bool pos=true;
	for(long long i=0; i<N; i++){
		aku_nyerah[i*len/N]=s[i]-'a';
	}
	for(long long i=0; i<M; i++){
		if(aku_nyerah.count(i*len/M)&&aku_nyerah[i*len/M]!=(t[i]-'a'))pos=false;
	}
	if(pos){
		cout<<len<<'\n';
	}else{
		cout<<-1<<'\n';
	}
}

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


#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define F .first
#define S .second 
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll a[110000];

main(){
  ll n,k,ans=0,cnt=0;
  cin>>n;
  rep(i,0,n)cin>>a[i];
  
  rep(i,0,n){
    while(a[i]%2==0){ans++;a[i]/=2;}
  }
  cout<<ans;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> v(n),c(n);
	for(int i=0;i<n;i++){
		cin >> v.at(i);
	}
	for(int i=0;i<n;i++){
		cin >> c.at(i);
	}

	int ans=0;
	for(int i=0;i<n;i++){
		if(v.at(i)-c.at(i)>0){
			ans+=v.at(i)-c.at(i);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def readInts():
  return [int(s) for s in input().split(" ")]

def solve():
  N = readInts()[0]
  S = input()
  if N % 2 == 1:
    return 'No'

  for i in range(N // 2):
    if S[i] != S[i + ( N // 2 )]:
      return 'No'

  return 'Yes'

def main():
  print(solve())

if __name__ == "__main__":
  main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m; cin >> n >> m;
    vi L(m), R(m);
    rep(i, m) cin >> L[i] >> R[i];

    int lmax = *max_element(_all(L));
    int rmin = *min_element(_all(R));

    int res = max(0, rmin - lmax + 1);

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>

int main(int argc, const char * argv[]) {
   
    int a,b,k;
    
    
    scanf("%d %d %d",&a,&b,&k);
    
    
    int diff = b-a+1;
    
    
    if(diff >= 2*k){
        
        for(int i=0;i<k;i++) printf("%d\n",a+i);
        for(int i=0;i<k;i++) printf("%d\n",b-k+1+i);
    }else{
        for(int i=a;i<=b;i++) printf("%d\n",i);
        
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())

T,A = 0,0

for i in range(N):
    F = 0
    Ti,Ai = map(int,input().split())
    if Ti<T: F += 2
    if Ai<A: F += 1
    
    if F==3: #両方大
        KT = T//Ti if T%Ti==0 else (T//Ti)+1
        KA = A//Ai if A%Ai==0 else (A//Ai)+1
        T = Ti*max([KT,KA])
        A = Ai*max([KT,KA])
        
    elif F==2: #T側大
        K = T//Ti if T%Ti==0 else (T//Ti)+1
        T = Ti*K
        A = Ai*K
        
    elif F==1: #A側大
        K = A//Ai if A%Ai==0 else (A//Ai)+1
        T = Ti*K
        A = Ai*K
        
    else: #両方小
        T = Ti
        A = Ai
        
print(T+A)

Measured memory_bytes: 3064
using System;

class quiz
{
    public long solve(long n, long s)
    {
        long digit = 0, sum = 0;
        long num = n, ans = -1;

        if (s > n / 2 + n % 2 && s != n)
            return -1;
        
        if (s == n)
            return n + 1;

        for (int i = 2; i <= Math.Pow(n, 0.5); i++)
        {
            digit = 0;
            num = n;
            sum = 0;

            for (long j = 0; Math.Pow(i, j) <= n; j++)
            {
                digit = j;
            }

            for (long j = digit; j >= 0; j--)
            {
                sum += (long)(num / ((long)Math.Pow(i, j)));
                num -= (long)(num / ((long)Math.Pow(i, j))) * (long)Math.Pow(i, j);
            }

            if (sum == s)
                return i;
        }

        for (int i = 1; i < Math.Pow(n, 0.5); i++)
        {
            if (((s - n % i) % i == 0) && (s - n % i) / i > 0 && (s - n % i) / i <= n / i - n / (i + 1) + 1)
            {
                ans = (long)n / i - (long)(s - n % i) / i + 1;
            }
        }

        return ans;
    }

    public int[] ParseIntBySpace(string str)
    {
        int[] array = new int[str.Length];
        int lastloc = 0, spaceloc = -1;

        for (int i = 0; i < str.Length; i++)
        {
            if (str[i] == ' ')
            {
                array[lastloc++] = int.Parse(str.Substring(spaceloc + 1, i - spaceloc - 1));
                spaceloc = i;
            }
            else if (i == str.Length - 1)
            {
                array[lastloc++] = int.Parse(str.Substring(spaceloc + 1, i - spaceloc));
            }
        }

        Array.Resize(ref array, lastloc);

        return array;
    }
}

class Example
{
    static void Main()
    {
        quiz ex = new quiz();

        //while (true)
        //{
            Console.WriteLine(ex.solve(long.Parse(Console.ReadLine()), long.Parse(Console.ReadLine())));
        //}
    }
}

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

int main(){
    int ans=0,c=0,maxc=0;
    int n;
    
    cin >>n;
    int a[n];

    cin >>a[0];
    if(a[0]==1)c=1;
    
    for (int i = 1; i < n; i++){
        cin >> a[i];
        
        if(a[i]==1 && a[i-1]==a[i]){
            c++;
        }else if(a[i]==1){
            c=1;
        }else{
            c=0;
        }

        maxc=max(maxc,c);
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << maxc+1 << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>

using namespace std;

void out_ans(vector<int> ret) {
    for (int i = 0; i < ret.size(); i++) {
        if (i != 0) {
            std::cout << ' ';
        }
        std::cout << ret[i];
    }
    std::cout << std::endl;
}

void solve(long long N){
    if (N == 3) {
        std::cout << 2 << ' ' << 5 << ' ' << 63 << std::endl;
    } else {
        vector<int> ret;
        ret.push_back(2);
        ret.push_back(4);
        ret.push_back(3);
        ret.push_back(9);
        N -= 4;
        if (N==0) {
            out_ans(ret); return;
        }
        if (N%2 == 1) {
            ret.push_back(30000);
            N--;
        }
        if (N==0) {
            out_ans(ret); return;
        }
        int j = 4;
        for (int i = 0; i < 4999; i++) {
            ret.push_back((j)*2);
            ret.push_back((j+1)*2);
            j += 3;
            N -= 2;
            if (N==0) {
                out_ans(ret); return;
            }
        }
        j = 5;
        for (int i = 0; i < 2499; i++) {
            ret.push_back((j)*3);
            ret.push_back((j+2)*3);
            j += 4;
            N -= 2;
            if (N==0) {
                out_ans(ret); return;
            }
        }
        for (int i = 0; i < 4999; i++) {
            ret.push_back((i+1)*6);
            N -= 1;
            if (N==0) {
                out_ans(ret); return;
            }
        }
        ret.push_back(30000);
        out_ans(ret); return;
    }
}

int main(){	
    struct timeval start,end;
    long long span;
    gettimeofday(&start,NULL);

    long long N;
    scanf("%lld",&N);
    solve(N);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


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

int main(void) {
    string s1,s2,s3;cin>>s1>>s2>>s3;
    char S1 = s1[0] - 'a' + 'A';
    char S2 = s2[0] - 'a' + 'A';
    char S3 = s3[0] - 'a' + 'A';
    printf("%c%c%c\n",S1, S2, S3);
    return 0;
}

Measured memory_bytes: 504
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int w[] = new int[n];
            for (int i = 0; i < n; i++) {
                w[i] = Integer.parseInt(in.next());
            }

            int b = Integer.MAX_VALUE;
            for (int i = 1; i < n; i++) {
                int s1 = 0;
                int s2 = 0;
                for (int j = 0; j < i; j++) {
                    s1 += w[j];
                }
                for (int j = i; j < n; j++) {
                    s2 += w[j];
                }
                b = Math.min(b, Math.abs(s2 - s1));
            }
            out.println(b);
        }

    }
}



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

int main() {
    ll N, K; cin >> N >> K;
    vector<ll> A(N); for (int i = 0; i < N; i++) cin >> A[i];
    vector<ll> ketabit(42, 0);
    vector<ll> beki(42); beki[0] = 1;
    for (int i = 1; i < 42; i++) beki[i] = beki[i-1] * 2;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 42; j++) {
            if (A[i] & beki[j]) ketabit[j]++;
        }
    }

    ll X = 0, ans = 0;
    for (int i = 41; 0 <= i; i--) {
        if (X + beki[i] > K) {
            ans += beki[i] * ketabit[i];
        } else {
            if (2 * ketabit[i] < N) X += beki[i];
            ans += beki[i] * max(ketabit[i], N - ketabit[i]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#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()
{
    ll a, b, v, w, t;
    cin >> a >> v >> b >> w >> t;
    if (v <= w) {
        cout << "NO" << endl;
        return 0;
    }

    if (abs(a - b) <= t * (v - w)) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;
}

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

LL N,A,B;

int main(){
	
	cin >> N >> A >> B;
	if ( (B-A) & 1LL ){
		if ( B-A == 1 ){
			printf("%lld\n",min(A, N-B+1));
		} else {
			printf("%lld\n",min(A + (B-A-1)/2 , N-B+1 + (N-(A+(N-B+1)))/2));
		}
	} else {
		printf("%lld\n",(B-A)/2);
	}
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,ret=1,sub=1; cin>>n;
	for (int i=0; i<n; i++) {
		int a; cin>>a;
		ret*=3;
		if(a%2==0) sub*=2;
	}
	cout<<ret-sub<<"\n";
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def call(n):
	print '',
	for i in xrange(1, n+1):
		if check(i):
			print(i),
	print

def check(i):
	if i % 3 == 0:
		return True
	elif i % 10 == 3:
		return True
	elif i / 10 > 0:
		x = i
		x /= 10
		while (x > 0):
			if x % 10 == 3:
				return True
			else:
				x /= 10
	return False


n = int(raw_input())
call(n)

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

int main() {
  string S, T; cin >> T >> S;
  if (S==T+'a' || S==T+'b' || S==T+'c' || S==T+'d' || S==T+'e' || S==T+'f' ||
      S==T+'g' || S==T+'h' || S==T+'i' || S==T+'j' || S==T+'k' || S==T+'l' ||
      S==T+'m' || S==T+'n' || S==T+'o' || S==T+'p' || S==T+'q' || S==T+'r' ||
      S==T+'s' || S==T+'t' || S==T+'u' || S==T+'v' || S==T+'w' || S==T+'x' ||
      S==T+'y' || S==T+'z') cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3636