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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define whole(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
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(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  ll h; cin >> h;
  int n; cin >> n;
  vector<ll> a(n); cin >> a;
  ll as = 0; rep(i, n)as += a[i];
  if(as >= h)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>

int main(void)
{
  double r, c, s;

  while(scanf("%lf", &r) != EOF)
  {
    
    c = 2.0 * r * M_PI;
    s = r * r * M_PI;
  
    printf("%.6lf %.6lf\n", s, c);
  }

  return 0;
}





Measured memory_bytes: 2048
#include <iostream>
#include <cmath>
#include <set>
#include <string>
using std::cin;
using std::cout;
using std::endl;
using std::string;

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

    int count = 0;
    for (char i = '0'; i <= '9'; i++) {
        for (char j = '0'; j <= '9'; j++) {
            for (char k = '0'; k <= '9'; k++) {
                int flag = 0;
                for (int s = 0; s < N; s++) {
                    if (
                        (flag == 0 && S[s] == i) ||
                        (flag == 1 && S[s] == j) ||
                        (flag == 2 && S[s] == k)
                    ) {
                        flag++;
                    }
                    if (flag == 3) break;
                }
                if (flag == 3) count++;
            }
        }
    }

    cout << count << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long
string s;
LL mod = 1000000007;
LL su[100002];
LL dp[100002];
int main(){
  cin>>s;
  reverse(ALL(s));
  int n = s.size();
  REP(i,n+1){
    if(i==0)su[i]=3;
    else su[i]=(3*(su[i-1]-2)+2)%mod;
  }
  REP(i,n+1){
    if(i==0)dp[i]=1;
    else if(s[i-1]=='0')dp[i]=dp[i-1];
    else dp[i]=(su[i-1]+2*(dp[i-1]-1))%mod;
  }
  /*
  REP(i,n+1)cerr<<su[i]<<" ";
  cerr<<endl;
  REP(i,n+1)cerr<<dp[i]<<" ";
  cerr<<endl;
  */
  cout<<dp[n]<<endl;
  return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

string str;
int i, ok1;
int k, t, j, a[1000], lg;
int main()
{
    cin>>k>>t;
    for (i=1;i<=t;i++)
    {
        cin>>a[i];
    }
    sort(a+1, a+t+1);
    lg=t;
    while (lg>1)
    {
        a[lg]=a[lg]-a[1];
        for (j=1;j<lg;j++)
            a[j]=a[j+1];
        lg--;
        sort(a+1,a+lg+1);
    }
    cout<<max(a[1]-1, 0);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll N;
  cin >> N;
  ll ans=N;
  vl x(N),y(N);
  rep(i,N){
    cin >> x[i] >> y[i];
  }
  rep(i,N){
    rep(j,N){
      if(i==j){
        continue;
      }
      else{
        ll cnt=0;
        ll dx=x[i]-x[j],dy=y[i]-y[j];
        rep(I,N){
          rep(J,N){
            if(I==J){
              continue;
            }
            else{
              if(x[I]-x[J]==dx&&y[I]-y[J]==dy){
                cnt++;
              }
            }
          }
        }
        ans=min(ans,N-cnt);
      }
    }
  }
  cout << ans << endl;
}

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

#define pb push_back
#define fst first
#define snd second
#define INF 0x7fffffff
#define INFLL 0x7FFFFFFFFFFFFFFF
#define lenA(ar) sizeof(ar)/sizeof(*ar)
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define foreI(i,x,y) for(ll i=x-1;i>=y;i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;
ll n;
const int MAXN= 101;
const int m = 100000;
ll dp[MAXN][m+1];
ll val[MAXN];
ll we[MAXN];
ll solve(int pos,ll want){
    if(pos==n){
        if(want==0)return 0;
        return 1e16;
    }

    if(want<0)return 1e16;
    ll &r = dp[pos][want];
    if(r!=-1)return r;

    ll a = 1e16; ll b = 1e16;
    a = solve(pos+1,want-val[pos])+we[pos];
    b = solve(pos+1,want);
    r = min(a,b);
    return r;
}
int main() {FIN;
    
    cin>>n;
    ll weight;cin>>weight;
    fill(dp,-1);
    fore(i,0,n){
       cin>>we[i]; cin>>val[i];
    }
     ll ans = 0;
    fore(i,0,m+1){
         if(solve(0,i)<=weight)
            ans=i;


    }

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





Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
int n,ans;
int a[201];
int main(){
	cin>>n;
	for(int i=1;i<=2*n;i++)
		cin>>a[i];
	sort(a+1,a+1+2*n);
	for(int i=1;i<=2*n;i+=2)
		ans+=a[i];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
def LI():return list(map(int,input().split()))
def yes():return print("Yes")
def no():return print("No")
from collections import deque, defaultdict, Counter
from heapq import heappop, heappush
# import math
# pi=math.pi
# print(pi)
# yes()
# no()
# n=int(input())

# s=input()

a,b=LI()
print(a*b)


Measured memory_bytes: 64576
#define IO std::ios::sync_with_stdio(false);
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,k;
int a[100];
int main(){
	IO;
	int h=0;
	for(int i=1;i<=6;i++){
		cin>>k;
		a[k]++;
		h=max(h,a[k]);
	}
	if(h==3)cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
}

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

int main(){

	string s;
	cin >> s;

	int l,r;

	for(int i = 0; i < s.length(); i++){
		if(s[i] == 'A'){ l = i; break;}
	}

	for(int i = s.length(); i > 0; i--){
		if(s[i] == 'Z'){ r = i; break;}
	}

	cout << r - l + 1 << endl;

	return 0 ;
}


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

MAX = 10**5+100
MOD = 10**9+7
fact = [0]*MAX #fact[i]: i!
inv = [0]*MAX #inv[i]: iの逆元
finv = [0]*MAX #finv[i]: i!の逆元
fact[0] = 1
fact[1] = 1
finv[0] = 1
finv[1] = 1
inv[1] = 1
    
for i in range(2, MAX):
    fact[i] = fact[i-1]*i%MOD
    inv[i] = MOD-inv[MOD%i]*(MOD//i)%MOD
    finv[i] = finv[i-1]*inv[i]%MOD

def C(n, r):
    if n<r:
        return 0
    if n<0 or r<0:
        return 0
    return fact[n]*(finv[r]*finv[n-r]%MOD)%MOD

n = int(input())
a = list(map(int, input().split()))
idx = defaultdict(list)

for i in range(n+1):
    idx[a[i]].append(i)

for i in range(1, n+1):
    if len(idx[i])==2:
        f = idx[i][0]
        s = idx[i][1]
        break

for k in range(1, n+2):
    print((C(n-1, k)+2*C(n-1, k-1)-C(n+f-s, k-1)+C(n-1, k-2))%MOD)
    

Measured memory_bytes: 74652
#include <iostream>
#include <vector>
#include <algorithm>

int main(void){
    int N, x, ans=0;
    std::cin >> N >> x;
    std::vector<int> a(N);
    for (int i=0; i<N; ++i){
        std::cin >> a.at(i);
    }

    std::sort(a.begin(), a.end());

    for (int i: a) {
        x -= i;
        if (x < 0){
            break;
        } else {
            ++ans;
        }
    }

    if (x > 0 && ans > 0) {
        --ans;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3580
#include <iostream>

int main (){
   int x1, x2, x3, x4, x5;
   std::cin >> x1 >> x2 >> x3 >> x4 >> x5;
   if (x1 == 0){
      std::cout << 1;
   } else if (x2 == 0){
      std::cout << 2;
   } else if (x3 == 0){
      std::cout << 3;
   } else if (x4 == 0){
      std::cout << 4;
   } else if (x5 == 0){
      std::cout << 5;
   }
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}


signed main(){
  int a[3];
  FOR(i,3) cin >> a[i];
  sort(a,a+3);
  if(a[0]==5 && a[1]==5 && a[2] == 7) cout <<"YES\n";
  else cout <<"NO\n";

  return 0;
}

  

struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;
int dp[N][2][2];
string d;
int dfs(int pos, bool lead = true, bool limit = true)
{
	if (pos == -1)
	{
		return 1;
	}
	if (dp[pos][lead][limit] != -1) return dp[pos][lead][limit];
	int& ret = dp[pos][lead][limit] = 0;

	int up = limit ? d[pos] - '0' : 1;
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			if (i + j == 2) continue;
			int o = (i ^ j);
			if (o > up) continue;
			ret += dfs(pos - 1, lead && o == d[pos] - '0', limit && o == d[pos] - '0');
			if (ret >= INF) ret -= INF;
		}
	}
	return ret;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	MEM(dp, -1);
	cin >> d;
	reverse(d.begin(), d.end());
	cout << dfs(d.length() - 1) << endl;
	return 0;
}

Measured memory_bytes: 11392
#include<iostream>
using namespace std;
inline int gcd(int a,int b) {
    int r;
    while(b>0) {
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
int main(){
	int k;
	cin>>k;
	cout<<360/gcd(360,k)<<endl; 
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, d;
  cin >> n >> d;
  vector<vector<double>> c(n, vector<double>(d));
  for(int i = 0; i < n; i++) for(int j = 0; j < d; j++) cin >> c[i][j];
  int cnt = 0;
  for(int i = 0; i < n; i++) for(int j = i + 1; j < n; j++){
    double sq = 0;
    for(int k = 0; k < d; k++){
      sq += (c[i][k] - c[j][k]) * (c[i][k] - c[j][k]);
    }
    sq = sqrt(sq);
    if(abs(sq - floor(sq)) < 1e-9) cnt++;
  }
  cout << cnt;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
//template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
const int MAX_M = 1010;
const int MAX_B = (1<<12)+10;
const int INF = 1000000000;

signed main() {
    int N, M;
    vector<int> p;
    vector<int> op;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        p.emplace_back(a);
        int tmp = 0;
        for (int i = 0; i < b; i++) {
            int c; cin >> c; c--; tmp |= (1<<c);
        }
        op.emplace_back(tmp);
    }
    
    vector<vector<int>> dp(MAX_M, vector<int>(MAX_B, INF));
    for (int i = 0; i < MAX_M; i++) dp[i][0] = 0;
    
    for (int i = 0; i < M; i++) {
        for (int s = 0; s < (1<<N); s++) dp[i+1][s] = dp[i][s];
        for (int s = 0; s < (1<<N); s++) {
            int k = (s|op[i]);
            chmin(dp[i+1][k], dp[i][s] + p[i]);
        }
    }
    
    int ans = dp[M][(1<<N)-1];
    if (ans == INF) ans = -1;
    cout << ans << endl;
    //for (int i = 0; i < (1<<N); i++) cout << dp[i] << " ";
    /*
    for (int i = 0; i <= M; i++) {
        for (int j = 0; j < (1<<N); j++) {
            int now = dp[i][j];
            if (now == INF) now = -1;
            cout << now << " ";
        } 
        cout << endl;
    }
    */
    return 0;
}

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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        long[] a=new long[n];
        long[] b=new long[n];
        StringTokenizer st;
        for(int i=0;i<n;i++){
            st=new StringTokenizer(br.readLine());
            a[i]=Integer.parseInt(st.nextToken());
            b[i]=Integer.parseInt(st.nextToken());
        }
        long count=0;
        for(int i=n-1;i>=0;i--){
            //System.out.println(count);
            a[i]+=count;
            while(a[i]%b[i]!=0){
                count+=(b[i]-a[i]%b[i]);
                a[i]+=(b[i]-a[i]%b[i]);
            }//System.out.println(Arrays.toString(a)+"\n"+Arrays.toString(b));
        }System.out.println(count);
    }
}

Measured memory_bytes: 28708
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b,c;
	cin>>a>>b>>c;
	if(b+c<a)
	{
	    cout<<0;
	}
	else
	{
	    cout<<b+c-a;
	}
	return 0;
}

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

int main() {
  int a;
  cin>>a;
  int p=0;
  int l;
  
  for(int i=0;i<a;i++){
    cin>>l;
    while(l%2==0){
      p++;
      l/=2;
    }
  }
  
  cout<<p<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N; cin >> N;
    vector<int> r(N);
    for(int i=0; i<N; i++) cin >> r[i];

    int ans = -pow(10, 9);

    int minj = r[0];
    for(int i=1; i<N; i++){
        int tmp = r[i]-minj;
        ans = max(ans, tmp);
        minj = min(minj, r[i]);

    }

    cout << ans << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[(int)2e5 + 100];
int main(){
	ll n,k;
	cin>>n>>k;
	ll arr[(int)2e5 + 100];
	for(int i = 1;i<=n;i++)cin>>arr[i];
	for(int i = 1;i<=n + 5;i++)dp[i] = (long long)1e9;
	dp[1] = 0;
	for(int i = 1;i<=n;i++){
		for(int j = 1;j <= k;j++){
		dp[i + j] = min(dp[i + j], dp[i] + abs(arr[i] - arr[i + j]));
		}
	}
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) cin >> a.at(i);
    string ans = "APPROVED";
    for(int i = 0; i < n; ++i){
        if(a.at(i) % 2 == 0){
            if(a.at(i) % 3 == 0 || a.at(i) % 5 == 0) continue;
            else ans = "DENIED";
        }
    }    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
from collections import deque
n = int(input())
P = int(''.join(input().split()))
Q = int(''.join(input().split()))

#dfsで探索
def dfs(s,tmp):
    #nより桁数大きいかP,Qよりも大きいときには打ち切り
    if len(s)>n+1 or int(s)>max(P,Q):
        return tmp
    #桁数がnの時に++1,P,Qと一致するかもチェック
    if len(s)==n+1:
        tmp+=1
        if int(s)==P:
            global a
            a = tmp
        if int(s)==Q:
            global b 
            b = tmp
        return tmp
    for c in [str(i) for i in range(1,n+1)]:
        if c not in s:
            tmp = dfs(s+c,tmp)
    return tmp

tmp = 0
a,b = 0,0
dfs('0',tmp)
print(abs(a-b))

Measured memory_bytes: 3316
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <numeric>
#include <bitset>
#include <stack>
#include <cstring>
using namespace std;

const int INF = 1 << 30;
const double EPS = 1e-10;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int main()
{
  string s;
  while (cin >> s) {
    if (s[0] == 'x' && s[s.size()-1] == 'x')
      cout << "x" << endl;
    else
      cout << "o" << endl;
  }
  return 0;
}

Measured memory_bytes: 1176
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  s=S()
  t=S()

  ans=0
  for i in range(3):
    if s[i]==t[i]:
      ans+=1
  return ans

# main()
print(main())


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

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

#define fst first
#define snd second
#define pb push_back

const int maxn=1000005,maxm=55;
const double pi=acos(-1.0);
const ll mod=1000000007;
const double eps=1e-6;

ll ksm(ll a,ll p)
{
    ll r=1;
    while(p>0)
    {
        if(p&1) r=r*a%mod;
        a=a*a%mod;
        p>>=1;
    }
    return r;
}

int n;
vector<int> E[maxn];

int fat[maxn],cnt[maxn],dl[maxn],dln=0,sta;
ll dp[maxn],dh[maxn],dq[maxn];
ll jc[maxn]={1,0},jci[maxn]={1,0};

ll ans[maxn];

int main()
{
	int i,j,k;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
    {
        jc[i]=jc[i-1]*i%mod;
        jci[i]=ksm(jc[i],mod-2);
    }
	for(i=0;i<n-1;i++)
    {
        int x,y;
        scanf("%d %d",&x,&y);
        --x;--y;
        E[x].pb(y);
        E[y].pb(x);
    }
    dl[dln++]=0;sta=0;memset(fat,-1,sizeof(fat));
    while(sta<dln)
    {
        int x=dl[sta++];
        for(i=0;i<E[x].size();i++)
        {
            int y=E[x][i];
            if(fat[x]==y) continue;
            fat[y]=x;
            dl[dln++]=y;
        }
    }
    for(i=n-1;i>=0;i--)
    {
        int x=dl[i];
        cnt[x]=1;
        for(j=0;j<E[x].size();j++)
        {
            int y=E[x][j];
            if(y!=fat[x]) cnt[x]+=cnt[y];
        }
    }
    memset(dq,-1,sizeof(dq));
    for(i=n-1;i>=0;i--)
    {
        int x=dl[i];
        dp[x]=jc[cnt[x]-1];
        for(j=0;j<E[x].size();j++)
        {
            int y=E[x][j];
            if(y!=fat[x])
            {
                dp[x]*=jci[cnt[y]];dp[x]%=mod;
                dp[x]*=dp[y];dp[x]%=mod;
            }
        }
    }
    dh[0]=1;
    for(i=1;i<n;i++)
    {
        int x=dl[i],y=fat[x];
        dh[x]=jc[n-cnt[x]-1];
        if(dq[y]<0)
        {
            dq[y]=1;
            for(j=0;j<E[y].size();j++)
            {
                int z=E[y][j];
                if(z==fat[y]) continue;
                dq[y]*=dp[z];dq[y]%=mod;
                dq[y]*=jci[cnt[z]];dq[y]%=mod;
            }
        }
        dh[x]*=dq[y]%mod;dh[x]%=mod;
        dh[x]*=dh[y];dh[x]%=mod;
        dh[x]*=jci[n-cnt[y]];dh[x]%=mod;
        dh[x]*=ksm(dp[x],mod-2);dh[x]%=mod;
        dh[x]*=jc[cnt[x]];dh[x]%=mod;
    }
    for(i=0;i<n;i++)
    {
        ans[i]=dh[i]*dp[i]%mod*jc[n-1]%mod*jci[cnt[i]-1]%mod*jci[n-cnt[i]]%mod;
        printf("%d\n",int(ans[i]));
    }
    return 0;
}


Measured memory_bytes: 66420
#include<stdio.h>
   int main(void){
      int S,h,m,s;
  
      scanf("%d",&S);
  
      h = S/3600;
      m = (S-(3600*h))/60;
      s = S-(3600*h + 60*m);
  
      printf("%d:%d:%d\n",h,m,s);
  
      return 0;
   }


Measured memory_bytes: 2100
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include <string>
#include <math.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
  ll n; cin >>n;
  std::vector<ll> a(n);
  cinf(n,a);
  sort(a.begin(),a.end());
  if(a[0]>=0){
    ll sum=a[0];
    for(int i=1;i<n-1;i++){
      sum-=a[i];
    }
    cout << a[n-1]-sum << endl;
    ll sum1=a[0];
    for(int i=1;i<n-1;i++){
      cout << sum1 << " " << a[i] << endl;
      sum1-=a[i];
    }
    cout << a[n-1] << " " << sum1 << endl;
    return 0;
  }
  else if(a[n-1]<=0){
    ll sum=a[n-1];
    for(int i=n-2;i>=0;i--){
      sum-=a[i];
    }
    cout << sum << endl;
    ll sum1=a[n-1];
    for(int i=n-2;i>=0;i--){
      cout << sum1 << " " << a[i] << endl;
      sum1-=a[i];
    }
    return 0;
  }
  else{
    ll Max=a[n-1];
    ll Min=a[0];
    for(int i=1;i<n-1;i++){
      if(a[i]<=0){
        Max-=a[i];
      }
      else{
        Min-=a[i];
      }
    }
    cout << Max-Min << endl;
    ll Max1=a[n-1];
    ll Min1=a[0];
    for(int i=1;i<n-1;i++){
      if(a[i]<=0){
        cout << Max1 << " " << a[i] << endl;
        Max1-=a[i];
      }
      else{
        cout << Min1 << " " << a[i] << endl;
        Min1-=a[i];
      }
    }
    cout << Max1 << " " << Min1 << endl;
    return 0;
  }
}

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

double dp[301][301][301];

int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(10);
    int n;
    cin>>n;
    int arr[n];
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    int dp[n][n][2];
    memset(dp,0,sizeof(dp));
    for(int diff=0; diff<n; diff++)
    {
        for(int i=0; i<n; i++)
        {
            int j = i+diff;
            if(j >= n)
                continue;
            if(i==j)
            {
                dp[i][j][0] = arr[i];
                dp[i][j][1] = arr[i]*-1;
            }
            else
            {
                dp[i][j][0] = max(arr[i] + dp[i+1][j][1] ,arr[j] + dp[i][j-1][1]);
                dp[i][j][1] = min(dp[i+1][j][0] - arr[i], dp[i][j-1][0] - arr[j]);            
            }
        }
    }
    cout<<dp[0][n-1][0];
    return 0;
}

Measured memory_bytes: 140928
#include<bits/stdc++.h>
#define pb push_back
#define pf push_front

using namespace std;
typedef long long int lli; 

string s;
lli a,n,b,c,t,temp1,temp2,x,y,temp,q,d,k,mod=1e9+7;
vector<lli>v(300005);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	map<lli,lli>mp;
	
	cin>>n;
	lli val=0;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		mp[a]++;
		v[i]=a;
	}
	
	vector<lli>ans;
	for(auto x:mp)
	{
		val+=(x.second*(x.second-1)/2);	
	}
	
	for(int i=0;i<n;i++)
	{
		ans.pb(val-(mp[v[i]]*(mp[v[i]]-1)/2)+((mp[v[i]]-1)*(mp[v[i]]-2)/2));
	}
	
	for(auto x:ans)cout<<x<<endl;
}


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

def isprime(n):
    if (n <= 1) : 
        return False
    if (n <= 3) : 
        return True
    if (n % 2 == 0 or n % 3 == 0) : 
        return False
    i = 5
    while(i * i <= n) : 
        if (n % i == 0 or n % (i + 2) == 0) : 
            return False
        i = i + 6

    return True
def fun(n):
    i = n
    while 1:
        if isprime(i):
            break
        i+=1
    return i

print(fun(n))

Measured memory_bytes: 3064
from fractions import gcd
N=int(input())
A=list(map(int,input().split()))
L=[0]
R=[0]
for i in range(N):
    L.append(gcd(L[i],A[i]))
    R.append(gcd(R[i],A[-(i+1)]))
R=R[::-1]
ans=0
for i in range(N):
    ans=max(ans,gcd(L[i],R[i+1]))
print(ans)

Measured memory_bytes: 95456
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
	static int mod = (int)1e9+7;
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	public static void main(String sp[])throws IOException{
		FastReader sc = new FastReader();
		long n = sc.nextLong();
		long m = sc.nextLong();
		if(n==1 || m==1){
			System.out.println("1");
			return;
		}
		long ans = ((m*n)+1)/2;
		System.out.println(ans);
	}
	
	
	public static class pair{
		int a;
		int b;
	}
	
	
	
	static int parent[];
	public static int find(int a){
		if(parent[a]==a)
			return a;
		int rep = find(parent[a]);
		parent[a]=rep;
		return rep;
	}
	public static void join(int a, int b){
		int f1 = find(a);
		int f2 = find(b);
		if(f1==f2)
			return;
		
		if(f1<f2)
			parent[f2] = f1;
		else parent[f1] = f2;
	}
	
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 21332
n = int(input())
s = input()


white = 0
for i in s:
    if(i=='.'):
        white += 1
        
# 全部黒の場合
        
ans = white

# 左からi+1 個白の場合

now = white

for i in range(n):
    if(s[i]=='#'):
        now+=1
    else:
        now-=1
    ans = min(now,ans)

print(ans)


Measured memory_bytes: 73560
#include<cstdio>
#include<algorithm>
#include<cstring>
#define MN 10005
using namespace std;
typedef long long ll;
int n,fr[MN],maxn=1,ans[MN],res[MN],tt,tans;ll a[MN],f[MN];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]),f[i]=a[i];
	for(int i=1;i<=n;i++)
		for(int j=1;j<i;j++)if((i-j)%2==0&&f[j]+a[i]>f[i])f[i]=f[j]+a[i],fr[i]=j;
	for(int i=2;i<=n;i++)if(f[i]>f[maxn])maxn=i;printf("%lld\n",f[maxn]);
	for(int i=n;i>maxn;i--)res[++tans]=i;int tmp=maxn;ans[++tt]=maxn;
	while(fr[tmp])ans[++tt]=fr[tmp],tmp=fr[tmp];
	for(int i=1;i<ans[tt];i++)res[++tans]=1;
	for(int i=tt-1;i>=1;i--){
		for(int j=(ans[i]+ans[i+1])/2-ans[i+1]+1;j>1;j--)res[++tans]=j;
	}printf("%d\n",tans);
	for(int i=1;i<=tans;i++)printf("%d\n",res[i]);
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
#include<list>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//int型0~9を文字0~9に変換
char int_to_char(int c) {
	if (c == 0) return '0';
	if (c == 1) return '1';
	if (c == 2) return '2';
	if (c == 3) return '3';
	if (c == 4) return '4';
	if (c == 5) return '5';
	if (c == 6) return '6';
	if (c == 7) return '7';
	if (c == 8) return '8';
	if (c == 9) return '9';
	else return'x';
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	int n, q;
	int S[100000], T[50000];
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> S[i];
	}
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		cin >> T[i];
	}

	int ans = 0;
	for (int i = 0; i < q; i++)
	{
		int x = T[i];
		int l = 0, r = n - 1;
		while (r - l > 1)
		{
			int mid = (l + r) / 2;
			if (S[mid] == x)
			{
				if (S[l] == x || S[r] == x) break;
				else
				{
					ans++;
					break;
				}
			}
			else if (S[mid] > x)
			{
				r = mid;
			}
			else if (S[mid] < x)
			{
				l = mid;
			}
		}
		if (S[l] == x || S[r] == x) ans++;
	}

	cout << ans << endl;

	return 0;
}


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

