akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
    ll n;
    cin >> n;
    ll arr[n];
    for (ll i = 0; i < n; i++) {
        cin >> arr[i];
    }
    ll c[n] = {0};
    for (int i = 1; i < n; i++) {
        c[i] = c[i-1] + abs(arr[i] - arr[i-1]);
        if (i > 1) {
            c[i] = min(c[i], c[i-2] + abs(arr[i] - arr[i-2]));
        }
    }
    cout << c[n-1] << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

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

    int a, b, c, d;
    a = n / 1000;
    b = n % 1000 / 100;
    c = n % 100 / 10;
    d = n % 10;

    if ((a + b + c + d) == 7)
        printf("%d+%d+%d+%d=7\n", a, b, c, d);
    else if ((a - b + c + d) == 7)
        printf("%d-%d+%d+%d=7\n", a, b, c, d);
    else if ((a + b - c + d) == 7)
        printf("%d+%d-%d+%d=7\n", a, b, c, d);
    else if ((a + b + c - d) == 7)
        printf("%d+%d+%d-%d=7\n", a, b, c, d);
    else if ((a - b - c + d) == 7)
        printf("%d-%d-%d+%d=7\n", a, b, c, d);
    else if ((a + b - c - d) == 7)
        printf("%d+%d-%d-%d=7\n", a, b, c, d);
    else if ((a - b + c - d) == 7)
        printf("%d-%d+%d-%d=7\n", a, b, c, d);
    else if ((a - b - c - d) == 7)
        printf("%d-%d-%d-%d=7\n", a, b, c, d);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

int main()
{
    char ch;
    cin >> ch;
    printf("%c", ch+1);
}

Measured memory_bytes: 3548
#include <stdio.h>
#include <algorithm>
#include <queue>

using namespace std;

typedef struct point {
  int x;
  int y;
  int t;
} POINT;

int t, n, sx, sy, cnt;
bool d[140][140];
bool f[140][140];
queue<POINT> que;

bool input() {
  int i;

  scanf("%d %d", &t, &n);
  if (!t && !n) return false;
  fill(d[0], d[0] + 140 * 140, true);
  fill(f[0], f[0] + 140 * 140, true);
  for (i = 0; i < n; i++) {
    scanf("%d %d", &sx, &sy);
    d[sy + 70][sx + 70] = false;
  }
  scanf("%d %d", &sx, &sy);

  while (!que.empty()) que.pop();

  return true;
}

int main() {
  POINT a, b;

  while (input()) {
    a.x = sx + 70;
    a.y = sy + 70;
    a.t = t + 1;
    cnt = 0;
    que.push(a);
    while (!que.empty()) {
      a = que.front();
      que.pop();
      //printf("%d %d %d\n", a.x, a.y, a.t);
      if (!a.t) break;
      //if (a.y < 0 || 63 <= a.y || a.x < 0 || 63 <= a.x) continue;
      if (!d[a.y][a.x] || !f[a.y][a.x]) continue;
      f[a.y][a.x] = false;
      cnt++;
      
      b.x = a.x + 1;
      b.y = a.y + 1;
      b.t = a.t - 1;
      que.push(b);
      b.x = a.x + 1;
      b.y = a.y + 0;
      b.t = a.t - 1;
      que.push(b);
      b.x = a.x + 0;
      b.y = a.y - 1;
      b.t = a.t - 1;
      que.push(b);
      b.x = a.x - 1;
      b.y = a.y - 1;
      b.t = a.t - 1;
      que.push(b);
      b.x = a.x - 1;
      b.y = a.y + 0;
      b.t = a.t - 1;
      que.push(b);
      b.x = a.x + 0;
      b.y = a.y + 1;
      b.t = a.t - 1;
      que.push(b);
    }
    printf("%d\n", cnt);
  }


  return 0;
}

Measured memory_bytes: 872
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define MAX_N 50001
#define MAX_M 21
using namespace std;
int n, m;
int value[MAX_M];

int solve() {
    int coin[MAX_N];
    memset(coin, MAX_N, sizeof(coin));
    coin[0] = 0;

    for(int r = 0; r < m; r++) {
        int val = value[r];
        for(int c = val; c <= n; c++) {
            coin[c] = min(coin[c], coin[c - val] + 1);
        }
    }
    return(coin[n]);
}

int main(void) {
    cin >> n >> m;
    for(int r = 0; r < m; r++) cin >> value[r];
    
    cout << solve() << endl;
    return(0);
}

Measured memory_bytes: 1364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	printf("%d\n", min(n*a, b));
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<set>
#include<stack>
#include<queue>
using namespace std;

