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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;

const ll inf = numeric_limits<ll>::max();

void solve_2(){
    ll n;
    cin>>n;
    ll h[n];
    fr(i, n) cin>>h[i];
    vector<ll> dp(n, inf);
    dp[0] = 0;
    fr(i, n){
        for(auto j: {i+1, i+2}){
            if(j < n){
                dp[j] = min(dp[j], dp[i] + llabs(h[i] - h[j]));
            }
        }
    }
    cout<<dp[n-1];
}

void solve(){
    ll n;
    cin>>n;
    ll h[n + 1], dp[n+1][2];

    rep(i, 1, n) cin>>h[i];

    dp[1][0] = dp[1][1] = 0;
    dp[2][0] = 0ll + llabs(h[2] - h[1]);
    dp[2][1] = inf;

    rep(i, 3, n){
        dp[i][0] = min(dp[i-1][0], dp[i-1][1]) + llabs(h[i] - h[i-1]);
        dp[i][1] = min(dp[i-2][0], dp[i-2][1]) + llabs(h[i] - h[i-2]);
    }

    cout<<min(dp[n][0], dp[n][1]);

}

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

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

    return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll A, B, C;
  cin>>A>>B>>C;
  ll ans = 0;
  if(A+B+1<C) ans = A+B+1+B;
  else ans = B+C;
  cout<<ans<<endl;
}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  char a, b;
  cin >> a >> b;
  cout << (a == b ? 'H' : 'D') << endl;


  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int A,B,mult;
        Scanner sc = new Scanner(System.in);

        do {
            A = sc.nextInt();
        }while (!(A>=1 && A<=20));

        do {
            B= sc.nextInt();
        }while (!(B>=1 && B<=20));

        if (A<=9 && B<=9){
            System.out.println(mult=A*B);
        }else {
            System.out.println(-1);
        }
    }
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
using namespace std;
int main()
{
int n;
cin>>n;
int a[n],b[n],c[n];
for(int i=0;i<n;i++)
{
cin>>a[i]>>b[i]>>c[i];
}
int dp[n][3];
dp[0][0]=a[0];
dp[0][1]=b[0];
dp[0][2]=c[0];
int ans=max(a[0],max(c[0],b[0]));
for(int i=1;i<n;i++)
{
dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
ans=max(ans,max(dp[i][1],max(dp[i][2],dp[i][0])));
}
cout<<ans<<endl;
}


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

int n, m;

vector<vector<int>> g;
vector<int> indeg;
// vector<bool> sorted;
// list<int> out;
vector<int> t; // ソート済み配列

void bfs(int s) {
    queue<int> q;
    q.push(s);
    while (not q.empty()) {
        int u = q.front();
        q.pop();
        // sorted[u] = true;
        // out.push_back(u);
        t.push_back(u);
        for (int v : g[u]) {
            // if (sorted[v] == false) {
            if (find(t.begin(), t.end(), v) == t.end()) { // ソート済み配列にない
                if (--indeg[v] == 0) {
                    q.push(v);
                }
            }
        }
    }
}

void topological_sort() {
    // sorted.resize(n, false);
    rep(i, n) {
        // if (sorted[i] == false && indeg[i] == 0) {
        if (find(t.begin(), t.end(), i) == t.end()) {
            if (indeg[i] == 0) bfs(i);
        }
    }
    if (t.size() == n) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
}

int main() {
    cin >> n;
    cin >> m;
    g.resize(n);
    indeg.resize(n);
    rep(i, m) {
        int s, t;
        cin >> s;
        cin >> t;
        g[s].push_back(t);
        indeg[t]++;
    }
    topological_sort();
}


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

typedef long long ll;
const size_t MAX_N = (size_t) 1e5 + 5;

ll a[MAX_N], b[MAX_N];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    ll res = 0;
    for (int i = n - 1; i + 1; i--) 
        res += (b[i] - (a[i] + res) % b[i]) % b[i];
    cout << res;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    int N;
    vector<int> L;

    cin >> N;

    for(int i = 0; i < N; i++){
        int data;
        cin >> data;
        L.push_back(data);
    }

    if(accumulate(L.begin(), L.end(), 0) > 2 * *max_element(L.begin(), L.end())) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main{

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        if(str.equals("SUN")){
            System.out.print(7);
        }else if(str.equals("MON")){
            System.out.print(6);
        }else if(str.equals("TUE")){
            System.out.print(5);
        }else if(str.equals("WED")){
            System.out.print(4);
        }else if(str.equals("THU")){
            System.out.print(3);
        }else if(str.equals("FRI")){
            System.out.print(2);
        }else if(str.equals("SAT")){
            System.out.print(1);
        }
       
    }
    
}


