akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

const int maxn = 100;
string a[maxn];

int main() {
    #ifdef LOCAL
    assert(freopen("a.in", "r", stdin));
    #else
    #endif
    int n, m;
    cin >> n >> m;
    int c = 0;
    forn (i, n) {
        cin >> a[i];
        forn (j, m)
            c += a[i][j] == '#';
    }
    int y = 0;
    int k = 0;
    forn (x, n) {
        if (a[x][y] != '#') {
            cout << "Impossible\n";
            return 0;
        }
        ++k;
        while (y + 1 < m && a[x][y + 1] == '#')
            ++y, ++k;
    }
    if (y == m - 1 && k == c) {
        cout << "Possible\n";
        return 0;
    }
    cout << "Impossible\n";
}


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

int main()
{
    string s;
    cin >> s;
    int a,b,c,d,i;
    a = s.at(0)-'0';    b = s.at(1)-'0';
    c = s.at(2)-'0';    d = s.at(3)-'0';
    int sum = a;
    if(a+b+c+d == 7){
        cout << a << '+' << b << '+' << c << '+' << d << "=7" << endl;
    }else if(a+b+c-d == 7){
        cout << a << '+' << b << '+' << c << '-' << d << "=7" << endl;
    }else if(a+b-c+d == 7){
        cout << a << '+' << b << '-' << c << '+' << d << "=7" << endl;
    }else if(a-b+c+d == 7){
        cout << a << '-' << b << '+' << c << '+' << d << "=7" << endl;
    }else if(a+b-c-d == 7){
        cout << a << '+' << b << '-' << c << '-' << d << "=7" << endl;
    }else if(a-b+c-d == 7){
        cout << a << '-' << b << '+' << c << '-' << d << "=7" << endl;
    }else if(a-b-c+d == 7){
        cout << a << '-' << b << '-' << c << '+' << d << "=7" << endl;
    }else if(a-b-c-d == 7){
        cout << a << '-' << b << '-' << c << '-' << d << "=7" << endl;
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;

  set<string> ss;
  string s;
  char last;

  cin >> s;
  last = s[s.length() - 1];
  ss.insert(s);

  bool b = true;

  for (int i = 1; i < N; i++) {
    cin >> s;
    if (last != s[0]) {
      b = false;
    }
    last = s[s.length() - 1];
    ss.insert(s);
  }

  if (N != ss.size()) {
    b = false;
  }

  if (b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main() {string s;cin>>s;int f=1;
       for(int i=0;i<s.size();i++){
       if(i%2==1){if(s[i]=='R'){f=0;}}
                 else{if(s[i]=='L'){f=0;}}}
     if(f){cout<<"Yes"<<endl;}
     else{cout<<"No"<<endl;}
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author apurba_debnath
 */

#include <bits/stdc++.h>

#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl

using namespace std;

class ATakoyaki {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n, x, t, time = 0;
        in >> n >> x >> t;
        int tako = 0;
        while (tako < n) {
            time += t;
            tako += x;
        }
        out << time;
    }
};


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

    ATakoyaki solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);

    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {
  int N; string S; cin>>N>>S;
  vector<int> sum1(N+2,0);
  vector<int> sum2(N+2,0);
  for(int i = 0; i < S.length(); i++) {
    sum1[i+1] = sum1[i] + (S[i] == 'W' ? 1 : 0);
  }
  for(int i = S.length()-1; i >= 0; i--) {
    sum2[i+1] = sum2[i+2] + (S[i] == 'E' ? 1 : 0);
  }
  int ans = N*2;
  for(int i = 1; i <= S.length(); i++) {
    int tmp = sum1[i-1] + sum2[i+1];
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


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

class Main {
    public static void main(String[] args)throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int y = Integer.parseInt(st.nextToken());
        int x = Integer.parseInt(st.nextToken());
        long [][]numbers = new long[y][x];
        for(int i =0;i<y;i++){
            String line = br.readLine();
            for(int j =0;j<x;j++){
                if(line.charAt(j)=='#')
                    numbers[i][j]=0;
                else {
                    if(i==0&&j==0)
                        numbers[0][0]=1;
                    else if (i == 0)
                        numbers[i][j] = numbers[i][j - 1]%1000000007;
                    else if (j == 0)
                        numbers[i][j] = numbers[i - 1][j]%1000000007;
                    else
                        numbers[i][j] = (numbers[i - 1][j] + numbers[i][j - 1])%1000000007;
                }

            }
        }
        out.println(numbers[y-1][x-1]%1000000007);
        out.flush();
    }
}

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

int main(){
    int i , n , a , b , c , d , e , A , B , sum;
	cin>>n>>A>>B;
	sum = 0;
    for(int i = 1 ; i <= n ; i++){
		a = i / 10000;
		b = i % 10000 / 1000;
		c = i % 10000 % 1000 / 100;
		d = i % 10000 % 1000 % 100 / 10;
		e = i % 10000 % 1000 % 100 % 10;
		if(a + b + c + d + e >= A && a + b + c + d + e <= B) sum+=i;
    	}
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << max(A*B,C*D) << '\n';
}


Measured memory_bytes: 3584
#include"bits/stdc++.h"
using namespace std;

#define ll long long
#define INF INT_MAX/3
#define pi 2*acos(0.0)
#define eps 1e-14

const int MAX_N = (int)1e+3;
const int MAX_M = (int)1e+2;
int N;
char a[101];
int max_x;
void input()
{
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
}

void solve()
{
	int x = 0;
	max_x = 0;
	for (int i = 0; i < N; i++) {
		if (a[i] == 'I') {
			x++;
		}
		else {
			x--;
		}
		if (x > max_x) {
			max_x = x;
		}
	}
	cout << max_x << endl;
}
int main() {
	input();
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	int N;
	cin>>N;
    vector<unsigned int> a(N);
    for(int i=0; i<N; i++){
        cin>>a[i];
    }
    sort(a.begin(), a.end());

    int ans = 0;
    for(int i=0; i<N; i++){
        if(!a.empty()){
            unsigned int c = a.back();
            unsigned int b = pow(2, int(log2(c) + 1));
            unsigned int d = b - c;
            if(binary_search(a.begin(), a.end(), d)){
                auto l = lower_bound(a.begin(), a.end(), d);
                if(l != a.end() - 1){
                    ans++;
                    a.erase(l);
                }
            }
            a.pop_back();
        }
    }
	cout<<ans<<endl;

	return 0;
}

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


int main() {
  string S;
  cin >> S;
  if(S.at(0) == S.at(1) && S.at(1) == S.at(2)){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}


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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= (n); i += 2) {
    int cnt = 0;
    for (int j = 1; j <= n; j++)
      if (i % j == 0) cnt++;
    if (cnt == 8) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int K,A,B; cin >> K >>  A >> B;
    cout << (B/K * K >= A ? "OK" : "NG") << en;
    return 0;
}

Measured memory_bytes: 3652
#include <cstdio>

int main(){
    char s[3][11];
    scanf("%s %s %s",s[0],s[1],s[2]);
    for(int i = 0; i < 3; i++){
        s[i][0] = 'A' + (s[i][0] - 'a');
        printf("%c",s[i][0]);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const double EPS = 1e-8;
using vec = vector<double>;
using mat = vector<vec>;

// 連立方程式Ax=bを解く
// Aは正方行列を仮定
// 解無し、一意に定まらない : 長さ0のvector
vec gauss_jordan(const mat &A, const vec &b){
    int d = A.size();
    mat B(d, vec(d+1));
    rep(i,d){
        rep(j,d) B[i][j] = A[i][j];
        B[i][d] = b[i];
    }

    rep(i,d){
        int pivot = i;
        for(int j=i; j<d; ++j){
            if( abs(B[j][i]) > abs(B[pivot][i]) ) pivot = j;
        }
        swap(B[i], B[pivot]);

        // 解無し、一意に定まらない : 長さ0のvector
        if(abs(B[i][i]) < EPS) return vec();

        // 注目する変数の係数を1にする
        for(int j=i+1; j<=d; ++j) B[i][j] /= B[i][i];
        rep(j,d){
            if(i==j) continue;
            // j番目の式からi番目の変数を除去
            for(int k=i+1; k<=d; ++k) B[j][k] -= B[j][i]*B[i][k];
        }
    }

    vec ret(d);
    rep(i,d) ret[i] = B[i][d];
    return ret;
}

double f(const vec &a, double x){
    double ret = 0;
    rep(i,a.size()) ret += a[i]*pow(x,i);
    return ret;
}

int solve(int d){
    vector<double> v(d+3);
    rep(i,d+3) cin >>v[i];

    // 考慮しない2つを選択
    rep(i,d+3)rep(j,i){
        int row = 0;
        mat A(d+1,vec(d+1));
        vec b(d+1);

        rep(k,d+3){
            if(k==i || k==j) continue;

            rep(l,d+1) A[row][l] = pow(k,l);
            b[row] = v[k];
            ++row;
        }

        vec a = gauss_jordan(A,b);
        // printf(" %d %d\n", i,j);
        // dbg(a);
        if(a.size() > 0){
            int ct = 0;
            for(int idx:{i,j}){
                // printf(" %.10f %.10f  abs %.10f\n", f(a,idx), v[idx], abs(f(a,idx) - v[idx]));
                if( abs(f(a,idx) - v[idx]) > 1e-5 ) ++ct;
            }
            if(ct==1){
                if( abs(f(a,i) - v[i]) > 1e-5 ) return i;
                else return j;
            }
        }
    }
    assert(false);
    return -1;
}

int main(){
    int d;
    while(cin >>d,d) cout << solve(d) << endl;
    return 0;
}



Measured memory_bytes: 3392
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    VI v;
    int h, w;
    int n;
    cin >> h >> w >> n;
    REP(i, n){
        int a;
        cin >> a;
        REP(j, a) v.push_back(i + 1);
    }

    REP(i, h){
        REP(j, w){
            if(i % 2 == 0){
                cout << v[i * w + j] << " ";
            }else{
                cout << v[(i + 1) * w - j - 1] << " ";
            }
        }
        cout << "\n";
    }

    return 0;
}


Measured memory_bytes: 384
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  int A, B; std::cin >> A >> B;
  if (B%A == 0) std::cout << A + B << std::endl;
  else          std::cout << B - A << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        string str;
        vector<int>Point(n,0);
        int field=0;
        cin>>str;
        for(int i=0;i<100;i++){
            if(str[i]=='M')Point[i%n]++;
            else if(str[i]=='S'){
                field+=Point[i%n]+1;
                Point[i%n]=0;
            }
            else if(str[i]=='L'){
                Point[i%n]+=field+1;
                field=0;
            }
        }
        sort(Point.begin(),Point.end());
        for(int i=0;i<n;i++){
                cout<<Point[i]<<" ";
            }
            cout<<field<<endl;
    }
}

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

int int_sort(const void *a, const void *b){
  return *(int *)a - *(int *)b;
}

int main(){
  int n, k, i, ans, h[100010], c, hoge;
  scanf("%d %d", &n, &k);
  for(i=0; i<n; i++){
    scanf("%d", &h[i]);
  }

  qsort(h,n,sizeof(int),int_sort);

  ans=h[k-1]-h[0];
  for(i=1; i<=n-k; i++){
    c=h[k+i-1]-h[i];
    if(c<ans) ans = c;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 892
import java.util.*;

public class Main {
	
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if (c == 'B') {
				if (sb.length() > 0) {
					sb.deleteCharAt(sb.length() - 1);
				}
			} else {
				sb.append(c);
			}
		}
		System.out.println(sb);
	}
}


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

int searchIndex(vector<char> s, char item) { for (int i = 0; i < s.size(); ++i) if (s[i] == item) return i;}

int main() {
    vector<char> alphabets = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y',  'Z'};
    int n;
    string s;
    cin >> n >> s;
    for (char & i : s) {
        int index = searchIndex(alphabets, i);
        i = alphabets.at(index + n > 25 ? index + n - 26 : index + n);
    }
    cout << s << endl;
}


Measured memory_bytes: 3676
// m-solutions2020_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    REPN(i, K, N){
        if (A[i] > A[i-K]){
            print("Yes");
        } else {
            print("No");
        }
    }

    return 0;
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int n,k,c;
int l[MAXn],r[MAXn];
int main(){
    IOS();
    cin >> n >> k >> c;
    string s;
    cin >> s;
    int idx = 0;
    REP (i,n) {
        if (s[i] == 'o') {
            l[++idx] = i;
            if (idx >= k) break;
            i += c;
        }
    }
    idx = k;
    for (int i=n-1;i>=0;i--) {
        if (s[i] == 'o') {
            r[idx--] = i;
            if (idx <= 0) break;
            i -= c;
        }
    }

    REP1 (i,k) if (l[i] == r[i]) cout << l[i]+1 << endl;
}


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

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin>>n;
    vector<ll> data(n);
    for(ll i=0; i<n; i++)
        cin>>data[i];
    sort(data.begin(),data.end());
    cout<<data[n-1]-data[0]<<endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long     ll;
#define fr            first
#define sc            second
#define com(i,n)      for(int i=0;i<n;i++)
#define dom(i,n)      for(int i=1;i<=n;i++)
#define mom(i,n)      for(int i=n;i>=0;i--)
#define sortI(a,n)    sort(a,a+n)
#define sortD(a,n)    sort(a,a+n,greater<int>())
#define sortvi(a)     sort(a.begin(),a.end())
#define sortvd(a)     sort(a.begin(),a.end(),greater<int>())
#define sumall(a,x)   accumulate(a.begin(),a.end(),x)
#define pi            3.14159265358979323846264338327950
using namespace std;
map<ll,ll>mp;
int main()
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double ans,con,x,y;
    x=2.00*pi*(h/12.0+m/720.0);
    y=2.00*pi*(m/60.0);
    con=fabs(x-y);
    ans=sqrt(a*a+b*b-2*a*b*cos(con)); 
  
    cout <<fixed << setprecision(20)<< ans << endl;
}


