akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

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; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;

struct mint {
	long long x;
	mint(long long x = 0) :x((x% mod + mod) % mod) {}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

const int N = 100000;
int cnt[N + 1];
mint fc[N + 1];
int main()
{

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

	ll n, k; cin >> n >> k;
	for (int i = 1; i <= k; i++) cnt[i] += 1;
	for (int i = 1; i <= k; i++) {
		for (int j = i + i; j <= k; j += i) {
			cnt[i] += cnt[j];
		}
	}
	for (int i = k; i >= 1; i--) {
		for (int j = i + i; j <= k; j += i) {
			fc[i] -= fc[j];
		}
		fc[i] += mint(cnt[i]).pow(n);
	}
	mint res = 0;
	for (int i = 1; i <= k; i++) {
		res += fc[i] * i;
	}
	cout << res.x << "\n";
	return 0;
}

Measured memory_bytes: 4784
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)



int main(){ FastIO;

int c=0,n,t;cin>>n;t=n;
while(t>0)
{
	c+=(t%10);
	t=t/10;
}
if(n%c==0) cout<<"Yes";
else cout<<"No";



return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
using namespace std;

int n,num=0,maxn;
string tmp;
vector<string> s(10000);
int a[10000]={},b[10000]={},ao=0,bo=0,mid=0;


int main(void) {

	cin>>n;
	for (int i = 0; i < n; i++) {
		cin>>tmp;
		s[i]=tmp;
		for (int ser = 1; ser < s[i].size(); ser++) {
			if(s[i][ser]=='B'&&s[i][ser-1]=='A'){
				num++;
				//cout<<num<<"\n";
			}
		}
		int ooo=s[i].size()-1;
		if(s[i][ooo]=='A')a[i]++;
		if(s[i][0]=='B')b[i]++;
		if(a[i]>0&&b[i]>0)mid++;
		else if(a[i]>0)ao++;
		else if(b[i]>0)bo++;
	}
	if(mid>0){
		num+=mid-1;
		//printf("mid%d\n",num);
		if(ao>0){
			num++;
			ao--;
		}
		if(bo>0){
			num++;
			bo--;
		}
		num+=min(ao,bo);
	}else{
		num+=min(ao,bo);
	}




	/*for (int i = 0; i < n; i++) {
		cout<<s[i]<<"\n";
	}*/

	cout<<num<<"\n";


	return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define N 200005
#define LL long long
using namespace std;
LL val[N];//- + - +
LL suf[N];
int n; 
int main(){
	scanf("%d",&n);
	scanf("%lld",&val[1]);
	int cnt=1;
	for(int i=2,t,last='+';i<=n;i++){
		char ch=getchar();
		while(ch!='+'&&ch!='-') ch=getchar();
		scanf("%d",&t);
		if(ch=='+'&&last=='+') val[cnt]+=t;
		else if(ch!=last) val[++cnt]=t;
		else val[++cnt]=0,val[++cnt]=t;
		last=ch;
	}
	for(int i=cnt;i>=1;i--) suf[i]=suf[i+1]+val[i];
	LL pre=0,ans=-1e18;
	for(int i=1;i<=cnt;i++){
		pre+=val[i]*(i%2==0 ? -1:1);
		if(i%2==0){
			ans=max(ans,pre-val[i+1]+suf[i+2]);
		}
	}
	ans=max(ans,pre);
	cout<<ans<<endl;
	return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n)   for (int i = 0; i < (n); i++)
#define sz(x)       (int)(x).size()
#define eb          emplace_back
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

const int mod = 1e9 + 7;

ll modExp(ll b, int e) {
    ll r = 1;
    while (e) {
        if (e & 1) r = r * b % mod;
        b = b * b % mod;
        e /= 2;
    }
    return r;
}

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

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

    vi sieve(k + 1, 0);
    for (int i = 1; i <= k; i++) {
        sieve[i] += i;
        for (int j = i + i; j <= k; j += i) {
            sieve[j] -= sieve[i];
        }
    }

    map<int, ll> mrp;
    for (int i = 1; i <= k; i++) {
        mrp[k / i] += sieve[i];
    }

    ll ans = 0;
    for (auto& i : mrp) {
        ans = (ans + modExp(i.fi, n) * (i.se % mod)) % mod;
    }
    cout << ans;

    return 0;
}


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

#define ll long long int
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define nl '\n'
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define all(a) a.begin(),a.end()
#define F first
#define S second
const ll N=1e6+9;
const ll mod=1e9+7;

ll a[N],h[N];

void solve()
{
	ll n,k;
	cin>>n>>k;
	rep(i,1,n)a[i]=1e9;
	rep(i,1,n)cin>>h[i];
	a[1]=0;
	rep(i,2,n)
	{
		ll p= max((ll)1,i-k);
		rep(j,p,i-1)
		a[i] = min(a[i] , a[j]+abs(h[i]-h[j]));
		//cout<<a[i]<<" ";

	}
    cout<<a[n];
}



int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t=1;
    //pre();
    //cin>>t;
    //if(t^1)exit(0);
    while(t--)
       solve();
}

