akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
using namespace std;
const int N=100007,P=1000000007;
int n,c,G[26];
char S[N];
int main () {
	scanf("%d%s",&n,S);
	int ans=0;
	For(i,0,n-1) {
		int res=1;
		For(j,0,25)
		if (j!=S[i]-'a') res=1LL*res*(G[j]+1)%P;
		++G[S[i]-'a'];
		ans=(ans+res)%P;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
  int x,y,r,num;
  scanf("%d %d",&x,&y);
  if(x<y){
    r=x;
    x=y;
    y=r;
  }
  while((num=x%y)!=0){
    x=y;
    y=num;
  }
  printf("%d\n",y);
  return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
constexpr int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    vi a(5);
    rep(i, 5) cin >> a[i];

    rep(i, 5){
        if(a[i] == 0){
            cout << i+1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) do{}while(0)
#endif




int main(){
	ll r, g, b, k;
	cin >> r >> g >> b;
	cin >> k;
	
	int op = 0;
	while ( g <= r ){ g *= 2; op++; }
	while ( b <= g ){ b *= 2; op++; }
	
	
	cout << (op <= k ? "Yes" : "No" ) << endl;
	
	return 0;
}




Measured memory_bytes: 3632
n,m=map(int,input().split())
keys=[None]*m
dp=[-1]*(2**n)
dp[0]=0
for i in range(m):
  a,b=map(int,input().split())
  c=list(map(int,input().split()))
  cond=0
  for j in c:
    cond+=2**(j-1)
  keys[i]=[a,cond]
for key in keys:
  for sta in range(2**n):
    if dp[sta]==-1:continue
    if dp[sta|key[1]]==-1:
      dp[sta|key[1]]=key[0]+dp[sta]
    else:
      dp[sta|key[1]]=min(dp[sta|key[1]],dp[sta]+key[0])
print(dp[-1])


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

int main() {
  int n; cin>>n;
  //cout << n << endl;
  vector<pair<int,int>> stdnt(n);
  rep(i,n){
    cin >> stdnt[i].first;
    stdnt[i].second = i+1;
  }
  //rep(i,n) cout << stdnt[i].first <<" " <<stdnt[i].second


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

  rep(i,n) cout << stdnt[i].second <<" ";
  cout << endl;
}


Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,k;
    cin >> n >> k;
    if(n%k == 0){
        cout << 0 << endl;
    }
    else{
        cout << 1 << endl;
    }
    return 0;
}

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

int L;
char S[100010];

bool f(int i) {
  if (i >= L) return true;
  if (S[i] == 'd' && S[i+1] == 'r' && S[i+2] == 'e' && S[i+3] == 'a' && S[i+4] == 'm') {
    return (S[i+5] == 'e' && S[i+6] == 'r' && f(i+7)) || f(i+5);
  }
  if (S[i] == 'e' && S[i+1] == 'r' && S[i+2] == 'a' && S[i+3] == 's' && S[i+4] == 'e') {
    return (S[i+5] == 'r' && f(i+6)) || f(i+5);
  }
  return false;
}

int main() {
  cin >> S;
  L = string(S).length();
  cout << (f(0) ? "YES\n" : "NO\n");
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int h,w,a,b;cin>>h>>w>>a>>b;
    rep(i,b){
        rep(j,a)cout<<1;
        rep(j,w-a)cout<<0;
        cout<<endl;
    }
    rep(i,h-b){
        rep(j,a)cout<<0;
        rep(j,w-a)cout<<1;
        cout<<endl;
    }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define print(x) cout << (x) << endl;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    for (int i; i < N; i++) {
        int a = 0;
        int count = 0;
        cin >> a;
        while(a % 2 == 0) {
            a /= 2;
            count++;
        }
        B.at(i) = count;
    }
    sort(B.begin(), B.end());
    cout << B.at(0) << endl;
}

Measured memory_bytes: 256
import Data.Functor( (<$>))
import Control.Monad( replicateM, forM_)

main = do
    let
	readLine = (read <$>) . words <$> getLine   ::IO [Int]

    initialDice <- readLine
    q <- read <$> getLine
    questions <- replicateM q readLine
    let
	matchedState dice [top, front]
	  = head $ filter checkFront checkList
	      where
		roll d 'S' = [d!!4, d!!0, d!!2, d!!3, d!!5, d!!1]
		roll d 'N' = [d!!1, d!!5, d!!2, d!!3, d!!0, d!!4]
		roll d 'W' = [d!!2, d!!1, d!!5, d!!0, d!!4, d!!3]
		roll d 'E' = [d!!3, d!!1, d!!0, d!!5, d!!4, d!!2]

		rolls d dirs = foldl roll d dirs

		checkTop d = top == head d
		checkFront d = front== d!!1
		rot d = rolls d "ESW"
		candidate = filter checkTop
				[ dice
				, rolls dice "S"
				, rolls dice "SS"
				, rolls dice "SSS"
				, rolls dice "E"
				, rolls dice "EE"
				, rolls dice "EEE"]
		checkList = do
		    c <- candidate
		    [c, rot c, rot.rot $ c, rot.rot.rot $ c]

    forM_ questions $
			print . (!!2) . matchedState initialDice



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

namespace agc002_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] balls = new int[x[0]];
            bool[] ret = new bool[x[0]];
            ret[0] = true;
            for (int i = 0; i < x[0]; i++) balls[i] = 1;
            for (int i = 0; i < x[1]; i++)
            {
                int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
                n[0]--; n[1]--;
                balls[n[0]]--; balls[n[1]]++;
                if (ret[n[0]])
                {
                    ret[n[1]] = true;
                    if (balls[n[0]] == 0) ret[n[0]] = false;
                }
            }
            int result = 0;
            for (int i = 0; i < x[0]; i++)
            {
                if (ret[i]) result++;
            }
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 17504
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

  int n,k;
  cin>>n>>k;
  if((n+1)/2>=k){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }



  return 0;
}

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

