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

#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define bg begin()
#define ed end()
#define pii pair<int,int>

int main(){
	int n , m;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	while(cin >> n >> m){
		if(n<=5){
			cout << 0 << endl;
		}
		else if(n<13){
			cout << m/2 << endl;
		}
		else{
			cout << m << endl;
		}
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

ll modinv(ll a) {
  ll M = MOD, b = M, u = 1, v = 0;
  while (b)
    u -= a / b * v, swap(u, v), a %= b, swap(a, b);
  return (u % M + M) % M;
}

void solve() {
  ll N;
  cin >> N;
  vector<ll> X(N);
  rep (i, N) cin >> X[i];

  ll foo = 1;
  for (ll i = 1; i < N; i++) foo = (foo * i) % MOD;

  cerr << "foo: " << foo << endl;

  vector<ll> bar(N);

  for (ll i = 1; i < N; i++) bar[i] = (foo * modinv(i)) % MOD;
  for (ll i = 2; i < N; i++) {
    bar[i] += bar[i-1];
    bar[i] %= MOD;
  }

  cerr << "bar: ";
  for (auto it: bar) cerr << it << ", ";
  cerr << endl;

  ll ans = 0;

  for (ll i = 1; i < N; i++) {
    ll tmp = bar[i];
    tmp *= X[i] - X[i-1];
    tmp %= MOD;
    ans += tmp;
    ans %= MOD;
  }

  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner; // ?????¨?????????????????????

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in); // ??????????????????????????????.

        // ?????????????????? int ?????¨??????????????\???????????????.
        // ??????????????????????????? 0 ????????????.
        while (true) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            if (x == 0 && y == 0) { break; }
            if (x > y) { System.out.println(y + " " + x); }
            else { System.out.println(x + " " + y); }
        }
    }
}

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

#define x first
#define y second
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back
#define DEBUG(x) cout << #x << " = " << x << endl;

using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }
template <typename T> inline T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

inline void proc_status ()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) << endl;
}

const int Maxn = 4000 + 10;
const int Mod = 924844033;

int N, K;
int Dp[Maxn][Maxn][2]; // Dp[i][j][0/1]表示当前处理到第$i$个数，已经连了$j$条边，$i$这个数是否往它前面的那个数连边
int P[Maxn];
int fac[Maxn];

inline void Add (int &a, int b) { if ((a += b) >= Mod) a -= Mod; }

inline void Init ()
{
	fac[0] = 1;
	for (int i = 1; i <= 2 * N; ++i) fac[i] = (LL) fac[i - 1] * i % Mod;
}

inline void Solve ()
{
	Init ();

	int p = N / K, q = N % K;
	int now = 0, cnt = 1;
	for (int k = 0; k < 2; ++k)
	{
		for (int i = 1; i <= q; ++i, ++cnt) 
			for (int j = 1; j <= p + 1; ++j) 
				P[++now] = cnt;
		for (int i = 1; i <= K - q; ++i, ++cnt) 
			for (int j = 1; j <= p; ++j) 
				P[++now] = cnt;
	}

//	for (int i = 1; i <= 2 * N; ++i) cout << P[i] << ' ' ; puts("");

	Dp[1][0][0] = 1;

	for (int i = 2; i <= 2 * N; ++i)
	{
		for (int j = 0; j <= N; ++j)
		{
			Dp[i][j][0] = (Dp[i - 1][j][0] + Dp[i - 1][j][1]) % Mod;
			if (i && j && P[i] == P[i - 1]) Dp[i][j][1] = Dp[i - 1][j - 1][0];
		}
	}

	int ans = 0;

	for (int i = 0; i <= N; ++i)
	{
		int sum = (LL) (Dp[2 * N][i][0] + Dp[2 * N][i][1]) % Mod * fac[N - i] % Mod;
//		cout << i << " " << sum << endl;
		if (i & 1) Add (ans, Mod - sum);
		else Add (ans, sum);
	}
	
	cout << ans << endl;
}

inline void Input ()
{
	N = read<int>(), K = read<int>();
}

int main()
{


	Input ();
	Solve ();

	return 0;
}


Measured memory_bytes: 124672
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
const double PI = acos(-1.0);
const long mod = 1000000007;

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

  bool dp[30009][4][1009];
  dp[0][0][0] = true;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j <= 3; j++) {
      for(int k = 0; k < 1000; k++) {
        if(dp[i][j][k] == true) {
          dp[i+1][j][k] = true;
          if(j < 3) 
            dp[i+1][j+1][k*10 + (s[i] - '0')] = true;
        }
      }
    }
  }
  int cnt = 0;
  for(int i = 0; i < 1000; i++) 
    if(dp[n][3][i] == true) cnt++;
  cout << cnt << endl;
}

Measured memory_bytes: 121824
loop = int(input())
ac = 0
wa = 0
tle =0
re = 0

for _ in range(loop):
  judge = input()
  if judge == 'AC':
    ac += 1
  elif judge == 'WA':
    wa += 1
  elif judge == 'TLE':
  	tle += 1
  elif judge == 'RE':
    re += 1
    
print('AC x {}'.format(ac))
print('WA x {}'.format(wa))
print('TLE x {}'.format(tle))
print('RE x {}'.format(re))