Measured memory_bytes: 5120
a, b = map(int,input().split())

bs = [list(map(int, input().split())) for i in range(a)]
for i in range(a):
    bs[i].append(sum(bs[i]))
aa = []

for i in range(b+1):
    aa.append(sum([a[i] for a in bs]))
bs.append(aa)

for i in bs:
    print(" ".join(map(str,i)))


Measured memory_bytes: 5700
////////////////////////////////////////////////////////////////
//
//    (☝ ՞ਊ ՞)☝ << Be accept!!
//
//    C++ format for competitive professional v1.0
//
//    GCC is recommendation.
//
////////////////////////////////////////////////////////////////
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<time.h>
#include<random>
#include<map>
#include<thread>
#include<tuple>
#include<boost/multiprecision/cpp_int.hpp>
#define rep(i,n) for(int i = 0;i < n;i++)
using ll = long long;
using namespace std;
using namespace boost::multiprecision;//cpp_int
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
int inline setup(void) {//set
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	return 0;
}
int lenght(char* str){//getcharlengh
	int i = 0;
	while (str[i]) {
		i++;
	}
	return i;
}
int gcd(long long a, long long b) {
	if (a < b)return gcd(b, a);
	long long r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
#define DEBUG
int main(int argc, const char* argv[]) {
	setup();
		
	int n, m;
	cin >> n >> m;
	int mx = max(n, m);
	int mn = min(n, m);
	rep(i, mx) {
		cout << mn;
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
H,W,K = map(int,input().split())

s = [0 for _ in range(H)]

for i in range(H):
    s[i] = list(str(input()))

a = [[0]*W for _ in range(H)]
wait = []
count = 0
for i in range(H):
    pre = -1
    for j in range(W):
        if pre == -1 and s[i][j] == "#":
            count += 1
            pre = j
            for k in range(j+1):
                a[i][k] = count
        elif pre != -1 and s[i][j] == ".":
            a[i][j] = count
        elif pre != -1 and s[i][j] =="#":
            count += 1
            pre = j
            a[i][j] = count
    if pre == -1 and (i == 0 or wait != []):
        wait.append(i)
    elif pre == -1:
        for k in range(W):
            a[i][k] = a[i-1][k]
    elif pre != -1 and wait != []:
        for x in wait:
            for k in range(W):
                a[x][k] = a[i][k]
        wait = []

for i in range(H):
    print(" ".join(map(str,a[i])))


Measured memory_bytes: 7924
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = (1<<30);

int main() {
  int k,n;
  cin >> k >> n;
  int a[n+1];
  for(int i = 0; i < n; i++)
    cin >> a[i];
  
  int ma = 0,dist;
  for(int i = 0; i < n; i++) {
    if(i == n-1) 
      dist = abs(a[i] - k) + a[0];
    else
      dist = abs(a[i] - a[i+1]);
    
    ma = max(ma, dist);
  }

  cout << k - ma << endl;
}

Measured memory_bytes: 4372
#include<bits/stdc++.h>
 
#define ll long long 
# define skorost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 

using namespace std ;
 
ll z , o , ans ;

ll N = 1e4 + 15820 ;

int main(){ skorost ;

	int n ;

	cin >> n ;

	int a[n] ;

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

		cin >> a[i] ;

		ans += a[i] ;

	}

	int m ;

	cin >> m ;

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

		int x , y ;

		cin >> x >> y ;

		ans -= a[x-1] ;

		ans += y ;

		cout << ans << endl ;

		ans -= y ;

		ans += a[x-1] ;

	}

}

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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if(A==B && B==C){
    cout << 1 << endl;
  }
  else if(A!=B && B!=C && C!=A){
    cout << 3 << endl;
  }
  else{
    cout << 2 << endl;
  }
} 

Measured memory_bytes: 3540
a,b,c=map(int,input().split())
d=[int(i) for i in input().split()]
#print(c)
e=[]
f=[]
for i in range(b):
	if d[i]<c:
		e.append(d[i])
	else:
		f.append(d[i])
#print(e)
#print(f)
g=len(e)
h=len(f)
if g<=h:
	print(g)
else:
	print(h)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  ll ans = 0;
  int N; cin>>N;
  bool same = true;
  ll cand = 10000000000LL;
  REP(i,N) {
    ll a, b; cin>>a>>b;
    ans += a;
    if(a>b) cand = min(cand,b);
    if(a != b) same = false;
  }
  if(same) ans = 0;
  else ans -= cand;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
'''input
4
3 3 3 3
'''
from collections import Counter
n = input()
arr = map(int,raw_input().split())
c = Counter(arr)
ans = 0
for i in c:
	if c[i] < i:
		ans += c[i]
	else:
		ans += (c[i]-i)