set< P > A,B;
ll sumA=0;

ll N,Q;

ll a[200005];
ll b[200005];
ll tmp=0;

ll funcA(){
  if(A.empty())return 0;
  return A.begin()->first;
}

ll funcB(){
  if(B.empty())return 0;
  auto it=B.end();
  it--;
  return it->first;
}

int main(){
  cin>>N>>Q;
  N*=2;
  for(int i=0;i<N;i++){
    cin>>a[i];
    tmp+=a[i];
  }
  for(int i=0;i<N;i++)cin>>b[i];

  for(int i=1;i+1<N;i++){
    P p=P(b[i]-a[i],i);
    if(p.first>0){
      A.insert(p);
      sumA += p.first;
    }else{
      B.insert(p);
    }
  }

  for(int i=0;i<Q;i++){
    ll id,na,nb;
    cin>>id>>na>>nb;
    id--;
    
    if( id == 0 || id == N-1 ){
      tmp -= a[id];
      a[id]=na;
      tmp += a[id];
    }else{
      tmp -= a[id];
      tmp += na;
      P p=P(b[id]-a[id],id);
      a[id]=na;
      b[id]=nb;
      P np=P(b[id]-a[id],id);

      if(A.count(p)){
        A.erase(p);
        sumA-=p.first;
      }else{
        B.erase(p);
      }
    
      if(np.first>0){
        A.insert(np);
        sumA+=np.first;
      }else{
        B.insert(np);
      }
    }
    /*
    cout<<"////"<<endl;
    for(auto p : A)cout<<p.first<<' '<<p.second<<endl;
    cout<<"////"<<endl;
    */
    if(A.size()%2==0){
      cout<<tmp+sumA<<endl;
    }else if(!A.empty()&&!B.empty()&&funcA()+funcB()>=0){
      //      cout<<"X"<<endl;
      cout<<tmp+sumA+funcB()<<endl;      
    }else{
      //      cout<<"Y"<<endl;
      cout<<tmp+sumA-funcA()<<endl;
    }
    
  }
  return 0;
}


Measured memory_bytes: 17280
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector< vector<int> > vt(N, vector<int>(N, 0));
    for(int i=0; i<N; i++){
        int num=i;
        for(int j=0; j<10; j++){
            vt[i][j]=num%2;
            num/=2;
            if(num==0) break;
        }
    }

    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            for(int bi=0; bi<9; bi++){
                if(vt[i][bi]!=vt[j][bi]){
                    cout << bi+1;
                    break;
                }
            }

            if(j==N-1) cout << endl;
            else cout << ' ';
        }
    }
    

    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(){
  vi a(5);
  int k;
  rep(i,0,5) cin >> a[i];
  cin >> k;

  sort(all(a));
  if(a[4]-a[0] <= k){
    cout << "Yay!" << endl;
  }else{
    cout << ":(" << endl; 
  }
}

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

#define INF (1 << 29)

#define MAX_N 20000
#define MAX_M 16

using namespace std;

int N, M, C[MAX_M], X, dp[MAX_N + 1][256];

int main()
{
	while (true)
	{
		for (int i = 0; i < MAX_N + 1; i++)
		{
			for (int j = 0; j < 256; j++)
			{
				dp[i][j] = INF;
			}
		}

		dp[0][128] = 0;

		cin >> N >> M;

		if (N == 0 && M == 0) { break; }

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

		for (int i = 0; i < N; i++)
		{
			cin >> X;

			for (int j = 0; j < 256; j++)
			{
				for (int k = 0; k < M; k++)
				{
					int ptr = max(j + C[k], 0);

					ptr = min(ptr, 255);

					int sabun = (X - ptr) * (X - ptr);

					dp[i + 1][ptr] = min(dp[i + 1][ptr], dp[i][j] + sabun);
				}
			}
		}

		cout << *min_element(dp[N], dp[N] + 256) << endl;
	}

	return 0;
}

Measured memory_bytes: 23076
#include <iostream>
#include <cstdlib>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <sstream>
#include <math.h>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecchar vector<char>
#define vecstr vector<string>
#define vecbool vector<bool>
#define vec2bool vector<vector<bool>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s >= 0;s--)

#define Pi 3.1415926535897932384626

