akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000
#define MAX_N 100010

int n;
vector<int> a, b, c;

void input() {
  cin >> n;
  rep(i, 0, n) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  rep(i, 0, n) {
    int tmp;
    cin >> tmp;
    b.push_back(tmp);
  }
  rep(i, 0, n) {
    int tmp;
    cin >> tmp;
    c.push_back(-tmp);
  }
}

void solve() {
  vsort(a);
  vsort(b);
  vsort(c);

  ll rsl = 0;
  rep(i, 0, n) {
    ll cnt_a = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
    ll cnt_c = lower_bound(c.begin(), c.end(), -b[i]) - c.begin();
    rsl += cnt_a * cnt_c;
  }
  cout << rsl << endl;
}

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

  input();
  solve();
}



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

#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 SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);
const long long MOD = 1000000007;

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    ll n;
    ll p[200010];
    vector<ll > v;
    string s, t;

    cin >> n;

    REP(i, n){
        cin >> p[i];
    }

    ll ans = 0;
    REP(i, n){
        if ((i+1)%2!=0 && p[i]%2!=0){
            ans++;
        }
    }

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

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

int main()
{
    int x, y;
    for (int i = 0; i < 3000; i++)
    {
        cin >> x >> y;
        if (x == 0 && y == 0)
        {
            break;
        }
        else if (x > y)
        {
            cout << y << " " << x << endl;
        }
        else
        {
            cout << x << " " << y << endl;
        }
    }
}


Measured memory_bytes: 3084
/**
 *    Author:  "Robin Singh" !!!!    
**/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define str string 
#define szz(v) ((int)(v).size())  
#define vi vector<int>
#define vll vector<ll>
#define fr(i, j, k) for(i = j; i < k; i++)
#define bk(i, j, k) for(i = j; i >= k; i--)
#define frit(it, a) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)  // use fill() for value other than 0 //
#define rtn return 
#define RT fprintf(stderr, "\nTIME = %lf\n", 1.0 * clock()/CLOCKS_PER_SEC)
#define nl "\n"
#define INF 1LL<<61
#define inf 1<<30
#define dbg(x) (cerr << #x << ": " << x << "\n")
const long long mod = 1e9+7;