print ans


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int mod = 1e9+7;

int gcd(const int a, const int b)
{ return (b == 0) ? a : gcd(b,a%b); }

int pow(const int a, const int k)
{
    LL ans = 1, x = a;
    FOR(i,0,31) {
        if (k & (1<<i)) {
            ans *= x; ans %= mod;
        }
        x *= x; x %= mod;
    }
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        VI A(n); 
        FOR(i,0,n) 
            cin >> A[i];
        map<int,int> factor;
        FOR(i,0,n) {
            int a = A[i];
            for (int f = 2; f*f <= a; f++) {
                int c = 0;
                while (a%f == 0) {
                    a /= f; c++;
                }
                if (c)
                    factor[f] = max(factor[f],c);
            }
            if (a)
                factor[a] = max(factor[a],1);
        }
        LL lcm = 1;
        FOR_ALL(i,factor) {
            lcm *= pow(i->first,i->second);
            lcm %= mod;
        }
        int ans = 0;
        FOR(i,0,n) {
            ans += lcm * pow(A[i],mod-2) % mod;
            ans %= mod;
        }
        cout << ans << endl;
    }
    return 0;
}


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

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

void solve(double x1, double y1, double x2, double y2, double xq, double yq) {
    double x,y;
    if (y1==y2) {
        x = xq;
        y = 2*y1-yq;
        printf("%.4f %.4f\n", x, y);
        return;
    }
    if (x1==x2) {
        y = yq;
        x = 2*x1-xq;
        printf("%.4f %.4f\n", x, y);
        return;
    }
    x = (2*yq-2*y1-2*(y2-y1)/(x2-x1)*((xq/2)-x1)+xq*(x2-x1)/(y2-y1))/
    ((y2-y1)/(x2-x1)+(x2-x1)/(y2-y1));
    y = yq-(x2-x1)/(y2-y1)*(x-xq);
    printf("%.4f %.4f\n", x, y);
}