int main() {
	ll x, n, ans=1000,count=-1,i=0;
	string s = "Yes";
	bool flag = false;

	cin >> x >> n;

	vecll p(n);

	forll(i, 0, n)
		cin >> p[i];

	if(n > 0)
		sort(p.begin(), p.end());

	while (count <= 100)
	{
		count++;
		if(i < p.size())
			if (count == p[i])
			{
				i++;
				continue;
			}

		if (abs(x - count) < abs(x-ans))
			ans = count;
	}

	cout << ans;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
    int a,b,c,x,y,sum=0,k,m;
    scanf("%d %d %d %d %d",&a,&b,&c,&x,&y);
    if(x!=y)
    {
        if((a+b)>2*c)
        {
           k=x<y?x:y;
           m=x<y?y:x;
           if(m==x)
           {
               sum=k*2*c+(m-k)*a;
           }
           else
           {
               sum=k*2*c+(m-k)*b;
           }
           if(m*c*2<sum)
           {
               sum=m*c*2;
           }
        }
        else
            sum=x*a+y*b;
    }
    else
    {
        if((a+b)>2*c)
        {
            sum=x*2*c;
        }
        else
            sum=x*a+y*b;
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

int main()
{	
	int n; std::cin >> n;
	
	for (long long int i=0; i<(1<<n); i++) {
		std::cout << i << ":";
		long long int d = i;
		for (int j=0; j<n; j++) {
			if ( (d&1) == 1 ) std::cout << " " << j;
			d >>= 1;
		}
		std::cout << std::endl;
	}
	
	return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
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; }
const long long INF = 1LL << 60;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  char a;
  cin>>a;
  a++;
  cout<<a;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> b(n-1);
  rep(i,n-1) cin >> b[i];
  vector<int> a(n,INF);
  rep(i,n-1) {
    a[i] = min(a[i], b[i]);
    a[i+1] = min(a[i+1], b[i]);
  }
  int ans = 0;
  rep(i,n) ans += a[i];
  cout << ans << endl;
  return 0;
}

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

class prime_table {
public:
        prime_table(int maxn) : maxn(maxn), is_primes(maxn + 1, true) {
                is_primes[0] = is_primes[1] = false;
                for (int i = 2; i <= maxn; i ++) {
                        if (is_primes[i]) {
                                primes.push_back(i);
                                for (int j = i + i; j <= maxn; j += i) is_primes[j] = false;
                        }
                }
        }
        bool is_prime(int n) {
                assert(n <= maxn);
                return is_primes[n];
        }
        vector<int> get_primes() {
                return primes;
        }
private:
        int maxn;
        vector<int> primes;
        vector<bool> is_primes;
};

template<class T>
bool is_prime(T n) {
        if (n < 2 || (n > 2 && (n % 2 == 0))) {
                return false;
        }
        for (T i = 3; i * i <= n; i += 2) {
                if (n % i == 0) {
                        return false;
                }
        }
        return true;
}

template<class T>
vector<pair<T, int>> factorize(T n) {
        assert(n > 1);
        vector<pair<T, int>> res;
        for (T i = 2; i * i <= n; i ++) {
                if (n % i == 0) {
                        int c = 0;
                        while (n % i == 0) {
                                n /= i;
                                c ++;
                        }
                        res.emplace_back(i, c);
                }
        }
        if (n > 1) {
                res.emplace_back(n, 1);
        }
        return res;
}

int main() {
        int n;
        cin >> n;
        int ans = 0;
        rep(i, n) {
                int a;
                cin >> a;
                ans += is_prime(a);
        }
        cout << ans << endl;
        return 0;
}



Measured memory_bytes: 3092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {

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

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);
		int k = Integer.parseInt(str[1]);

		str = br.readLine().split(" ");
		int p[] = new int[n];

		for (int i = 0; i < n; i++) {
			p[i] = (Integer.parseInt(str[i]) + 1);
		}

		int s[] = new int[n + 1];
		s[0] = 0;

		for (int i = 0; i < n; i++) {
			s[i + 1] = s[i] + p[i];
		}

		int max = 0;
		for (int i = 0; i <= n - k; i++) {
			max = Math.max(max, s[i + k] - s[i]);
		}
		System.out.println((double) max / 2);
	}
}


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

int main(void) {
    int N;
    cin >> N;
    int cnt = 0;
    while (true) {
        int tmp = N % 10;
        N /= 10;
        if (N == 0 || cnt == 2) break;
        if (tmp == N % 10) cnt++;
        else cnt = 0;
    }
    cout << ( (cnt == 2) ? "Yes" : "No" ) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    n=n%10;
    if(n==3){
        cout<<"bon"<<endl;
    }
    else if((n==1)||(n==0)||(n==6)||(n==8)){
        cout<<"pon"<<endl;
    }
    else{
        cout<<"hon"<<endl;
    }
}


