akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<double, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
int n,m;
struct edge { int to;double cost; };
int V;
vector<edge> G[100000];
double d[100000];
void init(int v) {
	rep(i, v) {
		G[i].clear();
	}
}
void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P>>que;
	fill(d, d + V, 10000);
	d[s] = 0;
	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v]+eps < p.first)continue;
		for (int i = 0; i < (int)G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost+eps) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}
int main() {
	while (cin >> n>>m, n) {
		V = 100000;
		int s, g; cin >> s >> g; s--; g--;
		init(100000);
		P dis[30][30];
		rep(i, 30) {
			rep(j, 30) {
				dis[i][j] = { 0,0 };
			}
		}
		rep(i, m) {
			int x, y, D, c; cin >> x >> y >> D >> c; x--; y--;
			dis[x][y] = dis[y][x] = { D,c };
		}
		rep(f, n) {
			rep(i, n) {
				rep(j, 31) {
					Rep1(k, -1, 1) {
						int x = j + k;
						if (x <= 0 || x > 30)continue;
						rep(l, n) {
							if (f!=l&&i != l && dis[i][l].first != 0 && dis[i][l].second >= x) {
								G[i + j * n+f*n*31].push_back({ l + n * x+i*n*31,(double)dis[i][l].first / double(x) });
							}
						}
					}
				}
			}
		}
		dijkstra(s + s * n*31);
		double mi = 10000;
		rep(i, n) {
			mi = min(mi, d[g + n+ n * 31*i]);
		}
		if (mi == 10000) {
			cout << "unreachable" << endl; continue;
		}
		cout << fixed << setprecision(5) << mi << endl;
	}
	return 0;
}



Measured memory_bytes: 62152
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long int ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PLL, int> PLLI;
typedef pair <PLL, PLL> PP;
typedef pair <PII, int> PPI;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
const int mod = 1e9+7;
const int inf = 1e9+9;
const ll MOD = 1e9+696969;
const long long INF = 1e18+3;
const int MAXN = 2005;
 
int n, m, g[MAXN][MAXN], h[MAXN], s[MAXN], top;
char str[MAXN];
 