int main() {
    double x1,y1,x2,y2,xq,yq;
    char c;
    while(cin>>x1>>c>>y1>>c>>x2>>c>>y2>>c>>xq>>c>>yq) {
        solve(x1,y1,x2,y2,xq,yq);
    }
   return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (long long int i = f; i < t; i++)
#define pr(i, f, t) for (long long int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define ia(n, a) rp(ia_i, 0, n) cin >> a[ia_i]
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define ce(a) cout << (a) << endl
int main()
{
    ll k;
    string s;
    cin >> k >> s;
    if (s.size() <= k)
    {
        ce(s);
    }
    else
    {
        cout << (s.substr(0, k)) << "..." << endl;
    }
}

Measured memory_bytes: 3632
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>

using namespace std;

int main(){
    int m, k;
    scanf("%d %d", &m, &k);
    if(m == 0){
        if(k == 0){
            printf("0 0\n");
        }else{
            printf("-1\n");
        }
        return 0;
    }else if(m == 1){
        if(k == 0){
            printf("0 0 1 1\n");
        }else{
            printf("-1\n");
        }
        return 0;
    }else{
        if(k >= (1 << m)){
            printf("-1\n");
        }else{
            for(int i = 0; i < (1 << m); ++i){
                if(i != k){
                    printf("%d ", i);
                }
            }
            printf("%d ", k);
            for(int i = (1 << m) - 1; i >= 0; --i){
                if(i != k){
                    printf("%d ", i);
                }
            }
            printf("%d\n", k);
        }
    }
    return 0;
}


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

int main()
{
    int N;
    std::cin >> N;
    std::vector<int> R(N);
    for (int i = 0; i < N; ++i) std::cin >> R.at(i);
    int s = 0;
    for (int i = 0; i < N; ++i) {
        int c;
        std::cin >> c;
        R.at(i) -= c;
        if (R.at(i) > 0) s += R.at(i);
    }

    std::cout << s << std::endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [0]*4

for i in range(n):
    s = input()
    if s == "AC":
        a[0] += 1
    elif s == "WA":
        a[1] += 1
    elif s == "TLE":
        a[2] += 1
    else:
        a[3] += 1
        
print("AC x",a[0])
print("WA x",a[1])
print("TLE x",a[2])
print("RE x",a[3])

Measured memory_bytes: 74772
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    vector<int> p(n);
    REP(i,n) cin>>p[i];

    int v=0;
    REP(i,n) if(p[i]!=i+1) v++;

    cout<<((v==0 || v==2)? "YES":"NO")<<endl;

	return 0; 
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  for(int i=0;i<4;i++){
    int t,n;cin>>t>>n;
    if(t%4==1){
      cout<<n*6000<<endl;
    }else if(t%4==2){
      cout<<n*4000<<endl;
    }else if(t%4==3){
      cout<<n*3000<<endl;
    }else{
      cout<<n*2000<<endl;
    }
  }
}


Measured memory_bytes: 3116
#ifndef ___Class_RollingHash
#define ___Class_RollingHash

#include<iostream>
#include<string>
#include<vector>
using namespace std;
template <long long mod, long long base = 257>
class RollingHash {
private:
	std::string str;
	std::vector<long long> sum;
public:
	RollingHash() : str(""), sum(std::vector<long long>(1, 0)) {};
	RollingHash(const std::string &s) : str(s) {
		sum.resize(str.size() + 1);
		for (int i = 0; i < str.size(); i++) sum[i + 1] = (1LL * sum[i] * base + s[i]) % mod;
	}
	static inline long long modpow(long long a, long long b) {
		long long ret = 1; a %= mod;
		while (b) {
			if (b & 1) ret = 1LL * ret * a % mod;
			a = 1LL * a * a % mod;
			b >>= 1;
		}
		return ret;
	}
	std::string get() { return str; }
	long long gethash(int l, int r) {
		return (sum[r] - sum[l] * modpow(base, r - l) % mod + mod) % mod;
	}
};

#endif

const int MOD = 2016112121;
string T;

int main() {
	cin >> T; RollingHash<MOD> S(T); bool flag = false;
	for (int i = T.size() / 3; i >= 1; i--) {
		int G = (T.size() - i * 3); if (G % 2 == 1 || G <= 0)continue;
		G /= 2;
		long long p1 = S.gethash(0, i);
		long long p2 = S.gethash(i, i + G);
		long long p3 = S.gethash(i + G, i * 2 + G);
		long long p4 = S.gethash(i * 2 + G, i * 2 + G * 2);
		long long p5 = S.gethash(i * 2 + G * 2, i * 3 + G * 2);
		if (flag == false) {
			if (p1 == p3 && p3 == p5) {
				if (p2 == p4) {
					cout << "Love " << T.substr(0, i + G) << "!" << endl; flag = true;
				}
			}
		}
	}
	if (flag == false)cout << "mitomerarenaiWA" << endl;
	return 0;
}

Measured memory_bytes: 12100
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int n;

int check(int x){
	sst st;
	st<<x;
	string s=st.str(),t=s;
	reverse(t.begin(),t.end());
	return s==t;
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>n;
	rep(i,INF){
		if(check(n-i)){
			cout<<n-i<<endl;
			return 0;
		}
		if(check(n+i)){
			cout<<n+i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1220
N,M,X = map(int,input().split())
A = set(list(map(int,input().split())))

t = 0
for i in range(X+1,N):
    if i in A:
        t += 1
s = 0
for i in range(X-1,-1,-1):
    if i in A:
        s += 1
print(min(t,s))

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
using namespace std;
int		cnt;

int		main(void)
{
	int		A, B;
	cin >> A >> B;
	cout << (B % A == 0 ? A + B : B - A) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int x;
    cin>>x;
    for (int i = 1; i < 1000; i++)
    {
        if(360*i % x == 0)
        {
            cout<<360*i/x<<endl;
            return 0;
        }
    }
    
 //   cout<<(360+x-1)/x;
    return 0;
}

Measured memory_bytes: 3632
import math

if __name__ == "__main__":

    pi = math.pi

    param = input().split()

    a = int(param[0])
    b = int(param[1])
    deg = int(param[2])

    rad = math.radians(deg)

    S = 1/2*a*b*math.sin(rad)
    h = b * math.sin(rad)
    L = a + b + math.sqrt(a**2 + b**2 - 2*a*b*math.cos(rad))

    print(str(S))
    print(str(L))
    print(str(h), end="")



Measured memory_bytes: 5708
s = input().rstrip()
t = input().rstrip()
s = s[::-1]
t = t[::-1]
for i in range(len(s) - len(t) + 1):
    for j in range(len(t)):
        if s[i + j] != '?' and s[i + j] != t[j]:
            break
    else:
        res = s[:i] + t + s[i + len(t):]
        print(res.replace('?', 'a')[::-1])
        exit()
print('UNRESTORABLE')

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

namespace abc141
{
    class abc141a
    {
        static string[] weathers = new string[]{ "Sunny","Cloudy","Rainy"};
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var r = Solve(s);

            Console.WriteLine(weathers[r]);
        }

        static int Solve(string s)
        {
            var today = weathers.ToList().IndexOf(s);
            var forecast = (today + 1) % 3;

            return forecast;
        }
    }
}


Measured memory_bytes: 13152
s=input()
n=len(s)-1
sum=0
List=[s[0]]
for i in range(2**n):
    for j in range(n):
        if (i>>j)&1:
            List+=["+"]+[s[j+1]]
        else:
            List+=[s[j+1]]
    m=0
    for h in List:
        if h=="+":
            sum+=m
            m=0
        else:
            m*=10
            m+=int(h)
    sum+=m
    List=[s[0]]
print(sum)
           

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 200030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;
int n,k;
int arr[N];
double ar[1005];
int main()
{

cin>>n>>k;
rep(i,1,n+1)
cin>>arr[i];
rep(i,1,1001)
{
	double x=0.0;
	rep(j,1,i+1)
	x+=1.0*(1/(1.0*i))*j;
	ar[i]=x;
}
double mx=0.0;
double ans=0.0;
rep(i,1,k+1)
{
	ans+=1.0*ar[arr[i]];
}
mx=ans;

rep(i,k+1,n+1)
{
	ans+=1.0*ar[arr[i]];
	ans-=1.0*ar[arr[i-k]];
	mx=max(mx,ans);
}
cout<<fixed<<setprecision(10)<<mx;


	
}

Measured memory_bytes: 1024
import math
n = int(input())
A = []
for i in range(n):
  a,b = map(int,input().split())
  A.append([a,b])
sum = 0
for i in range(n):
  for j in range(n):
    if j <= i:
      continue
    else:
      sum += math.sqrt((A[i][0]-A[j][0])**2+(A[i][1]-A[j][1])**2)

print(sum*2/n)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

typedef struct {
	int to;
	int dst;
}Edge;

int main()
{
	int N;
	cin >> N;
	vector<vector<Edge>> v(N);
	for (int i = 0; i < N - 1; i++) {
		int a, b, w;
		cin >> a >> b >> w;
		a--;
		b--;
		v[a].emplace_back(Edge{ b, w });
		v[b].emplace_back(Edge{ a, w });
	}
	vector<int> ans(N, 2);
	ans[0] = 0;

	queue<int> que;
	que.push(0);

	while (que.size()) {
		int now = que.front();
		que.pop();
		for (Edge e : v[now]) {
			if (2 == ans[e.to]) {
				que.push(e.to);
				if (0 == e.dst % 2) {
					ans[e.to] = ans[now];
				} else {
					ans[e.to] = (ans[now] + 1) % 2;
				}
			}
		}
	}

	for (int i = 0; i < N; i++) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 6784
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9+7;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N, K;
	cin >> N >> K;
	LL sum = 0;
	for (LL k = K; k <= N+1; k++) {
		sum += (2 * k * N - 2 * k * k + 2 * k + 2) / 2;
		sum %= MOD;
	}
	cout << sum << "\n";
	return 0;
}


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

struct FenwickTree{
	vector<ll> data;
	FenwickTree(int n):data(n+1){}
	void AddRange(int i,int x){
		for(;i;i-=i&-i)
			data[i]+=x;
	}
	void AddRange(int i,int j,int x){
		AddRange(i,-x);
		AddRange(j,x);
	}
	int Get(int i){
		ll res=0;
		for(i++;i<data.size();i+=i&-i)
			res+=data[i];
		return res;
	}
};

int main()
{
	for(int n;cin>>n && n;){
		FenwickTree ft(n+1);
		rep(i,n){
			int a,b; cin>>a>>b; a--;
			a=min(a,n+1);
			b=min(b,n+1);
			ft.AddRange(a,b,1);
		}
		int res=0;
		repi(i,1,n+1)
			if(ft.Get(i)>=i)
				res=i;
		cout<<res<<endl;
	}
}

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main(){
	int n,k,m,cnt=0;
	cin>>n>>k;
	if((n-1)*(n-2)/2<k){
		cout<<-1<<endl;
		return 0;
	}
	cout<<n-1+(n-1)*(n-2)/2-k<<endl;
	for(int i=2;i<=n;i++){
		cout<<1<<" "<<i<<endl;
	}
	for(int i=2;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			cnt++;
			if((n-1)*(n-2)/2-k<cnt)return 0;
			cout<<i<<" "<<j<<endl;
		}
	}
	return 0;
} 


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#define rep(i, n) for(long long i = 0;(i) < (n);(i)++)
using namespace std;
using ll = long long;

int N, K, h[100000];

int main()
{
	int ans = 0;
	cin >> N >> K;
	rep(i, N)
	{
		cin >> h[i];
		if (h[i] >= K)
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();

		//HashMap<Integer, Integer> sunukeMap = new HashMap<Integer, Integer>();
		int[] sunukeArray = new int[N+1];
		for (int i = 0; i < sunukeArray.length; i++) {
			sunukeArray[i] = 0;
		}
		for (int i = 0; i < K; i++) {
			int d = sc.nextInt();
			for (int j = 1; j <= d; j++) {
				sunukeArray[sc.nextInt()]++;

				//				if (sunukeMap.containsKey(j)) {
				//					int value = sunukeMap.get(j);
				//					sunukeMap.put(j, ++value);
				//				} else {
				//					sunukeMap.put(j, 1);
				//				}

			}
		}
		int counter = 0;
		for (int i = 1; i < sunukeArray.length; i++) {
			if (sunukeArray[i] == 0) {
				counter++;
			}
		}
		System.out.print(counter);

	}
}


Measured memory_bytes: 46188
#include <stdio.h>
int main(){
    
    int x,y,i;
    
    for(i=0;i<3000;i++){
        scanf("%d %d",&x,&y);
        
        if(x==0 && y==0) break;
        
        if(x<y) printf("%d %d\n",x,y);
        else printf("%d %d\n",y,x);
    }
    

    return 0;
    
}

Measured memory_bytes: 600
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;

public class Hello
{

    public static void Main()
    {
        string[] n = Console.ReadLine().Split(' ');
        string s;
        for (int i = 0; i < int.Parse(n[0]); i++) {
            s = Console.ReadLine();
            Console.WriteLine(s);
            Console.WriteLine(s);
        }
    }

}



public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int Cin()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }

}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
using namespace std;
char s[20];
long long a[10];
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%s", s + 1);
        if (s[1] == 'M') a[1]++;
        if (s[1] == 'A') a[2]++;
        if (s[1] == 'R') a[3]++;
        if (s[1] == 'C') a[4]++;
        if (s[1] == 'H') a[5]++;
    }
    long long res = 0;
    for (int i = 1; i <= 5; ++i) {
        for (int j = i + 1; j <= 5; ++j) {
            for (int k = j + 1; k <= 5; ++k) {
                res += a[i] * a[j] * a[k];
            }
        }
    }
    printf("%lld", res);
    return 0;
}

