akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

class Program {
  static void Main() {
    var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int x1 = arr[0];
    int y1 = arr[1];
    int x2 = arr[2];
    int y2 = arr[3];
    int dx = x2 - x1;
    int dy = y2 - y1;
    int x3 = x2 - dy;
    int y3 = y2 + dx;
    int x4 = x1 - dy;
    int y4 = y1 + dx;
    Console.WriteLine($"{x3} {y3} {x4} {y4}");
  }
}


Measured memory_bytes: 13396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		long a = fs.nextInt();
		long b = fs.nextInt();
		int k = fs.nextInt();
		
		for(int i = 0; i < k; i++) {
			
			if(i % 2 == 0) {
				if(a % 2 == 1) {
					a--;
				}
				long halfA = a / 2;
				a = halfA;
				b += halfA;
			}else {

				if(b % 2 == 1) {
					b--;
				}
				
				long halfB = b / 2;
				b = b / 2;
				a += halfB;
			}
		}
		
		System.out.println(a+" "+b);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
int INF=1e9;
int n;
int t[301][301];
int u[301][301];

int sum(int ai,int aj,int bi,int bj){
  ai--,aj--;
  return u[bi][bj]-u[ai][bj]-u[bi][aj]+u[ai][aj];
}

int calc(int ah,int bh){
  int res=-INF;
  int maxm=0;
  for(int i=1;i<=n;i++){
    res=max(res,maxm+sum(ah,i,bh,i));
    int d=t[ah][i]+t[bh][i];
    if(ah==bh)d/=2;
    maxm=max(maxm+d,sum(ah,i,bh,i));
  }
  return res;
}