Measured memory_bytes: 4084
import java.util.*;
import java.io.*;

class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int[][] count = new int[10][10];
        int head,tail;
        for(int i=1;i<=n;i++){
            tail = i%10;
            int tmp = i;
            while(tmp >=10){
                tmp/=10;
            }
            head = tmp%10;
            count[head][tail]++;
        }
        long sum = 0;
        for(int i=1;i<=9;i++){
            for(int j=1;j<=9;j++){
                sum+=(long)count[i][j]*count[j][i];
            }
        }
        System.out.println(sum);
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

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

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

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

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

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

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

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

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

#define ll long long int
#define pb push_back
#define endl "\n"

int main() {
    int t=1;
    // cin>>t;
    while(t--)
    {
        long double n,a,ans;
        cin>>n;
        a=n/3;
        ans=a*a*a;
        cout<<setprecision(13)<<ans<<endl;
    }
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
int main() {
 int N,D;
  cin >> N;
  cin >> D;
  
  vector<vector<int>> X(N, vector<int>(D));
    for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> X.at(i).at(j);
    }
  }
  
  double dis;
  int count;
  count = 0;
  
  
  for(int i=0; i < N;  i++){
    for(int j=i+1; j < N ; j++){
      dis = 0;
      for(int d=0; d<D; d++){
        dis = dis + ( X.at(i).at(d) - X.at(j).at(d) ) * ( X.at(i).at(d) - X.at(j).at(d) );
      }
      dis = sqrt(dis);
      if( ceil(dis) == dis ){
      count = count +1;
       }
    }
  }
   cout << count;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>


