akhauriyash/Code-Regression huggingface dataset:
#include <sstream>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<ctime>
#include<cmath>
#include<map>
#include<unordered_map>
#include<stack>
#include<random>
#include<queue>
#include<list>
#include<math.h>
#include<bitset>
#include<fstream>
using namespace std;
#define ll long long int
#define ld long double
#define key pair<ld,ld>
#define ii pair<int,int>
#define si set<int>
#define vii vector<pair<int,int> >
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int> >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define nu 100001
#define mul(x,y) ((ll)(x)*(y))%mod
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (int i = 0; i < int(n); i++)
#include<fstream>
const ll INF=9223372036854775807;
const ll mod=998244353;
int  MOD(int  a, int  b)
{
    if(a>b)
        return a-b;
    else
        return b-a;
}
ll  max3(ll  a,ll  b, ll  c)
{
    return max(c,max(a,b));
}
ll min3(ll  a,ll  b,ll  c)
{
    return min(a,min(b,c));
}
ll  power(ll  x,ll  y,ll mod1)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x)%mod1;
        y = y>>1;
        x = (x*x)%mod1;
    }
    return res;
}
ll logg(ll  a)
{
    ll  x=0;
    while(a>1)
    {
        x++;
        a/=2;
    }
    return x;
}
ll  gcd(ll  a,ll   b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll abso(ll x)
{
    if(x<0)
    {
        return -x;
    }
    return x;
}
ll ceiling (ll  a,ll  b)
{
    if(a%b==0)
    {
        return a/b;
    }
    else
    {
        return a/b+1;
    }
}
ll modinv(ll x,ll p)
{
    return power(x,p-2,p);
}
int main()
{
    ll a,b;
    cin>>a>>b;
    ll t=(a+b)/2;
    if(abso(a-t)==abso(b-t))
    {
        cout<<t<<endl;
    }
    else
    {
        cout<<"IMPOSSIBLE"<<endl;
    }
}


Measured memory_bytes: 764
# coding: utf-8

N = int(input())
T, A = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]

def mean_temp_diff (x):
  return abs(A - (T - x * 0.006))

min_diff = 10000
min_idx = 0

for i in range(len(H)):
  mtd = mean_temp_diff(H[i])
  if mtd < min_diff :
    min_diff = mtd
    min_idx = i

print(min_idx + 1)

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

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

MOD = 1000000007

R = 0
B = 0
G = 0

ans = 1
for a in A:
    #print(a, ans, R)
    count = 0
    if a == R:
        count += 1
    if a == B:
        count += 1
    if a == G:
        count += 1

    ans *= count

    if a == R:
        R += 1
    elif a == B:
        B += 1
    elif a == G:
        G += 1
    ans %= MOD

print(ans)
    

        


Measured memory_bytes: 13932
#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <map>

using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)


int main() {
    int n;
    cin >> n;
    vector<pair<ll, ll> > pairs(n);
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        pairs[i] = make_pair(b, a);
    }
    sort(pairs.begin(), pairs.end());//pairのソートは第一成分で実行される
    rep(i, n) {
        if (i != 0)pairs[i].second += pairs[i - 1].second;
        if (pairs[i].second > pairs[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;


    return 0;
}

Measured memory_bytes: 5964
#include <iostream>
#include <memory>
#include <string>
#include <vector>

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

using lint = long int;
using llint = long long int;
using namespace std;

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

    int idx = 1;
    llint sum = 0;
    while (true) {
        if (idx % 15 != 0 && idx % 3 != 0 && idx % 5 != 0) {
            sum += idx;
        }
        if (idx == n)
            break;
        idx++;
    }
    cout << sum << endl;
}



Measured memory_bytes: 3604
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 300010
#define LL long long
int lazy[MAXN*4],col[MAXN*4];
int a[MAXN*2],n,K,tot;
void PushDown(int i)
{
	if(lazy[i])
	{
		col[i<<1]=col[i<<1|1]=lazy[i<<1]=lazy[i<<1|1]=lazy[i];
		lazy[i]=0;
	}
}
void Change(int i,int l,int r,int L,int R,int k)
{
	if(L>R) return;
	if(L<=l&&r<=R)
	{
		col[i]=lazy[i]=k;
		return;
	}
	PushDown(i);
	int mid=(l+r)/2;
	if(L<=mid) Change(i<<1,l,mid,L,R,k);
	if(R>mid) Change(i<<1|1,mid+1,r,L,R,k);
}
int Query(int i,int l,int r,int k)
{
	if(l==r) return col[i];
	PushDown(i);
	int mid=(l+r)>>1;
	if(k<=mid) return Query(i<<1,l,mid,k);
	return Query(i<<1|1,mid+1,r,k);
}
int l[MAXN],r[MAXN];
LL f[MAXN];
LL Ask(int k)
{
	int pos=Query(1,1,tot,k);
	return pos?(f[pos]+(a[l[pos]]-a[k]+K)%K):0;
}
LL sum[MAXN];
int main()
{
	int typ;
	scanf("%d%d",&n,&K);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&sum[i],&typ);
		sum[i]+=sum[i-1];
		if(typ==2) l[i]=0,r[i]=K-1;
		else l[i]=(K-2*sum[i-1]%K)%K,r[i]=(K-2*sum[i]%K)%K;
		if(typ==1&&2*(sum[i]-sum[i-1])>K)
		{
			printf("-1\n");
			return 0;
		}
		a[++tot]=l[i],a[++tot]=r[i];
	}
	sort(a+1,a+1+tot);
	tot=unique(a+1,a+1+tot)-a-1;
	for(int i=1;i<=n;i++)
	{
		l[i]=lower_bound(a+1,a+1+tot,l[i])-a;
		r[i]=lower_bound(a+1,a+1+tot,r[i])-a;
	}
	for(int i=n;i;i--)
	{
		f[i]=Ask(l[i]);
		if(l[i]>r[i]) Change(1,1,tot,r[i]+1,l[i]-1,i);
		else Change(1,1,tot,1,l[i]-1,i),Change(1,1,tot,r[i]+1,tot,i);
	}
	LL ans=f[1];
	for(int i=tot;i;i--)
		ans=min(ans,Ask(i));
	printf("%lld\n",ans+2*sum[n]);
}

