akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <utility>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>
#include <math.h>
#include <stdio.h>

using namespace std;

#define REP(i,n,m) for( long long int i = (n); i < (m); i++ )
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define SORT(v) sort( ALL(v) );
#define LAST(v) v[v.size()-1]
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,-1,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pi pair<int, int>
#define MP make_pair
#define PB push_back
#define IIN(a) int a; cin >> a;
#define LIN(a) ll a; cin >> a;
#define SIN(a) string a; cin >> a;
#define EPS (1e-10)
#define INF 1000000000000LL

int MOD=1000000007;
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
//I ASCII code: '0' = 48; 'A' = 65; 'a' = 97

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    LIN(h)
    LIN(w)
    LIN(a)
    LIN(b)
    cout<< h*w + a*b - a*w - b*h<<endl;
    return 0;
}


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

namespace ProblemA
{
    class Program
    {
        static void Main(string[] args)
        {
            var buff = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var wake = new int[]{ buff[0], buff[1] };
            var sleep = new int[] { buff[2], buff[3] };
            int study = buff[4];

            int ans = sleep[0] * 60 + sleep[1] - (wake[0] * 60 + wake[1]) - study;
            Console.WriteLine(ans);
        }
    }
}


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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

int main(){
  int l, r, d;
  cin >> l >> r >> d;
  
  int ans = 0;
  
  rep(i, l, r+1){
    if(i%d == 0)
      ans++;
  }
  
  cout << ans << endl;
  
  return 0;
  
}

Measured memory_bytes: 3632
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.D
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			var cin = new Scanner();

			char c = cin.Next()[0];
            switch (c)
            {
				case 'A':
                    Console.WriteLine('T');
					break;
				case 'T':
                    Console.WriteLine('A');
					break;
				case 'G':
                    Console.WriteLine('C');
					break;
				case 'C':
                    Console.WriteLine('G');
					break;
                default:
                    break;
            }

            Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define ll long long
ll mod=1000000007;
#define vl vector<ll>
#define pl pair<ll,ll>
#define rep(i,b) for(ll i=0;i<b;i++)
#define all(v) (v).begin(),(v).end()
using namespace std;
vector<pair<ll,ll>> N;
bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
int main(){
    ll n,A,B;
    cin>>n;
    rep(i,n){
        cin>>A>>B;
        N.push_back(make_pair(A,B));
    }
    sort(all(N),compare_by_b);
    ll time=0;
    string ans="Yes";
    for(ll i=0; i<N.size(); i++){
        //cout << N[i].first << ' ' << N[i].second << endl;
        time+=N[i].first;
        if(time>N[i].second)ans="No";
    }
    cout<<ans<<endl;
}

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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10
#define MAX_N 100
#define MAX_W 10000

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int dp[MAX_N+1][MAX_W+1];
int N, W, v[MAX_N], w[MAX_N];

int main(){
  scanf("%d%d", &N, &W);
  rep(i, N) scanf("%d%d", v+i, w+i);

  rep(i, N) rep(j, W+1){
    if(j < w[i]) dp[i+1][j] = dp[i][j];
    else dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
  }

  printf("%d\n", dp[N][W]);
  return 0;
}

Measured memory_bytes: 5100
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<string>
#include<cstdio>
#include<stack>
#include<memory.h>
#include<cmath>
#include<bitset>
#include<functional>
#include<memory>
#include<utility>
using namespace std;
#define FOR(i,m,n) for(i=m;i<n;i++)
#define MIN(x,y) (x>y?y:x)
#define ab(x,y) (x>y ?(x-y):(y-x))
#define CLR(a,b) memset(a,b,sizeof(a))
#define ROF(i,m,n) for(i=m;i>=n;i--)
#define BUG cout<<"debug"<<endl;
#define RT return
#define BK break
#define HEAP priority_queue
#define SP " "
#define lowf(a,b,c) lower_bound(a,b,c)
#define upf(a,b,c) upper_bound(a,b,c)
#define CP bool cmp(node A,node B)
typedef long long LL;
typedef vector<int> VI;
const int INF = 2147483647;
const int NEN = -INF - 1;
const LL LINF = 9223372036854775807;
int fa[100005];
int N, Q;
int main()
{
	while (1)
	{
		scanf("%d%d", &N, &Q);
		if (N == 0 && Q == 0)break;
		int i;
		unsigned long long sum = 0;
		char ope;
		int  a;
		FOR(i, 1, N)
		{
			scanf("%d", &fa[i + 1]);
		}
		fa[1] = 1;
		while (Q--)
		{
			scanf("%c", &ope);
			scanf("%c", &ope);
			scanf("%d", &a);
			if (ope == 'M')fa[a] = a;
			else
			{
				while (fa[a] != a)
				{
					a = fa[a];
				}
				sum += a;
			}
		}
		printf("%lld\n", sum);
	}
}