Measured memory_bytes: 21716
#include<stdio.h>

#define MAX 2000000
#define INFTY (1<<30)

int H,A[MAX+1];

void maxHeapify(int);
int extract(void);
void increaseKey(int,int);
void insert(int);
void swap(int *,int *);

int main(){
  int key;
  char s[10];

  while(1){
    scanf("%s",s);
    if(s[0] == 'e' && s[1] == 'n')break;

    if(s[0] == 'i'){
      scanf("%d",&key);
      insert(key);
    }
    else printf("%d\n",extract());
  }

  return 0;
}

void maxHeapify(int i){ 
int l,r,larg,tmp;

  l = 2 * i;
  r = 2 * i + 1;

  if(l <= H && A[l] > A[i])larg = l;
  else larg = i;

  if(r <= H && A[r] > A[larg])larg = r;

  if(larg != i){
    tmp = A[i];
    A[i] = A[larg];
    A[larg] = tmp;
    maxHeapify(larg);
  }

}

int extract(void){
  int maxv;

  if(H < 1)return -INFTY;

  maxv = A[1];
  A[1] = A[H--];
  maxHeapify(1);

  return maxv;
}

void increaseKey(int i,int key){

  if(key < A[i])return;

  A[i] = key;
  while(i > 1 && A[i/2] < A[i]){
    swap(&A[i],&A[i/2]);
    i = i/2;
  }
}

void insert(int key){

  H++;
  A[H] = -INFTY;
  increaseKey(H,key);
}

void swap(int *a,int *b){
  int tmp;

  tmp = *a;
  *a = *b;
  *b = tmp;
}

Measured memory_bytes: 4696
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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; }

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;}