Measured memory_bytes: 3648
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#define LWC 16
using namespace std;
char s[LWC+5];
int p[LWC+5], sum;
bool flag = true;
int main()
{
	scanf("%s", s);;;;;;;;;;
	int len = strlen(s);;;;;
	for(int i=0; i<len; i++)
	{
		sum += s[i] - '0';
		if(sum%9)
			flag = false;
	}
	if(s[0] == '0')
		cout<<0;
	else if(flag == true)
		cout<<9*strlen(s);
	else
	{
		cout<<max(9*(int)strlen(s+1)+s[0]-'1', sum);
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[3001][3001][2];
ll solve(vector<ll>&v,int i,int j,bool turn){
	if(i>j){
		return 0;
	}

	if(dp[i][j][turn]!=-1){
		return dp[i][j][turn];
	}

	if(turn==1){
		return dp[i][j][turn] = max(v[i] + solve(v,i+1,j,0),v[j] + solve(v,i,j-1,0));
	}else{

		return dp[i][j][turn] = min(solve(v,i+1,j,1),solve(v,i,j-1,1));
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	memset(dp,-1,sizeof dp);
	ll n;
	cin>>n;
	vector<ll>v(n+1);
	ll sum = 0;
	for(int i = 1; i <= n ; i++){
		cin>>v[i];
		sum += v[i];
	}
	ll scoreX = solve(v,1,n,1);
	ll scoreY = sum - scoreX;
	cout<<scoreX - scoreY<<endl;
	// for(int i = 1; i <= n ; i++){
	// 	cout<<v[i]<<" ";	
	// }
	return 0;
}

Measured memory_bytes: 144632
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

struct Edge{
    int to, cost;
    Edge() = default;
    Edge(int to, int cost) : to(to), cost(cost) {}
};

vector<vector<Edge>> graph;
vector<ll> dist;

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

    int n, m;
    cin >> n >> m;
    graph.resize(n);
    dist.assign(n, 1e+15);
    for(int i = 0; i < m; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        graph[a].push_back(Edge(b, -c));
    }
    dist[0] = 0;
    for(int loop = 0; loop < n - 1; ++loop){
        for(int from = 0; from < n; ++from){
            for(auto e : graph[from]){
                int to = e.to, cost = e.cost;
                chmin(dist[to], dist[from] + cost);
            }
        }
    }
    ll ans = dist[n - 1];
    for(int loop = 0; loop < n - 1; ++loop){
        for(int from = 0; from < n; ++from){
            for(auto e : graph[from]){
                int to = e.to, cost = e.cost;
                chmin(dist[to], dist[from] + cost);
            }
        }
    }
    if(ans != dist[n - 1])  cout << "inf\n";
    else    cout << -ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  sort(A.rbegin(), A.rend());
  ll x = 0, y = 0;
  rep(i, N) {
    if(A[i] == A[i+1]) {
      if(!x) {
        x = A[i];
        i++;
      }
      else {
        y = A[i];
        break;
      }
    }
  }
  cout << x*y << endl;
  return 0;
}

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

ll MOD = 1e9 + 7;

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

  ll xx = 0, yy = 0, cx = x[0], cy = y[0];
  for (int i = 1; i < n; i++) {
    xx = (xx + i * x[i] - cx) % MOD;
    cx = (cx + x[i]) % MOD;
  }
  for (int i = 1; i < m; i++) {
    yy = (yy + i * y[i] - cy) % MOD;
    cy = (cy + y[i]) % MOD;
  }
  cout << xx * yy % MOD << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int sum[200005];
map<int,int> mp;
int main()
{
    int ans=0;
    string s;
    cin >>s;
    mp[0]=1;
    int len=s.size(),x=0,cnt=1;
    for(int i=len-1;i>=0;i--)
    {
        x=((s[i]-'0')*cnt+x)%2019;
        ans+=mp[x];
        mp[x]++;
        cnt=cnt*10%2019;
    }
    cout <<ans<<endl;
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=3e5+10;
const ll mod =  998244353;
ll fac[maxn], inv[maxn];
ll qpow(ll a,ll b)
{
	ll r=1,t=a;
	while(b)
	{
		if(b&1)
			r=(r*t)%mod;
		b>>=1;
		t=(t*t)%mod;
	}
	return r;
}
void init()
{
	fac[0] = 1ll;
	for (int i = 1; i < maxn; i++)
		fac[i] = fac[i - 1] * i % mod;
	inv[maxn - 1] = qpow(fac[maxn - 1], mod - 2);
	for (int i = maxn - 2; i >= 0; i--)
		inv[i] = inv[i + 1] * (i + 1) % mod;
}
ll c(ll n, ll m)
{
	if (n < m) 
		return 0;
	return fac[n] * inv[m] % mod * inv[n - m] % mod;
}
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int a=0,a1=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='R')
			a++;
		else
			a1++;
	}
	if(a>a1)
		cout<<"Yes\n";
	else
		cout<<"No\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
   	int N, M;
    cin >> N >> M;
  	int a[2 * M];
  	int table[N] = {0};
  	int ans = 0;
    for(int i = 0; i < 2 * M; ++i){
      cin >> a[i];
    }
  	for(int i = 0; i < 2 * M; ++i){
     	table[a[i]-1]++;
    }
  	for(int i = 0; i < N; ++i){
     	cout << table[i] << endl;
    }
}

Measured memory_bytes: 256
// A. 

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

typedef long long LL;
static const LL MOD = 1000000007LL;

