akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;                   //入力文字を格納
  vector<string> phrase = {"dream", "dreamer", "erase", "eraser"};   //左から5,7,5,6文字
  
  reverse(S.begin(), S.end());                      
  for(int i = 0; i < phrase.size(); i++)
    reverse(phrase.at(i).begin(), phrase.at(i).end());  //各文字列を反転させる

  /*与えられた語句はいずれも5文字以上であり、dreamとdreamer, eraseとeraser, dreamer
     dreamおよびeraseの複合体など判別の組み合わせによっては、どの部分で分割して判別す　ればよいのかわかりづらい。しかしながら逆で文字を追ってみると、頭から3文字で判別　可能となる。またそこから次の語句までの文字数も抽出できる。*/

  bool equal = true;                                                //このtrueを守り抜ければ勝ち
  for(int i = 0; i < S.size(); ){                                 //iはSの1文字1文字を指すので上限はS.size()-1(配列)
    bool subEqual = false;                                     //現在位置からphrase内の語句に一致するものは？
    for(int j = 0; j < phrase.size(); j++){           //phraseの数だけループ
      string tmp = phrase.at(j);                             //検査語句の抽出、全phrase.size()回
      if(S.substr(i, tmp.size()) == tmp){            //Sのi～i+tmp.size()の文字とtmpの関係
        subEqual = true;                                             //一致していたなら今回はequal君は延命
        i += tmp.size();                                                 //次の敵(語句の先頭)を指す
      }
    }
    if(!subEqual){                                                       //phrase内のどの語句とも一致しなかった
      equal = false;                                                     //equal君サヨナラ
      break;                                 
    }
  }

  if(equal) cout << "YES" << endl;                  //延命成功
  else           cout << "NO" << endl;                   //延命失敗

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

void mod( ll &n, ll m=MOD ){ n%=m,n+=m,n%=m; }

const int MAXN = 1e5+5;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

bool check( vector<int>&v )
{
    for(int i=1;i<v.size();i++)
    {
        if( v[i] < v[i-1] )
            return 0;
    }
    return 1;
}

int main() 
{
    fastio();

    int n;
    cin>>n;
    vector<int>v(n,0);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    int cnt = 0;
    if( check(v) ) cnt++;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            swap(v[i],v[j]);
            if( check(v) )
                cnt++;
            swap(v[i],v[j]);
        }
    }
    if( cnt == 0 )
        cout<<"NO";
    else
        cout<<"YES";

    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val X = next()
    var s = 0
    var ans = 0
    for (x in X) {
        when {
            x == 'S' -> s++
            s > 0 -> s--
            else -> ans++
        }
    }
    var t = 0
    for (x in X.reversed()) {
        when {
            x == 'T' -> t++
            t > 0 -> t--
            else -> ans++
        }
    }
    println(ans)
}

Measured memory_bytes: 41344
N = input()
S = input()
s = []
for c in S:
    s.append(c)

red = 0
blue = 0
for i in range(len(s)):
    if s[i] == "R":
        red += 1
    if s[i] == "B":
        blue += 1
        
if red > blue:
    print("Yes")
else:
    print("No")

  

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const int mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = 3.141592653589793;

