akhauriyash/Code-Regression huggingface dataset:
/*
 * Dice1.cpp
 *
 *  Created on: 2014/08/08
 *      Author: WanWan1985
 */
#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;
 
// for util
#define ALL(a)          (a).begin(), (b).end()
#define FOR(i, a, b)    for(int i = (a); i < (b); i++)
#define REP(i, n)       FOR(i, 0, n)
#define PB              push_back
#define MP              make_pair
#define CL              clear
#define EXIT            (0)
#define PINT            pair<int, int>
 
typedef unsigned int u_int;
typedef long long ll;

enum E_DiceArrayIndex {
	eTOP = (0),
	eSOUTH,
	eEAST
//	eWEST,
//	eNORTH,
//	eDOWN
};

enum E_DiceLavel {
	eOne = (0),
	eTwo,
	eThree,
	eFour,
	eFive,
	eSix,
	eDiceLavelNum
};

// Diceクラス
class Dice {
	vector<int> m_vecDiceNum;
	vector<pair<E_DiceLavel, E_DiceLavel>> m_vecDiceState;
public:
	// 初期状態設定
	void init(const vector<int>& a_vecInputData) {
		REP(i, a_vecInputData.size()) {
			m_vecDiceNum.PB(a_vecInputData.at(i));
		}
		m_vecDiceState.PB(make_pair(eOne, eSix));		// TOP
		m_vecDiceState.PB(make_pair(eTwo, eFive));		// SOUTH
		m_vecDiceState.PB(make_pair(eThree, eFour));	// EAST
	}

	// 移動後のDice配置更新
	void upDateDicePosition(const char& a_chrCommand) {
		if ('S' == a_chrCommand) {
			pair<E_DiceLavel, E_DiceLavel> Top = m_vecDiceState[eTOP];
			pair<E_DiceLavel, E_DiceLavel> South = m_vecDiceState[eSOUTH];
			m_vecDiceState[eSOUTH] = Top;
			m_vecDiceState[eTOP] = make_pair(South.second, South.first);
		} else if ('N' == a_chrCommand) {
			pair<E_DiceLavel, E_DiceLavel> Top = m_vecDiceState[eTOP];
			pair<E_DiceLavel, E_DiceLavel> South = m_vecDiceState[eSOUTH];
			m_vecDiceState[eSOUTH] = make_pair(Top.second, Top.first);
			m_vecDiceState[eTOP] = South;
		} else if ('W' == a_chrCommand) {
			pair<E_DiceLavel, E_DiceLavel> Top = m_vecDiceState[eTOP];
			pair<E_DiceLavel, E_DiceLavel> East = m_vecDiceState[eEAST];
			m_vecDiceState[eTOP] = East;
			m_vecDiceState[eEAST] = make_pair(Top.second, Top.first);
		} else if ('E' == a_chrCommand) {
			pair<E_DiceLavel, E_DiceLavel> Top = m_vecDiceState[eTOP];
			pair<E_DiceLavel, E_DiceLavel> East = m_vecDiceState[eEAST];
			m_vecDiceState[eTOP] = make_pair(East.second, East.first);
			m_vecDiceState[eEAST] = Top;
		}
	}
	// サイコロ上面の数字を取得する
	int GetTopSurfaceNum() {
		pair<E_DiceLavel, E_DiceLavel> Top = m_vecDiceState[eTOP];
		return m_vecDiceNum[Top.first];
	}
};

int main(void) {

	int i, j, k, l, m, n;
	cin >> i >> j >> k >> l >> m >> n;
	vector<int> vecDiceNum;
	vecDiceNum.PB(i);
	vecDiceNum.PB(j);
	vecDiceNum.PB(k);
	vecDiceNum.PB(l);
	vecDiceNum.PB(m);
	vecDiceNum.PB(n);

	string strCommand;
	cin >> strCommand;

	Dice Dice1;
	Dice1.init(vecDiceNum);

	REP(i, strCommand.size()) {
		const char chrCommand = strCommand.at(i);
		Dice1.upDateDicePosition(chrCommand);
	}

	cout << Dice1.GetTopSurfaceNum() << endl;

	return EXIT;
}

Measured memory_bytes: 1228
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 100000000000000000

int main() {
    long double A;
    long double B;
    cin >> A >> B;
    ll ans = floor((long double)A * B + 0.001);
    cout << ans << endl;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    int a, b; cin >> a >> b;
    if(a <= 5) cout << 0;
    else if (a <= 12) cout << b / 2;
    else cout << b;
    return 0;
    }



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

using namespace std;