Measured memory_bytes: 3512
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin>>n>>a>>b;
    ll h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    } 
    ll mi=0,ma=10000000000,mid=(mi+ma)/2;
    bool maki;
    ll num;
    while(mi!=mid){
        maki=false;
        num=0;
        for(int i=0;i<n;i++){
            num+=(max(0LL,h[i]-mid*b+a-b-1))/(a-b);
        }
        if(num<=mid)maki=true;
        if(maki){
            ma=mid;
        }else{
            mi=mid;
        }
        mid=(ma+mi)/2;
    }
    cout << ma<<endl;
    return 0;
}


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

int main() {
  int N, K, X, Y, price = 0;
  cin >> N >> K >> X >> Y;

  for (int i = 0; i < N; i++) {
    if (i < K) price += X;
    else price += Y;
  }
  cout << price << endl;
}

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

int main(void){
    char taro[100];
    char hanako[100];
    int n,i,t=0,h=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s",&taro);
        scanf("%s",&hanako);
        if(strcmp(taro,hanako) == 0){
            t += 1;
            h += 1;
        } else if(strcmp(taro,hanako) > 0){
            t += 3;
        } else {
            h += 3;
        }
    }
    printf("%d %d\n",t,h);
    return 0;
}

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}

int main() {
  string s;cin>>s;
  bool ans=true;
  char b=0;
  REP(i,4){
    if(b==s[i]){
      ans=false;
      break;
    }
    b=s[i];
  }
  cout << (ans?"Good":"Bad") << endl;
}

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

long N, A, B;
static int h[100000];
int binarySearch(int ok, int ng, bool f(int n)) {
	while (abs(ng - ok) > 1) (f(ok + ng >> 1) ? ok : ng) = ok + ng >> 1;
	return ok;
}

bool f(int n) {
	long explosion = 0; // 爆発の中心となる回数
	for (int i = 0;i < N;++ i) explosion += max(0L, (h[i] - n * B + A - B - 1) / (A - B));
	return explosion <= n;
}
int main() {
	cin >> N >> A >> B;
	for (int i = 0;i < N;++ i) cin >> h[i];
	cout << binarySearch(2000000000, 0, f);
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main { 
    public static void main(String[] args) {
       Scanner sc=new Scanner(System.in);
       String o="";
       int k=sc.nextInt();
       int x=sc.nextInt();
      if(500*k>=x)o="Yes";
      else o="No";
      System.out.println(o);
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    cout << N * N * N << endl;

    return 0;
}


Measured memory_bytes: 3620
n = gets.to_i
arr = gets.split(' ').map(&:to_i)

if arr.include?(0)
  puts 0
else
  result = arr[0]
  arr.shift
  arr.each do |a|
    result *= a
    if result > 10 ** 18
      puts -1
      break
    end
  end
  puts result if result <= 10 ** 18
end


Measured memory_bytes: 21568
import java.util.*;
public class Main {
	int i,runner;
	String time;
	Runner timeArray[] = new Runner[24];
	int flag[] = new int[timeArray.length];
	Runner subArray[] = new Runner[timeArray.length];
	void doIt(){
		Scanner sc = new Scanner(System.in);
		for(i = 0; i < timeArray.length; i ++ ){
			runner = sc.nextInt();
			time = sc.next();
			timeArray[i] = new Runner(runner,time);
		}
		for(i = 0; i < 3; i ++ ){
			Arrays.sort(timeArray,i * 8,i * 8 + 8);
			System.out.println(timeArray[i * 8].runner+" "+timeArray[i * 8].time);
			System.out.println(timeArray[i * 8 + 1].runner+" "+timeArray[i * 8 + 1].time);
			timeArray[i * 8].time = "hoge";
			timeArray[i * 8 + 1].time = "hoge2";
		}
		Arrays.sort(timeArray);
		System.out.println(timeArray[0].runner+" "+timeArray[0].time);
		System.out.println(timeArray[1].runner+" "+timeArray[1].time);
	}
	class Runner implements Comparable<Runner>{
		int runner;
		String time;
		Runner(int runner,String time){
			this.runner = runner;
			this.time = time;
		}
		@Override
		public int compareTo(Runner r){
			return time.compareTo(r.time);
		}
	}
	public static void main(String[] args) {
		new Main().doIt();
	}
}

Measured memory_bytes: 26036
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, string>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
const int A = 26;

class C{
  public:
    string s;
    int cnt;
    C(string _s, int _c){ s = _s; cnt = _c; }
    C(){}
    bool operator < (const C &c) const{
      if(cnt != c.cnt) return cnt > c.cnt;
      else return s < c.s;
    }
};

void push_ans(vector<C> &v, string s){
  REP(i, v.size()){
    if(v[i].s == s){
      ++v[i].cnt;
      return ;
    }
  }
  v.push_back(C(s, 1));
}

void getline_string(vector<string> &s){
  string o;
  getline(cin, o);
  stringstream ss(o);
  string tmp;
  while(getline(ss, tmp, ' ')) s.push_back(tmp);
}

int main() {
  int N;
  while(cin >>N && N){
    vector< vector<C> > ans(A, vector<C>());
    vector<string> s;
    string tmp;
    getline(cin, tmp);
    REP(i, N) getline_string(s);
    REP(i, s.size()) push_ans(ans[s[i][0] - 'a'], s[i]);
    char c; cin >>c;
    int ci = c - 'a';
    SORT(ans[ci]);
    if(ans[ci].size() == 0) cout <<"NA" <<endl;
    else{
      int lim = min(5, (int)(ans[ci].size()));
      REP(i, lim) printf("%s%c", ans[ci][i].s.c_str(), (i + 1 == lim ? '\n' : ' '));
    }


  }
  return 0;
}

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

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

  int N;
  cin >> N;
  vector<int> A(N);
  int all = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    all ^= A[i];
  }
  for (int i = 0; i < N; i++) {
    cout << (all ^ A[i]) << " ";
  }
  cout << '\n';
  return 0;
}


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

