akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll n,a,b,pass=0,sea=0;
    cin>>n>>a>>b;
    string s;
    cin>>s;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='a')
        {
            if(pass<a+b)
            {
                pass++;
                Yes
            }
            else
            {
                No
            }
        }
        else if(s[i]=='b')
        {
            if(pass<a+b&&sea<b)
            {
                pass++;
                sea++;
                Yes
            }
            else
            {
                No
            }
        }
        else
        {
            No
        }
    }

}
return 0;
}

Measured memory_bytes: 848
#include <stdio.h>
 
int main(void)
{
    char c;
    int s[26]={0},i,j;
    while(scanf("%c",&c)!=EOF)for(j=0;j<26;j++)if(c==j+'a'||c==j+'A')s[j]++;
    for(i=0;i<26;i++)printf("%c : %d\n",i+'a',s[i]);
    return 0;
}


Measured memory_bytes: 2112
import scala.io.Source

object Main {
//  def calcMaxProfit(numbers: Seq[Int]): Int = {
//    val maxProfit: Int = (1 to numbers.size-1)
//      .toStream
//      .map{i =>
//        val a  = numbers(i-1)
//        val bs = numbers.toStream.drop(i)
//        bs.max - a
//      }
//      .max
//    maxProfit
//  }

  def calcMaxProfit(numbers: Seq[Int]): Int = {
    var min       = numbers(0)
    var maxProfit = numbers(1) - min
    for(i <- 1 until numbers.size) {
      maxProfit = math.max(maxProfit, numbers(i) - min)
      min       = math.min(min, numbers(i))
    }
    maxProfit
  }


  def main(args: Array[String]): Unit = {
    // Get interator of stdin
    val stdinIterator = Source.stdin.getLines()

    // Skip the first line
    stdinIterator.next()

    // Get input
    val numbers: Seq[Int] = stdinIterator.toSeq.map(_.toInt).toArray

    // Calc max profit
    val maxProfit = calcMaxProfit(numbers)

    // Print max profit
    println(maxProfit)
  }
}


Measured memory_bytes: 120776
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
using ll = int64_t;

int main() {
  ll n, x, m;
  cin >> n >> x >> m;
  vector<bool> used(m * 2);
  vector<ll> one_cycle;

  int start = 0;
  ll now = x;
 	for(int i = 0; i < n; ++i) {
    used[now] = true;
    one_cycle.push_back(now);
    now = now * now % m;
    if (used[now]) {
      for(int j = 0; j < (int)one_cycle.size(); ++j) if (one_cycle[j] == now) {
        start = j;
        break;
      }
      break;
    }
  }

  ll s1 = 0, s2 = 0, loop = one_cycle.size() - start;
  for(int i = 0; i < start; ++i) s1 += one_cycle[i];
  for(int i = start; i < one_cycle.size(); ++i) s2 += one_cycle[i];
  ll ans = s1 + (n - start) / loop * s2;
  for(int i = 0; i < (n - start) % loop; ++i) {
    ans += now;
    now = now * now % m;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3876
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

    private static List<String> switchState = new ArrayList<String>();
    private static List<List<Integer>> switchStateList = new ArrayList<List<Integer>>();
    private static String str;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        Integer[][] arr = new Integer[N][2];
        for (int i = 0; i < N; i++) {
            arr[i][0] = 0;
            arr[i][1] = 1;
        }
        makeSwitchState(0, arr, "");

        for (String strState : switchState) {
            String[] splitState = strState.split(",");
            List<Integer> list = new ArrayList<Integer>();
            for (String s : splitState) {
                list.add(Integer.valueOf(s));
            }
            switchStateList.add(list);
        }

        Map<Integer, Integer> switchCountMap = new HashMap<Integer, Integer>();
        List<List<Integer>> switchConnectList = new ArrayList<List<Integer>>();
        for (int i = 0; i < M; i++) {
            int k = sc.nextInt();
            List<Integer> list = new ArrayList<Integer>();
            for (int j = 0; j < k; j++) {
                int s = sc.nextInt();
                list.add(s);
            }
            switchConnectList.add(list);
        }

        List<Integer> pList = new ArrayList<Integer>();
        for (int i = 0; i < M; i++) {
            int p = sc.nextInt();
            pList.add(p);
            //            System.out.println(p);
        }

        int ans = 0;
        for (List<Integer> state : switchStateList) {
            int cnt = 0;
            for (int i = 0; i < M; i++) {
                List<Integer> switches = switchConnectList.get(i);
                int on = 0;
                for (Integer sw : switches) {
                    if (state.get(sw - 1) == 1) {
                        on++;
                    }
                }
                if (on % 2 == pList.get(i)) {
                    cnt++;
                } else {
                    break;
                }
            }
            if (cnt == M) {
                ans++;
            }
        }

        System.out.println(ans);

    }

    static void makeSwitchState(int i, Integer[][] arr, String output) {
        if (i == arr.length) {
            switchState.add(output);
            return;
        }

        String delim = (output.length() > 0) ? "," : "";
        for (int j = 0; j < arr[i].length; j++) {
            makeSwitchState(i + 1, arr, output + delim + arr[i][j]);
        }
    }
}


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

