akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define infi            2e9
#define infl            5e18
#define MX              100005
#define pi              2*acos(0.0)
#define ll              long long int
#define rr              read()
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define ms(a,b)         memset(a, b, sizeof(a))
#define loop(i,n)       for(register int i=0;i<n;i++)
#define pool(i,n)       for(register int i=n-1;i>=0;i--)
#define loop1(i,n)      for(register int i=1;i<=n;i++)
#define pool1(i,n)      for(register int i=n;i>0;i--)

using namespace std;

inline ll read(){char c=getchar();ll num,sign=1;for(;c<'0'||c>'9';c=getchar())if(c=='-')sign=-1;for(num=0;c>='0'&&c<='9';){c-='0';num=num*10+c;c=getchar();}return num*sign;}
// inline ll pw(ll b, ll p){ll ans=1;while(p>0){if(p&1)ans*=b;p>>=1;b*=b;}return ans;}
// inline bool isPrime(ll n){if(n==1)return false;if(n==2)return true;if(!(n%2))return false;for(ll i=3;i<=sqrt(n);i+=2)if(!(n%i))return false;return true;}
// inline ll gcd(ll a, ll b){if(a==0)return b;return gcd(b%a,a);}

// //*************************************  Bitmask Opereations  **********************************//
// int Set(int N,int pos){return N=N | (1<<pos);}
// int reset(int N,int pos){return N= N & ~(1<<pos);}
// bool check(int N,int pos){return (bool)(N & (1<<pos));}
// //********************************************************************************************//


int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    //#ifdef rid.dle
    //freopen("in.txt", "r", stdin);
    //#endif
    
    int n=rr;
    int ar[MX],dp[MX];

    loop(i,n)dp[i]=infi,ar[i]=rr;

    dp[0]=0;
    loop(i,n){
        for(register int j:{i-1,i-2}){
            if(j>-1){
                dp[i] = min(dp[i], dp[j]+abs(ar[i]-ar[j]));
            }
        }
    }

    cout << dp[n-1] << endl;

    return 0;
}

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

using namespace std;

#define REPEAT(i, N) for (int i = 0; i < (N); i++)

int main() {
  int N, M;
  long long sum = 0;
  
  cin >> N >> M;
  
  REPEAT(i, M) {
    int _in;
    
    cin >> _in;
    
    sum += _in;
  }
  
  if (N < sum) {
    cout << -1 << endl;
  } else {
    cout << N - sum << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<utility>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, ans;
    cin >> a >> b;
    ans = (3*a + b)/2;

    cout << ans <<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#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 = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a,b;
	cin >> a >> b;
	cout << (a - 1) * (b - 1 ) << endl;
}

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

vector<string> B(2000);
vector<vector<int>> li(2000, vector<int>(2000, 0));
vector<vector<int>> hi(2000, vector<int>(2000, 0));

int H, W;
int cnt = 0;

void Hsl(int h, int w) {
	if (h > H - 1) return;
	if (B[h][w] == '#') return;
	cnt++;
	Hsl(h + 1, w);
	li[h][w] = cnt;
	return;
}

void Wsl(int h, int w) {
	if (w > W - 1)return;
	if (B[h][w] == '#') return;
	cnt++;
	Wsl(h, w + 1);
	hi[h][w] = cnt;
	return;
}

int main() {
	cin >> H >> W;
	string S;
	for (int i = 0;i < H;i++) {
		cin >> S;
		B[i] = S;
	}
	int ans = 0;
	for (int i = 0;i < H;i++) {
		for (int j = 0;j < W;j++) {
			if (li[i][j] == 0) {
				cnt = 0;
				Hsl(i, j);
			}
			if (hi[i][j] == 0) {
				cnt = 0;
				Wsl(i, j);
			}
			ans = max(ans, li[i][j] + hi[i][j]);
		}
	}
	cout << ans - 1 << endl;
}

Measured memory_bytes: 35840
#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
 
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const ull INF = ull(8e18);
ull P[222222];
ull a[222222];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; ull x; cin>>n>>x;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		P[i]=a[i]+P[i-1];
	}
	ull res=INF;
	for(int i=1;i<=n;i++)
	{
		ull ans = 0; ull cur = 3;
		ans+=i*x;
		for(int j=n;j>=1;j-=i)
		{
			int r = j; int l = max(1, j-i+1);
			ans += (cur==3?5:cur)*(P[r]-P[l-1]);
			cur+=2;
		}
		res=min(res,ans);
	}
	res+=n*x;
	cout<<res<<'\n';
}


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

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, 
less<int>, rb_tree_tag, 
tree_order_statistics_node_update> indexed_set;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	char c;
	cin >> c;
	if(isupper(c)) {
		cout << 'A';
	}
	else {
		cout << 'a';
	}
	cout << "\n";
	return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define P pair<int,int>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define re(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
int n;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n){
        cin>>a[i];
    }
    sort(a,a+n);
    double kai=a[0];
    rep(i,n-1){
        kai=(kai+a[i+1])/2.0;
    }
    cout<<kai<<endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