#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int dp[100005];
vector<int> G[100005];

int rec(int curr){
  if(dp[curr] != -1) return dp[curr];
  
  int ret = 0;
  for(auto x : G[curr]){
    ret = max(ret, rec(x) + 1);
  }
  return dp[curr] = ret;
}

int main(){
  int N, M;
  cin >> N >> M;
  
  for(int i = 0; i < M; i++){
    int x, y;
    cin >> x >> y, x--, y--;
    G[x].push_back(y);
  }

  for(int i = 0; i < 100005; i++) dp[i] = -1;

  int ans = 0;
  for(int i = 0; i < N; i++){
    ans = max(ans, rec(i));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8192
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, h, m int
	fmt.Scan(&a, &b, &h, &m)

	min := float64(h*60 + m)
	long := float64(360) / float64(60)
	short := float64(360) / float64(12*60)
	temp := long * min
	for temp >= 360.0 {
		temp -= 360.0
	}
	ang := abs(short*min - temp)
	ang = Min(ang, 360-ang)

	aa := float64(a)
	bb := float64(b)
	fmt.Println(math.Sqrt(aa*aa + bb*bb - 2*aa*bb*math.Cos(ang*math.Pi/180)))
}

func abs(a float64) float64 {
	if a < 0 {
		return (-1) * a
	}
	return a
}

func Min(a, b float64) float64 {
	if a < b {
		return a
	}
	return b
}

Measured memory_bytes: 1824
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
const int P = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
char s[MAXN];
map <string, int> dp[MAXN];
int n, ans, bit[MAXN];
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1), bit[n + 1] = 1;
	for (int i = n; i >= 1; i--) {
		bit[i] = bit[i + 1];
		if (s[i] == '?') bit[i] = 2 * bit[i] % P;
	}
	string empty = "";
	dp[0][empty] = 1;
	for (int i = 1; i <= n; i++)
	for (auto x : dp[i - 1]) {
		string t = x.first;
		int v = x.second;
		if (s[i] != '1') {
			t += '0';
			if (t.size() >= 3 && t[t.size() - 1] == '0' && t[t.size() - 2] == '0' && t[t.size() - 3] == '0') {
				t.resize(t.size() - 2);
				update(dp[i][t], v);
				t += "00";
			} else update(dp[i][t], v);
			t.resize(t.size() - 1);
		}
		if (s[i] != '0') {
			t += '1';
			if (t.size() >= 3) {
				int ans = 0;
				ans += t.back() - '0', t.pop_back();
				ans += t.back() - '0', t.pop_back();
				ans += t.back() - '0', t.pop_back();
				t += ans / 2 + '0';
			}
			if (t == "11") update(ans, 1ll * v * bit[i + 1] % P);
			else update(dp[i][t], v);
		}
	}
	empty += '1';
	update(ans, dp[n][empty]);
	writeln(ans);
	return 0;
}

