akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    vector<int> a(10);
    for(int i=0;i<10;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    cout<<a[9]<<endl<<a[8]<<endl<<a[7]<<endl;
    return 0;
}

Measured memory_bytes: 3068
#include <stdio.h>
int main(void){
    // Your code here!
    
  int i,n;
  scanf("%d",&n);
  int a[n];
  for(i=0; i<n; i++){
     scanf("%d",&a[i]);
     }
  for(i=n-1; i>=0; i--){
  if(i==0){
  printf("%d\n",a[i]);
  }else{
       printf("%d ",a[i]);
  }
  }
  return 0;
}


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

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

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

  qsort(X, M, sizeof(int), com);

  int D[M-1];
  for(i = 0; i < M-1; i++){
    D[i] = X[i+1] - X[i];
  }

  qsort(D, M-1, sizeof(int), com);

  long sum = 0;
  for(i = 0; i < M - N; i++){
    sum += D[i];
  }

  printf("%ld\n", sum);

  return 0;
}


Measured memory_bytes: 1396
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

#define MAX_N 10
int n;
int p[MAX_N], q[MAX_N];

void print_setprecision(int i, long double rsl) {
  cout << fixed << setprecision(i) << rsl << endl;
}

void input() {
  cin >> n;
  rep(i, 0, n) cin >> p[i];
  rep(i, 0, n) cin >> q[i];
}

bool isEqual(int x[], int y[]) {
  rep(i, 0, n) if(x[i] != y[i]) return false;
  return true;
}

void solve() {
  int arr[n];
  rep(i, 0, n) arr[i] = i + 1;
  int cnt = 0;
  int orderP = 0, orderQ = 0;
  do {
    if(isEqual(arr, p)) orderP = cnt;
    if(isEqual(arr, q)) orderQ = cnt;
    ++cnt;
  } while (next_permutation(arr, arr + n));
  cout << abs(orderP - orderQ) << endl;
}

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


Measured memory_bytes: 256
/*****Here we go again!******/

#include<bits/stdc++.h>
using namespace std;

#define pi 3.1415926535
#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ll long long
#define llu unsigned long long
#define setbits(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define tc int test_case; cin >> test_case; while(test_case--)
#define f(i,a,n) for(int i = a ; i < n ; i++)
#define rf(i,n,a) for(int i = n-1 ; i >= a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define get(a,n) f(i,0,n) cin >> a[i];
#define show(a,n) f(i,0,n) cout << a[i] << " "; cout << endl;
#define sp(x) fixed << setprecision(10) << x
#define fast ios:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define trace(x) cerr << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cerr<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"

typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;

const int inf = 1e9;
const ll inf64 = 1e18;
const int mod = inf + 7;
const int N = 2e5 + 10;

int main()
{
    fast;
    int n, k;
    cin >> n >> k;
    vi a(n+1);
    f(i,1,n+1) cin >> a[i];
    vi dp(N);

    f(i,1,k+1)
    {
        f(j,1,n+1)
        {
            if(i >= a[j] and dp[i - a[j]] == 0)
            {
                dp[i] = 1;
                break;
            }
        }
    }
    if(dp[k])
        cout << "First";
    else
        cout << "Second";
}


Measured memory_bytes: 3992
#include <stdio.h>
#include <string.h>

