akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long K, long long A, long long B){
  if((B-A)>= K-1||A%K==0||B%K==0||B%K<A%K){
    cout<<"OK"<<endl;
  }else{
    cout<<"NG"<<endl;
  }
}

int main(){
  cout<<setprecision(1000);
    long long K;
    scanf("%lld",&K);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(K, A, B);
    return 0;
}


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

typedef long long ll;
typedef long double ld;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int a,b;
	cin>>a>>b;
	if((a+b)%2!=0) cout<<"IMPOSSIBLE";
	else cout<<(a+b)/2;
	
	
		
	return 0;
}



Measured memory_bytes: 256
w = int(input())
n = int(input())
Ami = []
Num = []
for i in range(n):
    Ami.append(list(map(int,input().split(","))))
for i in range(1,w+1):
    pos = i
    for j in range(n):
        if pos == Ami[j][0]:
            pos = Ami[j][1]
        elif pos == Ami[j][1]:
            pos = Ami[j][0]
    Num.append([pos,i])
Num = sorted(Num)
for k in range(0,w):
    print(Num[k][1])

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

long long n, k, ans;

int main() {
    cin >> n >> k;
    ans = 1;
    if (n > k) ans = 0;
    for (int i=0; i<n; i++) {
        ans = (ans * (k-i))%1000000007;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;


int main()
{ 

ll n; 
cin>>n;

long double x[n],y[n];

for(ll i=0;i<n;i++)
  cin>>x[i]>>y[i];

  long double ans=0;

  for(ll i=0;i<n;i++)
  {
    for(ll j=0;j<n;j++)
    {
      if(i!=j)
        ans+=sqrt((x[i]-x[j])*(x[i]-x[j]) +(y[i]-y[j])*(y[i]-y[j]));
    }
  }
ans/=n;
  cout<<fixed<<setprecision(10)<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define MAX_N 200000

using namespace std;
typedef pair<int, int> ipair;

int H, W, N, x, y;
string S, T;

int cnt_S[4][MAX_N + 1], cnt_T[4][MAX_N + 1];
string chars = "LRUD";

//高橋君が勝つかどうかを返す
bool solve() {
    for(int i = 0; i < N; ++i) {
        bool to_left, to_up;
        //高橋君
        to_left = x + cnt_S[1][i] - cnt_T[0][i] - W < 
                         - (x - cnt_S[0][i] + cnt_T[1][i]);

        to_up = y + cnt_S[3][i] - cnt_T[2][i] - H < 
                         - (y - cnt_S[2][i] + cnt_T[3][i]);

        if(S[i] == 'L' && to_left) x--;
        if(S[i] == 'R' && !to_left) x++;
        if(S[i] == 'U' && to_up) y--;
        if(S[i] == 'D' && !to_up) y++;

        if(x < 0 || x >= W || y < 0 || y >= H) return false;

        //青木君
        to_left = x + cnt_S[1][i + 1] - cnt_T[0][i] - W < 
                         - (x - cnt_S[0][i + 1] + cnt_T[1][i]);

        to_up = y + cnt_S[3][i + 1] - cnt_T[2][i] - H < 
                         - (y - cnt_S[2][i + 1] + cnt_T[3][i]);

        if(T[i] == 'L' && !to_left) x--;
        if(T[i] == 'R' && to_left) x++;
        if(T[i] == 'U' && !to_up) y--;
        if(T[i] == 'D' && to_up) y++;

        if(x < 0 || x >= W || y < 0 || y >= H) return false;
    }

    return true;
}

int main(int argc, char **argv) {
    cin >> H >> W >> N >> y >> x;
    cin >> S >> T;
    y--, x--;

    cnt_S[0][N] = cnt_S[1][N] = cnt_S[2][N] = cnt_S[3][N] = 0;
    cnt_T[0][N] = cnt_T[1][N] = cnt_T[2][N] = cnt_T[3][N] = 0;

    for(int i = N - 1; i >= 0; --i)
        for(int j = 0; j < 4; ++j) {
            cnt_S[j][i] = cnt_S[j][i + 1] + (S[i] == chars[j]);
            cnt_T[j][i] = cnt_T[j][i + 1] + (T[i] == chars[j]);;
        }
    
    
    cout << (solve() ? "YES" : "NO") << endl;
}

Measured memory_bytes: 7048
#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);
  }
  
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  int A=0,B=0;
  
  for(int i=0;i<N;i++){
    if(i%2==0)A+=a.at(i);
    else B+=a.at(i);
  }
  
  cout<<A-B<<endl;
}

Measured memory_bytes: 3588
#include <stdio.h>
#include <math.h>
int main(void) {
	int n,i;
	scanf("%d",&n);
	double x1[20],y1[20],x2[20],y2[20],x3[20],y3[20],a[20],b[20],c[20],aa[20],bb[20],cc[20],r[20],x[20],x11[20],x22[20],x33[20],x12[20],x13[20],y[20],y11[20],y12[20],y13[20],y22[20],y33[20];
	for(i=0;i<n;i++){
		scanf("%lf %lf %lf %lf %lf %lf",&x1[i],&y1[i],&x2[i],&y2[i],&x3[i],&y3[i]);
		aa[i]=fabs(((x2[i]-x1[i])*(x2[i]-x1[i]))+((y2[i]-y1[i])*(y2[i]-y1[i])));
		bb[i]=fabs(((x3[i]-x2[i])*(x3[i]-x2[i]))+((y3[i]-y2[i])*(y3[i]-y2[i])));
		cc[i]=fabs(((x1[i]-x3[i])*(x1[i]-x3[i]))+((y1[i]-y3[i])*(y1[i]-y3[i])));
		a[i]=sqrt(aa[i]);
		b[i]=sqrt(bb[i]);
		c[i]=sqrt(cc[i]);
		r[i]=(a[i]*b[i]*c[i])/(sqrt((a[i]+b[i]+c[i])*(-a[i]+b[i]+c[i])*(a[i]-b[i]+c[i])*(a[i]+b[i]-c[i])));
		x11[i]=x1[i]*x1[i];
		x22[i]=x2[i]*x2[i];
		x33[i]=x3[i]*x3[i];
		x12[i]=x1[i]-x2[i];
		x13[i]=x1[i]-x3[i];
		y11[i]=y1[i]*y1[i];
		y22[i]=y2[i]*y2[i];
		y33[i]=y3[i]*y3[i];
		y12[i]=y1[i]-y2[i];
		y13[i]=y1[i]-y3[i];
		x[i]=(((y13[i]*(y11[i]-y22[i]+x11[i]-x22[i]))-(y12[i]*(y11[i]-y33[i]+x11[i]-x33[i])))/((2*y13[i]*x12[i])-(2*y12[i]*x13[i])));
		y[i]=(((x13[i]*(x11[i]-x22[i]+y11[i]-y22[i]))-(x12[i]*(x11[i]-x33[i]+y11[i]-y33[i])))/((2*x13[i]*y12[i])-(2*x12[i]*y13[i])));
		printf("%.3f %.3f %.3f\n",x[i],y[i],r[i]);
		
	}
	return 0;
}


Measured memory_bytes: 1980
#include <iostream>

 

using namespace std;

 

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if(a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if(b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    else if(b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
    else if(c <= a && a <= b)
        cout << c << " " << a << " " << b << endl;
    else if(c <= b && b <= a)
        cout << c << " " << b << " " << a << endl;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(){
    cin.tie(0)->sync_with_stdio(false);

	string s;
	cin >> s;
	reverse(s.begin(), s.end());

	bool ok = true;
	while (true) {
		if (s[0] == 'm') {
			if ("maerd" != s.substr(0, 5)) {
				ok = false;
				break ;
			} else s.erase(s.begin(), s.begin() + 5);
		} else if (s[0] == 'r') {
			if ("remaerd" != s.substr(0, 7)) {
				if ("resare" != s.substr(0, 6)) {
					ok = false;
					break ;
				} else s.erase(s.begin(), s.begin() + 6);
			} else s.erase(s.begin(), s.begin() + 7);
		} else if (s[0] == 'e') {
			if ("esare" != s.substr(0, 5)) {
				ok = false;
				break ;
			} else s.erase(s.begin(), s.begin() + 5);
		} else {
			ok = false;
			break;
		}
		if (s.size() == 0) break ;
	}

	if (ok) cout << "YES" << '\n';
	else cout << "NO" << '\n';
    return 0;
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a;
  vector<int> b;
  a.resize(n);
  b.resize(n);
  for(int i=0; i<n; i++){
    cin >> a.at(i) >> b.at(i);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());

  if(n%2==1){
    int p = (n-1)/2;
    cout<<b[n-1-p] - a[p] + 1 <<endl;
  }
  else {
    int p = n/2;
    cout<< (b[p] + b[p-1]) - (a[p] + a[p-1]) +1 << endl;
  }

  return 0;
}


Measured memory_bytes: 4468
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int K = sc.nextInt();
		int ans = 0;
		if (N % K != 0) ans = 1;
		System.out.println(ans);
	}

	public static long gcd(long a, long b) {
		long remainder = a % b;
		if (remainder == 0) {
			return b;
		} else {
			return gcd(b, remainder);
		}
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21200
from collections import defaultdict
n = int(input())
if n in [1, 2]:
    print(0)
    exit()

count_primes = defaultdict(int, {})
for m in range(2, n+1):
    p = 2
    while p**2 <= m:
        while m%p == 0:
            m //= p
            count_primes[p] += 1
        p += 1
    if m > 1:
        count_primes[m] += 1
# print(count_primes)

count_div = [0]*100
for _, c in count_primes.items():
    for i in range(c+1):
        count_div[i] += 1
# print(count_div)

ans = count_div[74] + count_div[24]*(count_div[2]-1) \
    + count_div[14]*(count_div[4]-1) + count_div[4]*(count_div[4]-1)//2*(count_div[2]-2)
print(ans)


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

using LL = long long;

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); --(i))
#define SORT(x) sort(ALL((x)))
#define RSORT(x) sort(RALL((x)))
#define SZ(x) (int)(x).size()
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e18;

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

  string ans = "ABC";
  string N;
  cin >> N;

  cout << ans + N << '\n';

  return 0;
}

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

int main() {
    int k;
    int p[5];
    bool ans = true;
    
    for (int i = 0; i < 5; i++) {
        cin >> p[i];
    }
    
    cin >> k;
    
    for (int i = 0; i < 5; i++) {
        for (int ii = (i + 1); ii < 5; ii++) {
            if ((p[ii] - p[i]) > k) {
                ans = false;
                break;
            }
        }
    }
    
    cout << (ans ? "Yay!" : ":(") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

vector<pair<string, i64> > solve(i64 N) {
  if(N == 1) {
    return {{"a", 1}};
  }
  vector<pair<string, i64>> prev(solve(N - 1));
  i64 i, j;
  vector<pair<string, i64>> ret;
  REP(0, sz(prev), i) {
    i64 n = prev[i].second;
    string a = prev[i].first + "a";
    REP(0, n+1, j) {
      ret.pb({a, max(n, j+1)});
      a[N-1]++;
    }
  }
  return ret;
}

int main(int argc, char *argv[]) {
  i64 N;
  cin >> N;

  vector<pair<string, i64>> ans = solve(N);
  //vector<pair<string, i64>> ans2 = ans;
  //sort(all(ans2));
  i64 i;
  REP(0, sz(ans), i) {
    cout << ans[i].first << endl;
    //if(ans[i].first != ans2[i].first) {
    //cout << "error" << endl;
    //}
  }
  
  return 0;
}


Measured memory_bytes: 10080
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x;
    
    int c=0;
    cin>>n>>x;
    int a[n];
    for(int i=0;i<n;i++)
    {
    	cin>>a[i];
    	if(a[i]>=x)
    	{
    		c++;
		}
	}
	cout<<c<<endl;
	
    
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)3e2+11;
ll const LG=(ll)log2(N)+1;


void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        ll h,w;
        cin>>w>>h>>x>>y;
        
        ll a1,a2,b1,b2;
        
         ld ans=(double)(w*h)/2.0;
         cout<<fixed<<setprecision(11);
         cout<<ans<<" ";
         if(2*x==w and 2*y==h){
                 cout<<1<<endl;
         }else{
                 cout<<0<<endl;
         }

        
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}