const int N = 110;

int n, k, ans, a[N];

int solve(int x, int y) {
	int res = 0;
	vector<int> vec;
	for (int i = 0; i < x; i++)
		vec.push_back(a[i]);
	for (int i = 0; i < y; i++)
		vec.push_back(a[n - i - 1]);
	int rem = k - x - y;
	sort(vec.begin(), vec.end(), greater<int>());
	while(vec.size() && vec.back() < 0 && rem) {
		rem--;
		vec.pop_back();
	}
	for (int num: vec)
		res += num;
	return res;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= n; j++)
			if(i + j <= k && i + j <= n)
				ans = max(ans, solve(i, j));
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
using namespace std;

int main() {
    int N, M; cin >> N >> M;
    ll mod=1000000007;
    vector<int> s(N+1, 0), t(M+1, 0);
    for(int i=0; i<N; ++i) cin >> s[i+1];
    for(int i=0; i<M; ++i) cin >> t[i+1];
    vector<vector<ll>> dp(N+1, vector<ll>(M+1, 1));
    for(int i=1; i<=N; ++i){
        for(int j=1; j<=M; ++j){
            dp[i][j]=(dp[i-1][j]+dp[i][j-1]+mod-(s[i]==t[j] ? 0 : dp[i-1][j-1]))%mod;
        }
    }
    cout << dp[N][M] << endl;
    return 0;
}


Measured memory_bytes: 31616
// AOJ 1127
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int c[100][100];

struct P{
    double x,y,z,r;
    double abs(){
        return sqrt(x*x+y*y+z*z);
    }
};

P operator - (P a,P b){
    a.x -= b.x;
    a.y -= b.y;
    a.z -= b.z;
    return a;
}



int uf[1000];
int get(int x){
    return uf[x] = (uf[x]==x?x:get(uf[x]));
}
int unite(int x,int y){ uf[get(x)] = get(y); }

double calc(P a,P b){
    return max((a-b).abs()-a.r-b.r,0.);
    
}
int main(){
    int n;
    while(cin >> n && n){
        for(int i = 0 ; i < 1000 ; i++) uf[i] = i;
        vector<P> pts(n);
        for(int i = 0 ; i < n ; i++){
            cin >> pts[i].x >> pts[i].y >> pts[i].z >> pts[i].r;
        }
        double ans = 0;
        vector< pair<double,pair<int,int> > > e;
        for(int i = 0 ; i < n ; i++){
            for(int j = 0 ; j < n ; j++){
                double dist = calc(pts[i],pts[j]);
                e.push_back(make_pair(dist,make_pair(i,j)));
            }
        }
        sort(e.begin(),e.end());
        for(int i = 0 ; i < e.size() ; i++){
            if( get(e[i].second.first) != get(e[i].second.second)){
                ans += e[i].first;
                unite(e[i].second.first,e[i].second.second);
            }
        }
        printf("%.3lf%c",ans,10);
    
    }
}

Measured memory_bytes: 1636
#include<iostream>
#include<cstdio>
using namespace std;
int main(void)
{	
	int E=0;int Y=0;
	scanf("%d %d",&E,&Y);
	switch(E)
	{
		case 0:if(Y>=1989){printf("H%d\n",Y-1988);break;}
			   else if(Y>=1926){printf("S%d\n",Y-1925);break;}
			   else if(Y>=1912){printf("T%d\n",Y-1911);break;}
			   else if(Y>=1868){printf("M%d\n",Y-1867);break;}
		case 1:printf("%d\n",1867+Y);break;
		case 2:printf("%d\n",1911+Y);break;
		case 3:printf("%d\n",1925+Y);break;
		case 4:printf("%d\n",1988+Y);break;
	}
	return 0;
}