Measured memory_bytes: 256
n = int(input())
l =[]
for i in range(n):
  st= str(input())
  l.append(st)
AC= l.count("AC")
WA = l.count("WA")
TLE=l.count("TLE")
RE =l.count("RE")
print("AC x",AC)
print("WA x",WA)
print("TLE x",TLE)
print("RE x ",RE)

           

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

int xs[1010], ys[1010], xt[1010], yt[1010];
int w, h, n;

// 任意の個数の変数をスペース区切りで出力します
void dump() {
  cout << endl;
}
template <class Head, class... Tail>
void dump(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(Tail) != 0)
    cout << " ";
  dump(std::move(tail)...);
}

void dum(int* v, int n) {
  cout << "{";
  for (int i = 0; i < n; i++) {
    cout << v[i] << (i < n - 1 ? " " : "");
  }
  cout << "}\n";
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  cout << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  cout << "}";
  return os;
}

int compress(int x, int* s, int* t) {  // 最大の幅を返します
  vector<int> v;
  v.push_back(0);
  v.push_back(x);
  v.push_back(x + 1);
  for (int i = 0; i < n; i++) {
    v.push_back(s[i]);
    v.push_back(s[i] + 1);
    v.push_back(t[i]);
    v.push_back(t[i] + 1);
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  for (int i = 0; i < n; i++) {
    s[i] = lower_bound(v.begin(), v.end(), s[i]) - v.begin();
    t[i] = lower_bound(v.begin(), v.end(), t[i]) - v.begin();
  }
  return v.size() - 2;
}

bool g[3000][3000];

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

void dfs(int y, int x) {
  g[y][x] = true;
  for (int i = 0; i < 4; i++) {
    if (y + dy[i] < 0 || h <= y + dy[i] || x + dx[i] < 0 || w <= x + dx[i]) continue;
    if (g[y + dy[i]][x + dx[i]] == false) dfs(y + dy[i], x + dx[i]);
  }
}

// ====================================================================

int main() {
  while (true) {
    cin >> w >> h;
    if (w == 0 && h == 0) break;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> xs[i] >> ys[i] >> xt[i] >> yt[i];
    }
    w = compress(w, xs, xt);
    h = compress(h, ys, yt);

    // cout << w << " " << h << endl;
    // dum(xs, n);
    // dum(ys, n);
    // dum(xt, n);
    // dum(yt, n);

    // マス目作って塗ってDFS
    for (int i = 0; i < 3000; i++)
      for (int j = 0; j < 3000; j++)
        g[i][j] = false;

    // 塗る所を塗る
    for (int i = 0; i < n; i++)
      for (int y = ys[i]; y < yt[i]; y++)
        for (int x = xs[i]; x < xt[i]; x++)
          g[y][x] = true;

    // 空いている場所があればそこからDFS
    int ans = 0;
    for (int y = 0; y < h; y++) {
      for (int x = 0; x < w; x++) {
        // cout << (g[y][x] == true ? "1" : "_");
        if (g[y][x] == false) dfs(y, x), ans++;
      }
      // cout << endl;
    }

    cout << ans << endl;
  }
}



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