using ll = long long;
const int mx = 2e5 + 10;
int vis[mx], vis2[mx], cmp1, cmp2, ans[mx];
vector < int > G[mx], R[mx];
vector < int > cm[mx], cm1[mx];

void dfs1( int u ) {
    vis[u] = cmp1;
    for( int v: G[u] ) {
        if( !vis[v] ) {
            dfs1( v );
        }
    }
    cm[ cmp1 ].push_back( u );
}

void dfs2( int u ) {
    vis2[u] = cmp2;
    for( int v: R[u] ) {
        if( !vis2[v] ) {
            dfs2( v );
        }
    }
    cm1[ cmp2 ].push_back( u );
}

int main() {
    #ifdef LU_SERIOUS
        freopen( "in.txt", "r", stdin );
    #endif // LU_SERIOUS
    int n, k, l, x, y;
    map < int, vector < int > > mp;
    while( cin >> n >> k >> l ) {
        for( int i=0; i<=n; i++ ) {
            G[i].clear();
            R[i].clear();
            cm[i].clear();
            cm1[i].clear();
            vis[i] = 0;
            vis2[i] = 0;
            ans[i] = 1;
        }
        for( int i=0; i<k; i++ ) {
            cin >> x >> y;
            G[x].push_back( y );
            G[y].push_back( x );
        }
        for( int i=0; i<l; i++ ) {
            cin >> x >> y;
            R[x].push_back( y );
            R[y].push_back( x );
        }
        cmp1 = 0;
        cmp2 = 0;
        for( int i=1; i<=n; i++ ) {
            if( !vis[i] ) {
                cmp1++;
                dfs1( i );
            }
            if( !vis2[i] ) {
                cmp2++;
                dfs2( i );
            }
        }
        for( int i=1; i<=cmp2; i++ ) {
            mp.clear();
            for( int v: cm1[ i ] ) {
                mp[ vis[ v ] ].push_back( v );
            }
            for( auto xx: mp ) {
                for( int v: xx.second ) {
                    ans[ v ] += int( ( xx.second.size() - 1 ) );
                }
            }
        }
        for( int i=1; i<=n; i++ ) cout << ans[i] << " \n"[ i==n ];
    }
    return 0;
}