ll gcd(ll a,ll b) { return b==0 ? a : gcd(b, a%b); }
ll expo(ll x, ll y){ ll res = 1; x = x % mod;  while (y > 0) { if (y & 1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
void matmul(ll a[][2], ll b[][2]) { ll tmp[2][2]; for(int i=0; i<2; i++) { for(int j=0; j<2; j++) { tmp[i][j] = 0; for(int k=0; k<2; k++) tmp[i][j] = (tmp[i][j] + a[i][k]*b[k][j]) % mod; }} for(int i=0; i<2; i++) for(int j=0; j<2; j++) a[i][j] = tmp[i][j]; }
ll fibo(int n)    // returns nth fibonacci number, also S(n) = f(n+2)-1
{ if(n == 0) return 0; else if(n == 1) return 1; ll T[2][2] = { {0, 1} , {1, 1} }; ll res[2][2] = { {1, 0}, {0,1} }; n--; while(n) { if(n & 1) matmul(res, T); n >>= 1; matmul(T, T); } return res[1][1]; }

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, k;
    cin >> n >> k;
    int i, a[n];
    fr(i, 0, n)
        cin >> a[i];
    if(n==k){
        cout << 1;
        rtn 0;
    }
    int c=0;
    i = 0;
    while(i < n-1){
        i += k-1;
        c++;
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 640
// 'By Anki'

#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define wr(i) cout<<#i<<" = "<<i<<",  ";
#define wre(i) cout<<#i<<"  =  "<<i<<endl;
#define all(v) v.begin(),v.end()
typedef long long ll;
#define lim 1000000007LL
// #define lim 10LL
#define M 1000006
 
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
 
ll fact(ll n)
{
    ll ans=1LL;
    while(n)
    ans*=(n--);
    return ans;

}

ll func(ll val,ll n,ll a,ll b,ll c,vector<ll>v){
    ll ans=0LL;
    if(a+b<=c){
        for(auto x:v){
            if(x>val)ans+=(x-val)*b;
            else ans+=(val-x)*a;
        }
    }
    else
    {
        int i=0,j=n-1;
        while(i<j){
            if(v[i]>val)break;
            if(v[j]<val)break;
            ll tmp=min(val-v[i],v[j]-val);
            v[j]-=tmp;
            v[i]+=tmp;
            ans+=tmp*c;
            if(v[j]==val)j--;
            if(v[i]==val)i++;
        }
        if(v[i]>val){
            for(;i<=j;i++)ans+=(v[i]-val)*b;
        }
        else if(v[j]<val){
            for(;j>=i;j--)ans+=(val-v[j])*a;
        }
    }
    // wr(ans);
    return ans;
}

ll ternary(ll l,ll r, vector<ll>v,ll n, ll a, ll b,ll c){
    while(r-l>2){
        ll m1=l+(r-l)/3;
        ll m2=r-(r-l)/3;
        // wr(m1)wre(m2)
        if(func(m1,n,a,b,c,v)<func(m2,n,a,b,c,v))r=m2;
        else l=m1;
    }
    ll ans=func(l,n,a,b,c,v);
    for(int i=l;i<=r;i++)ans=min(ans,func(i,n,a,b,c,v));
    return ans;
}

vector<ll>vis;
void bfs(ll x,vector<ll>v[]){
    queue<ll>q;
    q.push(x);
    while (!q.empty())
    {
        ll s=q.front();
        q.pop();
        for(auto x:v[s])
        if(!vis[x])vis[x]=s,q.push(x);
    }
}

int main()
{
fast
ll t=1;
// cin>>t;
while(t--)
{
    ll n,k;
    cin>>n>>k;
    vis.resize(n+1,0LL);
    vector<ll>v[n+1];
    ll x,y;
    for(int i=1;i<=k;i++){
        cin>>x>>y;
        v[x].pb(y);v[y].pb(x);
    }
    bfs(1LL,v);
    bool f=true;
    for(int i=2;(i<=n)&&f;i++)if(!vis[i])f=false;
    if(!f)cout<<"No\n";
    else{
        cout<<"Yes\n";
        for(int i=2;i<=n;i++)cout<<vis[i]<<"\n";
    }

    
}
} 

Measured memory_bytes: 12832
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <stack>
#include <list>

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,b,n) for(int i=b;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

const float PI = 3.1415926;
static const int INFTY = (1<<30);

using namespace std;

int B[102][102];
int M[102][102];
int w, h, xs, ys, xg, yg, n, res;
 
void bfs(int x, int y, int c) {
  if(x <= 0 || y <= 0 || x > w+1 || y > h+1)
    return;
  if(B[x][y] != c)
    return;
  if(M[x][y] == 1) {
    return;
  } else {
    M[x][y] = 1;
  }
  if(x == xg && y == yg) {
    res = 1;
    return; 
  }
  bfs(x+1, y, c);
  bfs(x, y+1, c);
  bfs(x-1, y, c);
  bfs(x, y-1, c);
}

int main() {
  while(cin >> w >> h, w) {
    // ?????????
    rep(i, w+1) {
      rep(j, h+1) {
        B[i][j] = 0;
        M[i][j] = 0;
      }
    }
    res = 0;
    cin >> xs >> ys;
    cin >> xg >> yg;
    cin >> n;
    // ??????????????????
    rep(i, n) {
      int c, d, x, y;
      cin >> c >> d >> x >> y;
      
      B[x][y] = c;
      B[x+1][y] = c;
      B[x][y+1] = c;
      B[x+1][y+1] = c;
      if ( d == 0 ) {
        B[x+2][y] = c;
        B[x+3][y] = c;
        B[x+2][y+1] = c;
        B[x+3][y+1] = c;
      } else {
        B[x][y+2] = c;
        B[x][y+3] = c;
        B[x+1][y+2] = c;
        B[x+1][y+3] = c;
      }        
    }
    if(B[xs][ys] != 0)
      bfs(xs, ys, B[xs][ys]);
    if(res)
      cout << "OK" << endl;
    else
      cout << "NG" << endl;
  }
  
  return 0;
}

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

int main() {
    int N,K;
    vector<int> A(200000);
    
    cin >> N >> K;
    for(int i = 0;i<N;i++){
        cin >> A[i];
    }
    
    int pre_point;
    int chukan_point=1;
    int now_point;
    int flag0 = 0;
        
    //chukan
    for(int j = 0;j<K-1;j++){
        chukan_point *= A[K-1-j];
    }
    
    
    int kaisu = N-K;
    for(int i =0;i<kaisu;i++){

        pre_point = A[K+i-K];
        now_point = A[K+i];
        
        if((pre_point < now_point)&&(flag0==0)){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }

        //next shori
        chukan_point /= pre_point;
        chukan_point *= now_point;
        flag0=0;
    }
    return 0;
    
}


Measured memory_bytes: 3860
#include <iostream>
#include <string>
using namespace std;
int main(){
    string S, T;
    cin >> S;
    cin >> T;
    bool check=false;
    int ct,cs;

    for(int j=S.length()-T.length(); j>=0; j--){
        for(int i=0; i<T.length(); i++){
            for(int k=0; k<T.length(); k++){
                if(S[j+k-i]!='?' && S[j+k-i]!=T[k]){
                    break;
                }else if(k==T.length()-1){
                    check=true;
                    cs=j;
                    ct=i;
                    goto LABEL;
                }
            }
        }
    }
    LABEL:

    string ans=S;
    if(check){
        for(int i=0; i<T.length(); i++){
            ans[cs+i-ct]=T[i];
        }
        for(int i=0; i<S.length(); i++){
            if(ans[i]=='?')ans[i]='a';
        }
        cout << ans <<endl;
    }else{
        cout << "UNRESTORABLE\n";
    }
    return 0;
}


Measured memory_bytes: 256
S = input()
S_r = S[::-1]

Ss = ["remaerd","resare","esare","maerd"]

ind = 0
while ind < len(S):
    flg = False
    for s in Ss:
        n = len(s)
        if S_r[ind:ind+n] == s:
            ind += n
            flg = True
    if not flg:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 70000
#include <stdio.h>
#define mod 2019

int min(int a,int b){
  if(a < b){
    return a;
  }
  return b;
}

int max(int a,int b){
  if(a > b){
    return a;
  }
  return b;
}

int main(void){
  int L, R;
  scanf("%d%d", &L, &R);
  
  if(R-L >= mod){
    printf("0\n");
    return 0;
  }
  L %= mod;
  R %= mod;
  int maximam = max(L, R);
  int minimam = min(L, R);
  int ans = 1e9;
  for (int i = minimam; i < maximam; i++) {
    for (int j = i+1; j <= maximam; j++) {
      ans = min((i*j)%mod, ans);
    }
  }
  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
int a,b;
int e_gcd(int a,int b,int &x,int &y)
{
    if(b==0)
    {
        x=1;
        y=0;
        return a;
    }
    int ans=e_gcd(b,a%b,x,y);
    int tmp=x;
    x=y;
    y=tmp-a/b*y;
    return ans;
}
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d%d",&a,&b);
    int x,y;
    e_gcd(a,b,x,y);
    printf("%d %d\n",x,y);
    return 0;

}

Measured memory_bytes: 3220
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
#include<cstring>
#include<string>
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	if(a * b % 2) cout << "Odd" << endl;
	else cout << "Even" << endl;
	return 0;
}

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

int GCD(int c, int d){
    if(c%d == 0){
        return d;
    }
    else{
        return GCD(d, c%d);
    }
}

int main(void){
    long int a, b;
    while(cin >> a >> b){
        if(a < b){
            int x = a;
            a = b;
            b = x;
        }
        long int gcd_a_b = GCD(a, b);
        cout << gcd_a_b << " " << a*b/gcd_a_b << endl;
    }
    return 0;
}



Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <math.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
using namespace std;
typedef long long ll;

vector<pair<int, int>> to[100010];
bool visited[100010];
ll dist[100010];
ll gcd(ll a, ll b)
{
   if (b == 0)
   {
       return a;
   }
    return gcd(b, a%b);
}
void dfs(int now, ll d) {
  visited[now] = true;
  dist[now] = d;
  for (auto p : to[now]) {
    if (visited[p.first]) continue;
    dfs(p.first, d + p.second);
  }
}
vector<int>ans(10005,0);
void f(ll n){
    for (ll x = 1; x*x<n;x++){
        for (ll y = 1; y*y<n;y++){
            for (ll z = 1; z*z<n;z++){
                ll v = (x*x)+(y*y)+(z*z)+(x*y)+(y*z)+(z*x);
                if(v<10005) ans[v]++;
            }
        }
    }
}

int main() {
    int n,d;
    cin >> n >> d;
    ll ans = 0;
    rep(i,0,n) {
        ll x1,x2;
        cin >> x1>>x2;
        x1*=x1;
        x2*=x2;
        ll sum = x1+x2;
        if(sqrt(sum)<=d) ans ++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6064
// #include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <vector>
using namespace std;

int main(){
  list<int> l;
  int n; cin>>n;
  string cmd; int x;
  for(int i=0; i<n; ++i){
    cin>>cmd;
    if(cmd[0]=='i'){
      cin>>x;
      l.push_front(x);
    } else if(cmd.length()==6){
      cin>>x;
      auto j=find(begin(l), end(l), x);
      if(j!=end(l)){
        l.erase(j);
      }
    } else if(cmd[6]=='F'){
      l.pop_front();
    } else{
      l.pop_back();
    }
  }
  auto j=--cend(l);
  for(auto i=cbegin(l); i!=j; ++i){
    cout<<*i<<' ';
  }
  cout<<*j<<'\n';
  return 0;
}


Measured memory_bytes: 34316
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'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'};
vector<char>AL(26);
AL = {'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'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N;
	cin >> N;
	vector<char>S(N);
	rep(i, N) {
		cin >> S[i];
	}
	int cnt = 0;
	rep(i, N) {
		if (S[i] == 'Y') {
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;
}

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

using namespace std;

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    vi a(m);
    rep(i, m) cin >> a[i];
    int k = upper_bound(all(a), x) - a.begin();
    cout << min(k, m - k) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define int long long
   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; }
    const int MAX =200005;
const int MOD =1e9+7;
using mint = modint998244353;
//using mint = modint;
using S=pair<mint,int>;
using F=int;

 mint tx[200000];
 mint kx[10];
S op(S a,S b){
 
  return {a.first*tx[b.second]+b.first,a.second+b.second};
}
S e(){
  mint w=0;
  return {w,0};
}
S mapping(F  f,S x){
  if(f==-1)return x;
  return {(tx[x.second]-1)*kx[f],x.second};
}
F composition(F f,F g){
  if(f==-1)return g;
  return f;
}
F id(){
  return -1;
}
signed main(){
int n,q;
cin>>n>>q;
lazy_segtree<S, op, e, F, mapping, composition, id> seg(n);
int l,r,d;
mint f=1;
tx[0]=1;
for(int i=1;i<200001;i++)tx[i]=tx[i-1]*10;
for(int i=1;i<=9;i++){
  kx[i]=i;
  kx[i]/=9;
}
for(int i=0;i<n;i++)seg.set(i,{f,1});
cerr<<seg.all_prod().first.val()<<endl;
for(int i=0;i<q;i++){
  cin>>l>>r>>d;l--;
seg.apply(l,r,d);
cout<<seg.all_prod().first.val()<<endl;

}
}



Measured memory_bytes: 17512
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#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 ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

#define MAX_E 2005
#define MAX_V 2000

struct edge{int from,to,cost; };
edge es[MAX_E];
int V,E;
ll d[MAX_V+1] = {};//最短径路を格納


bool bellmanford(ll s){
	rep(i,0,V)d[i] = linf;
	d[s] = 0;
	rep(j,0,V-1)rep(i,0,E)if(d[es[i].from]!=linf)d[es[i].to]=min(d[es[i].to],d[es[i].from]+es[i].cost);
	
	rep(j,0,V)rep(i,0,E)if(d[es[i].from]!=linf){
	
		if(d[es[i].to]>d[es[i].from]+es[i].cost)d[es[i].to]=-linf;
	}
	if(d[V-1]==-linf)ret 1;
	else ret 0;
}
 

int main(){
  int first = 0;
  bool flag;
  cin >> V >> E ;
  
  rep(i,0,E){
    cin >> es[i].from >> es[i].to >> es[i].cost;
    es[i].from --;
    es[i].to --;
    es[i].cost *= -1;
  }

  
  flag = bellmanford(first);
  
  if(flag == true){
    cout << "inf" << endl;
  }else{
  	cout << -d[V-1] << endl;
  }

	return 0;
}


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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int k, x;
    cin >> k >> x;
    if(500 * k >= x){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
N,M,Q = map(int, input().split())
L = [[int(l) for l in input().split()] for _ in range(Q)]

def f(A):
    res = 0
    for i in range(Q):
        if A[L[i][1]-1]-A[L[i][0]-1] == L[i][2]:
            res += L[i][3]

    return res

import itertools

nums = [i for i in range(1, M+1)]
ans = 0
for A in itertools.combinations_with_replacement(nums, N):
    ans = max(ans, f(A))

print(ans)

Measured memory_bytes: 9152
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()
x,y = li()

command = s.split("T")

ud = set()
lr = set()

lr.add(len(command[0]))
ud.add(0)

for i, cm in enumerate(command[1:]):
    if i%2 == 1:
        new_lr = set()
        for element in lr:
            new_lr.add(element + len(cm))
            new_lr.add(element - len(cm))
            
        lr = new_lr
        
    else:
        new_ud = set()
        for element in ud:
            new_ud.add(element + len(cm))
            new_ud.add(element - len(cm))
            
        ud = new_ud

if (x in lr) and (y in ud):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 50780
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine().Split(' ');

            if (N[0] == N[1])
            {
                Console.WriteLine(N[2]);
            }
            else if(N[1] == N[2])
            {
                Console.WriteLine(N[0]);
            }
            else
            {
                Console.WriteLine(N[1]);
            }
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <ctype.h>
#include <string.h>

int f(const void *a, const void *b)
{
	return(*(int *)a - *(int *)b);
}
int main(void)
{
	int n;
	scanf("%d",&n);
	int *v;
	v = (int *)malloc(sizeof(int)*(n));
	double *a;
	a = (double *)malloc(sizeof(double)*(n));
	int i = 0;
	while (i < n)
	{
		scanf("%d",&v[i]);
		i++;
	}
	qsort(v,n,sizeof(int),f);
	i = 0;
	while (i < n)
	{
		a[i] = (double)v[i];
		i++;
	}
	i = 1;
	while (i < n)
	{
		a[i] = (a[i] + a[i-1])/2.0;
		i++;
	}
	printf("%.12f\n",a[n-1]);
	return(0);
}


Measured memory_bytes: 128
#include<stdio.h>
char a[28] = {"abcdefghijklmnopqrstuvwxyz"};
char b[27] = {};
char c[100] = {};
int i, j;
int d;

int main(){
	scanf("%s", c);
	for (i = 0; i < 100; i++){
		for (j = 0; j < 21; j++){
			if (c[i] == a[j]){
				b[j]++;
			}
		}
		}
	for (i = 0; i < 21; i++){
		if (b[i] % 2 == 0||b[i]%2==2){
			d++;
		}
		else{
		}
	}
	if (d == 21){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll N,M;
vector<string> A,B;

bool isMatch(int sy,int sx){
    for(int i=0;i<M;i++)for(int j=0;j<M;j++){
        int y = sy +i;
        int x = sx+j;
        if(A[y][x] != B[i][j]){
            return false;
        }
    }
    return true;
}

int main() {
    cin >> N >>M;
    A.resize(N);
    B.resize(M);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    for(int i=0;i<M;i++){
        cin >> B[i];
    }
    for(int i=0;i<=(N-M);i++)for(int j=0;j<=(N-M);j++){
        if(isMatch(i,j)){
            cout <<"Yes"<<endl;
            return 0;
        }
    }
    cout <<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

enum Type{

	pre_0,
	pre_1,
};

int M,N;
int table[SIZE];
int dp[SIZE][2];


int main(){

	scanf("%d %d",&M,&N);

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

		scanf("%d",&table[i]);
		table[i]--;
	}

	int ans;

	if(M >= 3){

		ans = 0;
		for(int i = 0; i < N-1; i++){

			if(table[i] == table[i+1]){ //i+1を、iとi+2のいずれとも違うシャツにできる
				ans++;
				table[i+1] = -BIG_NUM;
			}
		}

	}else{ //M == 2

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

			dp[i][pre_0] = 0;
			dp[i][pre_1] = 0;
		}

		if(table[0] == 0){

			dp[0][pre_0] = 0;
			dp[0][pre_1] = 1;

		}else{

			dp[0][pre_0] = 1;
			dp[0][pre_1] = 0;
		}

		for(int i = 1; i < N; i++){

			if(table[i] == 0){

				//0のまま
				dp[i][pre_0] = dp[i-1][pre_1];

				//1にする
				dp[i][pre_1] = dp[i-1][pre_0]+1;

			}else{ //table[i] == 1

				//0にする
				dp[i][pre_0] = dp[i-1][pre_1]+1;

				//1のまま
				dp[i][pre_1] = dp[i-1][pre_0];
			}
		}

		ans = min(dp[N-1][pre_0],dp[N-1][pre_1]);
	}

	printf("%d\n",ans);

	return 0;
}



Measured memory_bytes: 4292
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>Pa;
const long long INF = 1ll<<62;
const int maxn = 2e6+10;
ll n,m,cnt;
map<ll,ll>Ma[maxn];//标记
vector<Pa>V[maxn];//存放pair关系
int vis[maxn];
ll dist[maxn];
int getid(int u,int v)//返回编号 
{
	if(Ma[u][v]==0)
		Ma[u][v]=++cnt;
	return Ma[u][v];
} 
void spfa()
{
	for(int i=0;i<=cnt;i++)
	{
		vis[i]=0;
		dist[i]=INF;
	}
	queue<int>q;
	q.push(1);
	dist[1]=0;
	vis[1]=1;
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		vis[u]=0;
		for(int i=0;i<V[u].size();i++)
		{
			int v=V[u][i].first;
			int Valu=V[u][i].second;
			if(dist[v] > dist[u]+Valu)
			{
				dist[v]=dist[u]+Valu;
				if(vis[v]==0)
				{
					vis[v]=1;
					q.push(v);
				}
			}	
		}		
	}
	if(dist[n]==INF)
		cout<<"-1"<<endl;
	else
		cout<<dist[n]/2<<endl;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	cnt=n;//从n+1开始记录编号
	for(int i=0;i<m;i++)
	{
		int u,v,id;
		cin>>u>>v>>id;
		int uid=getid(u,id);
		int vid=getid(v,id);
		V[u].push_back(Pa(uid,1));
		V[uid].push_back(Pa(u,1));
		
		V[v].push_back(Pa(vid,1));
		V[vid].push_back(Pa(v,1));
		
		V[vid].push_back(Pa(uid,0));
		V[uid].push_back(Pa(vid,0));
	} 
	spfa();
	return 0;
}
 

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

int main() {

    string s;

    cin >> s;
    int len = s.size();
  if(len != 1){
   	if(s.at(0) == '?'){
      if(s.at(1) == 'D'){
      	s.at(0) = 'P';
      }else{
        s.at(0) = 'D';
      }
          
    }
	    if(s.at(len -1) == '?'){
        s.at(len - 1) = 'D';
      
    }
  
  for(int i = 1 ;i <= len -2;i++){
    if(s.at(i) == '?'){
      if(s.at(i -1) == 'P'){
        s.at(i) = 'D';
        
      }
       else if(s.at(i + 1) == 'D' || s.at(i + 1) == '?'){
        s.at(i) = 'P';
         
      }else{
      
         s.at(i) = 'D';
       }
         
       
     
    }
  }
  }else{
    if(s.at(0) == '?'){
      s.at(0) = 'D';
    }
    
  }
	cout << s;

}

Measured memory_bytes: 3744
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    int n;
    while(1){
        cin>>n;
        if(n==0)break;
        vi num(1001);
        for(int i=0;i<1001;i++)num[i]=i;
        
        int ans=0;
        for(int i=2;i<n;i++){
            int sum=0;
            for(int j=1;j<=i;j++)sum+=num[j];
            if(sum==n){
                ans++;
                // cout<<i<<" "<<sum<<endl;
            }
            for(int j=i+1;j<1001;j++){
                sum+=num[j];
                sum-=num[j-i];
                if(sum==n){
                    ans++;
                    // cout<<i<<" "<<j<<" "<<sum<<endl;
                }
            }
        }
        cout<<ans<<endl;
    }
    

//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\n"
#define all(v) v.begin(), v.end()
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long int i;
typedef long long int lli;
typedef pair<lli, lli> pll;
lli mod = 998244353;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // lli t;
    // cin >> t;
    vector<pll> v;
    lli n, k;
    cin >> n >> k;
    for1(i, 0, k)
    {
        lli a, b;
        cin >> a >> b;
        v.pb(mp(a, b));
    }
    vector<lli> s(n + 2, 0);
    s[n] = 1;
    // cout << n << endl;
    for (int i = n - 1; i >= 1; i--)
    {
        s[i] = s[i + 1];
        s[i] %= mod;
        for (int j = 0; j < k; j++)
        {
            lli l = v[j].first + i, r = v[j].second + i;
            r = min(n, r);
            if (l <= n)
            {
                lli x = s[l] + mod - s[r + 1];
                x %= mod;
                s[i] += x;
            }
            s[i] %= mod;
        }
        // cout << s[i] << " ";
        s[i] %= mod;
    }
    s[1] += mod;
    s[1] -= s[2];
    s[1] %= mod;
    cout << s[1] << endl;
}

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


int main(){
    int N;
    string str;
    cin >> N;
    for(;N--;){
        cin >> str;
        int t = 0, cf = 0;
        for(int x = 0; x < str.size(); x++){
            t += str[x] - '0';
            if(t >= 10){
                cf++;
                t = t/10 + t%10;
            }
        }
        if((str.size() + cf) % 2){
            cout << "Audrey wins.\n";
        }else{
            cout << "Fabre wins.\n";
        }
    }
    return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int a,b,c,d;
  	cin>>a>>b>>c>>d;
  	cout<<800*a-a/15*200<<endl;
}

Measured memory_bytes: 3636
import Data.Char
import Text.Printf

main = do
  [a,b,c,d] <- map digitToInt <$> getLine
  putStrLn $ f a b c d

f :: Int -> Int -> Int -> Int -> String
f a b c d
  | a + b + c + d == 7 = printf "%d+%d+%d+%d=7" a b c d
  | a + b + c - d == 7 = printf "%d+%d+%d-%d=7" a b c d
  | a + b - c + d == 7 = printf "%d+%d-%d+%d=7" a b c d
  | a + b - c - d == 7 = printf "%d+%d-%d-%d=7" a b c d
  | a - b + c + d == 7 = printf "%d-%d+%d+%d=7" a b c d
  | a - b + c - d == 7 = printf "%d-%d+%d-%d=7" a b c d
  | a - b - c + d == 7 = printf "%d-%d-%d+%d=7" a b c d
  | a - b - c - d == 7 = printf "%d-%d-%d-%d=7" a b c d


Measured memory_bytes: 508
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
            out.flush();
        }
    }

    private void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        List<List<Node>> edgeList = new ArrayList<List<Node>>();
        for (int i = 0; i < n; i++) {
            edgeList.add(new ArrayList<>());
        }

        for (int i = 0; i < n - 1; i++) {
            int u = in.nextInt() - 1;
            int v = in.nextInt() - 1;
            int w = in.nextInt();

            Node node = new Node();
            node.to = v;
            node.cost = w;
            edgeList.get(u).add(node);

            node = new Node();
            node.to = u;
            node.cost = w;
            edgeList.get(v).add(node);
        }

        int[] ans = new int[n];
        for (int i = 0; i < n; i++) {
            ans[i] = -1;
        }

        Queue<Integer> nodeQueue = new ArrayDeque<>();
        nodeQueue.add(0);
        ans[0] = 0;
        while (!nodeQueue.isEmpty()) {
            int index = nodeQueue.poll();
            for (Node toNode : edgeList.get(index)) {
                if (ans[toNode.to] != -1) {
                    continue;
                }

                ans[toNode.to] = (ans[index] + toNode.cost) % 2;
                nodeQueue.add(toNode.to);
            }
        }

        for (int i : ans) {
            out.println(i);
        }
    }
}

class Node {
    int to;
    int cost;
}

class InputReader implements AutoCloseable {
    private final Scanner sc = new Scanner(System.in);

    String next() {
        return this.sc.next();
    }

    int nextInt() {
        return Integer.parseInt(this.sc.next());
    }

    long nextLong() {
        return Long.parseLong(this.sc.next());
    }

    double nextDouble() {
        return Double.parseDouble(this.sc.next());

    }

    @Override
    public void close() {
        this.sc.close();
    }
}


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

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	ll x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	ll k1 = x/d;
	if(k1 > k)
		cout << x-k*d;
	else
	{
		x = x - k1*d;
		k = k - k1;
		if(k%2)
			cout << abs(x-d);
		else 
			cout << x;
	}
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
//double pi=3.1415926535898;
//double pi=acos(-1.0);
#define scarr(a,s,e) for(int i=s;i<=int(e);i++) scanf("%d ",&a[i]);
#define prarr(a,s,e) for(int i=s;i<=int(e);i++) printf("%d ",a[i]);
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define mkp        make_pair
#define sc(x)      scanf("%d",&x)
#define scl(x)     scanf("%lld",&x)
#define pr(x)      printf("%d ",x)
#define prl(x)     printf("%lld ",x)
#define prln(x)    printf("%d\n",x)
#define prlln(x)   printf("%lld\n",x)
#define r0         return 0;
#define CC         continue;
#define scd(x)     scanf("%lf",&x)
#define prd(x)     printf("%.10f\n",x)
#define bb(x)      cerr<< x <<endl;
#define pii        pair<int,int>
#define vi         vector<int>
#define fr         first
#define se         second
//#define max(a,b) a<b?b:a
//#define min(a,b) a<b?a:b
const ll M  = 1e9+7 ;
const ll inf = 1e18 ;
const int si = 1e5+9;
const int N = 1e5+5 ;
//////////////////////    Hi    ^_^  hack me if you can :P

int main()
{
    int n,t,mx=0,sm=0;
    int a[2000];
    cin>>n>>t;
    lop(i,t)
    {
        cin>>a[i];
        mx=max(mx,a[i]);
        sm+=a[i];
    }
    sm-=mx;
    cout<<max(0,mx-sm-1);
    r0;
}

/*

ll pwmod(ll a, ll n, ll mod) {
    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}
Wj0944296025*
*/
/*
freopen("output.txt","w",stdout);
freopen("input.txt","r",stdin);
for (int i=0;i<n;i++)            Hi    ^_^  hack me if you can :P
int mx[]= {0,0,1,-1, 1,1,-1,-1};
int my[]= {1,-1,0,0, 1,-1,1,-1};
bool inside (int i,int j) {return (i>=0 && i<n && j>=0 && j<m);}

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

void gcd(LL n,LL m,LL &d,LL &xx,LL &yy){
    if(!m) {d=n; xx=1; yy=0;}
    else {gcd(m,n%m,d,yy,xx); yy-=xx*(n/m);}
}

int getm(int l,int r)
{
    if(l>r)
        return N;
    if(l==r)
        return 0;
    if(l==r-1)
        return s[l] != s[r];
    if(s[l]==s[r])
        return getm(l+1,r-1);
    else
        return 1+min(getm(l+1,r),getm(l,r-1));
}

int BIT[si], a[si], n;
void update(int x, int delta)
{
    for(; x <= N; x += x&-x)
        BIT[x] += delta;
}
int query(int x)
{
    int sum = 0;
    for(; x > 0; x -= x&-x)
        sum += BIT[x];
    return sum;
}

*/


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    char c[2000] = {0}, w[15] = {0};
    int i, j, m, n, o, p;
    m=0;
    while(1){
        scanf("%c", &w[m]);
        if(w[m] == '\n'){
            break;
        }
        m = m+1;
    }
    n = 0;
    while(1){
        scanf("%c", &c[n]);
        if(c[n] == 'T' && c[n-1] == 'X' && c[n-2] == 'E' && c[n-3] == 'T' && c[n-4] == '_' && c[n-5] == 'F' && c[n-6] == 'O' && c[n-7] == '_' && c[n-8] == 'D' && c[n-9] == 'N' && c[n-10] == 'E'){
            break;
        }
        n += 1;
    }
    
    p=0;
    for(i=0; i<n; i++) {
        if(w[0] == c[i] || w[0] == c[i]+32 || w[0] == c[i]-32){
            if(c[i+m] == ' ' || c[i+m] == '\n' || w[0] == c[0]){
                if(c[i-1] == ' ' || c[i-1] == '\n' || w[0] == c[0]+32 || w[0] == c[0]-32){
                    o=o+1;
                    for(j=0; j<m; j++){
                        if(w[j] == c[i+j] || w[j] == c[i+j]+32 || w[j] == c[i+j]-32){
                            o=o+1;
                        }
                    }
                }
            }
            if(o==m+1){
                p=p+1;
            }
            o=0;
        }
    }
    
    printf("%d\n", p);
    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<pair<long long, long long> > list(n);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    list[i].first = a + b;
    list[i].second = a;
  }
  sort(list.rbegin(), list.rend());
  long long sum1 = 0, sum2 = 0;
  for (int i = 0; i < n; i++) {
    if (i%2 == 0) {
      sum1 += list[i].second;
    }
    else {
      sum2 += list[i].first - list[i].second;
    }
  }
  long long ans = sum1 - sum2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

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