Measured memory_bytes: 3232
#include  <stdio.h>
int main(void){

  int K,U;
  int sum,total;
  int i;
  int array[5000];

  while(1){

    sum = 0;

    scanf("%d",&K);
    if( K == 0 )break;

    U = K * ( K - 1 ) / 2;

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

    for( i = 0 ; i < U ; i++ ){
      sum += array[i];
    }
    total = sum / ( K - 1 );
    printf("%d\n", total);
  }
  return 0;
}

Measured memory_bytes: 616
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>

using namespace std;


#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;

//constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;


/*vectorの要素を全部確認するやつだよ。普通に拡張for文したほうがいいよ。

for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}

*/


/*for文でx,yを上下左右確認するやつだよ。正直使いづらいよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}

*/


/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/


/*実行開始からの経過時間を表すよ。

while (clock() < 1900000) {  }

*/


/*まだ使えないテクニックのメモだよ。

for (int bit = 0; bit < (1<<n); ++bit)//bit全探索用のfor文だよ

*/


/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; ++i) {
	for (int j = 0; j < w; ++j) {

	}
}

*/


int main() {
	int n; cin >> n;
	int h[114514];

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

	int ans[114514];
	ans[0] = 0;
	ans[1] = abs( h[1] - h[0]);

	for (int i = 2; i <= n; i++) {
		ans[i] = min(ans[i - 1] + abs(h[i] - h[i - 1]), ans[i - 2] + abs(h[i - 2] - h[i]));
	}

	cout << ans[n-1] << endl;

}



Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include<map>

using namespace std;


long long T1,T2,A1,A2,B1,B2,i,j,k,l,n1,n2,m;

int main()
{
  cin >> T1>>T2>>A1>>A2>>B1>>B2;
  if(A1<B1)
  {
    i=B1;
    B1=A1;
    A1=i;
    
    i=B2;
    B2=A2;
    A2=i;
  }
  n1=T1*(A1-B1);
  n2=T2*(B2-A2);
  l=n2-n1;
  if(l<0)
  {
    cout <<0;
    return 0;
  }
  
  if(l==0)
  {
    cout <<"infinity";
    return 0;
  }
  
  m=n1/(n2-n1)+1;
  k=n1%(n2-n1);
  
  if(k>0)
  {
    cout << 2*m-1;
  }
  else
  {
    cout << 2*m-2;
  }
  
    
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(0)
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
typedef long long ll;
#define pri(n) printf("%d\n",n)
#define lpri(n) printf("%lld\n",n);
#define rep(i,st,ed) for(int i=st;i<ed;i++)
#define var(n) int n; scn(n)
#define F first
#define S second 
#define pb(n) push_back(n)
const int N=3003;
const ll M=1e9+7;
const ll inf=1e18;

int dp[N][N];
void add(int& a,int b)
{
	a+=b;
	if(a>=M)
		a-=M;
}

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

	dp[1][1]=1;
	for(int len = 2;len<=n;len++)
	{
		for(int j=1;j<=len;j++)
			add(dp[len-1][j],dp[len-1][j-1]);
		for(int cur = 1;cur<=len;cur++)
		{
			if(s[len-2]=='<')
				add(dp[len][cur],dp[len-1][cur-1]);
			else
				add(dp[len][cur],(dp[len-1][len]-dp[len-1][cur-1]+M)%M);
		}
	}
	int ans = 0;
	for(int i=1;i<=n;i++)
		add(ans,dp[n][i]);
	cout<<ans<<endl;
}

Measured memory_bytes: 34176
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
using namespace std;
using ll = long long;

int main(){
  int N;
  cin >> N;
  vector<ll> A(N),T(N);
  cin >> T[0] >> A[0];
  for(int i=1;i<N;i++){
    cin >> T[i] >> A[i];
    ll bait=1,baia=1;
    if(T[i]<T[i-1]){
      bait=(T[i-1]+T[i]-1)/T[i];
    }
    if(A[i]<A[i-1]){
      baia=(A[i-1]+A[i]-1)/A[i];
    }
    T[i]*=max(bait,baia);
    A[i]*=max(bait,baia);
  }
  cout << T[N-1]+A[N-1] << endl;
}

Measured memory_bytes: 3560
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	int n;
	char a;
	cin >> n >> s;
	for (int i = 0; i < s.length(); i++) {
		a = s[i] + n;
		if (a > 90)a = a - 26;
		cout << a;
	}
	cout << endl;
}

  
  

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import glob

class InputGenerator(object):
    def __init__(self, input_path=None):
        if input_path != None:
            self.g = self.input_generator(input_path)
        else:
            self.g = None

    def input_generator(self, input_path):
        with open(input_path) as f:
            for line in f:
                yield line

    def get_input(self):
        if self.g == None:
            return input()
        else:
            return next(self.g)