Measured memory_bytes: 15232
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define PI       3.1415926535897932384626433832795028841971
#define INF      5000000000000000000
#define EPS      1e-10
#define MOD      1000000007
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;

struct UF{
	int par[100000];
	int rank[100000];
	int si[100000];

	void init(int n){
		rep(i,n){
			par[i] = i;
			rank[i] = 0;
			si[i] = 1;
		}
	}

	int find(int x){
		if(par[x] == x) return x;
		else return par[x] = find(par[x]);
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		
		if(rank[x] < rank[y]){
			par[x] = y;
			si[y] += si[x];
		} else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
			si[x] += si[y];
		}
	}

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

int n, m;
int k;
UF uf;
vector<int> e[100000];

int main(){
    cin >> n >> m;
    uf.init(n);
    rep(i,n){
        int k;
        cin >> k;
        rep(j,k){
            int m;
            cin >> m;
            m--;
            e[m].push_back(i);
        }
    }
    rep(i,m){
        for(int j = 1; j < e[i].size(); j++){
            uf.unite(e[i][0],e[i][j]);
        }
    }
    int cnt = 0;
    rep(i,n){
        if(uf.par[i] == i){
            cnt++;
        }
    }
    if(cnt > 1) cout << "NO" << endl;
    else cout << "YES" << endl;
}


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