Measured memory_bytes: 256
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
   s = input()
   flag = True
   for i,v in enumerate(s):
      if i != 0:
         if s[i-1] == v:
            flag = False
            break
   if flag:
      print("Good")
   else:
      print("Bad")

if __name__ == "__main__":
    main()

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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define ALL(a) a.begin(), a.end()
#define FOR(x,to) for(x=0;x<(to);x++)

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

int A[E5+2];

void solve() {	
	ll s = 0;
	int N;
	cin >> N;
	A[0] = 0;
	for (int i = 1; i<=N+1; ++i) {
		cin >> A[i];
		s += abs(A[i]-A[i-1]);
	}
	A[N+1] = 0;

	for (int i = 1; i <= N; ++i) {
		cout << s - abs(A[i]-A[i-1]) - abs(A[i]-A[i+1]) + abs(A[i-1]-A[i+1]) << '\n';
	}
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;

using Real = long double;
using Point = complex< Real >;
const Real EPS = 1e-12, PI = acos(-1.0L);

inline bool eq(Real a, Real b) { return fabs(b-a) < EPS;}

istream &operator>>(istream&is, Point &p)
{
    Real a, b;
    is >> a >> b;
    p = Point(a, b);
    return is;
}

struct Circle
{
    Point p;
    Real r;

    Circle() = default;

    Circle(Point p, Real r) : p(p), r(r) {}
};

using Points = vector< Point >;
using Circles = vector< Circle >;

int checker(Circle c1, Circle c2)
{
    if (c1.r < c2.r) swap(c1, c2);
    Real d = abs(c1.p - c2.p);
    if (c1.r + c2.r < d) return 4;
    if (eq(c1.r+c2.r, d)) return 3;
    if (c1.r - c2.r < d) return 2;
    if (eq(c1.r - c2.r, d)) return 1;
    return 0;
}

bool intersect(Circle c1, Circle c2)
{
    int tmp = checker(c1, c2);
    // 交点の存在TF
    return 1 <= tmp and tmp <= 3;
}

pair<Point, Point> crosspoint(const Circle &c1, const  Circle &c2)
{
    Real d = abs(c1.p - c2.p);
    Real a = acos((d*d + c1.r * c1.r - c2.r * c2.r) / (2 * d * c1.r));
    Real t = atan2(c2.p.imag() - c1.p.imag(), c2.p.real() - c1.p.real());

    // Real theta = a+t, a-t
    Point p1 = c1.p + Point(cos(t+a) * c1.r, sin(t+a) * c1.r);
    Point p2 = c1.p + Point(cos(t-a) * c1.r, sin(t-a) * c1.r);
    return {p1, p2};
}

int N, K;
Points P;
vector<int> c;
vector<long double> r;
Circles C;

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

    cin >> N >> K;
    P.resize(N);
    c.resize(N);
    r.resize(N);
    C.resize(N);
    rep(i,N) cin >> P[i] >> c[i];
}