int main(){
	int i, j, ans;
	scanf("%d%d", &n, &m);
	for(i = 1; i <= n; ++ i){
		scanf("%s", str + 1);
		for(j = 1; j <= m; ++ j)
			g[i][j] = int(str[j] == '#');
	} ans = max(n, m);
	for(i = 1; i < n; ++ i){
		for(j = 1, top = 0; j < m; ++ j){
			if(g[i][j] ^ g[i][j + 1] ^ g[i + 1][j] ^ g[i + 1][j + 1]) h[j] = 0;
			else ++ h[j];
			while(top && h[j] <= h[s[top]]){
				ans = max(ans, (j - s[top - 1]) * (h[s[top]] + 1));
				-- top;
			} s[++ top] = j;
		}
		for(; top; -- top)
			ans = max(ans, (m - s[top - 1]) * (h[s[top]] + 1));
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 15872
#from fractions import gcd
#x = list(map(int, input().split()))
N = int(input())
a = list(map(int,input().split()))

cnt = 1
for i in range(N):
    if a[i] == cnt:
        cnt += 1
if cnt == 1:
    cnt =N+1
else:
    cnt -=1
print(N-cnt)    


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

#define MAXN 100005
#define int long long
#define LL long long
#define pii pair<int, int>
#define fi first
#define se second
#define fastio ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

using namespace std;

int N, W;
int dp[MAXN];
int w[105], v[105];

signed main() {
    cin >> N >> W;
    memset(dp, 0x3f, sizeof(dp));
    for (int i = 1; i <= N; i++) {
        cin >> w[i] >> v[i];
    }
    dp[0] = 0;
    for (int i = 1; i <= N; i++) {
        for (int j = N*1000; j >= v[i]; j--) {
            dp[j] = min(dp[j], dp[j-v[i]] + w[i]);
        }
    }
    for (int i = N*1000; i >= 0; i--) {
        if (dp[i] <= W) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
n=int(input())
b=list(map(int, input().split()))  
ans=[]
for i in range(n):
    for j in range(1,len(b)+1):
        if b[-j]==len(b)+1-j:
            ans.append(b[-j])
            del(b[-j])
            break

if len(b)!=0:
    print(-1)
    exit()

ans.reverse()

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

            
    
    
            
                
    
        

     

    

     

    


Measured memory_bytes: 39024
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 23 14:04:30 2020

@author: liang
"""

N, M = map(int,input().split())

if N == 1 and M == 1:
    ans = 1
elif N == 1:
    ans = M - 2
elif M == 1:
    ans = N - 2
else:
    ans = (N-2)*(M-2)
print(ans)

Measured memory_bytes: 9124
N=int(input())
ad_ma=[[0 for i in range(N)] for j in range(N)]
for i in range(N):
    nums=list(map(lambda x:int(x)-1,input().split()))
    f=nums[0]
    nums=nums[2:]
    for num in nums:
        ad_ma[f][num]=1

 
for i in range(N):
    for j in range(N):
        if(j!=N-1):
            print(ad_ma[i][j],end=' ')
        else:
            print(ad_ma[i][j])

Measured memory_bytes: 8416
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
  let mut line: String = String::new();
  io::stdin().read_line(&mut line);
  line.trim().parse().ok().unwrap()
}

fn main() {
  let S: String = input();
  if S == "Sunny" {
    println!("Cloudy");
  } else if S == "Cloudy" {
    println!("Rainy");
  } else {
    println!("Sunny");
  }
}


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

using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'

ll mn = 1000000000000000000;

void func(ll n)
{
	int lnn = sqrt(n);
	for(int i = 1 ; i <= lnn; i++)
	{
		if(n%i == 0)
		{
			ll a = i;
			ll b = n/i;
			mn = min((a-1) + (b-1), mn);
		}
	}
}

int main()
{
	//IOS
	ll n;
	
	cin >> n;
	
	func(n);
	
	cout << mn << endl;
	
	return 0;
}


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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main(){
  string n;
  cin >> n;
  string ans;
  int len = n.size()-1;
  if(strtoint(n[len]) == 0 or strtoint(n[len]) == 1 or strtoint(n[len]) ==6 or strtoint(n[len]) ==8)ans = "pon";
  else if(strtoint(n[len]) == 2 or strtoint(n[len]) ==4 or strtoint(n[len]) ==5 or strtoint(n[len]) ==7 or strtoint(n[len]) ==9)ans = "hon";
  else if(strtoint(n[len]) == 3)ans = "bon";
  cout << ans << endl;

}

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

using Lint=long long;

int main()
{
   int N; cin>>N;
   vector<string> s(N);
   vector<int> t(N);
   for(int i=0;i<N;i++) cin>>s[i]>>t[i];
   string X; cin>>X;

   int ans=0;
   bool flag=false;
   for(int i=0;i<N;i++){
      if(flag) ans+=t[i];
      if(s[i]==X) flag=true;
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<iomanip>
#include<sstream>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<numeric>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define repc(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto n :(array))

typedef long long ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;
typedef map<string,int> dict;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
double eps = 1e-10 ;

  template <typename T>
void out(vector < T > v)
{
  for(size_t i = 0; i < v.size(); i++)
  {
    debug(v[i]);
  }
}

template<typename T>
string ntos( T i ) {
  ostringstream s ;
  s << i ;
  return s.str() ;
}

template<typename T>
T ston(string str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double n = 0;
  vector<double> v(11,0);
  while(cin >> v[1]){
    n = 0;
    repc(i,2,11){
      if(i % 2 == 0){
        v[i] = v[i-1]*2;
      }
      else{
        v[i] = v[i-1]/3;
      }
      n+=v[i] ;
    }
    cout <<fixed<< setprecision(9) <<n+v[1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, t, a;
    cin >> n >> t >> a;
    double ans = INF;
    int pos = 0;
    rep(i, n)
    {
        double h;
        cin >> h;
        double x = t - h * 0.006;
        double d = abs(a - x);
        if (abs(ans - a) > d)
        {
            ans = x;
            pos = i + 1;
        }
    }
    cout << pos << endl;
}

Measured memory_bytes: 256
// 解説を読んだ
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

const double INF = 1e6;
const double EPS = 1e-8;
#define same(a, b) (abs(a-b) < EPS)

double a, b, c, d;

double fx(double x){
    return a*x*x*x+b*x*x+c*x+d;
}

bool binary(double l, double r, double &v){
    if(same(fx(l), 0)){
        v = l;
        return true;
    }
    if(same(fx(r), 0)){
        v = r;
        return true;
    }
    if(fx(l)*fx(r) > 0) return false;
    int loop = 200;
    while(loop-- > 0){
        double mid = (l+r)/2;
        double val = fx(mid);
        if(val*fx(l) > 0)   l = mid;
        else                r = mid;
    }
    if(same(fx(l),0)){
        v = l;
        return true;
    }
    if(same(fx(r),0)){
        v = r;
        return true;
    }
    return false;
}


int main(){
    int q;
    cin >> q;
    while(q-- > 0){
        int p = 0, m = 0;
        auto judge = [&](double val){
            if(same(val,0)) return;
            if(val < 0) m++;
            if(val > 0) p++;
        };
        cin >> a >> b >> c >> d;
        double det = b*b-3*a*c;
        if(det >= 0){
            double l = (-b-sqrt(b*b-3*a*c))/(3*a);
            double r = (-b+sqrt(b*b-3*a*c))/(3*a);
            if(l > r)   swap(l, r);
            double tmp;
            if(binary(-INF, l, tmp))    judge(tmp);
            if(binary(l, r, tmp))       judge(tmp);
            if(binary(r, INF, tmp))     judge(tmp);
        }else{
            double tmp;
            if(binary(-INF, INF, tmp))  judge(tmp);
        }
        printf("%d %d\n", p, m);
    }
    return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, r;
  cin >> n >> r;
  if (n >= 10)
    cout << r << '\n';
  else cout << (r + (100 * (10 - n))) << '\n';

  return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextInt();
  string S; cin >> S;
  int ans = 0;

  REP(a, 10) {
    REP(b, 10) {
      REP(c, 10) {
        int ai = S.find('0' + a);
        if (ai == string::npos) continue;
        int bi = S.find('0' + b, ai + 1);
        if (bi == string::npos) continue;
        int ci = S.find('0' + c, bi + 1);
        if (ci == string::npos) continue;
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

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

def main():
    mod=10**9+7
    N=I()
    S1=input()
    S2=input()
    L=[0]
    
    #最初：0 縦向き:1 横向き:2
    i=0
    for _ in range(N):
        if S1[i]==S2[i]:
            L.append(1)
            i+=1
        else:
            L.append(2)
            i+=2
        if i>=N:
            break
    ans=1
    
    for i in range(1,len(L)):
        if L[i-1]==0:
            if L[i]==1:
                ans*=3
            else:
                ans*=6
        elif L[i-1]==1:
            ans*=2
        else:
            if L[i]==1:
                continue
            else:
                ans*=3
        ans%=mod
    print(ans)
        
    

main()


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
#define Graph vector<vector<int>>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }


int main(){

    long long K;
    scanf("%lld",&K);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);

    ll count=0;

    for(int i = A; i <= B; i++){
        if(i%K==0){
            count++;
        }
    }

    if(count>0){
        cout << "OK" << endl;
    }

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


    return 0;
}


Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}


struct edge{
    int to, cost;
    edge(int To, int Cost): to(To), cost(Cost){};
};


int V; //頂点数
vector<vector<edge>> G;
vector<int> d; //sからの距離

void dijkstra(int s){
    //Pi_i first: 距離　second: 頂点
    priority_queue<Pi_i, vector<Pi_i>, greater<Pi_i>> que;
    d.resize(V, INF);
    d[s] = 0;
    que.push(MP(0, s));

    while(!que.empty()){
        Pi_i p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        for(edge &e: G[v]){
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(MP(d[e.to], e.to));
            }
        }
    }
}

int main(){
    cin >> V;
    G.resize(V);
    REP(i, V){
        int u, k; cin >> u >> k;
        REP(j, k){
            int v, c; cin >> v >> c;
            G[u].PB(edge(v, c));
        }
    }
    dijkstra(0);
    REP(i, V){
        cout << i << " " << d[i] << "\n";
    }
    return 0;
}



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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int64_t n;
    vector<pair<int64_t, int64_t>> tasks;
    cin >> n;
    for(int i=0;i<n;i++){
        int64_t a, b;
        cin >> a >> b;
        tasks.emplace_back(b, a);
    }
    sort(tasks.rbegin(), tasks.rend());

    int64_t time = tasks[0].first;
    for(int i=0;i<n;i++){
        time = min(time, tasks[i].first);
        time -= tasks[i].second;
        if(time < 0) goto ng;
    }
    if(time >= 0){
        cout << "Yes" << endl;
    }else{
        ng:
        cout << "No" << endl;
    }

    
    return 0;
}

Measured memory_bytes: 6256
{-# LANGUAGE Strict #-}
import qualified Data.ByteString.Char8 as B
import           Data.Vector.Unboxed   (Vector)
import qualified Data.Vector.Unboxed   as V


main :: IO ()
main = do
  [k, n] <- map read . words <$> getLine
  as <- readIntsLn
  print $ solve k n as

readIntsLn :: IO (Vector Int)
readIntsLn = V.unfoldr (B.readInt . B.dropWhile (== ' ')) <$> B.getLine

solve :: Int -> Int -> Vector Int -> Int
solve k _ as = k - V.maximum bs
  where as' = as `V.snoc` a
        a = k + (V.head as)
        bs = V.zipWith (-) as' (0 `V.cons` as)


Measured memory_bytes: 14940
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int m; cin >> m;
    rep(i,0,m) {
        string s; cin >> s;
        int len = s.length();
        set<string> res;
        rep(j,1,len) {
            int len_l = j, len_r = len - j;
            string s1 = s.substr(0, len_l);
            string s2 = s.substr(len_l, len_r);
            string s3 = s1;
            string s4 = s2;
            reverse(s3.begin(), s3.end());
            reverse(s4.begin(), s4.end());
            res.insert(s1 + s2);
            res.insert(s2 + s1);

            res.insert(s1 + s4);
            res.insert(s4 + s1);

            res.insert(s3 + s2);
            res.insert(s2 + s3);

            res.insert(s3 + s4);
            res.insert(s4 + s3);
        }
        cout << res.size() << endl;
    }
    return 0;
}

Measured memory_bytes: 3216
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    vector<int> pref(n), suf(n);
    pref[0] = a[0];
    for (int i = 1; i < n; ++i)
        pref[i] = max(pref[i - 1], a[i]);
    suf[n - 1] = a[n - 1];
    for (int i = n - 2; i >= 0; --i)
        suf[i] = max(suf[i + 1], a[i]);
    for (int i = 0; i < n; ++i)
    {
        if (i == 0)
            cout << suf[1];
        if (i == n - 1)
            cout << pref[n - 2];
        if (i > 0 && i < n - 1)
            cout << max(pref[i - 1], suf[i + 1]);
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3968
A, B, M = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))

minVal = min(a) + min(b)

for _ in range(M):
  x, y, c = list(map(int, input().split()))
  minVal = min(a[x - 1] + b[y - 1] - c, minVal)

print(minVal)

Measured memory_bytes: 18612
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  cout << n / 3 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;
#define INF 100000

int main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int a = x2 - x1;
    int b = y2 - y1;
    int x3 = x2 - b;
    int y3 = y2 + a; 
    int x4 = x3 - a; 
    int y4 = y3 - b;
    //cout << a << " " << b << endl;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ff(n,m) for(ll i=1;i<n;i++)for(ll j=1;j<m;j++)
#define f(m) for(ll i=0;i<m;i++)
using namespace std;

int main()
{
    fio;
    ll n,m;
    cin>>n>>m;
    char arr[n][m];
    ll dp[n][m];
    for(ll i=0;i<n;i++){for(ll j=0;j<m;j++){cin>>arr[i][j];if(arr[i][j]=='#'){dp[i][j]=0;}}}
    dp[0][0]=0;
    f(n){dp[i][0]=0;}
    f(m){dp[0][i]=0;}
    ll i=1;
    while((arr[i][0]!='#')&&i<n){dp[i][0]=1;i++;}
    i=1;
    while((arr[0][i]!='#')&&i<m){dp[0][i]=1;i++;}



    for(ll i=1;i<n;i++)
    {for(ll j=1;j<m;j++)
        {
          if(arr[i][j]!='#'){dp[i][j]=(dp[i-1][j]%1000000007+dp[i][j-1]%1000000007)%1000000007;}
          else{dp[i][j]=0;}
        }
    }


    cout<<dp[n-1][m-1];
    return 0;

}



Measured memory_bytes: 12272
#include <iostream>
#include <cassert>
#include <queue>

#define INF 922337203685477580
typedef long long ll;

using namespace std;

int partition(int *A, int p, int r) {
  int x = A[r];
  int i = p - 1;
  for (int j = p; j < r; j++) {
    if (A[j] <= x) {
      i++;
      int a = A[i];
      A[i] = A[j];
      A[j] = a;
    }
  }
  int a = A[r];
  A[r] = A[i + 1];
  A[i + 1] = a;

  return i + 1;
}
int main() {
  int n;
  cin >> n;

  int A[n];
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }

  int pos = partition(A, 0, n - 1);
  for (int i = 0; i < n; i++) {
    if (i) cout << " ";
    if (i == pos) {
      cout << "[" << A[i] << "]";
    } else {
      cout << A[i];
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3476
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }

int main(){
	ll n ; cin >> n ;
	vll a(n) ;
	for(auto &i:a) cin >> i ;
	map<ll,ll> m ;
	ll pos = 0 ;
	vll b = a ;
	sort(all(b)) ;
	for(int i=0;i<n;i++) m[b.at(i)] = i ;
	ll ans = 0 ;
	for(int i=0;i<n;i++) ans += ((m[a.at(i)]&1)!=(i&1)) ;
	cout << ans/2 << endl ;
}

Measured memory_bytes: 11160
#include<stdio.h>
#include<math.h>

int main(){
	
	double h, m;
	double k;
	double ans;
	double a, b;
	
	scanf("%lf%lf%lf%lf", &a,  &b, &h, &m);
	
	k = h * 30 - 5.5 * m;
	
	if(k < 0)
		k = k * (-1);
	
	if(k > 180)
		k = 360 - k;
	k = k * 3.141592653589793 / 180.0;
	ans = (a * a) + (b * b) - (2 * a * b * cos(k));
	
	printf("%.10lf", sqrt(ans));
	
	return 0;
}


Measured memory_bytes: 2492
#include<stdio.h>
#include<map>
using namespace std;
int n,ch[1000005],sh[1000005],ans,sum,fa[1000005],tot,mk[1000005];
map <int,int> mp,mmp;
int gf(int p){
	if(fa[p]==p)return p;
	return fa[p]=gf(fa[p]);
}
void mg(int a,int b){
	int fx=gf(a),fy=gf(b);
	if(fx!=fy){
		fa[fx]=fy;
	}
}
int main(){
//	freopen("duliu.in","r",stdin);
//	freopen("duliu.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&sh[i]);sum^=sh[i];mp[sh[i]]++;
	}mp[sum]++;
	for(int i=1;i<=n;i++){
		scanf("%d",&ch[i]);mp[ch[i]]--;
		if(mp[ch[i]]<0){
			ans=-999999999;
		}
		if(sh[i]!=ch[i]){mk[i]=1;
			ans++;
		}
	}
	sh[n+1]=sum;
	for(int i=1;i<=n+1;i++){
		if(mp[sh[i]]>0){
			ch[n+1]=sh[i];break;
		}
	}
	n++;tot=n+n;
	mk[n]=1;
	for(int i=1;i<=n;i++){
		if(!mk[i])continue;
		if(mmp[sh[i]]==0)mmp[sh[i]]=++tot;
		fa[i]=i;fa[i+n]=i+n;
	}
	for(int i=1;i<=tot;i++)fa[i]=i;
	for(int i=1;i<=n;i++){
		if(!mk[i]){
			fa[i]=fa[i+n]=0;
		}
	}
	for(int i=1;i<=n;i++){
		if(sh[i]!=ch[i])mg(i,i+n);
		mg(i,mmp[sh[i]]);mg(i+n,mmp[ch[i]]);
	}
	for(int i=1;i<=tot;i++){
		if(fa[i]==i){//printf("i:%d\n",i);
			ans++;
		}
	}
	ans--;
	if(ans<0)printf("-1");
	else printf("%d",ans);
}

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<long long, long long>> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i].first >> v[i].second;
	}
	sort(v.begin(), v.end());
	multiset<long long, greater<long long>> ms;
	int j = 0;
	long long ans = 0;
	for (int i = 1; i <= m; i++) {
		for (; j < n && v[j].first == i; j++) {
			ms.insert(v[j].second);
		}
		if (ms.size()) {
			ans += *ms.begin();
			ms.erase(ms.begin());
		}
	}
	cout << ans;

}

Measured memory_bytes: 6400
import collections
N = int(input())
stack = collections.deque("a")
charset = [chr(ord("a") + i) for i in range(26)]
ans = []
while stack:
    s = stack.pop()
    if len(s) == N:
        ans.append(s)
        continue
    my_max = 0
    for s_s in s:
        my_max = max(my_max, charset.index(s_s))
    for i in range(my_max + 2):
        stack.append(s + charset[i])
[print(a) for a in sorted(ans)]

Measured memory_bytes: 14824
//Optional FAST

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

//Required Libraries

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

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work
vector<vector<ll>> ADJ;
vector<ll> val;
vector<ll> ans;
vector<ll> d;

void dfs(ll u,ll p=-1)
{
    ll prev=*lower_bound(d.begin(),d.end(),val[u]);
    *lower_bound(d.begin(),d.end(),val[u])=val[u];
    ans[u]=distance(d.begin(),lower_bound(d.begin(),d.end(),inf));
    for(auto v:ADJ[u])
    {
        if(v!=p)
        {
            dfs(v,u);
        }
    }
    *lower_bound(d.begin(),d.end(),val[u])=prev;
}

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    val.resize(N+1);
    ADJ.resize(N+1);
    ans.resize(N+1);
    d.resize(N+1,inf);
    FORI(i,1,N+1)
    {
        READ(val[i]);
    }
    FORI(i,0,N-1)
    {
        READV(u);
        READV(v);
        ADJ[u].pb(v);
        ADJ[v].pb(u);
    }
    dfs(1);
    FORI(i,0,N)
    {
        cout<<ans[i+1]<<endl;
    }

//-----------------------------------------------------------------------------------------------------------//


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, 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; }

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


ll dp[1005][(1<<12)+5];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  map<ll,ll> m;
  rep(i,n){
    ll a; cin>>a;
    m[a]++;
  }
  ll ans=0;
  for(auto e: m){
    if(e.second%2==1) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 6528
import sys
input = sys.stdin.readline
def chmin(a, b):
    if a > b:
        return b
    else:
        return a
  
n,k = map(int,input().split())
h = [int(i) for i in input().split()]
# dpの最小値を変更する関数

# 無限大の値
f_inf = 10 ** 9 
# DP テーブルを初期化　(最小化問題なので INF に初期化)
dp = [f_inf] * (10**5+10)
# 初期条件
dp[0] = 0
# 足場 i-1 から足場 i へ移動する。コストは|h[i]−h[i-1]|
# 足場 i-2 から足場 i へと移動する コストは |h[i]−h[i-2]|
for i in range(1, n):
    for j in range(1,k+1):
        if i-j < 0 :
            continue
        else:
            dp[i] = chmin(dp[i], dp[i - j] + abs(h[i] - h[i-j]))
print(dp[n-1])


Measured memory_bytes: 52444
#!/usr/bin/env python
# coding: utf-8

# In[4]:


import math


# In[17]:


N,M = map(int, input().split())


# In[18]:


if abs(N-M) > 1:
    ans = 0
else:
    ans = math.factorial(N)*math.factorial(M)
    if N == M:
        ans *= 2
print(ans%(10**9+7))


# In[ ]:






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

int main(){
	string s;cin>>s;
  	reverse(s.begin(),s.end());
  	int i=0;
  	while(s.size()>i){
    	if(s.substr(i,7)=="remaerd")     { i+=7;continue;}
      	else if(s.substr(i,6)=="resare") {i+=6;continue;}
      	else if(s.substr(i,5)=="esare")  { i+=5;continue;}
      	else if(s.substr(i,5)=="maerd")  { i+=5;continue;}
        else{cout<<"NO"<<endl;return 0;}          
    }
  	cout<<"YES"<<endl;
}    


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int max = 0;
  int min = INT_MAX;
  cin >> N;
  int tmp;
  for(int i = 0; i < N; i++){
    cin >> tmp;
    if(max < tmp) max = tmp;
    if(min > tmp) min = tmp;
  }
  cout << max - min << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        int ans = Math.max(A*B,C*D);
        System.out.println(ans);
    }
}

Measured memory_bytes: 9684
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#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;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    
    int ans=0;
    int i;
    for(i=1; i<=n; i++) {
        int curr=i;
        int cnt=0;
        while(curr) {
            curr/=10;
            cnt++;
        }
        if(cnt%2) {
            ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

struct node{
	int u,v,w;
};
node a[65];

int main()
{
	int L,n=1,s=0;
	scanf("%d",&L);
	int t=1,m=--L;
	while(t<=m){
		a[s++]=node{n,n+1,t};
		a[s++]=node{n,n+1,0};
		++n;
		m-=t;	t<<=1;
	}
	if(m){
		int xi=t,p=t/2,k=n-1;
		while(k>=1){
			if(p<=m){
				a[s++]=node{k,n,xi};
				xi+=p;	m-=p;
			}
			p/=2;	--k;
		}
	}
	printf("%d %d\n",n,s);
	for(int i=0;i<s;++i)
		printf("%d %d %d\n",a[i].u,a[i].v,a[i].w);
	
	return 0;
}

Measured memory_bytes: 256
def main():
    MAX = 10 ** 18
    n = int(input())
    a = list(map(int,input().split()))
    a.sort(reverse=True)
    ans = 1
    if a[-1] == 0:
        ans = 0
    else:
        for i in range(n):
            ans *= a[i]
            if ans > MAX:
                ans = -1
                break
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  string s;
  ll a, b;
  cin >> a >> b;
  
  //vector<ll> a(n);  rep(i, 0, n) cin >> a[i];
  
  cout << a*b << "\n";
  
  //cout << (  ?"Yes" :"No") << "\n";

}

Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int main() {
    
    string strOdd;
    string strEven;

    
    cin >> strOdd >> strEven;

    //三項演算子
    int len = (int)(strOdd.length() >= strEven.length()) ? (int)strOdd.length() : (int)strEven.length();
    
    string str;
    for(int i=0;i < len ;i++){

        if(strOdd.length() > i){
            str.push_back(strOdd[i]);
        }
        if(strEven.length() > i){
            str.push_back(strEven[i]);
        }
        
    }

    cout << str << endl;
    

    return 0;
}



Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

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


Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] val = new int[w];
		for (int i = 0; i < w; i++) {
			val[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1;
			int tmp = val[a];
			val[a] = val[b];
			val[b] = tmp;
		}
		for (int i = 0; i < w; i++) {
			System.out.println(val[i]);
		}
		sc.close();
	}

}



Measured memory_bytes: 26088
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    ll x;
    cin >> x;
    ll ans = x / 11 * 2;

    if (x % 11 == 0) {
    } else if (x % 11 <= 6) {
        ans++;
    } else {
        ans += 2;
    }

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

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int H = 0;
        int W = 0;
        int x = 0;
        int y = 0;
        
        while(true){
            H = sc.nextInt();
            W = sc.nextInt();
            
            if(H==0 && W ==0)break;
            for(x = 0; x < H; x++){
            for(y = 0; y < W; y++){
                if(x == 0 || x == H-1 || y == 0 || y == W-1){
                System.out.print("#");
                }else{
                    System.out.print(".");
                }
            }
            System.out.println("");
                
            }
            System.out.println("");
        }
    }
}



Measured memory_bytes: 34308
#include <string>
#include <iostream>

using namespace std;

int main()
{
	string n;
	int k;
	bool fb[10] = { false };

	cin >> n >> k;
	for (int i = 0; i < k; ++i) {
		int f;
		cin >> f;
		fb[f] = true;
	}

	int nl = n.size();
	for (int i = 0; i < nl; ++i) {
		int d = n[i] - '0';
		if (!fb[d]) continue;

		while (d <= 9 && fb[d]) ++d;
		while (d > 9) {
			--i;
			d = (i < 0 ? 0 : n[i] - '0') + 1;
			while (d <= 9 && fb[d]) ++d;
		}

		char fc = '0' + d;
		if (i < 0) cout << fc; else n[i] = fc;
		
		d = 0; while (d <= 9 && fb[d]) ++d;
		fc = '0' + d;
		for (++i; i < nl; ++i) n[i] = fc;
	}
	cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <math.h>
using namespace std;
int main(){
    int n,d,ans=0;
    long long a;
    double b;
    cin>>n>>d;
    int A[20][20];
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++) cin>>A[i][j];
    }


    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            a=0;
            for(int k=0;k<d;k++) a+=(A[i][k]-A[j][k])*(A[i][k]-A[j][k]);
            b=sqrt((double)a);
            if(b-(int)b==0) ans++;
        }
    }

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

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
	int n,p,x,y; int t[16][16];
	while(scanf("%d",&n), n)
	{
		memset(t,0,sizeof(t));

		p=0; x=n/2; y=n/2+1;
		while(p<n*n)
		{
			x=(x+n)%n;
			y=(y+n)%n;

			if(!t[y][x])
			{
				t[y][x]=++p;
				y++;
				x++;
			}
			else
			{
				y++;
				x--;
			}
		}

		for(y=0; y<n; y++)
		{
			for(x=0; x<n; x++)
			{
				printf("%4d",t[y][x]);
			}
			printf("\n");
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <random>
#include <cassert>
#include <numeric>
#define ll long long int
#define LL unsigned long long
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;



int main() {
    string o,e; cin >> o >> e;
    int n = o.size(), m = e.size();
    vector<char> ans(n+m);
    rep(i,n) ans[i*2] = o[i];
    rep(i,m) ans[i*2+1] = e[i];

    for(char i : ans) cout << i;
}


Measured memory_bytes: 3584
#include <stdio.h>

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

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
double pi=acos(-1);
typedef long long ll;
const double ex=1e-5;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const int INF=0x3f3f3f3f,max_n=200005;
const int mod=1e9+7;
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}

int r1,c1,r2,c2;
typedef long long ll;
long long inv(int i,int p)
{
	if(i==1)return 1;
	return (p-p/i)*inv(p%i,p)%p;
}
ll jiecheng[2000050]={1};
ll g(int n,int m,int p)
{
	int fenzi=jiecheng[n+m]%p;
	int fenmu=((ll)jiecheng[m]%p*jiecheng[n]%p)%p;
	ll niyuan=inv(fenmu,p);
	return (ll)fenzi*niyuan%p;
}
ll f(int n,int m,int p)
{
	if(n<0)
	{
		return 0;
	}
	if(n+m<=p)
	{
		return g(n,m,p);
	}
	if(m==0)return 1;
	if(m==1)return (n+m)%p;
	else if(n==0)return 1;
	else
	{
		int a1=f((n+m)/p-m/p,m/p,p)%p;
		int a2=f((n+m)%p-m%p,m%p,p)%p;
		return (ll)a1*a2%p;
	}
}
ll g(int r,int c)
{
	return f(c+1,r,mod)+f(c,r+1,mod)-1;
}
signed main()
{
	for(int i=1;i<=2000005;i++)
	{
		jiecheng[i]=(ll)jiecheng[i-1]*i%mod;
	}
	cin>>r1>>c1>>r2>>c2;
	cout<<((g(r2,c2)%mod-g(r2,c1-1)%mod-g(r1-1,c2)%mod+g(r1-1,c1-1)%mod)%mod+mod)%mod;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for (int i = 0; i < r; i++)
#define isc(n) scanf("%d", &n)

int main() {
  int N;
  scanf("%d", &N);
  int count = 0;
  for (int i = 0, m = N, P; i < N; i++) {
    scanf("%d", &P);
    if (P <= m) {
      m = P;
      count++;
    }
  }
  printf("%d", count);
  return 0;
}


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

using I = long long;
const I MOD = 1e9+7;

std::vector<I> prime_factor(I n) {
  std::vector<I> prime;
  for(I i = 2; i <= n / i; ++i) {
    prime.emplace_back(0);
    for(; n % i == 0; n /= i) ++prime.back();
    if(!prime.back()) prime.pop_back();
  }
  if(n != 1) prime.emplace_back(1);
  return prime;
}

int main() {
  I N, M;
  cin >> N >> M;

  I res = 1;
  for(auto p: prime_factor(M)) {
    vector<vector<I>> dp(N+1, vector<I>(p+1));
    dp[0][p] = 1;
    for(auto i=0; i<N; ++i) {
      for(auto j=0; j<=p; ++j) {
        for(auto k=0; k<=j; ++k) (dp[i+1][k] += dp[i][j]) %= MOD;
      }
    }
    (res *= dp[N][0]) %= MOD;
  }
  cout << res << endl;
}


Measured memory_bytes: 27520
#include<bits/stdc++.h>
using namespace std;
int n;
char a[300];
int main(){
	cin>>n;
	cin>>a;
	int opt=1;
	if(n%2==1) cout<<"No"<<endl;
	else{
		for(int i=0;i<(n/2);i++){
			if(a[i]!=a[i+n/2]){
				opt=0;
				break;
			}
		}
		if(opt==1) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
void solving(){
int k,a,b;
cin>>k>>a>>b;
int fl=1;
for(int i=a;i<=b;i++){
    if(i%k==0){fl=0;cout<<"OK\n";break;}
}
if(fl==1)cout<<"NG\n";
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
 
    solving();
    return 0;
}

Measured memory_bytes: 3696