Measured memory_bytes: 40568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2005;
const int mod=1e9+7;

#define endl "\n"

int fac[N],inv_fac[N]; 

int qpow(int base,int p,int mod){//快速幂取模 
	int ans=1;
	while(p){
		if(p&1) ans=1ll*ans*base%mod;
		base=1ll*base*base%mod;
		p>>=1;
	}
	return ans;
}

int inv(int a,int p){//费马小定理求逆元 
	return qpow(a,p-2,p);
}

void solve(int n,int mod){//阶层计算预处理 
	fac[0]=inv_fac[0]=1;
	for(int i=1;i<=n;i++){
		fac[i]=1ll*fac[i-1]*i%mod;
		inv_fac[i]=inv(fac[i],mod);
	}
}

int C(int n,int m){//原理C(n,m)=n!/(n-m)!/m! 
	if(n<0||m<0||m>n) return 0;
	return (1ll*fac[n]*inv_fac[n-m]%mod)*inv_fac[m]%mod;
}

int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int k,n;
	cin>>n>>k;
	solve(n,mod);
	for(int i=1;i<=k;i++){
		cout<<1ll*C(k-1,i-1)*C(n-k+1,i)%mod<<endl;
		//cout<<1ll*C(k-1,i-1)*(1ll*C(n-k-1,i-2)+C(n-k-1,i-1)+C(n-k-1,i))%mod<<endl;
	}
	return 0;
}
/*
隔板法。
k个蓝球分成i分，所有蓝球之间有k-1个间隙，需要有i-1个隔板， 
故共有C(k-1,i-1)种分法。 
n-k个红球，共有n-k+1个位置用于放蓝球堆，选其中i个位置
作为隔板，C(n-k+1,i)。
组合数可以用递推公式C(n,m)=C(n-1,m)+C(n-1,m-1)求得，
时间复杂度O(n^2) ，也可以求阶乘和阶乘的逆元求组合数，复杂度更低。 
*/

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int N, count = 0;
  
  scanf("%d", &N);
  
  while(N >= 1){
    if(N%10 == 1){
      count++;
    }
    N = N/10;
  }
  
  printf("%d\n", count);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <math.h>