int main()
{
 int d,g,p[11],c[11],scr[11][1001]={};
 scanf("%d %d",&d,&g);
 int sm=0;
 for(int i=1;i<=d;i++)
 {
	scanf("%d %d",&p[i],&c[i]);
sm+=p[i];
 }
 for(int i=1;i<=d;i++)
 {
	for(int j=0;j<=sm;j++)
	{
	 //scr[i][j]の最大値はscr[i-1][j]かscr[i-1][j-N]+N*i*100かコンプリートが入るやつか
	 	for(int k=0;k<=min(j,p[i]);k++)
		{
		 if(k==p[i]){scr[i][j]=max(scr[i-1][j],(scr[i-1][j-k]+i*100*k+c[i]));}
		 else{scr[i][j]=max(scr[i-1][j],(scr[i-1][j-k]+i*100*k));}
		}
	}
 }
 for(int i=0;i<=1000;i++)
 {
	if(scr[d][i]>=g){printf("%d",i);break;}
 }
}



Measured memory_bytes: 3844
//#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}
template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n, x;
    cin >> n >> x;

    v_int l(n+1);
    irep2(i, 1, n) {
        cin >> l[i];
    }
    int d = 0;
    int ans = 0;
    irep(i, n+1) {
        d = d + l[i];
        if(d <= x) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
} /*atcoder*/


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef pair<int,int> pi;
typedef long long int ll;

const int N = (int)1e5+5;

int grid[11][1001], sum[11][1001], tsum[11][1001];
string str[11];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int h,w,k,ans = INT_MAX;
    cin>>h>>w>>k;
    for(int i=1;i<=h;i++) {
        cin>>str[i];
        for(int j=1;j<=w;j++) {
            grid[i][j] = (str[i][j-1]-'0');
            sum[i][j] = sum[i][j-1];
            for(int k=1;k<=i;k++) {
                sum[i][j] += grid[k][j];
            }
        }
    }
    /*for(int i=1;i<=h;i++) {
        for(int j=1;j<=w;j++) {
            cout<<sum[i][j]<<" ";
        }
        cout<<"\n";
    }*/
    for(int mask=0;mask<(1<<(h-1));mask++) {
        int prev = 0,cuts = __builtin_popcount(mask);
        vector<int> rows;
        for(int i=1;i<=h;i++) {
            for(int j=1;j<=w;j++) {
                tsum[i][j] = sum[i][j] - sum[prev][j];
            }
            if(i==h || ((1<<(i-1))&mask)) {
                prev = i;
                rows.push_back(i);
            }
        }
        bool ch = true;
        for(int i=1;i<=h && ch;i++) {
            for(int j=1;j<=w;j++) {
                if (tsum[i][j]-tsum[i][j-1] > k) {
                    ch = false;
                    break;
                }
            }
        }
        if (!ch) {
            continue;
        }
        prev = 0;
        for(int j=1;j<=w;j++) {
            for(auto i:rows) {
                if(tsum[i][j]-tsum[i][prev] > k) {
                    prev = j-1;
                    cuts++;
                    break;
                }
            }
        }
        /*for(int i=1;i<=h;i++) {
            for(int j=1;j<=w;j++) {
                cout<<tsum[i][j]<<" ";
            }
            cout<<"\n";
        }*/
        //cout<<mask<<" "<<cuts<<"\n";
        ans = min(ans,cuts);
    }
    cout<<ans;
}


Measured memory_bytes: 384
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

int main(){
    string S;
    cin >> S;
    llong maxv=0;
    llong cnt=0;
    for(int i=0; i<S.size(); i++){
        if(S[i]=='S'){
            maxv = max(maxv, cnt);
            cnt = 0;
        }else{
            cnt++;
        }
    }
    maxv = max(maxv, cnt);
    cout << maxv << endl;
    return 0;
}

Measured memory_bytes: 3164
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long n;
		long abcde[]=new long[5];
		n=sc.nextLong();
		long cell=n;
		int idx=0;
		for(int i=0;i<5;i++) {
			abcde[i]=sc.nextLong();
		}
		cell=abcde[0];
		for(int i=1;i<5;i++) {
			if(abcde[i]<cell) {
				idx=i;
				cell=abcde[i];
			}
		}
		long ans=(long)Math.ceil(n/(cell*1.0))+4;
		System.out.println(ans);
	}

}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}