int main(){
     int k;
     cin >> k;
     int numeros[k];

     bool certo = true;
     int contador=0;

     int menor = 1e10;

     for(int i = 0; i<k;i++){
        cin >> numeros[i];
        if(numeros[i] < menor){
            contador+=1;
            menor=numeros[i];
        }

     }
     cout << contador << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a;i<n;i++)
#define ve vector
#define ss second 
#define ff first
#define pf pop_front
#define pob pop_back
#define psf push_front
#define res(x) cout<<x<<'\n'
#define read(t) ll t;cin>>t

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
   int a[3];
   cin>>a[0]>>a[1]>>a[2];
   sort(a,a+3);
   if(a[0]==a[1]&&a[1]!=a[2]){
       cout<<"Yes"<<endl;
   }
   else if(a[0]!=a[1]&&a[1]==a[2]){
        cout<<"Yes"<<endl;
   }
   else{
       cout<<"No"<<endl;
   }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};
int h, w, n;

void free_fall(vector<string>& S){
  for(int i = 0; i < h-1; ++i){
    for(int j = 0; j < w; ++j){
      if(S[i+1][j] == '.'){
	for(int k = 0; k <= i; ++k){
	  swap(S[i-k][j], S[i+1-k][j]);
	}
      }
    }
  }
}