int main(){
  long long A,B; cin >> A >> B;
  

  if( (A+B)%2 == 0 ){
    cout << (A+B)/2 << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl; 
  }
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  [a, b, c, d] <- map (read::String -> Int) . words <$> getLine
  let left = a + b
      right = c + d
  putStrLn $ if left > right then "Left" else if right > left then "Right" else "Balanced"




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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	string s;
	cin >> s;
	vector<ll>arr(s.size() + 1);
	rep(i, s.size() + 1) {
		if (i == 0)arr[i] = (s[i] == '<') ? 0LL : 1LL;
		else if (i == s.size())arr[i] = (s[i-1] == '>') ? 0 : arr[i - 1] +1LL;
		else {
			if (s[i - 1] == '>' && s[i] == '<')arr[i] = 0;
			else if (s[i - 1] == '<')arr[i] = arr[i - 1] + 1LL;
			else arr[i] = 0LL;
		}
	}

	for (int i = s.size()-1; i >=0;i--) {
		if (s[i] == '>')arr[i] = max(arr[i + 1] + 1LL,arr[i]);
	}
	if (s[0] == '>')arr[0] = arr[1] + 1LL;

	ll sum = accumulate(all(arr),0LL);
	cout << sum << endl;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
int a[15];
int b[15];
int c[15][15];

int need;
void go(int ind) {
    set<int> bad;
    forn(i, ind) {
        bad.insert(a[i]);
        forn(j, i) {
            bad.insert(a[i] + a[j]);
        }
    }
    int ways = 0;
    int beg = 1;
    if (ind > 0) {
        beg = a[ind - 1];
    }
    for (int j = beg; ; ++j) {
        if (bad.count(j)) {
            continue;
        }
        bool ok = true;
        forn(i, ind) if (bad.count(a[i] + j)) {
            ok = false;
            break;
        }
        if (!ok) {
            continue;
        }
        ++ways;
        a[ind] = j;
        if (ind == need - 1) {
            if (a[ind] + a[ind - 1] < b[ind] + b[ind - 1]) {
                memcpy(b, a, sizeof b);
            }
        } else {
            go(ind + 1);
        }
        if (ways == 3) {
            break;
        }
    }
}

LL ans[10][10];

int main() {
    for (need = 1; need <= 9; ++need) {
        forn(i, need) b[i] = 1234;
        go(0);
        forn(i, need) c[need][i] = b[i];
        int cur = 1 + b[need - 1];
        if (need > 1) {
            cur += b[need - 2];
        }
    }

    cin >> n;
    LL mul = 1;
    for (int i = n - 1; i >= 1; --i) {
        forn(j, i) {
            ans[i][j] = ans[j][i] = c[i][j] * mul;
        }
        if (i > 1) {
            mul *= c[i][i - 2] + c[i][i - 1] + 1;
        }
    }
    forn(i, n) {
        forn(j, n) cout << ans[i][j] << ' ';
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 2000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
//const ll MOD = 67280421310721ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう！


int main(){
    int n,g;
    std::cin >> n>>g;
    std::vector<int> p(n),c(n);
    rep(i,n)std::cin >> p[i]>>c[i];
    int ans=INF;
    brep(n){
        int d=0,cc=0;
        priority_queue<int> q;
        rep(i,n){
           if(bit&(1<<i)){
                d+=c[i];
                d+=(i+1)*100*p[i];
                cc+=p[i];
           }
           else{
               rep(j,p[i]){
                   q.push((i+1)*100);
               }
           }
        }
      //  std::cout << d << std::endl;
        if(d>=g){
            chmin(ans,cc);
            continue;
        }
        while(!q.empty()){
            int i=q.top();
            cc++;
            d+=i;
            if(d>=g){
                chmin(ans,cc);
                break;
            }
            q.pop();
        }
        
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100

int graph[MAX+1][MAX+1];
int d[MAX+1];
int f[MAX+1];

int n;
int t;
void dfs(int id){
  int i;
  if(id!=0)
    t++;
  d[id]=t;
  for(i=1;i<=n;i++) {
    if(graph[id][i] != 0 && d[i] == 0) {
      dfs(i);
    }
  }
  if(id != 0)
    t++;
  f[id] = t;
}

int main() {
  int i,j;
  scanf("%d\n",&n);
  for(i=0;i<=n;i++){
    graph[0][i]=1;
  }
  int u,k,v;
  for(i=0;i<n;i++){
    scanf("%d %d ",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d ",&v);
      graph[u][v]=1;
    }
  }
  dfs(0);
  for(i=1;i<=n;i++) {
    printf("%d %d %d\n",i,d[i],f[i]);
  }
  return 0;
}


Measured memory_bytes: 2052
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<double, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

int main() {
	int k;
	cin >> k;
	int x = 7 % k;
	int i = 1;
	set<int>s;
	while (s.count(x)==0) {
		if (x == 0) {
			cout << i << endl;
			return 0;
		}
		s.insert(x);
		x = (x * 10 + 7) % k;
		++i;
	}
	cout << -1 << endl;
	return 0;
}

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


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

  vector<char> data(N);

  for(int i = 0 ;i< N;i++){
    cin >> data.at(i);
 //       cout << data.at(i) << endl;
  }


  int ref = 1;
  //char col = data.at(0);
  
  for ( int i = 0;i < N-1;i++){
//    cout << data.at(i) << ":" << data.at(i+1) << endl;
    if(data.at(i) == data.at(i+1)){
    }
    else{
      ref++;
//      cout << ref << endl;
    } 
  }

  
  cout << ref << endl;
}







Measured memory_bytes: 384
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
#include "tuple"

#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n,i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define intinf 1000000000
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;


int main() {
	int n, a, b;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
	}
	else {
		cin >> a >> b;
		cout << a + b << endl;
	}
	return 0;
}


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

int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(a[a[i]-1]==i+1) ans++;
    }
    cout<<ans/2<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long x,y,a,ans;
int main()
{
	scanf("%lld %lld",&x,&y);
	a=x;ans=1;
	while(a*2<=y)
	{
		a*=2;
		ans++;
	}
	printf("%lld",ans);
	return 0; 
}

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

typedef long long i64;
const int MAX_N = 105, MOD = 998244353, base = 7;

map<i64, int> mp;
string S;

i64 gethash(string s) {
  i64 h = 0;
  for (int i = 0; i < s.length(); ++i)
    h = h * base + s[i] - 'a' + 1;
  return h;
}

i64 dfs(string s) {
  if (s == "") return 1;
  i64 hs = gethash(s);
  if (mp.count(hs) != 0) return mp[hs];
  int l = s.length();
  i64 res = (s[0] - '0' + 1) * dfs(s.substr(1, l - 1)) % MOD;
  
  for (int i = 1; i <= l; ++i)
    for (int j = 2; i * j <= l; ++j) {
      int len = i * j;
      static string temp = "";
      temp = "";
      for (int k = 0; k < i; ++k) {
	bool flag = 1;
	for (int x = 0; x < j; ++x)
	  if (s[k + x * i] == '0') {
	    flag = false;
	    break;
	  }
	if (flag) temp += '1';
	else temp += '0';
      }
      res = (res + dfs(temp) * dfs(s.substr(len, l - len)) % MOD) % MOD;
    }
  
  return mp[hs] = res;
}

int main() {
  cin >> S;
  printf("%lld\n", dfs(S));
  return 0;
}


Measured memory_bytes: 3072
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
typedef long long int ll;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define MOD 1000000007
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);  
//*s.find_by_order(p)   returns the value of pth largest starting from 0 
//s.order_of_key(p)   returns no. of items that are strictly < p 
//string bin = bitset<64>(m).to_string();     convert decimal m to binary
int main()
{
	fast;ll t1;t1=1;
	while(t1--)
	{
		ll n,ans=0,i,a,j,k;
		cin>>n;
		vector<ll>v;
		for(i=0;i<n;i++)
		{
			cin>>a;
			v.pb(a);
		}
		for(i=0;i<n;i++){
			for(j=i+1;j<n;j++){
				for(k=j+1;k<n;k++){
					if(v[i]==v[j] || v[i]==v[k] || v[j]==v[k]){continue;}
					if(v[i]+v[j]>v[k] && v[i]+v[k]>v[j] && v[j]+v[k]>v[i]){ans++;}
					//cout<<v[i]<<" "<<v[j]<<" "<<v[k]<<" "<<i<<" "<<j<<" "<<k<<"\n";
				}
			}
		}
		cout<<ans<<"\n";
	}

}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int D;
    cin >> D;

    if (D == 25){
        cout << "Christmas" << endl;
    }
    else if (D == 24){
        cout << "Christmas Eve" << endl;
    }
    else if (D == 23){
        cout << "Christmas Eve Eve" << endl;
    }
    else {
        cout << "Christmas Eve Eve Eve" << endl;
    }
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	s := nextString()
	num1 := 1
	num2 := 0
	if s[1] == s[0] {
		num1 += 1
		if s[2] != s[0] {
			num2 += 1
			if s[3] == s[2] {
				fmt.Println("Yes")
				return
			}
		}

	} else {
		num2 += 1
		if s[2] == s[0] {
			num1 += 1
			if s[3] == s[1] {
				fmt.Println("Yes")
				return
			}
		} else if s[2] == s[1] {
			if s[3] == s[0] {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
    int n,i;
    int fib[45];
    fib[0]=1;
    fib[1]=1;
    scanf("%d",&n);
    for(i=2;i<=n;i++){
        fib[i]=fib[i-1]+fib[i-2];
    }
    printf("%d\n",fib[n]);
    return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,i,j;scanf("%d%d",&n,&k);
  int h[n],dp[n] = {};
  for(i=1;i<n;i++) dp[i] = 1000000000;
  for(i=0;i<n;i++) scanf("%d",&h[i]);
  for(i=1;i<n;i++){
    for(j=1;j<=k;j++){
      if(i>=j) dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
  }
  printf("%d\n",dp[n-1]);
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;
long long n, k, mn=1e18, x=-1, a[N], lt[N], rt[N];
int main() {
	long long i, j, t;
	scanf("%d%d", &n, &k);
	for(i=0; i<n; i++) {
		scanf("%lld", &a[i]);
		if(a[i]<0) x = i;
	}
	for(i=x, j=1; i>=0; i--, j++) lt[j] = -a[i];
	for(; j<=k; j++) lt[j] = 1e9;
	for(i=x+1, j=1; i<n; i++, j++) rt[j] = a[i];
	for(; j<=k; j++) rt[j] = 1e9;
	for(i=0; i<=k; i++) {
		t = lt[i] + rt[k-i] + min(lt[i], rt[k-i]);
		mn = min(mn, t);
	}
	printf("%lld", mn);
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Union Find tree
//-------------------------------------------------
class UnionFind
{
private:
    ::std::vector<int> par;
    ::std::vector<int> rank;
public:
    UnionFind(int n):par(n), rank(n){
        for(int i=0; i<n; i++){
            par[i] = i;
            rank[i] = 0;
        }
    }
    int root(int x){
        if (par[x]==x) return x;
        return par[x] = root(par[x]);
    }
    bool same(int x, int y){
        return root(x)==root(y);
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if (rx==ry) return;
        if (rank[rx]>rank[ry]){
            par[ry] = rx;
        }else{
            par[rx] = ry;
            if (rx==ry) rank[ry]++;
        }
    }
};

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,k; cin>>n>>m>>k;
    UnionFind uf(n);
    vi cnt(n,1);
    rep(i,m){
        int a,b; cin>>a>>b; a--; b--;
        uf.unite(a,b);
        cnt[a]++; cnt[b]++;
    }
    map<int,int> M;
    rep(i,n){
        int r = uf.root(i);
        M[r]++;
    }
    rep(i,k){
        int a,b; cin>>a>>b; a--; b--;
        if (uf.same(a,b)){
            cnt[a]++;
            cnt[b]++;
        }
    }
    rep(i,n){
        if (i>0) cout<<" ";
        int r = uf.root(i);
        cout<<M[r]-cnt[i];
    }
    return 0;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  bool Q=true;
  for(int i=1;i<1001;i++){
    if(i*8/100==A&&i/10==B){
     Q=false;
     cout<<i<<endl;
     break;
    }
  }
  if(Q){
    cout<<-1<<endl;
  }
}
     

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

int main(){
	while(1){
	int n;
	cin>>n;
	
	if(n==0) break;
	
	int x[20],y[20];
	for(int i=0;i<n;i++) cin>>x[i]>>y[i];
	
	int vx=10,vy=10;
	int ans[20];
	for(int i=0;i<n;i++) ans[i]=0;
	
	int m;
	cin>>m;
	char s[30];
	int l[30];
	for(int i=0;i<m;i++){
		cin>>s[i]>>l[i];
		
		for(int j=0;j<l[i];j++){
			if(s[i]=='N') vy++;
		    else if(s[i]=='E') vx++;
		    else if(s[i]=='S') vy--;
		    else vx--;
		
		    for(int k=0;k<n;k++){
				if(vx==x[k]&&vy==y[k]) ans[k]=1;
			}
		}
	}
	
	
	int tmp=1;
	for(int i=0;i<n;i++){
		if(ans[i]==0){
			tmp=0;
			break;
		}
	}
	
	
	cout<<((tmp)?"Yes":"No")<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 3096
n = int(input())
l=[input() for x in range(n)]
ll=[]
cont=0
if len(l)==len(set(l)):
    for i in range(n):
        ll.append(list(l[i]))
    for i in range(n-1):
        if ll[i][-1]==ll[i+1][0]:
            cont+=1
    if n-1==cont:
        print("Yes")
    else:
        print("No")                

else:
    print("No")

Measured memory_bytes: 3064
#include <numeric>
#include <iostream>
#include <array>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <queue>


using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vvi = vector<vi>;
const ll MOD = 1e9 + 7;
vi alphabet = { 'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z' };



int main() {
    int N, M;
    cin >> N >> M;
    vi a(M);
    vi b(M);
    rep(i, M) {
        cin >> a[i];
        cin >> b[i];
    }
    int count = 0;

    rep(i, M) {
        vvi g(N + 1);
        rep(j, M) {
            if (i == j) continue;
            g[a[j]].push_back(b[j]);
            g[b[j]].push_back(a[j]);
        }
        
        vi dist(N + 1, -1);
        dist[1] = 0;        
        queue<int> q;
        q.push(1);
        
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            for (int u : g[v]) {
                if (dist[u] != -1) continue;
                q.push(u);
                dist[u] = dist[v]+1;
            }
        }


        
        for (int k = 1; k < N + 1;k++) {
            if (dist[k] == -1) {
                count++;
                break;
            }
        }
    }
    cout << endl;
    cout << count << endl;
}

Measured memory_bytes: 256
//    #include "grader.h"
    #include <bits/stdc++.h>  
     
    using namespace std;
    #define forn(i, n) for (int i = 0; i < int(n); i++)
    #define re return
    #define fi first
    #define mp make_pair
    #define se second
    #define sz(a) (int)a.size()
    #define prev previ
    #define tm tmmm
    #define div divv
    typedef long long ll;
    typedef pair<ll, ll> pll;
    typedef pair<int, int> pii;
     
    const ll mod = ll(1e9) + 9LL, pr = 239, mod2 = ll(1e9) + 7;
     
    int n, p, sum, k[2];
    ll cnt[100][100];
     
    int main() {
    	iostream::sync_with_stdio(0), cin.tie(0);
    	cin >> n >> p;
    	forn (i, n) {
    		int a;
    		cin >> a;
    		k[a % 2]++;
    		sum = (sum + a) % 2;
    	}
    	int k1 = 0;
    	if ((sum + p) % 2)
    		k1 = 1;
    	ll ans = 1;
    	forn (i, k[0])
    		ans = ans * 2LL;
    		cnt[0][0] = 1;
    	for (int i = 1; i < 100; i++) {
    		cnt[i][0] = 1;
    		for (int j = 1; j <= i; j++)
    			cnt[i][j] = cnt[i - 1][j] + cnt[i - 1][j - 1];
    	}
    	sum = 0;
    	for (int i = k1; i <= k[1]; i += 2)
    		sum += cnt[k[1]][i];
    	ans *= sum;
    	cout << ans;
    }

Measured memory_bytes: 384
import sys
import math

# python3にlongの概念はない
N = int(input())
M = int(math.sqrt(N))
# N**0.5でも可能
number = 1
ans = 1

for i in range(1, M+1):
    if N % i == 0:
        number = i

number = math.floor(N/number)
ans = len(str(number))

print(ans)

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)

#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(void)
{
    int i=0;
    string c;
    getline(cin,c);

    REP(i,c.size()) {
        if(c[i]>='a'&&c[i]<='z') cout<<char(c[i]-0x20);
        else if(c[i]>='A'&&c[i]<='Z') cout<<char(c[i]+0x20);
        else cout<<c[i];
    }
    cout<<endl;

}



Measured memory_bytes: 3176
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#define pb push_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define upmin(ans,ansx) (ans)=min((ans),(ansx))
#define upmax(ans,ansx) (ans)=max((ans),(ansx))
#define INF (1100000099)
#define INFLL (1100000000000000099ll)
#define MOD (1000000009)
#define MAXN (200005)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

vector<char> V;
char str[MAXN];
int N;

int main() {
    scanf(" %s", str); N = (int)strlen(str);
    for(int i = 0; i < N; i++) {
        if(!V.empty() && V.back() == 'S' && str[i] == 'T') V.pop_back();
        else V.pb(str[i]);
    }
    printf("%d\n", sz(V));
    return 0;
}

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

int main()
{
    ll a,b,c;
    cin >> a >> b >> c;
    if(c<=a+b) {
        cout << "No" << endl;
    }
    else {
        if(4*a*b < (c-a-b)*(c-a-b)) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
N, K = map(int,input().split())
ls = [0]+[0]*10**5
for i in range(N):
    a,b = map(int,input().split())
    ls[a] += b
ii = 0
for i in range(1,10**5+1):
    ii += ls[i]
    if ii >= K:
        ans = i
        break
    else:
        continue
print(ans)

Measured memory_bytes: 11688
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll MOD = 1e9+7;
ll H, N, M, L, K, W, X, Y, Z;
ll ans = 0;
int main() {
	int A, B, C;
	cin >> A >> B >> C;
	int maxn = max(A, max(B, C));
	ans = maxn * 10 + A + B + C - maxn;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(void) {
  long n;
  long m = 1000000007;
  scanf("%ld", &n);
  long r = 1;
  for(int i = 0;i<n;r = (r * ++i) % m) {
  }
  printf("%ld\n", r);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
typedef vector<int> vi;
typedef vector<double> vd;
 
double mypow(double b ,int e){
      if(e == 0) return 1;
      if(e%2==0)
            return mypow( b*b, e/2 );
      else
            return mypow( b*b, e/2 ) * b;
}
 
int main(){
 
 
      int N,M,L; cin >> N >> M >> L ;
      if(N==1){
            cout << 1.0 << endl;
            return 0;
      }
      vector<vd> prob(N,vd(M+1,0.0));
      vector<vd> dist(N,vd(M+1,0.0));
 
      vd p(N),t(N),v(N);
      for(int i=0; i<N; i++) cin >> p[i] >> t[i] >> v[i];
 
      // PRE PROCESS
      for(int i=0; i<N; i++){
            dist[i][0] = (double)L / v[i];
            for(int j=1; j<=M; j++){
                  dist[i][j] = dist[i][j-1] + t[i];
            }
      }
      for(int i=0; i<N; i++)
            prob[i][0] = mypow((100-p[i])/100,M);
      for(int i=0; i<N; i++){
            for(int j=1; j<=M; j++){
                  if(p[i] != 100)
                        prob[i][j] = (prob[i][j-1] * (p[i]/100)) / ((100-p[i])/100);
                  else
                        prob[i][j] = 1.0;
            }
      }
      double comb = 1;
      for(int j=1; j<=M; j++){
            comb = comb * (M - j + 1) / j; 
            for(int i=0; i<N; i++){
                  prob[i][j] *= comb;
            }
      }
       
      vector<vd> sum = prob;
      for(int i=0; i<N; i++){
            for(int j=M-1; j>=0; j--){
                  sum[i][j] += sum[i][j+1];
                  if(sum[i][j] > 1) sum[i][j] = 1;
            }
      }
 
      vector<vd> ans = prob;
      for(int i=0; i<N; i++){
            for(int j=0; j<=M; j++){
                  for(int k=0; k<N; k++){
                        if(i==k) continue;
                        int id = upper_bound(dist[k].begin(),dist[k].end(), dist[i][j]) - dist[k].begin();
                        if(id > M) ans[i][j] = 0.0;
                        else       ans[i][j] *= sum[k][id];
 
                  }
            }
      }
 
      for(int i=0; i<N; i++){
            double tmp = 0.0;
            if(p[i] == 100) tmp = ans[i][M];
            else
                  for(int j=0; j<=M; j++)
                        tmp += ans[i][j];
            if(tmp > 1) tmp = 0;
            printf("%.10f\n",tmp);
      }
                         
}

Measured memory_bytes: 3408
#include<bits/stdc++.h>
using namespace std;
int mod=1e9+7;

void add_self(int& a,int b){
  a+=b;
  if(a>=mod) a-=mod;
}
int main()
{
    string s;
    int d;
    cin>>s;
    cin>>d;
    vector<vector<int>> dp1(d,vector<int>(2));
    //v[i][0] represent the number of possible digit whose sum is i and is smaller than the given number;
    // 1 represent the equal to case
    int len=s.length();
    dp1[0][0]=1;

    for(int index=0;index<len;index++){
        vector<vector<int>> dp(d,vector<int>(2));
        for(int sum=0;sum<d;sum++){
            for(bool smaller:{true,false}){
                for(int i=0;i<=9;i++){
                    if(s[index]-'0'<i && !smaller) break;
                    /*
                    if(smaller)
                    add_self(dp[(sum+i)%d][0],dp1[sum][0]);
                    else if(!smaller && s[index]-'i'>i)
                    add_self(dp[(sum+i)%d][0],dp1[sum][1]);
                    else
                     add_self(dp[(sum+i)%d][1],dp1[sum][1]);*/
                     add_self(dp[(sum+i)%d][smaller|| i<s[index]-'0'],dp1[sum][smaller]);
                }
            }
        }
     dp1=dp;
    }
    /*
     for(int i=0;i<d;i++){
        for(int j=0;j<2;j++)
            cout<<dp1[i][j]<<" ";
         cout<<"\n";
     }*/
   int ans=(dp1[0][0]+dp1[0][1])%mod;
   ans--;
   if(ans==-1)
    ans=mod-1;
   cout<<ans;
}


Measured memory_bytes: 3664
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<tuple>
#include<utility>
#include<map>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define MP make_pair
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

//https://algo-logic.info/calc-pow/
ll pow(ll x, long long n) {
    ll ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x = x * x ;
        n >>= 1;  // n を1bit 左にずらす
    }
    return ret;
}

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N, M;
	cin >> N >> M;
	int K = pow(2, N);
	vector<ll> dp(K,INF);
	dp.at(0) = 0;
	FOR(i, 0, M)
	{
		ll a, b;
		cin >> a >> b;
		ll sum=0;
		while(b--){
			int c;
			cin >> c;
			sum += pow(2, c - 1);
		}
		chmin(dp[sum] ,a);
	}
	/*
	FOR(i, 0, K)
		cout << i << ":" << dp[i] << endl;
		*/

	for (int bit1 = 0; bit1 < K - 1; ++bit1)
	{
        for (int bit2 = bit1 + 1; bit2 < K; ++bit2) {
            ll nsum = bit1 | bit2;
			chmin(dp[nsum], dp[bit1] + dp[bit2]);
			//cout << bit1 << " " << bit2 << " " << nsum << endl;
		}
	}

	
	if(dp[K-1]==INF)
		cout << -1 << endl;
	else
		cout << dp[K - 1] << endl;
		
	/*
	FOR(i, 0, K)
		cout << i << ":" << dp[i] << endl;
		*/

	return 0;
}



Measured memory_bytes: 4108
import bisect
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
A.sort()
C.sort()

ans = 0
for i in range(N):
  b = B[i]
  a = bisect.bisect_left(A, b)
  c = N - bisect.bisect_right(C, b)
  ans += a * c
print(ans)

Measured memory_bytes: 22592
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    cout << a[0] +a[1] << endl;
}


Measured memory_bytes: 3596
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for (LL i=(a);i<=(b);++i)
#define ROF(i,b,a) for (LL i=(b);i>=(a);--i)
#define lowbit(x) ((x)&(-(x)))
#define OPTIM __attribute__((optimize("O2")))
typedef long long LL;
typedef long double LD;
inline LL read(){
	LL x=0,f=1; char ch=getchar();
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}

const LL MAXN=200005,MAXM=1000006;
char ch,s[MAXN];
LL n,m,a[MAXN],b[MAXN],c[MAXN],d[MAXN];
LL f[105][105][305];
LL cmp(LL i,LL j) { return c[i]<c[j]; }
int main(){
	LL i,j,k;
	n=read(); m=read();
	FOR(i,1,n) {
		a[i]=read(); b[i]=read();
		c[i]=(a[i]-a[1]);
	}
	FOR(i,1,n) d[i]=i;
	sort(d+1,d+1+n,cmp);
	//FOR(i,1,n) cout<<c[d[i]]<<' '<<b[d[i]]<<endl;
	memset(f,0,sizeof(f));
	FOR(i,1,n) {
		FOR(j,0,i)
			FOR(k,0,j*3) f[i][j][k]=f[i-1][j][k];
		ROF(j,i,1)
			ROF(k,j*3,c[d[i]]) f[i][j][k]=max(f[i][j][k],f[i-1][j-1][k-c[d[i]]]+b[d[i]]);
		/*cout<<"-------------"<<i<<endl;
		FOR(j,0,i) {
			FOR (k,0,j*3) cout<<f[i][j][k]<<' ';
			cout<<endl;
		}*/
	}
	
	LL ans=0;
	FOR(i,0,n)
		FOR(j,0,i*3)
		if (m>=i*a[1]+j) ans=max(ans,f[n][i][j]);
	cout<<ans<<endl;
	return 0;
}

/*
*/


Measured memory_bytes: 30976
#include <stdio.h>
#define N 8
#define TRUE 3
#define FALSE 2
#define FREE -1
#define NOT_FREE 1

void syokika(void);
void printboard(void);
void putQueen(int);

int X[N][N];
int row[N],col[N],dpos[2*N-1],dneg[2*N-1];

int main()
{
  int i,j,k,r,c;
  
  syokika();

  for(i=0;i<N;i++)
    {
      for(j=0;j<N;j++)
	{
	  X[i][j] = FALSE;
	}
    }
  scanf("%d",&k);
  for(i=0;i<k;i++)
    {
      scanf("%d%d",&r,&c);
      X[r][c] = TRUE;
    }

  putQueen(0);
  return 0;
}

void syokika()
{
  int i;
  for(i=0;i<N;i++)
    {
      row[i] = FREE;
      col[i] = FREE;
    }
  for(i=0;i<2*N-1;i++)
    {
      dpos[i] = FREE;
      dneg[i] = FREE;
    }
}

void printboard()
{
  int i,j;

  for(i=0;i<N;i++)
    {
      for(j=0;j<N;j++)
	{
	  if(X[i][j] == TRUE)
	    {
	      if(row[i] != j) return;
	    }
	}
    }
  for(i=0;i<N;i++)
    {
      for(j=0;j<N;j++)
	{
	  if(row[i] == j)printf("Q");
	  else printf(".");
	}
      printf("\n");
    }
}

void putQueen(int a)
{
  int j;
  if(a==N)
    {
      printboard();
      return;
    }
  for(j=0;j<N;j++)
    {
      if(col[j] == NOT_FREE || dpos[a+j] == NOT_FREE || dneg[a-j+N-1] == NOT_FREE) continue;

      row[a] = j;
      col[j] = dpos[a+j] = dneg[a-j+N-1] = NOT_FREE;

      putQueen(a+1);

      col[j] = dpos[a+j] = dneg[a-j+N-1] = FREE;
    }
}
	 

Measured memory_bytes: 572
A, B = map(int, input().split())

if A == B:
    print(A)
else:
    A -= 1
    ans = 0
    a = 1
    b = 1
    if ((A+1)//2) % 2 == 1:
        if A % 2 == 0:
            a = 1 ^ A
        else:
            a = 1
    else:
        if A % 2 == 1:
            a = 0
        else:
            a = A

    if ((B+1)//2) % 2 == 1:
        if B % 2 == 0:
            b = 1 ^ B
        else:
            b = 1
    else:
        if B % 2 == 1:
            b = 0
        else:
            b = B

    print(a ^ b)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long w,i,j,x,y,r,s;
    cin>>w>>i>>j;
    r=i+w;
    s=j+w;
 
    x=max(i,j);
    y=min(r,s);
 
    if(x>=y)
        cout<<x-y;
        else
         cout<<0;
   return 0;
   }

Measured memory_bytes: 3656
T = int(input())
import sys
sys.setrecursionlimit(20000)

def f(n):
    if n == 0:
        return 0
    if n == 1:
        return D
    if n in dic:
        return dic[n]
    if n%2 == 0:
        n2 = f(n//2)+A
    else:
        n2 = min(f((n+1)//2), f((n-1)//2))+A+D
    if n%3 == 0:
        n3 = f(n//3)+B
    elif n%3 == 1:
        n3 = min(f((n-1)//3), f((n+2)//3)+D)+B+D
    else:
        n3 = min(f((n-2)//3)+D, f((n+1)//3))+B+D
    if n%5 == 0:
        n5 = f(n//5)+C
    elif n%5 == 1:
        n5 = min(f((n-1)//5)+D, f((n+4)//5)+4*D)+C
    elif n%5 == 2:
        n5 = min(f((n-2)//5)+2*D, f((n+3)//5)+3*D)+C
    elif n%5 == 3:
        n5 = min(f((n-3)//5)+3*D, f((n+2)//5)+2*D)+C
    else:
        n5 = min(f((n-4)//5)+4*D, f((n+1)//5)+D)+C
    res = min(n2, n3, n5, n*D)
    dic[n] = res
    return res
    
for _ in range(T):
    N,A,B,C,D = map(int, input().split())
    dic = {}
    print(f(N))

Measured memory_bytes: 10840
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()
A=n1()

A.sort()

ans=1
for a in A:
    ans*=a
    if ans>10**18:
        print(-1)
        break
else:
    print(ans)

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

int main(){
    int a, b, x, y, i, j; cin>>a>>b;
    for(x=2; x<1000; x++){
        y=x-1;
        i=(y*(y+1))/2; j=(x*(x+1))/2;
        if(i-a == j-b) cout<<i-a;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
 
const ll MOD = 1000000007;
const ll INF = 1000000000;
 
int main(void){

    int n,a,b;
    cin >> n >> a >> b;
    cout << min(a,b) << ' ' << max(0,a+b-n);
    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll A, ll B) {
  cout << (A-1)*(B-1) << endl;
}

int main() {
  ll A;
  cin >> A;
  ll B;
  cin >> B;
  solve(A, B);
  return 0;
}


Measured memory_bytes: 256
import math

N = int(input())
An = [int(i) for i in input().split()]


mod = int(math.pow(10, 9) + 7)

sum_an = sum(An)
sum_result = 0

for i in range(N - 1):
    Ai = An[i]
    sum_an -= Ai
    sum_result += (Ai * sum_an) % mod


print(sum_result % mod)


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

int main(){
    //宣言、入力
    int k, n, min = 10000000, temp;
    cin >> k >> n;
    int a[n];
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    //最短路を計算
    for (int j = 0; j < n; j++){
        if (j == 0) temp = k - (a[j] + (k - a[n-1]));
        else temp = k - (a[j] - a[j-1]);
        if (temp < min) min = temp;
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main (String [] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B =sc.nextInt();
        int X =sc.nextInt();
        if (A==X){
            System.out.println("YES");
        }else if (A<= X &&  X -A <= B){
            System.out.println("YES");
        }
        else{
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 22612
/* Author: Mrigank
Science is what we understand well enough to explain to a computer, 
    Art is everything else we do - Donald E. Knuth */

#include <bits/stdc++.h>
#include <iostream>
#include <unordered_map>
#include <map>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <string> 
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<ll, int> PLI;
typedef pair < ll , ll > PLL;
typedef pair<int, int> PII;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < pair < ll , ll > > vpl;
typedef vector < pair < ll , bool > > vpb;
typedef vector < vector < int > > vvi;
typedef vector < vector < ll > > vvl;


#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x , val) memset(x , val , sizeof(x))
#define deb(x) cout<<#x<<" :: "<<x<<"\n"
#define deb2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define deb3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n"
#define all(x) x.begin() , x.end()
#define alls(x , y) x.begin() , x.end() , y
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl "\n"

const ll mxsize = 3e5 + 10;
const ll linf = 1e9;
const ld inf = 10000000000.0;
const ll mod = 1e9 + 7;
 
/******************************************** CODE STARTS FROM HERE *************************************************/ 

int main()
{
    fastIO;
    ll a , b , c , d;
    cin >> a >> b >> c >> d;
    bool ok = false;
    ll cnt = 0;
    while(1)
    {
        //deb2(a , c);
        if(c <= 0)
        {
            ok = true;
            break;
        }
        else if(a <= 0)
        {
            break;
        }
        if(cnt % 2 == 0)
        {
            c = c - b;
        }
        else
        {
            a = a - d;
        }
        cnt++;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    std::string S;
    std::cin >> S;
    int maxLen = 0;
    for(int mojisu = 1; mojisu <= S.size(); mojisu++){
        for(int start = 0; start + mojisu <= S.size(); start++){
            std::string T = S.substr(start, mojisu);
            int i;
            for(i = 0; i < mojisu; i++){
                if(T[i] == 'A' || T[i] == 'C' || T[i] == 'G' || T[i] == 'T'){
                    continue;
                }else{
                    break;
                }
            }
            if(i == mojisu){
                maxLen = std::max(maxLen, mojisu);
            }
        }
    }
    std::cout << maxLen << std::endl;
    return 0;
}


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

def main():
  r, c, n = map(int, input().split())
  L = []
  def trans(x, y):
    z = None
    if x == 0:
      z = y
    if y == c:
      z = c + x
    if x == r:
      z = c + r + c - y
    if y == 0:
      z = 2*r + 2*c - x
    return z

  for _ in range(n):
    x1, y1, x2, y2 = map(int, input().split())
    z1 = trans(x1, y1)
    z2 = trans(x2, y2)
    if z1 is not None and z2 is not None:
      L.append((z1, z2))
      L.append((z2, z1))
  L.sort()
  cnt = 0
  D = dict()
  for z1, z2 in L:
    if z1 < z2:
      cnt += 1
      D[z1] = cnt
    else:
      if D[z2] != cnt:
        print("NO")
        exit()
      cnt -= 1
  print("YES")
if __name__ == "__main__":
  main()

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

int main(){
  string s,t,g;
  cin>>s>>t;
  int a,b;
  cin>>a>>b;
  cin>>g;
  if(g==s)a--;
  else if(g==t)b--;
  cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256