void solve()
{
    long double ok = 1e6;
    long double ng = 0.0;

    while((ok-ng)>1e-8)
    {
        bool clear = false;
        long double mid = (ok + ng) / 2;
        // input
        rep(i,N)
        {
            r[i] =  mid / c[i];
            C[i] = Circle(P[i], r[i]);
        }
        Points Check;
        // 候補となる点を抽出する。中心と交点を投げる
        rep(i,N)
        {
            Check.push_back(P[i]);
            REP(j,i+1,N)
            {
                if (intersect(C[i], C[j]))
                {
                    auto tmp = crosspoint(C[i], C[j]);
                    Check.push_back(tmp.first);
                    Check.push_back(tmp.second);
                }
            }
        }

        for (auto p : Check)
        {
            int cnt = 0;
            rep(i,N)
            {
                if(abs(P[i] - p) <= r[i] + EPS) cnt++;
            }

            if (cnt >= K) clear = true;
        }
        if (clear) ok = mid;
        else ng = mid;
    }

    cout << fixed << setprecision(20) << ok << endl;
}

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




Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;

using namespace std;

int main()
{
    int n;
    cin >> n;
    int k = n;
    int sum = 0;
    while(k)
    {
        sum += k%10;
        k /= 10;
    }
    if(n%sum == 0)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int64_t sheets[50] {1};
int64_t patties[50] {1};

int64_t f(int64_t n, int64_t x)
{
  if (x <= 0) return 0;
  if (n <= 0) return 1;
  if (x <= sheets[n - 1] + 1) {
    return f(n - 1, x - 1);
  } else {
    return patties[n - 1] + 1 + f(n - 1, x - 2 - sheets[n - 1]);
  }
}

int main()
{
  int64_t n, x;
  cin >> n >> x;
  for (auto i = 1; i < n; i++) {
    sheets[i] = sheets[i - 1] * 2 + 3;
    patties[i] = patties[i - 1] * 2 + 1;
  }
  cout << f(n, x) << endl;
}


Measured memory_bytes: 256
string = input()
if len(string) < 26:
  for i in range(97, 124):
    if chr(i) not in string:
      break
  print(string + chr(i))
else:
  val = [string[-1]]
  for i in string[-2::-1]:
    if i > val[-1]:
      val.append(i)
    else:
      break
  if len(val) == 26:
    print(-1)
  else:
    print(string[:-len(val)-1] + min(i for i in val if i > string[-len(val)-1]))

Measured memory_bytes: 9024