int n,v,m;
int a[200000+5];
int nxl[200000+5][20],nxr[200000+5][20];
int ok[200000+5]={};
int dpl[1000000];
int dpr[1000000];
int pre,now,nx;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> v;
    rep(i,n) cin >> a[i];
    m=0;
    int vv=v;
    while (vv>0){
        vv/=2;
        m+=1;
    }
    m+=1;
    rep(j,m){
        nxl[n-1][j]=n-1;
        nxr[0][j]=0;
    }
    rep(j,m){
        now=0;
        pre=0;
        while (now<n-1){
            while (now<n-1){
                nx=now+1;
                if (a[nx]-a[now]>v/pow(2,j)) break;
                now=nx;
            }
            rep2(i,pre,nx) nxl[i][j]=now;
            pre=nx;
            now=nx;
        }
    }
    rep(j,m){
        now=n-1;
        pre=n-1;
        while (now>0){
            while (now>0){
                nx=now-1;
                if (a[now]-a[nx]>v/pow(2,j)) break;
                now=nx;
            }
            rrep2(i,pre,nx) nxr[i][j]=now;
            pre=nx;
            now=nx;
        }
    }
    fill(dpr,dpr+(1<<m),n-1);
    rep(i,1<<m)rep(j,m){
            if (!(i>>j&1)){
                int L=nxl[dpl[i]][j];
                int R=nxr[dpr[i]][j];
                if (L==n-1) L-=1;
                if (R==0) R+=1;
                dpl[i|(1<<j)]=max(dpl[i|(1<<j)],L+1);
                dpr[i|(1<<j)]=min(dpr[i|(1<<j)],R-1);
            }
    }
    bool f=false;
    rep(i,1<<m){
        int tmp=i;
        if (tmp&1) tmp=tmp^1;
        int left=dpl[tmp];
        int nokori=((1<<m)-1)^tmp;
        nokori-=1;
        int right=dpr[nokori];
        if (left<right){
            if (nxl[left][0]>=right){
                ok[left]+=1;
                ok[right+1]-=1;
            }
        }
        else{
            f=true;
            break;
        }
    }
    if (f){
        rep(i,n) cout << "Possible" << endl;
    }
    else{
        rep(i,n) ok[i+1]+=ok[i];
        rep(i,n){
            if (ok[i]>0) cout << "Possible" << endl;
            else cout << "Impossible" << endl;
        }
    }
    return 0;
}


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define b begin()
#define e end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>k;

	f(i,0,n-1) cin>>ara[i];

	while(n){
        res=n-k;
        count++;
        if(res>0)n=n-k+1;
        else break;
        if(n>0 && n<k) {
            count++;
            break;
        }
        else if(n==0) break;
	}

	cout<<count<<endl;

}


Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
    int n,k,d,s,cnt=0;
    int a[200]={0},i,j,l;
    scanf("%d %d",&n,&k);

    for(i=1;i<=k;i++){
        scanf("%d",&d);
        for(j=1;j<=d;j++){
            scanf("%d",&s);
            a[s]++;
        }
    }
    for(i=1;i<=n;i++){
        if(a[i]==0){
            cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int sum=0;
    for(int i=0; i<k; i++){
        sum+=a[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3624
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    cout<<24-n+24<<"\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#define NUM 1000

int fib(int n);
int F[NUM];

int main()
{
  int n;

  scanf("%d",&n);
  printf("%d\n",fib(n));

  return 0;
}

int fib(int n)
{
  if(n == 0 || n == 1) return F[n] = 1;

  if(F[n] != NULL) return F[n];

  return F[n] = fib(n-2)+fib(n-1);
}



Measured memory_bytes: 2112
/*input

*/

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <math.h>
#include <iomanip>
#include <utility>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

ll MOD = 1000000007;
const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define inv(a)      powr((a), (MOD - 2))
#define all(c)      (c).begin(),(c).end()
#define rep(i,a,b)  for(ll i = (a); i < (b); i ++)
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template<typename T> void toInt(string s, T &a) { istringstream(s) >> a; }
ll gcd(ll a, ll b) { ll t; while(a) { t = a; a = b%a; b = t; } return b; }
ll sub(ll a, ll b) { a -= b; a = (a + MOD) % MOD; return a; }
ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
ll add(ll a, ll b) { a += b; a %= MOD; return a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll powr(ll a, ll b) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a);
    a = mul(a, a), b >>= 1;
  }
  return x;
}

bool check(ll n)
{
  if(n == 1) return 0;
  if(n == 2 or n == 3) return 1;
  if(n%2 == 0 or n%3 == 0) return 0;
  for(ll i = 5; i*i <= n; i += 6) if(n%i == 0 or n % (i+2) == 0) return 0;
  return 1;
}

/*********************************START**********************************/
const int N = 100005;

int main()
{
  ifalse;
  int n;
  cin >> n;
  vector < int > v(n);
  map < int, int > mp;
  int ma = 0;
  for(auto &x: v) {
    cin >> x;
    mp[x] ++;
    ma = max(ma, x);
  }
  for(int i = 0; i < n; i ++) {
    if(v[i] != ma) {
      cout << ma, nl; 
    } else if(mp[ma] > 1) {
      cout << ma, nl;
    } else {
      int mi = 0;
      for(auto x: v) {
        if(x == ma) {
          continue;
        } else {
          mi = max(x, mi);
        }
      }
      cout << mi, nl;
    }
  }
  return 0;
}

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

int main(){
    long long n;
    cin >> n;
    vector<long long> a(87);
    a.at(0)=2;
    a.at(1)=1;
    rep(i,2,87){
        a.at(i)=a.at(i-1)+a.at(i-2);
    }
    cout << a.at(n) << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<complex>
#include<vector>
#include<math.h>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
 
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
P projection(const L &l, const P &p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}
bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}
double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}
double distanceSS(const L &s, const L &t) {
  if (intersectSS(s, t)) return 0;
  return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
             min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}
P start,end;
P wolf[50][4];
double h[50];
int main(){
    int a;
    while(scanf("%d",&a),a){
        int W,Z,X,Y;
        scanf("%d%d",&X,&Y);
        start=P(X,Y);
        scanf("%d%d",&X,&Y);
        end=P(X,Y);
        double left=0;
        double right=1000;
        for(int i=0;i<a;i++){
            scanf("%d%d%d%d%lf",&X,&Y,&W,&Z,h+i);
            if((real(start)-X)*(real(start)-W)<=0&&(imag(start)-Y)*(imag(start)-Z)<=0)right=0;
            wolf[i][0]=P(X,Y);
            wolf[i][1]=P(X,Z);
            wolf[i][2]=P(W,Z);
            wolf[i][3]=P(W,Y);
        }
        for(int i=0;i<100;i++){
            double M=(left+right)/2;
            bool ok=true;
            for(int j=0;j<a;j++){
                double V=M;
                if(h[j]<M)V=sqrt(M*M-(M-h[j])*(M-h[j]));
                for(int k=0;k<4;k++){
                    if(distanceSS(L(start,end),L(wolf[j][k],wolf[j][(k+1)%4]))<V)ok=false;
                }
            }
            if(ok)left=M;
            else right=M;
        }
        printf("%f\n",left);
    }
}

Measured memory_bytes: 1108
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

typedef pair<ll,const char*> parsed;

parsed expr(const char*);
parsed term(const char*);
parsed fact(const char*);

parsed expr(const char* s)
{
	//cout<<"expr(\""<<s<<"\")"<<endl;
	parsed now=term(s);
	while(*now.second=='+' || *now.second=='-'){
		char op=*now.second;
		parsed next=term(now.second+1);
		if(op=='+')
			now=parsed(now.first+next.first,next.second);
		else
			now=parsed(now.first-next.first,next.second);
	}
	//cout<<"expr(\""<<s<<"\")="<<now.first<<endl;
	return now;
}

parsed term(const char* s)
{
	//cout<<"term(\""<<s<<"\")"<<endl;
	parsed now=fact(s);
	while(*now.second=='*' || *now.second=='/'){
		char op=*now.second;
		parsed next=fact(now.second+1);
		if(op=='*')
			now=parsed(now.first*next.first,next.second);
		else
			now=parsed(now.first/next.first,next.second);
	}
	//cout<<"term(\""<<s<<"\")="<<now.first<<endl;
	return now;
}

parsed fact(const char* s)
{
	//cout<<"fact(\""<<s<<"\")"<<endl;
	//if(s[0]=='('){
	//	parsed res=expr(s+1);
	//	res.second++;
	//	return res;
	//}
	//else{
	//	const char* p=s;
	//	if(*p=='-')
	//		p++;
	//	ll n=0;
	//	while(isdigit(*p)){
	//		n=n*10+*p-'0';
	//		p++;
	//	}
	//	return parsed(n,p);
	//}
	
	if(s[0]=='-' || isdigit(s[0])){
		const char* p=s;
		if(*p=='-')
			p++;
		ll n=0;
		while(isdigit(*p)){
			n=n*10+(*p-'0');
			p++;
		}
		return parsed(n,p);
	}
	//else if(s[0]=='('){
	//	parsed res=expr(s+1);
	//	res.second++;
	//	return res;
	//}
	//else
	//	exit(0);
	else{
		parsed res=expr(s+1);
		res.second++;
		return res;
	}
}

int main()
{
	int n;
	cin>>n;
	rep(i,n){
		string s;
		cin>>s;
		cout<<expr(s.c_str()).first<<endl;
	}
	//string s;
	//getline(cin,s);
	//while(getline(cin,s))
	//	cout<<expr(s.c_str()).first<<endl;
	
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI2(A, B);
  print((A + B) % 24);
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var ma, mb, mc, x int
	fmt.Scanf("%d\n", &ma)
	fmt.Scanf("%d\n", &mb)
	fmt.Scanf("%d\n", &mc)
	fmt.Scanf("%d\n", &x)

	cnt := 0
	for a := 0; a <= ma; a++ {
		for b := 0; b <= mb; b++ {
			for c := 0; c <= mc; c++ {
				all := 500*a + 100*b + 50*c
				if all == x {
					cnt++
				}
			}
		}
	}
	fmt.Println(cnt)

}


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

int main()
{
  int arr[3]={0},count=0,count1=0;
  cin>>arr[0]>>arr[1]>>arr[2];
  for(int i=0;i<3;i++)
  {
    if(arr[i]==5)
      count++;
    else if(arr[i]==7)
      count1++;
    else{}
  }
  if(count==2 && count1==1)
    cout<<"YES";
  else
    cout<<"NO";
  return 0;
}


Measured memory_bytes: 3556
import java.util.*;

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

    int a,b;
    String op;
    int result=0;
    Scanner sc = new Scanner(System.in);
    while(true){
      a = Integer.parseInt(sc.next());
      op = sc.next();
      b = Integer.parseInt(sc.next());

      if(op.equals("+")){
        result = a + b;
      }else if(op.equals("-")){
        result = a - b;
      }else if(op.equals("*")){
        result = a * b;
      }else if(op.equals("/")){
        result = a / b;
      }else if(op.equals("?")){
        break;
      }
      System.out.println(result);
    }
  }
}