int main() {
	
	char kata1[10];
	scanf("%s",kata1);
	if(kata1[0] == 'A' && kata1[1] == 'B' && kata1[2] == 'C'){
		printf("ARC\n");
	}else
	{
		printf("ABC\n");
	}
	
	return 0; 
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   1e9 +7  ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////
void solve(){
   ll a ;
   ld b ;
   cin >> a >> b ;
   ld res = a*b ;
   cout << (ll) res ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1 ;
   // cin >> t ;
    int case1 = 1 ;
    while(t--){
        //cout << "Case #" << case1 << ": " ;
        case1++;
        solve( );
    }
}


Measured memory_bytes: 3748
// #include <bits/stdc++.h>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<map>
#include<set>
#include<vector>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<string>
#include<tuple>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
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;}
template<class T>inline void                             in(T &p){cin>>p;}
template<class T1,class T2>inline void                   in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void          in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T>inline void                             ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
template<class T>inline void                             outs(T p){for_each(all(p),out<decltype(p[0])>);}
string s;
inline void solve(void){
  in(s);
  out(s.substr(0,s.size()-8));
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;

int main(){
  ll sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  ll dx = tx - sx;
  ll dy = ty - sy;
  string u = "U", d = "D", l = "L", r = "R";
  string ans;
  rep(i,dy){
    ans.append(u);
  }
  rep(i,dx){
    ans.append(r);
  }
  rep(i,dy){
    ans.append(d);
  }
  rep(i,dx+1){
    ans.append(l);
  }
  rep(i,dy+1){
    ans.append(u);
  }
  rep(i,dx+1){
    ans.append(r);
  }
  ans.append(d);
  ans.append(r);
  rep(i,dy+1){
    ans.append(d);
  }
  rep(i,dx+1){
    ans.append(l);
  }
  ans.append(u);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    s = input()
    s1 = int(s[:2])
    s2 = int(s[2:])
    isYYMM = 1 <= s2 <= 12
    isMMYY = 1 <= s1 <= 12
    if isYYMM and isMMYY:
        print("AMBIGUOUS")
    elif isYYMM:
        print("YYMM")
    elif isMMYY:
        print("MMYY")
    else:
        print("NA")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<set>
#include<cmath>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll INF =  1LL << 60;
const int inf = 1 << 30;
int n, m, x, y, q, d; ll z, w = 0, sum; int ans = 1;
const int MAX = 510000;
const int MOD = 1000000007;
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
int main(void) {
	cin >> z >> w;
	sum = gcd(z, w);
	for (ll i = 2; sum >= i * i; i++) {
		if (sum % i == 0) {
			ans++;
			while (sum % i == 0) sum /= i;
		}
	}if (sum != 1)ans++;
	cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <queue>
#include <map>

using namespace std;

int main()
{
    int n, q;
    int max_id = 0, max_num = 0;

    cin >> n >> q;
    map<int, int> data;
    for (int i = 1; i <= n; ++i)
        data.insert(map<int, int>::value_type(i, 0));

    int a, v;
    while (q--) {
        cin >> a >> v;
        data[a] += v;

        if (a == max_id) {
            max_num = data[a];

            if (v < 0) {
                map<int, int>::iterator it = data.begin();
                for ( ; it != data.end(); ++it) {
                    if ((*it).second > max_num) {
                        max_num = (*it).second;
                        max_id = (*it).first;
                    }
                    else if ((*it).second == max_num && (*it).first < max_id) {
                        max_id = (*it).first;
                    }
                }
            }
        }
        else if (data[a] > max_num ||
                 (data[a] == max_num && a < max_id)) {
            max_id = a;
            max_num = data[a];
        }

        cout << max_id << " " << max_num << endl;
    }

    return 0;
}

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

typedef long long s64;
#define rep(i,l,r) for(int i=l;i<=r;++i)
const int N=50+5,M=100+5,D=1e9+7;
s64 mi(s64 x,int y=D-2)
{
	s64 ans=1;
	while(y)
	{
		if(y&1)ans=ans*x%D;
		x=x*x%D;y>>=1;
	}
	return ans;
}
namespace BING
{
int fa[N],sz[N];
int find(int x)
{
	return x==fa[x]?x:fa[x]=find(fa[x]);
}
void merge(int x,int y)
{
	if(x==y)return ;
	fa[x]=y;
	sz[y]+=sz[x];
}
};
using BING::find;
vector<int>lk[N];
int fa[N],dfn[N],tot;
s64 jie[M*2];
int k;

void dfs(int x)
{
	dfn[x]=++tot;
	for(auto y:lk[x])
	if(y!=fa[x])
	{
		if(dfn[y])
		{
			if(dfn[y]>dfn[x])continue;
			int now=find(x);
			++BING::sz[now];
			for(int z=x;z=fa[z],z!=y;)BING::merge(find(z),now);
			continue;
		}
		++BING::sz[y];fa[y]=x;
		dfs(y);
	}
}
void init_jie(int n)
{
	jie[0]=1;
	rep(i,1,n)jie[i]=jie[i-1]*i%D; 
}
s64 C(int n,int m)
{
	return jie[n]*mi(jie[m]*jie[n-m]%D)%D;
}

int cnt[N];

int main()
{
	//freopen("1.in","r",stdin);
	int n,m;
	cin>>n>>m>>k;
	rep(i,1,m)
	{
		int x,y;
		cin>>x>>y;
		lk[x].push_back(y);
		lk[y].push_back(x);
	}
	
	rep(i,1,n)BING::fa[i]=i;
	rep(x,1,n)
	if(!dfn[x])dfs(x);
	init_jie(m+k);
	rep(x,1,n)++cnt[BING::fa[x]];
	s64 ans=1;
	rep(x,1,n)
	if(BING::fa[x]==x)
	{
		int s=BING::sz[x];
		if(!s)continue;
		if(s==1){ans=ans*k%D;continue;}
		if(s>cnt[x]+1){ans=ans*C(s+k-1,k-1)%D;continue;}
		s64 sum=0;
		rep(i,0,s-1)(sum+=mi(k,__gcd(i,s)))%=D;
		ans=ans*sum%D*mi(s)%D;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll modpw(ll x,ll k){
	ll res=1;
	while(k!=0){
		if(k&1)res=res*x%MOD;
		x=x*x%MOD;
		k=k>>1;
	}
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,zero=0;
	cin>>n;
	map<pll,pll> mp;
	rep(i,n){
		ll x,y;
		cin>>x>>y;
		if(x==0&&y==0)zero++;
		else if(x==0)mp[pll(0,0)].fs++;
		else if(y==0)mp[pll(0,0)].sc++;
		else{
			ll g=gcd(abs(x),abs(y));
			if(y<0){
				x=-x;y=-y;
			}
			x/=g;y/=g;
			if(x<0)mp[pll(y,-x)].fs++;
			else mp[pll(x,y)].sc++;
		}
	}
	ll ans=1;
	for(auto x:mp){
		ans*=(modpw(2,x.sc.fs)+modpw(2,x.sc.sc)-1);
		ans%=MOD;
	}
	ans=(ans+zero+MOD-1)%MOD;
	puta(ans);
}


Measured memory_bytes: 19112
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int aa=max(a,b);
    int bb=min(a,b);
    for(int i=1;i<=aa;i++)
    {
        cout<<bb;
    }
    return 0;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
int sum(int x){
    return __builtin_popcount(x);
}
vector<int> solve(int a, int b, int T){
    if (T==1) return {0};
    int common = -1;
    for (int i=0; i < T; i++){
        int ba = a & (1<<i);
        int bb = b & (1<<i);
        if (ba != 0) ba=1;
        if (bb != 0) bb=1;
        if (ba != bb) continue;
        common = i;
    }
    if (common != -1){
        int na = 0, nb = 0;
        int cur=0;
        for (int i=0; i < T; i++){
            if (i==common) continue;
            int ba = a & (1<<i);
            int bb = b & (1<<i);
            if (ba != 0) ba=1;
            if (bb != 0) bb=1;
            na += (1<<cur)*ba, nb += (1<<cur)*bb;
            cur++;
        }
        vector<int> res = solve(na, nb, T-1);
        vector<int> nres = {common};
        for (int i=0; i < res.size(); i++){
            if (res[i]>=common) nres.push_back(res[i]+1);
            else nres.push_back(res[i]);
            nres.push_back(common);
        }
        return nres;
    }
    int na = a & ((1<<(T-1)) - 1), nb = b & ((1<<(T-1)) - 1);
    int nc = na ^ 1;
    vector<int> A = solve(a, nc, T-1), B = solve(nc, b, T-1);
    //cout << a << " " << nc << " " << T-1 << endl;
    vector<int> res;
    for (int i=0;i<A.size();i++) res.push_back(A[i]);
    res.push_back(T-1);
    for (int i=0;i<B.size();i++) res.push_back(B[i]);
    return res;
}
main() {
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, a, b;
    cin >> n >> a >> b;
    int sa = sum(a)%2, sb = sum(b)%2;
    if (sa == sb){
        cout << "NO";
        return 0;
    }
    vector<int> R = solve(a, b, n);
    cout << "YES" << endl;
    cout << a << " ";
    for (int i=0; i < R.size(); i++){
        a ^= (1<<(R[i]));
        cout << a << " ";
    }
}


Measured memory_bytes: 2184
W = input()
n = 0
while True :
    T = input()
    if T== "END_OF_TEXT" :
        break
    small_T = list(T.split())
    for i in range(len(small_T)) :
        if str.lower(small_T[i]) == str.lower(W) :
            n += 1
print(n)


Measured memory_bytes: 5556
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    S = input_raw[0]
    dict = {}
    dict["R"] = 0
    dict["B"] = 0
    for s in S:
        dict[s] += 1
    if dict['R'] > dict['B']:
        print "Yes"
    else:
        print "No"

if __name__ == '__main__':
    main()


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

int main() {
	long long n;
	vector<long long> a;
	cin >> n;
	a.resize(n);
	long long cnt = 0;


	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i > 0) {
			cnt += abs(a[i - 1] - a[i]);
			if (i == n - 1) {
				cnt += abs(a[i] - 0);
			}
		}
		else if (i == 0) {
			cnt += abs(0 - a[i]);
		}
	}

	long long old_num, new_num;

	for (int j = 0; j < n; j++) {
		if (j == 0) {
			old_num = abs(0 - a[j]) + abs(a[j] - a[j + 1]);
			new_num = abs(0 - a[j + 1]);
		}
		else if (j == n - 1) {
			old_num = abs(a[j - 1] - a[j]) + abs(a[j] - 0);
			new_num = abs(a[j - 1] - 0);
		}
		else {
			old_num = abs(a[j - 1] - a[j]) + abs(a[j] - a[j + 1]);
			new_num = abs(a[j - 1] - a[j + 1]);
		}
		cout << cnt - old_num + new_num << endl;
	}

	return 0;
}

Measured memory_bytes: 2048
#include <stdio.h>

int main(){
  int A[100],N,i,j,k,minj = 0,cg,count = 0;

  scanf("%d",&N);

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

  for(i = 0 ; i<N ;i++){
    minj = i;
    for(j = i ; j < N ; j++){
      if(A[j] < A[minj]){
	minj = j;
      }
    }
    cg = A[i];
    A[i] = A[minj];
    A[minj] = cg;
    if(minj != i) count++;
  }
  
  for(k=0;k<N;k++){
    printf("%d",A[k]);
    if(k == N-1) break;
    printf(" ");
  }
  printf("\n");

  printf("%d\n",count);
  
  return 0;
}




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

using namespace std;

int H, W, N;
int MapData[1000][1000];
int DpDirection[1001][1001];

void solve(int curRow, int curCol) {

	if (curRow == H || curCol == W) {
		cout << curRow + 1 << " " << curCol + 1 << endl;
		return;
	}

	if (MapData[curRow][curCol] == 1) {
		if (DpDirection[curRow][curCol] % 2 == 1) {
			++curCol;
		}
		else {
			++curRow;
		}
	}
	else {
		if (DpDirection[curRow][curCol] % 2 == 1) {
			++curRow;
		}
		else {
			++curCol;
		}
	}
	solve(curRow, curCol);
}

int main() {

	while (cin >> H >> W >> N, H) {
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				cin >> MapData[i][j];
			}
		}

		memset(DpDirection, 0, sizeof(DpDirection));
		DpDirection[0][0] = N;
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if (MapData[i][j] == 1) {
					DpDirection[i][j + 1] += DpDirection[i][j] - DpDirection[i][j] / 2;
					DpDirection[i + 1][j] += DpDirection[i][j] / 2;
				}
				else if (MapData[i][j] == 0) {
					DpDirection[i][j + 1] += DpDirection[i][j] / 2;
					DpDirection[i + 1][j] += DpDirection[i][j] - DpDirection[i][j] / 2;
				}
			}
		}

		solve(0, 0);
	}

	return 0;
}