int main(){
  cin>>n;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      cin>>t[i][j];
      u[i][j]=t[i][j]+u[i-1][j]+u[i][j-1]-u[i-1][j-1];
    }
  }
  int ans=-INF;
  for(int i=1;i<=n;i++){
    for(int j=i;j<=n;j++){
      ans=max(ans,calc(i,j));
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

struct Date {
  int y, m, d;
  bool operator < (const Date &date) const {
    if(y != date.y) return y < date.y;
    if(m != date.m) return m < date.m;
    return d < date.d;
  }
};

const int N = 5;
string name[N] = {"pre-meiji", "meiji", "taisho", "showa", "heisei"};
Date begin[N] = {{0,0,0}, {1868,9,8}, {1912,7,30}, {1926,12,25}, {1989,1,8}};

int main() {
  int y, m, d;
  while(cin >> y >> m >> d) {
    Date now = {y,m,d};
    for(int i = 0; i < N; ++i) {
      if(i+1 == N || now < begin[i+1]) {
        if(i == 0) cout << name[i] << endl;
        else {
          cout << name[i] << " " << now.y - begin[i].y + 1
               << " " << now.m << " " << now.d << endl;
        }
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

const int MAX = 200000;
const int INF = 1000000001;
const double PI = 3.14159265358979323846264;
const double QUA = PI * 20.0 / 4.0;

struct Point{
	bool operator < (const Point& p)const {
		return y < p.y;
	}
	long long x,y;
};

int main() {
	int N;
	Point S, G;
	vector<Point> point;
	vector<long long> table;

	cin >> S.x >> S.y >> G.x >> G.y;
	cin >> N;
	for (int i = 0; i < N; i++) {
		Point p;
		cin >> p.x >> p.y;
		point.push_back(p);
	}

	if (G < S)swap(S, G);
	sort(point.begin(), point.end());

	vector<Point>::iterator begin = lower_bound(point.begin(), point.end(), S);
	vector<Point>::iterator end = upper_bound(point.begin(), point.end(), G);

	while (begin != end) {
		if (G.x < S.x) {
			if (S.x < begin->x || begin->x < G.x) {
				begin++; 
				continue;
			}
		}
		else {
			if (S.x > begin->x || begin->x > G.x) {
				begin++;
				continue;
			}
		}
		long long x = abs(begin->x - S.x);
		vector<long long>::iterator it = lower_bound(table.begin(), table.end(), x);
		if (it == table.end()) {
			table.push_back(x);
		}
		else {
			*it = x;
		}
		begin++;
	}

	double len = (abs(G.x - S.x) + abs(G.y - S.y)) * 100;

		if (table.size() <= abs(G.y - S.y) && table.size() <= abs(G.x - S.x)) {
			len -= table.size() * (20.0 - QUA);
		}
		else {
			len -= (table.size() - 1) * (20.0 - QUA);
			len = len - 20.0 + QUA * 2;
		}
		
	cout << fixed;
	cout << setprecision(15) << len << endl;

	return 0;
}

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

const int inf = 1e9;
const ll linf = 1e18;

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

    int N, M, R; cin >> N >> M >> R;
    vector<int> r(R);
    for (int i = 0; i < R; i++) {
        cin >> r[i]; r[i]--;
    }

    sort(r.begin(), r.end()); // next_permutation用
    
    vector<vector<int>> g(N, vector<int> (N, inf));
    for (int i = 0; i < N; i++) g[i][i] = 0;
    for (int i = 0; i < M; i++) {
        int a, b, c; cin >> a >> b >> c; a--, b--;
        g[a][b] = g[b][a] = c;
    }

    // Warshall-floyd
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }

    int ans = inf;
    do {
        int tmp = 0;
        for (int i = 0; i < R - 1; i++) {
            int d = g[r[i]][r[i + 1]];
            if (d >= inf) {
                tmp = inf;
                break;
            }
            tmp += d;
        }
        ans = min(ans, tmp);
    } while (next_permutation(r.begin(), r.end()));

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

Measured memory_bytes: 384
import numpy as np
inpl = lambda: list(map(int,input().split()))
N = int(input())
b = np.array(inpl(),dtype=np.int)

d = np.array(range(1,N+1),dtype=np.int) - b
if len(np.where(d < 0)[0]) > 0:
    print(-1)
    exit()

ans = np.empty(N,dtype=np.int)
for i in range(N):
    z = np.where(d == 0)[0]
    if len(z) == 0:
        print(-1)
        exit()
    else:
        k = z[-1]
        d[k] = -1
        for n in range(k+1,N):
            if d[n] > 0:
                d[n] -= 1
        ans[N-1-i] = b[k]

for i in range(N):
    print(ans[i])

Measured memory_bytes: 18708
n,m = map(int,input().split())
id = sorted([list(map(int,input().split())) for _ in range(m)])
maxl = id[0][0]
minr = id[0][1]
for i in range(1,len(id)):
    maxl = max([maxl, id[i][0]])
    minr = min([minr, id[i][1]])

print(max([minr-maxl+1,0]))

Measured memory_bytes: 28660
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <math.h>
#define DEBUG

int main()
{
    char inS[4] = {};
    char inT[4] = {};
    //read
    scanf("%s", inS);
    scanf("%s", inT);

    //solve
    int ans = 0;
    for(int i = 0; i < 3; i++)
    {
        if(inT[i] == inS[i])
        {
            ans++;
        }
    }

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

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }return 0; }
#define all(a)  (a).begin(),(a).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define vll vector<ll>
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
const ll INF =1LL << 62;

int main(){
  int N;
  string S;
  cin >> N;
  cin >> S;
  int cntr=0;
  int cntb=0;
  rep(i,S.size()){
    if(S[i] == 'R')
      cntr ++;
    else
      cntb ++;
  }
  if(cntr > cntb)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
//Running median
//keeping max heap for first half and min heap for second half
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl "\n";
ll  P=1000000007;
ll M=P;
ll power(ll a, ll b) {
    if(b == 0) return 1;
    ll x = power(a, b / 2);
    x = (x * x)%M;
    if(b%2) x = (x*a)%M;
    return x;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i,j,k,l,m,n,o,p,q,r,s,t;
    cin>>n>>k;
    j=0;
    for(i=0;i<k;i++)
    {
        cin>>l;
        j+=l;
    }
    s=(n-j);
    l=-1;
    s=max(s,l);
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3652
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}

bool Check(ll num, ll pos) {
        return (bool)(num & (1LL << pos));
}
 long long int sumXOR(ll arr[], int n)
{
     long long int sum = 0;
    for (int i = 0; i <=60; i++)
    {
        //  Count of zeros and ones
        long long zc = 0, oc = 0;

        // Individual sum at each bit position
        long long int idsum = 0;
        for (int j = 0; j < n; j++)
        {
           /* if (arr[j] % 2 == 0)
                zc++;
            else
                oc++;
            arr[j] /= 2;*/

            if(Check(arr[j],i))zc++;

            else oc++;
        }

        // calculating individual bit sum
        idsum = (oc * ((zc * ((1ll << i)%Mod))%Mod))%Mod;

        // final sum
        sum =(sum+ idsum)%Mod;
    }
    return sum%Mod;
}
int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;



        cin>>n;


        long long ara[n+2];

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

         cout<<sumXOR(ara,n)<<endl;


}



Measured memory_bytes: 5920
while True:
    m = input()
    if m == 0:
        break
    cards = [map(int, raw_input().split()) for i in range(m)]
    dp = [[0] * 1001 for i in range(m+1)]
    dp[0][0] = 1
    for i, card in enumerate(cards, start=1):
        a, b = card
        dp[i] = dp[i-1][:]
        for num in range(a, a*b+1, a):
            for k in range(num, 1001):
                if dp[i-1][k-num] != 0:
                    dp[i][k] += dp[i-1][k-num]
    g = input()
    for i in range(g):
        n = input()
        print dp[m][n]

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

int main(){
	int N, D;
	cin >> N >> D;
	vector<vector<int>> X(N, vector<int>(D));
	for(int i = 0; i < N; i++){
		for(int j = 0; j < D; j++){
			cin >> X.at(i).at(j);
		}
	}
	int cnt = 0;
	
	for(int i = 0; i < N; i++){
		for(int j = i + 1; j < N; j++){
			double dis = 0;
			for(int k = 0; k < D; k++){
				dis += ((X.at(j).at(k) - X.at(i).at(k)) * (X.at(j).at(k) - X.at(i).at(k)));
			}
			dis = sqrt(dis);
			double check = floor(dis);
			if(dis == check) cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000009
const long long INF = 1LL<<60;

int main() {
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> v;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        v.push_back({b,a});
    }
    sort(all(v));
    int ans=0;
    int prev=0;
    rep(i,m){
        if(v[i].second<prev) continue;
        ans++;
        prev=v[i].first;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 1400
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

const int N=100005;

void solve()
{
    int n,x,t;
    cin>>n>>x>>t;
    int ans=t*((n+x-1)/x);
    cout<<ans<<endl;
    
}
int32_t main()
{
    IOS;
    //FILE *fin = freopen("in","r",stdin);
    //FILE *fout = freopen("out","w",stdout);
    int t;
    t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}





Measured memory_bytes: 3664
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int a,b;
   cin >> a >> b;

   int ans = (a-1)*(b-1);

   cout << ans << endl;



   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  string n;cin>>n;
  cout<<outputYesNo(n.find('7')!=string::npos)<<endl;
  return 0;
}


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

int main(){
#define int ll
  int n; cin >> n;
  string s; cin >> s;
  int tmp = 0;
  rep(i,n-1) if(s[i+1] == 'E') tmp++;
  int ans = tmp;
  rep(i,n-1){
    if(s[i] == 'W') tmp++;
    if(s[i+1] == 'E') tmp--;
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x); //実装を楽にするためxを絶対値にしちゃう
    ll ans;

    // 往復に辿り着く前に終わる
    if (x / d > k) {
        ans = x - d * k;

    // 往復する場合
    } else {
        ll e = x / d; //往復開始するまでの回数
        k -= e; //操作回数を減らす
        x -= e * d; //xから往復開始一まで移動 

        if (k % 2 == 1) x = abs(x - d); //+-繰り返すとすると、奇数だったら左にすすむ
        ans = x;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; i++) {
        cin >> H[i];
    }

    int ans = 0, preans = 0;
    for(int i = 0; i < N-1; i++) {
        if(H[i] >= H[i+1]) {
            preans++;
        } else {
            ans = max(ans, preans);
            preans = 0;
        }
    }
    ans = max(ans, preans);
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

char str0[15], str1[15],str2[15];

void solve()
{
    scanf("%s%s", str0, str1);
    int a,b;
    scanf("%d%d", &a, &b);
    scanf("%s", str2);
    if(strcmp(str0,str2)==0) {
        printf("%d %d\n", a-1,b);
    }
    else {
        printf("%d %d\n", a,b-1);
    }


    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N=300005;
int n,L[N],R[N];
char s[N];
int main(){
	scanf("%d%s",&n,s+1);
	for (int i=1;i<=n;i++){
		L[i]=L[i-1]+(s[i]=='W');
	}
	for (int i=n;i>=1;i--){
		R[i]=R[i+1]+(s[i]=='E');
	}
	int ans=n+1;
	for (int i=1;i<=n;i++)
		ans=min(ans,L[i-1]+R[i+1]);
	printf("%d",ans);
	return 0;
}

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

int main() {
    int N,K;
    cin >> N >> K;
    int list[51];
    for(int i = 0; i<N;i++) {
        cin >> list[i];
    }
    sort(list, list + N, greater<int>());
    int max = 0;
    for(int i = 0; i<K; i++ ) {
        max += list[i];
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int x, y, z, i;
    
    for(i = 0; i < 3000; i++)
    {
        scanf("%d%d", &x, &y);
        if(x == 0 && y == 0)
        {
            break;
        }
        else
        {
            if(x > y)
            {
                z = x;
                x = y;
                y = z;
            }
            printf("%d %d\n", x , y);
        }
    }
    

    
    return 0;
}

Measured memory_bytes: 600
#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;
	#define lld long long int 
	#define vll vector<long long int>
	#define vs vector<string> 
	#define vint vector<int> 
	#define vp vector<pair<int,int>>
	#define vpll vector<pair<long long int , long long int>>
	#define forl(i,a,b) for(int i = a ; i <= b ; i++)
	#define forln(i,a,b) for(int i = a; i < b ; i++)
	#define forb(i,b,a) for(int i = b ; i >= a ; i--)
	#define forbn(i,b,a) for(int i = b ; i > a ; i--)
	lld mod = 1e9 + 7;
	#define len(str) lld len = str.length();
	#define ps push_back
	#define B begin
	#define E end
	#define mk make_pair
	#define F first 
	#define S second 
	#define FAST ios_base::sync_with_stdio(false),cin.tie(NULL)
	#define test()                  lld t; cin>>t; while(t--)

	typedef tree< pair<lld, lld>, null_type,less<pair<lld, lld>>,rb_tree_tag,
	tree_order_statistics_node_update> ordered_set;

	#define o_set tree<lld, null_type,greater_equal<lld>, rb_tree_tag,tree_order_statistics_node_update> 

	/*
	struct cmp
	{
		bool operator()(const pair<int,int>& l , const pair<int,int>&r){
			if(l.F > r.F) return true;
			if(l.F == r.F){
				if(l.S < r.S) return true;
				else return false;
			}else return false;
		}
	};

	*/
	lld power(lld x, lld y) 
	{ lld temp; if( y == 0) return 1; temp = power((x%mod), (y%mod)/2); if (y%2 == 0) return ((temp%mod)*(temp%mod))%mod;else return (((x%mod)*(temp%mod))%mod*(temp%mod))%mod;} 


	void solution( void );

	int main()
	{
		FAST;
		solution();
		return 0;
	}
	void solution()
	{
		lld n;
		cin>>n;
		if(n == 1){ cout<<"0"<<endl; return ;}
		map<lld,lld>mp;
		lld nn = n;
		for(lld i =2; i <= (lld)1000010 ; i++){
			while(n%i == 0){
				mp[i]++;
				n /= i;
				// cout<<i<<endl;
			}
		}
		lld cnt = 0;
		if(mp.size() == 0){cout<<"1"; return;}
		for(auto it:mp){	
// 			cout<<it.S<<endl;
			nn = it.S;
			lld k = 1;
			while(nn > 0){
				// cout<<k<<" ";
				nn -= k;
				if(nn >= 0)
					cnt++;
				k += 1;
			}
		}
		if(n != 1){  cnt++; }
		cout<<cnt<<endl;
	}

	// void sol()
	// {
	// 	double a,b;
	// 	cin>>a>>b;
	// 	lld tmp = a*b;
	// 	cout<<tmp;
	// }


Measured memory_bytes: 3636
import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N=int(input())
l = prime_factorize(N)
m = collections.Counter([])
m[1]=1
x=1
cnt=0
y=list()
for i in range(len(l)):
    if x!=1 and x%l[i]!=0:
        x=1
    x*=l[i]
    #print(x)
    if m[x]==0:
        y.append(x)
        m[x]=1
        cnt+=1
        x=1
#print(l)
#print(m)
#print(x,y)
print(cnt)


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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007
#define M2 500000004

int	main() {
	long N;
	cin >>N;
	vector<long> A(N, 0);
	for (long i=0; i<N; i++)
		cin >>A.at(i);
	vector<long> B(61, 0);
	for (long i=0; i<N; i++) {
		long AA=A.at(i);
		long j=0;
		while (AA>0) {
			if (1==AA%2)
				B.at(j)++;
			AA /=2;
			j++;
		}
	}
	vector<long> C(61, 0);
	for (long i=0; i<61; i++) {
		C.at(i)=B.at(i)*(N-B.at(i))%MOD;
		C.at(i) %=MOD;
	}
	long S=0;
	long D=1;
	for (long i=0; i<61; i++) {
		long DD=D*C.at(i);
		DD %=MOD;
		S +=DD;
		S %=MOD;
		D *=2;
		D %=MOD;
	}
	//S *=M2;
	//S %=MOD;
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+20;
long long v[N], c[51][51];
void init()
{
	memset(c, 0, sizeof(c));
	c[0][0] = 1;
	for (int i = 1; i <= 50; i++)
	{
		c[i][0] = 1;
		for (int j = 1; j <= i; j++)
			c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
	}
}
int main()
{
	long long n, a, b, num = 0, k = 0, ans = 0;
	init();
	cin >> n >> a >> b;
	double ave;
	for (int i = 0; i < n; i++) cin >> v[i];
	sort(v, v + n);
	reverse(v, v + n);
	for (int i = 0; i < a; i++) ave += v[i];
	ave /= a;
	for (int i = 0; i < n; i++)
	{
		if (v[i] == v[a - 1])
		{
			num++;
			if (i < a) k++;
		}
	}
	if (k == a)
	{
		for (int i = a; i <= b; i++)
			ans += c[num][i];
	}
	else ans += c[num][k];
    cout.precision(20);
 	cout << fixed << ave << endl << ans;
}


Measured memory_bytes: 3820
// Problem link : 
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <deque>
#include <bitset>
#include <climits>
using namespace std;

#define ll long long int
#define F(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define F1(a,n) for(int i=1;i<=n;i++){cin>>a[i];}
#define P(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define P1(a,n) for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define NF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m) for(int i=0;i<=n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}}cout<<endl;
#define PNF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}}cout<<endl;
#define mod 1000000007
#define AS
ll n;
ll a[25][25];
ll dp[25][(1<<21)];
ll solve(ll i,ll women)
{
	if(i==n)
	{
		return women==0;
	}
	ll ans = 0;
	if(dp[i][women]!=-1) return dp[i][women];
	for(ll w=0;w<n;w++)
	{
		bool available = (women&(1<<w));
		if(available and a[i][w])
		{
			ans=(ans+solve(i+1,women&(~(1<<w))))%mod;
		}
	}
	return dp[i][women]=ans;
}
int main()
{
// int n;
cin>>n;
// int a[n][n];
for(int i = 0;i<n;i++)
{
	for(int j=0;j<n;j++)
	{
		cin>>a[i][j];
	}
}
ll women = (1<<n)-1;
memset(dp,-1,sizeof dp);
cout<<solve(0,women)%mod;
return 0;
}

Measured memory_bytes: 409856
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] num = new int[n];
		for (int i = 0; i < num.length; i++) {
			num[i] = scanner.nextInt();
		}
		boolean[] check = new boolean[n];
		int i = 0;
		int count = 0;
		while (!check[i]) {
			//System.out.println(i);
			count++;
			check[i] = true;
			i = num[i] - 1;
			if (i == 1) {
				System.out.println(count);
				System.exit(0);
			}
		}
		System.out.println("-1");
		scanner.close();
	}
}


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

#define ll long long int
#define mod 1000000007

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;


int main()
{  
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n,m,x,s=0;
    cin>>n>>m;
    for(int i=0;i<m;i++){
		cin>>x;
		s+=x;
	}
	int ans=n-s;
	if(ans<0)ans=-1;
	cout<<ans<<"\n";
    
}



Measured memory_bytes: 3640
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#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;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int n;
string s;

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
	
	cin >> s;
	n = s.size();
	int k = 0;
	string pre  = "";
	string cur = "";
	for(int i=0;i<n;i++){
		cur+=s[i];
		if(cur!=pre){
			k++;
			pre = cur;
			cur = "";
		}
	}
	cout << k << endl;

return 0;
}
///....


Measured memory_bytes: 720
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  n,m,c = map(int,input().split())
  B = list(map(int,input().split()))
  cnt =0
  for i in range(n):
    ans = 0
    A = list(map(int,input().split()))
    for j in range(m):
      ans += B[j] * A[j]
    #-
    ans += c
    #-
    if ans > 0:
      cnt += 1
  print(cnt)
if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

    // 問題数
    int a = sc.nextInt();
    // 提出数
    int b = sc.nextInt();

    int[] w = new int[a];
    Map<Integer, Boolean> map = new HashMap<>();
    for (int i = 0; i < a; i++) {
      map.put(i + 1, false);
      w[i] = 0;
    }

    int wrong = 0;
    int correct = 0;
    int problemNum;
    String result;
    for (int i = 1; i <= b; i++) {
      problemNum = sc.nextInt();
      result = sc.next();
      if (!map.get(problemNum)) {
        if (result.equals("WA")) {
          w[problemNum - 1]++;
        }
        if (result.equals("AC")) {
          correct++;
          wrong += w[problemNum - 1];
          map.put(problemNum, true);
        }
      }
    }
    System.out.println(correct + " " + wrong);
  }
}


Measured memory_bytes: 69856
#include<iostream>
#include<string>
#include<cctype>
#include<stack>
using namespace std;
typedef long long ll;
int main()
{
    string a,b;
    string c;
    cin>>a>>b;
    int i=0;
    for(i=0;i<min(a.length(),b.length());i++)
    {
        c+=a[i];
        c+=b[i];
    }
    for(;i<a.length();i++)
        c+=a[i];
    for(;i<b.length();i++)
        c+=b[i];
    cout<<c<<endl;
    return 0;
}



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

int main(){
  int n;
  string s;
  cin>>n>>s;
  int mx=0;
  rep(i,n-1){
    vector<int> x(26,0),y(26,0);
    int num=0;
    rep(j,n){
      int k=s[j]-'a';
      j>i?y[k]++:x[k]++;
    }
    rep(j,26)if(x[j]>0&&y[j]>0)num++;
    mx=max(mx,num);
  }
   cout<<mx;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <iomanip>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str="";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}

int main() {
	int h, w; cin >> h >> w;
	string datas[50 + 2], temp,push2,ans[50];
	datas[0] = gen(w + 2);
	datas[h+1] = gen(w + 2);

	for (int i = 1; i < h+1; i++) {
		cin >> temp;
		datas[i] = "." + temp + ".";
	}
	//cout << endl;
	for (int i = 1; i < h + 1; i++) {
		temp = datas[i];
		push2 = "";
		for (int j = 1; j < w + 1; j++) {
			int cnt = 0;
			
			if (temp[j] == '.') {
				cnt++;
				string up, down;
				up = datas[i - 1];
				down = datas[i + 1];
				if (up[j - 1] == '#') cnt++;
				if (up[j] == '#') cnt++;
				if (up[j + 1] == '#') cnt++;

				if (temp[j - 1] == '#') cnt++;
				if (temp[j + 1] == '#') cnt++;

				if (down[j - 1] == '#') cnt++;
				if (down[j] == '#') cnt++;
				if (down[j + 1] == '#') cnt++;
			}
			if (cnt != 0) push2 += to_string(cnt-1);
			else push2 += temp[j];
			//cout << temp;
		}
		ans[i-1] = push2;
	}

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

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define ll long long
using namespace std;
int a,b,c;
int main()
{
    cin>>a>>b>>c;
    ll ans=0;
    int t=min(b,c);
    c-=t;
    b-=t;
    ans+=2*t;
    t=min(a,c);
    ans+=t;
    c-=t;
    a-=t;
    if (c>=1) ans+=1;
    ans+=b;
    cout<<ans<<endl;

    return 0;
}


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

using namespace std;

#define REP(var, n)  for (int var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<int>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x << " "; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


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


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 (b < a) {
        a = b;
        return true;
    }
    return false;
}

const int MOD = (int) 1e9 + 7;
const int INF = 1 << 29;

void solve() {
    ll n;
    cin >> n;
    ll res = 0;

    ll denom = 10;
    if (n % 2 == 0) {
        while(true) {
            ll t = (n / denom);
            if (t == 0) break;
            res += (n / denom);
            denom *= 5;
        }
    }

    cout << res << endl;
}


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

//    cout << solve() << endl;
    solve();
//    cout << (solve() ? "Yes" : "No") << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;			
	   
int main() {
			fast
			// #ifndef ONLINE_JUDGE
			// freopen("input.txt","r",stdin);
			// freopen("output.txt","w",stdout);
			// #endif

			ll n,k;
			cin>>n>>k;
			ll ans=0;
			ll arr[n];
			for(ll i=0;i<n;i++)
			cin>>arr[i];

			sort(arr,arr+n);
			for(ll i=0;i<k;i++)
			ans+=arr[i];
			cout<<ans;
			
			return 0;
		 }	


Measured memory_bytes: 3620
n,w=map(int,input().split())
value=[]
wt=[]
for i in range(n):
    a,b=map(int,input().split())
    wt.append(a)
    value.append(b)
dp=[[0 for i in range(w+1)] for j in range(n+1)]
for i in range(1,n+1):
    for j in range(1,w+1):
        if wt[i-1]<=j:
            dp[i][j]=max(value[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
print(dp[n][w])


Measured memory_bytes: 171400
#include <iostream>
int main(int argc, const char * argv[]) {
    int k, x;
    std::cin >> k >> x;
    
    int max =  1000000;
    int min = -1000000;
    for(int i=x-k+1; i<=x+k-1; i++)
    {
        std::cout << i << " ";
    }
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=100100;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
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(){
    ll N,ans=1;
    cin>>N;
    vector<ll> A(N),cnt(N,0);
    for(ll i=0;i<N;i++){
        cin>>A[i];
        cnt[A[i]]++;
        if(A[i]==0) ans*=4-cnt[A[i]];
        else ans*=cnt[A[i]-1]-cnt[A[i]]+1;
        ans%=MOD;
    }
    cout<<ans<<endl;
}


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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
    int x1, x2, y1,y2,x3,y3,x4,y4,dx,dy;
    cin >> x1 >> y1 >> x2 >> y2;
    dx = x2- x1;
    dy = y2 - y1;
    x3 = x2 - dy;
    y3 = y2 + dx;
    x4 = x1 - dy;
    y4 = y1 + dx;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int n,card;
void make_map(map<int,int>& col, map<int,int>& row, map<int,int>& dia, map<int,int>& rdia) {
	int temp;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			cin >> temp;
			col[temp] = j + 1;
			row[temp] = i + 1;
			if (i == j) {
				dia[temp] = n+1;
			}
			if (i+j == n-1) {
				rdia[temp] = n+2;
			}
		}
	}
}

bool check_line(int& count, map<int,int>& hash) {
	if (hash[card] > 0) {
		++count;
		if (count == n) {
			return true;
		}
	}
	return false;
}

int main(void) {
	int u,v,m;
	cin >> n >> u >> v >> m;
	map<int,int> rcol,ccol;
	map<int,int> rrow,crow;
	map<int,int> rdia,cdia;
	map<int,int> rrdia,crdia;
	if (n > 1) {
		make_map(rcol,rrow,rdia,rrdia);
		make_map(ccol,crow,cdia,crdia);
	}
	else {
		int temp;
		cin >> temp;
		rdia[temp] = 1;
		cin >> temp;
		cdia[temp] = 1;
	}

	int rc,cc;
	vector<int> rc_col(n,0),cc_col(n,0);
	vector<int> rc_row(n,0),cc_row(n,0);
	vector<int> rc_dia(2,0),cc_dia(2,0);
	rc = cc = 0;
	bool fin = false;
	for (int i = 0; i < m; ++i) {
		cin >> card;
		if (!fin) {
			if (check_line(rc_col[rcol[card]-1],rcol)) {
				++rc;
			}
			if (check_line(rc_row[rrow[card]-1],rrow)) {
				++rc;
			}
			if (check_line(rc_dia[0],rdia)) {
				++rc;
			}
			if (check_line(rc_dia[1],rrdia)) {
				++rc;
			}
			if (check_line(cc_col[ccol[card]-1],ccol)) {
				++cc;
			}
			if (check_line(cc_row[crow[card]-1],crow)) {
				++cc;
			}
			if (check_line(cc_dia[0],cdia)) {
				++cc;
			}
			if (check_line(cc_dia[1],crdia)) {
				++cc;
			}
			if (rc >= u && cc >= v) {
				cout << "DRAW" << endl;
				fin = true;
			}
			else if (rc >= u) {
				cout << "USAGI" << endl;
				fin = true;
			}
			else if (cc >= v) {
				cout << "NEKO" << endl;
				fin = true;
			}
		}
	}
	if (!fin) {
		cout << "DRAW" << endl;
	}
	return 0;
}

Measured memory_bytes: 34896
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j=0,a[57],n,s=0,cc[58];
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n;i++)
    {
        if(a[i]==i+1){

        }
        else{
            s++;
            //cc[j++]=i;
        }
    }

    if(s==2||s==0)
    {
        cout<<"YES"<<endl;

    }
    else{
        cout<<"NO"<<endl;
    }



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(int argc, const char * argv[]) {
    int a, b;
    cin >> a >> b;
    int num = 1, cnt = 0;
    while (num < b) {
        num--;
        num += a;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

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



int main(){ FastIO;

int n,i,j,k;cin>>n>>k;
int a[n]; for(i=0;i<n;i++) cin>>a[i];
int dp[n];
for(i=0;i<n;i++) dp[i]=INT_MAX;
dp[0]=0;
for(i=0;i<n-1;i++)
{
	for(j=1;j<=k;j++)
	{
		if(i+j<n)
		{
			dp[i+j]=min(abs(a[i+j]-a[i])+dp[i],dp[i+j]);
		}
	}
}
cout<<dp[n-1];

return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define ifr(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pof pop_front
#define pob pop_back
#define pb emplace_back
#define pf emplace_front
#define fstm(m,n,r) m.reserve(n);m.max_load_factor(r)
#define mp make_pair
#define mt make_tuple
#define inf LLONG_MAX
#define os tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
const double PI = acos(-1);
typedef complex<double> cd;
typedef long long ll;
ll gcd(){return 0ll;} template<typename T,typename... Args> T gcd(T a,Args... args) { return __gcd(a,(__typeof(a))gcd(args...)); }
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef unordered_map<ll,ll> umap;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007 
#define N 100001

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

    int n,ans=0;
    string s;
    cin>>n>>s;
    for(int i=0;i<n-2;i++) {
    	if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') {
    		ans++;
    	}
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll F[2100010];

ll Mul(ll a, ll b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
ll square(ll x) {
	return (x * x) % mod;
}

ll power(ll x, ll y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

ll Div(ll a, ll b) {
	return Mul(a, power(b, mod - 2));
}
ll P(ll n, ll r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

ll C(ll n, ll r) {
	if (n < r || n < 0 || r < 0) return 0;
	ll ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}

ll cnt[100010];
int main()
{
	ll N, K;
	cin >> N >> K;
	ll ans = 0;
	for (int i = K; i >= 1; i--) {
		ll num = power(K / i, N);
		int j = 2;
		while (i * j <= K) {
			num -= cnt[i * j];
			j++;
		}
		cnt[i] = num;
		ans = (ans + i * num) % mod;
		if (ans < 0) ans += mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4416
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	fmt.Println(float64((n+1)/2) / float64(n))
}


Measured memory_bytes: 1772
n,x,y = map(int,input().split())

x -= 1
y -= 1
cnt = [0]*n

for i in range(n):
    for j in range(i+1,n):
        dis = min(j-i,abs(x-i)+1+abs(j-y))
        cnt[dis] += 1
for i in range(1,n):
    print(cnt[i])

Measured memory_bytes: 9344
n,m=map(int,input().split())
lr = [list(map(int,input().split())) for _ in range(m)]
min_id = 1
max_id = n
for v in lr:
  min_id = max(min_id,v[0])
  max_id = min(max_id,v[1])
if max_id < min_id:
  out = 0
else:
  out = max_id - min_id +1  
print(out)  

Measured memory_bytes: 27332