akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

struct Card{
  char suit;
  char value;
};

void bubble(struct Card A[], int n)
{
  int i, j;
  struct Card t;
  for ( i = 0; i < n; i++ )
  {
    for ( j = n-1; j >= i+1; j-- )
    {
      if ( A[j].value < A[j-1].value )
      {
	t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(struct Card A[], int n)
{
  int i, j, mini;
  struct Card t;
  for ( i = 0; i < n; i++ )
  {
    mini = i;
    for ( j = i; j < n; j++ ){
      if ( A[j].value < A[mini].value ) mini = j;
    }
    t = A[i]; A[i] = A[mini]; A[mini] = t;
  }
}

void print(struct Card A[], int n)
{
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i ) printf(" ");
    printf("%c%c", A[i].suit, A[i].value);
  }
  printf("\n");
}

int isStable(struct Card C1[], struct Card C2[], int n)
{
  int i;
  for ( i = 0; i < n; i++ )
  {
    if ( C1[i].suit != C2[i].suit ) return 0;
  }
  return 1;
}

int main()
{
  struct Card C1[101], C2[101];
  int n, i;
  char ch;

  scanf("%d\n", &n);
  for ( i = 0; i < n; i++ )
  {
    scanf("%c%c ", &C1[i].suit, &C1[i].value);
  }

  for ( i = 0; i < n; i++ ) C2[i] = C1[i];

  bubble(C1, n);
  selection(C2, n);

  print(C1, n);
  printf("Stable\n");
  print(C2, n);
  if ( isStable(C1, C2, n) )
  {
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}



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

using namespace std;

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

bool SameRatio(int a1, int b1, int a2, int b2)
{
    auto gcd1 = Gcd(a1, b1);
    auto gcd2 = Gcd(a2, b2);

    a1 /= gcd1;
    b1 /= gcd1;

    a2 /= gcd2;
    b2 /= gcd2;

    return a1 == a2 && b1 == b2;
}

int main()
{
    int n, ratio_a, ratio_b;
    cin >> n >> ratio_a >> ratio_b;

    constexpr int kInf = (1 << 25);
    const int kGramLimit = 10 * (n + 1);

    vector<vector<int>> min_cost(kGramLimit + 1, vector<int>(kGramLimit + 1, kInf));
    min_cost[0][0] = 0;

    for (auto i = 0; i < n; i += 1) {
        int grams_a, grams_b, cost;
        cin >> grams_a >> grams_b >> cost;

        for (auto a = kGramLimit - grams_a; a >= 0; a -= 1) {
            for (auto b = kGramLimit - grams_b; b >= 0; b -= 1) {
                auto next_a = a + grams_a;
                auto next_b = b + grams_b;
                min_cost[next_a][next_b] = min(min_cost[next_a][next_b],
                                               min_cost[a][b] + cost);
            }
        }
    }

    auto res = kInf;
    for (auto a = 1; a <= kGramLimit; a += 1) {
        for (auto b = 1; b <= kGramLimit; b += 1) {
            if (min_cost[a][b] < kInf && SameRatio(ratio_a, ratio_b, a, b)) {
                res = min(res, min_cost[a][b]);
            }
        }
    }

    if (res >= kInf) {
        res = -1;
    }

    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 896
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

suf = []
insuf = []
S1 = 0
S2 = 0

for i in range(N):
    if A[i] < B[i]:
        insuf.append(B[i]-A[i])
    elif A[i] > B[i]:
        suf.append(A[i]-B[i])

if len(insuf) == 0:
    print(0)
    exit()
else:
    S1 = sum(insuf)
    suf.sort(reverse=True)
    for i in range(len(suf)):
        S2 += suf[i]
        if S2 >= S1:
            ans = len(insuf) + i + 1
            break

    if S2 < S1:
        ans = -1

    print(ans)

Measured memory_bytes: 19508
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>

#define INF 1000000000
#define REP(i,n) for(int i=0; i<n; i++)
#define REP_R(i,n,m) for(int i=m; i<n; i++)
#define MAX 50

using namespace std;

int h,w;
char grid[MAX + 5][MAX + 5];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
bool flag = false;
int cnt = 0;

int main() {
  memset(grid, '.', sizeof(grid));
  cin >> h >> w;
  for (int i=1; i<=h; i++) {
    for (int j=1; j<=w; j++) {
      cin >> grid[i][j];
    }
  }

  for (int i=1; i<=h; i++) {
    for (int j=1; j<=w; j++) {
      if (grid[i][j] == '#') {
        if (grid[i-1][j] == '.' && grid[i][j-1] == '.' && grid[i+1][j] == '.' && grid[i][j+1] == '.') {
          printf("No\n");
          return 0;
        }
      }
    }
  }

  printf("Yes\n");

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
//コピペするとこ
void print(vector<int> vec){
    int n = SZ(vec) ;
    REP(i,n){
        cout << vec.at(i) ;
        if(i!=n-1){
            cout <<" " ;
        }
    }
    cout <<endl ;
}


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

int i, j;

int main()
{
    int n ;
    cin >> n ;
    vector<int> v(n) ;
    REP(i,n){
        cin >> v.at(i) ;
    }
    for(i=1;i<n;i++){
        print(v) ;
        j = i-1 ;
        int vv = v.at(i) ;
        while(j>=0 && vv<=v.at(j) ){
            v.at(j+1) = v.at(j) ;
            j-- ;
        }
        v.at(j+1) = vv ;
    }
    print(v) ;
    
    

  return 0 ;
}




Measured memory_bytes: 3108
n, l = map(int, input().split())
A = list(map(int, input().split()))
for i in range(n-1):
  if A[i]+A[i+1] >= l:
    f = i+1
    break
else:
  print("Impossible")
  exit()
print("Possible")
for i in range(1, f):
  print(i)
for i in range(n-1, f, -1):
  print(i)
print(f)

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

int main(){
  vector<vector<int>> c(3, vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> c.at(i).at(j);
    }
  }
  
  vector<int> a(3);
  vector<int> b(3);
  for(int i=0;i<3;i++){
    b.at(i) = c.at(0).at(i);
  }
  a.at(0) = 0;
  for(int i=1;i<3;i++){
    a.at(i) = c.at(i).at(0) - b.at(0);
  }
  
  int k = 0;
  
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      if(c.at(i).at(j) != a.at(i) + b.at(j)){
        k++;
      }
    }
  }
  
  if(k == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll ;
using namespace std;
int main() {
  int n;
  cin >> n;
  std::map<char, ll> v = {{'M',0},{'A',0},{'R',0},{'C',0},{'H',0}};
  std::string march = "MARCH";
    
  for (int i = 0; i < n; ++i) {
    string a;
    cin >> a;
    char ia = a[0];
    if (v.find(ia) != v.end()) {
        v[ia] += 1;
    }
   } 
   ll count = 0;
   for (int i = 0; i < 3; ++i) {
     for (int j = i+1; j < 4; ++j) {
       for (int k = j+1; k < 5; ++k) {
         count += v[march[i]] * v[march[j]] * v[march[k]];
       } 
     }
   }
   cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let h = line[0];
    let w = line[1];
    let n = line[2];
    let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let y = line[0];
    let x = line[1];
    let s: Vec<char> = read_line().trim().chars().collect();
    let t: Vec<char> = read_line().trim().chars().collect();

    let mut lx = 1;
    let mut rx = w;
    let mut ly = 1;
    let mut ry = h;
    let mut ans = true;
    for i in (0..n).rev() {
        match t[i] {
            'L' => { rx = cmp::min(w, rx+1); },
            'R' => { lx = cmp::max(1, lx-1); },
            'U' => { ry = cmp::min(h, ry+1); },
            'D' => { ly = cmp::max(1, ly-1); },
            _ => {},
        }
        match s[i] {
            'L' => { lx += 1; },
            'R' => { rx -= 1; },
            'U' => { ly += 1; },
            'D' => { ry -= 1; },
            _ => {},
        }
        if lx > rx || ly > ry {
            ans = false;
            break;
        }
    }

    if ans && lx <= x && x <= rx && ly <= y && y <= ry {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VB vector<bool>
#define VVL vector<vector<ll>>

int main(){
    ll N, M;
    cin >> N >> M;
    VL k(M);
    VVL s(M, VL(N,0));
    rep(i,0,M){
        cin >> k[i];
        rep(j,0,k[i]){
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    VL p(M);
    rep(i,0,M)cin >> p[i];
    
    ll ans = 0;
    rep(bit, 0, 1LL<<N){
        VB sw(N, false);
        rep(i, 0, N){
            if(bit & 1LL<<i) sw[i] = true;
        }
        ll c = 0;
        rep(i, 0, M){
            ll ctmp = 0;
            rep(j, 0, k[i]){
                if(sw[s[i][j]]) ctmp++;
            }
            if(ctmp%2 == p[i]) c++;
        }
        if(c == M) ans++;
    }
 	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#define _CRT_SECURE_NO_WARNINGS

#include <vector>
#include <iostream>
#include <string>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <queue>
#include <deque>
#include <math.h>
#include <cmath>
#include <stack>
#include <algorithm>
#include <list>
#include <array>
#include <valarray>
#include <unordered_map>
#include <cassert>
#include <random>
#include <cstring>
#include <sstream>

using namespace std;

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

#define X first
#define Y second
#define all(a) a.begin(), a.end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)

double eps = 1e-5;
const int INF = 2e9 + 7;
const li LINF = 9e18 + 7;


int main() {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif

	li x, y;
	cin >> x >> y;

	if (x % y == 0) {
		cout << -1 << endl;
		return 0;
	}

	cout << x * (y - 1) << endl;
}

Measured memory_bytes: 764
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int64 n;
  vector<int64> a(5);
  cin >> n;
  int64 ret = 5, best = 0;
  for (int i = 0; i < 5; ++i) {
    cin >> a[i];
    best = max(best, (n + a[i] - 1) / a[i] - 1);
  }
  ret += best;
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif


using namespace std;
#define M 1000000001
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repb(i,a,b) for(int i=a;i>=b;--i)
#define repv(arr)  for(auto it=arr[i].begin();it!=arr[i].end();++it)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define vc vector<char>
#define sz(a) (int)a.size()
#define ssortA(arr)   stable_sort(arr.begin(),arr.end())
#define ssortB(arr)   stable_sort(arr.begin(),arr.end(),greater<int>());
#define pii pair<int,int>
#define pli pair<long long,int>
#define pll pair<long long,long long>
#define fi first
#define se second
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define mp make_pair
#define endl "\n" 
#define LCM(a,b) boost::math::lcm(a,b)
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define check(ds,x) (int)(ds.find(x)!=ds.end()?1:0)
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s;
    int n;
    cin>>n;
    cin>>s;
    int r=0,w=0;
    rep(i,0,sz(s)){
        if(s[i]=='W')++w;
        else{
            ++r;
        }
    }
    int count=0;
    rep(i,0,r){
        if(s[i]!='R')++count;
    }
    cout<<count<<endl;
}

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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;
#define inf 999999999 

main(){
  string s; cin >> s;
  s[3]='8';
  cout << s << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int i,a,b,c,cnt=0;
	scanf("%d%d%d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if(c%i==0)cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	int a, b, c, d; cin >> a >> b >> c >> d;
	int t = min(b, d) - max(a, c);
	if(0 < t) cout << t << endl;
	else cout << 0 << endl;
}


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

int main() {
  int N,odd;
  double ans = 0.0;

  cin >> N;
  odd = (N+1)/2;

  //doubleにキャストして小数点6桁まで表示する(標準でdoubleは小数点6桁まで表示可能)
  ans = (double)odd / N;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <array>

int main(int argc, char const* argv[])
{
    int a, b;
    std::cin >> a >> b;;

    if(a >= 13)
    {
        std::cout << b << std::endl;
    }
    if(12 >= a && a >= 6)
    {
        std::cout << b / 2 << std::endl;
    }
    if(5 >= a)
    {
        std::cout << 0 << std::endl;
    }
}


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

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int n;
vector<int> a, b, c;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int x;
		scanf("%d", &x);
		a.push_back(x);
	}
	for (int i = 0; i < n; ++i) {
		int x;
		scanf("%d", &x);
		b.push_back(x);
	}
	for (int i = 0; i < n; ++i) {
		int x;
		scanf("%d", &x);
		c.push_back(x);
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	ll ans = 0;
	for (int i: b) {
		int x = lower_bound(a.begin(), a.end(), i) - a.begin();
		int y = upper_bound(c.begin(), c.end(), i) - c.begin();
		y = c.size() - y;
		ans += ll(x) * y;
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 1784
#include<cstdio>
int d,n,s=0,a;
int main(){
	scanf("%d%d",&d,&n);
	for(int i=1;i<=5000000;i++){
		int ss=0;
		int x=i;
		while(x%100==0&&x) x/=100,ss++;
		if(ss==d) s++;
		if(s==n) {
			a=i;break;
		}
	}
	printf("%d",a);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int a(int a,int b){return a+b;}
int b(int a,int b){return a-b;}
int c(int a,int b){return a*b;}
int d(int a,int b){return a/b;}
int main(){
  int n,m;
  char op;
  while(cin >> n >> op >> m&& op!='?'){
    if(op=='+')cout << a(n,m) << endl;
    else if(op=='-')cout << b(n,m) << endl;
    else if(op=='*')cout << c(n,m) << endl;
    else if(op=='/')cout << d(n,m) << endl;
  }
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    int d[n];
    for(int i=0;i < n;i++)cin >> d[i];
    sort(d,d+n);
    cout << d[n/2] - d[(n/2)-1] << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    int n, k;
    string s;
    cin >> n >> k >> s;
    s[k-1] -= 'A' - 'a';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-9;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#endif
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
double a,b,x;
const double pi=3.1415926535897932384626;
double mytan(double deg){
	return tan(deg/180.0*pi);
}
int main(){
	cin>>a>>b>>x;
	x/=a;
	if(x>=0.5*a*b){
		double tmp=(a*b-x)*2.0/a;
		double L=0.0,R=90.0;
		while(R-L>eps){
			double mid=(L+R)/2.0;
			if(mytan(mid)<tmp/a)L=mid;
			else R=mid;
		}
		printf("%.12lf",R);
	}else{
		double tmp=x*2.0/b;
		double L=0.0,R=90.0;
		while(R-L>eps){
			double mid=(L+R)/2.0;
			if(mytan(mid)<tmp/b)L=mid;
			else R=mid;
		}
		printf("%.12lf",90.0-R);
	}
	return 0;
}

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

int main()
{
    int n,a,b,c,d,i,j,x;
    char s[500][500];
    while(~scanf("%d %d",&a,&b))
    {

        getchar();
        for(i=1; i<=a; i++)
        {
            scanf("%s",s[i]);
        }
        for(i=1; i<=a; i++)
        {

            printf("%s",s[i]);
            printf("\n");
            printf("%s",s[i]);

            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 1760
// https://beta.atcoder.jp/contests/abc079
// status:

#define SUBMIT

#include <bits/stdc++.h>
using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const ui64 MAX_N = 86;
ui64 lu[MAX_N + 1];

void init_lucas_number() {
    lu[0] = 2;
    lu[1] = 1;
    for (int i = 2; i <= MAX_N; ++i) lu[i] = lu[i - 1] + lu[i - 2];
}

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    stringstream stream(R"(5
)");
#endif
    init_lucas_number();
    int N;
    stream >> N;
    cout << lu[N] << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())

def yakusu(x):
    xx = 2
    y = []
    while xx**2 < x:
        if x%xx == 0:
            y.append(xx)
            y.append(x//xx)
        xx += 1
    if xx**2 == x:
        y.append(xx)
    y.append(x)
    return y
    
if n == 2:
    ans = 0
else:
    ans = len(yakusu(n-1))

for i in yakusu(n):
    nn = n
    while True:
        if nn%i == 0:
            nn = nn//i
        else:
            break
    if nn%i == 1:
        ans += 1

print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

vector<int> dist(200010,0);//ノード間距離

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

  int dist_max = 0;
  rep(i,n) {
    dist_max = max(dist_max,dist[i]);}
  cout << k-dist_max << endl;
}

Measured memory_bytes: 1792
def bubbleSort( nums ):
	cnt = 0
	for i in range( 0, len( nums ) ):
		for j in range( len( nums )-1 , i, -1 ):
			if nums[j] < nums[ j-1 ]:
				nums[j], nums[ j-1 ] = nums[ j-1 ], nums[j]
				cnt += 1

	print( " ".join( map( str, nums) ) )
	print( cnt )


n = int( input( ) )
nums = [ int( val ) for val in input( ).split( " " ) ]
bubbleSort( nums )

Measured memory_bytes: 6724
main2(){
  int x,y,w,h,r,n,a,b;
  scanf("%d%d%d%d",&x,&y,&w,&h);
  for(r=0,scanf("%d",&n);n;n--){
    scanf("%d%d",&a,&b);
    if(x<=a&&a<=x+w && y<=b&&b<=y+h)r++;
  }
  printf("%d\n",r);
}
main(n){for(scanf("%d",&n);n;n--)main2();exit(0);}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<string.h>
using namespace std;
int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int ms;
	int big=max(max(a,b),c);
	for(int i=0;i<k;i++)
	{
		ms=big*2+(a+b+c-max(max(a,b),c));
		big*=2;
	}
	cout<<ms;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define MOD 1000000007

int main(){
  int A,B,ans=0;
  scanf("%d%d",&A,&B);
  if(A>B)ans=A*2-1;
  else if(A==B)ans=A*2;
  else ans=B*2-1;
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

int main(){
	ll i, j;
	ll N, M;
	cin >> N >> M;
	vll A(N);
	multiset<ll> S;
	for (auto &e : A) {
		cin >> e;
		S.insert(e);
	}

	for (i = 0; i < M; i++){
		multiset<ll>::iterator smaxit = S.end();
		smaxit--;
		ll smaxval = *smaxit;
		S.erase(smaxit);
		S.insert(smaxval / 2);
	}
	ll ans = 0;
	for (auto e : S){
		ans += e;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define optimize ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pii pair<int, int>
#define ll long long
#define INF 1000000000
#define MAXN 200020
#define MAXL 22

using namespace std;


int main(int argc, char const *argv[])
{
	optimize;


	int A, B;

	cin >> A >> B;

	int r = max(0, A - (2 * B));

	cout << r << endl;


	return 0;	
} 	

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
for i in range(n,1000):
    if len(set(str(i))) == 1:
        print(i)
        break
    

Measured memory_bytes: 10340
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
using namespace std;

int main()
{
		int n;
		double head;
		vector<double> dp(3005);
		dp[0] = 1;
		scanf("%d", &n);
		for (int i = 0; i < n; i++) {
			scanf("%lf", &head);
			for (int j = i + 1; j >= 0; j--) {
				dp[j] = (j == 0 ? 0 : dp[j - 1] * head) + (1 - head) * dp[j];
			}

		}
		double ans = 0.0;
		for (int i = 0; i < n + 1; i++) {
			int tail = n - i;
			if (i > tail) ans += dp[i];
		}

		printf("%.10lf\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;

int H, W, M;
int h[300005], w[300005];

set< pair<int, int >> S;

int C[300005];
int D[300005];

set < pair<int, int>> G;

int main(void) {
	cin >> H >> W >> M;
	for (int i = 1; i <= M; i++) {
		cin >> h[i] >> w[i];
	}

	int ans = 0;

	for (int i = 1; i <= M; i++) {
		C[h[i]]++; D[w[i]]++; G.insert(make_pair(h[i], w[i]));
	}

	for (int i = 1; i <= H; i++) {
		S.insert(make_pair(-C[i], i));
	}

	pair<int, int> P;

	for (int j = 1; j <= W; j++) {
		int tmp = D[j];
		//cout << "j= " << j << endl;
		for (auto it = S.begin(); it != S.end(); it++) {
			int num = -(*it).first;
			P.first = (*it).second; P.second = j;
			//cout << "num= " << num << " P.first= " << P.first << " P.second= " << P.second << endl;
			if (G.find(P) != G.end()) { ans = max(ans, num + D[j] - 1); }
			else { ans = max(ans, num + D[j]); break; }

		}
		
	}

	cout << ans << endl;

	//for (auto y : S) { cout << -y.first<<" "<<y.second << endl; }

	return 0;
}

Measured memory_bytes: 36376
s = input()
small = list("abcdefghijklmnopqrstuvwxyz")


if s[0] == "A" and s[2:-1].count("C") == 1:
	i = s.index("C")
	for j in range(1, len(s)):
		if j == i:
			continue
		else:
			if s[j] not in small:
				print("WA")
				break
	else:
		print("AC")
else:
	print("WA")


Measured memory_bytes: 38384
#include<stdio.h>
int main(){
    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");
    return 0;
}
    



Measured memory_bytes: 2052
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define wuyt main
typedef long long ll;
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
//#define getchar()(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();
if(c == '-')Nig = -1,c = getchar();
while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
return Nig*x;}
#define read read()
const ll inf = 1e15;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;
int num[maxn];
map<string,int>mp;
map<string,int>::iterator it;
int main()
{
    ios_base::sync_with_stdio(false);
    /**int n=read;
    int flag=1;
    for(int i=1;i<=n;i++)
    {
        num[i]=read;
        if(num[i]%2==0){
            if(num[i]%3!=0&&num[i]%5!=0)
                flag=0;
        }
    }
    if(flag==0) printf("DENIED\n");
    if(flag) printf("APPROVED\n");**/
        /**
        int n=read;
    string ss;
    map<string,int>mp;
    for(int i=0;i<n;i++)
    {
        ///scanf("%s",ss);
        cin>>ss;
        mp[ss]++;
    }
    int cnt=0;
    for(auto& v:mp) cnt=max(cnt,v.second);
    for(auto& v:mp){
        if(v.second==cnt)
            ///cout<<v.first<<endl;
            printf("%s\n",v.first);
    }
    ll n;
    ios_base::sync_with_stdio(false);
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        ///scanf("%s",ss);
        ///getchar();
        string ss;
        cin>>ss;
        mp[ss]++;
    }
    int maxx=-1;
    for(const auto& x : mp){
        int temp=x.second;
        if(temp>maxx) maxx=temp;
    }
    for(auto it=mp.begin();it!=mp.end();it++){
        if(it->second==maxx)
            ///cout<<it->first<<endl;
            printf("%s\n",it->first);
    }**/
    int n;
    cin>>n;
    int maxx=0;
    for(int i=1;i<=n;i++)
    {
        string s;
        ///scanf("%s",&s);
        cin>>s;
        mp[s]++;
        maxx=max(maxx,mp[s]);
    }
    for(auto x:mp)
        if(x.second==maxx)
            cout<<x.first<<endl;
	return 0;
}


Measured memory_bytes: 23808
#!/usr/bin/perl
use sort 'stable';
use Math::Trig;

my ($a,$b,$h,$m) = map { $_ - 0 } split(/\s+/,scalar(<STDIN>));

my $dig1 = $h * (2 * pi)/12 + $m * (2 * pi)/(12*60);
my $dig2 = $m * (2 * pi)/60;

my ($x1,$y1) = ( $a * cos($dig1), $a * sin($dig1) );
my ($x2,$y2) = ( $b * cos($dig2), $b * sin($dig2) );

my $dist = sqrt( ( ($x1 - $x2) ** 2 ) + ( ($y1 - $y2) ** 2 ) );
print "$dist\n";








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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> a(H);
  rep(i,H) cin >> a[i];
  vector<bool> row(H);
  vector<bool> column(W);
  
  rep(i, H) {
    rep(j, W) {
      if (a[i][j]=='#') {
        row[i]=true;
        column[j]=true;
      }
    }
  }
  
  rep(i, H) {
    if (row[i]) {
      rep(j, W) {
        if (column[j]) cout << a[i][j];
      }
      cout << endl;
    }
  }
}


Measured memory_bytes: 3640
#include <stdio.h>

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

Measured memory_bytes: 128
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

const ll MOD = 1e9 + 7;
ll n;
vll a;

ll bin_exp(ll b, ll e, ll mod) {
    ll ret = 1;
    while (e > 0) {
        if (e & 1) {
            (ret *= b) %= mod;
        }
        (b *= b) %= mod;
        e >>= 1;
    }
    return ret;
}

int main() {
    fast_io; cout_precision;
    cin >> n;
    a.resize(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    if ((n & 1) && a[0] != 0) {
        cout << 0 << endl;
        return 0;
    }
    for (ll i = n & 1, v = i + 1; i < n; i += 2, v += 2) {
        if (a[i] != v || a[i + 1] != v) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << bin_exp(2, n >> 1, MOD) << endl;
}

Measured memory_bytes: 1024
n,a,b = gets.chomp.split(" ").map(&:to_i)
x = gets.chomp.split(" ").map(&:to_i)
border = b/a
now = x[0]
mp = 0
(n-1).times do |i|
  if x[i+1] - now > border
    mp += b
    now = x[i+1]
  else
    mp += (x[i+1] - now) * a
    now = x[i+1]
  end
end
puts mp

Measured memory_bytes: 21792
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var one = cin.ReadLine.Split(' ');
            var N = int.Parse(one[0]);
            var M = long.Parse(one[1]);

            long result = 0;
            List<List<long>> set = new List<List<long>>();
            for (int i = 0; i < N; i++)
            {
                List<long> setIn = new List<long>();
                var two = cin.ReadLine.Split(' ');
                setIn.Add(long.Parse(two[0]));
                setIn.Add(long.Parse(two[1]));
                set.Add(setIn);
            }
            set = set.OrderBy(x => x[0]).ToList();
            foreach (var item in set)
            {
                if (M == 0)
                {
                    break;
                }
                if (M - item[1] > 0)
                {
                    result += (item[0] * item[1]);
                    M -= item[1];
                }
                else
                {
                    result += (item[0] * M);
                    M = 0;
                }
            }
            Console.Write(result);
        }

    }
    public class deci
    {
        public bool IsFinish { get; set; } = false;
        public int Len { get; set; }
    }
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 35248
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
 
//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;
 
const double pi = acos (-1.0);
const double eps = 1e-9;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, a, b;
vector <int> ans;

inline void boost () {
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}
 
inline void Solve () {
   cin >> n >> a >> b;
   if (!(a + b - 1 <= n && n <= a * b)) cout << -1, exit (0);
   for (int i = a; i >= 1; i --) ans.pb (i);
   if (b != 1) {
      int len = (n - a) / (b - 1);
      int ost = (n - a) % (b - 1);
      int it = a + 1;
      for (int z = 1; z < b; z ++) {
         int kon = it + len - 1 + (ost > 0);
         it = kon + 1;
         for (int i = 1; i <= len + (ost > 0); i ++) ans.pb (kon --);
         ost --;
      }
   }
   reverse (all (ans));
   for (auto it : ans) cout << it << ' ';
}               
 
signed main () {                                       
  // #ifdef QWERTY
  //    freopen("input", "r", stdin);
   //#endif
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}                   

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

#define LL long long
LL sum;

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

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,a,b,c,d;
	cin >> n;	
	for(a=1;a<=n;a++)
		for(b=1;b<=n;b++)
			for(c=1;c<=n;c++)
				d=gcd(a,b),d=gcd(c,d),sum+=d;
	cout << sum << endl;	
	return 0;
}

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

#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)

int main()
{
	int N, D;
	int X[100][100];

	scanf("%d%d", &N,&D);

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < D; j++)
			scanf("%d", &X[i][j]);
	}

	int dis;
	int ans = 0;

	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			dis = 0;
			for (int k = 0; k < D; k++)
			{
				dis += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
			}

			for (int l = 1; l < 1000; l++)
			{
				if (l * l == dis)
					ans++;
			}
		}
	}
	printf("%d", ans);
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = vs[0];
            int w = vs[1];

            long[] dp = new long[100009];
            dp[0] = 0;
            for (int i = 1; i < dp.Length; i++)
            {
                dp[i] = w + 1;
            }
            for (int i = 0; i < n; i++)
            {
                long[] obj = Console.ReadLine().Split().Select(long.Parse).ToArray();
                for (int j = dp.Length - 1; j >= 0; j--)
                {
                    if (j - obj[1] >= 0)
                    {
                        dp[j] = Math.Min(dp[j], dp[j - obj[1]] + obj[0]);
                    }
                    else
                    {
                        dp[j] = Math.Min(dp[j], obj[0]);
                    }
                }
            }
            for (int i = dp.Length - 1; i >= 0; i--)
            {
                if (dp[i] <= w)
                {
                    Console.WriteLine(i);
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 13920
#include<bits/stdc++.h>
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define loop(i,m,n) for(lli i=m;i<=n;i++)
#define loopr(i,m,n) for(lli i=m;i>=n;i--)
#define pb push_back
#define vi vector<int>
#define ff first
#define ss second
#define ii pair<int,int>
#define vii vector<ii>
#define INF 1000000000
#define mod 1000000007
#define siz 1000001
#define endl "\n"
const double PI=3.14159265358979323846264338327950288419716939937510;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;

int main()
{
	lli a,b,c,d,e,f,g,h,ans;
	cin>>a>>b>>c>>d;
	e=a*c;
	f=a*d;
	g=b*c;
	h=b*d;
	ans=max(e,max(f,max(g,h)));
	cout<<ans<<endl;
    return 0;
}
/*
1 2 1 1

3 5 -4 -2

-1000000000 0 -1000000000 0
*/


Measured memory_bytes: 3644
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
const int mod=1000000007;
inline int ad(int x){return x>=mod?x-mod:x;}
inline int dec(int x){return x<0?x+mod:x;}
bool pd[610];
int top,sta[610],f[2][610][610];
bool cmp(int a,int b){return a>b;}
 main()
{
    //freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n=read(),cnt=0;
	for(int i=1;i<=n;i++)
	{
		int x=read(),y=read();
		if(x!=-1)pd[x]=true;if(y!=-1)pd[y]=true;
		if(x!=-1 && y!=-1)continue;
		cnt++;
		if(x!=-1)sta[++top]=x,cnt--;
		if(y!=-1)sta[++top]=y,cnt--;
	}
	for(int i=1;i<=2*n;i++)if(pd[i]==false)sta[++top]=i;
	sort(sta+1,sta+top+1,cmp);
	int now=0;f[now][0][0]=1;
	for(int i=1;i<=top;i++)
	{
		now^=1;memset(f[now],0,sizeof(f[now]));
		for(int j=0;j<i;j++)
		{
			for(int k=0;k<i-j;k++)
			{
				if(pd[sta[i]]==true)
				{
					f[now][j][k+1]=ad(f[now][j][k+1]+f[now^1][j][k]);
					if(j)f[now][j-1][k]=ad(f[now][j-1][k]+f[now^1][j][k]);
				}
				else
				{
					f[now][j+1][k]=ad(f[now][j+1][k]+f[now^1][j][k]);
					if(j)f[now][j-1][k]=ad(f[now][j-1][k]+f[now^1][j][k]);
					if(k)f[now][j][k-1]=ad(f[now][j][k-1]+1LL*f[now^1][j][k]*k%mod);
				}
			}
		}
	}
	int ans=f[now][0][0];
	for(int i=1;i<=cnt;i++)ans=1LL*ans*i%mod;
	pr2(ans);
	return 0;
}

Measured memory_bytes: 3072
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		String s = sc.next();
		int n = s.length();
		
		if (n == 2) {
			pr.println(s);
		} else {
			pr.println(new StringBuilder(s).reverse());
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 23508
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    while(true){
        int H, W;
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
}


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

long long A,B,C,T,ans;

void work()
{
	if(!(T&1)) ans=A-B;
	else ans=B-A;
	if(abs(ans)>1e18) puts("Unfair");
	cout<<ans<<endl;
}

void init()
{
	cin>>A>>B>>C>>T;
}

int main()
{
	init();
	work();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	bool operator<(const struct Info &arg) const{
		if(x != arg.x){
			return x < arg.x;
		}else{
			return y < arg.y;
		}
	}
	double x,y,r;
};

int N;
Info info[100001];

bool compare_y(Info left,Info right){

	return left.y < right.y;

}

double calc_dist(int a,int b){
	return sqrt((info[a].x-info[b].x)*(info[a].x-info[b].x)+(info[a].y-info[b].y)*(info[a].y-info[b].y))-(info[a].r+info[b].r);
}

double calc_y_dist(int a,int b){
	return (info[b].y-info[b].r)-(info[a].y+info[a].r);
}

double closest_pair(Info* array,int tmp_N){
	if(tmp_N <= 1)return DBL_MAX;

	int mid = tmp_N/2;

	double x = array[mid].x;
	double dist = min(closest_pair(array,mid),closest_pair(array+mid,tmp_N-mid));
	inplace_merge(array,array+mid,array+tmp_N,compare_y);

	vector<int> V;


	int left,right,m,search_left;

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

		for(int k = 0; k < min((int)V.size(),2); k++){
			dist = min(dist,calc_dist(V[V.size()-1-k],i));
		}

		V.push_back(i);
	}
	return dist;
}

void func(){

	for(int i = 0; i < N; i++){
		scanf("%lf %lf %lf",&info[i].r,&info[i].x,&info[i].y);
	}
	sort(info,info+N);

	printf("%.10lf\n",closest_pair(info,N));
}

int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 7008
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();

        for (int i=0; i<5; i++) {
            int input = sc.nextInt();
            list.add(input);
        }

        Collections.sort(list);

        int diff = list.get(4) - list.get(0);
        int k = sc.nextInt();

        if (diff <= k) {
            System.out.println("Yay!");
        } else {
            System.out.println(":(");
        }
    }
}

class Pair<T1,T2> {
    private T1 left;
    private T2 right;

    public Pair(T1 left, T2 right) {
        this.left = left;
        this.right = right;
    }

    public T1 getLeft() {
        return this.left;
    }

    public T2 getRight() {
        return this.right;
    }

    @Override
    public boolean equals(Object object) {
        Pair pair = (Pair)object;
        if (pair.getLeft().equals(this.getLeft())
                && pair.getRight().equals(this.getRight())) {
            return true;
        }
        return false;
    }
}


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

#define MOD (1000000007LL)

using namespace std;

int main(void){
    long long N, A, B;
    cin >> N >> A >> B;
    long long ans = 0;
    ans += (N / (A + B)) * A;
    N %= A + B;
    ans += min(N, A);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
        int main()
        {
            char S[10];
          
            scanf("%s",S);
            
            if(S[0]=='S') printf("Cloudy\n");
            else if(S[0]=='C') printf("Rainy\n");
            else printf("Sunny\n");
          
            return 0;
        }

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int a, b, c;
  cin >> a >> b >> c;
  REP(i,b+1) {
    if(a*i % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256