int main() {
	fast();
 
    /*NA – JEONG – MO – SA – JI – MI – DA – CHAE – TZU*/
    
    ll a, b;
    cin >> a >> b;
    for(int i=0; i<=10000000; i++){
        ll z = i*8;
        z/=100;
        ll zz = i*10;
        zz/=100;
        if(z==a&&zz==b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int paper[10][10];

void add(int x, int y)
{
	if( x < 0 || x > 9 || y < 0 || y > 9 )return;
	paper[x][y]++;
}

void smallAdd(int x, int y)
{
	add( x, y );
	add( x - 1, y     );
	add( x    , y - 1 );
	add( x + 1, y     );
	add( x    , y + 1 );
}

void midAdd(int x, int y)
{
	smallAdd(x, y);
	add( x - 1, y - 1 );
	add( x + 1, y - 1 );
	add( x - 1, y + 1 );
	add( x + 1, y + 1 );
}

void bigAdd(int x, int y)
{
	midAdd(x, y);
	add( x    , y - 2 );
	add( x - 2, y     );
	add( x    , y + 2 );
	add( x + 2, y     );
}

void drop(int x, int y, int size)
{
	int i;
	int j;
	switch( size )
	{
		case 1:
			smallAdd( x, y );
			break;
		case 2:
			midAdd( x, y );
			break;
		case 3:
			bigAdd( x, y );
			break;
	}
}

int main(void)
{
	int x;
	int y;
	int size;
	int numOfWhite = 0;
	int mostBlack = 0;
	int i;
	int j;
	
	while( scanf( "%d,%d,%d", &x, &y, &size ) != EOF )
	{
		drop( x, y, size );
	}
	
	for( i = 0; i < 10; i++ )
	{
		for( j = 0; j < 10; j++ )
		{
			if( paper[i][j] == 0 )
			{
				numOfWhite++;
			}
			if( paper[i][j] > mostBlack )
			{
				mostBlack = paper[i][j];
			}
		}
	}
	printf( "%d\n%d\n", numOfWhite, mostBlack );
	
	return (0);
}

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

public class Main {
    public static void printTable(int[][] table){
        int N = table.length;
        for(int r=0;r<N;r++){
        	for(int l=0;l<N;l++)System.out.print(table[l][r]+" ");
        	System.out.println();
        }
    }
    public static int[][] makeTable(int N, int[] Left, int[]Right){
        int[][] count = new int[N][N];
        
        for(int m=0;m<Left.length;m++){
        	count[Left[m]][Right[m]]++;
        }
        
        for(int l=N-1;l>0;l--){
        	for(int r=0;r<N;r++)count[l-1][r]+=count[l][r];
        }
        for(int r=0;r<N-1;r++){
        	for(int l=0;l<N;l++)count[l][r+1]+=count[l][r];
        }
        return count;
        
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int Q = sc.nextInt();
        int[] Left = new int[M];
        int[] Right = new int[M];
        for(int m=0;m<M;m++){
        	Left[m]=sc.nextInt()-1;
        	Right[m]=sc.nextInt()-1;
        }
        int[][] table = makeTable(N,Left,Right);
        
        for(int query=0;query<Q;query++){
        	int p = sc.nextInt()-1;
        	int q = sc.nextInt()-1;
        	System.out.println(table[p][q]);
        }
    }
}

Measured memory_bytes: 155224
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000002486618624LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


long long solve(std::map<int, int>& map)
{
  int w = 0;

  while (! map.empty()) {
    auto pair(*map.rbegin());

    if (pair.second >= 4)
      return 1LL * pair.first * pair.first;

    if (pair.second >= 2)
      w = pair.first;
    
    map.erase(pair.first);

    if (w)
      break;
  }

  if (map.empty())
    return 0;

  while (! map.empty()) {
    auto pair(*map.rbegin());

    if (pair.second >= 2)
      return 1LL * w * pair.first;

    map.erase(pair.first);
  }

  return 0;
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, A;

  std::cin >> N;

  std::map<int, int> map;

  for (int i = 0; i < N; i ++) {
    std::cin >> A;

    map[A] ++;
  }

  std::cout << solve(map) << std::endl;

  return 0;
}


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

char Sa[100],Sb[100],Sc[100];
int cnta = 0,cntb = 0,cntc =0;
int lena,lenb,lenc;
int turna(){
	if(cnta == lena ){
		return 1;
	}
	if(Sa[cnta] == 'a'){
		cnta++;
		return turna();
	}else if(Sa[cnta] == 'b'){
		cnta++;
		return turnb();
	}else if(Sa[cnta] == 'c'){
		cnta++;
		return turnc();
	}
		
}
int turnb(){
	if(cntb == lenb){
		return 2;
	}
	if(Sb[cntb] == 'a'){
		cntb++;
		return turna();
	}else if(Sb[cntb] == 'b'){
		cntb++;
		return turnb();
	}else if(Sb[cntb] == 'c'){
		cntb++;
		return turnc();
	}
}
int turnc(){
	if(cntc == lenc){
		return 3;
	}
	if(Sc[cntc] == 'a'){
		cntc++;
		return turna();
	}else if(Sc[cntc] == 'b'){
		cntc++;
		return turnb();
	}else if(Sc[cntc] == 'c'){
		cntc++;
		return turnc();
	}
}
int main(){
	scanf("%s %s %s",Sa,Sb,Sc);
	lena = strlen(Sa);
	lenb = strlen(Sb);
	lenc = strlen(Sc);
	int ret = turna();
	if(ret == 1){
		printf("A\n");
	}else if(ret == 2){
		printf("B\n");
	}else if(ret == 3){
		printf("C\n");
	}
}


Measured memory_bytes: 128
n=int(input())
s=input()
al="abcdefghijklmnopqrstuvwxyz"
candidate=[]
count=0
for i in range(n-1):
    for j in al:
        if j in s[:i+1] and j in s[i+1:]:
            count+=1
    candidate.append(count)
    count=0
candidate.sort()
print(candidate[-1])

Measured memory_bytes: 3060
import java.awt.*;
import java.io.*;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
import java.util.HashMap;
import java.util.Map;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int[] h=new int[n];
        for(int i=0;i<n;i++){
            h[i]=sc.nextInt();
        }
        int[] dp=new int[n];
        dp[0]=0;
        dp[1]=Math.abs(h[0]-h[1]);
        for(int i=2;i<n;i++){
            dp[i]=min(h,dp,i,k);
        }
        System.out.println(dp[n-1]);
    }
    public static int min(int[] h,int[] dp,int i,int k){
        int min=Integer.MAX_VALUE;
        for(int j=1;j<=k;j++){
            if(i-j>=0) {
                int temp=dp[i-j]+Math.abs(h[i]-h[i-j]);
                if(temp<min)min=temp;
            }
            else break;
        }
        return min;
    }
    public static int setBit(long n){
        int count=0;
        while(n>0){
            n=n&(n-1);
            count++;
        }
        return count;
    }
}

Measured memory_bytes: 51388
N = int(input())
V = list(map(int, input().split()))

even = []
odd = []
for i in range(N):
    if i % 2 == 0:
        even.append(V[i])
    else:
        odd.append(V[i])

cnt_even = {}
for e in even:
    if e not in cnt_even:
        cnt_even[e] = 1
    else:
        cnt_even[e] += 1

cnt_odd = {}
for o in odd:
    if o not in cnt_odd:
        cnt_odd[o] = 1
    else:
        cnt_odd[o] += 1

cnt_even = [[v, k] for k, v in cnt_even.items()]
cnt_odd = [[v, k] for k, v in cnt_odd.items()]
cnt_even.sort(reverse=True)
cnt_odd.sort(reverse=True)

ce = cnt_even[0][0]
ce_num = cnt_even[0][1]
ce_res = sum([v for v, k in cnt_even[1:]])

co = cnt_odd[0][0]
co_num = cnt_odd[0][1]
co_res = sum([v for v, k in cnt_odd[1:]])

if ce_num != co_num:
    print(ce_res + co_res)
else:
    if len(cnt_even) > 1 and len(cnt_odd) > 1:
        ce_res_2 = ce_res - cnt_even[1][0] + ce
        co_res_2 = co_res - cnt_odd[1][0] + co
        res = min(ce_res + co_res_2, ce_res_2 + co_res)
    elif len(cnt_even) == 1 and len(cnt_odd) > 1:
        co_res_2 = co_res - cnt_odd[1][0] + co
        res = ce_res + co_res_2
    elif len(cnt_even) > 1 and len(cnt_odd) == 1:
        ce_res_2 = ce_res - cnt_even[1][0] + ce
        res = ce_res_2 + co_res
    else:
        res = min(ce, co)
    print(res)


Measured memory_bytes: 70508
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int y = sc.nextInt();
    for(int i = 0; i <= n; i++){
      for(int j = 0; j + i <= n; j++){
        int tmp = (y - 10000 * i - 5000 * j) / 1000;
        if(i + j + tmp == n){
          System.out.println(i + " " + j + " " + tmp);
          System.exit(0);
        }
      }
    }
    System.out.println("-1 -1 -1");
  }
}