def show_trace(s, trace):
    offset = 0
    arrow = ''
    for i in trace:
        if i != 0:
            print('{}{}'.format(arrow, s[offset:offset+i]), end='')
            arrow = ' -> '
        offset += i
    print('')

def solve(s):
    valid_term_list = ['dream', 'dreamer', 'erase', 'eraser']
    offset_candidate_list = [[0]]

    while offset_candidate_list != []:
        trace = offset_candidate_list.pop()
        offset = sum(trace)

        for c in valid_term_list:
            c_len = len(c)
            if c == s[offset:offset + c_len]:
                offset_candidate_list.append(trace + [c_len])
                if offset + c_len == len(s):
                    # show_trace(s, trace + [c_len])
                    return True

    return False

if __name__ == '__main__':
    TEST_FLAG = False

    if TEST_FLAG == True:
        file_path_list = sorted(glob.glob('test/*'))
    else:
        file_path_list = [None]

    for file_path in file_path_list:
        gen = InputGenerator(file_path)
        l = gen.get_input().rstrip()
        x = int(l)
        if x >= 30:
            print('Yes')
        else:
            print('No')


Measured memory_bytes: 9976
#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 SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a ,old;
  bool up = false;
  bool down = false;
  int ans = 1;
  cin >> n;
  cin >> old;
  REP(i,n-1){
      cin >> a;
      if (a>old){
          up=true;
      }
      if (a<old){
          down=true;
      }
      if (up&&down){
          up = down = false;
          ans++;
      }
      old = a;
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    for(int i = 0; i < n; i++) c[i] = a[i] - b[i];
    
    sort(c.begin(),c.end());
    int flag = 0,l,r = n-1,now = 0;
    for(l = 0; c[l] < 0; l++){
        now += c[l];
        while(now <  0){
            if(l == r){
                cout << -1 << endl;
                return 0;
            }
            now += c[r];
            r--;
        }
    }
    cout << (now < 0 ? -1 : l + (n-1-r)) << endl;
    return 0;
}

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

#define REP(i,n) for(decltype(n) i=0; i<(n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define st first
#define nd second
#define pb push_back

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef long long ll;

void solve(){
    int n;
    cin>>n;
    vi a(n), b(n), c(n);
    vector<ll> gt(n);
    REP(i,n) cin>>a[i];
    REP(i,n) cin>>b[i];
    REP(i,n) cin>>c[i];
    sort(ALL(a));
    sort(ALL(b));
    sort(ALL(c));
    int j=0;
    REP(i,n){
        while(j<n && c[j] <= b[i]) ++j;
        gt[i] = n-j;
    }
    gt.pb(0);
    for(int i=n;i>=0;--i) gt[i] += gt[i+1];
    j=0;
    ll ans=0;
    REP(i,n){
        while(j<n && b[j] <= a[i]) ++j;
        ans += gt[j];
    }
    cout<<ans;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
#define prev prev228
#define all(x) (x).begin(), (x).end()

long long MOD = 1e9 + 7;
long long fact[2100000];
long long ufact[2100000];
int a, b, c, d;

long long inq(long long a, long long b)
{
    if (!b) return 1;
    long long l = inq(a, b / 2);
    if (b % 2) return l * l % MOD * a % MOD;
    return l * l % MOD;
}

long long cnk(long long n, long long k)
{
    if (k < 0 || k > n) return 0;
    return fact[n] * ufact[k] % MOD * ufact[n - k] % MOD;
}

long long fi(long long a, long long b)
{
    long long ans = 0;
    long long summ = a + b;
    long long cur = 1;
    for (int i = 0; i <= summ; i++)
    {
        ans = (ans + cur) % MOD;
        cur = (2 * cur - cnk(i, a) - cnk(i, a + i - (a + b)) + 2 * MOD) % MOD;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    fact[0] = 1, ufact[0] = 1;
    for (int i = 1; i <= 2000000; i++) fact[i] = fact[i - 1] * i % MOD, ufact[i] = inq(fact[i], MOD - 2);
    cin >> a >> c >> b >> d;
    cout << (fi(b, d) + fi(a - 1, c - 1) - fi(a - 1, d) - fi(b, c - 1) + MOD + MOD) % MOD;
}


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

int x, n, p;
bitset<105> q;

int s(bool r, int a = x){
	if(a < 0) return a;
	if(!q[a]) return a;
	return r ? s(1, a + 1) : s(0, a - 1);
}

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

	cin >> x >> n;
	for(int i = 0; i < n; i++){
		cin >> p;
		q[p] = 1;
	}

	int l = s(0);
	int r = s(1);
	x - l > r - x ? cout << r : cout << l;
	cout << "\n";
  
  	return 0;
}

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

namespace SquareSearch
{
    class Program
    {
        static char GetCharOrDefault(string s, int index, char defaultChar)
        {
            if (s.Length <= index)
            {
                return defaultChar;
            }

            return s[index];
        }



        static bool SearchSquare(string line, int[] lengthOfColumns, int targetSquareLength)
        {
            var isFound = false;

            var count = 0;
            for (var i = 0; i < lengthOfColumns.Length; ++i) { 
                if (GetCharOrDefault(line, i, ' ')  != '*') {
                    ++lengthOfColumns[i];
                }
                else {
                    lengthOfColumns[i] = 0;
                }

                if (targetSquareLength <= lengthOfColumns[i])
                {
                    ++count;
                    if (targetSquareLength <= count)
                    {
                        isFound = true;
                    }
                }
                else
                {
                    count = 0;
                }
            }

            return isFound;
        }


        static int GetLargetSquareLength(int rank, IEnumerable<string> lines)
        {
            var columns = new int[rank];
            var targetSquareLength = 1;
            foreach (var s in lines)
            {
                if (SearchSquare(s, columns, targetSquareLength))
                {
                    ++targetSquareLength;
                }
            }
            return targetSquareLength - 1;
        }


        static IEnumerable<string> ReadLines(int count)
        {
            for (var i = 0; i < count; ++i)
            {
                yield return Console.ReadLine();
            }
        }


        static void Main(string[] args)
        {
            var answer = new List<int>();

            while (true) 
            {
                var input = Console.ReadLine();
                var rank = 0;
                {
                    if (int.TryParse(input, out rank) == false)
                    {
                        break;
                    }

                    if (rank == 0)
                    {
                        break;
                    }
                }

                var length = GetLargetSquareLength(rank, ReadLines(rank));
                answer.Add(length);
            }

            foreach (var n in answer) {
                Console.WriteLine(n);
            }
        }
    }
}

Measured memory_bytes: 5880
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  int N;
  sc.scan(N);
  int[] A = new int[N];
  foreach (i; 0 .. N)
    sc.scan(A[i]);

  writeln(reduce!(max)(A) - reduce!(min)(A));
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> d(n);
  for (int i = 0; i < n; i++) cin >> d[i];
  sort(d.begin(), d.end());
  int mid = n / 2 - 1;
  cout << d[mid + 1] - d[mid] << endl;
  return 0;
}


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

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

    map<string, int> data;
    for (int i = 0; i < n; i++){
        string str;
        cin >> str;

        data[str]++;
    }

    cout << data.size() << endl;
}