Measured memory_bytes: 147072
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;

#define huge 1000000007

int main(void) {

	long long N = 0, L = 1;
	cin >> N;
	
	for (int i = 1; i <= N; i++) {
		
		
		L  = (L*i);
		L %= huge;
	}

	cout << L << endl;

	return 0;




}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n,m,max=0,nowMove=0,nowH=0,preH=-1;
    scanf("%d",&n);
    while(n>0)
    {
        scanf("%d",&nowH);
        if(preH>=nowH) nowMove++;
        else
        {
            if(nowMove>max) max=nowMove;
            nowMove=0;
        }
        preH=nowH;
        n--;
    }
    max>=nowMove?printf("%d",max):printf("%d",nowMove);
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int s,w;
  cin>>s>>w;

  if(w>=s)cout<<"unsafe"<<endl;
  else cout<<"safe"<<endl;  
     
  return 0;
}


Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  //A=(A+11)%13;
  //B=(B+11)%13;
  if(A==1)A=14;
  if(B==1)B=14; 
  if(A>B)
  cout<<"Alice";
  if(A<B)
  cout<<"Bob";
  if(A==B)
  cout<<"Draw";
  system ("pause");
  return 0;
  } 

Measured memory_bytes: 504
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
	string ss;
	cin >> ss;
	if((ss[1]==ss[2]&&ss[2]==ss[3])||(ss[0]==ss[1]&&ss[1]==ss[2]))	cout <<"Yes\n";
	else cout <<"No\n";
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner in = new Scanner(System.in);

		int set_count = in.nextInt();
		int min = 0;
		int max = 0;
		long sum = 0;

		for(int i = 0; i < set_count; i++){
			int num = in.nextInt();
			if(i == 0){
				min = num;
				max = num;
			}else{
				min = Math.min(min, num);
				max = Math.max(max, num);
			}
			sum += num;
		}
		System.out.println(min + " " + max + " " + sum);
	}

}



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

