akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

#define MOD 1000000007
template<int mod>
struct ModInt{
	int x;
	ModInt():x(0){}
	ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
	ModInt &operator+=(const ModInt &p){
		if((x+=p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator-=(const ModInt &p){
		if((x+=mod-p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator*=(const ModInt &p){
		x=(int)(1LL*x*p.x%mod);
		return *this;
	}
	ModInt &operator/=(const ModInt &p){
		*this*=p.inverse();
		return *this;
	}
	ModInt &operator^=(long long p){
		ModInt res = 1;
		for (; p; p >>= 1) {
			if (p & 1) res *= *this;
			*this *= *this;
		}
		return *this = res;
	}
	ModInt operator-()const{return ModInt(-x);}
	ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
	ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
	ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
	ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
	ModInt operator^(long long p)const{return ModInt(*this)^=p;}
	bool operator==(const ModInt &p)const{return x==p.x;}
	bool operator!=(const ModInt &p)const{return x!=p.x;}
	explicit operator int() const { return x; }						   // added by QCFium
	ModInt operator=(const int p) {x = p; return ModInt(*this);} // added by QCFium
	ModInt inverse()const{
		int a=x,b=mod,u=1,v=0,t;
		while(b>0){
			t=a/b;
			a-=t*b;
			std::swap(a,b);
			u-=t*v;
			std::swap(u,v);
		}
		return ModInt(u);
	}
	friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){
		return os<<p.x;
	}
	friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){
		long long x;
		is>>x;
		a=ModInt<mod>(x);
		return (is);
	}
};
typedef ModInt<MOD> mint;

mint nCx(int n, int x) {
    mint res = 1;
    for (int i = n; i > n-x; --i)
        res *= i;
    for (int i = x; i > 0; --i)
        res /= i;
    return res;
}

int main () {
    int n, a, b;
    cin >> n >> a >> b;
    mint res = (mint(2) ^ n) - 1;
    res -= nCx(n,a);
    res -= nCx(n,b); 
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
typedef long long ll;
typedef double dd;
#define pb push_back
#define mp make_pair
#define endl "\n"
#define M 1000000007
#define pi acos(-1)
/*ll power(ll a,ll b)
{
    ll res = 1;
    while(b > 0)
    {
        if(b & 1)
            res = (res*a)%M;
        a = (a*a)%M;
        b = b >> 1;
    }
    return res;
}*/
/*ll modinv(ll a)
{
   return power(a,M - 2); 
}*/
/*vector<ll> primes(ll n)
{
    bool *sieve = new bool[n + 1];
    ll i,j;
    vector<ll> v;
    for(i = 3; i <= n; i+=2)
        sieve[i] = true;
    sieve[2] = true;
    for(i = 3; i*i <= n; i+=2)
    {
        if(sieve[i])
            for(j = i*i; j <= n; j+=i)
                sieve[j] = false;
    }
    if(n >= 2)
    {
        v.pb(2);
        for(i = 3; i <= n; i+=2)
        {
            if(sieve[i])
                v.pb(i);
        }
    }
    return v;
}*/

/*class graph{
public:
    vector<ll> *g;
    ll n;
    graph(ll v)
    {
        n = v + 1;
        g = new vector<ll> [n];
    }
    void addegde(ll f,ll s)
    {
        g[f].pb(s);
        g[s].pb(f);
    }
    void dfs(bool *visited,ll sv)
    {
        visited[sv] = true;
        for(auto x: g[sv])
        {
            if(!visited[x])
            {
                dfs(visited,x);
            }
        }
    }
    void bfs(ll sv){
       queue<ll> q;
       bool visited[n] = {};
       q.push(sv);
       visited[sv] = true;
       while(!q.empty())
       {
           ll node = q.front();
           q.pop();
           for(auto x : g[node])
           {
               if(!visited[x])
               {
                   visited[x] = true;
                   q.push(x);
               }
           }
       }
    }
};*/
int main()
{
    fast;
 
    ll i,j,t,c = 0,k;
    ll l,r;
    cin >> l >> r;
    ll c1 = l/2019,c2 = r / 2019;
    if(c2 - c1 >= 1)
      cout<<"0"<<endl;
    else
    {
      ll mn = LONG_LONG_MAX;
      for(i = l; i <= r; i++)
      {
        for(j = i + 1; j <= r; j++)
          mn = min(mn,(i*j)%2019);
      }
      cout<<mn<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int N,M;
		
	while(cin>>N>>M,N||M){
		int Expected[11]={0};
		int sum=0;
		int p,d;
		
		for(int i=0;i<N;i++){
			cin>>d>>p;
			Expected[p]+=d;
		}
		
		for(int i=10;i>=0;i--){
			if(Expected[i]<=M){
				M-=Expected[i];
				Expected[i]=0;
			}
			else{
				Expected[i]-=M;
				M=0;
			}
			sum+=Expected[i]*i;
		}
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int main(){
  int k, s;cin>>k>>s;
  int ans=0;
  for(int x=0;x<=k;x++){
    if(s-x<0)break;
    else{
      for(int y=0;y<=k;y++){
        if(s-x-y<0)break;
        else if(s-x-y<=k)ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

using tl = tuple<ll, ll, ll>;

ll n, m, q;
vvl query;

ll dfs(vl ns, ll v) {
    if (ns.size() == n) {
        ll res = 0;
        rep(i, q) {
            ll a = query[i][0];
            ll b = query[i][1];
            ll c = query[i][2];
            ll d = query[i][3];
            if (ns[b] - ns[a] == c) res += d;
        }
        return res;
    }

    ll res = 0;
    for (int i = v; i < m; ++i) {
        ns.push_back(i);
        chmax(res, dfs(ns, i));
        ns.pop_back();
    }
    return res;
}

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

    cin>>n>>m>>q;
    rep(i, q) {
        ll a, b, c, d;
        cin>>a>>b>>c>>d; a--; b--;
        vl temp {a, b, c, d};
        query.push_back(temp);
    }
    vl v;
    cout<<dfs(v, 0)<<endl;
}

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


int main(){
  int x,y;
  cin >> x >> y;
  int a,b,c;
  cin >> a >> b >> c;
  vector<int> p(a),q(b),r(c);
  vector<int> d;
  for(int i=0;i<a;++i){
    cin >> p[i];
  }
  for(int i=0;i<b;++i){
    cin >> q[i];
  }
  for(int i=0;i<c;++i){
    cin >> r[i];
    d.push_back(r[i]);
  }
  sort(p.rbegin(),p.rend());
  sort(q.rbegin(),q.rend());
  for(int i=0;i<x;++i){
    d.push_back(p[i]);
  }
  for(int i=0;i<y;++i){
    d.push_back(q[i]);
  }
  sort(d.rbegin(),d.rend());
  long long ans=0;
  for(int i=0;i<x+y;++i){
    ans+=d[i];
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    ll a, b;
    cin >> a >> b;
    vector<ll> x(n);
    for(int i=0; i<n; i++){
        cin >> x[i];
    }

    ll ans = 0;
    for(int i=1; i<n; i++){
        ll tmp = x[i] - x[i-1];
        if(tmp * a > b){
            ans += b;
        }else{
            ans += tmp*a;
        }
    }

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

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)

void printVec(std::vector<int> &vec) {
//    std::cout << "";
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        std::cout << *it << " ";
    }
    cout << '\n';
}

void printVec1(std::vector<string> &vec) {
//    std::cout << "";
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        std::cout << *it << " ";
    }
    cout << '\n';
}

void printVec2(std::vector<Int> &vec) {
//    std::cout << "";
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        std::cout << *it << " ";
    }
    cout << '\n';
}

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;
    //a*bは64bit integer overflow
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

int n;
int a;
int x[52];
bool dfs(int i,int sum,int cnt){
    if(i==n) return a==(sum/cnt);
    if(dfs(i+1,sum,cnt))return true;
    if(dfs(i+1,sum+x[i],cnt+1))return true;
    return false;
}

int cnt=0;
int main() {
    IOS;
    //prec;
    //std::ifstream in("01-04.txt");
    //std::cin.rdbuf(in.rdbuf());
    string s;cin>>s;
    cout<<s.substr(0,s.size()-8);


    cout << endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


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

 
using namespace std;
int main()
{
    ll n, temp;
    cin>>n;
    ll j=1,ans=0;
    for(int i=1;i<=n;i++)
    {
        cin>>temp;
        if(temp==j)
        {   j++;
            ans++;
        }
    }
    if(ans==0)
        cout<<"-1\n";
    else
        cout<<n-ans<<"\n";
    
}

Measured memory_bytes: 3608
#include <stdio.h>
 
int main(){
    int m, d;
    int  days[11] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30};
    char day[7][10] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
    
    while(scanf("%d %d", &m, &d), m != 0){
        while(--m > 0) d += days[m - 1];
        
        printf("%s\n", day[(d + 2) % 7]);
    }
 
    return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

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

	long long ans = 0;
	for (int i = 1; i < N; i++) {
		if (t[i] - t[i-1] <= T) {
			ans += t[i] - t[i - 1];
		} else {
			ans += T;
		}
	}
	ans += T;

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


Measured memory_bytes: 1024
s = input()
judge = True
alphabet_1 = "ABCDEFGHIJKMLNOPQRSTUVWXYZ"
alphabet_2 = "ABDEFGHIJKMLNOPQRSTUVWXYZ"
count = 0
if s[0] != "A":
    judge = False
for i in range(1,len(s)):
    if i >1 and i<=len(s)-2:
        if s[i] == "C" : count+=1
        for j in alphabet_2:
            if j == s[i] : 
                judge=False
                break
    else:
        for j in alphabet_1:
            if j == s[i]:
                judge=False
                break
if count !=1 : judge = False
print("AC") if judge else print("WA")

Measured memory_bytes: 3064
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> vll;
typedef deque<ll> dqll;

#define MOD 1000000007

int main() {
  ll N, M;

  cin >> N >> M;

  ll ans = 0;
  if (2 * N < M) {
    ans += N;
    M -= 2 * N;
    ans += M / 4;
  } else {
    ans += M / 2;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define pb push_back
#define ms(a, x) memset(a, x, sizeof(a))
#define forn(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i) 
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int mod = 1e9;
const int N = 3e3+10;
/*=======================================================================*/

char s[N], t[N];
int dp[N][N];
// bool pd = 0;
// string str [N][N];

int main() {
   scanf("%s",s);
   scanf("%s",t);
   int n = strlen(s), m = strlen(t);
   for(int i = n-1; i >= 0; --i) {
      for(int j = m-1; j >= 0; --j) {
         if(s[i] == t[j]) {
            dp[i][j] = dp[i+1][j+1] + 1;
         } else {
            dp[i][j] = max(dp[i+1][j], dp[i][j+1]);
         }
      }
   }

   for(int i = 0, j = 0; i < n && j < m; ) {
      if(s[i] == t[j]) {
         cout << s[i];
         // pd = 1;
         i++, j++;
      } 
      else if(dp[i][j] == dp[i+1][j]) i++;
      else j++; 
   }
   // if(!pd) printf("The answer is (an empty string).");
   puts("");
   // cout << str[n-1][m-1] << endl;
   return 0;
}

Measured memory_bytes: 35584
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
using namespace std;
const int N=105;
#define rg register int
int a[N*N],b[N*N],n,p,tot;
int main()
{
    scanf("%d",&n);
    if(n%2==0)p=n+1;
    else p=n;
    for(rg i=1;i<=n;i++)
        for(rg j=i+1;j<=n;j++)
            if(i+j!=p)a[++tot]=i,b[tot]=j;
    printf("%d\n",tot);
    for(rg i=1;i<=tot;i++)
        printf("%d %d\n",a[i],b[i]);
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
 int n,m,p,x,i,a=0;
 scanf("%d",&n);
 int t[n];
 for(i=0;i<n;i++){
  scanf("%d",&t[i]);
  a+=t[i];
 }
 scanf("%d",&m);
 for(i=0;i<m;i++){
  scanf("%d%d",&p,&x);
  printf("%d\n",a+x-t[p-1]);
 }
 return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();
		int C = stdIn.nextInt();
		
		System.out.println(C + " " + A + " " + B);
	}
}

Measured memory_bytes: 23764
/*input
55
*/
#include<bits/stdc++.h>
using namespace std;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int fast_ex(int a,int n,int m){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= fast_ex(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

bool isprime(int n){
   for(int i = 2;i*i <= n;i++){
       if(n%i == 0)return 0;
   }
   return 1;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  int n;
  cin >> n;
  int i = 6;
  while(n){
    if(isprime(i)){
      cout << i << " ";
      n--;
    }
    i+=5;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        String  str = sc.next();
        String ans = "";
        int a = Character.getNumericValue(str.charAt(0));
        int b = Character.getNumericValue(str.charAt(1));
        int c = Character.getNumericValue(str.charAt(2));
        int d = Character.getNumericValue(str.charAt(3));
        
        if(a+b+c+d==7){
            ans = ""+a+"+"+b+"+"+c+"+"+d+"=7";
        }else if(a+b+c-d==7){
            ans = ""+a+"+"+b+"+"+c+"-"+d+"=7";
        }else if(a+b-c+d==7){
            ans = ""+a+"+"+b+"-"+c+"+"+d+"=7";
        }else if(a+b-c-d==7){
            ans = ""+a+"+"+b+"-"+c+"-"+d+"=7";
        }else if(a-b+c+d==7){
            ans = ""+a+"-"+b+"+"+c+"+"+d+"=7";
        }else if(a-b+c-d==7){
            ans = ""+a+"-"+b+"+"+c+"-"+d+"=7";
        }else if(a-b-c+d==7){
            ans = ""+a+"-"+b+"-"+c+"+"+d+"=7";
        }else if(a-b-c-d==7){
            ans = ""+a+"-"+b+"-"+c+"-"+d+"=7";
        }
        
        
		System.out.println(ans);
    }
}


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

int main(){
    int x, y;
    cin >> x >> y;
    int ret = 0;
    if(x == 3)  ret += 100000;
    if(x == 2)  ret += 200000;
    if(x == 1)  ret += 300000;
    if(y == 3)  ret += 100000;
    if(y == 2)  ret += 200000;
    if(y == 1)  ret += 300000;
    if(x+y == 2)    ret += 400000;
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
h,w,k = map(int,input().split())
dp = [[0]*w for i in range(h+1)]
mod = 1000000007
dp[0][k-1] = 1
a = [1,1,2,3,5,8,13,21]
for i in range(h):
  for j in range(w):
    if j != 0:
      if j == w-1 or j == 1:
        dp[i+1][j] += dp[i][j-1]*(a[w-2])%mod
      else:
        dp[i+1][j] += dp[i][j-1]*(a[j-1]*a[w-1-j])%mod
    if j != w-1:
      if j == 0 or j == w-2:
        dp[i+1][j] += dp[i][j+1]*(a[w-2])%mod
      else:
        dp[i+1][j] += dp[i][j+1]*(a[j]*a[w-2-j])%mod
    if j == 0 or j == w-1:
      dp[i+1][j] += dp[i][j]*(a[w-1])%mod
    else:
      dp[i+1][j] += dp[i][j]*(a[j]*a[w-1-j])%mod
print(dp[h][0]%mod)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <stack>
#include <queue>
#include <map>
using namespace std;
#define MAX_N 105
#define MAX_M 11
#define PI 3.14159265359
#define rep(i,n) for(int i=0; i<n; ++i)
#define INF 1001001001

typedef pair<int, int> P;

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

    int cnt = 0;
    while (a > 0 && c > 0) {
        if (cnt % 2) a -= d;
        else c -= b;
        ++cnt;
    }
    cout << ((cnt % 2) ? "Yes" : "No") << endl;

    return 0;
}

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

int main(int argc, char *argv[])
{
    int A, B;
    std::string S;

    std::cin >> A >> B;
    std::cin >> S;

    std::string a;
    std::string b;

    a = S.substr(0, A);
    b = S.substr(A+1, S.size()-(A+1));

    bool a_flag = false;
    bool haihun = false;
    bool b_flag = false;

    if (std::all_of(a.cbegin(), a.cend(), isdigit)) {
        a_flag = true;
    }

    std::string str = "-";
    if (S.substr(A, 1) == str) { 
        haihun = true;
    }

    if (std::all_of(b.cbegin(), b.cend(), isdigit)) {
        b_flag = true;
    }

    if (a_flag && haihun && b_flag) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No"  << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

vvl comb(int n, int r) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}

int keta(ll a){
	int ke=1;
	while(a/=10)ke++;
	return ke;
}

int n;
ll a,b,h[M];
bool f(int time){
	ll res=0;
	rep(i,0,n){
		ll tmp=h[i]-time*b;
		if(tmp>0)res+=(tmp+(a-b)-1)/(a-b);
	}
	return (res<=time);
}

int main(){
	cin>>n>>a>>b;
	rep(i,0,n)cin>>h[i];
	int l=0,r=inf;
	while(l+1<r){
		int mid=(l+r)>>1;
		if(f(mid))r=mid;
		else l=mid;
	}
	print(l+1);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,k;
vector<int> g[100001];
int num[100001];
priority_queue<pair<int,int>,vector<pair<int,int> > ,greater<pair<int,int> > > pq;
int main(){
    cin>>n;
    memset(num,-1,sizeof(num));
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    cin>>k;
    for(int i=0;i<k;i++){
        int x,y;
        cin>>x>>y;
        x--;
        num[x]=y;
        pq.push(make_pair(y,x));
    }
    while(!pq.empty()){
        int d=pq.top().second;
        pq.pop();
        for(int i=0;i<g[d].size();i++)
            if(num[g[d][i]]==-1)
                num[g[d][i]]=num[d]+1,pq.push(make_pair(num[d]+1,g[d][i]));
    }
    for(int i=0;i<n;i++)
        for(int j=0;j<g[i].size();j++)
            if(abs(num[i]-num[g[i][j]])!=1)
                return cout<<"No"<<endl,0;
    cout<<"Yes"<<endl;
    for(int i=0;i<n;i++)
        cout<<num[i]<<endl;
    return 0;
}

Measured memory_bytes: 7924
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long X;
  cin >> X;
  long long int A,B;
  for (long long int i = -120; i < 120; i++){
    for (long long int j = -120; j < 120; j++){
      if (j*j*j*j*j - i*i*i*i*i == X){
        A = j;
        B = i;
      }
    }
  }
  cout << A << " " << B;
}


Measured memory_bytes: 3540
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

using namespace std;

class InputConsole {
public:
	template<typename T>
	static void inputs(vector<T> &vec) {
        string inputString;
        getline(cin, inputString);

        while (!inputString.empty()) {
            int i = 0;
            for (i = 0; i < inputString.length(); i++) {
                if (inputString[i] == ' ') {
                    break;
                }
            }
            stringstream ss;
            ss<< inputString.substr(0, i);
            T data;
            ss >> data;
            vec.push_back(data);
            inputString.erase(0, i + 1);
        }
	}
};

void Main()
{
    long long  a, b, c, d;
    cin >> a >> b >> c >> d;
    long long max;
    max = a * c;
    if (max < a * d)max = a * d;
    if (max < b * c)max = b * c;
    if (max < b * d)max = b * d;
    cout << max << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}




Measured memory_bytes: 3644
#include<stdio.h>
#include<string.h>
int main(void){
char s[11];
  scanf("%s",&s);
  
 for(int i=0;i<strlen(s);i+=2){
   if(s[i]!='h'||s[i+1]!='i'){
printf("No");
     return 0;
   }
 }
printf("Yes");
  
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define MAX 200000000
#define white 0
#define black 1
 
int n, c[100][100];
 
int prim() {
  int i, d[100], p[100], cl[100], sum, minc, u;
  for (i = 0; i < n; ++i) {
    cl[i] = white;
    d[i] = MAX;
  }
     
  d[0] = 0;
     
  while(1){
    minc = MAX;
    for (i = 0; i < n; ++i){
      if (cl[i] != black && d[i] < minc){
        minc = d[i];
        u = i;
      }
    }
         
  if (minc == MAX) break;
         
    cl[u] = black;
         
    for (i = 0; i < n; ++i) {
      if (cl[i] != black && c[u][i] != MAX) {
        if (c[u][i] < d[i]){
          d[i] = c[u][i];
          p[i] = u;
        }
      }
    }
  }
     
  sum = 0;
  for (i = 1; i < n ; ++i) {
    sum += c[i][p[i]];
  }
  return sum;
}
 
int main() {
  int i, j;
  scanf("%d", &n);
     
  for (i = 0; i < n; ++i) {
    for (j = 0; j < n; ++j) {
      scanf("%d", &c[i][j]);
        if (c[i][j] == -1) c[i][j] = MAX;
    }
  }
     
    printf("%d\n", prim());
    return 0;
}

Measured memory_bytes: 1816
#include<iostream>
#include<vector>
#include<string>

int main(){
    int n;
    std::cin >> n;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        int a;
        std::cin >> a;
        if(a % 2 == 1 && (i + 1) % 2 == 1) cnt++;
    }
    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 3564
#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 endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod= 1e9+7;
const ll INF = 1LL<<40;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main(){
  ll n,k,ans=0;
  string s;
  cin>>s;
  rep(i,0,3){
    if(s[i]=='A')ans++;
    else if(s[i]=='B')ans--;
  }
  if(ans==3||ans==-3)cout<<"No";
  else cout<<"Yes";
}

Measured memory_bytes: 256
A = []
for i in range(3):
    A.append(list(map(int, input().split())))

t = 0
if A[0][0] - A[1][0] == A[0][1] - A[1][1] == A[0][2] - A[1][2]:
    if A[2][0] - A[1][0] == A[2][1] - A[1][1] == A[2][2] - A[1][2]:
        if A[0][0] - A[0][1] == A[1][0] - A[1][1] == A[2][0] - A[2][1]:
            if A[0][2] - A[0][1] == A[1][2] - A[1][1] == A[2][2] - A[2][1]:
                t = 1
if t == 1:
    print("Yes")
else:
    print("No")

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

int main() {
	int k,s;
    cin >> k >> s;
    int count = 0;
    for(int x=0;x<=k;x++){
      for(int y=0;y<=k;y++){
        int z = s-x-y;
        if(0<=z && z<=k){
          count++;
        }
      }
    }
    cout << count << endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
//type
typedef long long ll;
#define pii pair<int, int>
#define vi vector<int>
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
#define ios cin.tie(0); ios::sync_with_stdio(false)
#define FIX(a) cout << fixed << setprecision(a)
//manip
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power(T a, T b)
{return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
template<typename T> T gcd(T a, T b) {if (b == 0) return a; return gcd(b, a % b);}
template<typename T> T lcm(T a, T b) {return a / gcd(max(a, b), min(a, b)) * b;} //先に割る!!
#define outa(a, n) rep(i, n) cout << a[i] << " "; cout << endl
#define out(a) cout << a << endl
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0
//minimal required terms
//cast caution
//look constraints always



int main() {
    string s; cin >> s;
    int now = s[0] - 'A';
    int ans = 0;
    if (s[0] == 'A') ans++;
    rep3(i, 1, SZ(s)) {
        if (s[i] == s[i - 1]) {
            ans++;
        }
        if (s[i] - 'A' < now) {
            ans++;
        }
        now = s[i] - 'A';
        
    }
    cout << ans << endl;
}



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

int main()
{
    char S[17];
    int counter = 0;
    cin >> S;
    char ac[17] = "CODEFESTIVAL2016";
    for(int i = 0; i < 16; i++){
        if(S[i] != ac[i]){
            ++counter;
        }
    }
    cout << counter << endl;
    

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;

//  -d
int main() {
    ll n;
    cin >> n;
    ll ans = n * (n - 1);
    ans    = ans / 2;
    printf("%lld\n", ans);
}



Measured memory_bytes: 256
a=io.read("n")
b=io.read("n")
local res=0
if b==100 then
  res=a*1000+b
  elseif b>=10 and b<=99 then
    res=a*100+b
  else
    res=a*10+b
end
local _,k=math.modf(math.sqrt(res))
if k==0 then
  print("Yes")
else
  print("No")
end

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;
ll N;
ll X[201000];
ll Y[201000];
char C[201000];
ll ans = INF;
map<char, char> nxt;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    nxt['U'] = 'L';
    nxt['L'] = 'D';
    nxt['D'] = 'R';
    nxt['R'] = 'U';
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> X[i] >> Y[i] >> C[i];
    }
    for(int t = 0; t < 4; t++) {
        cerr << "---------------------------T:" << t << endl; 
        for(int i = 0; i < N; i++) {
            ll tmp = X[i];
            X[i] = -Y[i];
            Y[i] = tmp;
            C[i] = nxt[C[i]];
        }
        map<ll, vector<ll>> U, R, D;
        for(int i = 0; i < N; i++) {
            if(C[i] == 'U') U[X[i]+Y[i]].push_back(X[i]);
            if(C[i] == 'R') R[X[i]+Y[i]].push_back(X[i]);
        }
        for(auto tmp : U) {
            ll idx = tmp.first;
            auto v1 = tmp.second;
            auto v2 = R[idx];
            sort(v1.begin(), v1.end());
            sort(v2.begin(), v2.end());
            for(auto pos : v2) {
                auto itr = lower_bound(v1.begin(), v1.end(), pos);
                if(itr == v1.end()) continue;
                chmin(ans, ((*itr) - pos) * 10);
            }
        }
        U.clear();
        for(int i = 0; i < N; i++) {
            if(C[i] == 'U') U[X[i]].push_back(Y[i]);
            if(C[i] == 'D') D[X[i]].push_back(Y[i]);
        }
        for(auto tmp : U) {
            ll idx = tmp.first;
            auto v1 = tmp.second;
            auto v2 = D[idx];
            swap(v1, v2);
            sort(v1.begin(), v1.end());
            sort(v2.begin(), v2.end());
            for(auto pos : v2) {
                auto itr = lower_bound(v1.begin(), v1.end(), pos);
                if(itr == v1.end()) continue;
                chmin(ans, ((*itr) - pos) * 5);
            }
        }
    }
    if(ans == INF) cout << "SAFE" << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 59420
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int,int> pii;
typedef pair <db,db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD=998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=200005;

void solve()
{
    int n;
    cin>>n;
    ldb pro=1.0;
    ldb a[n];int zr=0;
    for(int i=0;i<n;i++)
    { cin>>a[i];
        if(!a[i])
            zr=1;
    }
    if(zr)
    {
        cout<<0<<endl;
        return;
    }
    ldb MX=1000000000000000000.0;
    for(int i=0;i<n;i++)
    {
        pro=pro*a[i];
        //cout<<fixed<<setprecision(0);
        //cout<<pro<<endl;
        if(pro>MX)
        {
            cout<<-1<<endl;
            return;
        }
    }
    cout<<fixed<<setprecision(0);
    cout<<pro<<endl;
    
    
}


int32_t main()
{
    IOS;
    //pre();
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        
        solve();
    }
    return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

  int N=in();
  vector<ll> A(N);
  REP(i,N) A[i]=in();
  
  int neg=0;
  ll min_abs_neg=-1;
  bool zero=false;
  ll sum=0;
  for(int i=0;i<N;i++){
    sum += abs(A[i]);
    if(min_abs_neg<0 || min_abs_neg>abs(A[i])){
      min_abs_neg = abs(A[i]);
    }
    
    if(!A[i]){
      zero = true;
    }
    else if(A[i]<0){
      neg++;
    }
  }
  if(zero || !(neg%2)){
    cout << sum << endl;
  }
  else{
    cout << sum-2*min_abs_neg << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))

a.append(0)
a.insert(0, 0)
costs = []
for i in range(n + 1):
    costs.append(abs(a[i + 1] - a[i]))

s = sum(costs)
for i in range(n):
    ans = s - costs[i] - costs[i + 1] + abs(a[i] - a[i + 2])
    print(ans)

Measured memory_bytes: 14048
#include<cstdio>

int main() {
    int n;
    scanf("%d",&n);
    bool card[4][13];
    for(int i = 0;i < 4;i++) {
        for(int j = 0;j < 13;j++) {
            card[i][j] = false;
        }
    }
    for(int i = 0;i < n;i++) {
        char c;
        scanf("\n%c",&c);
        int x;
        scanf("%d",&x);
        if(c =='S') {
            card[0][x - 1] = true;
        }
        else if(c =='H') {
            card[1][x - 1] = true;
        }
        else if(c =='C') {
            card[2][x - 1] = true;
        }
        else if(c =='D') {
            card[3][x - 1] = true;
        }
    }
    for(int i = 0;i < 4;i++) {
        for(int j = 0;j < 13;j++) {
            if(!card[i][j]) {
                if(i == 0) {
                    printf("S %d\n",j + 1);
                }
                else if(i == 1) {
                    printf("H %d\n",j + 1);
                }
                else if(i == 2) {
                    printf("C %d\n",j + 1);
                }
                else if(i == 3) {
                    printf("D %d\n",j + 1);
                }
            }
        }
    }
}


Measured memory_bytes: 2700
#define ll long long
#define MOD 1000000007
#define MOD2 998244353
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set2d(array, val, m, n) memset(array, val, sizeof(array[0][0]) * m * n);
#include <bits/stdc++.h>
using namespace std;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x %= p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll po(ll base, ll powerRaised)
{
    if (powerRaised != 0)
        return (base * po(base, powerRaised - 1));
    else
        return 1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, k;
    cin >> n >> k;
    cout << min(n % k, k - (n % k));
}

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

bool flag[1000001];  //その数を見たかどうか/falseなら素数
int exist[1000001];

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    bool pairwise = true;
    bool setwise = true;

    rep(i, 1000001) flag[i] = false;
    rep(i, 1000001) exist[i] = 0;
    rep(i, N)++ exist[A[i]];

    for (int i = 2; i <= 1000001; ++i) {
        int cnt = 0;
        cnt += exist[i];
        if (!flag[i]) {
            for (int j = i * 2; j <= 1000001; j += i) {
                flag[j] = true;
                cnt += exist[j];
            }
        }
        if (cnt > 1) pairwise = false;
        if (cnt == N) setwise = false;
    }
    if (pairwise) {
        cout << "pairwise coprime" << endl;
    } else if (setwise) {
        cout << "setwise coprime" << endl;
    } else
        cout << "not coprime" << endl;
}


Measured memory_bytes: 11880
#include <iostream>
#include <map>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	map<int, int> mp;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		mp[a]++;
	}
	int ans = 0;
	for (auto it: mp) {
		if (it.second < it.first) {
			ans += it.second;
		}
		else ans += it.second - it.first;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4736
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[][] A = new int[2][N+1];
		int[] t0 = new int[N+1];
		int[] t1 = new int[N+1];
		int[] ans = new int[N+1];
		int total0 = 0,total1 = 0;
		for( int i=1; i<=N; i++ ){
			A[0][i] = sc.nextInt();
			total0 += A[0][i];
			t0[i] = total0;
		}
		for( int i=1; i<=N; i++ ){
			A[1][i] = sc.nextInt();
		}
		for( int i=N; i>=1; i-- ){
			total1 += A[1][i];
			t1[i] = total1;
		}
		for( int i=1; i<=N; i++ ){
			ans[i] = t0[i] + t1[i];
		}
		Arrays.sort(ans);
		System.out.println(ans[N]);
	}
}


Measured memory_bytes: 21844
N = int(input())
R = [list(map(int,input().split())) for k in range(N)]
B = [list(map(int,input().split())) for k in range(N)]

R = sorted(R, key = lambda x: -1*x[1])
B = sorted(B)

ans = 0
for b in B:
    for r in R:
        if r[0] < b[0] and r[1] < b[1]:
            ans += 1
            R.remove(r)
            break

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if (a==b) {
        cout<<c<<endl;
    } else if (a==c) {
        cout<<b<<endl;
    } else {
        cout<<a<<endl;
    }
}


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

using namespace std;
const int N=1e6+9;

vector<int>prime;
bool flag[N];

void seive(){
    for(int i=4;i<N;i+=2)flag[i]=true;
    for(int i=3;i*i<N;i+=2){
        if(!flag[i]){
            for(int j=i*3;j<N;j+=i*2)flag[j]=true;
        }
    }
    prime.push_back(2);
    for(int i=3;i<N;i+=2){
        if(!flag[i])prime.push_back(i);
    }
}

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

    int a[n];
    for(int& i : a )cin >> i;
    seive();
    //for(int i=0;i<20;i++)cout<<prime[i]<<" ";
    //cout<<endl;
    map<int,int> cnt;

    for(int i : a){
        int temp=i;

        for(int x : prime){
            if(x*x>temp)break;
            if(temp%x==0){
                    cnt[x]++;
                    while(temp%x==0)temp/=x;
            }
        }
        if(temp>1)cnt[temp]++;
    }
    bool flag = true;

    for(auto [x,y ] : cnt){
        if(y>1){
            flag=false;
            break;
        }
    }
    if(flag){
        cout<<"pairwise coprime"<<endl;
        return 0;    
    }

    int g=a[0];
    for(int i=1;i<n;i++)g=__gcd(g,a[i]);
    if(g==1)cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;
}



Measured memory_bytes: 12088
//始点0が1つずつ増えていくと考えると、一から多始点最短路をせずとも、新しく増えた始点から最短路を更新すれば十分と分かる。
//一見O(N^4)に見えるけど、最短路の長さが減る所しか見なくて良いので、元々の最短路の長さの和 = O(N^3)くらいの計算で解ける。
//詳細：空白に入るときコスト0, それ以外はコスト1. 逆から見ると「空白から出るときコスト0, そうでないときコスト1」
#include <iostream>
#include <algorithm>
#include <queue>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
typedef tuple<int, int, int> T;

int dy[4] = {-1, 0, 1, 0};
int dx[4] = {0, 1, 0, -1};
int n;
int p[250000];
int dist[500][500];
bool used[500][500];

signed main() {
	int i, j;
	
	cin >> n;
	rep(i, n * n) { cin >> p[i]; p[i]--; }
	rep(i, n) rep(j, n) dist[i][j] = min({i, j, n - 1 - i, n - 1 - j});
	
	int ans = 0;
	rep(i, n * n) {
		int sy = p[i] / n;
		int sx = p[i] % n;
		ans += dist[sy][sx];
		
		queue<T> que;
		que.push(T(dist[sy][sx], sy, sx));
		used[sy][sx] = true;
		
		while (!que.empty()) {
			T now = que.front(); que.pop();
			int cst = get<0>(now);
			int y = get<1>(now);
			int x = get<2>(now);
			rep(j, 4) {
				int ny = y + dy[j];	 //next y
				int nx = x + dx[j];
				if (ny < 0 || ny >= n || nx < 0 || nx >= n) continue;
				int ncst = cst + (used[y][x] == false);
				if (dist[ny][nx] <= ncst) continue;
				dist[ny][nx] = ncst;
				que.push(T(ncst, ny, nx));
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5768
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<ll>a(n),sum(n+1,0);
    rep(i,n){
        cin>>a[i];
        sum[i+1]=sum[i]+a[i];
    }
    ll ans=0;
    sort(sum.begin(),sum.end());
    rep(i,n){
        int j=1;
        ll cnt=0;;
        while(i+j<=n&&sum[i]==sum[i+j]){
        ++cnt;
        ++j;
        }
        --j;
        i+=j;
        ans+=cnt*(cnt+1)/2;
    }
    cout<<ans<<endl;
    return 0;
    }


Measured memory_bytes: 3328
N,K = map(int,input().split())
h = list(map(int,input().split()))

dp = [0]*N
for i in range(1,N):
    dp[i] = min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,min(i,K)+1)])
print(dp[-1])

Measured memory_bytes: 52576
s = input()

cand1, cand2 = "", ""
if len(s) % 2 == 0:
  cand1 = "10" * (len(s) // 2)
  cand2 = "01" * (len(s) // 2)
else:
  cand1 = "0" + "10" * ((len(s) - 1) // 2)
  cand2 = "1" + "01" * ((len(s) - 1) // 2)

counter_cand1 = [s[i] == cand1[i] for i in range(len(s))]
counter_cand2 = [s[i] == cand2[i] for i in range(len(s))]

print(min(counter_cand1.count(False), counter_cand2.count(False)))

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

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

signed main() {
    int N;
    cin >> N;
    vi A(N);
    REP(i, N) cin >> A[i];

    double b = 0;
    REP(i, N) b += 1.0 / A[i];
    double ans = 1.0 / b;
    cout << setprecision(10) << ans << endl;

    return 0;
}


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

int main() {
  int S, W;
  cin >> S >> W;
  if(W >= S) cout << "unsafe" << endl;
  else cout << "safe" << endl;
  return 0;
}

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

void Main(){
    
}

bool S[14], H[14], C[14], D[14];
int main() {
	int n; cin >> n;
	rep(i, n) {
		string s; int d; cin >> s >> d;
		if (s == "S")S[d] = true;
		if (s == "H")H[d] = true;
		if (s == "C")C[d] = true;
		if (s == "D")D[d] = true;
	}
	for (int i = 1; i <= 13; i++) {
		if (!S[i])cout << "S " << i << endl;
	}
	for (int i = 1; i <= 13; i++) {
		if (!H[i])cout << "H " << i << endl;
	}
	for (int i = 1; i <= 13; i++) {
		if (!C[i])cout << "C " << i << endl;
	}
	for (int i = 1; i <= 13; i++) {
		if (!D[i])cout << "D " << i << endl;
	}
}



Measured memory_bytes: 3168
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int max = 0;
		for(int i=0;i<s.length();i++){
			int n = 0;
			for(int j=0;j<t.length()&&i+t.length()<=s.length();j++){
				if(s.charAt(i+j) == t.charAt(j)){
					n++;
				}
			}
			if(max < n){
				max = n;
			}
		}
		System.out.println(t.length()-max);
		sc.close();
	}
}



Measured memory_bytes: 36160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
const int MOD = 1000000007;

template<class T>
class BIT {
private:
    vector<T> dat;
    int n;
public:
    BIT(int _n) : dat(_n + 1), n(_n) {}
    // [1, i] の総和
    T sum(int i) {
        int s = 0;
        while(i > 0) {
            s += dat[i];
            s %= MOD;
            i -= i & -i;
        }
        return s;
    }
    // [l, r] の総和
    T sum(int l, int r) {
        if(l > r) return 0;
        return sum(r) - sum(l - 1);
    }
    void add(int i, T x) {
        while(i <= n) {
            dat[i] += x;
            dat[i] %= MOD;
            i += i & -i;
        }
    }
};

int main() {
    int N, K;
    cin >> N >> K;
    K++;
    vector<int> A(N);
    rep(i, 0, N) cin >> A[i];
    vector<BIT<int>> dp(N + 1, K);
    dp[0].add(K, 1);
    rep(i, 0, N) rep(j, 1, K + 1) {
        int a = dp[i].sum(j, min(K, j + A[i]));
        if(a < 0) a += MOD;
        dp[i + 1].add(j, a);
    }
    cout << dp[N].sum(1) << endl;
    return 0;
}


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n){
        cin >> s.at(i);
    }
    sort(s.begin(), s.end());
    int count = 1;
    rep(i,n-1){
        if(s.at(i) != s.at(i+1)) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 9596