Measured memory_bytes: 19224
anser = []
anser1 = []
while True :  
 
      
  mojiretsu = list(input())
  if mojiretsu == list("-") : break
  m = int(input())
 
 
  for i in range(m) :
       
        
        A = int(input())
        C = ''.join(mojiretsu[0:A])
        del mojiretsu[0:A]
        mojiretsu.append(C)
        E = ''.join(mojiretsu)
        mojiretsu = list(E)
       

        D = ''.join(mojiretsu)
      
      
  anser.append(D)
  anser1 = '\n'.join(anser)
print(anser1)



Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
    long long N,W,k,val[109],we[109],i,j;
        long long Kn[105][100007];
    void knap()
    {
        for(i=0;i<=W;i++)
            Kn[0][i]=0;
        for(i=1;i<=N;i++)
            Kn[i][0]=0;
//            cout<<"HA";
        for(i=1;i<=N;i++)
            for(j=1;j<=W;j++)
{
                if(we[i]>j) {
                        Kn[i][j]=Kn[i-1][j];
//                        cout<<i<<" "<<we[i]<<" "<<j<<" "<<Kn[i][j]<<endl;
                }
                else
                    {
                        Kn[i][j]=max(Kn[i-1][j],val[i]+Kn[i-1][j-we[i]]);
//                        cout<<we[i]<<" "<<j<<" "<<Kn[i][j]<<endl;
                    }
}
        cout<<Kn[N][W]<<endl;
    }
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>N>>W;
    for(i=1;i<=N;i++)
        cin>>we[i]>>val[i];
        knap();
//        cout<<"?";
        return 0;
}


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

int main(){
  long int N,K;
  cin >> N >> K;
  long int N_work;
  
  long int sp;

  if(N>=K){
    sp=N/K;
    N=N-K*sp;
  }
  
  for(;;){
    if(N>=K){
      N_work=N-K;
      if(N_work>=N){
        cout << N << endl;
        return 0;
      }
      else{
        N=N_work;
      }
    }
    else if(K>N){
      N_work=K-N;
      if(N_work>=N){
        cout << N << endl;
        return 0;
      }
      else{
        N=N_work;
      }
    }
  }
}

Measured memory_bytes: 256
const n,k = map(x -> parse(Int,x), split(readline()))
const a = sort(map(x -> parse(Int,x) ,split(readline())))
ans = n+1
temp = 0