int digit_len(long long x){
    int res = 0;
    while(x > 0){
        x /= 10;
        res++;
    }
    return res;
}

int main(){
    long long n;
    int ans = 99999;
    cin >> n;
    for(long long i=1; i*i<=n; i++){
        if(n%i==0){
            ans = min(ans, max(digit_len(i), digit_len(n/i)));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import*
import sys
input = sys.stdin.readline


class UnionFind(object):
    def __init__(self, n):
        # 親の番号を格納する。親だった場合は-(その集合のサイズ)
        # 作るときはParentsの値を全て-1にする
        # こうすると全てバラバラになる
        self.parents = [-1 for i in range(n)]

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return

    def size(self, x):
        return -self.parents[self.find(x)]


n, k, l = map(int, input().split())
ro_cl = UnionFind(n)
ra_cl = UnionFind(n)
d = defaultdict(int)
for i in range(k):
    p, q = map(int, input().split())
    ro_cl.union(p-1, q-1)
for i in range(l):
    p, q = map(int, input().split())
    ra_cl.union(p-1, q-1)
for i in range(n):
    d[(ro_cl.find(i), ra_cl.find(i))] += 1
print(*[d[(ro_cl.find(i), ra_cl.find(i))]for i in range(n)])

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

int main(){
	int a, b, y[] = {4, 6, 9, 11};
	char ais='x', bis='x';
	cin >> a >> b;
	if(a==2)
		ais = 'z';
	if(b==2)
		bis = 'z';
	for(int i=0; i<4; i++){
		if(y[i] == a)
			ais = 'y';
		if(y[i] == b)
			bis = 'y';
	}
	if(ais == bis)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

int main() {
  int N;
  scanf("%d", &N);

  for (int i = 0; i <= N / 7; i++) {
    for (int j = 0; j <= N / 4; j++) {
      if (7 * i + 4 * j == N) {
        printf("Yes");
        return 0;
      }
    }
  }
  
  printf("No");
  return 0;
}

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

void input(int& rnSelSiz, vector<int>& rvnHeight)
{
  int nHeightSiz;
  cin >> nHeightSiz >> rnSelSiz;
  rvnHeight.resize(nHeightSiz);

  for (int& rnHeight : rvnHeight)
    cin >> rnHeight;

  sort (begin(rvnHeight), end(rvnHeight));
}

int calcMinDiffHeight(int nSelSiz, const vector<int>& cnrvnHeight)
{
  int nMinDiffHeight = INT_MAX;

  for (int i = 0; i < cnrvnHeight.size() - (nSelSiz - 1); i++)
    nMinDiffHeight = min(nMinDiffHeight, cnrvnHeight[i + (nSelSiz - 1)] - cnrvnHeight[i]);  
  
  return nMinDiffHeight;
}
 
int main()
{
  int nSelSiz;
  vector<int> vnHeight;

  input(nSelSiz, vnHeight);
  cout << calcMinDiffHeight(nSelSiz, vnHeight) << endl;

  return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	long long x, y, ans = 0;
	cin >> x >> y;
	for (;;) {
		ans++;
		x *= 2;
		if (x > y) {
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  string n;
  cin >> n;
  int ha = 0;
  for (char c:n){
    ha += atoi(&c);
  }
  int rawN = stoi(n);
  if (rawN % ha == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}



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

int main(void) {
	int A, B;
	string S;
	cin >> A >> B >> S;

	bool ans = true;
	if (S.length() != A + B + 1)
		ans = false;
	else {
		for (int i = 0; i < (int)S.length(); ++i) {
			if (i == A) {
				if (S[i] != '-') {
					ans = false;
					break;
				}
			}
			else {
				if (S[i] < '0' || S[i] > '9') {
					ans = false;
					break;
				}
			}
		}
	}

	if (ans)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};
use std::collections::BinaryHeap;

fn main() {
    input!{
        n: usize,
        m: usize,
        mut v: [(usize, usize); n]
    }
    let mut pq = BinaryHeap::new();
    v.sort_by_key(|x| x.0);
    let mut ans = 0;
    let mut j = 0;
    for i in (0..m).rev() {
        while j < n && v[j].0 == m - i {
            pq.push(v[j].1);
            j += 1;
        }
        if let Some(b) = pq.pop() {
            ans += b;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
import java.util.*
import kotlin.math.*
import java.io.BufferedReader
import java.io.InputStreamReader


private var fs = BufferedReader(InputStreamReader(System.`in`))
private fun readLn() = fs.readLine()!! // string line
private fun readStrings() = readLn().split(" ") // list of strings
private fun readLong() = readLn().toLong()
private fun readLongs() = readStrings().map { it.toLong() } // list of ints
private fun readInt() = readLn().toInt() // single int
private fun readInts() = readStrings().map { it.toInt() } // list of ints

fun main() {
    solveAtc()
}
fun solveAtc() {
    var n = readLong()
    var ans  = ""
    while(n>0){
        var num = n/26
        var rest = n%26
        if(rest==0L){
            num--
            ans += ('z')
        }
        else{
            ans += 'a' + rest.toInt()-1
        }
        n=num
    }
    ans = ans.reversed()
    println(ans)

}

Measured memory_bytes: 35600
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

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

struct edge{int to,cost;};

int ans[100][100];

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

	int n,m;
	cin >> n >> m;

	int a,b,c;
	vector<edge> es[n];
	for(int i=0;i<m;i++){
		cin >> a >> b >> c;
		a--; b--;
		es[a].push_back({b,c});
		es[b].push_back({a,c});
		ans[a][b]=ans[b][a]=1;
	}
	int d[n],f,t,cost,from[n];
	int when[n];
	P tmp;
	for(int s=0;s<n-1;s++){
		for(int i=0;i<n;i++){
			d[i]=from[i]=INF;
		}
		priority_queue<P,vector<P>,greater<P>> que;
		que.push(P(0,s));
		d[s]=0;
		while(!que.empty()){
			tmp=que.top(); que.pop();
			cost=tmp.first,f=tmp.second;
			if(d[f] < cost) continue;
			for(int j=0;j<es[f].size();j++){
				t=es[f][j].to,cost=es[f][j].cost;
				if(d[t] > d[f]+cost){
					d[t]=d[f]+cost;
					que.push(P(d[t],t));
					from[t] = f;
				}
			}
		}
		for(int i=s+1;i<n;i++){
			if(from[i]!=INF){
				ans[i][from[i]]--;
				ans[from[i]][i]--;
			}
		}
	}

	int num=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(ans[i][j] == 1) num++;
		}
	}
	cout << num << "\n";

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL endl
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
#define deb(x) cout << #x": " << (x) << endl;
const lli N = 1e7;
const lli INF = 1e14;
const lli mod = 1e9+7;

// ---- コーディングはここから！ ('-')7


int main(){_
	int n; cin>>n;

	auto g=[&](int l){
		if(l>=400 and l<600)return 8;
		if(l<800)return 7;
		if(l<1000)return 6;
		if(l<1200)return 5;
		if(l<1400)return 4;
		if(l<1600)return 3;
		if(l<1800)return 2;
		return 1;
	};
	cout<<g(n)<<ENDL;

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N,K,Q;
	cin >> N >> K >> Q;
	vector <int> A(Q);
	vector <int> P(N,0);
	for (int i = 0; i < Q; i++){
		cin >> A.at(i);
		P.at(A.at(i)-1) += 1;
	}
	
	for (int i =0; i < N; i++){
		if(P.at(i)>(Q-K)){
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}	
	
	
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> P(N);
    REP(i, 0, N) cin >> P[i];

    int ans = 0;
    REP(i, 0, N) {
        if (i == P[i] - 1) {
            if (i != N - 1) swap(P[i], P[i + 1]);
            else swap(P[i], P[i - 1]);
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
    string op;
    int a, b;
    while(1){
        cin >> a >> op >> b;
        if (op=="?") break;
        else if (op=="+") cout << a + b << endl;
        else if (op=="-") cout << a - b << endl;
        else if (op=="*") cout << a * b << endl;
        else if (op=="/") cout << a / b << endl;
        
    }
    return 0;
}

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

int main(){
    int A,B,C;
    cin >> A >> B >> C;

    if(A==B){
        if(A!=C) cout << "Yes" << endl;
        if(A==C) cout << "No" << endl;
    }
    else if(A==C){
        if(A!=B) cout << "Yes" << endl;
        if(A==B) cout << "No" << endl;
    }
    else if(B==C){
        if(B!=A) cout << "Yes" << endl;
        if(B==A) cout << "No" << endl;    
    }
    else{
        cout << "No" << endl;
    }
}

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

int main(void) {
  int a,b,sum=0;
  double t,n;
  cin >> a >> b >> t;
  n = t + 0.5;
  for(int i=a; i<n; i+=a){
    sum += b;
  }
  cout << sum << endl;
}



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 main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	reverse(a.begin(), a.end());
	vector<int> l(a.size() + 1, 0);
	l[0] = a[0];
	int len = 1;
	for (int i = 1; i < n; ++i) {
		if (l[len - 1] <= a[i]) l[len++] = a[i];
		else *upper_bound(l.begin(), l.begin() + len, a[i]) = a[i];
	}
	cout << len << endl;
	return 0;
}


Measured memory_bytes: 1024
pos = [0,1,2,0,-1,2,0,1,2]
while 1:
    s = raw_input()
    if s == "#": break
    ans = 10**9
    for ini in range(2):
        tmp = 0
        b = int(s[0])-1
        lr = ini
        for i in range(1,len(s)):
            f = int(s[i])-1
            if lr == 0:
                if pos[b] < pos[f]: tmp += 1
                else: lr = 1-lr
            else:
                if pos[b] > pos[f]: tmp += 1
                else: lr = 1-lr
            b = f
        ans = min(ans, tmp)
    print ans

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

int main() {
  int N;
  string S;
  bool flag = false;
  cin >> N;

  for ( int i = 0 ; i < N ; i++){
    cin >> S;
    if ( S == "Y" ){
      flag = true;
      break;
    }
    else {
      continue;
    }
  };
  
  if (flag){
    cout << "Four" << endl;
  } else{
    cout << "Three" << endl;
  };
  
}


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

int main() {
  int N, K, tmp;
  cin >> N >> K;
  vector<int> ball(N + 1);
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    ball.at(tmp)++;
  }
  
  sort(ball.begin(), ball.end());
  int ans = 0;
  for (int i = 1; i < N + 1 - K; i++) {
    ans += ball.at(i);
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3964
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define READ(a) int a; cin >> a;
#define READARR(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define READMAT(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define print(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
 
int power (int a, int b = mod - 2)
{
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	READARR(a, n);
	sort(a + 1, a + n + 1);
	
	int fac[100006]= {};
	fac[0] = 1;
	FOR (i, 1, 100005) fac[i] = fac[i - 1] * i % mod;
	
	int sum = 0, b = 0;
	FOR (i, k, n) sum = (sum + a[i] * fac[i - 1] % mod * power(fac[k - 1]) % mod * power(fac[i - k]) % mod) % mod;
	FOR (i, 1, n - k + 1) 
	{
	    b = (b + a[i] * fac[n - i] % mod * power(fac[k - 1]) % mod * power(fac[n - i - k + 1]) % mod) % mod;
	  //  cout << i << ": " << a[i] <<  " " << fac[n - i] << " " << fac[n - i] % mod * power(fac[k - 1]) % mod * power(fac[n - i - k + 1]) % mod << endl;
	}
	
	
	cout << (sum - b + mod) % mod;
}

Measured memory_bytes: 1792
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

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

        public void Solve(ConsoleInput cin)
        {
            //var D = cin.ReadInt;
            //var N = cin.ReadInt;
            //var M = cin.ReadInt;//buy
            //long[] A = new long[N];
            //A = cin.ReadLongArray(N);
            //long x = 0;
            //    int y = 0;
            //x = A.Max() - A.Min();
            int[] N = cin.ReadIntArray(2);
            int a = N[0];
            int b = N[1];
            if (a * b == 15) { Console.WriteLine("*"); }
            else if (a + b == 15) { Console.WriteLine("+"); }
            else { Console.WriteLine("x"); }

            Console.Read();

        }
    }

    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: 11220