Measured memory_bytes: 23124
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N;
    in(N);

    N %= 1000;
    if (N != 0) N = 1000 - N;

    outl(N);

    return 0;
}

Measured memory_bytes: 3588
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  int A=0,B=0,C=0;
  cin >> A >> B >> C;
  cout << (A+B>=C?"Yes":"No") << endl;

  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <queue>
#include <math.h>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
#include <list>
#include <ctype.h>
#include <cassert>
#include <stack>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <ctime>
#include <functional>
#include <ctime>
#include <limits>
#include <tuple>
#include <complex>
#include <numeric>
#include <future>
#include <random>

using namespace std;

#define snd second
#define fst first
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define left _left
#define right _right

const ld pi = acos(-1.0);

template<typename T>
T abs(T x) {
    return x > 0 ? x : -x;
}

template<typename T>
T sqr(T x) {
    return x * x;
}

template<typename T>
bool chmin(T &x, T y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}

template<typename T>
bool chmax(T &x, T y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}

template<typename U, typename V>
ostream &operator<<(ostream &s, const pair<U, V> &x) {
    s << "(" << x.fst << ", " << x.snd << ")";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const vector<U> &x) {
    s << "[";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "]";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const set<U> &x) {
    s << "{";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "}";
    return s;
}

template<int sz>
ostream operator<<(ostream &s, const bitset<sz> &x) {
    for (int i = 0; i < sz; i++) {
        s << x[i];
    }
    return s;
}


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