for i = n:-1:1
    if temp + a[i] < k
        temp += a[i]
    else
        ans = min(ans, i)
    end
end

print(ans - 1)


Measured memory_bytes: 168716
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

signed main() {
  ll K, N;
  cin >> K >> N;
  vector<ll> A;
  ll before = 0;
  rep(i, N) {
    ll a;
    cin >> a;
    A.pb(a - before);
    before = a;
    if (i == N - 1) {
      A[0] = (A[0] + K - a);
    }
  }
  SORT(A);
  COUT(K - A[N - 1]);
  return 0;
}

Measured memory_bytes: 2420
from itertools import accumulate
n = int(input())
a = list(map(int, input().split()))
a.sort()
a_acc = list(accumulate(a))[:-1]
ans = 1
for i in reversed(range(n-1)):
    if a_acc[i] * 2 >= a[i+1]:
        ans += 1
    else: break
print(ans)


Measured memory_bytes: 14428
/**
 * Problem:	C. 
 * Author:	hkxadpall. 
 * Date:	2018-09-01. 
 * Upload:	AtCoder. 
 */
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue> 
#include <map>
#include <set>
using namespace std;

namespace AuthorName { 
    template <typename _TpInt> inline _TpInt read();
    template <typename _TpRealnumber> inline double readr();
    template <typename _TpInt> inline void write(_TpInt x);
//	template <typename _TpSwap> inline void swap(_TpSwap &x, _TpSwap &y);
	
#	define Max_N 100007
	
	int n, k, nk, ns;
	int a[Max_N];
	long long ans;
	
	int gcd(int a, int b)
	{
		return (b == 0) ? (a) : (gcd(b, a % b));
	} 
	
	int main() 
	{
		n = read<int>();
		a[0] = read<int>();// int a;
		for (int i = 1; i <= n; i++) {
			a[i] = read<int>();
		}
		sort(a, a + n + 1);
		int max_gcd = (a[1] - a[0]);
		for (int i = 2; i <= n; i++) {
			max_gcd = gcd(max_gcd, a[i] - a[0]);
		}
		write(max_gcd);
	    return 0;
	}

#	define Getchar() getchar()

    template <typename _TpInt>
    inline _TpInt read()       
    {
        register int flag = 1;
        register char c = Getchar();
        while ((c > '9' || c < '0') && c != '-') 
            c = Getchar();
        if (c == '-') flag = -1, c = Getchar();
        register _TpInt init = (c & 15);
        while ((c = Getchar()) <= '9' && c >= '0') 
            init = (init << 3) + (init << 1) + (c & 15);
        return init * flag;
    }

    template <typename _TpRealnumber>
    inline double readr()       
    {
        register int flag = 1;
        register char c = Getchar();
        while ((c > '9' || c < '0') && c != '-') 
            c = Getchar();
        if (c == '-') flag = -1, c = Getchar();
        register _TpRealnumber init = (c & 15);
        while ((c = Getchar()) <= '9' && c >= '0') 
            init = init * 10 + (c & 15);
        if (c != '.') return init * flag;
        register _TpRealnumber l = 0.1;
        while ((c = Getchar()) <= '9' && c >= '0') 
            init = init + (c & 15) * l, l *= 0.1;
        return init * flag;
    }

    template <typename _TpInt>
    inline void write(_TpInt x)
    {
        if (x < 0) {
            putchar('-');
            write<_TpInt>(~x + 1);
        }
        else {
            if (x > 9) write<_TpInt>(x / 10);   
            putchar(x % 10 + '0');
        }
    }

//	template <typename _TpSwap>
//	inline void swap(_TpSwap &x, _TpSwap &y)
//	{
//	    _TpSwap t = x;
//	    x = y;
//	    y = t;
//	}
}