int main(){

    int N; cin >> N;
    vector<int> L(N);
    for(int i=0; i<N; i++)cin >> L[i];
    long res=0;

    sort(L.begin(), L.end(), greater<int>());

    for(int i=0; i<N-2; i++){
        for(int j=i+1; j<N-1; j++){
            for(int k=j+1; k<N; k++){
                if(L[i]+L[j]>L[k]&&L[k]+L[j]>L[i]&&L[i]+L[k]>L[j]) res++;
                else break;
            }
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 384
#template
def inputlist(): return [int(j) for j in input().split()]
#template
#issueから始める
N = int(input())
a = inputlist()
ans = [0]*(N+1)
flag = [0]*(N+1)
def divisore(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort(reverse=True)
    return divisors
for i in range(1,N+1):
    k = N+1-i
    d = N//k
    if d == 1:
        ans[k] = a[k-1]
        if a[k-1] == 1:
            li = divisore(k)
            for j in range(len(li)):
                x = li[j]
                flag[x] +=1
    else:
        if flag[k] % 2== a[k-1]:
            ans[k] = 0
        else:
            ans[k] = 1
            lia = divisore(k)
            for s in range(len(lia)):
                y = lia[s]
                flag[y] +=1
ansa = ans[1:]
count = 0
lis = []
for i in range(N):
    if ansa[i] == 1:
        count+=1
        lis.append(i+1)
if count == 0:
    print(0)
    exit()
print(count)
print(*lis)

Measured memory_bytes: 74856
#include <algorithm>
#include <iostream>
#include <list>
#include <map> //連想配列
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector> //動的配列

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

bool check(int t, int x, int y) {
  int z = t - abs(x) - abs(y);
  if (z >= 0 && z % 2 == 0) {
    return true;
  } else {
    return false;
  }
}

int main() {
  int N;
  std::cin >> N;
  int tt[N], xx[N], yy[N];
  int t, x, y;
  int t0 = 0, x0 = 0, y0 = 0;
  for (int i = 0; i < N; i++) {
    std::cin >> tt[i] >> xx[i] >> yy[i];
  }

  for (int i = 0; i < N; i++) {
    t = tt[i] - t0;
    x = xx[i] - x0;
    y = yy[i] - y0;
    if (!check(t, x, y)) {
      std::cout << "No" << std::endl;
      return 0;
    } else {
      t0 = t;
      x0 = x;
      y0 = y;
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}


Measured memory_bytes: 1408
n = int(input())
a = list(map(int,input().split()))
amari = True
for i in a:
    if i%2 == 0:
        if i%3 == 0 or i%5 == 0:
            amari = True
        else:
            amari = False
            break
print('APPROVED' if amari else 'DENIED')

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

void solve() {
    int N;
    cin >> N;
    map<string, int> ss;
    int M = 0;
    for (int i = 0; i < N; ++i) {
        string s;
        cin >> s;
        ss[s] += 1;
        if (M < ss[s]) M = ss[s];
    }

    for (pair<string, int> s : ss) {
        if (s.second == M) cout << s.first << endl;
    }
}

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


Measured memory_bytes: 25216
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;


int main(){
  int k; string s;
  cin>>k>>s;
  for (int i = 0; i < k; i++) {
    cout<<s[i];
    if(i==s.length()-1){
      return 0;
    }
  }
  cout<<"...";
}





/* きょむ〜 */


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  ll a,b;cin>>a>>b;
  ll ret=abs(a-b);
  if(ret%2){
    ret=min(a+(b-a-1)/2,n-b+1+(b-a-1)/2);
  }
  else ret/=2;
  cout<<ret<<endl;
  return 0;

}


Measured memory_bytes: 256
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll a,b,c,d;
void solve()
{
    cin>>a>>b>>c>>d;
    a--;
    ll gcd=c/__gcd(c,d)*d;
    ll a1=b-b/c-b/d+b/gcd;
    ll a2=a-a/c-a/d+a/gcd;
    //cout<<a2<<endl;
    cout<<a1-a2<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int N, A, B;

int Insert(int t, int i, int b) {
  return (t >> i << (i+1)) + (b << i) + (t & ((1 << i)-1));
}

int Remove(int t, int i) {
  return (t >> (i+1) << i) | (t & ((1 << i)-1));
}

vector<int> Create(int n, int a, int b) {
  vector<int> ret;
  assert(n > 0);

  if (n == 1) {
    if (a == 0) assert(b == 1);
    if (a == 1) assert(b == 0);
    ret.eb(a);
    ret.eb(b);
    return ret;
  }

  rep(i, n) {
    int p = a >> i & 1;
    int q = b >> i & 1;
    assert(Insert(Remove(a, i), i, p) == a);
    assert(Insert(Remove(b, i), i, q) == b);
    if (p == q) {
      auto res = Create(n-1, Remove(a, i), Remove(b, i));
      for (int v : res) {
        ret.eb(Insert(v, i, p));
        ret.eb(Insert(v, i, p^1));
        p ^= 1;
      }
      assert(ret.front() == a);
      assert(ret.back() == b);
      assert(ret.size() == 1 << n);
      return ret;
    }
  }

  auto res = Create(n-2, a >> 2, b >> 2);
  deque<int> fgray = {0, 1, 3, 2};
  while (1) {
    int v = fgray.front();
    if (v == (a&3)) break;
    fgray.pop_front();
    fgray.eb(v);
  }

  deque<int> ngray;
  rep(i, 4) {
    ngray.eb(fgray[(i+3)%4]);
  }

  rep(i, 4) {
    ret.eb((res[0] << 2) | fgray[i]);
  }

  reps(i, 1, res.size()) {
    rep(j, 4) {
      ret.eb((res[i] << 2) | ngray[j]);
    }
    reverse(all(ngray));
  }
  assert(ret.front() == a);
  assert(ret.back() == b);
  assert(ret.size() == 1 << n);
  return ret;
}

int main() {
  scanf("%d%d%d", &N, &A, &B);

  if (__builtin_popcount(A^B)%2 == 0) {
    puts("NO");
    return 0;
  }

  puts("YES"); 
  auto ans = Create(N, A, B);
  rep(i, 1 << N) {
    if (i) cout << " ";
    cout << ans[i];
  }
  cout << "\n";
}


Measured memory_bytes: 1668
// {{{
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)x.size())
#define FOR(i,n) for(int i=0;i<n;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
using LL=long long;
using PII=pair<int,int>;
using VI=vector<int>;

#ifdef FEI
template<typename T>
void _dump(const char* s, T&& head) { cerr<<s<<"="<<head<<endl; }
template<typename T, typename... Args>
void _dump(const char* s, T&& head, Args&&... tail) {
    int c=0;
    while (*s!=',' || c!=0) {
        if (*s=='(' || *s=='[' || *s=='{') c++;
        if (*s==')' || *s==']' || *s=='}') c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1, tail...);
}

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, ##__VA_ARGS__); \
} while(0);

template<typename Iter>
ostream& _out(ostream &s, Iter b, Iter e) {
    s<<'[';
    for (auto it=b; it!=e; it++) s<<(it==b?"":",")<<*it;
    s<<']';
    return s;
}

template<typename A, typename B>
ostream& operator <<(ostream &s, const pair<A,B> &p) { return s<<"("<<p.first<<","<<p.second<<")";}
template<typename T>
ostream& operator <<(ostream &s, const vector<T> &x) { return _out(s,ALL(x)); }
template<typename T, size_t N>
ostream& operator <<(ostream &s, const array<T,N> &x) { return _out(s,ALL(x)); }
template<typename T>
ostream& operator <<(ostream &s, const set<T> &x) { return _out(s,ALL(x)); }
template<typename A, typename B>
ostream& operator <<(ostream &s, const map<A,B> &x) { return _out(s,ALL(x)); }
#else
#define dump(...)
#endif

template<typename T>
void _R(T &x) { cin>>x; }
void _R(int &x) { scanf("%d",&x); }
void _R(LL &x) { scanf("%" PRId64,&x); }
void _R(double &x) { scanf("%lf",&x); }
void _R(char &x) { scanf(" %c",&x); }
void _R(char *x) { scanf("%s",x); }

void R(){}
template<typename T, typename... X>
void R(T& head, X&... tail) { _R(head); R(tail...); }
// }}}

LL max(LL a, LL b, LL c) {
    return max(a, max(b, c));
}

LL min(LL a, LL b, LL c) {
    return min(a, min(b, c));
}

int main() {
    LL ans = INT_MAX, n, m;
    R(n, m);

    if (n%3)
        ans = min(ans, m);
    else
        ans = 0;

    if (m%3)
        ans = min(ans, n);
    else
        ans = 0;

    for (int i=0; i<n; i++) {
        LL a, b, c;
        a = i*m;
        b = (n-i)*(m/2);
        c = (n-i)*((m+1)/2);
        ans = min(ans, max(a, b, c) - min(a, b, c));
    }

    for (int i=0; i<m; i++) {
        LL a, b, c;
        a = i*n;
        b = (m-i)*(n/2);
        c = (m-i)*((n+1)/2);
        ans = min(ans, max(a, b, c) - min(a, b, c));
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int 
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
#define lb lower_bound
#define ub upper_bound
//hash base 177013

const int INF=1000000000+7;

int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	//ll testcase;
	//cin>>testcase;
	//while(testcase--)
	{
		int n,w;
		cin>>n>>w;
		ll a[n][2];
		fi(0,n)
		{
			cin>>a[i][0]>>a[i][1];
		}
		ll dp[100000+2];
		fill(dp,dp+100002,INF);
		dp[0]=0;
		fi(0,n)
		{
			for(int j=100001;j>=0;j--)
			{
				if(j-a[i][1]>=0)
				dp[j]=min(dp[j],dp[j-a[i][1]]+a[i][0]);
			}
		}
		int ans=0;
		for(int i=100001;i>=0;i--)
		{
			if(dp[i]<=w)
			{
				ans=i;
				break;
			}
		}
		cout<<ans;
		
		
	}
}


Measured memory_bytes: 4416
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000000
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int L, R, xm = INF;

  std::cin >> L >> R;

  bool f[2019];

  memset(f, 0, sizeof(f));

  for (int i = L; i <= R; i ++) {
    if (f[i % 2019])
      break;

    f[i % 2019] = true;

    for (int j = i + 1; j <= std::min(i + 2222, R); j ++) {
      long long x = 1LL * i * j % 2019;
      
      if (x < xm)
        xm = x;
    }
  }

  std::cout << xm << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int A,B,C,D,sum=0;

	scanf("%d",&A);

	scanf("%d",&B);

	if(A>B){
		sum=sum+B;
	}
	else{
		sum=sum+A;
	}

	scanf("%d",&C);
	
	scanf("%d",&D);

	if(C>D){
		sum=sum+D;
	}
	else{
		sum=sum+C;
	}
	
	printf("%d",sum);

	return 0;
}	
	
		

	

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

// #define DEBUG 100

using namespace std;
using ll = unsigned long long;
using pii = pair<int, int>;

const int oo = 1e9 + 7;
const ll mod = 1e9 + 7,maxn = 100010;
const double PI = acos(-1);

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0); 
    string s;
    cin >> s;

    cout << (s[2] == s[3] and s[4] == s[5]? "Yes" : "No") << endl;
    return 0;
}

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

inline int read(){
    int a = 0;
    bool f = 0;
    char c = getchar();
    while(c != EOF && !isdigit(c)){
        if(c == '-')
            f = 1;
        c = getchar();
    }
    while(c != EOF && isdigit(c)){
        a = (a << 3) + (a << 1) + (c ^ '0');
        c = getchar();
    }
    return f ? -a : a;
}

const int MOD = 1e9 + 7 , MAXN = 4000 , MAXM = 200000;
int f[MAXN + 10][MAXN + 10] , jc[MAXN + 10 << 1] = {1 , 1} , ny[MAXN + 10 << 1] = {1} , a[MAXM + 10] , b[MAXM + 10];

inline long long poww(long long a , int b){
    int times = 1;
    while(b){
        if(b & 1)
            times = times * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return times;
}

int main(){
    for(long long i = 2 ; i <= MAXN << 1 ; i++)
        jc[i] = jc[i - 1] * i % MOD;
    ny[MAXN << 1] = poww(jc[MAXN << 1] , MOD - 2);
    for(long long i = (MAXN << 1) - 1 ; i ; i--)
        ny[i] = ny[i + 1] * (i + 1) % MOD;
    int N = read() , ans = 0;
    for(int i = 1 ; i <= N ; i++){
        a[i] = read();
        b[i] = read();
        f[-a[i] + 2000][-b[i] + 2000]++;
        ans = (ans + MOD - jc[a[i] + b[i] << 1] * (long long)ny[a[i] << 1] % MOD * ny[b[i] << 1] % MOD) % MOD;
    }
    for(int i = 1 ; i <= MAXN ; i++){
        f[i][0] += f[i - 1][0];
        f[0][i] += f[0][i - 1];
    }
    for(int i = 1 ; i <= MAXN ; i++)
        for(int j = 1 ; j <= MAXN ; j++)
            f[i][j] = ((f[i][j] + f[i - 1][j]) % MOD + f[i][j - 1]) % MOD;
    for(int i = 1 ; i <= N ; i++)
        ans = (ans + f[a[i] + 2000][b[i] + 2000]) % MOD;
    cout << ans * poww(2 , MOD - 2) % MOD;
    return 0;
}

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

const int mod = 1000000007;
long long calc(long long a, long long b, long long p)
{
	if (b == 0) return 1;
	if (b % 2 == 0)
	{
		long long d = calc(a, b / 2, p);
		return (d * d) % p;
	}
	else
		return (a * calc(a, b - 1, p)) % p;
}

long long nCr(long long n, long long r) 
{
	if (r == 0) return 1;
	long long x = 1;
	long long y  = 1;
 	for (long long i = 1; i <= r; ++i ) 
  	{
		x *= (n-i+1);
		x %= mod;
		y  *= i;
		y %= mod;
	}
	return x * calc(y, mod - 2, mod) % mod;
}
signed main(void)
{
	int n, k;
	cin >> n >> k;
	for(int i = 1; i <= k; i++)
	{
		ll ans;
		ans = nCr(n - k + 1, i) * nCr(k - 1, i - 1) % mod;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
string str;
map<char,ll>M;
map<pair<char,ll>,ll>MM;
ll expr(string str){
	if('0' <= str[0] && str[0] <= '9'){
		ll ret = 0;
		rep(i,str.size()) ret = ret*10LL+str[i]-'0';
		return ret;
	}
	else{
		char id = str[0];
		string nw = "";
		for(int i=2;i<str.size()-1;i++) nw.pb(str[i]);
		ll in = expr(nw);
		if(in > 1e17) return 1e18;
		if(M[id] <= in) return 1e18;
		if(0 > in) return 1e18;
		if(MM.find(mp(id,in)) == MM.end()) return 1e18;
		return MM[mp(id,in)];
	}
}
int main(){
	while(1){
		cin>>str;
		if(str == ".") return 0;
		M.clear(); MM.clear();
		vector<string>vec; vec.pb(str);
		while(1){
			cin>>str;
			if(str == ".") break;
			vec.pb(str);
		}
		rep(i,vec.size()){
			string par = vec[i];
			int pos = -1;
			rep(j,par.size()){
				if(par[j] == '=') pos = j;
			}
			if(pos == -1){
				//declaration
				char id = par[0];
				ll num = 0;
				for(int i=2;i<par.size()-1;i++){
					num = num*10+par[i]-'0';
				}
				M[id] = num;
			}
			else{
				string le="",ri="";
				for(int j=2;j<pos-1;j++) le.pb(par[j]);
				for(int j=pos+1;j<par.size();j++) ri.pb(par[j]);
				ll assign_val = expr(ri);
				char id = par[0];
				ll index = expr(le);
				//cout << index << " " << id << " " << assign_val << endl;
				if(index > 1e17 || index >= M[id] || index < 0 || assign_val > 1e17){
					cout << i+1 << endl;
					goto fail;
				}
				MM[mp(id,index)] = assign_val;
			}
		}
		cout << 0 << endl;
		fail:;
	}
}


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

int main()
{
    ll n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int big1, big2;
    vector<int> b = a;
    sort(b.begin(), b.end());
    big1 = b[n-1];
    big2 = b[n-2];

    rep(i,n) {
        if(a[i] == big1)
            cout << big2 << endl;
        else
            cout << big1 << endl;
    }
            
            
    return 0;
}


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

int main(){
  int A, B, count=0;
  cin >> A >> B;
  
  for(int i=A; i<=B; i++) if(i/10000 == i%10 && (i/1000)%10 == (i/10)%10) count++;
  cout << count;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define _for(it, a) \
  for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> a;
  int x;
  long long res = 1e10;
  for (int n = 0; n < N; ++n) {
    scanf("%d", &x);
    a.pb(x);
  }
  for (int n = -105; n <= 105; ++n) {
    long long tres = 0;
    for (int j = 0; j < N; ++j) {
      tres += (a[j] - n) * 1ll * (a[j] - n);
    }
    res = min(res, tres);
  }
  cout << res << endl;
  return 0;
}

// Built using Sublime-CHelper plug-in (beta)


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

int n, s, ans;
void dfs(int now, int num, int total){
    if(num == n){ans+=(total == s); return;}
    for(int i = now; i < 10; i++){
        dfs(i + 1, num + 1, total + i);
    }
    return;
}

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

    while(cin >> n >> s){
        if(n == 0 and s == 0) break;
        ans = 0;
        dfs(0, 0, 0);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3028
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 998244353
using namespace std;
typedef pair<llint, llint> P;
typedef pair<P, llint> E;

string s;

int main(void)
{
	cin >> s;
	llint n = s.size();
	if(s.back() == '1'){
		cout << -1 << endl;
		return 0;
	}
	s.pop_back();
	
	string t = s;
	reverse(t.begin(), t.end());
	if(s.front() == '0' || s != t){
		cout << -1 << endl;
		return 0;
	}
	
	cout << 1 << " " << 2 << endl;
	int v = 2;
	for(int i = 3; i <= n; i++){
		cout << v << " " << i << endl;
		if(s[i-2] == '1') v = i;
	}
	
	return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(std::string N){
    long long sum = 0;
    for(char& c : N) {
        int n = c - '0';
        sum += n;
    }
    if(0 == sum % 9) {
        cout << YES << endl;
    } else {
        cout << NO << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string N;
    std::cin >> N;
    solve(N);
    return 0;
}


Measured memory_bytes: 3920
#include <bits/stdc++.h>
 
using namespace std;
 
#define EPS 1e-9
 
struct Point{
    double x,y;
   
    Point(){}
    Point(double x,double y) : x(x),y(y) {}
   
    Point operator + (const Point &p)const{ return Point(x+p.x,y+p.y); }
    Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y); }
    Point operator * (const double &k)const{ return Point(x*k,y*k); }
    Point operator / (const double &k)const{ return Point(x/k,y/k); }
};
 
double dot(const Point &a,const Point &b){ return a.x*b.x+a.y*b.y; }
double cross(const Point &a,const Point &b){ return a.x*b.y - b.x*a.y; }
double norm(const Point &p){ return dot(p,p); }
double dist(const Point &a,const Point &b){
    return sqrt(pow(a.x-b.x,2) + pow(a.y-b.y,2));
}
 
istream &operator >> (istream &is,Point &p){
    return is >> p.x >> p.y;
}
 
#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
typedef Point Vector;
 
int ccw(Point p0,Point p1,Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if(cross(a,b) > EPS) return COUNTER_CLOCKWISE;
    if(cross(a,b) < -EPS) return CLOCKWISE; 
    if(dot(a,b) < -EPS) return ONLINE_BACK; 
    if(norm(a) < norm(b)) return ONLINE_FRONT; 
    return ON_SEGMENT;
}
 
struct Segment{
    Point s,t;
    Segment(){}
    Segment(Point s,Point t) : s(s),t(t) {}
};
 
bool isIntersectSS(const Segment &a,const Segment &b){
    Point s[2] = {a.s,a.t}, t[2] = {b.s,b.t};
    return (ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
	    ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0);
}
 
Point crosspointSS(const Segment &a,const Segment &b){
    Vector va = a.t-a.s, vb = b.t-b.s;
    double d = cross(vb,va);
    return a.s+va*cross(vb,b.t-a.s)*(1.0/d);
}
 
struct P{
    int comp;
    int pos;
    double dist;
 
    bool operator < (const P &p)const{
	if(dist != p.dist){
	    return dist < p.dist;
	}
    }
};
 
int solve(int idx,int p,vector<P> &v){
    if(idx == (int)v.size()) return 0;
    int res;
    if(v[idx].comp == 0){
	if(p == v[idx].pos){
	    res = solve(idx+1,!p,v)+1;
	}else{
	    res = solve(idx+1,p,v);
	}
    }else{
	if(p == v[idx].pos){
	    res = solve(idx+1,p,v);
	}else{
	    res = solve(idx+1,!p,v)+1;
	}
    }
    return res;
}
 
int main(){
    int Tc,N,comp,pos;
    cin >> Tc;
    while(Tc--){
	Segment s,line;
	cin >> s.s >> s.t >> N;
	vector<P> vec;
	for(int i = 0 ; i < N ; i++){
	    cin >> line.s >> line.t >> comp >> pos;
	    if(isIntersectSS(line,s)){
		Point p = crosspointSS(line,s);
		double d = dist(p,s.s);
		vec.push_back((P){comp,pos,d});
	    }
	}
	sort(vec.begin(),vec.end());
	cout << min(solve(0,0,vec),solve(0,1,vec)) << endl;
    }
    return 0;
}

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

#define ll long long int

int main(){
    int n,w;
    cin>>n>>w;
    int weight[n], value[n];
    for(int i=0;i<n;i++)
        cin>>weight[i]>>value[i];
    ll dp[n+1][w+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=w;j++){
            if(i==0 || j == 0)
                dp[i][j] = 0;
            else if(weight[i-1] > j)
                dp[i][j] = dp[i-1][j];
            else
                dp[i][j] = max(value[i-1] + dp[i-1][j-weight[i-1]], dp[i-1][j]);
        }
    }
    cout<<dp[n][w];
    return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, x;
int a[105];
int ans;
ll sum[105];

int main() {
	while(cin >> n >> x) {
		ans = 0;
		int pos = 0;
		memset(a, 0, sizeof(a));
		memset(sum, 0, sizeof(sum));
		for(int i = 1; i <= n; i++) cin >> a[i];
		sort(a + 1, a + n + 1);
		for(int i = 1; i <= n; i++) sum[i] = sum[i - 1] + (ll)a[i];
		if(sum[n] == x) ans = n;
		else if(sum[n] < x) ans = n - 1;
		else {
			for(int i = 1; i <= n; i++) {
				if(sum[i] <= x && sum[i + 1] >= x) {
					pos = i;
					break;
				}
			}
			if(pos) ans = pos;
			else ans = 0;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int dp[100000001];
int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	int a[m], b[m];
	for (int i = 0; i < m; i++) scanf("%d %d", &a[i], &b[i]);
	for (int i = 0; i <= 100000001; i++){
		if (dp[i] == 0 && i > 0) continue;
		if (dp[i] >= n){
			printf("%d\n", i);
			return 0;
		}
		for (int j = 0; j < m; j++) dp[i + b[j]] = max(dp[i + b[j]], dp[i] + a[j]);
	}
}

Measured memory_bytes: 388992
S=list(input())
p=abs(int(S[0])*100+int(S[1])*10+int(S[2])-753)
for i in range(1,len(S)-2):
    p2=int(S[i])*100+int(S[i+1])*10+int(S[i+2])
    if abs(p2-753)<p:
        p=abs(p2-753)
    if p==0:
        break
print(p)

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

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

int main(void){

    int N, D;
    cin >> N >> D;
    vector<double> x(N), y(N);
    rep(i, N) cin >> x.at(i) >> y.at(i);

    int ans=0;
    rep(i, N){
        if(sqrt(x.at(i)*x.at(i)+y.at(i)*y.at(i)) <= D) ans++;
    }
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 6428
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    S=input()
    T=input()
    N=len(S)
    M=len(T)
    ans=10000
    
    for i in range(N-M+1):#Sのi文字字目から
        temp=0
        for j in range(M):#Tのj文字目
            if S[i+j]!=T[j]:
                temp+=1
                
        ans=min(ans,temp)
        
    print(ans)

main()


Measured memory_bytes: 67608
import sys
from collections import deque


class P(list):
    def __init__(self):
        list.__init__(self)
        self.space = None
        self.path = ""

    def __hash__(self):
        return hash(str(self[:]))


def is_target(p):
    return p[:] == ans[:]


N = 3
N2 = N*N
ans = [1, 2, 3, 4, 5, 6, 7, 8, 9]
# space index
si = 0

# move
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
direction = ('u', 'l', 'd', 'r')


def bfs(p):
    Q = deque()
    Q.append(p)
    V = set()
    V.add(p)

    while Q:
        u = Q.popleft()
        if u == ans:
            return u.path
        sx = u.space // N
        sy = u.space % N
        for i in range(4):
            tx = sx + dx[i]
            ty = sy + dy[i]
            if tx < 0 or ty < 0 or tx >= N or ty >= N:
                continue
            v = P()
            v[:] = u[:]
            v.path = u.path
            c = int(tx*N+ty)
            v[u.space] = v[c]
            v[c] = 9
            v.space = c
            if v not in V:
                V.add(v)
                v.path += direction[i]
                Q.append(v)


p = P()
for i in range(N):
    line = sys.stdin.readline()
    a, b, c = map(int, line.split())
    p.append(a)
    p.append(b)
    p.append(c)
for i in range(N2):
    if p[i] == 0:
        p[i] = 9
        p.space = i

re = bfs(p)
print(len(re))



Measured memory_bytes: 87156
import java.io.*;
import java.util.*;

class Main{
    public static void main(String args[]){
        try{
            BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
            String s=reader.readLine();
            StringTokenizer st=new StringTokenizer(s," ");
            
            String a=st.nextToken();
            String b=st.nextToken();
            String c=st.nextToken();
            
            int an=Integer.parseInt(a);
            int bn=Integer.parseInt(b);
            int cn=Integer.parseInt(c);
            
            if(an<bn && bn<cn){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }

        }catch(IOException e){
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 24052
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

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

#define dump(x) cerr << #x << " = " <<(x)<<endl;
#define debug(x) cerr << #x << " = " <<(x) << "(L" << __LINE__ << ")" << __FILE__ << endl;

using namespace std;

int main(void){
  int n,l,i;
  cin >> n >> l;
  vector<string> v(n);
  REP(i,n){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  REP(i,n) cout << v[i];
  cout << endl;
  return 0;
}


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

typedef long long ll;

using namespace std;

int main() {
    ll n,m;
    string s;
    ll k;
    n = 5000000000000000;
    
    cin >> s >> k;
    
    ll ret=0;
    m=0;
    for (auto it = s.begin(); it!=s.end(); ++it){
        if (log(k-m)+1 < n*log(*it-'0')){
            ret = *it - '0';
            break;
        }
        m += pow(*it - '0', n);
        
        if (k==m){
            ret = *it - '0';
            break;
        }
    }
    
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
def parse():
  splited = input().split(" ")
  A = int(splited[0])
  B_n = splited[1].split(".")[0]
  B_d = splited[1].split(".")[1]
  B = int(B_n) * 100 + int(B_d)
  return A, B

def main():
  A, B = parse()
  print(int(A * B // 100))

if __name__ == "__main__":
  main()

Measured memory_bytes: 9192
import sys , math
from bisect import bisect
N=int(input())
alp="abcdefghijklmnopqrstuvwxyz"

R=[]
i=1
tot = 0
while tot < 1000000000000001:
    tar = 26**i
    tot+=tar
    R.append(tot+1)
    i+=1
keta = bisect(R , N)+1

if keta == 1:
    print(alp[N-1])
    sys.exit()

ans = ""
M = N - R[keta - 1]
for i in range(keta):
    j = keta - i - 1
    ind = M // (26**j)
    M -= ind * (26**j)
    ans+=alp[ind]
print(ans)

Measured memory_bytes: 62288
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>



struct UnionFind
{

  vector<int> par;
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    rep(i,n) par[i] = i;
  }

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

  bool unite(int x, int y) {

    x = root(x);
    y = root(y);

    if (x == y) return false;

    if (sizes[x] < sizes[y]) swap(x, y);

    par[y] = x;
    sizes[x] += sizes[y];

    return true;
  }

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

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

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

  int n,k,l;
  cin>>n>>k>>l;
  UnionFind uf1(n),uf2(n);

  rep(i,k){
    int a,b;
    cin>>a>>b;
    a--;b--;
    uf1.unite(a,b);
  }
  rep(i,l){
    int a,b;
    cin>>a>>b;
    a--;b--;
    uf2.unite(a,b);
  }

  map<P,int> mp;

  rep(i,n){
    mp[P(uf1.root(i),uf2.root(i))]++;
  }

  rep(i,n){
    cout<<mp[P(uf1.root(i),uf2.root(i))]<<' ';
  }

  cout<<endl;


}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll n;
string s;
bool a[256], b[256];
 
int main(int argc, char **argv) {
	cin >> n >> s;
	ll res = 0;
	REP(i, n) {
		CLEAR(a); CLEAR(b);
		ll c = 0;
		REP(j, i) a[s[j]] = true;
		FOR(j, i, n) b[s[j]] = true;
		REP(j, 256) if (a[j] && b[j]) ++c;
		res = max(res, c);
	}
	cout << res << endl;
	return 0;
}
 

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N;
    string s,t;
    cin >> s>>t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if(s<t){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<math.h>
using namespace std;

bool isPrime( int x ){
    if ( x < 2 ) return false;
    else if ( x == 2 ) return true;
    if ( x % 2 == 0 ) return false;
    int limit = (int)sqrt((double)x) + 1;
    for ( int i = 3; i <= limit; i += 2 ){
	if ( x % i == 0 ) return false;
    }
    return true;
}

int main(void){
  int n;
  while ( cin >> n, n){
    int cnt = 0;
    for ( int i = n+1; i <= 2*n; i++ )
      if ( isPrime( i ) )cnt++;
    cout << cnt << endl;
  }
    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(int i = (int)k; i < (int)n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(int i = (int)n-1; i > (int)k-1; i--)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl;

typedef long long ll;

const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const int dx8[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy8[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

ll kaijo[100000 +1];

const ll BIG_NUM = 1000000000 +7;

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

    int N, M;
    cin >> N >> M;

    if (abs(N-M) > 1) {
        cout << 0 << endl;
        return 0;
    }

    kaijo[0] = 1;
    REP(i,1,max(N,M)+1) kaijo[i] = (kaijo[i-1]*i) % BIG_NUM;

    ll ans = (kaijo[N] * kaijo[M]) % BIG_NUM;
    if (N==M)
        ans = ans*2 % BIG_NUM;

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


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int m[10];
    for(int i=0;i<10;i++)cin>>m[i];
    sort(m,m+10);
    reverse(m,m+10);
    for(int i=0;i<3;i++)cout<<m[i]<<endl;

    return 0;

}

Measured memory_bytes: 1176
from collections import deque

n, m =map(int, input().split())

ans = [-1 for _ in range(n+1)]
ans[0] = 0
ans[1] = 0

V = [[] for _ in range(n+1)]

for _ in range(m):
    x, y = map(int, input().split())
    V[x].append(y)
    V[y].append(x)

d = deque([1])

while d:
    l = d.popleft()
    for v in V[l]:
        if ans[v] != -1:
            continue
        ans[v] = l
        d.append(v)
        

    
if ans.count(-1) > 0:
    print('No')
else :
    print('Yes')
    print(*ans[2:], sep="\n")


Measured memory_bytes: 35756
//https://atcoder.jp/contests/abc139/tasks/abc139_e
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

struct Edge{
    ll st; //start
    ll tr; //end
    ll weight;
	Edge(ll s, ll t, ll w) : st(s), tr(t), weight(w) {}
	Edge() : Edge(0, 0, 0) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
//topological sort の一つを得る、１つの入力に対して複数の解答がる。
std::vector<int> tsort(const Graph &g, ll &mlop) {
    int n = g.size();
    enum class State { NEW, ACTIVE, FINISHED };
    std::vector<int> res;
    vector<State> state(n, State::NEW);
    vector<ll> length(n,1);
    static const std::function<bool(int)> dfs = [&](int v) {
        state[v] = State::ACTIVE;
        for (auto &e : g[v]) {
            int w = e.tr;
            if (state[w] == State::ACTIVE) return false;
            else if (state[w] == State::NEW) {
                auto rf = dfs(w);
                length[v] = max(length[v],length[w]+1);
				if(!rf) {
					return false;
				}
			}
		}
        state[v] = State::FINISHED;
        res.push_back(v);
        return true;
    };
    for (int i = 0; i < n; ++i){
        if (state[i] == State::NEW && !dfs(i)) return {-1};
    }
    std::reverse(res.begin(), res.end());
    mlop = *max_element(length.begin(),length.end());
    return res;
}

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif    
    ll N; cin>>N;
    vector<vector<ll>> aij(N,vector<ll>(N-1));
    for(auto&& an: aij){
        for(auto&& a:an){
            cin>>a; --a; //0start
        }
    }
    //match id取る
    ll cur_match_id=0;
    map<pair<ll,ll>,ll> match_id_map{};
    auto match_id = [&](ll i, ll j){
        assert(i!=j);
        assert(i<N&&j<N);
        if(i>j) swap(i,j);
        pair<ll,ll> ij={i,j};
        auto it = match_id_map.find(ij);
        if(it==match_id_map.end()){
			match_id_map[ij] = cur_match_id++;
            return match_id_map[ij];
        }
        return it->second;
    };

    ll match_num = N*(N-1)/2;
    Graph graph(match_num);
    REP(i, aij.size()){
        FOR(j, 1, aij[i].size()){
            auto s = match_id(i,aij[i][j-1]); //前の試合
            auto t = match_id(i,aij[i][j]);
            graph.at(s).emplace_back(s,t,0);
        }
    }
    ll ans=-1;
    auto ord = tsort(graph,ans);
    if (ord[0]<0) {
        cout<<-1<<endl;
        return 0;
    }

    //日数数える,max length of path from start
#if 1
    vector<ll> len(match_num,1);
    for(const auto& o:ord){
        for(const auto& e:graph.at(o)){
            len.at(e.tr) = max(len.at(e.tr), len.at(e.st)+1);
        }
    }
    ans = *max_element(len.begin(),len.end());
#endif
    cout<<ans<<endl;

    return 0;
}

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

  vector<int> A(N);
  
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  } 
  
  vector<int> B(N);
  for (int j = 0; j < N; j++) {
    B.at(A.at(j) - 1) = j + 1;
  }
  
  for (int i = 0; i < N; i++)
      cout << B.at(i) << " ";
  cout << endl;
}


Measured memory_bytes: 1536
#include <iostream>
#include <cstdlib>
#include <stack>
using namespace std;

int main()
{
  stack<int> S;
  int op1, op2;
  string s;

  while (cin >> s)
  {
    if (s[0] == '+')
    {
      op2 = S.top();
      S.pop();
      op1 = S.top();
      S.pop();
      S.push(op1 + op2);
    }
    else if (s[0] == '-')
    {
      op2 = S.top();
      S.pop();
      op1 = S.top();
      S.pop();
      S.push(op1 - op2);
    }
    else if (s[0] == '*')
    {
      op2 = S.top();
      S.pop();
      op1 = S.top();
      S.pop();
      S.push(op1 * op2);
    }
    else
    {
      S.push(atoi(s.c_str()));
    }
  }
  cout << S.top() << endl;

  return 0;
}


Measured memory_bytes: 3180
N, K = map(int, input().split())
A = list(map(int, input().split()))

for i in range(N):
	A[i] -= 1

judge = N*[0]
pos = 0
freq = 0

while judge[pos]==0 and K > 0:
	judge[pos] = 1
	pos = A[pos]
	K -= 1
	freq+=1

tmp = pos
pos = 0
while pos!=tmp:
	pos = A[pos]
	freq -= 1

#print(freq)
if K==0:
	print(pos+1)
else:
	K %= freq
	pos = tmp
	for i in range(K):
		pos = A[pos]
	print(pos+1)


Measured memory_bytes: 32296
loop do
  w, h = gets.split.map(&:to_i)
  break if w == 0
  fld_l = '#' * (w + 2)
  fld_r = '#' * (w + 2)
  pl = pr = 0
  h.times do |i|
    l, r = gets.split(' ')
    pl = (w + 2) * (i + 1) + l.index('L') + 1 if l.include?('L')
    pr = (w + 2) * (i + 1) + r.index('R') + 1 if r.include?('R')
    fld_l += '#' + l + '#'; fld_r += '#' + r + '#'
  end
  fld_l += '#' * (w + 2); fld_r += '#' * (w + 2)
  arr = []
  arr << [pl, pr]
  visit = ((h+2)*(w+2)).times.map{ [false] * ((h+2)*(w+2)) }
  res = 0
  until arr.empty?
    l, r = arr.shift
    [[-1, 0], [1, 0], [0, -1], [0, 1]].each do |y, x|
      nxt_l = l + y * (w + 2) + x
      nxt_r = r + y * (w + 2) - x
      next if fld_l[nxt_l] == '#' && fld_r[nxt_r] == '#'
      nxt_l = l if fld_l[nxt_l] == '#'
      nxt_r = r if fld_r[nxt_r] == '#'
      unless visit[nxt_l][nxt_r]
        if fld_l[nxt_l] == '%' && fld_r[nxt_r] == '%'
          res = 1
          break
        end
        if fld_l[nxt_l] == '%' || fld_r[nxt_r] == '%'
          next
        end
        arr << [nxt_l, nxt_r]
        visit[nxt_l][nxt_r] = true
      end
    end
    break if res == 1
  end
  puts res == 0 ?  'No' : 'Yes'
end

Measured memory_bytes: 124072