Measured memory_bytes: 26036
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
 
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

int main(){
    ll N;
    cin >> N;
    mint al = 1;
    rep(i,N){
        al *= 10;
    }
    mint re1 = 1;
    mint re2 = 1;
    mint re3 = 1;
    rep(i,N){
        re1 *= 9;
        re2 *= 9;
        re3 *= 8;    
    }
    mint ans = al - re1 - re2 + re3;

    cout << ans << endl;
}

Measured memory_bytes: 3632
package main

import (
    "fmt"
)

func main() {
	var K uint32 = 0
    arr :=[3]uint32{}
    fmt.Scan(&arr[0], &arr[1], &arr[2])
    fmt.Scan(&K)
	var max_ uint32 = 0
	for i:=0;i < len(arr);i++ {
		if max_<arr[i] {
			max_=arr[i]
		}
	}
	max_ = (max_ << K) - max_
	fmt.Println(arr[0]+arr[1]+arr[2]+max_)
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef unsigned long long ull;
typedef std::pair<int,int> P;

const ull INF = 1001001001001001001;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

struct Food{
    std::string name;
    ull w, s;
};

const int MAX_N = 10;
int N;
std::vector<Food> F;
int order[MAX_N], fact[11];

int main(){
    fact[0] = 1;
    FOR(i, 1, 11){
        fact[i] = fact[i-1] * i;
    }

    while(std::cin >> N, N){
        F.clear();

        REP(i, N){
            std::string name;
            ull w, s;
            std::cin >> name >> w >> s;
        
            F.push_back({name, w, s});
        }

        REP(i, N){
            order[i] = i;
        }
    
        ull min_cost = INF;
        int min_order[MAX_N];
        REP(_, fact[N]){
            // for(int i=0;i<N;i++){
            //     printf("%d, ", order[i]);
            // }
            // puts("");

            bool f = true;
            ull cost = 0, sum = 0;
            REP(i, N){
                int index = order[i];
                if(sum <= F[index].s);
                else{f = false;}

                cost += (N-i) * F[index].w;
                sum += F[index].w;
            }
            //std::cout << cost << std::endl;

            if(f && min_cost > cost){
                min_cost = cost;
                std::copy(order, order+N, min_order);
            }

            std::next_permutation(order, order+N);
        }

        //std::cout << min_cost << std::endl;
        for(int i=N-1;i>=0;i--){
            int index = min_order[i];
            std::cout << F[index].name << std::endl;
        }
    }
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
 
#define debug(x) cout << '>' << #x << ':' << x << endl
using namespace std;
using ll = long long;

const int N = 2005;
ll dp[N][N];

ll memo(vector<pair<ll, ll>> &a, ll idx, ll first, ll last) {
    // A[x] * abs(x - y)
    if (idx == 0) return 0;
    ll actualIdx = a[idx].second;
    ll &ans = dp[idx][first];
    if(ans != -1) return ans;
    ans = max(
        memo(a, idx - 1, first + 1, last) + a[idx].first * abs(actualIdx - first),
        memo(a, idx - 1, first, last - 1) + a[idx].first * abs(actualIdx - last)
    );
    return ans;
}

void solve() {
    ll n;
    cin >> n;
    vector<pair<ll, ll> > a(n + 1);
    for (ll i = 1; i <= n; ++i) {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a.begin() + 1, a.end());
    memset(dp, -1, sizeof(dp));
    cout << memo(a, n, 1, n);
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int T;
    T = 1;
    // cin >> T;
    for (int t = 1; t <= T; t++){
        // cout << "Case #" << t << ": ";
        solve();
    }
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}


// end of Template

str s,res;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(i%2==0)res+=s[i];
    }
    cout<<res<<newl;

}


Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
const int INF = 100000000;
typedef pair<int, int> P;
const int MAX_N = 1000000;