int main(){
  int n;
  double a=1.000000, b=0.000000;
  cin >> n;
  vector <double> v(n);
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  FOR(i,0,n){
     b+=a/v[i];
  }
  double ans = a/b;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int N,X,Y;
    cin >> N;
    if(N%1000 == 0)X = N/1000;     
    else X = N/1000 + 1 ;
    Y = X*1000 - N;
    cout << Y << endl;
    return 0;
}

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

int main()
{
  char s[110000];
  int res=0;
  cin >> s;

  int runlength;
  if(s[0]=='1') runlength++;
  else runlength--;

  FOR(i,1,strlen(s)-1){
    int prevrl=runlength;
    if(s[i]=='1') runlength++;
    else runlength--;
    if(abs(runlength)<abs(prevrl)) res++;
  }

  cout << res*2 << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD (ll)1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n, m) for (int i = (n), i < (m); i++)

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int
main(int argc, char *argv[])
{

  int n, q, k, a[100010];
  scanf("%d %d %d", &n, &k, &q);
  int score[100010] = {};
  rep(i, q) {
    scanf("%d", &a[i]);
    score[a[i] - 1] += 1;
  }

  for (int i = 0; i < n; i++) {
    if (score[i] + k - q <= 0) printf("No\n");
    else printf("Yes\n");
  }

  return 0;
}

  


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  ll H, W;
  cin >> H >> W >> N;
  map<P, ll> c;
  vector<ll>x, y;
  set<P> xy;
  rep(i, N){
    ll xt, yt;
    cin >> yt >> xt;
    c[{xt, yt}]=1;
    FOR(j, -2, 1){
      if(xt+j>=1 and xt+2+j<=W){
        FOR(k, -2, 1){
          if(yt+k>=1 and yt+2+k<=H){
            /*x.push_back(xt+j);
              y.push_back(yt+k);*/
            xy.insert({xt+j,yt+k});
          }
        }
      }
    }
  }

  llvec ans(10, 0);
  ans[0]=(H-2)*(W-2);
  for(auto i: xy){
    ll cnt = 0;
    ll xi=i.first;
    ll yi=i.second;
    rep(j, 3){
      rep(k, 3){
        if(c[{xi+j, yi+k}]==1){
          cnt++;
        }
      }
    }
    if(cnt!=0){
      ans[cnt]++;
      ans[0]-=1;
    }
  }
  
  rep(i, 10){
    cout << ans[i] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 212736
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int dfs(int crt, int sum, vector<long long> &v, vector<vector<int>> &G) {
    sum += v[crt];
    v[crt] = sum;
    for (int i = 0; i < G[crt].size(); i++) {
        dfs(G[crt][i], sum, v, G);
    }
    sum -= v[crt];
    return 0;
}

vector<vector<int>> pos;

int main(void) {
    string S, T;
    cin >> S >> T;
    pos = vector<vector<int>>(26);
    for (int i = 0; i < S.length(); i++) {
        int idx = (int)(S[i] - 'a');
        pos[idx].push_back(i);
    }
    for (int i = 0; i < T.length(); i++) {
        int idx = T[i] - 'a';
        if (pos[idx].size() == 0) {
            cout << -1 << endl;
            return 0;
        }
    }
    
    long long ans = 0;
    int crt_pos = 0;
    for (int i = 0; i < T.length(); i++) {
        int idx = T[i] - 'a';
        auto itr = lower_bound(pos[idx].begin(), pos[idx].end(), crt_pos);
        if (itr == pos[idx].end()) {
            ans++;
            crt_pos = *(pos[idx].begin()) + 1;
        } else {
            crt_pos = *itr + 1;
        }
    }
    cout << S.length()*ans + crt_pos<< endl;
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
using ll = long long;
ll n,d,x,y;
int cnt = 0;
int main()
{
	cin >> n >> d;
	while (n--)
	{
		cin >> x >> y;
		if (x * x + y * y <= d*d)cnt++;
	}
	cout << cnt;
}

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

using namespace std;

typedef long long ll;

ll S(ll x)
{
    return x * (x - 1) / 2;
}

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

    vector <int> a(n);
    vector <int> A(n);

    for(int& x : a) scanf("%d", &x), A[--x]++;

    ll Ans = 0;
    for(int i = 0; i < n; i++)  Ans += S(A[i]);

    for(int i = 0; i < n; i++)
    {
        Ans -= S(A[a[i]]);
        A[a[i]]--;
        Ans += S(A[a[i]]);

        printf("%lld\n", Ans);

        Ans -= S(A[a[i]]);
        A[a[i]]++;
        Ans += S(A[a[i]]);
    }
}


Measured memory_bytes: 4096
import numpy as np
n,m,x = map(int,input().split())
t = [ i + 1 for i in range(0,n)]
res = []
for i in range(n):
    c_a = list(map(int,input().split()))
    res.append(c_a)
import itertools
choice = []
def all_choice(x,n):
    for i in x:
        for j in itertools.combinations(range(0,n), i):
            choice.append(j)
    return choice
all_choice = all_choice(t,n)
count = []
for a in all_choice:
    res_0 = np.array([res[i] for i in a])
    flag = 0
    for i in range(m):
        if sum([t[i+1] for t in res_0]) < x:
            flag = 1
            break
    if flag == 0:
        count.append(sum([t[0] for t in res_0]))
if len(count)==0:
    print(-1)
else:
    print(min(count))

Measured memory_bytes: 27320
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(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 rep2(i, begin_i, end_i) for (int i = (int)begin_i; i < (int)end_i; i++)

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
int n,m;
int main(){
    cin>>n>>m;
    cout<<(m*1900+100*(n-m))*pow(2,m);
    return 0;
}




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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;

template<int N>
class UF{
    public:
    vector<int> par,size;
    UF():par(N),size(N,1){for(int i=0;i<N;++i)par[i]=i;};
    int operator[](int x){return (x == par[x])?x:par[x] = operator[](par[x]);}
    void operator()(int x,int y){
        x = operator[](x);
        y = operator[](y);
        if(x == y)return;
        if(x > y)swap(x,y);
        par[y] = x;
        size[x] += size[y];
    }
    int siz(int x){
        x = operator[](x);
        return size[x];
    }
};

UF<200050> uf{};
int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;++i){
        int a,b;
        cin>>a>>b;
        a--;b--;
        uf(a,b);
    }
    int ret = 0;
    for(int i=0;i<n;++i)if(i == uf[i]){
        ret = max(ret,uf.siz(i));
    }
    cout << ret << endl;
    return 0;
    
}