class BIT {
	std::vector<int> bit;
	int size;
public:
	BIT() { }
	BIT(int sz) { init(sz); }
	void init(int sz) {
		bit = std::vector<int>((size = sz) + 1);
	}
	int sum(int i) {
		int s = 0;
		while (i > 0) {
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
	void add(int i, int x) {
		while (i <= size) {
			bit[i] += x;
			i += i & -i;
		}
	}
};

struct modll {
	long long x;
	modll() { }
	modll(long long _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(const modll &r) { return (x + r.x) % MOD; }
	modll operator+=(const modll &r) { return x = (x + r.x) % MOD; }
	modll operator-(const modll &r) { return (x + MOD - r.x) % MOD; }
	modll operator-=(const modll &r) { return x = (x + MOD - r.x) % MOD; }
	modll operator*(const modll &r) { return (x * r.x) % MOD; }
	modll operator*(int r) { return (x * r) % MOD; }
	modll operator*=(const modll &r) { return x = (x * r.x) % MOD; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

int main(int argc, char *argv[])
{
	int N;
	cin >> N;
	BIT bit(262144);
	int cnt = 0, spc = 0, prev = 0, r = 0;
	for (int i = 1; i <= N; ++i) {
		int a;
		cin >> a;
		int left = (i - spc + 1) / 2;
		bit.add(left, 1);
		bit.add(i + 1, -1);
		r += a - (prev + 1);
		if (r > 0) {
			--r;
			++spc;
		}
		prev = a;
	}
	modll ans = 1;
	for (int i = 1; i <= N; ++i) {
		ans *= bit.sum(i);
	}
	cout << ans << endl;
	return 0;
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int a, b;
    char op;
    cin >> a >> op >> b;

    switch (op) {
        case '+':
            cout << (a + b) << endl;
            break;
        case '-':
            cout << (a - b) << endl;
            break;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()

using namespace std;

typedef long long ll;

int ans, N;
map<int, bool> m;

int main() {
  scanf("%d", &N);
  rep(i, 0, N) {
    int a;
    scanf("%d", &a);
    m[a] = !m[a];
  }
  for (auto itr = m.bg; itr != m.en; itr++) {
    if (itr->second) ans++;
  
  }
  printf("%d\n", ans);

}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using ll = long long;
std::deque<ll> deq;
int n;
std::vector<int> vec;
std::map<int, int> ma;

int main() {
    long long ans = 0;
    std::cin >> n;
    deq.assign(n*3, 0);
    for (int i = 0; i <3*n; i++) {
        std::cin >> deq[i];
    }
    std::sort(deq.begin(), deq.end());
    std::reverse(deq.begin(), deq.end());
    for (int i = 0; i < n; i++) {
        deq.pop_front();
        auto e = deq.front();
        ans += e;
        deq.pop_front();
        deq.pop_back();
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 2688
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>

using namespace std;
 
const double eps=1e-10;

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

int dec(string s)
{
	int coe=1,res=0;
	for(int i=0;i<s.size();i++){
		if('0'<=s[i] && s[i]<='9') coe=s[i]-'0';
		else{
			switch(s[i]){
				case 'm': res+=1000*coe; break;
				case 'c': res+=100*coe; break;
				case 'x': res+=10*coe; break;
				case 'i': res+=coe; break;
			}
			coe=1;
		}
	}
	return res;
}

string enc(int x)
{
	stringstream s;

	int coe=x/1000;
	if(coe==1) s<<"m";
	else if(coe>1) s<<coe<<"m";

	x%=1000;
	coe=x/100;
	if(coe==1) s<<"c";
	else if(coe>1) s<<coe<<"c";

	x%=100;
	coe=x/10;
	if(coe==1) s<<"x";
	else if(coe>1) s<<coe<<"x";

	x%=10;
	coe=x;
	if(coe==1) s<<"i";
	else if(coe>1) s<<coe<<"i";

	return s.str();
}

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

	for(int i=0;i<n;i++){
		string s1,s2;
		cin>>s1>>s2;
		cout<<enc(dec(s1)+dec(s2))<<endl;
	}

	return 0;
}

Measured memory_bytes: 1224
#include<iostream>
using namespace std;
int a, b, se = 0;
int main() {
	
	cin >> a >> b;
	for (int i = a; i <= b; i++) {
		if (i == 0) {
			cout << "Zero" << endl;
			return 0;
		}
		else if(i<0){
			se++;
		}
	}
	if (se % 2 == 0) {
		cout << "Positive" << endl;
	}
	else {
		cout << "Negative" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int N,M,K;cin>>M>>N>>K;
  REP(k,0,N+1)REP(l,0,M+1){
    if(M*k+(N-k)*l-k*l==K){
      print("Yes");
      re 0;
    }
  }
  print("No");

}


Measured memory_bytes: 256
h,w = map(int,input().split())
masume = [list(["."] for _ in range(w+2))]

for i in range(h):
    masume.append(list(["."]+list(input())+["."]))
    
masume.append(list(["."] for _ in range(w+2)))

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

for i in range(1,h+1):
    for j in range(1,w+1):
        count_mine = 0
        
        if masume[i][j] == ".":
            for k in range(8):
                if masume[i+dy[k]][j+dx[k]] == "#":
                    count_mine += 1

            masume[i][j] = str(count_mine)
            
for i in range(1,h+1):
    print(*masume[i][1:-1],sep="")

Measured memory_bytes: 3572
import collections

s = input()
t = input()
c1 = collections.Counter(s)
c2 = collections.Counter(t)
s_values = sorted(list(c1.values()))
t_values = sorted(list(c2.values()))

if len(s) == len(t):
  if len(list(set(s))) == len(list(set(t))):
    if s_values == t_values:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  print("No")

Measured memory_bytes: 4144
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define size 100010
int n;
long long x;
long long gcd(long long a,long long b)
{
    if(a%b==0) return b;
    else return gcd(b,a%b);
}
int main()
{
    ios::sync_with_stdio(false);
    long long number;
    long long ans;
    while(cin>>n>>x)
    {
        cin>>number;
        ans=abs(x-number);
        for(int i=1;i<n;i++) 
        {
            cin>>number;
            ans=gcd(ans,abs(x-number));
        }
        cout<<ans<<endl;
    }
}

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

#define bs bitset<3>

int main(){
  string s;

  cin >> s;

  vector<bs> v;
  REP (i, pow(2, s.size() - 1)) {
    v.push_back(bs(i));
  }

  for(auto x:v) {
    int res = s[0] - '0';
    REP(i, 3) {
      if (x[i])
        res += s[i + 1] - '0';
      else
        res -= s[i + 1] - '0';
    }
    if (res == 7) {
      REP(i, 3) {
        cout << s[i];
        cout << (x[i] == 1 ? '+' : '-');
      }
      cout << s[3] << "=7\n";
      exit(0);
    }
  }
}


Measured memory_bytes: 256
program Project1;
     
{$APPTYPE CONSOLE}
     
uses
  SysUtils;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k:Integer;
  l:array of Integer;
  s,s123,s1,s2,s3:string;
  al:string = 'abcdefghijklmnopqrstuvwxyz';
  tf,tfl,tfr:Boolean;
begin
  try
    { TODO -oUser -cConsole メイン : ここにコードを記述してください }
    Read(a);
    Read(b);
    Readln(x);
    count:=0;
    max  :=0;

    if (a<=x)and(x<=a+b) then
      Writeln('YES')
    else
      Writeln('NO');

    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<queue>

using namespace std;

int x[4];
long long a[3][1000];
long long tmp[3000];

int main(){
	for(int i=0;i<4;i++)cin>>x[i];
	for(int i=0;i<3;i++){
		for(int j=0;j<x[i];j++)cin>>a[i][j];
	}

	priority_queue<long long> pq;
	int cnt=0;
	for(int i=0;i<x[0];i++){
		for(int j=0;j<x[1];j++){
			pq.push(-a[0][i]-a[1][j]);
			cnt++;
			if(cnt==x[3]+1){
				pq.pop();
				cnt--;
			}
		}
	}

	for(int i=0;i<cnt;i++){
		long long t = pq.top();
		tmp[i] = -t;
		pq.pop();
	}

	long long cnt2=0;
	for(int i=0;i<cnt;i++){
		for(int j=0;j<x[2];j++){
			pq.push(-tmp[i]-a[2][j]);
			cnt2++;
			if(cnt2==x[3]+1){
				pq.pop();
				cnt2--;
			}
		}
	}

	for(int i=0;i<cnt2;i++){
		long long t = pq.top();
		tmp[i] = t;
		pq.pop();
	}

	for(int i=0;i<cnt2;i++){
		cout<<(-tmp[cnt2-i-1])<<endl;
	}


	return 0;
}

Measured memory_bytes: 384
class Pline :
	def __init__(self, flag = False):
		self.m = int(raw_input())
		self.points = [map(int,raw_input().split(" ")) for i in range(self.m)]
		self.points_rev = self.points[::-1]
		self.points = self.opt(self.points)
		if flag:
			self.points_rev = self.opt(self.points_rev)
		
	def isSame (self, pline):
		return ( self.m == pline.m and (self.comp(self.points, pline.points) 
				 or self.comp(self.points_rev, pline.points)) )

	def opt(self, points):
		dzero = (0 - points[0][0],  0 - points[0][1])
		second = (points[1][0] + dzero[0], points[1][1] + dzero[1])
		if second[0] == 0:
			sign = - 1 if second[1] < 0 else 1
			points = [[sign*(x + dzero[0]), sign*(y + dzero[1])] for x, y in points]
		else :
			sign = - 1 if second[0] < 0 else 1
			points = [[-sign*(y + dzero[1]) ,sign*(x + dzero[0]) ] for x, y in points]
		return points

	def comp (self, points_a, points_b):
		for i in range(self.m):
			if points_a[i] != points_b[i]:
				break
		else :
			return True
		return False

while 1:
	n = int(raw_input())
	if n == 0:
		break
	same_list = []
	zero_pline = Pline(True)
	for i in range(1,n+1):
		pline = Pline()
		if zero_pline.isSame(pline):
			same_list.append(i)
	same_list.sort()
	for i in same_list:
		print i
	print "+++++"

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

int main() {
	long long int n=0,m,a,b,c,d,e;
	long double z,w;
	string str,str2,str3;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a;
	cout<<"ABC"<<a;




	cout<<endl;
} 


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main() {
    int N, M;
    scanf("%d%d", &N, &M);
    vector<pair<long, long>> A(N);
    for (int i=0; i<N; i++) {
      A[i] = make_pair(0, 0);
      scanf("%ld%ld", &A[i].first, &A[i].second);
    }
    sort(A.begin(), A.end());

    long res = 0;
    int tmp;
    for (int i=0; i<N; i++) {
      tmp = M-A[i].second;
      if (tmp < 0) {
        res += M*A[i].first;
        break;
      }
      M = tmp;
      res += A[i].first*A[i].second;
    }

    printf("%ld", res);
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {

	public static void main(String[] args) {
		//
		// 入力
		//
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		Map<Integer,Integer> sc_map = new HashMap<Integer, Integer>();
		boolean isUnique = true;
		boolean isExist = true;

		// 重複を取る、重複に矛盾があればその場でエラーとする
		for (int i=0; i<M; i++) {
			int s = sc.nextInt();
			int c = sc.nextInt();
			
			// 存在チェック
			if(sc_map.containsKey(s)){
				int x = sc_map.get(s);
				if(x != c){
					// 重複に矛盾
		    		System.out.println(-1);
					return;
				}
				// putはしない
			}else{
				sc_map.put(s, c);
			}
        }
        
        // ０チェック
		int answer = -1;
		if(N == 1){
			if(sc_map.containsKey(1)){
				answer = sc_map.get(1);
			}else{
				answer = 0;
			}
		}else if(N == 2){
			if(sc_map.containsKey(1)){
				if(sc_map.get(1) == 0){
					isExist = false;
				}
				answer = sc_map.get(1)* 10;
			}else{
				answer = 10;
			}
			
			if(sc_map.containsKey(2)){
				answer += sc_map.get(2);
			}

		}else if(N == 3){
			if(sc_map.containsKey(1)){
				if(sc_map.get(1) == 0){
					isExist = false;
				}
				answer = sc_map.get(1)* 100;
			}else{
				answer = 100;
			}
			
			if(sc_map.containsKey(2)){
				if(sc_map.get(2) == 0){
					isExist = false;
				}
				answer += sc_map.get(2)* 10;
			}

			if(sc_map.containsKey(3)){
				answer += sc_map.get(3);
			}
		}

        if(isUnique && isExist){
    		System.out.println(answer);
        }else{
    		System.out.println(-1);
        }
	}

}


Measured memory_bytes: 22740
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>
#include <vector>

using namespace std;

int absmax(int p, int q) {
	int a, b;
	a = p;
	b = q;
	if( a < 0 ) a *= -1;
	if( b < 0 ) b *= -1;
	if( a < b ) return b;
	return a;
}

struct pairs {
	int p, q;
	bool operator ==(const pairs &right) const{
		return ( p == right.p && q == right.q );
	}
	bool operator <(const pairs &right) const{
		return ( p == right.p ? q < right.q : p < right.p );
	}
	pairs operator *(const pairs &right) const{
		pairs ret;
		ret.p = p * right.p - q * right.q;
		ret.q = p * right.q + q * right.p;
		return ret;
	}
};

int main(void){
//	FILE* fp_in = freopen("data.txt", "r", stdin);
	int N;
	cin >> N;
	string ans[] = { "C", "P" };

	for(int i = 0; i < N; i++) {
		pairs p, q;
		vector< pairs > sp;
		cin >> p.p >> p.q;
		for( q.p = - absmax(p.p, p.q) ; q.p <= absmax(p.p, p.q); q.p ++) {
			for( q.q = - absmax(p.p, p.q); q.q <= absmax(p.p, p.q); q.q ++) {
				int tmp = q.p * q.p + q.q * q.q;
				if( tmp > 0 && ( ( q.p * p.p + q.q * p.q ) % tmp == 0 ) && 
					( q.p * p.q - q.q * p.p ) % tmp == 0 ) {
						sp.push_back( q );
				}
			}
		}
		cout << ans[sp.size() == 8] << endl;
	}
//	while(1){}
	return 0;
}

Measured memory_bytes: 1224
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, a, b) for (long i = a; i < b; ++i)
#define REP(i, n) for (long i = 0; i < n; ++i)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

int main() {
  long n;
  cin >> n;
  vector<long> A(1000001, 0);
  FOR(i, 1, 1000000) {
    FOR(j, i + 1, (1000000 + i) / i) { A[i * j] += 2; }
  }
  FOR(i, 1, 1001) { A[i * i] += 1; }
  long ans = 0;
  FOR(i, 1, n) { ans += A[i]; }
  cout << ans << endl;
}


Measured memory_bytes: 11140
#include <cstdio>
#include <algorithm>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')

//------------------------------------------------------------------------------
#define SZ      (sz * 2 - 1)
#define LF(i)   (i + sz - 1)
#define PA(k)   ((k - 1) / 2)
#define LC(k)   (k * 2 + 1)
#define RC(k)   (k * 2 + 2)
#define M(l,r)  ((l + r) / 2)

const int ST_SIZE = 1 << 18;    // N_MAX * 2 - 1

int sz;
int dat[ST_SIZE];

void rmq_init(int n) {
  sz = 1;
  while (sz < n) sz <<= 1;
}

int query(int i) {
  int k = LF(i);
  int ret = dat[k];
  while (k > 0) {
    k = PA(k);
    ret += dat[k];
  }
  return ret;
}

void add_sub(int a, int b, int k, int l, int r) {
  if (r <= a || b <= l) return;
  if (a <= l && r <= b) dat[k]++;
  else {
    add_sub(a, b, LC(k), l, M(l, r));
    add_sub(a, b, RC(k), M(l, r), r);
  }
}

void add(int a, int b) {
  add_sub(a, b, 0, 0, sz);
}

//------------------------------------------------------------------------------
const int N_MAX = 300000;
const int M_MAX = 100000;

struct rng { int w, l, r; };
int N, M;
rng a[N_MAX];

bool compare_w(const rng& r1, const rng& r2) {
  return r1.w < r2.w;
}

void solve() {
  sort(a, a + N, compare_w);
  rmq_init(M + 1);
  int i = 0;
  FOR(d, 1, M) {
    while (i < N && a[i].w < d) {
      // printf("w: %d, l:%d, r: %d\n", a[i].w, a[i].l, a[i].r);
      add(a[i].l, a[i].r + 1);
      // DUMP(dat, SZ);
      i++;
    }
    int ans = N - i;
    if (i > 0) {
      for(int e = d; e <= M; e += d) {
        ans += query(e);
      }
    }
    printf("%d\n", ans);
  }
}

void input() {
  scanf("%d%d", &N, &M);
  REP(i, N) {
    int l, r, w;
    scanf("%d%d", &l, &r);
    a[i] = { r - l + 1, l, r };
  }
}

int main() {
  input();
  solve();
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  
  int AC = 0, WA = 0, TLE = 0, RE = 0;
  string judge;
  
  for (int i = 0; i < N; i++){
    cin >> judge;
    if (judge == "AC") AC += 1;
    if (judge == "WA") WA += 1;
    if (judge == "TLE") TLE += 1;
    if (judge == "RE") RE += 1;
  }

  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE;

  return 0;
}

Measured memory_bytes: 3248
<?php
//error_reporting(0);
//$S = trim(fgets(STDIN));
list($N,$M,$C) =  explode(" ",trim(fgets(STDIN)));
$B = explode(" ",trim(fgets(STDIN)));
$ret=0;
for($i=0;$i<$N;$i++) {
  $A=explode(" ",trim(fgets(STDIN)));
  if (chk($B,$A)) {
    $ret++;
  }
}
printf("%d\n",$ret);

function chk($B,$A) {
  global $M,$C;
  $s=0;
  for($i=0;$i<$M;$i++) {
    $s += $B[$i]*$A[$i];
  }
  $s+=$C;
  return $s > 0;
}


Measured memory_bytes: 4728
#include<bits/stdc++.h>
#pragma O3
#define int long long
using namespace std;
int a[3],b[3],ab[5001],ba[5001*5001];
signed main(){
//	freopen(".inp","r",stdin);
//	freopen(".out","w",stdout);
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<3;i++) cin>>a[i];
	for(int i=0;i<3;i++) cin>>b[i];
	for(int i=0;i<=n;i++){
		for(int j=0;j<3;j++){
			if(i-a[j]>=0) ab[i]=max(ab[i],ab[i-a[j]]+b[j]-a[j]);
		}
	}
	n+=ab[n];
	for(int i=0;i<=n;i++){
		for(int j=0;j<3;j++){
			if(i-b[j]>=0) ba[i]=max(ba[i],ba[i-b[j]]+a[j]-b[j]);
		}
	}
	n+=ba[n];
	cout<<n;
}

Measured memory_bytes: 195584
#include <bits/stdc++.h>
using namespace std;
int n,v,l[200005],b,e;
int main()
{
    cin>>n;
    b=ceil((double)(n+1)/2);
    e=(n%2==0)?(-1):(1);
    for(int i=1;i<=n;i++)
	{
        cin>>v;
        l[b]=v;
        b+=i*e;
        e*=-1;
    }
    for(int i=1;i<=n;i++)
    cout<<l[i]<<" ";
    return 0;
}

Measured memory_bytes: 2944
import math

n = int(input())
p = list(map(int, input().split()))

q = list(map(int, input().split()))

ord1 = 0
flag = [0] * (n+1)
for i in range(n-1):
	ln = 0
#	print(type(p[i]), p[i])
	for c in range(1,p[i]):
		if flag[c] == 0:
			ln = ln + 1 
	flag[p[i]] = 1
	ord1 = ord1 + ln * math.factorial(n-1-i)
#	print(ln,  math.factorial(ln))
ord1 = ord1+1 
#print(ord1)
  
ord2 = 0
flag = [0] * (n+1)
for i in range(n-1):
	ln = 0
#	print(type(q[i]), q[i])
	for c in range(1,q[i]):
		if flag[c] == 0:
			ln = ln + 1 
	flag[q[i]] = 1
	ord2 = ord2 + ln * math.factorial(n-1-i)
#	print(ln,  math.factorial(ln))
ord2 = ord2+1 
#print(ord2)

print(abs(ord2 - ord1))

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

int main() {
  int n;
  cin >> n;
  int count = 0;
  map <string, int> paper;
  for(int i = 0; i < n; i++){
    string s;
    cin >> s;
    if (paper.count(s)) {
    paper.at(s)++;
    }
    else{
      paper[s] = 1;
    }
  }
  for (auto p : paper) {
  auto v = p.second;
  count = max(count, v);
  }
  for (auto p : paper) {
  auto k = p.first;
  auto v = p.second;
  if(v == count){
    cout << k << endl;
  }
  }
  

  return 0;
}

Measured memory_bytes: 25216
n = int(input())
b = list(map(int,input().split()))
a = list()
pre = 100100100
for bb in b:
  if bb != pre:
    a.append(bb)
    pre = bb
  
print(a[0],end="")
for aa in a[1:]:
  print(" {}".format(aa),end="")
print()



Measured memory_bytes: 16644
/*input
1333333333

*/

#include <bits/stdc++.h>

using namespace std;

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

  int64_t x;
  cin >> x;

  int64_t s = 100;
  int c = 0;
  while (s < x) {
    s += (s / 100);
    c++;
  }

  cout << c << endl;
  return 0;
}

Measured memory_bytes: 3628