int main() {

    srand(time(NULL));

#ifdef LOCAL
    freopen("a.in", "r", stdin);
    //freopen("a.in", "w", stdout);
#else
    //freopen("brackets.in", "r", stdin);
    //freopen("brackets.out", "w", stdout);
#endif

    string s;
    cin >> s;

    if (s[0] == '0' || s.back() == '1') {
        cout << -1 << endl;
        return 0;
    }

    bool bad = false;
    int n = s.size();
    for (int i = 1; i < n; i++) {
        bad |= s[i - 1] != s[n - i - 1];
    }

    if (bad) {
        cout << -1 << endl;
        return 0;
    }

    vector<pair<int,int>> edges;

    edges.pb(mp(1, 2));

    int p = 2;
    for (int i = 2; i < n; i++) {
        if (s[i - 1] == '0') {
            edges.pb(mp(i + 1, p));
        } else {
            edges.pb(mp(i + 1, p));
            p = i + 1;
        }
    }

    assert(edges.size() == n - 1);
    for (auto p : edges) {
        cout << p.fst << " " << p.snd << endl;
    }



    return 0;
}

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

int main() {
  
  int N,K,Q;
  cin >> N >> K >> Q;
  
  int winner;
  
  vector<int> Point(N,K-Q);
  
  for ( int i =0; i<Q; i++ ) {
    
    cin >> winner;
    winner--;    
    Point.at(winner)++;
    
  }
  
  for ( int i=0; i<N; i++) {
    
    if ( Point.at(i) <1) {
      cout << "No" << endl;
    }
    
    else {
      cout << "Yes" << endl;
    }
    
  }
}

Measured memory_bytes: 1024
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

double_t A, B, H, M;

void solve()
{
    std::cin >> A >> B >> H >> M;

	double_t rad = (H / 12.0 + M / (12.0 * 60.0) - M / 60.0) * M_PI * 2;
	double_t sq = A * A + B * B - 2 * A * B * cos(rad);
	double_t ans = sqrt(sq);

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

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


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

int main() {
  
  ll h, n;
  cin >> h >> n;
  
  ll sum;
  
  for (ll i = 0; i < n; i++) {
    ll a;
    cin >> a;
    sum += a;
  }
  
  if (h <= sum) cout << "Yes" << endl;
  else cout << "No" << endl;


}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();
		Pair v = new Pair();
		v.from = x2-x1;
		v.end = y2 - y1;
		
		
		int x4 = x1-v.end;
		int y4 = y1 + v.from;
		int x3 = x4+ + v.from;
		int y3 = y4 + v.end;
		System.out.println(x3 + " "+ y3 + " "+x4 + " "+y4);
		

	}


}




class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}



Measured memory_bytes: 21716
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include <time.h>

typedef int32_t i32;
typedef int64_t i64;
typedef double f64;

void *const null=(void *)0;
i64 const llinf=4611686018427387903LL;
i64 const mod=1000000009LL;
f64 const pi=3.141592653589793;
f64 const rad=57.295779513082323;

#define CODE_

i32 main(void){
    i64 n,a,b,c,d;
    scanf("%lli%lli%lli%lli%lli",&n,&a,&b,&c,&d);
    i64 x=(n+a-1LL)/a*b;
    i64 y=(n+c-1LL)/c*d;
    printf("%lli\n",x<=y?x:y);
    return 0;
}



Measured memory_bytes: 2104
#include <stdio.h>
int cnt[100010],s,t;
int main(){
    int i,n,k;
    scanf("%d",&n);
    for(i=1;i<=n;++i)scanf("%d",&k),++cnt[k];
    for(i=1;i<=1e5;++i)if(cnt[i]>1){
        for(;cnt[i]>2;)cnt[i]-=2,s+=2;
        if(cnt[i]>1)++t;
    }
    s+=t;
    if(t%2)++s;
    printf("%d",n-s);
    return 0;
}


Measured memory_bytes: 512
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, x, rad, s, ans float64
	rad = 0
	ans = 0
	fmt.Scanf("%f", &a)
	fmt.Scanf("%f", &b)
	fmt.Scanf("%f", &x)
	s = x / a
	if s >= a*b/2 {
		var h float64 = 2 * (a*b - s) / a
		rad = math.Atan2(h, a)
	} else {
		var w float64 = 2 * s / b
		rad = math.Atan2(b, w)
	}
	ans = rad / (2 * math.Pi) * 360
	fmt.Printf("%f", ans)
}


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