bool simulate(vector<string> S){
  free_fall(S);
  /*
  cout << "_____fall_____" << endl;
  for(int i = 0; i < h; ++i)
    cout << S[i] << endl;
  */
  vector<string> S2(h);
  for(int i = 0; i < h; ++i)
    S2[i] = S[i];

  bool f = false, g = true;
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      if(S2[i][j] == '.') continue;
      g = false;
      char mark = S2[i][j];
      int x = i, y = j;
      int t = 0;
      while(x < h && S2[x][y] == mark){
	++t;
	++x;
      }
      if(t >= n){
	f = true;
	for(int k = 0; k < t; ++k)
	  S[i+k][j] = '.';
      }
      x = i;
      t = 0;
      while(y < w && S2[x][y] == mark){
	++t;
	++y;
      }
      if(t >= n){
	f = true;
	for(int k = 0; k < t; ++k)
	  S[i][j+k] = '.';
      }
    }
  }
  /*
  cout << "_____vanish_____" << endl;
  for(int i = 0; i < h; ++i)
    cout << S[i] << endl;
  */
  if(f){
    return simulate(S);
  }
  if(g) return true;
  return false;
}

int main(){
  cin >> h >> w >> n;
  vector<string> S(h);
  for(int i = 0; i < h; ++i)
    cin >> S[i];
  
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w-1; ++j){
      if(S[i][j] == S[i][j+1]) continue;
      swap(S[i][j], S[i][j+1]);
      /*
      cout << "<ORIGINAL>" << endl;
      for(int l = 0; l < h; ++l)
	cout << S[l] << endl;
      */
      if(simulate(S)){
	cout << "YES" << endl;
	return 0;
      }
      swap(S[i][j], S[i][j+1]);
    }
  }
  cout << "NO" << endl;  
  return 0;
}

Measured memory_bytes: 3292
S = gets.chomp.chars.sort
T = gets.chomp.chars.sort.reverse

ans = ''
(0...S.size).each{|i|
  (ans = 'No'; break) if i >= T.size
  (ans = 'No'; break) if S[i] > T[i]
  (ans = 'Yes'; break) if S[i] < T[i]
}
ans = 'Yes' if ans == '' && S.size < T.size
ans = 'No' if ans == ''

puts ans


Measured memory_bytes: 1788
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>

using namespace std;

class arcC {
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<long long> a(N);
        long long sum = 0;
        for (int i = 0; i < N; ++i) {
            in >> a[i];
            sum += a[i];
        }
        long long mn = 1000LL * 1000 * 1000 * 1000 * 1000;
        long long cur = a[0];
        for (int i = 1; i < N; ++i) {
            long long y = sum - cur;
            mn = min(mn, abs(cur - y));
            cur += a[i];
        }
        out << mn << "\n";
    }
};


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

	arcC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