int main(){
	int n;
	while(cin >> n , n){
		vector<int> v(n);
		for(int i=0;i<n;++i){
			cin >> v[i];
		}
		sort(v.begin(),v.end());
		int sum=0;
		for(int i=1;i<n-1;++i){
			sum+=v[i];
		}
		cout << floor((double)sum/(n-2)) << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main() {
    int n, b = 0, a = 0, ba=0;
    cin >> n;
    int ans = 0;
    rep(i,n) {
        string s;
        cin >> s;
        for(int i = 0; i < s.size()-1; ++i) {
            if(s[i]=='A' && s[i+1]=='B') ans++;
        }
        if(s[0]=='B' && s[s.size()-1]=='A') ba++;
        else if(s[s.size()-1]=='A') a++;
        else if(s[0]=='B') b++; 
    }
    ans += min(a+ba, b+ba);
    if(a==0 && b == 0 && ba > 0) ans--;
    cout << ans << endl;
    return 0;
}

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

signed main() {
  int n; cin >> n;
  int ans = 0;
  for(int i=105; i<=n; i+=2) {
    int c = 1;
    for(int j=2; j<=i; j++) if(i % j == 0) c++;
    if(c==8) ans++;
  }
  cout << ans << endl;
}


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

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define array(N, t) (t*)calloc(N, sizeof(t))
#define ll long long
#define INF ((1LL << 62) - (1LL << 31))
#define max(p, q)((p) > (q) ? (p) : (q))
#define min(p, q)((p) < (q) ? (p) : (q))
#define swap(type, a, b) { type temp = a; a = b; b = temp; }

int N;
int ans = 0;
int cnt = 0;
int D[110][2];

void solve1() {
  rep(i, N) {
    // ゾロ目が連続して3回続いたらゾロ目三回連続フラグを立てる
    if (cnt == 3) {
      ans = 1;
    }
    if (D[i][0] == D[i][1]) {
      // ゾロ目のケース
      if (cnt > 0) {
        // 前回ゾロ目だったら更に1足す
        cnt += 1;
      } else {
        // 前回ゾロ目じゃなかったら1にする
        cnt = 1;
      }
    } else {
      // ゾロ目じゃないケースは0にする
      cnt = 0;
    }
  }
}

void solve2() {
  int renzoku_cnt = 0;
  rep(i, N) {
    int d1 = D[i][0];
    int d2 = D[i][1];

    if (d1 == d2) {
      renzoku_cnt += 1;
    } else {
      renzoku_cnt = 0;
    }

    if (renzoku_cnt == 3) {
      ans = 1;
    }
  }
}

int main() {
  scanf("%d", &N);

  rep(i, N) {
    scanf("%d%d", &D[i][0], &D[i][1]);
  }
  solve2();
  if (ans == 1) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 1656
//Tonight's the night and it is going to happen again and again.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define T ll t; cin>>t; while(t--)
#define mod 1000000007
#define inf 1000000000000000000
#define mem(name,val) memset(name,val,sizeof(name))
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define endl "\n"
ll gcd(ll a,ll b){if(b==0){return a;}return gcd(b,a%b);}
int main()
{
   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
   #endif
   int n;ll sum=0;cin>>n;int a[n];
   f(n){cin>>a[i];}
   rep(i,1,n)
   {
    if(a[i]<a[i-1]){sum+=a[i-1]-a[i];a[i]=a[i-1];}
   }
   cout<<sum; 
}

Measured memory_bytes: 4392
import itertools
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
l = [a, b, c, d, e]
for v in itertools.combinations(l, 2):
    if abs(v[0]-v[1]) > k:
        print(':(')
        exit()
print('Yay!')


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
#define MAX 2000000
inline int read()
{
    int x=0,t=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')t=-1,ch=getchar();
    while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
    return x*t;
}
int f[MAX],dis[MAX];
int n,m;
int getf(int x)
{
	int tt=f[x];
	if(x==f[x])return x;
	f[x]=getf(f[x]);
	dis[x]+=dis[tt];
	return f[x];
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;++i)f[i]=i;
	while(m--)
	{
		int l=read(),r=read(),D=read();
		if(getf(l)==getf(r))
		{
			if(dis[r]-dis[l]!=D)
			{
				puts("No");
				return 0;
			}
		}
		else
		{
			int u=getf(l),v=getf(r);
			int d1=dis[l],d2=dis[r];
			int DD=d2-d1-D;
			if(DD>0)swap(u,v);
			f[v]=u;dis[v]=abs(DD);
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 4736
R(x,y,c){
	if(y)
		R(y,x%y,c+1);
	else
		printf("%d %d\n",x,c-1);
}
main(x,y){
	for(;scanf("%d%d",&x,&y),x;){
		R(x,y,x>=y);
	}
	exit(0);
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define NUM_MAX 3000
#define BUF_SIZE (NUM_MAX+50)
#define DIVISOR 1000000007

// size: specify sizeof(str)
int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

int main(void) {
    int num = get_int();
    char dirs[BUF_SIZE];
    get_str(&dirs[1], BUF_SIZE);
    // dp[N][last]
    static uint64_t dp[NUM_MAX+1][NUM_MAX+1];
    int i, j;
    // in i=2
    static uint64_t cum[NUM_MAX+2];
    if(dirs[1]=='<') {
        dp[2][2] = 1;
    } else {
        dp[2][1] = 1;
    }
    for(i = 1; i <= 4; i++) {
        cum[i] = cum[i-1] + dp[2][i-1];
    }

    for(i = 3; i <= num; i++) {
        switch(dirs[i-1]) {
            case '<': // prev < cur
                for(j = 2; j <= i; j++) {
                    dp[i][j] = cum[j] % DIVISOR; // dp[i-1][1] + .. dp[i-1][j-1]
                }
                break;
            case '>': // prev >= cur
                for(j = 1; j < i; j++) {
                    // prev >= j
                    dp[i][j] = (cum[i+1] - cum[j])%DIVISOR; // dp[i-1][j] + .. + dp[i-1][i]
                }
                break;
            default:
                break;
        }
#ifdef DEBUG
        printf("%c: ", dirs[i-1]);
        for(j = 1; j <= i; j++) {
            printf("%llu ", dp[i][j]);
        }
        putchar('\n');
#endif
        memset(cum, 0, sizeof(uint64_t)*(NUM_MAX+2));
        for(j = 1; j <= i+2; j++) {
            cum[j] = cum[j-1] + dp[i][j-1];
        }
    }
    uint64_t ans = 0;
    for(i = 1; i <= num; i++) {
        ans = (ans + dp[num][i])%DIVISOR;
    }
    printf("%d\n", (int)ans);
    return 0;
}

Measured memory_bytes: 68864
// AOJ 0245: Time Sale
// 2017.12.16 bal4u@uu

#include <stdio.h>
#include <string.h>

#define QMAX 100000
typedef struct { char r, c, t; int d, b; } Q;
Q q[QMAX+2]; int top, end;

#define WALL 64
#define COR  32

typedef struct { int d, s, e; } G;
G sell[10];
char map[22][22];
char mk[22][22][101][1024];
char buf[50], *p;
int mv[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};

int in()
{
	int n = 0;
	while (*p >= '0') n = 10*n + (*p++ & 0xf);
	p++;
	return n;
}

int main()
{
	int X, Y, r, c, n, i, j, sr, sc, ans;
	int d, t, b, r2, c2, max;

	while (fgets(p=buf, 10, stdin) && *p != '0') {
		X = in(), Y = in();
		memset(map, WALL, sizeof(map));
		for (r = 1; r <= Y; r++) {
			fgets(p=buf, 50, stdin);
			for (c = 1; c <= X; c++) {
				if (*p == '.') map[r][c] = COR;
				else if (*p == 'P') sr = r, sc = c, map[r][c] = COR;
				else map[r][c] = *p & 0xf;
				p += 2;
			}
		}
		fgets(p=buf, 5, stdin);
		n = *p & 0xf, max = 0;
		for (i = 0; i < n; i++) {
			fgets(p=buf, 50, stdin);
			j = in();
			sell[j].d = in(), sell[j].s = in(), sell[j].e = t = in();
			if (t > max) max = t;
		}

		ans = 0;
		memset(mk, 0, sizeof(mk));
		q[0].r = sr, q[0].c = sc, q[0].t = 0, q[0].d = 0, q[0].b = 0;
		top = 0, end = 1;
		while (top != end) {
			r = q[top].r, c = q[top].c, t = q[top].t, d = q[top].d, b = q[top].b;
			if (++top == QMAX) top = 0;

			if (d > ans) ans = d;
			if (t >= max) continue;
			if (mk[r][c][t][b]) continue;
			mk[r][c][t][b] = 1;

			for (i = 0; i < 4; i++) {
				r2 = r + mv[i][0], c2 = c + mv[i][1];
				if ((j = map[r2][c2]) > 10) continue;
				if (!(b & (1 << j)) && sell[j].s <= t && t < sell[j].e) {
					d += sell[j].d;
					b |= 1 << j;
				}
			}
			for (i = 0; i < 4; i++) {
				r2 = r + mv[i][0], c2 = c + mv[i][1];
				if (map[r2][c2] & COR) {
					q[end].r = r2, q[end].c = c2, q[end].t = t+1, q[end].d = d, q[end].b = b;
					if (++end == QMAX) end = 0;
				}
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> cards(n);
    for (int i=0;i<n;i++){
        cin >> cards[i];
    }
    vector<long long> left_scan_acc(n);
    vector<long long> right_scan_acc(n);
    for (int i=0;i<n;i++){
        if (i == 0){
            left_scan_acc[i] = cards[i];
        } else {
            left_scan_acc[i] = left_scan_acc[i-1] + cards[i];
        }
    }

    for (int i=0;i<n;i++){
        if (i == 0){
            right_scan_acc[n-i-1] = cards[n-i-1];
        } else {
            right_scan_acc[n-i-1] = right_scan_acc[n-i] + cards[n-i-1];
        }
    }

    long long minimum_value;
    for (int i=0;i<n-1;i++){
        if (i == 0){
            minimum_value = abs(left_scan_acc[i] - right_scan_acc[i+1]);
        } else {
            minimum_value = min(minimum_value, abs(left_scan_acc[i] - right_scan_acc[i+1]));
        }
    }
    cout << minimum_value << endl;

    return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	char s[105], t[105];
	cin >> s >> t;
	int ls = strlen(s);
	int lt = strlen(t);
	for(int i = 0; i < ls - 1; i++)
		for(int j = i + 1; j < ls; j++)
			if(s[i] > s[j])
				swap(s[i], s[j]);
	for(int i = 0; i < lt - 1; i++)
		for(int j = i + 1; j < lt; j++)
			if(t[i] < t[j])
				swap(t[i], t[j]);
	if(strcmp(s, t) < 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
 s = input()
 if s == 'SUN':
     print(7)
 elif s == 'MON':
     print(6)
 elif s == 'TUE':
     print(5)
 elif s == 'WED':
     print(4)
 elif s == 'THU':
     print(3)
 elif s == 'FRI':
     print(2)
 else:
     print(1)
main()

Measured memory_bytes: 9004
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    string s; cin >> s;
    int ans = 0;
    int n = s.size();
    rep(i, n) {
        ans += s[i] - '0';
    }
    if (ans % 9 == 0) cout << "Yes" <<endl;
    else cout << "No" << endl;
}


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

int main() {
int64_t a,c,d;
c=0;
d=0;
char b;
cin>>a;
vector<char> vec(3);
for(int64_t i=0;i<4;i++){
cin>>b;
if(b!='.'){vec.at(d)=b;
           d++;}
}
c=(int64_t)((vec.at(0)-'0')*100+(vec.at(1)-'0')*10+vec.at(2)-'0');
cout<<a*c/100<<endl;
} 


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/

int main(){
    double a, b, h, m; cin >> a >> b >> h >> m;
    double _kakudo = abs(30 * h + 0.5 * m - 6 * m);
    double kakudo = min(_kakudo,360 - _kakudo);
    double kakudo_ = M_PI / 180.0 * kakudo;
    double ans = pow(a * a + b * b - 2 * a * b * cos(kakudo_) ,0.5);
    cout << setprecision(15) << ans << endl;
}

Measured memory_bytes: 4356
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int>X(n);
  vector<int>Xsort(n);
  for(int i=0; i<n; i++){
    cin >> X[i];
  }
  Xsort = X;
  sort(Xsort.begin(), Xsort.end());
  int lmed=Xsort[n/2-1], rmed=Xsort[n/2];
  for(int i=0; i<n; i++){
    if(X[i]<=lmed)cout << rmed << endl;
    else if(X[i]>=rmed)cout << lmed << endl;
  }
  return 0;
}
    

Measured memory_bytes: 3712
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];





int main(){
    string a,b;
    cin>>a>>b;
    int c,d;
    cin>>c>>d;
    string e;
    cin>>e;
    if(a==e){
        cout<<c-1<<" "<<d<<endl;
    }
    else{
        cout<<c<<" "<<d-1<<endl;
    }
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<array>

using namespace std;
 
int main(){
#include<iostream>

using namespace std;
  int a,ans=0;
  cin >> a;
  vector<int> b(a);
  for(int i = 0;i < a;i++)
    cin >> b[i];

  sort(b.begin(),b.end());

  for(int i= 1;i < a;i++)
    ans += b[i] - b[i-1];
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <functional>
#include <typeinfo>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define mp(a, b) make_pair(a, b)
#define all(vec) (vec).begin(), (vec).end()
#define yn(formula) (formula) ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(formula) (formula) ? (cout << "YES" << endl) : (cout << "NO" << endl)
#define MIN(a, b) ((a) < (b)) ? (a) : (b)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
typedef vector<vll> vvl;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vp> vvp;
typedef vector<vpl> vvpl;

constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 29;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };

struct edge { ll to; ll cost; };

/*<ここから>***********************************************************/


int main()
{
	int N, M, X;
	cin >> N >> M >> X;
	vi A(M);
	rep(i, M) cin >> A[i];
	
	int a = 0, b = 0;
	rep(i, M) {
		if (A[i] < X) a++;
		else b++;
	}

	cout << min(a, b) << endl;
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
def gcd(x,y):
	if x%y: return gcd(y,x%y)
	else: return y
for _ in range(n):
	a,b,c,d = (int(i) for i in input().split())
	g = gcd(b,d)
	if a<b or b>d or b-g+(a%g)>c: print("No")
	else: print("Yes")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
using namespace std;
bool isPrime(int x){
  for(int i=2;i*i<=x;i++) if(x%i==0) return false;
  return true;
}
signed main(){
  int p,q,i,j,k;
  cin>>p>>q;
  k=q/__gcd(p,q);
  j=1;
  for(i=2;i*i<=k;i++){
    if(!isPrime(i)||k%i) continue;
    j*=i;
    while(k%i==0) k/=i;
  }
  cout << j*k << endl;
  return 0;
}

Measured memory_bytes: 3104
import Control.Monad
import Data.List
main = do
    n <- readLn
    cards <- replicateM n getLine
    putAnswer cards

putAnswer :: [String] -> IO ()
putAnswer cards
    | length cards == 52 = putStr ""
    | otherwise = putStrLn $ intercalate "\n" $ fullCards \\ cards

fullCards :: [String]
fullCards = (minorArcana 'S') ++ (minorArcana 'H') ++ (minorArcana 'C') ++ (minorArcana 'D')

minorArcana :: Char -> [String]
minorArcana arcana = do 
    let s = map show [1..13]
    map ((++) ([arcana] ++ " ")) s

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

int main() {
  int N,M;
  cin >> N;
  vector<string> s(N);
  for(int i=0;i<N;i++){
    cin >> s.at(i);
  }
  cin >> M;
  vector<string> t(M);
  for(int i=0;i<M;i++){
    cin >> t.at(i);
  }
  int ans=0;
  int tmp=0;
  for(int i=0;i<N;i++){
    tmp=0;
    for(int j=0;j<N;j++){
      if(s.at(i)==s.at(j)){
        tmp++;
      }
    }
    for(int k=0;k<M;k++){
      if(s.at(i)==t.at(k)){
        tmp--;
      }
    }
    if(ans<tmp){
      ans=tmp;
    }
  }
  cout << ans << endl;


}


Measured memory_bytes: 256
# ABC085C - Otoshidama
n, total = list(map(int, input().split()))
total //= 1000
for i in range(n + 1):
    for j in range(n + 1 - i):
        k = n - i - j
        if i * 10 + j * 5 + k == total:
            print(i, j, k)
            break
    else:
        continue
    break
else:
    print(-1, -1, -1)

Measured memory_bytes: 3060
#include<cstdio>
#include<vector>
using namespace std;
int main(void) {
	int n, m;
	vector<int>a,aa, b;
	int x, y, z;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d", &x);
		a.push_back(x);
	}
	x = 0;
	y = 0;
	z = 0;
	for (int i = 0; i < m; i++) {
		if (a[i] % 2 == 1) {
			if (x == 0) {
				y = a[i];
				x++;
			}
			else {
				z = a[i];
				x++;
			}
		}
	}
	if (x > 2) {
		printf("Impossible\n");
		return 0;
	}
	if (m == 1) {
		printf("%d\n", a[0]);
		if (n == 1) {
			printf("1\n");
			printf("1\n");
			return 0;
		}
		printf("2\n");
		printf("1 %d\n", n - 1);

		return 0;
	}
	if (y != 0) {
		aa.push_back(y);
		b.push_back(y);
	}
	for (int i = 0; i < m; i++) {
		if (a[i] % 2 == 0) {
			aa.push_back(a[i]);
			b.push_back(a[i]);
		}
	}
	if (z != 0) {
		aa.push_back(z);
		if (z > 1)b.push_back(z);
		else b[b.size() - 1]++;
	}
	b[0]++;
	b[b.size() - 1]--;
	for (int i = 0; i < aa.size(); i++) {
		printf("%d", aa[i]);
		if (i < aa.size() - 1)printf(" ");
		else printf("\n");
	}
	printf("%d\n", b.size());
	for (int i = 0; i < b.size(); i++) {
		printf("%d", b[i]);
		if (i < b.size() - 1)printf(" ");
		else printf("\n");
	}

	return 0;
}

Measured memory_bytes: 256
import numpy as np
import math as m

def main(**kwargs):
    minx = min(X)
    maxx = max(X)
    r = min([sum((X - x) ** 2) for x in range(minx, maxx+1)])
    return r

if __name__ == "__main__":
    cin = np.array(input().split(" ")).astype("int")
    n = cin[0]

    cin = np.array(input().split(" ")).astype("int")
    X = np.array(cin)
    
    cout = main(n=n, X=X)
    print(cout)

Measured memory_bytes: 12444
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main(){
    int ba=0,bb=0,ans=0;
    cin >> ba >> bb;
    if(ba==bb){
        ans = ba*2;
    }else{
        ans = max(ba,bb)*2-1;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
S = list(input())

ans = 0
cnt = 0
i = len(S)-1
while i >= 0:
    if i > 0 and S[i] == "C" and S[i-1] == "B":
        cnt += 1
        i -= 2
    elif S[i] == "A":
        ans += cnt
        i -= 1
    else:
        cnt = 0
        i -= 1
print(ans)

Measured memory_bytes: 4964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;
const int MAX_N = 2e5;


  
int main(){

  int d;
  cin >> d;
  vector<int> s[365], t[365];
  rep(i, d){
    rep(j, 26){
      int a;
      cin >> a;
      s[i].push_back(a);t[i].push_back(a);
    }
  }
  rep(i, d) sort(all(t[i]));
  rep(i, d){
    auto itr = find(all(s[i]), t[i][25]);
    cout << distance(s[i].begin(), itr)+1 <<endl;;
  }
}

  

Measured memory_bytes: 3752
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];
    
    long long ans = 0;
    for (int i = N - 1; i >= 0; --i) {
        A[i] += ans;
        ans += (A[i] + B[i] - 1) / B[i] * B[i] - A[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
x, y = map(int, input().split())

group = ['a', 'c', 'a', 'b', 'a', 'b', 'a', 'a', 'b', 'a', 'b', 'a']

if group[x-1] == group[y-1]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
N,M,X = map(int,input().split())
CA = [list(map(int,input().split())) for _ in [0]*N]

INF = 10**5*100
ans = INF
for i in range(2**N):
    tmp = 0
    B = [0]*M
    for j in range(N):
        if i>>j&1==0 : continue
        tmp += CA[j][0]
        for k,a in enumerate(CA[j][1:]):
            B[k] += a
    if min(B)>=X:
        ans = min(ans,tmp)
if ans == INF:
    ans = -1
print(ans)

Measured memory_bytes: 9224
N = int(input())
MOD = 10**9 + 7

dp = [[[[0] * 4 for ___ in range(4)]for __ in range(4)]for _ in range(N + 1)]
for i in range(4):
    for j in range(4):
        for k in range(4):
            dp[0][i][j][k] = 0
            dp[1][i][j][k] = 1
            dp[2][i][j][k] = 1
            if i == 2 and j == 1 and k == 0:
                continue
            elif i == 1 and j == 2 and k == 0:
                continue
            elif i == 2 and j == 0 and k == 1:
                continue
            dp[3][i][j][k] = 1


for n in range(3, N):
    for i in range(4):
        for j in range(4):
            for k in range(4):
                for c in range(4):
                    if c == 1 and i == 2 and j == 0:
                        continue
                    elif c == 2 and i == 1 and j == 0:
                        continue
                    elif c == 2 and i == 0 and j == 1:
                        continue
                    elif c == 2 and i == 1 and k == 0:
                        continue
                    elif c == 2 and j == 1 and k == 0:
                        continue
                    dp[n + 1][c][i][j] += dp[n][i][j][k]
                    dp[n + 1][c][i][j] %= MOD

ans = 0
for i in range(4):
    for j in range(4):
        for k in range(4):
            ans += dp[N][i][j][k]
print(ans % MOD)


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

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

  int ans=0;
  for(int i=0; i<n; i++){
    int l,r;
    cin>>l>>r;
    ans=ans-l+r+1;
  }
  cout<<ans<<endl;
}


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

#define fi first
#define se second

using P = pair<int, int>;
int n, w, h;
int L;

P calc(int x, int y, char c) {
    P ret;
    if(c == 'E') ret = {x+y, 2*w - x + y};
    else if(c == 'S') ret = {x - y, x + y};
    else if(c == 'W') ret = {L-x-y, L+x-y};
    else if(c == 'N') ret = {2*w-x+y, L-x-y};
    else assert(false);
    return ret;
}

int f(const vector<P>& d, int k) {
    int n = d.size();
    vector<P> v(n);
    rep(i, n) {
        v[i] = {d[i].fi - d[k].fi, d[i].se - d[k].fi};
        while(v[i].fi < 0) {
            v[i].fi += L;
            v[i].se += L;
        }
    }
    sort(v.begin(), v.end(), [&](const P& a, const P& b){return a.se < b.se;});
    int z = -1;
    int cnt = 0;
    for(auto&& p : v) {
        if(p.fi <= z) continue;
        else {
            z = p.se;
            cnt++;
        }
    }
    // cout << "k :" << k << endl;
    // rep(i, n) cout << v[i].fi << " " << v[i].se << endl;
    // cout << "cnt :" << cnt << endl;
    return cnt;
}


int main() {
    cin >> n >> w >> h;
    L = 2*w + 2*h;
    set<P> st;
    rep(i, n) {
        int x, y;
        char c;
        cin >> x >> y >> c;
        st.insert(calc(x, y, c));
    }
    // for(auto&& p : st) cout << p.fi << ", " << p.se << endl;
    vector<P> d;
    for(auto&& p : st) d.push_back(p);
    int ans = 1e9;
    rep(i, d.size()) {
        ans = min(ans, f(d, i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
typedef long long LL;
constexpr int kMax = 3000;

int main() {
  LL dp[kMax][kMax] = {};
  int N; std::cin >> N;

  for (int i = 0; i < N; ++i) {
    std::cin >> dp[i][i];
  }

  for (int j = 1; j < N; ++j) {
    for (int i = 0; i < N - j; ++i) {
      dp[i][i+j] = std::max(dp[i][i]-dp[i+1][i+j], dp[i+j][i+j] - dp[i][i+j-1]);
    }
  }

  std::cout << dp[0][N-1] << std::endl;
}


Measured memory_bytes: 70528
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`


		`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	s := next()

	ans := 0

	bc := 0

	for i := 0; i < len(s); i++ {
		if s[i:i+1] == "B" {
			bc++
		} else {
			ans += bc
		}
	}

	fmt.Fprintln(out, ans)
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


Measured memory_bytes: 1024
n=int(input())
cnt=0
from collections import Counter
cc=Counter()
for _ in range(n):
    s=input()
    if s[0]=='M' or s[0]=='A' or s[0]=='R' or s[0]=='C' or s[0]=='H':
        cc[s[0]]+=1
l=[]
for i in cc:
    l.append(cc[i])
#print(l)
for i in range(len(l)):
    for j in range(i+1,len(l)):
        for k in range(j+1,len(l)):
            cnt+=l[i]*l[j]*l[k]
print(cnt)
#print((cnt*(cnt-1)*(cnt-2))//6)


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int h, w, n;
    cin >> h >> w >> n;
    int sx, sy;
    cin >> sx >> sy;
    --sx; --sy;
    string s, t;
    cin >> s >> t;
    int lx = 0, rx = h, ly = 0, ry = w;
    ford(i, n) {
        if (t[i] == 'U') ++rx, uin(rx, h);
        if (t[i] == 'D') --lx, uax(lx, 0);
        if (t[i] == 'R') --ly, uax(ly, 0);
        if (t[i] == 'L') ++ry, uin(ry, w);

        if (s[i] == 'U') ++lx, uin(lx, h);
        if (s[i] == 'D') --rx, uax(rx, 0);
        if (s[i] == 'R') --ry, uax(ry, 0);
        if (s[i] == 'L') ++ly, uin(ly, w);
        if (lx >= rx || ly >= ry) break;
    }
    
    cout << (lx <= sx && sx < rx && ly <= sy && sy < ry ? "YES" : "NO") << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 920
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>

#define DEBUG 0

int main(int argc,char *argv[])
{
	int a,b,c,d;
	int ans[10]={};

	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);

	if (DEBUG) printf("%d %d %d %d\n",a,b,c,d);

	ans[a]++;
	ans[b]++;
	ans[c]++;
	ans[d]++;

	if (ans[1]==1 && ans[9]==1 && ans[7]==1 && ans[4]==1) printf("YES\n");
	else printf("NO\n");

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i = a; i<n; i++)
#define per(i,a,n) for (int i = n-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define all(now) (now).begin(),(now).end()
#define fi first
#define se second
#define SZ(now) ((int)(now).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod = 1000000007;
inline int read(int &n){char c=getchar();int x=0,f=1;while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+(c-'0');c=getchar();}return n = x*f;}
ll powmod(ll a,ll b,ll mod) {ll res = 1; a%=mod; assert(b>=0); for(;b; b>>=1){if(b&1)res = res*a%mod; a = a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int N = 7e2+7;
int T,n,m;
bool f[N][N], g[N][N];
int col[N], ans = 0x7fffffff, now, num[3];
inline int Get(int x){ return x*(x-1)>>1;}
bool dfs(int x, int c)
{
    col[x] = c, num[c]++;
    rep(i,1,n+1) if(!g[x][i]) {
        if(!col[i] && !dfs(i,3-c))
            return 0;
        else if(col[i]==c)
            return 0;
    }
    return 1;
}
int main()
{
    //ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    rep(i,1,m+1){
        int u, v;
        scanf("%d%d", &u, &v);
        g[u][v] = 1, g[v][u] = 1;
    }
    f[0][0] = 1;
    rep(i, 1, n + 1) g[i][i] = 1;
    rep(i,1,n+1) if(!col[i]) {
        num[1] = num[2] = 0;
        if(!dfs(i,1)){
            puts("-1");
            return 0;
        }

        now++;
        rep(j, 0, n + 1) if (f[now - 1][j]) 
            f[now][j + num[1]] = f[now][j + num[2]] = 1;
    }
    rep(i, 0, n + 1) if (f[now][i]) 
        // ans = min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
        ans=min(ans,Get(i)+Get(n-i));
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,m,k,a[200005],b[200005],asum[200005],bsum[200005],j,ans=0;
int main(){
  cin>>n>>m>>k;
  j=m;
  for(ll i=1;i<=n;i++){
    cin>>a[i];
    asum[i]=a[i]+asum[i-1];
  }
  for(ll i=1;i<=m;i++){
    cin>>b[i];
    bsum[i]=b[i]+bsum[i-1];
  }
  for(ll i=0;i<=n;i++){
    if(asum[i]>k) break;
    while(bsum[j]>k-asum[i]) j--;
    ans=max(ans,i+j);
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 9816
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int h[N];
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }
  int dp[N];
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  dp[2] = abs(h[2] - h[0]);
  for (int i = 0; i < N - 2; i++) {
    dp[i+2] = min(dp[i] + abs(h[i+2] - h[i]),dp[i+1] + abs(h[i+2] - h[i+1]));
  }
  cout << dp[N-1] << endl;
  return 0;
}

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

int main() {
	int n;
	cin>>n;
	int a[n],dp[n]={};
	for(int i=0;i<n;i++) cin>>a[i];
	dp[n-2]=abs(a[n-1]-a[n-2]);
	for(int i=n-3;i>=0;i--)
		dp[i]=min(dp[i+1]+abs(a[i+1]-a[i]),dp[i+2]+abs(a[i+2]-a[i]));
	cout<<dp[0];
	return 0;
}

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


int main() {
  ll n;
  cin>>n;
 string ans;
  while (n>0)
  {
    n--;
    ans+=n%26+'a';
    n/=26;
  }
  reverse(ans.begin(),ans.end());
  cout<<ans<<endl;
  return 0;
}


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

int main()
{
   int n;
   cin>>n;
   set<string> st;
   for(int i=0;i<n;i++)
   {string str;
   cin>>str;
   st.insert(str);
 }
 
   cout<<st.size()<<endl;
}


Measured memory_bytes: 19104
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

mod = 10**9+7

x,y = map(int,input().split())

group1 = [1,3,5,7,8,10,12]
group2 = [4,6,9,11]


ans = False
if x in group1 and y in group1:
    ans = True

elif x in group2 and y in group2:
    ans = True

if ans:
    print("Yes")
else:
    print("No")

    


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

int main(){
  int H, W, A, B; cin >> H >> W >> A >> B;
  for(int h = 0; h < H; h++){
    for(int w = 0; w < W; w++){
      cout << ((h < B) ^ (w < A));
    }
    cout << endl;
  }
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
int main(){
	LL a,b;scanf("%lld%lld",&a,&b);
	printf("%lld",a*b/gcd(a,b));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N = 10000000 + 5;

int main(){
	char c;
	cin >> c;
	if(c >= 'a' && c <= 'z')
		cout << 'a' << endl;
	else if(c >= 'A' && c <= 'Z')
		cout << 'A' << endl;
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

inline int read()
{
	int X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}

int n,W;
int w[N];
ll v[N];
ll dp[N];

int main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	n=read();
	W=read();

	for(int i=1;i<=n;++i){
		w[i]=read();
		v[i]=read();
	}

	for(int i=1;i<=n;++i){
		for(int j=W;j>=w[i];--j){
			dp[j]=max((ll)dp[j],(ll)dp[j-w[i]]+v[i]);
		}
	}

	printf("%lld\n",dp[W]);

    return 0;
}

Measured memory_bytes: 4428
import math
x = int(input())

maxs = []
for i in range(x):
    max = 0
    for j in range(x):
        if (i+1) ** (j+2) <= x:
            max = (i+1) ** (j+2)
            maxs.append(max)
        else:
            if j == 0:
                max = (i+1) ** (j+2)
                break
    # else:
    #     maxs.append(max)


maxs.sort()
# print(maxs)
print(maxs[-1])


Measured memory_bytes: 3060
#include <iostream>
#include <string>

using std::string;
using std::cin;
using std::cout;
using std::endl;

// ?????£???????????¢??°
string shuffle(string s, int n) {
	string left;
	string right;
	string s1;
	// ?????´
	left = s.substr(0, n);
	//cout << "left:" << left << endl;
	// ?????´
	right = s.substr(n, s.size());
	//cout << "right:" << right << endl;
	// ??£???
	s1 = right + left;
	return s1;
}

int main() {
	string a;	// ?????????
	int length;	// ?????£??????????????°
	int num;	// ?????£????????????????????°
	while (1)
	{
		cin >> a;
		if (a == "-") break;
		cin >> length;
		//cout << "length:" << length << endl;
		for (size_t i = 0; i < length; i++)
		{
			cin >> num;
			a = shuffle(a, num);			
		}
		cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 3124
n = int(input())
a = list(map(int, input().split()))


def chk(a, t):
    ans = 0
    x = 0
    for i in a:
        x += i
        if t == True and x < 1:
            ans += 1 - x
            x = 1
        if t == False and x > -1:
            ans += x + 1
            x = -1
        t = not t
    return ans


print(min(chk(a, True), chk(a, False)))


Measured memory_bytes: 14332
N = gets.to_i
A, B = N.times.map{ gets.split.map &:to_i }.transpose.map &:sort
B.reverse!
if N.even?
    left = A[N / 2] - A[N / 2 - 1]
    mid = B[N / 2] - A[N / 2]       # 両端含む
    right = B[N / 2 - 1] - B[N / 2]
    p left + (2 * mid + 1) + right
else
    left = A[N / 2]
    right = B[N / 2]
    p right - left + 1
end

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

int main() {
  int a, b, c, d, x, y;

  cin >> a >> b >> c >> d;
  
  x = a + b ;
  y = c + d ;
  if(x > y){
    cout << "Left" << endl;
  }
  if(x == y){
    cout << "Balanced" << endl;
  }
  if(x < y){
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <vector>
using namespace std;

int gcd(int x, int y) { return y > 0 ? gcd(y, x % y) : x; }

int main(int argc, char const *argv[]) {
  int a, b, tmp;
  while (!(cin >> a >> b).eof()) {
    if (a < b) {
      tmp = a;
      a = b;
      b = tmp;
    }
    std::cout << gcd(a, b) << ' ' << 1ll * a * b / gcd(a, b) << '\n';
  }
  return 0;
}



Measured memory_bytes: 3020
import sys

s = input()
r_s = s[::-1]
if(r_s != s):
    print('No')
    sys.exit()

n = (len(s)-1)//2
s_slice = s[0:n]
r_s_slice = s_slice[::-1]
if(s_slice != r_s_slice):
    print('No')
    sys.exit()

n = len(s)
s_3 = s[(n+3)//2 -1:]
r_s_3 = s_3[::-1]

if(s_3 != r_s_3):
    print('No')
    sys.exit()

print('Yes')


Measured memory_bytes: 3064
#include<stdio.h>

int main(){
	int i,s,c;
	
	while(0<=scanf("%d",&s)){
		if(s==0)break;
		for(i=0;i<9;i++){
			scanf("%d",&c);
			s-=c;
		}
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N;
  cin >> N;
  int64_t a[87]={0};
  a[0] = 2;
  a[1] = 1;
  for(int i = 2; i <=87; i++ ){
    a[i] += a[i-2]+a[i-1];
  }
  cout << a[N] << endl;

}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << ((c + b - 1) / b <= (a + d - 1) / d ? "Yes" : "No") << "\n";
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
 
#define pb push_back
#define mp make_pair
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
 
bool vis[200005];
vector<int> v[200001];
int l[200001],p[200001];
 
void edge(int a, int b)
{
    v[a].pb(b);
    v[b].pb(a);
}
void bfs(int u)
{
    queue<int> q;
    q.push(u);
    vis[u] = true;
    int x;
    while (!q.empty()) {
 
        int f = q.front();
        q.pop();
 
        for (int i = 0; i < v[f].size(); i++){
            x = v[f][i];
            if(!vis[x]){
                q.push(x);
                l[x] = l[f] + 1;
                p[x] = f;
                vis[x] = true;
            }
        }
    }
 
}
void init(){
  for(int i = 0 ; i <= 2000; i++)
  l[i] = 0;
 
  for(int i = 0 ; i <= 2000 ; i++)
     v[i].clear();
 
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
     int node, edg, a, b;
     cin >> node >> edg;
     for(int i = 0 ; i < edg; i++){
         cin >> a >> b;
         edge(a,b);
     }
     l[1] = 1;
     bfs(1);
     int c = 0;
     for(int i = 1 ; i <= node ; i++){
       if(vis[i])
          c++;
     }
     if(c == node){
      cout << "Yes" << endl;
      for(int i = 2 ; i <= node ; i++) cout << p[i] << endl;
     }
     else cout << "No" << endl;
 
 
    return 0;
}

Measured memory_bytes: 13276
import heapq
 
N, k = [int(s) for s in input().split(' ')]
 
h = []
while len(h) != N:
    heapq.heappush(h, int(input()))
  
min_height = 1000000000
h = heapq.nsmallest(N, h)
for start in range(0, N - k + 1):
    end = start + k - 1
    diff = h[end] - h[start]
    if diff < min_height:
        min_height = diff
print(min_height)


Measured memory_bytes: 8728