Measured memory_bytes: 9212
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;
  vector<Int> A(N);
  cin>>A;

  const Int M = 61;
  vector<Int> cnt(M, 0);
  for(Int i=0;i<N;i++)
    for(Int j=0;j<M;j++) cnt[j] += (A[i]>>j&1);

  Int ans = 0;
  for(Int i=0;i<N;i++){
    for(Int j=0;j<M;j++) cnt[j] -= (A[i]>>j&1);
    for(Int j=0;j<M;j++){
      Int num = (1LL<<j)%mod;
      if(A[i]>>j&1) ans += num * ((N - i - 1) - cnt[j]);
      else ans += num * (cnt[j]);
      ans %= mod;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2688
def resolve():
    N = int(input())
    S, T = input().split()

    S_list = list(S)
    T_list = list(T)

    answer = ""

    for i in range(N):
        answer += S_list[i]
        answer += T_list[i]

    print(answer)
    
 
if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3060
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define int ll

#define F first
#define S second
#define _sz(x) (int)x.size()

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

int const N = 1e5 + 20 ;
int n , a[N] , l , r ;

int32_t main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;

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

	l = r = 2 ;

	for (int i = n - 1 ; i >= 0 ; i --) {
		l = (l + a[i] - 1) / a[i] * a[i] , r = r / a[i] * a[i] + (a[i] - 1) ;
		if (l > r) return cout << "-1\n" , 0 ;
	}

	cout << l << ' ' << r << '\n' ;
}

Measured memory_bytes: 1024
import Control.Monad
import Data.List
main=do
    n<-readLn
    print =<< uni 0.sort<$>replicateM n readLn

uni :: Int -> [Int] -> Int
uni c [] = c
uni c [_] = c+1
uni c (a:b:ds)
    | a == b = uni c (b:ds)
    | True = uni (c+1) (b:ds)

Measured memory_bytes: 1020
S = int(input())
dp = [0] * (S+1)
MOD = 10**9 + 7

for watch in range(3,S+1):
    cnt = 1
    for i in range(3,watch):
        if watch - i < 3:
            break
        cnt += dp[watch-i]
    dp[watch] = cnt % MOD

print(dp[S])


Measured memory_bytes: 9200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int a = sc.nextInt();
		int ans = 0;

		while(h > 0) {
			h -= a;
			ans++;
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 35520
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <vector>

typedef long long ll;
#define rep(i,n) for(ll i = 0; i < n; i++)

using namespace std;

int main(){
	ll n;
	ll a[200000];
	cin >> n;
	rep(i,n) cin >> a[i];

	sort(a,a+n);
	rep(i,n){
		if(a[i] == a[i+1]){
			cout << "NO" << endl;
			return 0;
		}
	}

    cout << "YES" << endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a,a+n);
    int max = -1;
    int maxn;
    for(int i=0;i<n-1;i++){
        if(a[i]>a[n-1]/2){
            if(max<a[n-1] - a[i]){
                max = a[n-1]-a[i];
                maxn = a[i];
            }
        }else {
            if(max<a[i]){
                max = a[i];
                maxn = a[i];
            }
        }
    }
    cout << a[n-1] <<" " << maxn <<"\n";

}

Measured memory_bytes: 640
//2018.9.20 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-15
inline int read(){
    res s=0;
    bool w=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return w?-s:s;
}
inline void _swap(res &x,res &y){
    x^=y^=x^=y;
}
inline int _abs(const res &x){
    return x>0?x:-x;
}
inline int _max(const res &x,const res &y){
    return x>y?x:y;
}
const int N=1e5+10;
namespace MAIN{
    int n,m;
    int a[N],b[N],bx;
    inline void MAIN(){
        n=read(),m=read();
        for(res i=1;i<=m;i++)a[i]=read();
        if(m==1)b[++bx]=1,b[++bx]=n-1;
        else {
            res cnt=0;
            for(res i=1;i<=m;i++)cnt+=a[i]&1;
            if(cnt>2){puts("Impossible");return;}
            for(res i=2;i<m;i++)
                if(a[i]&1){
                    if(a[1]&1)_swap(a[i],a[m]);
                    else _swap(a[1],a[i]);
                }
            b[++bx]=a[m]+1;
            for(res i=m-1;i>1;i--)b[++bx]=a[i];
            b[++bx]=a[1]-1;
        }
        for(res i=1;i<=m;i++)printf("%d ",a[i]);
        puts("");
        if(!b[bx])bx--;
        printf("%d\n",bx);
        for(res i=bx;i>=1;i--)printf("%d ",b[i]);
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
const int MAX_N = 210;
int h, w;
char field[MAX_N][MAX_N];
int table[MAX_N][MAX_N];
int princess;
int soldier = INF;
void bfs(int y, int x)
{
    table[y][x] = 0;
    queue<P> que;
    que.push(P(y, x));
    while(!que.empty())
    {
        P p = que.front(); que.pop();
        for(int i = 0; i < 4; i++)
        {
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            if(ny < 0 || nx < 0 || ny >= h || nx >= w) continue;
            if(table[ny][nx] >= 0 || field[ny][nx] == '#') continue;
            table[ny][nx] = table[p.first][p.second] + 1;
            if(field[ny][nx] == '@') princess = table[ny][nx];
            if(field[ny][nx] == '$') soldier = min(table[ny][nx], soldier);
            que.push(P(ny, nx));
        }
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    int sy, sx;
    memset(table, - 1, sizeof(table));
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++) 
        {
            cin >> field[i][j];
            if(field[i][j] == '%') sy = i, sx = j;
        }
    }
    bfs(sy, sx);
    cout << (princess < soldier ? "Yes" : "No") << endl;
    return 0;
}




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

int main(){
	vector<int> x(5);
  for(int i=0; i<5; i++){
  cin >> x.at(i);
  }
  for(int i=0; i<5; i++){
  	if(x.at(i)==0){
    	cout << i+1<< endl;
    }
  }
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N; cin >> N;
    vector<int> v(N);
    REP(i,N) cin >> v[i];
    sort(RALL(v));

    int ans = 0;
    if (N < 3) OUT(0) 
    else {
        REP(i,N-2) FOR(j,i+1,N-1) FOR(k,j+1,N) {
            if (v[i] == v[j]) continue;
            if (v[j] == v[k]) continue;
            vector<int> v2{v[i],v[j],v[k]};
            sort(RALL(v2));
            if (v2[0] < v2[1] + v2[2]) ans++;
        }
        cout << ans << '\n';
    }

    return 0;
}

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

int main(void) {
    char c;
    int a[8][8];

    while (!cin.eof()) {
        int ci = -1, cj = -1;
        for (int i = 0; i < 8; ++i) {
            for (int j = 0; j < 8; ++j) {
                cin >> c;
                a[i][j] = int(c - '0');
                if (ci == -1 && a[i][j] == 1) {
                    ci = i;
                    cj = j;
                }
            }
        }

        if (ci <= 6 && cj <=6 && a[ci][cj] + a[ci][cj+1] + a[ci+1][cj] + a[ci+1][cj+1] == 4)
            cout << "A" << endl;
        else if (ci <= 4 && cj <=7 && a[ci][cj] + a[ci+1][cj]+a[ci+2][cj]+a[ci+3][cj] == 4)
            cout << "B" << endl;
        else if (ci <= 7 && cj <= 4 && a[ci][cj] + a[ci][cj+1] + a[ci][cj+2] + a[ci][cj+3] == 4)
            cout << "C" << endl;
        else if (ci <= 5 && 1 <= cj && a[ci][cj] + a[ci+1][cj] + a[ci+1][cj-1] + a[ci+2][cj-1] == 4)
            cout << "D" << endl;
        else if (ci <= 6 && cj <= 5 && a[ci][cj] + a[ci][cj+1] + a[ci+1][cj+1] + a[ci+1][cj+2] == 4)
            cout << "E" << endl;
        else if (ci <= 5 && cj <= 6 && a[ci][cj] + a[ci+1][cj] + a[ci+1][cj+1] + a[ci+2][cj+1] == 4)
            cout << "F" << endl;
        else if (ci <= 6 && 1 <= cj && cj <= 6 && a[ci][cj] + a[ci][cj+1] + a[ci+1][cj] + a[ci+1][cj-1] == 4)
            cout << "G" << endl;
    }
    return 0;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    string s;
    cin>>s;
    int ls=s.length();
    for (int i=1;i<ls;i++){
        if (s[i]==s[i-1]){
            cout<<"Bad";
            return 0;
        }
    }
    cout<<"Good";
    return 0;
}


Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Scanner;
 
/*
 * メモ
 * Scanner:nextは空白か改行までの単語
 * String[][] c = new String[h][w];
 * TemplateMain,"template_input.txt"
 * 0.5 == 1.0/2
 * Integer.valueOf(char)はダメ、(String)
 */
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int i = 1;
		while(true){
			int in = sc.nextInt();
			if(in == 0) break;
			System.out.println("Case " + i + ": " + in);
			i++;
		}
	}
}