int main() {
  int s;cin>>s;
  int a=s/100; int b=s%100;
  if ((a>=1 && a<=12) && (b>=1 && b<=12)) cout<<"AMBIGUOUS"<<endl;
  else if (a>=1 && a<=12) cout<<"MMYY"<<endl;
  else if (b>=1 && b<=12) cout<<"YYMM"<<endl;
  else cout<<"NA"<<endl;
}

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

namespace ABC119A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            string d;
            var word = Console.ReadLine().Split('/');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);
            if (a >= 2019 && b >= 05 && c >= 01)
                d = "TBD";
            else
                d = "Heisei";
            Console.WriteLine(d);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        w: String,
    }
    let w = w.chars().collect::<Vec<_>>();
    let mut cs = w.clone();
    cs.sort();
    cs.dedup();
    let res = cs.iter().all(|c| {
        w.iter().filter(|e| *e == c).count() % 2 == 0
    });
    if res {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int n,cnt=0;
bool check(int x)
{
	int ans=0;
	for(int i=1;i<=x;i++)
	{
		if(x%i==0)
		{
			++ans;
		}
	}
	return ans==8;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i+=2)
	{
		if(check(i))
		{
			++cnt;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 256
import sys
from typing import List, Set


sys.setrecursionlimit(200000)


def dfs(cur : int, prev: int) -> None:
    global prenum, parent, lowest, counter
    prenum[cur] = lowest[cur] = counter
    counter += 1
    for edge in edges[cur]:
        if prenum[edge] != sys.maxsize:
            if edge != prev:
                lowest[cur] = min(lowest[cur], prenum[edge])
            continue
        parent[edge] = cur
        dfs(edge, cur)
        lowest[cur] = min(lowest[cur], lowest[edge])


if __name__ == "__main__":
    V, E = map(int, input().split())
    edges: List[Set[int]] = [set() for _ in range(V)]

    for _ in range(E):
        s, t = map(int, input().split())
        edges[s].add(t)
        edges[t].add(s)

    prenum = [sys.maxsize] * V
    parent = [sys.maxsize] * V
    lowest = [sys.maxsize] * V
    counter = 0

    dfs(0, 1)
    ap: List[bool] = [False] * V
    r = 0
    for _ in filter(lambda x: x == 0, parent):  # type: ignore
        r += 1
        if r > 1:
            ap[0] = True
            break

    for i in range(1, V):
        p = parent[i]
        if p and prenum[p] <= lowest[i]:
            ap[p] = True

    for i, e in enumerate(ap):
        if e:
            print(i)



Measured memory_bytes: 27036
#include<stdio.h>
int cmp(const void *a,const void *b){return *(int*)a-*(int*)b;}
int main(){
    int h,a;
    scanf("%d%d",&h,&a);
    int ans=0;
    while(h>0){
        h-=a;
        ans++;
    }
    printf("%d\n",ans);
    return 0;
}

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

#define rep(i, n)  for (int i = 0; i < (int) (n); i++)
#define Rrep(i, n) for (int i = ((int) n - 1); i >= 0; i--)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
#define INF 2e15
#define MOD 10e9 + 7

typedef vector <int> vint;
typedef long long    ll;



int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    char num_str[1000000];

    scanf("%s", num_str); // 文字列代入

    char *num_ptr = num_str;
    int   count   = 0;
    int   sum     = 0;
    while (*num_ptr != '\0') {
        int tmp = num_str[count] - 48;
        sum += tmp;
        num_ptr++;
        count++;
    }
    // cout << sum << endl;
    if (sum % 9 == 0) { cout << "Yes" << endl; }
    else { cout << "No" << endl; }

    return 0;
}


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

using namespace std;

const int MAXN = 100 + 10;
const int INF = (int)(1e9);

char opp(char c) {
    return ((c == 'A') ? 'B' : 'A');
}

void print_alter(char f, int t, int n) {
    for(int i = 0; i < t; ++i) cout << f;
    for(int i = t; i < n; ++i) {
        f = opp(f);
        cout << f;
    }
    cout << endl;
}

void solve(string &s, int k) {
    int n = s.length();
    int sc = 0;
    bool B = false;
    while (k > 0) {
        if (sc >= n) break;
        char f = (B) ? 'B' : (((sc % 2) == 1) ? opp(s[sc]) : s[sc]);
        B = false;
        --k;
        if (f == 'B') ++sc;
        else {
            B = true;
        }
    }
    if (k == 0) {
        if (sc == n)
            print_alter((((n % 2) == 0) ? 'B' : 'A'), 1, n);
        else {
            char f = (B) ? 'B' : (((sc % 2) == 1) ? opp(s[sc]) : s[sc]);
            cout << f;
            for(int i = sc + 1; i < n; ++i)
                cout << (((sc % 2) == 1) ? opp(s[i]) : s[i]);
            if (sc > 0) {
                char c = ((sc % 2) == 1) ? 'A' : 'B';
                print_alter(c, 1, sc);
            }
            else cout << endl;
        }
    }
    else {
        char f = ((n % 2) == 0) ? 'B' : 'A';
        if (f == 'B') {
            print_alter('B', 1, n);
        }
        else {
            if ((k % 2) == 0) {
                print_alter('A', 1, n);
            }
            else {
                print_alter('B', 2, n);
            }
        }
    }
}

void run() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    //for(int i = 0; i <= k; ++i)
        solve(s, k);
}

int main()
{
    //freopen("input.txt", "r", stdin);

    int ntests = 1;
    //cin >> ntests;
    for(int tc = 1; tc <= ntests; ++tc) {
        run();
    }
}


Measured memory_bytes: 772
#include<stdio.h>
#include<math.h>
int main()
{
	
	long long int x,d,i;
	scanf("%lld",&x);
	d=sqrt(x);
	if(d*d==x)
	{
	printf("%lld\n",x);
    }
	else
	{
	for(i=1;x!=0;i++)
	{
	x=x-1;	
	d=sqrt(x);
	if(d*d==x)
	{
	printf("%lld\n",x);
	break;	
	}
    }
    }
	return 0;
}

Measured memory_bytes: 128
function main(input = "") {
    const N = input;
    let cnt = 0;
    N.split("").forEach((v) => {
        cnt += 0 | v;
    })
    return cnt % 9 === 0 ? "Yes" : "No";
}

//******************************
exports.main = main;

function Main(input) {
    console.log(main(input.trim()));
}

if (process.argv[2] !== "test") {
    Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}


Measured memory_bytes: 34368
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

long long Lucas(long long a, long long b, int n){
  if(n == 0)
    return b;
  else if(n == 1)
    return a;
  else
    return Lucas(a+b, a, n-1);
}

int main(){
  int N;
  cin >> N;
  cout << Lucas(1, 2, N) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<functional>
using namespace std;
#define ll long long int
#define ld long double
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,
tree_order_statistics_node_update> in_set;
#define rep(n) for(ll i=0;i<(n);i++)
#define jrep(n) for(ll j=0;j<(n);j++)
#define all(a) (a).begin(), (a).end()
#define dpp(a) cout<<(a).first<<" "<<(a).second<<endl;
#define append push_back
#define mod 1000000007
#define ff first
#define ss second
#define ffast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fast ios::sync_with_stdio(0);
ll pw(ll x,ll y,ll p=mod){ll r=1; x=x%p;while(y>0){ if(y&1)r=(r*x)%p;
y=y>>1;x=(x*x)%p;} return r; } vector<ll> uniq(vector<ll> arr)
{vector<ll>brr;sort(all(arr));brr.append(arr[0]);
for(auto i:arr)if(brr.back()!=i)brr.append(i);return brr;}

void solve(){
    ///ll n; cin>>n; vector<ll> arr(n); rep(n) cin>>arr[i];
    string s; cin>>s;
    ll mn = 0; ll tn = 0;
    for(auto i:s){
        if(i=='R'){ tn++; mn=max(mn,tn); }
        else tn=0;
    } cout<<mn<<endl;
}
 
int main(){
    ffast
    ll t=1;
//    cin>>t;
    rep(t) solve();
}
 
 
// *p.find_by_order(n) : nth value (0 indexed)
// p.order_of_key(7): index of 7 (0 indexed)


Measured memory_bytes: 3648
a, b, c, d = map(int, input().split())

t = 0
while a > 0 and c > 0:
    if t % 2 == 0:
        c -= b
    else:
        a -= d
    if a <= 0:
        flg_t = 0
    if c <= 0:
        flg_t = 1
    t += 1

if flg_t == 0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

struct edge {
  int to;
  ll cost;
  edge(int t, ll c): to(t), cost(c) {};
};

using P = pair<ll, int>;

vector<ll> d;
vector<int> par;
void dijkstra(int s, int N, vector<vector<edge>>& G) {
  priority_queue<P, vector<P>, greater<P>> que;
  d = vector<ll>(N, longinf);
  par = vector<int>(N, -1);
  d[s] = 0;
  que.push(P(0, s));

  while(!que.empty()) {
    P p = que.top();
    que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;

    for(int i=0; i<(int)G[v].size(); i++) {
      edge e = G[v][i];
      if(d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
        par[e.to] = v;
      }
    }
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  ll s; cin >> s;
  ll mx = 20000;
  vector<vector<edge>> G(n*mx);
  rep(i, m) {
    int u, v, a; ll b;
    cin >> u >> v >> a >> b;
    u--; v--;
    rep(j, mx) {
      if(j >= a) G[u*mx+j].push_back({int(v*mx+j-a), b});
      if(j >= a) G[v*mx+j].push_back({int(u*mx+j-a), b});
    }
  }
  rep(i, n) {
    ll c, d;
    cin >> c >> d;
    rep(j, mx) {
      G[i*mx+j].push_back({int(i*mx+min(j+c, mx-1)), d});
    }
  }
  dijkstra(min(s, mx-1), n*mx, G);
  rep(i, n) {
    if(i) {
      cout << *min_element(begin(d)+i*mx, begin(d)+(i+1)*mx) << "\n";
    }
  }
  return 0;
}


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

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

    vector<vector<int64_t>> num(10, vector<int64_t>(10, 0));
    for (int64_t i = 1; i <= N; i++) {
        string str_i = to_string(i);
        num[str_i.front() - '0'][str_i.back() - '0']++;
    }

    int64_t ans = 0;
    for (int64_t i = 0; i < 10; i++) {
        for (int64_t j = 0; j < 10; j++) {
            ans += num[i][j] * num[j][i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  string s;
  cin >> s;
  ll n = s.size();
  for (ll i = 0; i < n; i += 2) cout << s[i];
  cout << endl;
}

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

int main(){
	int N;
	cin >> N;
	vector<int> count(4,0);
	for(int i=0;i<N;i++){
		string S;
		cin >> S;
		if(S=="AC")count[0]++;
		if(S=="WA")count[1]++;
		if(S=="TLE")count[2]++;
		if(S=="RE")count[3]++;
	}
	cout << "AC x " << count[0] << endl;
	cout << "WA x " << count[1] << endl;
	cout << "TLE x " << count[2] << endl;
	cout << "RE x " << count[3] << endl;
	return 0;
}

Measured memory_bytes: 3640
/*||>>>> Praveen Ojha <<<<>>>> 16 June 2019 <<<<>>>> 17:32:56 <<<<||*/
// #pragma GCC optimize("Ofast") //(Very Fast but Inaccurate)
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //(Small operations in many loops)
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf 1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

int32_t main(){__
	int n,x;
	cin>>n>>x;
	vi a(n);
	for(int i=0;i<n;i++)
		cin>>a[i];
	int ans=1;
	vi vv;
	vv.push_back(0);
	for(int i=0;i<n;i++){
		int dnxt=vv.back()+a[i];
		if(dnxt<=x){
			ans++;
		}
		vv.push_back(dnxt);
	}
	cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
A = []
B = []
C = []
D = []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
for j in range(m):
    c, d = map(int, input().split())
    C.append(c)
    D.append(d)
for i in range(n):
    v_min = float('inf')
    for j in range(m):
        v = abs(A[i] - C[j]) + abs(B[i] - D[j])
        if v_min > v:
            v_min = v
            ans = j + 1
    print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define MAX 200009
#define ll long long
vector <ll> adj[MAX];
ll add[MAX];
ll value[MAX];
ll visited[MAX];
void dfs(ll s,ll p)
{
    if(visited[s]) return;
    visited[s]=1;
    ll x=add[s]+p;
    value[s]=value[s]+x;
    for(ll i=0;i<adj[s].size();i++)
    {
        ll f=adj[s][i];
        if(visited[f]==0) dfs(f,x);
    }
}
int main()
{
    ll n,q,x,y,p,v;
    cin>>n>>q;
    for(ll i=0;i<n-1;i++)
    {
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    memset(add,0,sizeof(add));
    memset(value,0,sizeof(value));
    memset(visited,0,sizeof(visited));
    for(ll i=0;i<q;i++)
    {
        cin>>p>>v;
        add[p]=add[p]+v;
    }
    dfs(1,0);
    cout<<value[1];
    for(ll i=2;i<=n;i++) cout<<" "<<value[i];
    cout<<endl;
}


Measured memory_bytes: 27392
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str = sc.next();
        if(n%2!=0){
            System.out.print("No");
            return;
        }
        
        int i = 0;
        while(i < n/2){
            if(str.charAt(i)!=str.charAt(i+n/2)){
                System.out.print("No");
                return;
            }
            i++;
        }
        System.out.print("Yes");
    }
    
}


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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define DIVUP(x, y) (((x) + ((y) - 1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

int main() {
  int N; scanf("%d", &N);
  int odd{0};
  int A;
  for (int i{0}; i < N; ++i) {
    scanf("%d", &A);
    if (A & 1 == 1) ++odd;
  }
  printf("%s\n", odd % 2 == 0 ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 256