Measured memory_bytes: 3804
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}

int32_t main()
{   
     IOS;
     
     ll n,m,i,j,k;
     string ss;
     cin>>ss;
     deque<char> s;
     for(i=0;i<(ll)ss.length();i++)
      s.pb(ss[i]);
     ll q;
     int f=0;
     cin>>q;
     while(q--)
     {
      ll x;
      cin>>x;
      if(x==1)
        f=1-f;
      else
      {
        ll y;
        char xx;
        cin>>y>>xx;
        if(f==0)
        {
          if(y==1)
            s.push_front(xx);
          else
            s.push_back(xx);
        }
        else
        {
          if(y==2)
            s.push_front(xx);
          else
            s.push_back(xx);
        }
      }
      // for(i=0;i<(ll)s.size();i++) cout<<s[i];
      //   cout<<endl;
     }
     if(f==0)
     {for(i=0;i<(ll)s.size();i++) cout<<s[i];}
   else
   {
    for(i=s.size()-1;i>=0;i--) cout<<s[i];
   }

     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

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

int C[3][3];

int A(int b1,int b2,int b3,int d)
{
	if (d == 3) {
		return 1;
	}

	for (int a = 0; a <= 100; a++) {
		if (a + b1 == C[d][0] && a + b2 == C[d][1] && a + b3 == C[d][2]) {
			return A(b1, b2, b3, d + 1);
		}
	}
	return 0;
}

int main()
{
	for (int i = 0; i < 3; i++) {
		for (int k = 0; k < 3; k++) {
			cin >> C[i][k];
		}
	}

	for (int b1 = 0; b1 <= 100; b1++) {
		for (int b2 = 0; b2 <= 100; b2++) {
			for (int b3 = 0; b3 <= 100; b3++) {
				int ok = A(b1, b2, b3, 0);
				if (ok) {
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static int[][] dp;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int r = sc.nextInt();
		ArrayDeque<Integer> deq = new ArrayDeque<>();
		for (int i = 0; i < r; i++) {
		    deq.add(sc.nextInt() - 1);
		}
		dp = new int[n][n];
		for (int i = 0; i < n; i++) {
		    Arrays.fill(dp[i], Integer.MAX_VALUE / 10);
		    dp[i][i] = 0;
		}
		for (int i = 0; i < m; i++) {
		    int a = sc.nextInt() - 1;
		    int b = sc.nextInt() - 1;
		    int c = sc.nextInt();
		    dp[a][b] = c;
		    dp[b][a] = c;
		}
		for (int i = 0; i < n; i++) {
		    for (int j = 0; j < n; j++) {
		        for (int k = 0; k < n; k++) {
		            dp[j][k] = Math.min(dp[j][k], dp[j][i] + dp[i][k]);
		        }
		    }
		}
		long min = Long.MAX_VALUE;
		for (int i = 0; i < r; i++) {
		    int x = deq.poll();
		    min = Math.min(min, search(x, deq));
		    deq.add(x);
		}
        System.out.println(min);
   }
   
   static long search(int idx, ArrayDeque<Integer> deq) {
       if (deq.size() == 1) {
           return dp[idx][deq.peek()];
       }
       int size = deq.size();
       long min = Long.MAX_VALUE;
       for (int i = 0; i < size; i++) {
           int x = deq.poll();
           min = Math.min(min, dp[idx][x] + search(x, deq));
           deq.add(x);
       }
       return min;
   }
}




Measured memory_bytes: 48592
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	double a, b, c, d, e, f;

	vector<string> v;
	while (cin >> a >> b >> c >> d >> e >> f) {
		double x, y;

		x = ((c * e) - (b * f)) / ((a * e) - (b * d));
		y = ((c * d) - (a * f)) / ((b * d) - (a * e));

		if (x == 0) {
			x = 0;
		}
		else if (y == 0) {
			y = 0;
		}

		x = x * 1000;
		x = round(x);
		x = x / 1000;

		y = y * 1000;
		y = round(y);
		y = y / 1000;

		stringstream ss;
		ss << fixed << setprecision(3) << x << " " << y;
		v.push_back(ss.str());
	}
	
	for (int i = 0; i < v.size(); i++) {
		cout << v[i] << endl;
	}

	return 0;
}

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

int main() {
  int k, x;
  cin >> k >> x;
  int lb = max(-1000000, x-k+1);
  int ub = min(1000000, x+k-1);

  for(int i=lb; i<=ub; i++)
    cout << i << " \n"[i==ub];
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    		String kosu=br.readLine();
    		int nako=Integer.parseInt(kosu);
        	String strArr[] = br.readLine().split(" ");
        	int[] a=new int[nako];

        	for(int j=0; j<nako; j++){
        		a[j]=Integer.parseInt(strArr[j]);
        	}

        	for(int i=0;i<nako-1;i++){
        	      for(int j=nako-1;j>i;j--){

        		if(a[j]<a[j-1]){
        		  int t=a[j];
        		  a[j]=a[j-1];
        		  a[j-1]=t;
        		}
        	  }
        	}

        	long sum=0;
        	for(int i=0; i<nako; i++){
        		sum+=a[i];
        	}

        	System.out.println(a[0]+" "+a[nako-1]+" "+sum);

    }
}

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

int main() {
	string s,t;
	cin>>s>>t;
	int count=0;
	for(int i=0; i<s.length(); i++){
		if(s[i] != t[i]){
			count++;
		}
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 3916
#include <stdio.h>
int main(void){
	int d[] = { -5, -1, 1, 5 };
	int np, bp, tp, pp, i, j, k, n, x, y;
	char s, t, b;
	
	for(; scanf("%d %c %c %c", &n, &s, &t, &b), n; ){
		double pr[2][25] = {};
		np = ( ( s - 'A' ) / 3 + 1 ) * 5 + ( s - 'A' ) % 3 + 1;
		tp = ( ( t - 'A' ) / 3 + 1 ) * 5 + ( t - 'A' ) % 3 + 1;
		bp = ( ( b - 'A' ) / 3 + 1 ) * 5 + ( b - 'A' ) % 3 + 1;
		pr[n & 1][np] = 1.0;

		for( ; n--; ){
			for( i = 1; i < 4; i++ ){
				for( j = 1; j < 4; j++ ){
					pr[n & 1][i * 5 + j] = 0.0;
				}
			}
			for( i = 1; i < 4; i++ ){
				for( j = 1; j < 4; j++ ){
					pp = i * 5 + j;
					for( k = 0; k < 4; k++ ){
						np = pp + d[k];
						x = np % 5;
						y = np / 5;
						if( x < 1 || x > 3 || y < 1 || y > 3 || np == bp ){
							pr[n & 1][pp] += pr[~n & 1][pp] * 0.25;
						}
						else{
							pr[n & 1][np] += pr[~n & 1][pp] * 0.25;
						}
					}
				}
			}
		}
		printf("%f\n", pr[0][tp] );
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    if(a < b){
        for(int i = 0; i < b; i++)
            cout << a;
    }
    else{
        for(int i = 0; i < a; i++)
            cout << b;
    }
    return 0;
}

Measured memory_bytes: 3560
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll get(vector<ll>v, ll len)
{
	ll now = 0;
	int lb = 0, ub = v.size() - 1;
	for (int i = 0; i < v.size(); i++)
	{
		if (i % 2 == 0)
		{
			if (i == v.size() - 1)now += v[lb];
			else now += v[lb] * 2, lb++;
		}
		else
		{
			if (i == v.size() - 1)now += len - v[ub];
			else now += (len - v[ub]) * 2, ub--;
		}
	}
	ll maxi = now;
	int cur = v.size() % 2;
	for (int i = 0; i < v.size() - 1; i++)
	{
		now -= v[i] * 2;
		if (cur == 0)
		{
			now += v[lb] + v[lb] - len;
		}
		else
		{
			now += v[lb] + v[lb + 1] - len;
			lb++;
		}
		maxi = max(maxi, now);
		cur = 1 - cur;
	}
	return maxi;
}
int main()
{
	ll len;
	int num;
	scanf("%lld%d", &len, &num);
	vector<ll>v1, v2;
	for (int i = 0; i < num; i++)
	{
		ll z;
		scanf("%lld", &z);
		v1.push_back(z);
		v2.push_back(len - z);
	}
	reverse(v2.begin(), v2.end());
	ll a = get(v1, len), b = get(v2, len);
	printf("%lld\n", max(a, b));
}


Measured memory_bytes: 5092
#include <iostream>

using namespace std;
#define MAX 100
#define NIL (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2
int G[MAX][MAX];//图的邻接矩阵
int color[MAX];//节点状态
int n;
int d[MAX];//最小权值
int p[MAX];//父亲节点
void dijkstra(){
    for(int i=0;i<n;i++){
        color[i] = WHITE;
        d[i] = NIL;
        p[i] = -1;
    }
    d[0] = 0;
    while(1){
        int u;
        int mincost = NIL;
        for(int i=0;i<n;i++){//循环找到下一个要加入到S中的(d[u]最小值)
            if(color[i]!=BLACK&&d[i]<mincost){
                mincost = d[i];
                u = i;
            }
        }
        if(mincost==NIL){
            break;
        }
        color[u] = BLACK;
        for(int v=0;v<n;v++){//给相邻顶点的d赋值（与之前的相比较，找到最小的）
            if(color[v]!=BLACK&&G[u][v]!=-1){
                    if(d[u]+G[u][v]<d[v]){
                        d[v] = d[u]+G[u][v];
                        p[v] = u;
                    }
                }
            }
        }



}
int main()
{
    cin>>n;
     for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            G[i][j] = -1;
        }

    }
    for(int i=0;i<n;i++){
        int u,k;
        cin>>u>>k;
        for(int i=0;i<k;i++){
            int v,c;
            cin>>v>>c;
            G[u][v] = c;
        }
    }

    dijkstra();
    for(int i=0;i<n;i++){
        cout<<i<<" "<<d[i]<<endl;
    }
    return 0;
}




Measured memory_bytes: 3132
#include<stdio.h>
int main()
{
    char A[10],B[10];
    while((scanf("%s%s%", &A, &B))!=EOF)
    {


    if (A[0]==B[2] && A[1]==B[1] && A[2]==B[0])
        printf("YES\n");
    else
        printf("NO\n");
    }

}


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

const int M = 1000005;

// エラトステネスのふるいっぽいことをする
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> cnt(M);
    for(int x : a) {
        if (cnt[x] != 0) {
            cnt[x] = 2;
            continue;
        }
        for(int i = x; i < M; i += x) cnt[i]++;
    }
    int ans = 0;
    for(int x : a) {
        if (cnt[x] == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

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



int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s;
	cin >> s;
	int ile = 0;
	for (int i = 0; i < s.size()/2; ++i){
		if (s[i] != s[s.size()-1-i])
			ile++;
	}
	cout << ile << "\n";
}

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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define mp(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    ll ans = 0;
    ll ar[n];
    for (int i = 0; i < n; i++) {
        cin >> ar[i];
    }
    for (int i = 1; i < n; i++) {
        if (ar[i] < ar[i - 1]) {
            ans += ar[i - 1] - ar[i];
            ar[i] = ar[i - 1];
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 5252
#include <bits/stdc++.h>
using namespace std;
int main(){
    int r,c;
    cin>>r>>c;
    int cards[r+1][c+1];
    int sum=0;
    int total_sum=0;
    for(int i = 0; i < r+1; i++){
		for(int j = 0; j < c+1; j++){
			cards[i][j] = 0;
		}
	}
    int total=0;
    for(int i=0;i<r;i++){
        sum=0;
        for(int j=0;j<c;j++){
            cin>>cards[i][j];
            sum+=cards[i][j];
            cards[r][j]+=cards[i][j];
        }
        cards[i][c]=sum;
        total_sum+=sum;
    }
    cards[r][c]=total_sum;
    for(int i=0;i<r+1;i++){
        for(int j=0;j<c;j++){
            cout<<cards[i][j]<<" ";
        }
        cout<<cards[i][c]<<endl;
    }
}


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

void solve(long long N, long long D){
    ll ans = N / (2 * D + 1);
    if (N % (2 * D + 1) == 0) cout << ans << endl;
    else cout << ans + 1 << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    solve(N, D);
    return 0;
}


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

using namespace std;
#define lint long long

const int MAX_N = 100000;
int color[MAX_N + 1];
map<int, vector<int>> gr;

bool dfs(int v, int c){
    color[v] = c;
    for(auto i : gr[v]){
        if(color[i] == c){
            return false;
        }
        if(color[i] == 0 && !dfs(i, -c)){
            return false;
        }
    }
    return true;
}

signed main() {
    lint N, M;
    cin >> N >> M;
    
    int A[M], B[M];
    
    for(int i = 0; i < M; ++i){
        cin >> A[i] >> B[i];
        gr[A[i]].push_back(B[i]);
        gr[B[i]].push_back(A[i]);
    }
    
    if(dfs(1, 1)){
        lint B = 0;
        for(int i = 1; i < N + 1; ++i){
            if(color[i] == 1){
                ++B;
            }
        }
        lint W = N - B;
        
        cout << B * W - M << endl;
    } else {
        cout << N * (N - 1) / 2 - M << endl;
    }
}

Measured memory_bytes: 13056
from itertools import combinations 
n,k=map(int,input().split())
m = (n-1)*(n-2)//2
if k>m:
    print(-1)
else:
    es = []
    for i in range(2,n+1):
        es.append('1 %d' % i)
        
    idx = 0
    for i,j in combinations(range(2,n+1),2):
        if idx == m-k:
            break
        es.append('%d %d' % (i,j))
        idx +=1
    print(len(es))
    print(*es,sep="\n")

Measured memory_bytes: 40816
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
        aa: [usize;n]
    }
    let mut b = vec![0;n+1];
    for i in aa {
        b[i] += 1;
    }
    let mut c = b.iter().filter(|x| **x != 0).count();
    let mut res = 0;
    for i in 1..n+1 {
        if c <= k {
            break;
        }
        let p = std::cmp::min(c - k, b.iter().filter(|x| **x == i).count());
        c -= p;
        res += p * i;
    }
    println!("{}", res);
}


Measured memory_bytes: 10492
(defun f (a c d)
  (- (+ a (floor a (lcm c d))) (floor a c) (floor a d)))

(let ((a (read))
      (b (read))
      (c (read))
      (d (read)))
     (princ (+ (if (= 0 (* (rem a d) (rem a c))) 0 1) (- (f b c d) (f a c d)))))

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

int main(){
  string s;
  cin >> s;
  int month = 10*(s.at(5) - '0') + s.at(6) - '0';
  if(month < 5){
    cout << "Heisei" << endl;
  }
  else{
    cout << "TBD" << endl;
  }
}

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

int main() {
	int N, M;
	int a[60], b[60], C[60] = { 0 };
	cin >> N >> M;
	for (int i = 0; i < M; i++)cin >> a[i] >> b[i];
	for (int i = 0; i < M; i++) {
		++C[a[i]];
		++C[b[i]];
	}
	for (int i = 1; i <=N; i++) cout << C[i] << endl;
}


Measured memory_bytes: 256
def solve(d,x,y):
    d[y][x] = 0
    bomb = [ [-3,0],[-2,0],[-1,0],[1,0],[2,0],[3,0],[0,-3],[0,-2],[0,-1],[0,1],[0,2],[0,3] ]
    for dx,dy in bomb:
        if 0 <= dx+x <= 7 and 0 <= dy+y <= 7 and d[dy+y][dx+x] :
                solve(d,dx+x,dy+y)
    return d


n = input()
for i in xrange(n):
    raw_input()
    data = []
    for j in xrange(8):
        data.append( map(int,raw_input()) )
    fx = input()
    fy = input()
    ans = solve(data,fx-1,fy-1)
    print "Data %d:" % (i+1)
    for e in ans:
        print "".join(map(str,e))

Measured memory_bytes: 4320
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
    string S,A="No";
    cin >> S;
	char d[4];
	d[0]=S[0],d[1]=S[1],d[2]=S[2],d[3]=S[3];
	sort(d,d+4);
    if (d[0]==d[1] && d[2]==d[3] && d[0]!=d[2])
        A="Yes";
    cout << A << endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split("\s").map(&:to_i)

sum = Array.new
a.each do |item|
  begin
    sum.push sum.last + item
  rescue
    sum.push item
  end
end


result = Array.new

# 左の最適値を計算
l = 0
c = 1
f_l = Array.new
diff = sum[-1]
while true do
    tmp_diff = (sum[c] - 2*sum[l]).abs

    #puts "l: #{l}, c: #{c}, diff: #{diff}, tmp_diff: #{tmp_diff}"

    if tmp_diff > diff then
        #puts "f_l[#{c}]: #{l-1}"
        f_l[c] = l-1
        l -= 1
        
        if c < n-2 then
            c += 1
            diff = sum[-1]
        else
            break
        end
    elsif l == c-1 then
        #puts "f_l[#{c}]: #{l}"
        f_l[c] = l
        
        if c < n-2 then
            c += 1
            diff = sum[-1]
        else
            break
        end
    elsif l < c-1 then
        diff = tmp_diff
        l += 1
    else
        break
    end
end

#p f_l

# 右の最適値を計算
r = 2
c = 1
f_r = Array.new
diff = sum[-1]
while true do
    tmp_diff = (sum[-1] - 2*sum[r] + sum[c]).abs

    #puts "c: #{c}, r: #{r}, diff: #{diff}, tmp_diff: #{tmp_diff}"

    if tmp_diff > diff then
        #puts "f_r[#{c}]: #{r-1}"
        f_r[c] = r-1
        r -= 1
        
        if c < n-2 then
            c += 1
            diff = sum[-1]
        else
            break
        end
    elsif r == n-1 then
        #puts "f_r[#{c}]: #{r}"
        f_r[c] = r
        
        if c < n-2 then
            c += 1
            diff = sum[-1]
        else
            break
        end
    elsif r < n-1 then
        diff = tmp_diff
        r += 1
    else
        break
    end
end

#p f_r

result = Array.new
for c in 1...n-2 do
    l = f_l[c]
    r = f_r[c]

    v1 = sum[l]
    v2 = sum[c] - sum[l]
    v3 = sum[r] - sum[c]
    v4 = sum[-1] - sum[r]

    tmp = [v1, v2, v3, v4]
    #puts "c: #{c}"
    #p tmp
    
    result.push tmp.max - tmp.min
end

puts result.min


Measured memory_bytes: 28132
#include "bits/stdc++.h"
// Custom Header <<<
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;
// >>>


signed main()
{
    int N;
    unordered_map<int,int> cnt;

    cin >> N;

    rep(i, 0, N) {
        int a; cin >> a;
        cnt[a] += 1;
    }

    vector<i64> a;

    for (const auto &e : cnt) {
        i64 l = e.first;
        int n = e.second;

        if (n >= 4) {
            a.push_back(l);
            a.push_back(l);
        } else if (n >= 2) {
            a.push_back(l);
        }
    }

    sort(ALL(a), greater<>());

    if (a.size() < 2) {
        cout << (0) << endl;
    } else {
        cout << (a[0] * a[1]) << endl;
    }
    return 0;
}

/* vim:set foldmethod=marker foldmarker=<<<,>>> : */


Measured memory_bytes: 4388
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;//10^18
const ll mod = 1000000007;
//printf("%.10f\n", n);
ll d[2134][2134];//コスト
void warshall_floyd(ll V) {
	for (int h = 1; h <= V; h++) {
		for (int i = 1; i <= V; i++) {
			for (int j = 1; j <= V; j++) {
				d[i][j] = min(d[i][j], d[i][h] + d[h][j]);
			}
		}
	}
}
ll ok[12345678], test[1000];
signed main() {
	for (int h = 0; h < 2134; h++) {
		for (int i = 0; i < 2134; i++) {
			d[h][i] = INF;
		}
	}
	ll n = 0, m, r, a = 0, b = 0, c = 0, cnt = 1, sum = 0, ans = INF;
	cin >> n >> m >> r; vector<ll> v;
	for (int h = 0; h < r; h++) { cin >> test[h]; }
	sort(test, test + r);
	for (int h = 0; h < m; h++) {
		cin >> a >> b >> c; d[a][b] = c; d[b][a] = c;
	}
	warshall_floyd(n);
	do {
		cnt = 0;
		for (int i = 1; i < r; i++) {
			cnt += d[test[i - 1]][test[i]];
		}
		ans = min(ans, cnt);
	} while (next_permutation(test, test + r));
	cout << ans << endl;
	return 0;
}

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


int main() {
    int n, l;
    cin >> n >> l;
    vector<string> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end());

    for (int i = 0; i < vec.size(); i++) {
        cout << vec.at(i);
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;

public class Main
{
  public static void main(String[] args) {
    try{
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      int n = Integer.parseInt(in.readLine());
      String[] arr = in.readLine().split(" ");
      int[] A = new int[n];
      for(int i=0; i<n; i++) {
        A[i] = Integer.parseInt(arr[i]);
      }
      int partitionId = partition(A, 0, n-1);
      StringBuilder sb = new StringBuilder();
      for(int i=0; i<n; i++) {
        if(i == partitionId) {
          sb.append("[").append(A[i]).append("] ");
        } else if(i == n-1) {
          sb.append(A[i]);
        } else {
          sb.append(A[i]).append(" ");
        }
      }
      System.out.println(sb.toString());
    } catch (IOException e) {}

  }

  public static int partition(int[] A, int p, int r) {
    int x = A[r];
    int i = p - 1;
    for(int j = p; j < r; j++) {
      if(A[j] <= x) {
        i++;
        int tmp = A[j];
        A[j] = A[i];
        A[i] = tmp;
      }
    }
    A[r] = A[i+1];
    A[i+1] = x;
    return i+1;
  }

}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	ll n, m=pow(10, 9)+7;
	string s;
	cin >> n >> s;
	vi v(26,0);
	for(char c: s) ++v[c-'a'];
	ll ans = 1;
	REP(i, 0, 26){
		ans *= (v[i]+1);
		ans%= m;
	}
	cout << (ans-1)%m;
	

}


Measured memory_bytes: 512
#include<iostream>
#include<map>
using namespace std;
typedef long long int ll;
static const int MAX_N = 100000;

int N; ll M;
map<ll, ll> mpa;

int main(){
	cin >> N >> M;
	ll sum = 0LL;
	for(int i = 0; i < N; i++){
		ll a;
		cin >> a;
		sum += a;
		mpa[sum % M]++;
	}
	ll res = 0LL;
	for(auto e : mpa){
		if(e.first == 0LL) res += e.second;
		res += e.second * (e.second - 1) / 2LL;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define r1 101
#define c1 100001
ll int knapsack(ll int *w,ll int *val, ll int sum, ll int n ,ll int dp[][c1])
{
    if(sum<=0||n<=0)
      return 0;
    
  	if(dp[n][sum]!=-1)
     return dp[n][sum];
 	if(w[n-1]<=sum)
     return  dp[n][sum] = max(val[n-1] + knapsack(w, val, sum-w[n-1], n-1,dp), knapsack(w, val,sum,n-1,dp));
  	else
      return  dp[n][sum] = knapsack(w, val,sum,n-1,dp);
}
int main()
{
 	ll int n,W;
  cin>>n>>W;
 	ll int w[n],val[n];
  for(int i=0;i<n;i++)
    cin>>w[i]>>val[i];
 
 ll  int dp[r1][c1];
  for(int i=0;i<r1;i++)
  {
      for(int j=0;j<c1;j++)
      dp[i][j]= -1;
  }
  cout<<knapsack(w,val,W,n,dp);
    
}

Measured memory_bytes: 82488
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        COneStrokePath solver = new COneStrokePath();
        solver.solve(1, in, out);
        out.close();
    }

    static class COneStrokePath {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] per = new int[n];
            boolean[][] hasEdge = new boolean[n][n];
            int cnt = 0;
            Operation op = new Operation();
            for (int i = 0; i < n; i++) {
                per[i] = i;
                Arrays.fill(hasEdge[i], false);
            }

            for (int i = 0; i < m; i++) {
                int a = in.nextInt() - 1;
                int b = in.nextInt() - 1;
                hasEdge[a][b] = true;
                hasEdge[b][a] = true;
            }

            while (true) {
                if (per[0] != 0) break;
                boolean f = true;
                for (int i = 0; i < n - 1; i++) f = f && hasEdge[per[i]][per[i + 1]];
                if (f) cnt++;
                if (op.nextPermutation(per) == null) break;
            }

            out.println(cnt);

        }

    }

    static class Operation {
        public int[] nextPermutation(int[] array) {
            int k = -1;
            int i = array.length - 2;
            while (i >= 0) {
                if (array[i] < array[i + 1]) {
                    k = i;
                    break;
                }
                i--;
            }

            // 存在しない場合nullを返す
            if (k == -1) return null;
            int l = k + 1;
            i = array.length - 1;
            while (i > k + 1) {
                if (array[k] < array[i]) {
                    l = i;
                    break;
                }
                i--;
            }

            int tmp = array[k];
            array[k] = array[l];
            array[l] = tmp;
            int[] res = new int[array.length];
            // k+1 <-> n-1
            for (int j = k + 1; j < array.length + k - j; j++) {
                tmp = array[j];
                array[j] = array[array.length + k - j];
                array[array.length + k - j] = tmp;
            }
            return array;
        }

    }
}



Measured memory_bytes: 23380
a=input()
a=int(a)
A=0
W=0
T=0
R=0
for i in range(a):
    b=input()
    if b=="AC":
        A=A+1
    elif b=="WA":
        W=W+1
    elif b=="TLE":
        T=T+1
    elif b=="RE":
        R=R+1
A=str(A)
W=str(W)
T=str(T)
R=str(R)
print("AC x "+A)
print("WA x "+W)
print("TLE x "+T)
print("RE x "+R)


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

int MOD = 1e9 + 7;
int n, m;
long long ans;
int v[25], u[25];
int a[60], b[60];
int dist[60][60];
vector<int> graph[60];

int k(int mask)
{
	if (__builtin_popcount(mask) % 2 == 0)
	    return 1;
	return -1;
}

void dfs(int v, int r, int p, int d)
{
	dist[r][v] = d;
	for (auto u : graph[v])
	    if (u != p) dfs(u, r, v, d + 1);
}

int on_path(int v, int a, int b)
{
	return dist[a][b] == dist[v][a] + dist[v][b];
}

int main()
{
	cin >> n;
	for (int i = 0; i < n - 1; i++)
	{
		int v, u;
		cin >> v >> u, v--, u--;
		a[i] = v, b[i] = u;
		graph[u].push_back(v);
		graph[v].push_back(u);
	}
	cin >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> v[i] >> u[i], v[i]--, u[i]--;
	}
	ans = (1LL << n) / 2;
	for (int i = 0; i < n; i++)
	{
		dfs(i, i, n, 0);
	}
	for (int mask = 1; mask < (1 << m); mask++) {
		int c = 0;
		for (int i = 0; i < n - 1; i++)
		{
			int t = 0;
			for (int j = 0; j < m; j++)
			{
				if ((1 << j) & mask)
				if (on_path(a[i], v[j], u[j]))
				if (on_path(b[i], v[j], u[j]))
				t = 1;
			}
			c += t;
		}
		//cout << "!" << mask << " " << c << endl;
		ans = ans + k(mask) * (1LL << (n - 1 - c));
	}
	cout << ans;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
using namespace std;
int login(int a, int b, int c){
    int count = 0;
    while( c > 0 ){
        c -= a;
        count++;
        if(count % 7 == 0) c -= b;
    }
    
    return count;
    
}
int main(){
    int a, b, c;
    scanf("%d %d %d",&a, &b, &c);
    printf("%d\n",login(a, b, c));
    return 0;
    
}


Measured memory_bytes: 3224
#include<iostream>


#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
using namespace std;

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




int main() {
	int n,a[51],cnt=0;
	cin >> n ;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i+1 == a[i])cnt++;
	}
	if (cnt == n || cnt == n - 2)cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}


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

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

while(1){
  int n; cin >> n;
  if(n == 0) break;
  vector<int> w(n);
  for(int i = 0; i < n; i++){
    cin >> w[i];
  }

  vector< vector<int> > dp(301,vector<int> (301,-1));
  function< int(int,int) > rec =
  [&](int l,int r){
    if(dp[l][r] != -1) return dp[l][r];

    if(abs(l-r) <= 1) return 0LL;

    int res = 0;
    if(abs(w[l] - w[r-1]) <= 1 && rec(l+1,r-1) == (r-1)-(l+1)){
      res = r - l;
    }
    for(int mid = l+1; mid < r; mid++){
      res = max(res,rec(l,mid) + rec(mid,r));
    }
    return dp[l][r] = res;
  };
  cout << rec(0,n) << endl;
}
  return 0;
}



Measured memory_bytes: 3804