Measured memory_bytes: 10908
package main

import (
	"fmt"
)

func main() {
	var s string
	var si, ei int = -1, -1
	fmt.Scan(&s)

	for i,j :=0, len(s)-1; i<len(s) && (si < 0 || ei < 0); i,j = i+1, j-1 {
		sc := string(s[i])
		if si < 0 && sc == "A" {
			si = i
		}
		ec := string(s[j])
		if ei < 0 && ec == "Z" {
			ei = j
		}
	}

	fmt.Println(len(s[si:ei+1]))
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007
#define eps 1e-8

int N;
double vx[1001],vy[1001];
double X,Y;
const double g=9.8;

double calc(double vxi,double vyi,double y0,double t1){
  return (-1.0/2.0)*g*t1*t1+vyi*t1+y0;
}

int main(){
  while(1){
    cin>>N;
    if(N==0)break;
    rep(i,N)cin>>vx[i]>>vy[i];
    cin>>X>>Y;
    bool ok=false;
    rep(i,N){
      double t1=X/vx[i];
      if(calc(vx[i],vy[i],0,t1)<Y+eps)ok=true;
    }
    if(!ok){
      cout<<"No"<<endl;
      continue;
    }
    double lb=-1e9,ub=1e9;
    double crtx,crty;
    rep(_,100){
      double D=(lb+ub)/2;
      crtx=0,crty=0;
      rep(i,N){
        double t1=(D-(vy[i]/vx[i]))/(-g/vx[i]);
        if(t1<0)t1=0;
        crtx+=vx[i]*t1;
        crty=calc(vx[i],vy[i],crty,t1);
      }
      if(crtx<X)ub=D;
      else lb=D;
    }
    //dbg(crty);
    if(crty>Y-eps){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3088
#include <iostream>]
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <algorithm>
using namespace std;
vector<int> vis;
long long f(long long n, long long mod) {
	if (vis[n] != 0) return vis[n];
	if (n == 1 || n == 2 || n == 0) return 0;
	if (n == 3 || n == 4 || n == 5) return 1;
	if (n == 6) return 2;
	long long res = 0;
	for (int i = 3; n-i>=3; i++) {
		res += (f(n - i,mod)%mod);
		res %= mod;
	}

	res++;
	vis[n] = res;
	return res;
}


long long modpow(long long base, long long exp, long long modulus) {
	base %= modulus;
	long long result = 1;
	while (exp > 0) {
		if (exp & 1) result = (result * base) % modulus;
		base = (base * base) % modulus;
		exp >>= 1;
	}
	return result;
}
int main()
{
	long long mod = 1000000007;
	/*long long n;
	cin >> n;
	cout << ((((n - 1) * n) % mod)* modpow(8, n - 2, mod)) % mod;*/
	long long n;
	cin >> n;
	vis.resize(n + 1);
	vector<long long> dp(n+7);
	cout << f(n, mod);
}


Measured memory_bytes: 3632
S = input()
MODN = 10 ** 9 + 7

# N[i]を持つ必要はないはず。まあ10^5だからメモリパンクはしない・・・？
Nz = [0] * (len(S)+1)
Na = [0] * (len(S)+1)
Nb = [0] * (len(S)+1)
Nc = [0] * (len(S)+1)
Nz[0] = 1

for i in range(len(S)):
  if S[i] == '?':
    Nz[i+1] = (Nz[i] * 3) % MODN
    Na[i+1] = (Nz[i] + Na[i] * 3) % MODN
    Nb[i+1] = (Na[i] + Nb[i] * 3) % MODN
    Nc[i+1] = (Nb[i] + Nc[i] * 3) % MODN
  elif S[i] == 'A':
    Nz[i+1] = Nz[i]
    Na[i+1] = (Nz[i] + Na[i]) % MODN
    Nb[i+1] = Nb[i]
    Nc[i+1] = Nc[i]
  elif S[i] == 'B':
    Nz[i+1] = Nz[i]
    Na[i+1] = Na[i]
    Nb[i+1] = (Na[i] + Nb[i]) % MODN
    Nc[i+1] = Nc[i]
  elif S[i] == 'C':
    Nz[i+1] = Nz[i]
    Na[i+1] = Na[i]
    Nb[i+1] = Nb[i]
    Nc[i+1] = (Nb[i] + Nc[i]) % MODN
  else:
    print("Error!!")

print(Nc[len(S)])

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

int main() {
    int H,W,K;
    cin >> H >> W >> K;
    vector< vector<int> > board(H, vector<int>(W,0));
    int maxb = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            char c;
            cin >> c;
            if (c == '#') {
                board[i][j] = 1;
                maxb++;
            }
        }
    }
    int maxh = pow(2,H), maxw = pow(2,W);
    int ansnum = 0;
    vector< vector<int> > tboard(H, vector<int>(W,0));
    for (int i = 0; i < maxh; i++) {
        for (int j = 0; j < maxw; j++) {
            copy(board.begin(), board.end(), tboard.begin());
            int temp = 0;
            for (int k = 0; k < H; k++) {
                if (!((i>>k) & 1)) {
                    continue;
                } 
                for (int l = 0; l < W; l++) {
                    if (tboard[k][l]) {
                        tboard[k][l] = 0;
                        temp++;
                    }
                }
            }
            for (int k = 0; k < W; k++) {
                if (!((j>>k) & 1)) {
                    continue;
                } 
                for (int l = 0; l < H; l++) {
                    if (tboard[l][k]) {
                        tboard[l][k] = 0;
                        temp++;
                    }
                }
            }
            ansnum += (maxb - temp == K) ? 1 : 0;
        }
    }
    cout << ansnum << endl;
    return 0;
}

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a,b;
  cin >> a >> b;
  string ab=a+b;

  for (int i = 0; i < 1000; i++)
  {
    if(to_string(i*i)==ab){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
#define pb emplace_back
#define mp make_pair
#define MOD (int) 1e9+7
#define for0(i, n) for (int i = 0; i < n; i++)
#define ff first
#define ss second
#define endl "\n"
#define bits(n) __builtin_popcount(n)
#define ini(a, i) memset(a, i, sizeof(a))

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	// cin >> t;
	t  = 1;
	while (t--)
	{
		ll n;
		cin >> n;
		ll arr[n];
		ll p = 0;
		for (ll i = 0; i < n; i++)
		{
			cin >> arr[i];
			if (arr[i] == 0)
				p = 1;
		}
		if (p == 1)
		{
			cout << "0" << endl;
			return 0;
		}
		// sort(arr, arr + n);
		long double ans = 1;
		for (ll i = 0; i < n; i++)
		{
			// cout << arr[i] * ans << " " << (arr[i] * ans > (ll)1e18) << endl;
			if ((arr[i] * ans) > (ll)1e18)
			{
				cout << "-1" << endl;
				return 0;
			}
			else
				ans = ans * arr[i];
		}
		cout << (ll)ans << endl;
	}
	return 0;
}
//|| (arr[i] * ans) < 0

Measured memory_bytes: 4424
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323
//void quick(int *,long long,long long);

int main(){
     
	long int n,r;
	while(scanf("%d",&n)!=EOF){
		if(n==0)
			break;
		r=0;
		while(n>0){
			r+=n/5;
			n=n/5;
		}
		printf("%ld\n",r);
	}
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <inttypes.h>
#include <stdlib.h>

int cmp(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	if (a < b) return -1;
	return a > b;
}

#define MAX 271828

int N, K;
int A[MAX];

int ruisekiwa[MAX];

int count[MAX];

int ask[MAX];

int id(int q) {
	int l = 1, r = N;
	while (l <= r) {
		int m = l + (r - l) / 2;
		if (ask[m] == q) return m;
		else if (q < ask[m]) r = m - 1;
		else l = m + 1;
	}
	return 0;
}

int main(void) {
	int i;
	int target;
	uint64_t answer = 0;
	if (scanf("%d%d", &N, &K) != 2) return 1;
	for (i = 1; i <= N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}

	for (i = 1; i <= N; i++) {
		ruisekiwa[i] = (ruisekiwa[i - 1] + (A[i] % K)) % K;
	}
	for (i = 1; i <= N; i++) {
		ask[i] = ruisekiwa[i] = (ruisekiwa[i] + K - (i % K)) % K;
	}
	qsort(ask + 1, N, sizeof(*ask), cmp);
	for (i = 1; i <= N && i < K; i++) {
		count[id(ruisekiwa[i])]++;
	}

#if 0
	for (i = 1; i <= N; i++) {
		printf(" %d" + (i == 1), ruisekiwa[i]);
	}
	putchar('\n');
#endif

	target = 0;
	for (i = 1; i <= N; i++) {
#if 0
		printf(" %d" + (i == 1), target);
#endif
		answer += count[id(target)];
		target = (target - 1 + K) % K;
		target = (target + (A[i] % K)) % K;
		if (i + K - 1 <= N) count[id(ruisekiwa[i + K - 1])]++;
		count[id(ruisekiwa[i])]--;
	}
#if 0
	putchar('\n');
#endif

	printf("%" PRIu64 "\n", answer);
	return 0;
}


Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
#define int long long

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

  int n,a,b; cin >> n >> a >> b;
  a -= b;
  vector<int> h(n);
  for(int i = 0; i < n; i++){
    cin >> h[i];
  }

  function< int(int) > rec =
  [&](int k){
    vector<int> v;
    for(int i = 0; i < n; i++){
      if(h[i] - b*k > 0) v.push_back(h[i] - b*k);
    }
    int cnt = 0;
    for(int i = 0; i < v.size(); i++){
      cnt += (v[i] + a-1) / a;
    }
    return (cnt <= k);
  };

  int l = 0,r = 1e9+10;
  while(r - l > 0){
    int mid = (l + r) / 2;
    if(rec(mid)) r = mid;
    else l = mid + 1;
  }
  cout << l << endl;

  return 0;
}


Measured memory_bytes: 2916
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
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;}

#define INF 1120000000
#define long long long // for codeforces

int main(){
  int n;
  cin>>n;
  map<pair<int,int>, int> m;
  rep(i,n){
    int x,y,w;
    cin>>x>>y>>w;
    m[mp(x,y)] = w;
  }

  int ans = 0;
  for(auto &p : m){
    int x = p.fi.fi, y = p.fi.se;
    int dx[] = {0,1,1}, dy[] = {1,0,1};
    rep(i,4){
      int crnt = p.se;
      rep(j,3){
        int nx = x +  dx[j], ny = y + dy[j];
        auto q = mp(nx,ny);
        if(m.count(q)==1) crnt += m[q];
      }
      if(i%2==0){
        dx[1]*=-1;
        dx[2]*=-1;
      }
      else {
        dy[0]*=-1;
        dy[2]*=-1;
      }
      ans = max(ans, crnt);
    }
  }

  cout << ans << " / 1" << endl;

  return 0;
}

Measured memory_bytes: 9296
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

class WeightUnionFindTree
    attr_accessor:par,:rank,:weight
    def initialize(n)
      @par=Array.new(n){|i| i}
      @rank=array(n,0)
      @weight=array(n,0)
    end

    def find(x)
        return x if @par[x]==x
        y=find(@par[x])
        @weight[x]+=@weight[@par[x]]
        @par[x]=y
        return y
    end

    def union(x,y,z)
        rx=find(x)
        ry=find(y)
        if @rank[rx]<@rank[ry]
            @par[rx]=ry
            @weight[rx]=z-@weight[x]+@weight[y]
        else
            @par[ry]=rx
            @weight[ry]=-z-@weight[y]+@weight[x]
            @rank[rx]+=1 if @rank[rx]==@rank[ry]
        end
    end

    def diff(x,y)
        return @weight[x]-@weight[y]
    end

    def same?(x,y)
        return find(x)==find(y)
    end
end
N,M=get_i
wuft=WeightUnionFindTree.new(N)
flag=true
M.times do
    l,r,d=get_i
    l-=1
    r-=1
    if wuft.same?(l,r) and wuft.diff(l,r)!=d
      flag=false
      break 
    end
    wuft.union(l,r,d)
end
puts yn_judge(flag)

Measured memory_bytes: 4220
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

S = input()
T = input()
N = len(S)
M = len(T)

def check(S, T):
    N = len(S)
    for i in range(N):
        if S[i] != '?' and S[i] != T[i]:
            return False
    return True

# 前の方はなるべくaで埋めたいので、後ろからTとの一致を探す
ans = [''] * N
for i in range(N-M, -1, -1):
    # 当てはまる部分列を見つけたら、答えに追記してbreak
    if check(S[i:i+M], T):
        for j in range(i, i+M):
            ans[j] = T[j-i]
        break
else:
    # 見つからなければNG
    print('UNRESTORABLE')
    exit()

for i in range(N):
    if S[i] != '?':
        ans[i] = S[i]
    # 辞書順最小にしたいので、余っている?はaで埋める
    elif ans[i] == '':
        ans[i] = 'a'
print(''.join(ans))


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int A[111111];
int ma[111111];

signed main(){
    cin>>N;
    rep(i,N)cin>>A[i];

    int t=0;
    for(int i=0;i<N;i++){
        t--;
        if(A[i]==0)t=INT_MAX;
        else if(A[i]>0)chmax(ma[i],t);
        else chmin(t,-A[i]);
    }
    t=0;
    for(int i=N-1;i>=0;i--){
        t--;
        if(A[i]==0)t=INT_MAX;
        else if(A[i]>0)chmax(ma[i],t);
        else chmin(t,-A[i]);
    }

    int ans=0;
    rep(i,N)if(A[i]>0)ans+=min(A[i],ma[i]);
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
bool u[256][256],used[256];

bool dfs(int x){
  if(used[x])return 0;
  used[x]=1;
  bool res=1;
  for(int i='A';i<='Z';i++)if(u[x][i])res&=dfs(i);
  used[x]=0;
  return res;
}

int main(){
  int T;
  cin>>T;
  while(T--){
    int h,w;
    cin>>h>>w;
    char c[50][50],d;
    int x1[256],x2[256],y1[256],y2[256];
    for(int i='A';i<='Z';i++){
      x1[i]=y1[i]=1e9;
      x2[i]=y2[i]=-1;
    }

    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
	cin>>d;
	c[i][j]=d;
	x1[d]=min(x1[d],j);
	y1[d]=min(y1[d],i);
	x2[d]=max(x2[d],j);
	y2[d]=max(y2[d],i);
      }
    
    bool ans=1;
    memset(u,0,sizeof(u));
    memset(used,0,sizeof(used));
    for(int i='A';i<='Z';i++)
      for(int y=y1[i];y<=y2[i];y++)
	for(int x=x1[i];x<=x2[i];x++){
	  if(c[y][x]=='.')ans=0;
	  else if(c[y][x]!=i)u[c[y][x]][i]=1;
	}
    
    for(int i='A';i<='Z';i++){
      memset(used,0,sizeof(used));
      ans&=dfs(i);
    }
    cout<<(ans?"SAFE":"SUSPICIOUS")<<endl;  
  }
  return 0;
}

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

using ll = unsigned long long;
using namespace std;

int main(void) {
    ll l,r;
    cin >> l >> r;

    if(r-l >= 2019){
        std::cout << 0 << endl;
        return 0;
    }

    ll* div = new ll[r-l+1];
    ll temp;

    for(ll sp = l ; sp <= r; ++sp) {
        div[sp-l] = sp%2019;
    }

    // std::sort(div, div+(r-l));
    int minv = INT32_MAX;
    int temp2;
    // cout << "r-l:" << r-l << endl;
    for(int i = 0; i < r-l; ++i) {
        for(int j = i+1; j <= r-l; ++j) {
            temp2 = (div[i] * div[j])%2019;
            // cout << "temp2" << temp2 << endl;
            if(!(temp2)){
                std::cout << 0 << endl;
                return 0;
            } else if (temp2 < minv){
                minv = temp2;
            }
        }
    }

    std::cout << minv << endl;

    return 0;
}

Measured memory_bytes: 256
#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 _GLIBCXX_DEBUG

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

const int max_n = 55;
int n;
string s, txt = "ABC";

int main(){
    cin >> n;
    cin.ignore();
    getline(cin, s);
    int cnt = 0;
    rep(i, n-2) {
        if(s.substr(i, 3) == txt){
            cnt++;
            i+=2;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3640
import std.stdio, std.string, std.conv;
void main() {
	long n, m, l;
	"%d %d %d\n".readf(&n, &m, &l);
	long[][] a, b;
    foreach (_n; 0..n) a ~= readln.split.to!(long[]);
    foreach (_m; 0..m) b ~= readln.split.to!(long[]);
    foreach (_a; a) {
        long[] c = [];
        foreach (_l; 0..l) {
            long s = 0;
            foreach (_m; 0..m) s += _a[_m] * b[_m][_l];
            c ~= s;
        }
        c.to!(string[]).join(" ").writeln;
    }
}

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

int main (){
    int N;
    cin>>N;
    vector<int> A(N);
    vector<vector<int>> Q(3, vector<int>(0));
    for(int i=0; i<N; i++){
        cin>>A.at(i);
        for(int j=0; j<A.at(i); j++){
            int x, y;
            cin>>x>>y;
            Q.at(0).push_back(i);
          	Q.at(1).push_back(x-1);
          	Q.at(2).push_back(y);
        }
    }
  	int S=pow(2, N);
  	vector<int> Pat(N);
  	int Max=0;
    for(ll Bit=0; Bit<S; Bit++){
      	bool X=true;
      	int TemBit=Bit;
      	int NUM=0;
      	for(int i=0; i<N; i++){
          	Pat.at(i)=TemBit%2;
          	NUM += TemBit%2;
          	TemBit/=2;
          	
        }
      	for(int i=0; i<Q.at(0).size(); i++){
          	if(Pat.at(Q.at(0).at(i))==1){
              	if(!(Q.at(2).at(i)==Pat.at(Q.at(1).at(i)))){
                  	X=false;
                  	break;
                }
            }
        }
      if(X){
        	Max=max(Max, NUM);
      }
    }
  	cout<<Max;
 	
}




Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int main(void) {
	int N, T, A, H[100000];
 
	scanf("%d%d%d", &N, &T, &A);
	for (int i = 0; i < N; i++)
		scanf("%d", &H[i]);
	
	int  ans = 0;
	double id = -1.0;
	for (int i = 0; i < N; i++) {
		double tmp = T - (H[i] * 0.006);
 
		if (id == -1.0)
			id = tmp;
		else if (fabs(id - A) > fabs(tmp - A)) {
			id = tmp;
			ans = i;
		}
	}
	printf("%d\n", ans + 1);
 
	return 0;
}


Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    string s;
    cin>>s;

    int cnt=0;
    int front_white=-1;
    int back_red=-1;
    rep(i,n){
        if(s[i]=='W'){
            front_white=i;
            break;
        }
    }
    rep(i,n){
        if(s[n-1-i]=='R'){
            back_red=n-1-i;
            break;
        }
    }
    if(front_white==-1 || back_red==-1 || front_white>back_red){
        cout<<0<<endl;
        return 0;
    }
    while(front_white<back_red){
        cnt ++;
        s[front_white]='R';
        s[back_red]='W';
        rep(i,n-front_white){
            if(s[i+front_white]=='W'){
                front_white=i+front_white;
                break;
            }
            if(i+front_white==n-1) front_white=n;
        }
        for(int i=back_red-1;i>=0;i--){
            if(s[i]=='R'){
                back_red=i;
                break;
            }
            if(i==0) back_red=-1;
        }
    }
    cout<<cnt<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
#define forn(i,n) for(int i=0; i < int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back
#define fst first
#define snd second

const int N = 100100;

int L[N], R[N];

int main() {
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    forn(i, m) cin >> L[i] >> R[i];
    vector<pii> v(m);
    forn(i, m) v[i] = {R[i], i};
    sort(all(v));
    int prev = -1;
    int cnt = 0;
    for (pii p : v) {
        int i = p.snd;
        if (L[i] >= prev) {
            ++cnt;
            prev = R[i];
        }
    }
    cout << cnt << '\n';
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;

long long gcd( long long a, long long b ) {
    
    long long c = a%b;
    
    if ( !c ) { return b; }
    
    return gcd(b,c);
    
}

int main() {
    
    int N;
    long long K;
    vector<long long> A;
    
    cin >> N >> K;
    
    bool is_ok = false;
    for ( int i = 0; i < N; i++ ) {
        long long a;
        cin >> a;
        A.push_back(a);
        if ( K == a ) { is_ok = true; }
    }
    
    if ( is_ok ) {
        cout << "POSSIBLE" << endl;
        return 0;
    }
    
    if ( A.size() == 1 ) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    
    sort( A.begin(), A.end() );
    reverse( A.begin(), A.end());
    
    if ( K > A[0] ) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    
    long long g = gcd(A[0],A[1]);
    for ( int i = 2; i < N; i++ ) {
        g = gcd(g,A[i]);
    }
     
    if ( K%g == 0 ) {
        cout << "POSSIBLE" << endl;
        return 0;
    }
    
    
    cout << "IMPOSSIBLE" << endl;
    
    return 0;
}

Measured memory_bytes: 1400
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        Integer a = sc.nextInt();
        Integer b = sc.nextInt();
        for(int i=13;i<=10000;i++){
            double p = i*0.08;
            double q = i*0.10;
            Integer p_t = (int)p;
            Integer q_t = (int)q;
            if(p_t==a && q_t==b){
                System.out.println(i);
                return;
            }
        }
        System.out.println(-1);

    }
}


Measured memory_bytes: 23764
h, w = io.read("*n", "*n", "*l")
map = {}
for i = 1, h do
  map[i] = {}
  s = io.read()
  for j = 1, w do
    map[i][j] = s:sub(j, j) == "#"
  end
end
valid = true
for i = 1, h do
  for j = 1, w do
    if map[i][j] then
      f = false
      if 1 < i and map[i - 1][j] then
        f = true
      elseif i < h and map[i + 1][j] then
        f = true
      elseif 1 < j and map[i][j - 1] then
        f = true
      elseif j < w and map[i][j + 1] then
        f = true
      end
      if not f then valid = false end
    end
  end
end
print(valid and "Yes" or "No")


Measured memory_bytes: 2732
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

D, N = MAP()
if N == 100:
	print(100 ** (D)*N+ 100 ** (D))
else:
	print(100 ** D * N)


Measured memory_bytes: 3888
#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;

struct edge{int to,cost;};


vector<int> es[8]; //es[a][i] = b; a->b存在
bool checked[8];
int n,ans=0;

void dfs(int from){
	//checked[from] = true;
	bool hasNext=false;
	for(int i=0;i<es[from].size();i++){
		int to = es[from][i];
//		cout << "\t" << from << "->" << to << "\n";
		if(!checked[to]){
			hasNext=true;
			checked[to] = true;
//			cout << "dfs(" << to << ")\n";
			dfs(to);
			checked[to] = false;
		}
	}
	if(!hasNext){
//		cout << from << " has no next\n";
		for(int i=0;i<n;i++){
			if(!checked[i]) return;
		}
		ans++;
	}
	return;
}

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

	int m;
	cin >> n >> m;

	int a,b;
	for(int i=0;i<m;i++){
		cin >> a >> b;
		a--;b--;
		es[a].push_back(b);
		es[b].push_back(a);
	}
	checked[0]=true;
	dfs(0);

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

Measured memory_bytes: 256