Measured memory_bytes: 4660
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
   ll n;
   cin>>n;
   if(n==1)
   {
       cout<<"1\n";
       return;
   }
   if(n%2==0)
   {
       cout<<0.5<<"\n";
       return;
   }
   ll no = (n+1)/2;
   ll ne = (n)/2;
//    cout<<no<<" "<<ne<<"\n";
   ld res = (ld)no/(ne+no);
   cout<<res<<"\n";
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

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

cnt_dict = {"AC":0,"WA":0,"TLE":0,"RE":0}
for i in range(N):
    s = input()
    cnt_dict[s] += 1

for s in ["AC", "WA", "TLE", "RE"]:
    print(f"{s} x {cnt_dict[s]}")


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

int main(){

    
    int n;
    cin >> n;

    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }   
    sort(v.rbegin(), v.rend());

    long long ans1 = 0;
    long long ans2 = 0;
    for(int i = 0; i < v.size()-1; i++){
        if(v[i] == v[i+1] ){
            if(ans1 == 0){
                ans1 = v[i];
                v[i+1] = 0;
            }
            else if(ans2 == 0){
                ans2 = v[i];
                cout << ans1 * ans2 << endl;
                return 0;
            }

        }
    }

    cout << ans1 * ans2 << endl;
    return 0;


}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int n,A[50];

int solve(int i,int m){
	if(m==0) return 1;
	if(i>=n) return 0;
	int res = solve(i+1,m)||solve(i+1,m-A[i]);
	return res;
}

int main() {
	int q;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>A[i];
	}
	cin>>q;
	for(int i=0;i<q;i++){
		int m;
		cin>>m;
		if(solve(0,m))  cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  string t;
  cin >> t;


  int ans = 2 * N;

  int match = 0;
  repp(i, 1, N) {
    if (s.substr(N - i, i) == t.substr(0, i))
      match = i;
  }
  ans -= match;
  cout << ans << endl;
}

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