int main()
{
    AuthorName::main();
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
typedef long long int ll;
int main(){
  long long int n;
  cin >> n;
  ll a;
  vector<ll>f,e,g;
  for(int i=0;i<n;i++) {
    cin >> a;
    if(a%4==0) f.push_back(a);
    else if(a%2==0) e.push_back(a);
    else g.push_back(a);
  }
  int fs=f.size();int es=e.size();int gs=g.size();
  if(fs==0){
    if(gs==0) cout <<"Yes"<<endl;
    else cout <<"No"<<endl;
  }
  else{
    if(gs==0) cout <<"Yes"<<endl;
    else{
      if(es==0){
        if(fs+1>=gs)cout <<"Yes"<<endl;
        else cout <<"No"<<endl;
      }
      else{
        if(fs>=gs) cout <<"Yes"<<endl;
        else cout <<"No"<<endl;
      }
    }
  }

}


Measured memory_bytes: 1528
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll mod=1e9+7;

int main(){
    ll n,m;
    cin >> n >> m;
    vector<pll> d(n);
    rep(i,m){
        ll a,b;
        cin >> a >> b;
        a--; b--;
        if(a==0) d[b].fi=1;
        if(b==n-1) d[a].se=1;
    }
    bool ok=false;
    rep(i,n){
        if(d[i].fi==1 && d[i].se==1) ok=true;
    }
    if(ok) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
} 


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

int main(){
    int n, m;
    cin >> n >> m;
    int a[m], total = 0, ans;
    for(int i=0;i<m;i++){
        cin >> a[i];
        total += a[i];
    }
    
    if(total <= n){
        ans = n - total;
    }
    else{
        ans = -1;
    }

    cout << ans << endl;
    return 0;
}

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

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

    string s;
    cin >> s;
    char prev = s[0];
    int res = 0;

    rep1(i, s.size()){
        if(prev != s[i]) ++res;
        prev = s[i];
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)


const ll MOD = 1000000007;

int main(){
    int N;cin>>N;
    vector<ll> a(N,0);
    REP(i,N)cin>>a[i];
    vector<ll> v(100005,0LL);
    v[0]=3LL;
    ll res=1LL;
  bool f=true;
    REP(i,N){
        if(v[a[i]+1]>=3 || v[a[i]+1]>=v[a[i]] || v[a[i]]==0 ){res=0;break;}
        else if(v[a[i]+1]==2)v[a[i]+1]++;
        else if(v[a[i]+1]==1){
          res*=v[a[i]]-1;
          res%=MOD;
          v[a[i]+1]++;
        }
        else if(v[a[i]+1]==0){
        	res *= v[a[i]];
            res %= MOD;
            v[a[i]+1]++;
        }
    }
    cout<<res<<endl;

    return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll K;
    cin >> K;
    vector<ll> sum(n + 1, 0);
    for (int i = 0; i < n; i++) {
        cin >> sum[i + 1];
        (sum[i + 1] += sum[i]) %= K;
    }

    for (int i = 1; i <= n; i++) {
        sum[i] = (sum[i] + K - i % K) % K;
    }

    /*
    for (int i = 0; i <= n; i++) {
        cerr << sum[i] << " ";
    }
    cerr << endl;*/

    map<ll, int> cnt;
    ll ans = 0;
    for (int i = 0; i <= n; i++) {
        if (i >= K) cnt[sum[i - K]]--;
        ans += cnt[sum[i]]++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int k;cin >> k;
    string s; cin >> s;
    if(s.size() <= k){
        cout << s << endl;
    } else {
        string ans;
        rep(i,k){
            ans += s[i];
        }
        ans += "...";
        cout << ans << endl;
    }
}


Measured memory_bytes: 3600
n,k=map(int,input().split())
l=[]
for i in range(n):
    l.append(list(map(int,input().split())))
ans=0
for i in range(n):
    if k|l[i][0]==k:
        ans+=l[i][1]
t=0
for i in range(30):
    if (1<<29-i)&k:
        t+=2**(29-i)
        p=t-1
        kai=0
        for i in range(n):
            if p|l[i][0]==p:
                kai+=l[i][1]
        ans=max(ans,kai)
print(ans)
        
       

Measured memory_bytes: 29428
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;

struct Card{
    string suit;
    int value;
};

int Func(){
    int x = 0;
    return x;
}

int main(){
    int H, W;
    int h, w;
    float f;
    string s;
    
    //cin >> N;
    //for (int i=0;i<N;i++) cin >> A[i];
    
    cin >> H >> W;
    cin >> h >> w;
    
    cout << H*W-(h*W+w*H-h*w) << endl;
    
    
//    Card C1[100], C2[100];
//    //for (int i=0;i<N;i++) cin >> C1[i].suit >> C1[i].value;
//    //for (int i=0;i<N;i++) C2[i] = C1[i];
//
//    vector<int> v{5,4,3,2}; // g++ -std=c++11
//    v.push_back(1);
//    for (int i=0;i<v.size();i++) cout << v[i] << " " ; cout << endl;
//    sort(v.begin(), v.end());
//    for (int i=0;i<v.size();i++) cout << v[i] << " " ; cout << endl;
//
//    // 時間計測
//    clock_t start = clock();
//    clock_t end = clock();
//    cout << "Time = " << (double)(end - start) / CLOCKS_PER_SEC << "sec.\n";
    
    return 0;
}


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

int main(){
    int h,w;cin >> h >> w;
    int wall[11][11]={};
    rep(i,10)rep(j,10)cin >> wall[i][j];
    rep(k,10)rep(i,10)rep(j,10){
        if(wall[i][j]>wall[i][k]+wall[k][j])wall[i][j]=wall[i][k]+wall[k][j];
    }
    ll res = 0;
    rep(i,h)rep(j,w){
        int a;cin >> a;
        if(a!=-1)res+=wall[a][1];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256