Measured memory_bytes: 41104
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
typedef long double LD;
#define LP(i, a, b) for (LL i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (LL i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-8
#define INF 1e9
#define LINF 1e18

LL const MaxSize = 100 + 5;
LL const MOD = 1e9 + 7;
LL const BASE = 256;

/*
 sum of indicies of neighbors = N * S = sum of (deg(v) * val(v))

 S >= N and S <= (N) * N - 1 / 2
 when N is even

 When N  = 4, S > 5 or 6

 when total of Vs is even, construst a bipartite graph??
 when toatl of vs is odd, take out 1, add add it

 for 10000
 for guess S
 1 + 100 for 1 to 5050, guess if it is possible to evenly distribute to into n equal partitions, if so, just

 when n  is even, just form n/2 pairs, and then a complete graph
 when n is odd


 */

int N;

int main() {
	ios_base::sync_with_stdio(false);
	//freopen("/Users/georgeli/A_1.in", "r", stdin);

	cin >> N;

	int n = N;
	if (N % 2)
		n--;

	int M = ((n - 2) * n) / 2; //TODO: odd case

	if (N % 2)
		M += n;

	cout << M << endl;

	int tv = 1 + n;

	LPE(v, 1, n)
	{
		LPE(u, v + 1, n)
		{
			if (v + u == tv) {

			} else {
				cout << v << " " << u << endl;
			}
		}
	}

	if (N % 2) {
		LPE(v, 1, n)
		{
			cout << v << " " << N << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main() {
  i64 N;
  cin >> N;
  vector<i64> a(N), b(N);
  i64 ans = 0;
  for(int i = 0;i < N;i++) cin >> a[i] ;
  for(int i = 0;i < N;i++) cin >> b[i];
  for(int i = (1 << 28);i > 0; i >>= 1) {
    for(auto& x: a) x = x & ((i << 1) - 1);
    for(auto& x: b) x = x & ((i << 1) - 1);
    sort(all(b));
    int bit = 0;
    for(auto x: a) { 
      bit += (lower_bound(all(b), 2 * i - x) - lower_bound(all(b), i - x)) + (lower_bound(all(b), 4 * i - x) - lower_bound(all(b), 3 * i - x));
    }
    ans |= i * !!(bit & 1);
    
  }
  cout << ans << endl;
}


Measured memory_bytes: 3328
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    string s;
    cin >> s;
    ll N = s.size();
    ll A_cnt = 0;
    ll BC_cnt = 0;
    ll i = 0;
    ll ans = 0;
    while(i < N){
        if (s[i] == 'A') {
            while(s[i] == 'A') {
                i++;
                A_cnt++;
            }
            while(s[i] == 'B' && s[i+1] == 'C') {
                i+=2;
                BC_cnt++;
            }
            ans += A_cnt * BC_cnt;
            if (s[i] != 'A') {
                A_cnt = 0;
            }
            BC_cnt = 0;
        } else {
            i++;
        }
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 764
s1 = input().split()
strS = s1[0]
s2 = input().split()
strT = s2[0]

charStrSList = list(strS)
charStrTList = list(strT)
diffStrList = []

idxA = 0
for sChar in charStrSList:
    if (sChar != charStrTList[idxA]) :
        diffStrList.append(sChar)
    idxA += 1

print(len(diffStrList)) 

Measured memory_bytes: 14228
N,M,K=map(int,input().split())
costA=list(map(int,input().split()))
costB=list(map(int,input().split()))
costA=[0]+costA
costB=[0]+costB

for i in range(N):
    costA[i+1]+=costA[i]
    
for i in range(M):
    costB[i+1]+=costB[i]

"""print(costA)
print(costB)"""

""

def upper_bound(list1,K):
    low=0
    high=len(list1) #index
    while high-low!=1:
        mid=(high+low)//2
        if list1[mid]>K:
            high=mid
        else:
            low=mid
    return low  #条件を満たす左側の要素数

number=[]
#print(costA)
#print(costB)
for i in range(N+1): #A側の机の本を固定 残りの時間でBを二分探索
    time=K-costA[i]
    if time<0:
        break
    #print(i,upper_bound(costB,time))
    number.append(i+upper_bound(costB,time))

"""print(i)
    print(upper_bound(costB,time))
    print(number)"""
    
print(max(number))



"""
print(cumcost)
#以下二分探索 必要なのはソート済みリストと検索したい値
#upper bound 基準値よりも大きい最初の値を返す
#lower bound 基準値以上の最初の値を返す
#欲しい値はl基準値以下の最大値=upper bound値−１の位置の値
    #冊数は+1なので、求める値はupper_bound
# 検索したい値＝K分を超えない最大の値
low=0
high=len(cumcost)-1
while high-low!=1: #差が１になったら終了
    print(high)
    print(low)
    mid=(high+low)//2 #pythonの//は切り捨て徐算
    if cumcost[mid]>K:  #推測した値が大きすぎた ### 値のダブり注意
        high=mid
    else: # 推測した値小さすぎた#cumcost<=K
        low=mid 
#条件を満たす値の個数 (upper_bound)
    #条件を満たすのが左・・・high
    #条件を満たすのが右・・・len(cumcost)--1-low
upper_bound=high #最終的な値はupper_bound
print(upper_bound)
"""
"""境界線が端っこにあると上手に探索できない
→例外処理で乗り切るか　探索のやり方自体を変更するか　どちらが良いか？"""

Measured memory_bytes: 40156
#include <iostream>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int main() {
    int n, x, y;
    cin >> n >> x >> y;

    vector<vector<int> > G(n);
    for (int i = 0; i < n - 1; ++i) {
        G[i].push_back(i + 1);
        G[i + 1].push_back(i);
    }
    G[x - 1].push_back(y - 1);
    G[y - 1].push_back(x - 1);

    map<int, int> M;
    for (int i = 0; i < n; ++i) {
        vector<int> dist(n, -1);
        queue<int> que;
        dist[i] = 0;
        que.push(i);

        while (! que.empty()) {
            int v = que.front();
            que.pop();

            for (int nv : G[v]) {
                if (dist[nv] != -1) continue;

                dist[nv] = dist[v] + 1;
                que.push(nv);
            }
        }

        for (int j = i + 1; j < n; ++j) ++M[dist[j]];
    }

    for (int i = 0; i < n - 1; ++i) cout << M[i + 1] << endl;
    
    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#ifndef LOCAL
#define endl '\n'
#endif

const int mod = 998244353;

int pwr(int a,int b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}


const int N = 3e5 + 5;
ll fact[N], ifact[N];

ll go(int n, int a) {
	ll ans = (fact[n] * 1LL * ifact[a]) % mod;
	ans = (ans * 1LL * ifact[n - a]) % mod;
	return ans;
}

signed main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	fact[0] = 1;
	for(int i = 1; i < N; i++) {
		fact[i] = (i * 1LL * fact[i - 1]) % mod;
	}
	ifact[N - 1] = pwr(fact[N - 1], mod - 2);
	for(int i = N - 2; i >= 0; i--) {
		ifact[i] = (ifact[i + 1] * 1LL * (i + 1)) % mod;
	}
	ll n, a, b, k;
	cin >> n >> a >> b >> k;
	ll ans = 0;
	for(int i = 0; i <= n; i++) {
		ll j = (k - a * i);
		if(j >= 0 && j % b == 0 && j <= b * n) {
			j /= b;
			ans += (go(n, i) * 1LL * go(n, j)) % mod;
			ans %= mod;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <string.h>
#define MAX_LEN 1001

int LCS_length(char *, char *);

int C[MAX_LEN][MAX_LEN];

int main()
{
	int n;
	int i;
	char S1[MAX_LEN], S2[MAX_LEN];
	
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	{
		scanf("%s", S1);
		scanf("%s", S2);
		
		printf("%d\n", LCS_length(S1, S2));
	}
	return 0;
}

int LCS_length(char *S1, char *S2)
{
	int i, j;
	int S1_len, S2_len;

	S1_len = strlen(S1);
	S2_len = strlen(S2);

	for(i = 0; i < S1_len; i++)
	{
		C[i][0] = 0;
	}
	for(j = 0; j < S2_len; j++)
	{
		C[0][j] = 0;
	}

	for(i = 1; i <= S1_len; i++)
	{
		for(j = 1; j <= S2_len; j++)
		{
			if(S1[i - 1] == S2[j - 1])
			C[i][j] = C[i - 1][j - 1] + 1;
			
			else if(C[i - 1][j] >= C[i][j - 1])
			C[i][j] = C[i - 1][j];
			
			else
			C[i][j] = C[i][j - 1];
		}
	}
	return C[S1_len][S2_len];
}

Measured memory_bytes: 4520
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>

int main(void)
{
	int N;
	scanf("%d\n",&N);
	int a[N];
	int min_push[N];
	int n;
	for (n=0;n<N;n++){
		scanf("%d\n",&a[n]);
		a[n]--;
		min_push[n] = -1;
	}
	int i=0;
	int curr = 1 - 1;
	while (1){
		//printf("%d\n",curr);
		if (min_push[curr]>=0)break; // 到達済みなら抜ける
		min_push[curr]=i;
		if (curr==2-1)break; // ボタン2に到達したら抜ける
		curr = a[curr];
		i++;
	}
	printf("%d\n",min_push[2-1]);
	return 0;
}


Measured memory_bytes: 896
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

h = [int(i) for i in input().split()]

h.sort()

if n - k <= 0:
    print("0")
else:
    rh = h[:n - k]
    ans = 0
    for i in rh:
        ans += i
    
    print(ans)

Measured memory_bytes: 26024
package main

import (
        "fmt"
        "sort"
)

func solution(a, b, c int) int {
        if a%2 == 0 || b%2 == 0 || c%2 == 0 {
                return 0
        }
        memo := []int{a, b, c}
        sort.Ints(memo)
        return memo[0] * memo[1]
}

func main() {
        var a, b, c int
        fmt.Scan(&a, &b, &c)
        fmt.Println(solution(a, b, c))
}

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

int main()
{
    int n, m;
    map<int, vector<int>> mp;
    cin >> n >> m;
    int h[n+1];
    for(int i=1; i<=n; i++){
		cin >> h[i];
    }
    int x[m+1], y[m+1];
    for(int i=0; i<m; i++){
		cin >> x[i] >> y[i];
		mp[x[i]].push_back(y[i]);
		mp[y[i]].push_back(x[i]);
    }

	bool ok = true;
    int ans = 0;

    for(auto a : mp){
		a.second.erase(unique(a.second.begin(), a.second.end()), a.second.end());
    	int sz = a.second.size();
		for(int i=0; i<sz; i++){
			if(h[a.first] <= h[a.second[i]]) ok = false;
		}
		if(ok) ans++;
		ok = true;
		//cout << a.first << ' ' << ans << endl;
    }
    ans += n - mp.size();

    cout << ans;

    return 0;
}


Measured memory_bytes: 14280
n,d=map(int,input().split())
L=[list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        a=0
        for k in range(d):
            a+=(L[i][k]-L[j][k])**2
        if int(a**0.5)==a**0.5:
            ans+=1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	bool ans=true;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		if(x%2!=0){
			ans=false;
		}
	}
	cout << (ans?"second":"first");
	// your code goes here
	return 0;
}

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

using namespace std;

#define rep(i,n) for(int i = 0;i < n;i++)
#define all(n)	n.begin(),n.end()
#define each(i,n) for(auto &i : n)

const int INF = 1e9;

signed main() {

	int w, h;
	while (cin >> w >> h && w) {
		int d[20][20][20];
		rep(y, h)rep(x, w)rep(z, 20)d[y][x][z] = 0;
		int wd[20], hd[20];
		rep(x, w) {
			cin >> wd[x];
		}
		rep(y, h) {
			cin >> hd[y];
		}
		int ans = 0;
		rep(x, w)rep(y, h) {
			if (wd[x] == hd[y]) {
				ans += wd[x];
				wd[x] = 0;
				hd[y] = 0;
			}
		}
		rep(y, h) {
			ans += hd[y];
		}
		rep(x, w) {
			ans += wd[x];
		}
		cout << ans << endl;
	}

	return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    int n;
    //int pos;
    cin >> n;
    vector<string> s(n);
    bool flag;
    int ans = 0;
    int Akey = 0;
    int Bkey = 0;
    int minus = 0;
    rep(i,n)
    {
        cin >> s[i];
    }
    rep(i,n)
    {
        /*
        flag = false;
        rep(j,s[i].size())
        {
            if(flag)
            {
                if(s[i][j] == 'B')
                {
                    ans++;
                    //cout << "i is " << i << " and j is " << j << endl;
                }
                flag = false;
            }
            else if(s[i][j] == 'A') flag = true;
            else flag = false;
        }
        */
        string::size_type pos = s[i].find("AB");
        while (pos != std::string::npos)
        {
            pos = s[i].find("AB", pos + 2 );
            ans++;
        }
        if(s[i][s[i].size()-1] == 'A' && s[i][0] != 'B') Akey++;
        if(s[i][s[i].size()-1] != 'A' &&s[i][0] == 'B') Bkey++;
        if(s[i][s[i].size()-1] == 'A' && s[i][0] == 'B') minus++;
    }
    //cout << "ans is" << ans << " and Akey is " << Akey << " and Bkey is " << Bkey << endl;
    //if(min(Akey,Bkey) <= minus) cout << ans + min(Akey,Bkey) - minus + 1 << endl;
    if(Akey + Bkey == 0 && minus != 0) cout << ans + minus - 1 << endl;
    else cout << ans + minus +  min(Akey,Bkey) << endl;
}


Measured memory_bytes: 768
#include <iostream>  
#include <cstring>  
#include <queue>  
#include <set>  
#include <vector>  
#include <cmath>  
#include <stack>  
#include <string>  
#include <queue>  
#include <algorithm>  
#include <cstdio>  
#include <map>  
using namespace std;  
#define INF 0x3f3f3f3f  
  
int main() {  
    long long n, k;  
    scanf("%lld%lld", &n, &k);  
    if (k == 0) {  
        printf("%lld\n", n * n);  
    }  
    else {  
        long long sum = (n - k) * (n - k + 1) >> 1;  
        for (int b = k + 1; b <= n; ++b) {  
            for (int p = k; p <= b - 1; ++p) {//枚举余数  
                int t = (n - p) / b;  
                if (t == 0) {  
                    break;  
                }  
                int li = n - t * b;  
                li = min(li, b - 1);  
                sum = sum + t * (li - p + 1);  
                p = li;  
            }  
        }  
        printf("%lld\n", sum);  
          
    }  
    //system("pause");  
    return 0;  
}  

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
	int i=0,o,t;
	char line[1001],apple[6]="apple",peach[6]="peach";
	while((t=getchar()) != EOF)
		line[i++]=t;
	line[i]=0;i=0;
	while(line[i]){
		o=0;
		if(line[i] == 'a'){
			if(memcmp(line+i,apple,5) == 0){
				while(peach[o]){
					line[i]=peach[o];
					i++;o++;
				}
			}
		}
		if(line[i] == 'p'){
			if(memcmp(line+i,peach,5) == 0){
				while(apple[o]){
					line[i]=apple[o];
					i++;o++;
				}
			}
		}
		i++;
	}
	printf("%s",line);
	return 0;
}

Measured memory_bytes: 524
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
    long int n,sf=0,iolv1=0;
    while(cin>>iolv1,iolv1)
    {
        char a;
        long int moji=0,find=0,find2=0;
        bool Iflg=0,Oflg=0,Iflg1=1;
        cin>>moji;
        //fflush(stdin);
        scanf("%c",&a);
        while(moji--)
        {
            scanf("%c",&a);

            //fflush(stdin);
            if(a=='I'&&Iflg1==1)
            {
                Oflg=1;
                Iflg1=0;
                //cout<<"IOK"<<endl;
                goto skip;
            }
            if(a=='O'&&Iflg1==1)
            {
                find=0;
                goto skip;
            }
            if(a=='O'&&Oflg==1)
            {
                Iflg=1;
                Oflg=0;
                //cout<<"ok"<<endl;
                goto skip;
            }
            if(a=='O')
            {
                Iflg=0;
                Oflg=0;
                Iflg1=1;
                if(find>=iolv1)find2+=find-iolv1+1;
                find=0;
                goto skip;
            }
            if(a=='I'&&Iflg==1)
            {
                Oflg=1;
                Iflg=0;
                find++;
                //cout<<"ok"<<endl;
                goto skip;
            }
            if(a=='I')
            {
                Iflg=0;
                Oflg=1;
                Iflg1=0;
                if(find>=iolv1)find2+=find-iolv1+1;
                find=0;
                goto skip;
            }
            skip:;
            //fflush(stdin);
            //cout<<find<<endl;
        }
        if(find>=iolv1)find2+=find-iolv1+1;
        cout<<find2<<endl;
        //cout<<"ok2"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
  int a, b;
  scanf("%x %x", &a, &b);
  if(a<b) printf("<");
  else if(a==b) printf("=");
  else printf(">");
  return 0;
}


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

int main(){
    
    int n;
  cin >> n;
  map<int,int> m;
  for(int i = 1;i<=9;i++){
    for(int j=1;j<=9;j++){
      m[i*j]++;
    }
  }
  if(m[n]==0){
    cout<<"No"<<endl;
  }
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pl pair<ll,ll>
#define vl(p) vector<p>
#define W while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007


int main() {
	FASTIO;
    ll t=1, i ,j, k, l;
    // cin>>t;
    W(t--) {
        ll n, k=2;
        cin>>n;
        ll a[n], res[n], temp[k];
        FOR(i,n) cin>>a[i];
        res[0]=0;
        Fore(i,1,k) res[i]=abs(a[i]-a[0]);
        For(i,k+1,n) {
            FOR(j,k) temp[j]=abs(a[i]-a[i-j-1])+res[i-j-1];
            res[i]=*min_element(temp,temp+k);
        }
        pr(res[n-1]);
        nl;
    }
	return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;

int fh, oh, ft, t;

void change(int price){
	fh = price / 50;
	price -= fh * 50;
	oh = price / 10;
	price -= oh * 10;
	ft = price / 5;
	price -= ft * 5;
	t = price;
}

int main(void){
	int p, a, b, c, d, count = 0, pay;
	while(scanf("%d", &p),p){
		if(count)
			printf("\n");
		count++;
		p /= 10;
		scanf("%d %d %d %d", &a, &b, &c, &d);
		pay = a + 5 * b + 10 * c + 50 * d - p;
		change(pay);
		while(t && a){
			a--;
			pay--;
			change(pay);
		}
		while(ft && b){
			b--;
			pay -= 5;
			change(pay);
		}
		while(oh && c){
			c--;
			pay -= 10;
			change(pay);
		}
		while(fh && d){
			d--;
			pay -= 50;
			change(pay);
		}
		if(a)
			printf("10 %d\n", a);
		if(b)
			printf("50 %d\n", b);
		if(c)
			printf("100 %d\n", c);
		if(d)
			printf("500 %d\n", d);
	}
	return 0;
}

Measured memory_bytes: 2556
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, N, x[101], y[101];
	long long h[101];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d %d %lld", &(x[i]), &(y[i]), &(h[i]));
	
	int j, k, X, Y;
	long long H = 1, flag[101][101];
	for (i = 0; i <= 100; i++) {
		for (j = 0; j <= 100; j++) flag[i][j] = -1;
	}
	for (k = 1; k <= N; k++) flag[x[k]][y[k]] = h[k];
	for (k = 1; k <= N; k++) if (h[k] > 0) break;
	if (k > N) {
		for (X = 0; X <= 100; X++) {
			for (Y = 0; Y <= 100; Y++) {
				if (X > 0 && flag[X-1][Y] == 0) continue;
				else if (X < 100 && flag[X+1][Y] == 0) continue;
				else if (Y > 0 && flag[X][Y-1] == 0) continue;
				else if (Y < 100 && flag[X][Y+1] == 0) continue;
				else break;
			}
			if (Y <= 100) break;
		}
	} else {
		for (X = 0; X <= 100; X++) {
			for (Y = 0; Y <= 100; Y++) {
				for (i = 1; i <= N; i++) if (h[i] > 0) break;
				H = h[i] + abs(X - x[i]) + abs(Y - y[i]);
				for (i = 1; i <= N; i++) {
					if (h[i] > 0 && h[i] != H - abs(X - x[i]) - abs(Y - y[i])) break;
					else if (h[i] == 0 && H > abs(X - x[i]) + abs(Y - y[i])) break;
				}
				if (i > N) break;
			}
			if (Y <= 100) break;
		}
	}
	
	printf("%d %d %lld\n", X, Y, H);
	fflush(stdout);
	return 0;
}

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

using namespace std;

typedef long long ll;

int a[3];
int b[3];

bool check(int x, int y, int z)
{
	bool c[5];
	int s;
	for (int i = 1; i < 5; ++i)
		c[i] = false;

	c[a[x]] = true;
	c[b[x]] = true;
	if ((b[x]!=a[y])&&(b[x]!=b[y])) {
		// cerr << b[x] << " " << a[y] << " " << b[y] << endl;

		if ((a[x]!=a[y])&&(a[x]!=b[y])) {
			return false;
		} else {
			if (a[x]==a[y]) {
				s = b[y];
				c[b[y]] = true;
			} else {
				s = a[y];
				c[a[y]] = true;
			}
		}
	} else {
		// cerr << b[x] << " " << a[y] << " " << b[y] << endl;
		if (b[x]==a[y]) {
			s = b[y];
			c[b[y]] = true;
		} else {
			s = a[y];
			c[a[y]] = true;
		}
	}
	if ((s!=a[z])&&(s!=b[z])) {
		return false;
	} else {
		if (s==a[z]) {
			s = b[z];
			c[b[z]] = true;
		} else {
			s = a[z];
			c[a[z]] = true;
		}
	}
	return c[4] && c[1] && c[2] && c[3];
}

int main(int, char**)
{
	cin >> a[0] >> b[0];
	cin >> a[1] >> b[1];
	cin >> a[2] >> b[2];

	if (check(0, 1, 2)) {
		cout << "YES" << endl;
		return 0;
	}
	if (check(0, 2, 1)) {
		cout << "YES" << endl;
		return 0;
	}
	if (check(1, 2, 0)) {
		cout << "YES" << endl;
		return 0;
	}
	if (check(1, 0, 2)) {
		cout << "YES" << endl;
		return 0;
	}
	if (check(2, 1, 0)) {
		cout << "YES" << endl;
		return 0;
	}
	if (check(2, 0, 1)) {
		cout << "YES" << endl;
		return 0;
	}

	cout << "NO" << endl;
	return 0;
}


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

    #pragma GCC optimize("O3")
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    /*#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #pragma GCC target ("avx2")*/

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

ll MAX = 1e15;
double PI = 3.141592653589793238463;
//double PI = acos(-1);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll n,m;
vector<vector<ll>> g;
set<ll> st;
vector<ll> ans;

void solve(){
    cin >> n >> m;
    g.resize(n);
    ans.resize(n, -1);
    for(ll i=0; i<m; i++){
        ll f,to;
        cin >> f >> to;
        f--; to--;
        g[f].push_back(to);
        g[to].push_back(f);
    }
    for(ll i=1; i<n; i++){
        st.insert(i);
    }
    queue<ll> q;
    q.push(0);
    while(!q.empty()){
        ll cur = q.front();
        q.pop();
        for(ll i=0; i<g[cur].size(); i++){
            ll to = g[cur][i];
            if(ans[to]==-1){
                ans[to]=cur;
                q.push(to);
            }
        }
    }

    for(ll i=1; i<n; i++){
        if(ans[i]==-1){
            cout << "No";
            return;
        }
    }
    cout << "Yes\n";
    for(ll i=1; i<n; i++){
        cout << ans[i]+1 << "\n";
    }

}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif


    ll t=1;
    //cin >> t;
    while(t--){
        solve();
    }


    return 0;
}


Measured memory_bytes: 17668
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>

using ll = long long;
using namespace std;

ll usu[1000006];
char s[100003];
ll sol, N, act;

int main(void){
    int N;
    cin  >> N;
    
    for (int n=0; n<N; n++) {
        cin >> s;
        sort(s, s+10);
        
        for (int strPos=0; strPos<10; strPos++) {
            usu[n] = usu[n] * 26 + (s[strPos] - 'a');
        }
    }
    
    sort(usu, usu+N);
    
    act = 1;
    sol = 0;
    for (int n=1; n<N; n++) {
        if (usu[n] == usu[n-1]) {
            act++;
        }
        else {
            sol += (act - 1) * act / 2;
            act = 1;
        }
    }
    
    sol += (act - 1) * act / 2;
    cout << sol << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int need(int coins[], int m, int V)
{
    int table[V+1];
    table[0] = 0;
    for (int i=1; i<=V; i++)
        table[i] = INT_MAX;
    for (int i=1; i<=V; i++)
    {
        for (int j=0; j<m; j++)
            if (coins[j] <= i)
            {
                int sub_res = table[i-coins[j]];
                if (sub_res != INT_MAX && sub_res + 1 < table[i])
                    table[i] = sub_res + 1;
            }
    }
    return table[V];
}
int main()
{
    int coins[16] = {1,6,9,36, 81, 216, 729, 1296, 6561,7776, 46656, 59049, 279936, 531441, 1679616, 4782969};
    int n;
    cin>>n;
    cout <<need(coins, 16, n)<<endl;

}


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

const int mod = 924844033, N = 2010;

ll pw(ll a, ll b) {
    ll r = 1;
    for( ; b ; b >>= 1, a = a * a % mod) {
        if(b & 1) {
            r = r * a % mod;
        }
    }
    return r;
}

ll getinv(ll n) {
    return pw(n, mod - 2);
}

void upd(ll &a, ll b) {
    a = (a + b) % mod;
}

int n, k, a[N * 2], m;
ll f[N * 2][N * 2][2];
ll fac[N * 2];

void init(int n) {
    fac[0] = 1;
    for(int i = 1 ; i <= n ; ++ i) {
        fac[i] = fac[i - 1] * i % mod;
    }
}

int main() {
    init(N * 2 - 1);
    scanf("%d%d", &n, &k);
    for(int i = 1 ; i <= k ; ++ i) {
        for(int p = 1 ; p <= 2 ; ++ p) {
            for(int j = i ; j <= n ; j += k) {
                a[++ m] = i != j;
            }
        }
    }
    f[0][0][0] = 1;
    for(int i = 1 ; i <= 2 * n ; ++ i) {
        for(int j = 0 ; j <= n ; ++ j) {
            f[i][j][0] = (f[i - 1][j][0] + f[i - 1][j][1]) % mod;
            if(a[i] && j >= 1) {
                f[i][j][1] = f[i - 1][j - 1][0];
            }
        }
    }

    ll ans = 0;
    for(int i = 0 ; i <= n ; ++ i) {
        upd(ans, (i & 1 ? -1 : 1) * (f[2 * n][i][0] + f[2 * n][i][1]) % mod * fac[n - i] % mod);
    }
    printf("%lld\n", (ans % mod + mod) % mod);
}


Measured memory_bytes: 251264
N = int(input())
A = list(map(int, input().split()))
ans = 1
colors = [0] * 3
mod = 10**9 + 7

for a in A:
    ans = (ans * colors.count(a)) % mod
    if ans != 0:
        i = colors.index(a)
        colors[i] += 1

print(ans)


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

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

const int MAX = 1e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;

string s, t;

int main(){
    cin >> s >> t;

    map<char, vector<int>> m;
    rep(i, s.size()){
        char c = s[i];
        m[c].push_back(i);
    }

    ll ans = 0;
    int x = -1;
    rep(i, t.size()){
        char c = t[i];

        vector<int>& index = m[c];
        if(index.size() == 0){
            cout << -1 << endl;
            return 0;
        }

        auto itr = upper_bound(index.begin(), index.end(), x);
        if(itr == index.end()){
            ans += s.size();
            x = m[c][0];
        } else {
            x = *itr;
        }
    }

    ans += x + 1;
    cout << ans << endl;
}

Measured memory_bytes: 1216
import numpy as np

D = int(input())
Cs = np.array(list(map(int, input().split())))
Ss = []
for d in range(D):
    s = list(map(int, input().split()))
    Ss.append(s)

Ss = np.array(Ss)


def scoring(solution):
    sat = 0
    last = [0] * 26
    for d in range(D):
        assert 1 <= solution[d] <= 26
        j = solution[d] - 1
        last[j] = d + 1
        for i in range(26):
            sat -= (d + 1 - last[i]) * Cs[i]
        sat += Ss[d][j]
    return sat


def update_days_till_next(days_till_next, solution, d, erase=False):
    contest = solution[d]
    delta = days_till_next[d + 1, contest] + 1 if d < D - 1 else 0
    days_till_next[d, contest] = delta
    for _d in range(d - 1, -1, -1):
        if solution[_d] == contest or _d == 0:
            days_till_next[_d:d, contest] = (d - _d) - np.arange(d - _d) + (delta if erase else 0)
            break


def get_solution(seed):
    solution = np.array(seed)
    days_till_next = np.ones_like(Ss) * (D - 1) - np.arange(D).reshape((D, 1))
    for d in range(D - 1, -1, -1):
        update_days_till_next(days_till_next, solution, d)

    for _ in range(80):
        n_contests = len(Ss[0])
        days_since_last = np.zeros(n_contests)
        for d, i in enumerate(solution):
            days_since_last += 1
            new_scores = days_till_next[d] * days_since_last * Cs + Ss[d]
            new_i = new_scores.argmax()
            days_since_last[new_i] = 0
            if new_i != i:
                update_days_till_next(days_till_next, solution, d, erase=True)
                solution[d] = new_i
                update_days_till_next(days_till_next, solution, d)

    return solution


def get_best_solution():
    seeds = [np.argmax(Ss + Cs.reshape(1, -1) * e, axis=1) for e in [10, 20, 40, 80]] + [np.argmax(Ss, axis=1)]
    best_sol = None
    best_score = -np.inf
    for seed in seeds:
        sol = get_solution(seed) + 1
        score = scoring(sol)
        if score > best_score:
            best_sol = sol

    return best_sol


solution = get_best_solution()


for s in solution:
    print(s)

# with open("test.out", "w") as f:
#     f.writelines("\n".join(list(map(str, solution))))


Measured memory_bytes: 27968
N = int(input())
X = list(map(int,input().split()))
X_sorted = sorted(X)
X_median = (N)/2
median1 = X_sorted[int(X_median)]
median2 = X_sorted[int(X_median-1)]
for i in range(N):
    if X[i] >=median1:
        print(median2)
    else:
        print(median1) 

Measured memory_bytes: 25556
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#include <map>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;
const ll INF = 100100100100100100;

ll H,W;
ll N;
ll a[100100];
ll f[110][110];
int main(){
  cin >> H >> W;
  cin >> N;
  ll h=0,w=0;
  rep(i,N){
    cin >> a[i];
    rep(j,a[i]){
      f[h][w] = i+1;
      cerr << h << " " << w << endl;
      if(w%2==0){
        if(h<H-1){
          h++;
        }
        else w++;
      }
      else if(w%2==1){
        if(h>0) h--;
        else w++;
      }
    }
  }
  rep(h,H){
    rep(w,W){
      if(w==0) cout << f[h][w];
      else cout << " " << f[h][w];
    }
    cout << endl;
  }
}


Measured memory_bytes: 512