using namespace std;
//for (int i = 0; i < N; i++){}


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

    map<int, int> mp;

    for(int i=N;i>1;i--){
        int jiku = i;
        for(int k=2;k<=i;k++){
            while(jiku%k == 0){
                    jiku = jiku/k;
                    mp[{k}]++;
            }
        }
    }
    long long res = 1;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        res *= (itr->second + 1);    // 値を表示
        res = res % 1000000007;
//        cout << itr->first << ":" << itr->second << endl;
//        cout << (itr->second + 1) % 1000000007 << endl;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<utility>
#include<algorithm>
#include<functional>
#include<deque>
#include<cctype>
#include<ctime>
#include<cstdlib>
#include<iomanip>
using namespace std;

int main(){
   int n;
   cin >> n;
   int sn = 0;
   int cp = n;
   while (cp){
      sn += cp%10;
      cp /= 10;
   }
   if (floor(1.0*n/sn) == ceil(1.0*n/sn)) cout << "Yes" << endl;
   else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	static char atta[2000000] = {0};
	int a, m;
	if (scanf("%d", &a) != 1) return 1;
	m = 1;
	for (;;) {
		if (atta[a]) {
			printf("%d\n", m);
			return 0;
		} else {
			atta[a] = 1;
			if (a % 2 == 0) a = a / 2; else a = 3 * a + 1;
			m++;
		}
	}
}


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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if (b == a) {
        cout << "YES" << '\n';
    } else if (b < a) {
        if ((v - w) * t >= a - b) cout << "YES" << '\n';
        else cout << "NO" << '\n';
    } else {
        if ((v - w) * t >= b - a) cout << "YES" << '\n';
        else cout << "NO" << '\n';
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e7+10;
char a[maxn];

int main(){
	cin>>a+1;
	int len=strlen(a+1);
	if(a[len]=='s')cout<<a+1<<"es";
	else cout<<a+1<<"s";
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define f(i,n) for(int i = 0;i<n;i++)
#define ll long long
#define pb push_back
int solve(int key){
	if(key>=1800 && key<=1999) return 1;
	if(key>=1600 && key<=1799) return 2;
	if(key>=1400 && key<=1599) return 3;
	if(key>=1200 && key<=1399) return 4;
	if(key>=1000 && key<=1199) return 5;
	if(key>=800 && key<=999) return 6;
	if(key>=600 && key<=799) return 7;
	if(key>=400 && key<=599) return 8;
}
int main(){
	int n,k;
	cin>>n>>k;

	vector<int>v;
	f(i,n){
		int a;
		cin>>a;
		v.pb(a);
	}

	int i = 0,j = k;

	while(j<n){
		if(v[j]>v[i]) cout<<"Yes";
		else cout<<"No";
		cout<<endl;
		i++;
		j++;
	}

}

Measured memory_bytes: 4316
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// ?????????????????¨?¨????????????°?????¨???
		final int VERTICALLIMIT = 12;
		final int SIDELIMIT = 12;

		Scanner in = new Scanner(System.in);
		//
		String[][] worldMap = new String[VERTICALLIMIT][SIDELIMIT];
		int count = 0;
		ArrayList<Integer> packmanCount = new ArrayList<>();

		while (in.hasNext()) {

			for (int verticalNum = 0; verticalNum < VERTICALLIMIT; verticalNum++) {

				String world = in.next();

				for (int sideNum = 0; sideNum < SIDELIMIT; sideNum++) {

					worldMap[verticalNum] = world.split("");

				}
			}

			for (int verticalNum = 0; verticalNum < VERTICALLIMIT; verticalNum++) {

				for (int sideNum = 0; sideNum < SIDELIMIT; sideNum++) {

					if (worldMap[verticalNum][sideNum].equals("1")) {

						packman(worldMap, verticalNum, sideNum);

						count++;

					}
				}
			}

			packmanCount.add(count);
			count = 0;

		}

		for(int result: packmanCount) {

			System.out.println(result);

		}

	}

	private static void packman(String[][] worldMap, int verticalNum, int sideNum) {

		// ????????????????????????????\???????????????¨????????°
		final int VERTICALZERO = 0;
		final int VERTICALLIMIT = 11;
		final int SIDEZERO = 0;
		final int SIDELIMIT = 11;

		if (worldMap[verticalNum][sideNum].equals("1")) {

			worldMap[verticalNum][sideNum] = "0";

			if (verticalNum > VERTICALZERO) {

				packman(worldMap, verticalNum - 1, sideNum);

			}

			if (verticalNum < VERTICALLIMIT) {

				packman(worldMap, verticalNum + 1, sideNum);

			}

			if (sideNum > SIDEZERO) {

				packman(worldMap, verticalNum, sideNum - 1);

			}

			if (sideNum < SIDELIMIT) {

				packman(worldMap, verticalNum, sideNum + 1);

			}

		} else {

			return;

		}
	}
}


