akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<string.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1<<29;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	int n;
	cin>>n;
	ll h[100001];

	rep(i,n){
		cin>>h[i];
	}
	int t=0,t2=0;
	rep(i,n-1){
		if(h[i]>=h[i+1])t++;
		t2=max(t2,t);
		if(h[i]<h[i+1])t=0;
	}
	cout<<t2<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <vector>
#include <string>
#include <ctype.h>
#include <set>
#include <map>
#include<cstdio>
#include<queue>
#include<cstdlib>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<iostream>
#include<cstring>
#include<complex>
#include<tr1/unordered_set>
#include<tr1/unordered_map>


#define FOR(i,j,k) for(int i=j;i<k;i++)
#define FORD(i,j,k) for(int i=j;i>=k;i--)
#define ll long long
//Make sure no overflow problems
//#define int long long
#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define VAR(i,n) __typeof(n) i = (n)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();i++)
#define FORDEACH(i,c) for( VAR(i,(c).rbegin()),i!=(c).rend();i++)
#define REP(i,n) FOR(i,0,n)
#define ld long double
const int INF = 1000000009;
const long long INFLL = (ll)INF * (ll)INF;
const ld EPS = 10e-9;
const double pi=6.283185307179586232;

using namespace std;

#pragma GCC optimize ("Ofast")
static auto _ = [] { std::ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0); std::cerr.tie(0); return 0; } ();

int main() {
    ll n,m,k;
    ll sum=0;
    cin>>n>>m;
    FOR(i,0,m){
        cin>>k;
        sum+=k;
    }
    if(n-sum<0)
        cout<<-1;
    else
        cout<<n-sum;

    return 0;
}



Measured memory_bytes: 3712
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	// n以下の素数のリスト
	List<Integer> eratosthenes(int n) {
		boolean[] prime = new boolean[n + 1];

		Arrays.fill(prime, true);
		prime[0] = false;
		prime[1] = false;
		for (int i = 2; i * i <= prime.length; i++) {
			if (prime[i]) {
				for (int j = 2; j * i < prime.length; j++) {
					prime[j * i] = false;
				}
			}
		}

		ArrayList<Integer> result = new ArrayList<>();
		for (int i = 0; i < prime.length; i++) {
			if (prime[i]) {
				result.add(i);
			}
		}
		return result;

	}

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();

		List<Integer> prime = eratosthenes(55556);

		int c = 0;
		List<Integer> ans = new ArrayList<>();
		for (int i = 0; i < prime.size(); i++) {
			int n = prime.get(i);
			if (n % 5 == 1) {
				ans.add(n);
				c++;
			}
			if (c >= N) {
				break;
			}
		}

		for (int x : ans) {
			out.print(x + " ");
		}
		out.println();
		sc.close();

	}

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

}


Measured memory_bytes: 22100
/*Bismillahir Rahmanir Rahim.*/
#include <stdio.h>
#include<string.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a<=(b*c))
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}


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

    cout << C-min(A-B,C) << endl; 
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define mod 1000000007

ll a[200100]={0};
ll sum[200100]={0};
ll b[200100]={0};

int main(){
  ll l,k;
  ll a,ans=0;
  ll n,m;
  ll buc[100]={0};
  cin >> n >> m;
  rep(i,n){
    cin >> k;
    rep(j,k){
      cin >> a;
      buc[a]++;
    }
  }
  rep(i,50){
    if(buc[i]==n)ans++;
  }
  cout << ans <<endl;
}


Measured memory_bytes: 256
/* be name khoda */

// #define stream_enable
// #define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
using namespace std;

#ifdef stream_enable
#define cin sss
#endif
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

const ll MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debugp(x) cout << #x << " -> " << "(" << (x).F << ", " << (x).S << ")" << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_dav].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD

stringstream sss;

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

const ll maxn = 2010;
const ll maxa = 2003000;

ll n, A[maxn];
bitset<maxa> ks;

void MAIN() {

    cin >> n;
    fori (i, n) cin >> A[i];
    ll s = 0;
    ks[0] = 1;
    fori (i, n) {
        ks |= ks << A[i];
        s += A[i];
    }
    ll ans = (s + 1) / 2;
    while (ks[ans] == 0) ++ans;
    cout << ans << '\n';

}

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

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    sss << R"(

    )";
    MAIN();
    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#define int long long
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define fcout cout << fixed << setprecision(10)
using namespace std;

signed main() {
  int n;
  cin >> n;
  int c = 0;
  rep(a, 1, n+1) {
    rep(b, a, n+1) {
      if(n - a*b >= 1) {
        if(a == b) c++;
        else c += 2;
      } else break;
    }
  }
  cout << c << "\n";
}

Measured memory_bytes: 3584
s = input().strip()
k = int(input().strip())
days = 5 * (10 ** 15)
if len(s) == 1:
    print(s)
    exit()