void add_self(int& a, int b)
{
	a+=b;
	if(a >= mod)
		a -= mod;
}
int main()
{
	string k;
	int d;
	cin>>k>>d;
	int len = k.size();
	vector<vector<int> > dp(d, vector<int>(2));
	dp[0][0] = 1;
	for(int where = 0; where< len; ++where)
	{
		vector<vector<int> > new_dp(d, vector<int>(2));
		for(int sum = 0; sum< d; ++sum){
			for(bool sm_already : {false, true}){
				for(int dig = 0; dig< 10; ++dig)
				{
					if(dig > k[where] - '0' && !sm_already)
						break;
						
					add_self(new_dp[(sum + dig) % d][sm_already || (dig < k[where] - '0')],dp[sum][sm_already]);
				}
			}
		}
		dp = new_dp;
	}
	int answer = (dp[0][false] + dp[0][true]) % mod;
	answer--;
	if(answer == -1)
		answer = mod - 1;
	cout<<answer<<endl; // -1 bidejki 0 se racuna kako resenie
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

int arr[100005];
long long MAXV=1000000007;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin>>N;
	arr[0]=1;
	int M;
	cin>>M;
	int cracks[M];
	bool flag=true;
	for(int i=0;i<M;i++){
		cin>>cracks[i];
		if(i>=1 && (cracks[i]-cracks[i-1])==1)
			flag=false;
	}
	if(flag==false){
		cout<<0;
		return 0;
	}
	int k=0;
	for(int i=1;i<=N;i++){
		if(cracks[k]==i){  //if it has cracks
			arr[i]=-1;
			k++;
		}
		else{ //not a crack
			if(i==1)
				arr[i]=1;
			else{
				if(arr[i-1]==-1)
					arr[i]=arr[i-2]%MAXV;
				else if(arr[i-2]==-1)
					arr[i]=arr[i-1]%MAXV;
				else
					arr[i]=((arr[i-2]%MAXV)+(arr[i-1]%MAXV))%MAXV;
			}
		}
	}
	cout<<arr[N];
  return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll int n,k,i,ar[200005],ans;
int main(){
	
	cin>>n>>k;
	for(i=0;i<n;i++)cin>>ar[i];
	sort(ar,ar+n);
	for(i=0;i<n-k;i++)ans+=ar[i];
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

const ll MAX = 5000001;//10^7が限界
const ll MOD = Mod;
//const ll MOD = INT64_MAX;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll pow(ll x,ll y,ll mod){
    if(y==0) return 1;
    if(y&1) return x*pow(x,y-1,mod)%mod;
    ll p=pow(x,y/2,mod);
    return p*p%mod;
}

ll dp[200100];
void solve(){
    ll k;
    string s;
    cin >> k >> s;
    ll n=s.size();
    ll ans=0;
    COMinit();
    rp(i,k+1){
        ans+=pow(25,i,Mod)*COM(n+k,i);
        ans%=Mod;
    }
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 121420
import sys
sys.setrecursionlimit(10**5)

n = int(input())
t = {i:{} for i in range(n)}
ans = [-1]*n
for _ in range(n-1):
    u, v, w = map(int, input().split())
    t[u-1][v-1] = w
    t[v-1][u-1] = w

def dfs(x):
    for y in t[x]:
        del t[y][x]
        ans[y] = ans[x] if t[x][y] % 2 == 0 else 1-ans[x]
        if len(t[y]) > 0:
            dfs(y)

ans[0] = 0
dfs(0)
for i in range(n):
    print(ans[i])

Measured memory_bytes: 94624
#include <iostream>
#include <complex>
#include <cmath>
#include <vector>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef complex<long long> xy_t;

double crossPro(xy_t a, xy_t b)
{
	return (conj(a) * b).imag();
}

int main()
{
	int N;
	double x[4],y[4];
	ll X[4],Y[4];
	cin >> N;

	for (int i = 0; i < N; ++i)
	{
		cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3];
		for (int j = 0; j < 4; ++j)
		{
			X[j] = round(x[j] * 1e5);
			Y[j] = round(y[j] * 1e5);
			//cout << X[j] << " " << Y[j] << endl;
		}
		xy_t t1(X[0],Y[0]);
		xy_t t2(X[1],Y[1]);
		xy_t t3(X[2],Y[2]);
		xy_t t4(X[3],Y[3]);

		if (crossPro(t2-t1,t4-t3) == 0)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3120
x,k,d = map(int,input().split())
r = abs(x)//d
if r >= k:
    print(abs(x)-abs(d)*k)
else:
    if (k-r)%2==0:
        print(abs(x)-abs(d)*r)
    else:
        print(abs(abs(x)-abs(d)*(r+1)))

Measured memory_bytes: 9144
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll seg[1<<19],lazy[1<<19],n,q;
void rep(int k,int r,int l){
    if(lazy[k]!=0){
        seg[k]+=(l-r+1)*lazy[k];
        if(l-r>0){
        lazy[k*2+1]+=lazy[k];
        lazy[k*2+2]+=lazy[k];
        }
    }
    lazy[k]=0;
}
void add(int a,int b,int r,int l,int k,int x){
    rep(k,r,l);
    
    if(a<=r&&l<=b){
        lazy[k]+=x;
        rep(k,r,l);
        return;
    }
    if(b<r||l<a)return;
    add(a,b,r,(r+l-1)/2,k*2+1,x);
    add(a,b,(r+l+1)/2,l,k*2+2,x);
    seg[k]=seg[k*2+1]+seg[k*2+2];
    
    
}
ll sum(int a,int b,int r,int l,int k){
    rep(k,r,l);
    if(a<=r&&l<=b)return seg[k];
    if(b<r||l<a)return 0;
    return sum(a,b,r,(r+l-1)/2,k*2+1)+sum(a,b,(r+l+1)/2,l,k*2+2);
}
int main(void){
    cin>>n>>q;
    for(int i=0;i<q;i++){
        int a,s,t;
        cin>>a>>s>>t;
        s--;
        t--;
        if(a){
            cout<<sum(s,t,0,(1<<18)-1,0)<<endl;
        }else{
            int x;
            cin>>x;
            add(s,t,0,(1<<18)-1,0,x);
            
        }
    }
}

Measured memory_bytes: 6284