int N, M;
vector<int> vec(MAX_N);

int main() {
	cin >> N >> M;
	int L = 1; int R = MAX_N;
	int tmpL, tmpR;
	rep(i, M) {
		cin >> tmpL;
		L = max(L, tmpL);
		cin >> tmpR;
		R = min(R, tmpR);
	}

	int ans = 0;
	for (int i = L; i <= R; i++)
	{
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 7036
#include <bits/stdc++.h>
#define lowbit(x) (x & -x)
#define jh(x, y) x ^= y ^= x ^= y
#define loc(x, y) (x - 1) * m + y
#define rg register
#define inl inline
#define PI 3.141592654
typedef long long ll;
const int N = 6e5 + 5, INF = 0x3f3f3f3f, mod = 998244353;
using namespace std;
namespace fast_IO {
	inl ll read() {
		rg char c;
		rg ll x = 0;
		rg bool flag = false;
		while ((c = getchar()) == ' ' || c == '\n' || c == '\r');
		if (c == EOF)return c; if (c == '-')flag = true; else x = c ^ 48;
		while ((c = getchar()) != ' ' && c != '\n' && c != '\r' && ~c)
			x = (x << 1) + (x << 3) + (c ^ 48);
		if (flag)return -x; return x;
	}
	inl ll max(rg ll a, rg ll b) { if (a > b)return a; return b; }
	inl ll min(rg ll a, rg ll b) { if (a < b)return a; return b; }
	void write(rg ll x) { if (x < 0)putchar('-'), x = -x; if (x >= 10)write(x / 10); putchar(x % 10 ^ 48); }
}

int main(void) {
	rg int a, b;
	scanf("%2d%2d", &a, &b);
	if (a >= 1 && a <= 12 && (b > 12 || !b))puts("MMYY");
	else if (b >= 1 && b <= 12 && (a > 12 || !a))puts("YYMM");
	else if (a >= 1 && a <= 12 && b >= 1 && b <= 12)puts("AMBIGUOUS");
	else puts("NA");
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

lmax = 0
rmin = N
for i in range(M):
    L, R = map(int, input().split())
    lmax = max(L, lmax)
    rmin = min(R, rmin)

ans = max(rmin - lmax + 1, 0)
print(ans)



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll r,c,s;
  cin>>r>>c>>s;
  if(r<c)
  {
      int t=r;
      r=c;
      c=t;
  }
  if(s%r)
  cout<<(s/r)+1<<endl;
  else
    cout<<s/r<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main()
{
    int h,n;
    cin>>h>>n;
    rep(i,n)
    {
        int a;
        cin>>a;
        h-=a;
        if(h<=0)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
}

Measured memory_bytes: 3620
n,m=map(int,input().split())
l=[]
for i in range(n):l.append([])
for i in range(m):
    p,y=map(int,input().split())
    l[p-1].append((i,y))
rl=[]
for i in range(n):
    ll=l[i]
    ll.sort(key=lambda x:x[1])
    hd=("000000"+str(i+1))[-6:]
    rr=[(ll[j][0],hd+("000000"+str(j+1))[-6:]) for j in range(len(ll))]
    rl+=rr
rl.sort()
for e in rl:
    print(e[1])


Measured memory_bytes: 42328
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi


def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)


def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y


for _ in range(int(input()) if not True else 1):
    n = int(input())
    #n, k = map(int, input().split())
    #c, d = map(int, input().split())
    #a = list(map(int, input().split()))
    #b = list(map(int, input().split()))
    #s = input()
    a=[]
    b=[]
    for i in range(n):
        x, y = map(int, input().split())
        a+=[x+y]
        b+=[x-y]
    a=sorted(a)
    b=sorted(b)
    print(max(a[-1]-a[0], b[-1]-b[0]))

Measured memory_bytes: 98212
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	int a,b;
  string s,n,u;
  cin>>s>>n>>a>>b>>u;
  if(u==s){
    cout<<a-1<<" "<<b<<"\n";
  }else{
    cout<<a<<" "<<b-1<<"\n";
  }
  return(0);
}

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

#define ALL(C)                      (C).begin(), (C).end() 
#define ARRAY_SIZE(A)               (sizeof(A) / sizeof(A[0]))
#define SIZE_ARRAY(A)               (sizeof(A) / sizeof(A[0]))
#define ALL_ARRAY(A)                (A), (A) + SIZE_ARRAY(A)

#define FOR(i, N)                   for (int i = 0; i < (int)(N); ++i)
#define FORC(i, C)                  for (int i = 0; i < (int)(C).size(); ++i)
#define FORN(i, x, n)               for (int i = x; i <= (int)(n); ++i)

#define FORI(N)						FOR(i, N)
#define FORJ(N)						FOR(j, N)
#define FORK(N)						FOR(k, N)

#define PRINT(x)                    std::cout << #x << " = [" << (x) << "]" << std::endl

std::vector<std::string> Split(const std::string& s, const std::string& seps = " ") {
	std::vector<std::string> ret;
	for (size_t p = 0, q; p != string::npos; p = q) {
		p = s.find_first_not_of(seps, p);
		if (p == string::npos) break;
		q = s.find_first_of(seps, p);
		ret.push_back(s.substr(p, q - p));
	}
	return ret;
}


int main() {
#if defined(_DEBUG)
	freopen_s((FILE**)stdin, "ReadMe.txt", "r", stdin);
#endif

	char buf[200];
	string s;
	cin.getline(buf, 200);
	s = buf;
	vector<string> vs(Split(s));
	string ret;
	FORC(i, vs) {
		ret += vs[i][0];
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdlib>
using namespace std;
#define REP(i,n) for(int i = 0;i < (int)(n);i++)

int main() {
	int a,b,ans=0;
	cin >> a >> b;
	for (int i = 1; i <= (b - a); i++)ans += i;
	cout << ans - b;
	return(0);
}


Measured memory_bytes: 256
N, K = map(int, input().split())
p = list(map(int, input().split()))
 
now = sum(p[:K])
saidai = now
for i in range(K, N):
  now -= p[i-K]
  now += p[i]
  if now > saidai:
    saidai = now
 
print('{:.12f}'.format((saidai + K)/2))

Measured memory_bytes: 24940
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

int main() {
    ll n;
    cin >> n;
    ll a[n + 1];
    ll b[n];

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

    ll beat = 0;
    for(ll i = 0; i < n; ++i) {
        // 上倒す
        ll up = min(a[i], b[i]);
        beat += up;
        a[i] -= up;
        b[i] -= up;

        // 斜め倒す
        ll slant = min(a[i + 1], b[i]);
        beat += slant;
        a[i + 1] -= slant;
        b[i] -= slant;
    }
    /*
        cout << endl;
        rep(i, n + 1) { cout << a[i] << " "; }
        cout << endl;
        rep(i, n) { cout << b[i] << " "; }
        cout << endl;
        */
    cout << beat << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
        int k; cin>>k;
        int a,b; cin>>a>>b;
        int v1=a/k,v2=b/k;
        if(v1==v2&&(v1*k)<a) cout<<"NG"<<endl;
        else { cout<<"OK"<<endl;}
}


Measured memory_bytes: 3648
#include <stdio.h>

int main()
{
	long long N;
	long long n, h, w;
	long long r;

	scanf("%lld", &N);
	for (n = 1; n <= 3500ll; n++) {
		for (h = 1; h <= 3500ll; h++) {

			if (4 * h * n - N * n - N * h != 0) {
				w = (h * n * N) / (4 * h * n - N * n - N * h);
				r = (h * n * N) % (4 * h * n - N * n - N * h);

				if (w > 0 && r == 0) {
					printf("%lld %lld %lld\n", h, n, w);
					return 0;
				}
			}
		}
	}

	return 0;
}


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

const ll INF = 1001001001;

int main()
{
    int n;
    cin >> n;
    string ans = "Yes";
    int xx = 0;
    int yy = 0;
    int tt = 0;
    rep(i, n) {
        int t, x, y;
        cin >> t >> x >> y;
        int dist = abs(x - xx) + abs(y - yy);
        tt = t - tt;
        if(tt < dist) ans = "No";
        else {
            if(tt % 2 != dist % 2) {
                ans = "No";
            }
        }
        tt = t;
        xx = x;
        yy = y;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
bitset<4050000> bs = 1;
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\Users\Joeon\Desktop\IN.txt", "r", stdin);
//		freopen("C:\Users\Joeon\Desktop\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T = next<int>(), sum = 0;
	while(T--)
	{
		int x = next<int>();
		bs |= bs<<x;
		sum += x;
	}
	D(sum, bs);
	hrp(i, (sum+1)/2, sum) if (bs[i]) { cout<<i<<endl; break; }
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int q;
  cin >> q;
  vi p(100000 + 1, 1), c(100000 + 1 + 1, 0);
  p[0] = p[1] = 0;
  int root = pow(100000, 0.5) + 1;
  for(int i = 2; i < root; i++){
    if(p[i]){
      for(int j = i + i; j <= 100000; j += i) p[j] = 0;
    }
  }
  for(int i = 1; i < 100002; i++){
    if(i != 2 && p[i] && p[(i + 1) / 2]) c[i + 1] = 1;
    c[i + 1] += c[i];
  }
  rep(i, q){
    int l,r;
    cin >> l >> r;
    cout << c[r + 1] - c[l] << endl;
  }
}

Measured memory_bytes: 1408
n=gets.to_i
array=gets.split.map(&:to_i)
sum=array.inject(:+)
answer=[]

otherthan1=0
i=1
(array.length/2).times{
  otherthan1+=array[i]*2
  i+=2  
}

answer<<sum-otherthan1


(n-1).times{|i|
    answer<<array[i]*2-answer[-1]
}

puts answer.join(' ')

Measured memory_bytes: 14084
import java.util.Scanner;
public class Main {
  	public static void main(String[] args){
      //入力値の取得
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      int[][] array = new int[m][2];
	  for (int i=0; i < m; i++) {
		  sc.nextLine();
		  array[i][0] = sc.nextInt();
		  array[i][1] = sc.nextInt();
	  }
	  sc.close();
 
	  //検査対象整数
	  int min=(int) Math.pow(10, n-1);
	  if (n==1) {
		  min=0;
	  }
	  int max=(int) Math.pow(10, n)-1;
 
	  int answer=-1;
	  outer: for(int i=min; i<=max; i++) {
		  char[] target = Integer.toString(i).toCharArray();
          if (m==0) {
            answer=i;
            break;
          }
		  for(int j=0; j<m; j++) {
			  if (!String.valueOf(target[array[j][0]-1]).equals(Integer.toString(array[j][1]))) {
				  break;
			  }
			  if (j==m-1) {
				  answer=i;
				  break outer;
			  }
		  }
	  }
	  System.out.println(answer);
  	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n,m;cin>>n>>m;
    ll sum=0;
    rep(i,m){
        ll t;cin>>t;
        sum+=t;
    }
    if(n-sum<0) cout<<-1<<endl;
    else cout<<n-sum<<endl;
    return 0;
}


Measured memory_bytes: 3656
/*
	Created by Faisal Ahmed
*/
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef long double ld;

int main()
{
	int n, mx = 0;
	map<string, int> mp;
	string str;
	
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> str;
		mp[str]++;
		mx = max(mx, mp[str]);
	}
	
	for(auto it = mp.begin(); it != mp.end(); it++){
		if(it->second == mx){
			cout << it->first << endl;
		}
	}
 	
	return 0;
}

Measured memory_bytes: 25216
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#define ll long long
#define INF 0x3f3f3f3f
#define N 1005
using namespace std;

int a[4],f=0;
char d[10];
void dfs(int cnt,int sum)
{
	if(f) return;
	if(cnt==4){
		if(sum==7){
			f=1;
			printf("%d%c%d%c%d%c%d=7\n",a[0],d[1],a[1],d[2],a[2],d[3],a[3],d[4]);
		}
		return;
	}
	d[cnt]='+';
	dfs(cnt+1,sum+a[cnt]);
	d[cnt]='-';
	dfs(cnt+1,sum-a[cnt]);
}
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++)
	a[i]=s[i]-'0';
	dfs(1,a[0]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>s;
    rep(i,Size(s)){
        if(s[i]=='U' || s[i]=='D')continue;
        if(i%2==0){
            if(s[i]=='R')continue;
        }
        else{
            if(s[i]=='L')continue;
        }
        Cout("No");
        return 0;
    }
    Cout("Yes");
    return 0;
}

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

#define ll long long
#define ii pair<int, int>
#define int ll
const int N = 12;

int p[N], c[N];
int a[N];

int32_t main()
{
    int D, G;
    cin >> D >> G;
    G/=100;
    for (int i = 0; i < D; i ++)
        cin >> p[i] >> c[i], c[i]/=100;
    for (int i = 0; i <= D; i ++)
        a[i] = i;
    int ans = 2e18;
    do
    {
        int res = 0;
        int sum = 0;
        for (int x = 0; x <= D; x ++)
        {
            int i = a[x];
            if ((G - sum + i) / (i+1) > p[i])
            {
                res += p[i];
                sum += (p[i] * (i + 1) + c[i]);
            }
            else
            {
                res += max((G - sum + i) / (i + 1), 0ll);
                sum += ((G - sum + i) / (i + 1)) * (i + 1);
                ans = min(ans, res);
            }
        }
    } while(next_permutation (a, a + D));
    cout << ans << endl;
}

Measured memory_bytes: 384