before = 0
for i in range(0, len(s)):
    diff = 0
    if s[i] == "1":
        diff = 1
    else:
        for j in range(1, (days + 1), 1):
            if 10 ** 18 <= int(s[i]) ** j:
                diff = int(s[i]) ** j
                break
    if (k - 1) < (before + diff):
        print(s[i])
        break
    else:
        before = before + diff


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

int num(char c){
    if(c == 'A'){
        return 10;
    }
    if(c == 'B'){
        return 11;
    }
    if(c == 'C'){
        return 12;
    }
    if(c == 'D'){
        return 13;
    }
    if(c == 'E'){
        return 14;
    }
    if(c == 'F'){
        return 15;
    }
    return 0;
}

int main (){
    char x,y;
    cin >> x >> y;
    if(num(x)> num(y)){
        cout << '>';
    }else if(num(x) < num(y)){
        cout << '<';
    }else{
        cout << '=';
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N, h[100000], DP[100000];

int main() {
	cin >> N;
	for (int i = 0; i != N; ++i)
		cin >> h[i];
	DP[0] = 0;
	DP[1] = abs(h[1] - h[0]);
	for (int i = 2; i != N; ++i)
		DP[i] = min(DP[i - 1] + abs(h[i] - h[i - 1]), DP[i - 2] + abs(h[i] - h[i - 2]));
	cout << DP[N - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int N,R,L;
int D[1000009];
int T[1000009];
int X[1000009];
int point[100009];
int seg[1<<18];
int lnumber,lstart;
int tim[100009];
int INF=-1<<30;
int main()
{
	scanf("%d%d%d",&N,&R,&L);
	for(int i=0;i<R;i++){
		scanf("%d%d%d",&D[i],&T[i],&X[i]);D[i]--;
	}
	for(int i=(1<<17)-1+N;i<(1<<18)-1;i++){
		seg[i]=N+1;
	}
	for(int i=(1<<17)-1;i<(1<<17)-1+N;i++){
		seg[i]=i+1-(1<<17);
	}
	for(int i=(1<<17)-2;i>=0;i--){
		int point1,point2;
		if(seg[2*i+1]==N+1)point1=INF;
		else point1=point[seg[2*i+1]];
		if(seg[2*i+2]==N+1)point2=INF;
		else point2=point[seg[2*i+2]];
		if(max(point1,point2)==INF){
			seg[i]=N+1;
		}
		else if(point1>point2){
			seg[i]=seg[2*i+1];
		}
		else if(point1<point2){
			seg[i]=seg[2*i+2];
		}
		else{
			seg[i]=min(seg[2*i+1],seg[2*i+2]);
		}
	}
	for(int i=0;i<R;i++){
		point[D[i]]+=X[i];
		int now=(1<<17)-1+D[i];
		while(now>0){
			now-=1;now/=2;
			int point1,point2;
			if(seg[2*now+1]==N+1)point1=INF;
			else point1=point[seg[2*now+1]];
			if(seg[2*now+2]==N+1)point2=INF;
			else point2=point[seg[2*now+2]];
			if(max(point1,point2)==INF){
				seg[now]=N+1;
			}
			else if(point1>point2){
				seg[now]=seg[2*now+1];
			}
			else if(point1<point2){
				seg[now]=seg[2*now+2];
			}
			else{
				seg[now]=min(seg[2*now+1],seg[2*now+2]);
			}
		}
		if(lnumber!=seg[0]){
			tim[lnumber]+=(T[i]-lstart);
			lnumber=seg[0];lstart=T[i];
		}
	}
	tim[lnumber]+=(L-lstart);
	int ans=0;int ma=-1;
	for(int i=0;i<N;i++){
		//printf("%d:%d\n",i,tim[i]);
		if(ma<tim[i]){
			ma=tim[i];ans=i;
		}
	}
	printf("%d\n",ans+1);
	return 0;
}

Measured memory_bytes: 13472
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;文字列 -> 整数
(defn Int [s] (Integer/parseInt s))
;文字列 -> 文字列
(defn Str [s] s)

;scanf的なノリで1行をいい感じに読み取る
;定数が重いので注意
(defn input [varTypes]
    (mapv 
        (fn [f s] (f s)) ;文字列sに関数fを適用する
        varTypes         ;適用する関数
        (clojure.string/split 
            (read-line)  ;1行を読み込み
            #" "         ;区切り文字
        )
    )
)

;スペース区切りの整数を受け取る
;速い
(defn inputFast [varType]
    (map
        varType
        (clojure.string/split 
            (read-line)  ;1行を読み込み
            #" "         ;区切り文字
        )
    )
)

(defn floor [a b] (quot a b))
(defn ceil [a b] (floor (- (+ a b) 1) b))


;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

(defn abs [a]
    (if (> 0 a)
        (- 0 a)
        a
    )
)

(dosync
    (def l1 (input [Int Int Int Int]))
    (let [[a b c d] l1]
        (def ab (abs (- a b)))
        (def bc (abs (- b c)))
        (def ac (abs (- a c)))
        (if (or (<= ac d) (and (<= ab d) (<= bc d)))
            (println "Yes")
            (println "No")
        )
    )
)





Measured memory_bytes: 68316
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

//nCr mod m
#define MOD 1000000007
#define M 1000000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!h)init();
	if(n<0||r<0||n<r)return 1;//??????
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%m,m-2,m)%m;
	return out;
}
ll ncr(ll n,ll r){
	ll t=1;
	for(int i=n;i>=n-r+1;i--)(t*=i)%=MOD;
	loop(i,1,r+1)(t*=powmod(i,MOD-2,MOD))%=MOD;
	return t;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,a,b;
	cin>>n>>a>>b;
	int t=MOD-1;
	(t+=powmod(2,n)%MOD)%=MOD;
	(t+=MOD-ncr(n,a))%=MOD;
	(t+=MOD-ncr(n,b))%=MOD;
	cout<<t<<endl;
}









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

using namespace std;

int main() {
    int w, h, x, y;
    cin >> w >> h >> x >> y;

    double ans = (double)w*h/2;
    int num = (w == 2* x && h == 2 * y) ? 1 : 0;

    printf("%.10f %d\n", ans, num);
    


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
int n,m,l,k,a,h;
bool frez[125];
int dist[125][125];
vector<pii> g[125];

int main(){
  while(true){
    scanf("%d%d%d%d%d%d",&n,&m,&l,&k,&a,&h);
    if(n+m+l+k+a+h==0)return 0;
    for(int i=0;i<125;i++){
      frez[i] = false;
      g[i].clear();
      for(int j=0;j<125;j++){
        dist[i][j] = 830252521;
      }
    }
    frez[a] = frez[h] = true;
    while(l--){
      int x;
      scanf("%d",&x);
      frez[x] = true;
    }
    while(k--){
      int s,t,u;
      scanf("%d%d%d",&s,&t,&u);
      g[s].push_back(pii(t,u));
      g[t].push_back(pii(s,u));
    }
    priority_queue< pair<int,pii> > Q;
    dist[a][m] = 0;
    Q.push(make_pair(-0, pii(a,m)));
    while(Q.size()){
      pair<int,pii> PP = Q.top(); Q.pop();
      int p = PP.second.first;
      int d = PP.second.second;
      if(dist[p][d] != -PP.first)continue;
      // printf("%d,%d -> %d\n",p,d,dist[p][d]);
      // edge
      for(int c=0;c<g[p].size();c++){
        int to = g[p][c].first;
        int cost = g[p][c].second;
        int nd = d-cost;
        if(nd<0)continue;
        if(dist[p][d] + cost < dist[to][nd]){
          dist[to][nd] = dist[p][d] + cost;
          Q.push(make_pair(-dist[to][nd], pii(to,nd)));
        }
      }
      // refr
      if(frez[p] && d<m){
        if(dist[p][d] + 1 < dist[p][d+1]){
          dist[p][d+1] = dist[p][d] + 1;
          Q.push(make_pair(-dist[p][d+1], pii(p,d+1)));
        }
      }
    }
    int ans = 830252521;
    for(int i=0;i<=m;i++)ans = min(ans, dist[h][i]);
    if(ans == 830252521){
      puts("Help!");
    }else{
      printf("%d\n",ans);
    }
  }
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
typedef long long ll;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

ll modpow(ll a, ll p)
{
    if (p == 0)
        return 1;
    if (!(p % 2))
    {
        ll halfP = p / 2;
        ll half = modpow(a, p);
        return half * half % mod;
    }
    else
    {
        return a * modpow(a, p - 1) % mod;
    }
}

ll comb(int a, int b)
{
    if (b > a - b)
        return comb(a, a - b);
    ll ansMul = 1;
    ll ansDiv = 1;
    for (int i = 0; i < b; i++)
    {
        ansMul *= a - i;
        ansDiv *= i + 1;
        ansMul %= mod;
        ansDiv %= mod;
    }
    ll ans = ansMul * modpow(ansDiv, mod - 2) % mod;
    return ans;
}

int main() {
    int N; cin >> N;
    vector<int> A(N), B(N);
    int ma = 0;
    rep(i, N) {
        cin >> A[i];
        B[i] = A[i];
        ma = max(ma, A[i]);
    }
    sort(all(B));
    int ma2 = B[N-2];
    rep(i, N) {
        if (A[i] != ma) cout << ma << endl;
        else cout << ma2 << endl;
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string L;
ll mod = 1e9+7;
ll lis2[100005];
ll lis3[100005]; 

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

    cin >> L;
    lis2[0] = lis3[0] = 1;

    for (int i = 1;i < 100005;i++){
        lis2[i] = (lis2[i-1]*2)%mod;
        lis3[i] = (lis3[i-1]*3)%mod;
    }

    ll ans = 0;

    ll a = 1;
    ll b = 1;

    for (int i = 0;i < L.size();i++){
        if(L[i] == '1'){
            ans += (lis3[L.size()-i-1]*a)%mod;
            b = (b*2)%mod;
            a *= 2;
            a %= mod;
        }
        //cout << ans << endl;
    }

    cout << (ans+b)%mod << endl;

    return 0;

}

Measured memory_bytes: 2000
MOD = (10**9) + 7


class modint():
    def __init__(self, value):
        self.value = value % MOD

    def __int__(self):
        return int(self.value)

    def __float__(self):
        return float(self.value)

    def __str__(self):
        return str(self.value)

    def __repr__(self):
        return str(self.value)

    def __add__(self, other):
        return (modint(self.value + other.value) if isinstance(other, modint)
                else modint(self.value + other))

    def __sub__(self, other):
        return (modint(self.value - other.value) if isinstance(other, modint)
                else modint(self.value - other))

    def __mul__(self, other):
        return (modint(self.value * other.value) if isinstance(other, modint)
                else modint(self.value * other))

    def __truediv__(self, other):
        return (modint(self.value * pow(other.value, MOD - 2, MOD))
                if isinstance(other, modint)
                else modint(self.value * pow(other, MOD - 2, MOD)))

    def __pow__(self, other):
        return (modint(pow(self.value, other.value, MOD))
                if isinstance(other, modint)
                else modint(pow(self.value, other, MOD)))

    def __eq__(self, other):
        return (self.value == other.value if isinstance(other, modint)
                else self.value == (other % MOD))

    def __ne__(self, other):
        return (self.value == other.value if isinstance(other, modint)
                else self.value == (other % MOD))

    def __radd__(self, other):
        return (modint(other.value + self.value) if isinstance(other, modint)
                else modint(other + self.value))

    def __rsub__(self, other):
        return (modint(other.value - self.value) if isinstance(other, modint)
                else modint(other - self.value))

    def __rmul__(self, other):
        return (modint(other.value * self.value) if isinstance(other, modint)
                else modint(other * self.value))

    def __rtruediv__(self, other):
        return (modint(other.value * pow(self.value, MOD - 2, MOD))
                if isinstance(other, modint)
                else modint(other * pow(self.value, MOD - 2, MOD)))

    def __rpow__(self, other):
        return (modint(pow(other.value, self.value, MOD))
                if isinstance(other, modint)
                else modint(pow(other, self.value, MOD)))

    def modinv(self):
        """
        self.valueのmod MOD上での乗法逆元を返す
        >>> MOD
        13
        >>> x = modint(4)
        >>> x.modinv
        <bound method modint.modinv of 4>
        >>> x.modinv()
        10
        """
        return modint(pow(self.value, MOD - 2, MOD))


def main():
    N = int(input())
    A = ["{:0>60b}".format(int(i)) for i in input().split()]
    ans = modint(0)
    for i in range(60):
        num_one = 0
        for a in A:
            if a[-(i+1)] == "1":
                num_one += 1
        ans += ((N-num_one)*num_one)*(2**i)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 156916
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;


int main(){

  int N;
  string S;

  cin >> N;
  cin >> S;

  // if 000 -> ans[0]=1, if 100 -> ans[100]=1, if 999 -> ans[999]=1;
  int ans[1000]; // store 0 or 1 to answer

  for(int i=0; i<=999; i++)
    ans[i] = 0;

  for(int i=0; i<=9; i++) { // i is biggest keta
    for(int ii = 0; ii<=N-3; ii++) {
      if (atoi(S.substr(ii, 1).c_str()) == i) {
        for(int j=0; j<=9; j++) { // j is middle keta
          for(int jj = ii+1; jj<=N-2; jj++) {
            if (atoi(S.substr(jj, 1).c_str()) == j) {
              for(int k=0; k<=9; k++) { // j is middle keta
                for(int kk = jj+1; kk<=N-1; kk++) {
                  if (atoi(S.substr(kk, 1).c_str()) == k) {
                    ans[(atoi(S.substr(ii, 1).c_str()) * 100) +
                        (atoi(S.substr(jj, 1).c_str()) * 10) +
                        atoi(S.substr(kk, 1).c_str())] = 1;
                    break;
                    // cout << atoi(S.substr(ii, 1).c_str()) << atoi(S.substr(jj, 1).c_str()) << atoi(S.substr(kk, 1).c_str()) << endl;
                  }
                }
              }
              break;
            }
          }
        }
        break;
      }
    }
  }

  int count = 0;
  for(int i=0; i<=999; i++){
    if(ans[i] == 1){
      count++;
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
//OPTIMIZATONS
#pragma GCC optimize("02")
//CODE
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;

const int mod = 998244353;
const int N = 2e5+1;
int fact[N] = {0};
int inv[N] = {0};

int power(int a,int b,int mod){
	if(b==0) return 1;
	int t = power(a,b/2,mod);
	t *= t;
	t %= mod;
	if(b&1) return (t*a)%mod;
	return t;
}

int ncr(int n,int r,int mod){
	int nnum = fact[n];
	int nden= inv[n-r]; int rfact=inv[r];
	int ans = nnum;
	ans = (ans*rfact)%mod;
	ans = (ans*nden)%mod;
	return ans;
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	fact[0] = 1; inv[0] = 1;
	fact[1] = 1; inv[1] = 1;
	for(int i=2;i<N;i++) fact[i] = (fact[i-1]*i)%mod;
	for(int i=2;i<N;i++) inv[i] = (power(fact[i],mod-2,mod))%mod;

	int n,m,k;
	cin>>n>>m>>k;
	int res = 0;
	for(int i=0;i<=k;i++){
		int ans = m;
		ans = (ans * power(m-1,n-i-1,mod))%mod;
		ans *= ncr(n-1,i,mod);
		ans %= mod;
		res = (res+ans)%mod;
	}
	cout<<res<<endl;
	return 0;
}


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

int main(){
  int blood[4]={0,0,0,0};
  int num;
  char komma;
  string bl;
  int i;

  while(cin>>num>>komma>>bl){
    if(bl=="A") blood[0]++;
    else if(bl=="B") blood[1]++;
    else if(bl=="AB") blood[2]++;
    else blood[3]++;
  }
  cout<<blood[0]<<endl<<blood[1]<<endl;
  cout<<blood[2]<<endl<<blood[3]<<endl;

  return 0;
}

Measured memory_bytes: 0
a,b,c,d,e,f = map(int,input().split())
ans = [0,0,0]
for i in range(0,3000//(a*100)+1):
    for j in range(0,3000//(b*100)+1):
        g = i*a*100+j*b*100
        if i==j==0 or g>f:
            continue
        for k in range(0,(f-g)//c+1):
            for l in range(0,(f-g)//d+1):
                if g+k*c+l*d>f:
                    continue
                if ans[2]<=(k*c+l*d)/(g+k*c+l*d) and k*c+l*d<=e*g/100:
                    ans[0] = g+k*c+l*d
                    ans[1] = k*c+l*d
                    ans[2] = (k*c+l*d)/(g+k*c+l*d)
print(ans[0],ans[1])

Measured memory_bytes: 3064
open System

let K = int <| Console.ReadLine()

let rec g = function 
    | [] -> []
    | [x] -> [x]
    | x::xs -> x :: (g xs)

let rec f: int * int list -> int list = function
    | 0, xs -> xs 
    | n, x::xs -> f (n - 1, xs)
    | n, xs -> f (n - 1, xs)

let runrun = 
    let rec f (n: int) (xs: int list) =
        seq {
            match n, xs with
            | 0, xss -> xss 
            | n, [] -> for i in 1..9 do yield! f (n - 1) [i]
            | n, x::xs->
                if x > 0 then  yield! f (n - 1) ((x - 1)::x::xs)
                yield! f (n - 1) (x::x::xs)
                if x < 9 then yield! f (n - 1) ((x + 1)::x::xs)
        }
    let ls2num = List.rev >> List.fold (fun acc x -> acc * 10L + int64 x) 0L
    seq {
        for digits in Seq.initInfinite((+) 1) do 
            yield! f digits [] |> Seq.map ls2num
    }

runrun
|> Seq.item (K-1)
|> printfn "%i"

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

using namespace std;

long long MOD=998244353;

long long add_mod(long long x,long long y){
	return (x+y)%MOD;
}

long long sub_mod(long long x,long long y){
	return (x-y+MOD)%MOD;
}

long long mul_mod(long long x,long long y){
	return x*y%MOD;
}

int n;
long long dp[4001][4001];

void solve(){
    int i,j;
    string str;
    cin >> str;
    n = str.length();
    vector<int> r(n+1,0),b(n+1,0);
    for(i = 0;i < n;i++){
        if(str[i] == '0'){
            r[i+1] = r[i] + 2;
            b[i+1] = b[i];
        }
        else if(str[i] == '1'){
            r[i+1] = r[i] + 1;
            b[i+1] = b[i] + 1;
        }
        else{
            r[i+1] = r[i];
            b[i+1] = b[i] + 2;
        }
    }
    dp[0][0] = 1;
    for(i = 1;i <= 2*n;i++){
        int ch = i;
        if(ch > n) ch = n;
        for(j = 0;j <= i;j++){
            if(r[ch] >= j) dp[i][j] = add_mod(dp[i][j],dp[i-1][j-1]);
            if(b[ch] >= i-j) dp[i][j] = add_mod(dp[i][j],dp[i-1][j]);
        }
    }
    long long ans = 0;
    for(i = 0;i <= 2*n;i++) ans = add_mod(dp[2*n][i],ans);
    cout << ans << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 123520
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

class WarshallFloyd{
	vector<vector<ll>> dist;
public:
	void CalcShortestPath(ConnectNodeInfo& connect){
		int V = connect.size();
		dist.resize(V,vector<ll>(V,1LL<<60));

		REP(i,V){
			dist[i][i]=0;
			int U = connect[i].size();
			REP(j,U){
				dist[i][connect[i][j].first] = connect[i][j].second;
			}
		}

		REP(k,V){
			REP(i,V){
				REP(j,V){
					if(dist[i][k]!=(1LL<<60) && dist[k][j]!=(1LL<<60)){
						dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
					}
				}
			}
		}
	}
	bool HasNegativeLoop(){
		bool flag = false;
		for(int i=0,ei=dist.size();i<ei;i++){
			if(dist[i][i]<0){
				flag = true;
				break;
			}
		}
		return flag;
	}
	ll CalcDiameter(){
		ll diameter = -(1LL<<60);
		int V = dist.size();
		REP(i,V){
			REP(j,V){
				if(dist[i][j]<1LL<<60){
					diameter = max(diameter,dist[i][j]);
				}
			}
		}
		return diameter;
	}
	ll GetDistance(int i,int j){
		return dist[i][j];
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int H=in(),W=in();
	ConnectNodeInfo connect(10);
	REP(i,10){
		REP(j,10){
			int v=in();
			if(i==j) continue;
			connect.AddDirectionalConnection(i,j,v);
		}
	}
	
	WarshallFloyd WF;
	WF.CalcShortestPath(connect);
	
	int sum = 0;
	REP(i,H){
		REP(j,W){
			int v=in();
			if(v>=0){
				sum += WF.GetDistance(v,1);
			}
		}
	}
	out(sum);
	return 0;
}

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

int main(){
  string s,t;
  cin >> s >> t;
  int a,b;
  cin >> a >> b;

  string u;
  cin >> u;
  if (s== u){
    a--;
  }else {
    b--;
  }
  cout << a<< " " << b;
  return 0;
}

Measured memory_bytes: 256
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1 << 30;

int n,l;
int a[2333];

int main(){
	scanf("%d%d",&n,&l);
	int mn=inf,sum=0;
	for(int i=1;i<=n;i++)a[i]=l+i-1,sum+=a[i];
	mn=inf;
	int ans;
	for(int i=1;i<=n;i++){
		int res=sum-a[i];
		if(mn>abs(sum-res)){
			mn=abs(sum-res);
			ans=res;
		}
	}
	printf("%d\n",ans);

	return 0;
}


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


int main(){
	int a,b,c;
	scanf("%d/%d/%d",&a,&b,&c);
	if(b<=4)puts("Heisei");
	else puts("TBD");
	return 0;
}


Measured memory_bytes: 256
K, N = map(int,input().split())
#K: 湖1周の長さ, N:湖の周りにある家の数

A = list(map(int, input().split()))
A.sort()
dist = [A[0]+K-A[-1]] + [A[i]-A[i-1] for i in range(1, N)]
print(K-max(dist))


Measured memory_bytes: 25836
import java.util.*;

class Main{
    Scanner sc = new Scanner(System.in);
    
    Main(){
     while(true){
      int a = sc.nextInt();
      String op = sc.next();
      int b = sc.nextInt();
      if (op.equals("?"))break;
      int ans = 0;
      switch ( op ){
       case "+" :
        ans = a+b;
        break;
       case "-" :
        ans = a-b;
        break;
       case "*" :
        ans = a*b;
        break;
       case "/" :
        ans = a/b;
        break;
       }
       System.out.printf("%d\n",ans);
      }
    }
    public static void main(String[] args){
    new Main();
    }    
}


Measured memory_bytes: 26212
x=input() #input
lx=len(x)
y=input()
ly=len(y)
dp=[[0]*(ly+2) for _ in range(lx+2)]
for i in range(0,lx+1):
    dp[i][0]= i
for i in range(0,ly+1):
    dp[0][i]= i
    
for i in range(0,lx):
    for j in range(0,ly):
        if x[i]==y[j]:
            dp[i+1][j+1]= min(dp[i+1][j]+1, dp[i][j+1]+1, dp[i][j]) #xのi文字目とyのj文字目が同じ時の漸化式
        else:
            dp[i+1][j+1]= min(dp[i][j+1]+1, dp[i+1][j]+1,dp[i][j]+1) #その他の場合の漸化式
print(dp[lx][ly])


Measured memory_bytes: 42564
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
#define int long long 
	while (true) {
		int a, l;
		cin >> a >> l;
		if (a == 0) return 0;
		map<int,int> going;
		going[a] = 0;
		for (int i = 1; i >= 0; ++i) {
			int gogo[10] = {};
			int now = a;
			for (int q = 0; q < l; ++q) {
				gogo[now % 10]++;
				now /= 10;
			}
			int maxi = 0, mini = 0;
			for (int i = 0; i < 10; ++i) {
				REP(q, gogo[i]) {
					mini *= 10;
					mini += i;
				}
			}
			for (int i = 9; i >= 0; --i) {
				REP(q, gogo[i]) {
					maxi *= 10;
					maxi += i;
				}
			}
			a = maxi - mini;
			if (going.find(a) != going.end()) {
				cout << going[a] << " " << a << " " << i - going[a] << endl;
				break;
			}
			going[a] = i;
		}
	}
}



Measured memory_bytes: 3004
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

int main(){
    fast_io
    
    int n, m;
    cin>>n>>m;
    vector<int> a(n);
    int sum=0;
    rep(i,n) {
        cin>>a[i];
        sum+=a[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    int cnt=0;
    rep(i,m){
        if(a[i]*4*m<sum){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;


public class C{
	
	public static void Main(){
	
		int n = Int32.Parse( Console.ReadLine() );		
		Dictionary<int, int> even = new Dictionary<int, int>(n);
		Dictionary<int, int> odd = new Dictionary<int, int>(n);
		string[] args = Console.ReadLine().Split(' ');
		for(int i = 0; i < n; i++){
			int v = Int32.Parse(args[i]);
			if((i % 2) == 0){
				if(even.ContainsKey(v)){
					even[v]++;
				}else{
					even.Add(v,1);
				}
			}else{
				if(odd.ContainsKey(v)){
					odd[v]++;
				}else{
					odd.Add(v,1);
				}
			}			
		}
		
		int evenMax1 = even.OrderBy(x => x.Value).Last().Key;
		int numEvenMax1 = even[evenMax1];
		even.Remove(evenMax1);
		int evenMax2 = 0, numEvenMax2 = 0;
		if(even.Count > 0){
			evenMax2 = even.OrderBy(x => x.Value).Last().Key;
			numEvenMax2 = even[evenMax2];
		}
		
		int oddMax1 = odd.OrderBy(x => x.Value).Last().Key;
		int numOddMax1 = odd[oddMax1];
		odd.Remove(oddMax1);
		int oddMax2 = 0, numOddMax2 = 0;
		if(odd.Count > 0){
			oddMax2 = odd.OrderBy(x => x.Value).Last().Key;
			numOddMax2 = odd[oddMax2];
		}
		
		if( evenMax1 != oddMax1 ){
			Console.WriteLine(n - (numEvenMax1 + numOddMax1));
			
		}else if( numEvenMax2 == 0 && numOddMax2 == 0 ){
			Console.WriteLine(n - 
				Math.Max(numEvenMax1, numOddMax1));
		
		}else if( numEvenMax2 == 0 ){
			Console.WriteLine(n - 
				(numEvenMax1 + numOddMax2));
			
		}else if( numOddMax2 == 0 ){
			Console.WriteLine(n - 
				(numEvenMax1 + numOddMax2));
			
		}else{
			Console.WriteLine( n - 
				Math.Max(
					numEvenMax1 + numOddMax2, 
					numEvenMax2 + numOddMax1
				)
			);	
		}
		
	}
	
}

Measured memory_bytes: 24288
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int t = s.nextInt();
    int minAi = Integer.MAX_VALUE;
    int maxValue = 0;
    int maxValuePairs = 0;
    for (int i = 0; i < n; i++) {
      int ai = s.nextInt();
      minAi = Math.min(minAi, ai);
      if (ai - minAi > maxValue) {
        maxValue = ai - minAi;
        maxValuePairs = 1;
      } else if (ai - minAi == maxValue) {
        maxValue = ai - minAi;
        maxValuePairs++;
      }
    }
    System.out.println(maxValuePairs);
  }
}


Measured memory_bytes: 33084
type direction = N | E | W | S

type state = { dir : direction; pos : int * int }

let vert (x, y) = y * 5 + x

let has_edge grid ((x1, y1) as p1) ((x2, y2) as p2) =
  let v1, v2 = (vert p1), (vert p2) in
  try grid.(v1).(v2) with Invalid_argument _ -> false

let set_edge grid ((x1, y1) as p1) ((x2, y2) as p2) =
  let v1, v2 = (vert p1), (vert p2) in
  grid.(v1).(v2) <- true;
  grid.(v2).(v1) <- true

let load_grid grid =
  let rec loop i =
    let line = read_line () in
    for j = 0 to (String.length line) - 1 do
      if line.[j] = '1' then
        set_edge grid
                 (j, i / 2)
                 (if i mod 2 = 0 then (j + 1, i / 2) else (j, i / 2 + 1))
    done;
    loop (succ i)
  in
  try loop 0 with End_of_file -> ()

let rec forward grid { dir = d; pos = (x, y) as p } =
  let has_edge_to = has_edge grid (x, y) in
  match d with
  | N -> if has_edge_to (x - 1, y) then
           { dir = W; pos = (x - 1, y) }
         else if has_edge_to (x, y - 1) then
           { dir = d; pos = (x, y - 1) }
         else
           forward grid { dir = E; pos = p }
  | E -> if has_edge_to (x, y - 1) then
           { dir = N; pos = (x, y - 1) }
         else if has_edge_to (x + 1, y) then
           { dir = d; pos = (x + 1, y) }
         else
           forward grid { dir = S; pos = p }
  | S -> if has_edge_to (x + 1, y) then
           { dir = E; pos = (x + 1, y) }
         else if has_edge_to (x, y + 1) then
            { dir = d; pos = (x, y + 1) }
         else
           forward grid { dir = W; pos = p }
  | W -> if has_edge_to (x, y + 1) then
           { dir = S; pos = (x, y + 1) }
         else if has_edge_to (x - 1, y) then
           { dir = d; pos = (x - 1, y) }
         else
           forward grid { dir = N; pos = p }

let () =
  let grid = Array.init 25 (fun _ -> Array.make 25 false) in
  load_grid grid;
  let rec loop s =
    let s = forward grid s in
    print_char
      begin
        match s.dir with
        | N -> 'U'
        | E -> 'R'
        | S -> 'D'
        | W -> 'L'
      end;
    if s.pos = (0, 0) then print_newline ()
    else loop s
  in
  loop { dir = E; pos = (0, 0) }

Measured memory_bytes: 2016
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;
typedef pair<int, string> PP;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    map<string, int> m;
    rep (i, n) {
        string s; cin >> s; m[s]++;
    }
    int best = 0;
    for (auto i : m) chmax(best, i.second);
    vector<string> ans;
    for (auto i : m) if (i.second == best) ans.push_back(i.first);
    sort(all(ans));
    for (string i : ans) cout << i << "\n";
    return 0;
}

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

int main() {
	
  string a,b ;
  cin >> a >> b ;
  
  if ( a.at(0) == b.at(2) && a.at(1) == b.at(1) && a.at(2) == b.at(0) ) cout << "YES" ;
  else cout << "NO";


}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input().rstrip()
    print("Cloudy" if s == "Sunny" else "Sunny" if s == "Rainy" else "Rainy")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 2940
def main():
    # 下、右、上、左
    dyx = [(1, 0), (0, 1), (-1, 0), (0, -1)]
    H, W = map(int, input().split())
    s = ["." * (W + 2)]
    s += ["." + input() + "." for i in range(H)]
    s += ["." * (W + 2)]
    for y in range(1, H + 1):
        for x in range(1, W + 1):
            if "." == s[y][x]:
                continue
            for dy, dx in dyx:
                if "#" == s[y + dy][x + dx]:
                    break
            else:
                print("No")
                return
    print("Yes")
    return


main()


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

int main() {
  int  a,b;
  cin >> a >> b;
  for(int i=0;i<10000;i++){
    if(i*8/100 == a && i*10/100 == b){cout << i << endl;return 0;}
  }
  cout << -1 << endl;
}


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

int dp[MAX][5],in[MAX],n;

int solve(int pos,int mv=1)
{

    if(pos>=n)
        return 0;
    if(dp[pos][mv]!=-1)
        return dp[pos][mv];
    int res=abs(in[pos]-in[pos+1])+solve(pos+1,1);
    if((pos+2)<=n)
        res=min(res,abs(in[pos]-in[pos+2])+solve(pos+2,2));
    return dp[pos][mv]=res;
}

int main()
{

    int i,res;
    cin >> n;
    for(i=1; i<=n; i++)
        cin >> in[i];
    memset(dp,-1,sizeof(dp));
    res=solve(1);
    cout << res << "\n";


    return 0;
}


Measured memory_bytes: 7296
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());

    let (n, a) = (io.read::<i64>(), io.read::<i64>());
    io.writeln(n * n - a);
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 2136
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll h,w;
	cin>>h>>w;
	if(h == 1 || w == 1){
		cout<<1;
		return 0;
	}
	ll a = h*w;
	if(a%2 == 0){
		cout<<a/2;
	}	
	else{
		cout<<(a+1)/2;
	}

	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 ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

int main(){
    int N, X, Y;
    cin>>N>>X>>Y;
    vector<int> G[N];
    rep(i, N){
        if(i==0){
            G[i].push_back(i+1);
        }
        else if(i==N-1){
            G[i].push_back(i-1);
        }
        else{
            G[i].push_back(i+1);
            G[i].push_back(i-1);
        }
    }
    G[X-1].push_back(Y-1);
    G[Y-1].push_back(X-1);
    int a[N]={0};
    int d[N][N]={0};
    bool seen[N]={false};
    queue<int> Q;
    rep(i, N){
        seen[i]=true;
        Q.push(i);
        while(!Q.empty()){
            int b=Q.front();
            Q.pop();
            rep(j, G[b].size()){
                if(seen[G[b].at(j)]==false){
                d[i][G[b].at(j)]=d[i][b]+1;
                Q.push(G[b].at(j));
                seen[G[b].at(j)]=true;
                }
            }
        }
        
        rep(j, N){
            seen[j]=false;
        }
        
    }
        rep(j, N){
            rep(k, N){
                a[d[j][k]]++;
            }
        }
    for(int i=1;i<N;i++){
        cout<<a[i]/2<<endl;
    }
}

Measured memory_bytes: 16000