using namespace std;

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ii> vii;

ll n;
string res;

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

	if (!n) {
		cout << 0 << endl;
		return 0;
	}

	for (int i = 0, s = 1; n; i++, s *= -1) {
		if (n % (1ll << (i+1)) != 0) {
			n -= (1ll << i) * s;
			res.push_back('1');
		} else {
			res.push_back('0');
		}
	}

	reverse(ALL(res));

	for (int i = 0, f = 0; i < res.size(); i++) {
		if (f || res[i] == '1') {
			cout << res[i];
			f = 1;
		}
	}

	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 105000000000

const int maxn = 1e5 + 10;


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

	int s;
	int sum=0;
	int min = 10000;
	rep(i, n) 
	{ 
		cin >> s;
		sum += s;
		if (s % 10 != 0 && s < min)min = s;
	}
	
	if (sum % 10 != 0) Print(sum);
	else if (min < 100) Print(sum - min);
	else Print(0);

	return 0;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int h,w;
char c[2000][2000];
int l[2000][2000],r[2000][2000],u[2000][2000],d[2000][2000];
int ans;
int main(){
    cin>>h>>w;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>c[i][j];
    for(int i=0;i<h;i++){
        if(c[i][0]=='.')l[i][0]=1;
        if(c[i][w-1]=='.')r[i][w-1]=1;
    }for(int j=0;j<w;j++){
        if(c[0][j]=='.')u[0][j]=1;
        if(c[h-1][j]=='.')d[h-1][j]=1;
    }for(int i=0;i<h;i++){
        for(int j=1;j<w;j++)if(c[i][j]=='.')l[i][j]=l[i][j-1]+1;
        for(int j=w-2;j>=0;j--)if(c[i][j]=='.')r[i][j]=r[i][j+1]+1;
    }for(int j=0;j<w;j++){
        for(int i=1;i<h;i++)if(c[i][j]=='.')u[i][j]=u[i-1][j]+1;
        for(int i=h-2;i>=0;i--)if(c[i][j]=='.')d[i][j]=d[i+1][j]+1;
    }
    for(int i=0;i<h;i++)for(int j=0;j<w;j++)ans=max(ans,l[i][j]+r[i][j]+u[i][j]+d[i][j]-3);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 66688
from itertools import*
s=input()
x=[[k,len(list(v))]for k,v in groupby(s)]

ans=0
#print(x)
for i in range(len(x)):
    try:
        if x[i][0]=="<" and x[i+1][0]==">":
            n=max(x[i][1],x[i+1][1])
            m=min(x[i][1],x[i+1][1])
            ans+=(n+1)*n//2+(m-1)*m//2
    except:
        break

if x[0][0]==">":
    y=x[0][1]
    ans+=y*(y+1)//2
if x[-1][0]=="<":
    y=x[-1][1]
    ans+=y*(y+1)//2

print(ans)


Measured memory_bytes: 30108
a[50],b[50],c[50],d[50],p,v,i,j,n,m;main(k){for(;~scanf("%d%d",n?(i<n?a:c-n)+i++:&n,m?i<n?b+i:d-n+i:&m););for(;j<n;printf("%d\n",p,j++))for(v=1e9,p=i=0;i<m;v>k?p=i,v=k:0)k=abs(a[j]-c[i])+abs(b[j]-d[i++]);}

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

#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define pii pair < int , int >
#define pll pair < long long, long long >

const int N = 200005;


int main()
{
    #ifdef Estb_probitie
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    int n, k;
    cin >> n >> k;

    int a[n + 2];
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    bool wi[k + 2] = {};

    for (int i = 0; i < n; ++i)
        wi[a[i]] = 1;


    for (int i = 1; i <= k; ++i)
    {
        for (int j = 0; j < n; ++j)
            if (i - a[j] >= 0 && !wi[i - a[j]])
              wi[i] = 1;
    }


    cout << (wi[k] ? "First" : "Second");
}


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

int main(){
  int N;
  cin>>N;
  vector<string> S(N);
  for(int i=0;i<N;i++){
  cin>>S.at(i);
  }
  sort(S.begin(),S.end());
  int t=N;
  for(int i=0;i<N-1;i++){
    if(S.at(i)==S.at(i+1)){
      t--;
    }
  }
  cout<<t<<endl;
  
  
}

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

using namespace std;
int main ()
{
	int sum = 0, a, ans = 0;
	int n;
	scanf ("%d", &n);
	for (int i = 1; i <= n; ++i)
	{
		scanf ("%d", &a);
		ans += sum * a;
		sum += a;
	}
	printf ("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Mar 22 21:00:14 JST 2020
 **/

signed main() {
    double x;
    cin >> x;
    cout << (x / 3) * (x / 3) * (x / 3) << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;

ll n, x;
vector<int> b(n), l(n), u(n);
ll f(ll g) {
	ll p = min(g / x,n), q = g % x;
	vector<P> sum(n);
	rep(i, 0, n) {
		ll add;
		if (q >= b[i]) add = 1LL*b[i] * l[i] + 1LL*(q - b[i]) * u[i];
		else add = 1LL*q * l[i];
		sum[i] = { 1LL*l[i] * b[i] + 1LL*(x - b[i]) * u[i],add };
	}
	sort(sum.begin(), sum.end(),greater<P>());
	ll sub = 0;
	rep(i, 0, p) sub += sum[i].first;
	if (p == n) return sub;
	ll res = 0;
	rep(i, 0, p) {
		res = max(res, sub - sum[i].first + sum[i].second + sum[p].first);
	}
	rep(i, p, n) {
		res = max(res, sub + sum[i].second);
	}
	return res;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); 
	cin >> n >> x;
	b.resize(n); l.resize(n); u.resize(n);
	rep(i, 0, n) cin >> b[i] >> l[i] >> u[i];
	ll sub = 0; rep(i, 0, n) sub += 1LL*l[i]*b[i];
	ll le = -1, ri = 1LL*inf*inf;
	while (ri - le > 1) {
		ll mi = (le + ri) / 2;
		if (f(mi) >= sub) ri = mi;
		else le = mi;
	}
	printf("%lld", ri);
	return 0;
}


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


int main(){
  long K, N;

  cin >> K >> N;
  vector<long> a(N);

  for(int i=0; i<N; i++){
    cin >> a[i];
  }
  long max_dist = 0;
  long dist;
  for(int i=0; i<N-1; i++){
    dist = a[i+1] - a[i];
    max_dist = max(dist, max_dist);
  }
  dist = K-a[N-1]+a[0];
  max_dist = max(dist, max_dist);
  cout << K - max_dist << endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;//这一句话必须有
char s1[101],s2[101];
int main()
{
    gets(s1);
    gets(s2);
    int n=strlen(s1);
    int m=strlen(s2); //先记录下来两个串的长度，避免重复计算
    sort(s1,s1+n);
    sort(s2,s2+m);//对两个串进行排序
    for(int i=0;i<fmax(n,m);i++)//这里要循环到最大值，因为有空格，空格<小写字母
    {
        if(s1[i]<s2[m-i-1])//如算法区所示
        {
            printf("Yes\n");
            return 0;
        }
        if(s1[i]>s2[m-i-1])//一个不符，直接跳出
            break;
    }
    printf("No\n");//不是yes就是no
    return 0;
} 

Measured memory_bytes: 128
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


int main()
{
	string s;
	cin >> s;
	vector<char>c(s.length());
	for (int i = 0; i < s.length(); i++)c[i] = s[i];
	sort(s.begin(), s.end());

	for (int i = 0; i < s.length()-1; i++) {
		if (s[i] == s[i + 1])return cout << "no" << endl,0;
	}

	cout << "yes" << endl;
}




Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x)
#define debug(x)
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)


void mainmain(){
    vint a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << a[K-1] << endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
import collections
S=input()
l=len(S)
T,d=0,1
A=[0]*2019
A[0]=1
for i in range(l):
    T+=int(S[l-i-1])*d
    d*=10
    T%=2019
    d%=2019
    A[T]+=1
ans=0
for cnt in A:
    ans+=cnt*(cnt-1)//2
print(ans)














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

int main(void){
	int n;
	cin>>n;
	for(int i=0;i<n;++i){
		int lines[9][9];
		int errors[9][9]={0};
		if(i!=0) cout<<endl;
		for(int j=0;j<9;++j){
			for(int k=0;k<9;++k)cin>>lines[j][k];
		}
		for(int j=0;j<9;++j){//yoko
			int count[9]={0};
			for(int k=0;k<9;++k)++count[lines[j][k]-1];
			for(int k=0;k<9;++k){
				if(count[lines[j][k]-1]>1) errors[j][k]=1;
			}
		}
		for(int j=0;j<9;++j){//tate
			int count[9]={0};
			for(int k=0;k<9;++k)++count[lines[k][j]-1];
			for(int k=0;k<9;++k){
				if(count[lines[k][j]-1]>1) errors[k][j]=1;
			}
		}
		for(int j=0;j<3;++j){//3x3
			for(int k=0;k<3;++k){
				int count[9]={0};
				for(int l=0;l<3;++l) for(int m=0;m<3;++m) ++count[lines[j*3+l][k*3+m]-1];
				for(int l=0;l<3;++l) for(int m=0;m<3;++m) if(count[lines[j*3+l][k*3+m]-1]>1) errors[j*3+l][k*3+m]=1;
			}
		}
		for(int j=0;j<9;++j){
			for(int k=0;k<9;++k){
				if(errors[j][k]) cout<<"*";
				else cout<<" ";
				cout<<lines[j][k];
			}
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
	double cx,cy,r,x1,x2,y1,y2,slope,cross_x,cross_y,k,div_x,div_y,ans1_x,ans1_y,ans2_x,ans2_y;
	int q;
	bool X_FLG,Y_FLG;

	scanf("%lf %lf %lf",&cx,&cy,&r);
	scanf("%d",&q);

	for(int i=0;i<q;i++){
		scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);

		X_FLG = false,Y_FLG = false;

		if(y1 == y2){
			X_FLG = true;
		}else if(x1 == x2){
			Y_FLG = true;
		}else{
			slope = (y2-y1)/(x2-x1);
		}

		if(X_FLG){
			cross_x = cx;
			cross_y = y1;
		}else if(Y_FLG){
			cross_x = x1;
			cross_y = cy;
		}else{
			cross_x = (cy*(x2-x1)*(y2-y1)+cx*(x2-x1)*(x2-x1)-y1*(y2-y1)*(x2-x1)+x1*(y2-y1)*(y2-y1))/((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1));
			cross_y = ((x1-x2)*cross_x+cy*(y2-y1)+cx*(x2-x1))/(y2-y1);
		}

		k = sqrt(r*r-((cx - cross_x)*(cx-cross_x)+(cy-cross_y)*(cy-cross_y)));

		if(X_FLG){
			printf("%.8lf %.8lf %.8lf %.8lf\n",cross_x - k,y1,cross_x+k,y1);
		}else if(Y_FLG){
			printf("%.8lf %.8lf %.8lf %.8lf\n",x1,cross_y-k,x1,cross_y+k);
		}else{
			div_x = k*(x2-x1)/(sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
			div_y = k*(y2-y1)/(sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));

			ans1_x = cross_x-div_x;
			ans1_y = cross_y-div_y;

			ans2_x = cross_x+div_x;
			ans2_y = cross_y+div_y;

			if(ans1_x < ans2_x){
				printf("%.8lf %.8lf %.8lf %.8lf\n",ans1_x,ans1_y,ans2_x,ans2_y);
			}else if(fabs(ans1_x-ans2_x) < 0.00000001 && ans1_y <= ans2_y){
				printf("%.8lf %.8lf %.8lf %.8lf\n",ans1_x,ans1_y,ans2_x,ans2_y);
			}else{
				printf("%.8lf %.8lf %.8lf %.8lf\n",ans2_x,ans2_y,ans1_x,ans1_y);
			}
		}
	}

	return 0;
}

Measured memory_bytes: 2716
d='URLD'
*y,s,t=open(0).read().split()
h,w,n,r,c=map(int,y)
b=[h,w,w,h]
o=[h-r+1,c,w-c+1,r]
t=[dict(zip(d,d[::-1]))[i] for i in t]
a=0
for i,j in enumerate(d):
  x=o[i]
  for k in range(n):
    x+=(s[k]==j)
    if x>b[i]:a=1
    x-=(t[k]==j)*x>1
print('YNEOS'[a::2])

Measured memory_bytes: 63692
while True:
    n = int(input())
    if n == 0:
        break
    a_score = 0
    b_score = 0
    for i in range(0,n):
        a,b = map(int,input().split())
        if a > b :
            a_score += a+b
        elif a < b :
            b_score += a+b
        else:
            a_score += a
            b_score += a
    print(a_score,b_score)


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  vector<pair<P,int>> data(N);
  rep(i,N) {
    int x,y,h;
    cin >> x >> y >> h;
    data[i] = make_pair(P(x,y),h);
  }
  vv(bool) checked(101,v(bool)(101,false));
  auto check = [&](int H,int X,int Y) {
    bool ok = true;
    rep(i,N) {
      int x = data[i].first.first;
      int y = data[i].first.second;
      int h = data[i].second;
      if(abs(x-X)+abs(y-Y) == H-h) {
        continue;
      }
      if(abs(x-X)+abs(y-Y) >= H && h == 0) {
        continue;
      }
      ok = false;
      break;
    } 
    return ok;
  };
  rep(i,N) {
    int h = data[i].second;
    if(h == 0) continue;
    int x = data[i].first.first;
    int y = data[i].first.second;
    rep(X,101) {
      rep(Y,101) {
        int H1 = abs(X-x) + abs(Y-y) + h;
        int H2 = abs(X-x) + abs(Y-y) - h;
        if(check(H1,X,Y)) {
          cout << X << " " << Y << " " << H1 << endl;
          return 0;
        }
        if(H2 > 0 && check(H2,X,Y)) {
          cout << X << " " << Y << " " << H2 << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using llong = long long;
const int MOD=1000000007;

int main(int argc, char**argv){
    llong n;
    cin >> n;
    vector<llong> a(n);
    llong n_neg = 0;
    llong min_val = 1LL << 60;
    llong sum = 0;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        if (a[i] < 0) n_neg++;
        min_val = min(min_val, abs(a[i]));
        sum += abs(a[i]);
    }

    if (n_neg % 2 == 0) cout << sum << endl;
    else cout << sum - 2*min_val << endl;

    return 0;
}


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

#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define FILL0(x) memset(x,0,sizeof(x))
#define FILL1(x) memset(x,-1,sizeof(x))

using namespace std;

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

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; }
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int h, w, m;
    cin >> h >> w >> m;
    
    set<P> bomb;
    int yb[h]={0}; 
    int xb[w]={0};



    int xmax=0;
    int ymax=0;
    
    rep(i, m)
    {
        int x, y;
        cin >> y >> x;
        x--;y--;

        xb[x]++;
        yb[y]++;

        bomb.insert(P(y, x));
    }

    rep(i, w)
    {
        if(xmax<xb[i])
        {
            xmax = xb[i];  
        }
    }
    rep(i, h)
    {
        if(ymax<yb[i])
        {
            ymax = yb[i];
        }        
    }

    int ans  = xmax + ymax;

    vector<int> yy, xx;
    rep(i, h)
    {
        if(ymax==yb[i])
        {
            yy.push_back(i);
        }
    }
    rep(i, w)
    {
        if(xmax==xb[i])
        {
            xx.push_back(i);
        }
    }

    rep(i, yy.size())
    {
        rep(j, xx.size())
        {
            if(bomb.count(P(yy[i], xx[j])))
            {
                continue;
            }
            else
            {
                cout << ans << endl;
                return 0;
            }        
        }
    }

    ans--;
    cout << ans  << endl;




    return 0;

}


Measured memory_bytes: 28408
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#define esp 1e-8
using namespace std;
typedef long long ll;
int n,k;
double a[10005];
int main()
{
    ll a,b;while(cin>>a>>b)
    {
        ll gcd=__gcd(a,b);
        ll lcm=a*b/gcd;
        cout<<gcd<<" "<<lcm<<endl;
    }
}


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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

const int INF = 1 << 21;
const int MAX = 103;
const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;
int n, G[MAX][MAX];

void dijkstra() {
  int minv;
  int d[MAX], color[MAX];

  fill((int*)d, (int*)(d+MAX), INF);
  memset(color, WHITE, sizeof(color));

  d[0] = 0;
  color[0] = GRAY;
  while (true) {
    minv = INF;
    int u = -1;
    rep(i,n) {
      if (minv > d[i] && color[i] != BLACK) {
	u = i;
	minv = d[i];
      }
    }
    if (u == -1) break;
    color[u] = BLACK;
    rep(v,n) {
      if (color[v] != BLACK && G[u][v] != INF) {
	if (d[v] > d[u] + G[u][v]) {
	  d[v] = d[u] + G[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }

  rep(i,n) {
    cout << i << ' ' << (d[i] == INF ? -1 : d[i]) << endl;
  }
}

int main() {
  cin >> n;
  rep(i,n) {
    fill((int*)G[i], (int*)(G[i]+n), INF);
  }
  
  int u, k, v, c;
  rep(i,n) {
    cin >> u >> k;
    rep(j,k) {
      cin >> v >> c;
      G[i][v] = c;
    }
  }

  dijkstra();
  return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;typedef long long ll;
#define int ll
#define N 100005
#define pb push_back
#define pv(x) cout<<#x<<": ";for(auto k:x){ cout<<k<<" "; }cout<<endl;
#define dbg(x) cout<<#x<<": "<<x<<endl;

int n,m,ni,mi;
// int num[N];
int ok=false;

void solve(){
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int ans=0;
		ans+=min(a,k);
		k-=ans;
		if(k){
			k-=min(b,k);
		}
		if(k){
			ans-=k;
		}
		cout<<ans<<endl;
}

int32_t main(){cin.tie(0);ios_base::sync_with_stdio(NULL);
	int t=1;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 3660
// clang-format off

#include <bits/stdc++.h>

#define int long long int
#define main signed main()
#define bye return 0
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define dump(x) cerr << "(L" << __LINE__ << ") " << #x << " = " << (x) << endl
#define clr(x, a) memset(x, a, sizeof(x))

#define sum(v) accumulate(all(v), 0)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!odd(n))

#define INF 1000000000
#define MOD 1000000007
#define PI acos(-1)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>

using namespace std;

// clang-format on

int K;
int ia = 0, na = 0;
int result = 0;

int _f(string I, string N, int *_ia, int *_na) {
  if (I == "kougekida" && N == "kougekida") {
    if (*_ia > *_na) {
      return 1;
    }
    if (*_ia < *_na) {
      return -1;
    }
    *_ia = *_na = 0;
    return 0;
  }
  if (I == "kougekida" && N == "mamoru") {
    if (*_ia == 0) {
      return -1;
    }
    if (*_ia == 5) {
      return 1;
    }
    *_ia = 0;
    return 0;
  }
  if (I == "kougekida" && N == "tameru") {
    return *_ia == 0 ? -1 : 1;
  }
  if (I == "mamoru" && N == "mamoru") {
    return 0;
  }
  if (I == "mamoru" && N == "tameru") {
    *_na = min<int>(5, *_na + 1);
    return 0;
  }
  if (I == "tameru" && N == "tameru") {
    *_ia = min<int>(5, *_ia + 1);
    *_na = min<int>(5, *_na + 1);
    return 0;
  }
  return -_f(N, I, _na, _ia); // ?????????????????°??????????????????
}

void f(string I, string N) {
  if (result == 0) {
    result = _f(I, N, &ia, &na);
  }
}

main {
  cin >> K;
  string I[K], N[K];
  rep(i, K) cin >> I[i];
  rep(i, K) cin >> N[i];
  rep(i, K) f(I[i], N[i]);
  cout << (result == 1 ? "Isono-kun"
                       : result == -1 ? "Nakajima-kun" : "Hikiwake-kun")
       << endl;
  bye;
}

Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
double pi = acos(-1.0);
const double EPS=1e-9;
#define MOD ll(1e9L+7)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define t() ll tt;cin>>tt;while(tt--) 


int main()
{
    fastio;
    ll i,j,n,m;
    cin>>n;
    vector<double>prob(n);
    vector<vector<double>>dp(n,vector<double>(n+1,0));
    // dp[i][j] = probability of j heads till index i
    for(i=0;i<n;i++) cin>>prob[i];
    dp[0][0]=1-prob[0];
    dp[0][1]=prob[0];

    for(i=1;i<n;i++)
        for(j=0;j<=n;j++)
            dp[i][j]= ((j>0)?dp[i-1][j-1]*prob[i] : 0  )+ dp[i-1][j]*(1-prob[i]);
    double ans=0.0;
    for(i=n/2 + 1;i<=n;i++)
        ans += dp[n-1][i];
    cout<<fixed<<setprecision(12)<<ans;


}

Measured memory_bytes: 73636
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let n = input::<i64>();

    let ans = (n + 110) / 111 * 111;
    println!("{}", ans);
}


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF -10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    int N,M;
    cin>>N>>M;
    vector<ll> x(N),y(N),z(N);
    rep(i,N)cin>>x[i]>>y[i]>>z[i];
    ll ans=0;
    rep(bit,(1<<3)){
        vector<ll> res(N,0); 
        rep(i,N){
            if(bit&1)res[i]+=x[i];
            else res[i]-=x[i];
            if(bit&2)res[i]+=y[i];
            else res[i]-=y[i];
            if(bit&4)res[i]+=z[i];
            else res[i]-=z[i];
        }
        sort(res.rbegin(),res.rend());
        ll tmp = 0;
        rep(i,M)tmp+=res[i];
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String u = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(sc.next().equals(s)){
            System.out.println((a-1)+" "+b);
        }else{
            System.out.println(a+" "+(b-1));
        }
    }
}

Measured memory_bytes: 21844