// ==============================?????°???????????????=======================================

  /*if(worldMap[i + 1][j] == 0 && worldMap[i - 1][j] == 0 && worldMap[i][j + 1] == 0 && worldMap[i][j - 1] == 0) {

	  worldMap[i][j] = 0;

  } else if(worldMap[i + 1][j] == 1 || worldMap[i - 1][j] != 0 || worldMap[i][j + 1] != 0 || worldMap[i][j - 1] != 0){

	  packman(worldMap, i + 1, j);

  } else if(worldMap[j + 1][j] == 1 && worldMap[i + 1][j] == 0 || worldMap[i - 1][j] != 0 || worldMap[i][j - 1] != 0) {

	  packman(worldMap, i, j + 1);

  } else if(worldMap[i][j - 1] == 1 && worldMap[i + 1][j] == 0 || worldMap[i - 1][j] != 0 || worldMap[i][j - 1] != 0){

	  packman(worldMap, i, j - 1);

  } else if(worldMap[i][i - 1] == 1 && worldMap[i + 1][j] == 0 || worldMap[i][j + 1] != 0 || worldMap[i][j - 1] != 0){

	  packman(worldMap, i - 1, j);

  }

  	worldMap[i][j] = 0;*/

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

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

    int X;
    cin >> X;
    if(X <= 3){
        cout << X << endl;
    }else{
        while(true){
            bool isSosuu = true;
            for(int i = 2; i * i <= X; i++){
                if(X % i == 0){
                    isSosuu = false;
                    break;
                }
            }
            if(isSosuu){
                break;
            }
            X++;
        }
        cout << X << endl;
    }
    return 0;
}

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