int main () {
  int n, k;
  cin >> n >> k;

  vi d(k);
  rep(i,k) cin >> d[i];

  FOR(ans,n,10*n+1) {
    int tmp = ans;
    bool flag = true;
    while (tmp > 0) {
      int a1 = tmp%10;
      //if (lower_bound(ALL(d),a1) != d.end() && *lower_bound(ALL(d),a1) == a1) {
      if (binary_search(ALL(d),a1)) {
        flag = false;
        break;
      }
      tmp /= 10;
    }
    if (flag) {
      cout << ans << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
int main(int argc, char *argv[]) {
  int n;
  vector<int> v{};
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    v.push_back(a);
  }
  reverse(v.begin(), v.end());
  for (int j = 0; j < n - 1; j++) {
    printf("%d ", v.at(j));
  }
  printf("%d\n", v.at(n - 1));
}



Measured memory_bytes: 2804
n=int(input())
L=list(map(int, input().split()))
ans=sum(L)
import collections
D=collections.Counter(L)
q=int(input())
for i in range(q):
	b, c =map(int, input().split())
	ans=ans+(c-b)*D[b]
	D[c]+=D[b]
	D[b]=0
	print(ans)

Measured memory_bytes: 24144
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(A,B);
    Cinii(H,M);
    cout << setprecision(15) << sqrt(A*A+B*B-2*A*B*cos(11.00*PI*(60*H+M)/360))  << nn;
    return 0;
}

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

int c(int a, int num) {
  int ret=0;
  while(a%num==0) { ret++; a/=num; }
  return ret;
}

int main() {
  int n;
  while(cin>>n,n) {
    int t=0,f=0;
    for(int i=2; i<=n; i++) { t+=c(i,2); f+=c(i,5); }
    cout<<min(t,f)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
/*
  -> Do Good Die Great
*/
#include <bits/stdc++.h>
#define int long long int
#define pii pair<int, int>
#define rep(s, e) for (int i = s; i < e; i++)
#define reep(s, e) for (int i = s; i <= e; i++)
#define ff first
#define ss second
#define eb emplace_back
#define pb push_back
#define MOD 1000000007
#define Hiraishin                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);                 \
    cout.tie(nullptr);
#define tests \
    int t;    \
    cin >> t; \
    while (t--)
using namespace std;

// global
const int mx = 5e6;
int fac[mx], ifac[mx];

// Pow in O(log(n))
int my_pow(int b, int e)
{
    int res = 1;
    b %= MOD;
    if (!b)
        return 0;
    while (e) {
        if (e & 1)
            res = (res * b) % MOD;
        b = (b * b) % MOD;
        e >>= 1;
    }
    return res;
}

int ncr(int n, int r)
{
    return (fac[n] * ifac[n - r] % MOD) * 1ll * ifac[r] % MOD;
}

void solve()
{
    int n, k;
    cin >> k;
    string s;
    cin >> s;
    n = s.length();
    int res = 0;
    for (int i = n; i <= n + k; i++) {
        res += ncr(n + k, i) * 1ll * my_pow(25, n + k - i) % MOD;
        res %= MOD;
    }
    cout << res << '\n';
}

signed main()
{
    Hiraishin
        //tests

        ifac[0]
        = fac[0] = 1;
    for (int i = 1; i < mx; i++) {
        fac[i] = (fac[i - 1] * i * 1ll) % MOD;
        ifac[i] = my_pow(fac[i], MOD - 2);
    }
    solve();
    return 0;
}

Measured memory_bytes: 82352
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
using namespace std;
typedef long long LL;
LL x[100005];
int main()
{
    int n, k;
    while(~scanf("%d%d", &n, &k))
    {
        for(int i = 1; i <= n; i++)
            scanf("%lld", &x[i]);
        LL ans = 1e18;
        for(int i = 1; i <= n - k + 1; i++)
        {
            LL tmp = 0;
            if(x[i] < 0 && x[i+k-1] <= 0)
                tmp = -x[i];
            else if(x[i] <= 0 && x[i+k-1] >= 0)
                tmp = 2*x[i+k-1] - 2*x[i] - max(-x[i], x[i+k-1]);
            else
                tmp = x[i+k-1];
            ans = min(ans, tmp);
        }
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h" 
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rerep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
#define all(s) s.begin(),s.end()
typedef long long ll;
int gcd(int a,int b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
const double pi=3.14159265358979;
const ll INF = 10e9;
int main(){
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double a_omega=0.5*(h*60+m);
    double b_omega=6*(m);
    double omega=max(a_omega,b_omega)-min(a_omega,b_omega);
    omega=min(omega,360-omega);
    omega=2*pi*omega/360;
    double ans;
    ans=pow(a,2)+pow(b,2)-2*a*b*cos(omega);
    ans=sqrt(ans);
    cout<<fixed<<setprecision(9)<<ans<<endl;
}

Measured memory_bytes: 4216
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto S = RD!string;
	auto T = RD!string;

	long ans = long.max;
	foreach (i; 0..S.length-T.length+1)
	{
		long cnt;
		foreach (j; 0..T.length)
		{
			if (S[i+j] != T[j])
				++cnt;
		}
		ans.chmin(cnt);
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}


Measured memory_bytes: 2752
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int n;
cin >> n;
string s[n];
int size[n];
int flg = -1;
REP(i,n) {
  cin >> s[i];
  size[i] = s[i].length();
  if(i>=1) {
    if(s[i-1][size[i-1]-1]!=s[i][0]) flg++;
    REP(j,i) {
      if(s[i]==s[j]) flg++;
    }
  }
}
if(flg==-1) {
  cout << "Yes" << endl;
} else {
  cout << "No" << endl;
}
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#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>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
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;

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

typedef pair<double,pair<int,int> > type;

void solve(int n,int m,int p,int a,int b){
  a--;b--;
  
  vector<int> t(n);
  for(int i=0;i<n;i++){
    cin>>t[i];
  }
  
  int dist[105][105];
  for(int i=0;i<105;i++){
    for(int j=0;j<105;j++)dist[i][j]=-1;
  }
  
  vector<int> x(p),y(p),z(p);
  for(int i=0;i<p;i++){
    cin>>x[i]>>y[i]>>z[i];
    x[i]--;y[i]--;
    dist[x[i]][y[i]]=dist[y[i]][x[i]]=z[i];
  }
  
  double dp[105][1<<8];
  for(int i=0;i<105;i++){
    for(int j=0;j<(1<<8);j++)dp[i][j]=1e12;
  }
  dp[a][0]=0;
  // cout<<1<<endl;
  // first -> コスト | second.first -> 現在地 second.second -> bit mask
  priority_queue<type,vector<type>,greater<type> > que;
  // cout<<1<<endl;
  que.push(mp(0,mp(a,0)));
  // cout<<1<<endl;
  while(que.size()){
    type top=que.top();que.pop();
    double cost=top.first;
    int now=top.second.first,now_mask=top.second.second;
    
    if(cost>dp[now][now_mask])continue;
    for(int i=0;i<m;i++)if(dist[now][i]!=-1){
	for(int j=0;j<n;j++){
	  int next_mask=now_mask;
	  if(next_mask & (1<<j))continue;
	  next_mask|=(1<<j);
	  double next_cost=cost+double(dist[now][i])/t[j];
	  if(dp[i][next_mask]>next_cost){
	    dp[i][next_mask]=next_cost;
	    que.push(mp(next_cost,mp(i,next_mask)));
	  }
	}
      }
  }
  
  double ans=1e12;
  for(int i=0;i<(1<<8);i++){
    ans=min(ans,dp[b][i]);
  }
  if(ans==1e12)printf("Impossible\n");
  else printf("%.8f\n",ans);
}

int main(){
  int n,m,p,a,b;
  while(cin>>n>>m>>p>>a>>b){
    if(!(n|m|p|a|b))break;
    solve(n,m,p,a,b);
  }
  return 0;
}



Measured memory_bytes: 4732
#include<stdio.h>
#include<string.h>
int main(void){
   char str[100],rts[100];
   int i,j,work;

   while((scanf("%s",str))!=EOF){
      for(i = strlen(str)-1;i>=0;i--){
         printf("%c",str[i]);
      }
      puts("");
   }
   return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
    int a,c;
    char b;
    while(1){
        cin >> a >> b >> c;
        if(b=='?') break;
        if(b=='+') cout << a+c;
        else if(b=='-')cout << a-c;
        else if(b=='*')cout << a*c;
        else cout << a/c;
        cout << endl;
    }
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;

int main(void) {
  int n,m;
  cin >> n >> m;
  vector<set<pair<int,int>>> a(n);
  rep(i,m){
    int p,q;
    cin >> p >> q;
    p--;
    a[p].insert(make_pair(q,i));
  }
  vll b(m);
  for(ll i=0;i<n;i++){
    ll cnt = 1;
    for(auto value:a[i]){
      b[value.second] = (i+1)*1000000+cnt;
      cnt++;
    }
  }
  rep(i,m){
    cout << setfill('0') << right << setw(12) << b[i] << endl;
  }
}






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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef string str;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

const double PI = acos(-1);

int main() {
    int a, b, x;
    cin >> a >> b >> x;
    double ans = 0.0;
    if(2 * x > a * a * b) ans = atan(2.0 * (a * a * b - x) / (a * a * a));
    else ans = atan(1.0 * a * b * b / (2 * x));
    cout << ans * 180 / PI << "\n";

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	long double T, X;
	in >> T >> X;
	out << T / X << std::endl;
}


Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    AB = [LI() for _ in range(N)]
    AB.sort(key=lambda x: x[1])

    ans = 'Yes'
    t = 0
    limit = 0
    for A, B in AB:
        limit = B
        t += A
        if t > limit:
            ans = 'No'
            break

    print(ans)

if __name__ == '__main__':
    resolve()


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


int main(int argc, char* argv[])
{
    int x,y;
    scanf("%d%d", &x, &y);

    int min=INF;
    int i,j;
    for(i=0; i<2; i++) {
        for(j=0; j<2; j++) {
            int cnt=0;
            int x0=x, y0=y;
            if(i) {
                x0=-x0; cnt++;
            }
            if(j) {
                y0=-y0; cnt++;
            }
            if(y0>=x0) {
                cnt+=(y0-x0);
                min=MIN(min,cnt);
            }
        }
    }
    printf("%d\n", min);

    return 0;
}



Measured memory_bytes: 128
#include<stdio.h>

int gcd(int,int);

int main(){
    int x,y;
    scanf("%d %d",&x,&y);
    printf("%d\n",gcd(x,y));
    return 0;
}
int gcd(int x,int y){
    int temp,z;
      if(x<y){
       temp = x;
       x = y;
       y = temp; 
    }
    while(y!=0){
        z = x % y;       
        x = y;
        y = z;
    }
    return x;
}




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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

int main(){
    int N; cin >> N;
    string s; cin >> s;
    bool flag=false;
    int res=1;
    for(int i=0; i<N-1; i++){
        if(s[i] != s[i+1]){
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3756
n=int(input())
s=input()
alp='abcdefghijklmnopqrstuvwxyz'

b=[]
for i in range(n):
  count=0
  s1=s[:i]
  s2=s[i:]
  for j in alp:
    if s1.count(j)*s2.count(j):
      count+=1
  b.append(count)
print(max(b))
    

Measured memory_bytes: 39280
def orderN(N,L,ices):
    upPeak = L - ices[0]
    downPeak = L - ices[0]
    peaks = []
    append = peaks.append
    for i in xrange(len(ices)):
        if i < N-1:
            if ices[i] < ices[i+1]:
                append(downPeak)
                downPeak = L - ices[i+1]
                upPeak += L - ices[i+1]
            else:
                append(upPeak)
                upPeak = L - ices[i+1]
                downPeak += L - ices[i+1]
        else:
            append(upPeak)
            append(downPeak)
    print(max(peaks))

N,L = map(int,raw_input().strip().split())
ices = [int(raw_input().strip()) for _ in xrange(N)]

orderN(N,L,ices)

Measured memory_bytes: 12564
# 入力
N = input()

A1 = [int(i) for i in input().split(" ")]
A2 = [int(i) for i in input().split(" ")]

total = 0
for i in range(int(N)):
    tmp = sum(A1[:i+1]) + sum(A2[i:])
    if(total < tmp):
        total = tmp
        
print(total)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;


int main() {
  int A, B;
  cin >> A >> B;
  int ans = A * B;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3232
import sys
# 再起回数上限変更
# sys.setrecursionlimit(1000000)

import math

X = int(input())
N = 10**8

a = 100
ans = 0
for i in range(N):
    a = math.floor(a * 1.01)
    ans += 1
    if a >= X:
        print(ans)
        sys.exit()


Measured memory_bytes: 63484
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>


using namespace std;

#define dprint(Exp,...) if(Exp){fprintf(stderr, __VA_ARGS__);}
#define printe(...) fprintf(stderr, __VA_ARGS__);
#define PrtExp(_Exp)  //cerr<< #_Exp <<" = "<< (_Exp)
#define PrtExpN(_Exp)  //cerr<< #_Exp <<" = "<< (_Exp) <<"\n"

#define SINT(n) scanf("%d",&n)
#define SINT2(n,m) scanf("%d %d",&n,&m)
#define SINT3(n,m,o) scanf("%d %d %d",&n,&m,&o)
#define SINT4(n,m,o,p) scanf("%d %d %d %d",&n,&m,&o,&p)
#define SINT5(n,m,o,p,q) scanf("%d %d %d %d %d",&n,&m,&o,&p,&q)
#define SLL(n) scanf("%lld",&n)
#define SLL2(n,m) scanf("%lld %lld",&n,&m)
#define SLL3(n,m,o) scanf("%lld %lld %lld",&n,&m,&o)
#define SST(s) scanf("%s",s)
#define SCH(c) scanf("%c",&c)

#define GC() getchar()

#define PINT(n) printf("%d",(int)(n))
#define PINT2(n,m) printf("%d %d",(int)(n),(int)(m))
#define PINT3(n,m,l) printf("%d %d %d",(int)(n),(int)(m),(int)(l))
#define PLL(n) printf("%lld",(long long)(n))
#define PST(s) printf("%s",(s))
#define PCH(s) printf("%c",(s))

#define PINTN(n) printf("%d\n",(int)(n))
#define PINT2N(n,m) printf("%d %d\n",(int)(n),(int)(m))
#define PINT3N(n,m,l) printf("%d %d %d\n",(int)(n),(int)(m),(int)(l))
#define PLLN(n) printf("%lld\n",(long long)(n))
#define PSTN(s) printf("%s\n",(s))
#define PCHN(s) printf("%c\n",(s))

#define PSP() printf(" ")
#define PN() printf("\n")

#define PC(c) putchar(c)
#define CSP (' ')
#define SN ("\n")

#define rep(i,a) for(int i=0;i<a;i++)
#define reP(i,a) for(int i=0;i<=a;i++)
#define Rep(i,a) for(int i=a-1;i>=0;i--)
#define ReP(i,a) for(int i=a;i>=0;i--)

#define rEp(i,a) for(i=0;i<a;i++)
#define rEP(i,a) for(i=0;i<=a;i++)
#define REp(i,a) for(i=a-1;i>=0;i--)
#define REP(i,a) for(i=a;i>=0;i--)

#define repft(i,a,b) for(int i=a;i<b;i++)
#define repfT(i,a,b) for(int i=a;i<=b;i++)
#define Repft(i,a,b) for(int i=a-1;i>=b;i--)
#define RepfT(i,a,b) for(int i=a;i>=b;i--)

#define foreach(a,it) for(auto it = a.begin(); it != a.end(); ++it)

#define FILL(a,v) fill(begin(a),end(a), v)
#define FILL0(a) memset(a,0,sizeof(a))
#define FILL1(a) memset(a,-1,sizeof(a))

typedef long long ll;

typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll>   Pll;


const int INF = 0x2aaaaaaa; // 715,827,882
const ll INFLL = 0x1f1f1f1f1f1f1f1fLL;//2,242,545,357,980,376,863

template <class A, class B> inline ostream& operator<<(ostream& st, const pair<A, B>& P) { return st << "(" << P.first << "," << P.second << ")"; };
template <class A, class B> inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first + Q.first, P.second + Q.second); };
template <class A, class B> inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first - Q.first, P.second - Q.second); };

#define fs  first
#define sc  second





map<int, int> m;

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

	int n;
	cin >> n;
	rep(i, n) {
		int a;
		cin >> a;
		++m[a];
	}

	int ret = 0;
	for (auto a : m) {
		if (a.fs < a.sc) {
			ret += a.sc - a.fs;
		} else if (a.fs == a.sc) {

		} else {
			ret += a.sc;
		}
	}
	cout << ret << endl;

}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
ll mod= 1e9 + 7;


int main(){
  int n;
  cin >> n;
  map<ll, int>p;
  int ans=0;
  rep(i,n){
    ll g;
    cin >>g;
    p[g]++;
  }
  for(auto i:p){
    if(i.second%2==1)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6528
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/

int main()
{
	int A, B, ans = 0;

	cin >> A >> B;


	if (A > 8 || B > 8) { cout << ":("; }
	else { cout << "Yay!"; }

	char qq;
	cin >> qq;
	return 0;
}

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

int M;
vector<int> X, Y;

int nc2(int x){
    if(x < 2)
        return 0;
    return x * (x-1) / 2;
}

int get_counts(map<pair<int, int>, int> &counts){
    int res = 0;
    for(auto p: counts)
        res += nc2(p.second);
    return res;
}

pair<int, int> get_fraction(int i, int j){
    int dx = X[i] - X[j];
    int dy = Y[i] - Y[j];
    int g = __gcd(dx, dy);
    
    return {dx/g, dy/g};
}

int dfs(int idx, int used, map<pair<int, int>, int> &counts){
    if(idx == M){
        return get_counts(counts);
    }
    
    int res = -1;
    if((used >> idx) & 1){
        res = max(res, dfs(idx+1, used, counts));
    }else{
        for(int i=idx+1; i<M; i++) if(((used >> i) & 1) == 0){
            int nused = used;
            nused |= 1 << idx;
            nused |= 1 << i;
            
            pair<int, int> fr = get_fraction(idx, i);
            counts[fr]++;
            res = max(res, dfs(idx+1, nused, counts));
            counts[fr]--;
        }
    }
    return res;
}

int main(){
    cin >> M;
    X.resize(M), Y.resize(M);
    
    for(int i=0; i<M; i++)
        cin >> X[i] >> Y[i];
    
    map<pair<int, int>, int> counts;
    cout << dfs(0, 0, counts) << endl;
    
    return 0;
}

Measured memory_bytes: 3084
A = input()
B = input()
C = input()
D = input()
E = input()
ABC = [A,B,C,D,E]
sort_abc = []
time = 0
m = 9
for abc in ABC:
    if m < int(abc[-1]) or abc[-1] == '0':
        sort_abc.insert(0,abc)
    else:
        m = int(abc[-1])
        sort_abc.append(abc)
sort_abc = list(map(int,sort_abc))
for i in range(5):
    abc = sort_abc[i]
    if i == 4:
        time += abc
    else:
        if abc%10 == 0:
            time += abc
        elif abc%10 != 0 and abc >= 10:
            time += abc + (10-abc%10)
        else:
            time += 10       
print(time)

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

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

    if(s == "ARC") cout << "ABC" << endl;
    else cout << "ARC" << endl;

    return 0;
}

Measured memory_bytes: 3580
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <valarray>

using namespace std;


main()
{
    int x,y; cin>>x>>y;
    int g[13]={-1,0,2,0,1,0,1,0,0,1,0,1,0};
    if(g[x]==g[y]) cout << "Yes" << "\n";
    else cout << "No" << "\n";
}


Measured memory_bytes: 256
def ma():
  n,m=map(int,input().split())
  ans=0
  e=[set(list(map(int,input().split()))[1:]) for i in range(m)]
  f=list(map(int,input().split()))
  for i in range(2**n):
    l={a for a,b in zip(range(1,n+1),bin(i)[2:].zfill(n)) if b=="1"}
    if sum({int(len(e[j-1]&l)%2 !=f[j-1]) for j in range(1,m+1)})==0:ans+=1
  print(ans)

if __name__=="__main__":
  ma()

Measured memory_bytes: 41328
import java.util.Arrays;
import java.util.Scanner;
import java.util.concurrent.SynchronousQueue;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	int n, m, l;
	String[] s;
	int[][] p;
	long[] p3 = new long[10];
	long[][] c = new long[1000][10];

	void run() {
		{
			p3[0] = 1;
			for (int i = 1; i < p3.length; ++i) {
				p3[i] = p3[i - 1] * 3;
			}
			c[0][0] = 1;
			for (int i = 1; i < c.length; ++i) {
				for (int j = 0; j < 10; ++j) {
					c[i][j] = c[i - 1][j] + (j > 0 ? c[i - 1][j - 1] : 0);
				}
			}
		}
		Scanner sc = new Scanner(System.in);
		while (true) {
			System.gc();
			n = sc.nextInt();
			m = sc.nextInt();
			l = sc.nextInt();
			if (n == 0 && m == 0 && l == 0)
				break;
			s = new String[l];
			p = new int[3][l];
			for (int i = 0; i < l; ++i) {
				s[i] = sc.next();
				if (s[i].equals("*"))
					continue;
				++p[s[i].charAt(0) - 'a'][s[i].length() - 1];
			}
			solve();
		}
	}

	void solve() {
		long tot = 0;
		for (int S = 1; S < p3[l]; S += 3) {
			int[] a = new int[l];
			for (int i = 0; i < l; i++) {
				a[i] = (int) ((S / p3[i]) % 3);
			}
			if (check(a)) {
				long comb = 1;
				int[] cnt = cnt(arr(a));
				for (int v : cnt) {
					comb *= c[n][v];
				}
				int wall = 1;
				int res = m;
				for (int v : a) {
					if (v == 2) {
						++wall;
						res -= 2;
					} else if (v == 1) {
						res -= 1;
					}
				}
				comb *= c[res + wall][wall];
				tot += comb;
			}
		}
		System.out.printf("%.20f\n", (double) tot / c[m * n][l]);

	}

	boolean check(int[] a) {
		int[] arr = arr(a);
		if (arr[arr.length - 1] > m)
			return false;
		int[] cnt = cnt(arr);
		if (cnt.length > 20) {
			throw new AssertionError();
		}
		cnt = Arrays.copyOf(cnt, 40);
		for (int x = 0; x < arr.length; ++x) {
			for (int y = 0; y < arr.length; ++y) {
				for (int z = 0; z < arr.length; ++z) {
					// cnt[x]???a,cnt[y]???b,cnt[z]???c?????¨????????????
					int[] cnt2 = new int[40];
					for (int shift = 0; shift < l; ++shift) {
						cnt2[arr[x] + shift] += p[0][shift];
						cnt2[arr[y] + shift] += p[1][shift];
						cnt2[arr[z] + shift] += p[2][shift];
					}
					boolean f = true;
					for (int i = 0; i < cnt2.length; ++i) {
						f &= (cnt[i] >= cnt2[i]);
					}
					if (f)
						return true;
				}
			}
		}
		return false;
	}

	int[] arr(int[] a) {
		int[] seq = new int[l];
		seq[0] = a[0];// =1
		for (int i = 1; i < a.length; ++i) {
			seq[i] = seq[i - 1] + a[i];
		}
		return seq;
	}

	int[] cnt(int[] arr) {
		int[] cnt = new int[arr[arr.length - 1] + 1];
		for (int v : arr) {
			++cnt[v];
		}
		return cnt;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define rep2r(i, l, r) for (int i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int N; cin >> N;
  string S; cin >> S;
  int ans = 1;
  rep(i, N - 1) ans += S[i] != S[i + 1];
  cout << ans << endl;
}


Measured memory_bytes: 512
n, m = gets.chomp.split().map(&:to_i)

ans = Array.new(m, 0)
input = gets.chomp.split().map(&:to_i)
for i in 1...input.size
  ans[input[i]-1] = 1
end

(n-1).times {
  input = gets.chomp.split().map(&:to_i)
  next if input[0] == m
  
  tmp = Array.new(m, 0)
  for i in 1...input.size
    tmp[input[i]-1] = 1
  end
  
  while index = tmp.index(0)
    tmp[index] = 1
    ans[index] = 0 if ans[index] == 1
  end
}

puts ans.count(1)

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a>b && a>c){
            if(b>c){
                System.out.printf("%d %d %d\n",c,b,a);
            }else{
                System.out.printf("%d %d %d\n",b,c,a);
            }
        }else if(b>a && b>c){
            if(a>c){
                System.out.printf("%d %d %d\n",c,a,b);
            }else{
                System.out.printf("%d %d %d\n",a,c,b);
            }
                
        }else if(c>b && c>a){
            if(a>b){
                System.out.printf("%d %d %d\n",b,a,c);
            }else{
                System.out.printf("%d %d %d\n",a,b,c);
                }
            }
        sc.close();
    }
}


Measured memory_bytes: 26472
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod=1e9+7;
int dp[102][100003];
int main()
{	//dp[i][j] distributing j candies among i children
	//dp[i][j]= sumofall dp[i-1][j-1]+dp[i-1][j-2]+.....+dp[i-1][j-x];
	
	int n,k;
	cin>>n>>k;int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	
	//base states
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		dp[i][0]=1;
		ll pre[k+2];memset(pre, 0, sizeof pre);
		for(int j=1;j<=k+1;j++)
		pre[j]=(pre[j-1]+dp[i-1][j-1])%mod;
		
		for(int j=1;j<=k;j++)
		dp[i][j]=(pre[j+1]-pre[max(0, j-a[i-1])]+mod)%mod;	
	}
	cout<<dp[n][k];

}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 18) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(S == T) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inp_ll;

const int MAXN = 100010;

int n;

int main()
{
	
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll ans = a-b;
	if (k&1) ans = -ans;
	cout << ans << endl;
	
	
	return 0;
}


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

typedef long long ll;
typedef long double ld;

#define deb(x) cerr << #x << ":" << x << "\n"

int main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t = 1;
    // cin >> t;
    for (int tc = 1; tc <= t; tc++)
    {
        ll i, j;
        cin >> i >> j;
        ll k = min(i, j);
        for (int itr = 1; itr <= (max(i, j)); itr++)
        {
            cout << k;
        }
        cout << "\n";
    }
    return 0;
}

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

int main() {
    int N; cin >> N;
    string S; cin >> S;
    
    N %= 26;

    for(int i = 0; i < S.size(); i++) {
        int a = (int)S.at(i);
        if(90 < N + a) {
            int rest = N - (90 - a);
            //cout << rest << endl;
            S.at(i) = (char)(64 + rest);
        }
        else
            S.at(i) = (char)(a + N);
        
    }
    cout << S << endl;
    //cout << (int)'A' << (int)'Z' << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <string>



using namespace std;

int main() {
    int n;
    int a[100];

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

    for (int i = n - 1; i > 0; i--) {
        cout << a[i] << " ";
    }
    cout << a[0] << endl;
    }
        


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

int main(){
	int a,b;
	cin>>a>>b;
  	if(a==1)a+=13;
  	if(b==1)b+=13;
  	if(a==b)cout<<"Draw"<<endl;
  	else if(a>b)cout<<"Alice"<<endl;
  	else cout<<"Bob"<<endl;
  	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

//static const long long MOD = 1000000007;

int main() {
    int A, B, C, answer;

    // input
    cin >> A >> B >> C;

    // process
    answer = C - (A - B);

    // output
    if (answer > 0)
        cout << answer;
    else
        cout << 0;

    return 0;
}

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

int main(void){
  int n;
  std::cin >> n;
  std::vector<int> d(n);
  int sum = 0;
  for(int i=0; i<n; i++){
    std::cin >> d[i];
    sum += d[i];
  }

  int ret = 0;
  for(int i=0; i<n; i++){
    ret += d[i] * (sum - d[i]);
  }

  std::cout << ret/2 << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int i;
  int N;
  scanf("%d",&N);
  
  int l[N+1];
  
  for(i=0;i<N;i++){
    scanf("%d",&l[i]);
  }
  
  int M=l[0];
  int S=0;
  
  for(i=0;i<N;i++){
    S=S+l[i];
    
    if(l[i]>M)M=l[i];
    else{}
  }
  
  if(S-M>M) printf("Yes\n");
  else printf("No\n");
  
  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  map<int,int> g[2];
  for(int i = 0; i < n; i++){
    int x; cin >> x;
    g[i%2][x]++;
  }
  vector<pair<int,int>> k[2];
  for(int i = 0; i < 2; i++){
    k[i].push_back({0, -1});
    for(auto it : g[i]) k[i].push_back({it.second, it.first});
	sort(k[i].rbegin(), k[i].rend());
    if(k[i].size() > 2)
    	k[i].resize(2);
  }
  int res = n;
  for(auto e : k[0]) for(auto f : k[1]) if(e.second != f.second)
    res = min(res, n - e.first - f.first);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 6136
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  string a;
  cin>>a;
  
  for(int i=0;i<19;i++){
    if(a.at(i)==',')
      a.at(i)=' ';
  }
  cout<<a;
  
  return 0;
}


Measured memory_bytes: 3032
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String key = sc.nextLine();
        String test = str+str;

        if(test.contains(key)) {
        	System.out.println("Yes");
        }else {
        	System.out.println("No");
        }
        sc.close();
    }
}


Measured memory_bytes: 26176
N,M = map(int,input().split())
citys = [list(map(int,input().split())) for _ in range(M)]
for i in range(M):
    citys[i].append(i)
citys.sort()
ppref = 0
city_code = 0
for city in citys:
    if ppref == city[0]:
        city_code += 1
    else:
        ppref = city[0]
        city_code = 1
    str_pref = str(city[0]).zfill(6)
    str_city = str(city_code).zfill(6)
    city.append(str_pref+str_city)

for city in sorted(citys, key=lambda x:x[2]):
    print(city[3])

Measured memory_bytes: 39656