int main(){
  string s;
  cin>>s;
  int ans=0;
  int i=0, n=s.size();
  while(i<n){
    int cur=0;
    while(s[i]=='R' && i<n){
        cur++;
        i++;
    }
    ans=max(ans, cur);
    i++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
const int INF = LLONG_MAX;

signed main(){

    int cnt[4] = {};
    for(int i = 0; i < 3; i++){
        int a, b; cin >> a >> b;
        a--;
        b--;
        cnt[a]++;
        cnt[b]++;
    }

    bool flag = true;
    for(int i = 0; i < 4; i++){
        if(cnt[i] > 2) flag = false;
    }

    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  map<int, int> m;
  REP(i, N){
    int d;
    cin >> d;
    m[d]++;
  }

  int ans = 12;
  if(m[0] >= 1)  ans = 0;
  if(m[12] >= 2) ans = 0;
  for(auto p : m) if(p.second >= 3) ans = 0;

  vector<int> vec = {0};
  bool right = true;
  for(auto p : m){
    if(p.second == 2){
      vec.emplace_back(p.first);
      vec.emplace_back(24-p.first);
    }else if(p.second == 1){
      if(right) vec.emplace_back(p.first);
      else vec.emplace_back(24-p.first);
      right = !right;
    }
  }

  sort(ALL(vec));

  REP(i, vec.size()-1){
    chmin(ans, vec[i+1]-vec[i]);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = get!(usize);
    let mut c = 0_i32;
    for _ in 0..n {
        let (l, r) = get!(i32, i32);
        c += r - l + 1;
    }
    println!("{}", c);
}

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

int main()
{
	int a, b;
    char c;
    cin>>a>>c>>b;
    switch(c)
    {
    	case '+': cout<<a+b<<"\n";
        		  break;
        case '-': cout<<a-b<<"\n";
    }
	return 0;
}

Measured memory_bytes: 256