akhauriyash/Code-Regression huggingface dataset:
/*input
10
1000 193 256 777 0 1 1192 1234567891011 48 425
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define mp   make_pair
#define pb   emplace_back
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define int long long
#define MAX 500
#define INF 0x3f3f3f3f

int n , x[MAX];
int32_t main(){
    IOS;
    cin >> n;
    int ans = 0;
    REP(i , 1 , n + 1) cin >> x[i];
    REP(times , 0 , 3000000 / n / n){
        REP(i , 1 , n + 1) if(x[i] >= n) {
            int tmp = x[i] / n;
            x[i] %= n;
            ans += tmp;
            REP(j , 1 , n + 1) if(i != j) x[j] += tmp;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		int str1 = scan.nextInt();
		int str2 = scan.nextInt();
		
		int i = 0;
		int j = 0;
		
		while(str1 != 0 && str2 != 0){
			for(i = 1; i <= str1; i++){
				for(j = 1; j <= str2; j++){
					if(i%2==1){
						if(j%2==0){
							System.out.print(".");
						}else if(j%2==1){
							System.out.print("#");
						}
					}else if(i%2==0){
						if(j%2==0){
							System.out.print("#");
						}else if(j%2==1){
							System.out.print(".");
						}
					}
				}
				System.out.println();
			}
			System.out.println();
			str1 = scan.nextInt();
			str2 = scan.nextInt();

		}
		
	}
}

Measured memory_bytes: 34772
X,Y,A,B,C = map(int,input().split())
r = sorted(list(map(int,input().split())),reverse=True)[:X]
g = sorted(list(map(int,input().split())),reverse=True)[:Y]
w = list(map(int,input().split()))

new = sorted(r+g+w,reverse=True)
print(sum(new[:X+Y]))

Measured memory_bytes: 108780
#include <iostream>
#include <algorithm>

using namespace std;

int a[300000];
int sorted_a[300000];

void check_sorted(int x, int y, int& diff)
{
  bool isSorted_x = false;
  bool isSorted_y = false;

  if (a[x - 1] == sorted_a[x - 1]) isSorted_x = true;
  if (a[y - 1] == sorted_a[y - 1]) isSorted_y = true;

  swap(a[x - 1], a[y - 1]);
  
  if (isSorted_x == true && a[x - 1] != sorted_a[x - 1]) diff++;
  if (isSorted_x == false && a[x - 1] == sorted_a[x - 1]) diff--;
  if (isSorted_y == true && a[y - 1] != sorted_a[y - 1]) diff++;
  if (isSorted_y == false && a[y - 1] == sorted_a[y - 1]) diff--;
}

int main()
{
  int N, Q;
  int x, y;
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    sorted_a[i] = a[i];
  }
  sort(sorted_a, sorted_a + N);

  int diff = 0;
  for (int i = 0; i < N; i++) {
    if (a[i] != sorted_a[i]) diff++;
  }

  bool sorted = false;
  int count = 0;
  if (diff == 0) sorted = true;
  cin >> Q;
  while (Q--) {
    if (!sorted) count++;
    cin >> x >> y;
    check_sorted(x, y, diff);
    if (!sorted && !diff) sorted = true;
  }
    
  sorted ? cout << count << endl : cout << "-1" << endl;
}



Measured memory_bytes: 5504
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.indexOf("YAKI") == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

void dfs(vector<vector<ll>> &next, vector<ll> &cnt, ll fr, ll frfr) {
  for (ll i = 0; i < next.at(fr).size(); i++) {
    if (fr != 0 && next.at(fr).at(i) - 1 == frfr) continue;
    cnt.at(next.at(fr).at(i) - 1) += cnt.at(fr);
    dfs(next, cnt, next.at(fr).at(i) - 1, fr);
  }
  return;
}

int main() {
  ll n, q, a, b;
  cin >> n >> q;
  vector<vector<ll>> next(n, vector<ll>(0));
  for (ll i = 0; i < n - 1; i++) {
    cin >> a >> b;
    next.at(a - 1).push_back(b);
    next.at(b - 1).push_back(a);
  }
  vector<ll> p(q), x(q), cnt(n, 0);
  for (int i = 0; i < q; i++) {
    cin >> p.at(i) >> x.at(i);
    cnt.at(p.at(i) - 1) += x.at(i);
  }
  dfs(next, cnt, 0, 0);
  for (ll i = 0; i < n - 1; i++) cout << cnt.at(i) << " ";
  cout << cnt.at(n - 1) << endl;
}

Measured memory_bytes: 36736
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    int x,y;
    string s="No";
    cin>>x>>y;
    if(y%2==0&&y>=x*2&&y<=x*4) s="Yes";
    cout<<s<<endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)

using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

int main()
{
    string s;
    cin >> s;
    int a = count(s.begin(), s.end(), s[0]);
    int b = count(s.begin(), s.end(), s[1]);
    int c = count(s.begin(), s.end(), s[2]);
    int d = count(s.begin(), s.end(), s[3]);
    string ans = a == 2 && b == 2 && c == 2 && d == 2 ? "Yes" : "No";
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <map>
#include <sstream>
#include <utility>
#include <stack>
#include <queue>
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vecto) vecto.begin(), vecto.end()
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
using ll = long long;

void ans(bool t_or_f)
{
    if (t_or_f == true)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
}

void Ans(bool t_or_f)
{
    if (t_or_f == true)
        std::cout << "YES" << std::endl;
    else
        std::cout << "NO" << std::endl;
}

using namespace std;

////////////////////////////////////////////////////////////////////

int main(){
    int n,l;
    cin >> n >> l;
    vector<int> vec(n);
    int sum = 0;
    rep(i, n){
        vec[i] = l + i;
        sum += vec[i];
    }
    if (vec[0] > 0 && vec[n - 1] > 0){
        sum -= vec[0];
        cout << sum << endl;
    }
    else if (vec[0] < 0 && vec[n - 1] < 0){
        sum -= vec[n - 1];
        cout << sum << endl;
    }
    else{
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int H, W;
    int i, j;
    while(1){
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0){
            break;
        }
        for(i = 0; i < H; i++){
            for(j = 0; j < W; j++){
                if(i == 0 || i == (H - 1)){
                    if(j == (W - 1)){
                        printf("#\n");
                    }else{
                        printf("#");
                    }
                }else{
                    if(j == 0){
                        printf("#");
                    }else if(j == (W - 1)){
                        printf("#\n");
                    }else{
                        printf(".");
                    }
                }
            }
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 588
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i=0;i<N;++i){
		cin >> A[i];
	}
	sort( A.begin(), A.end() );
	int now = -1;
	int cnt = 0;
	int ans = 0;
	for(int i=0;i<N;++i){
		if( A[i] != now ){
			ans += (cnt&1);
			now = A[i];
			cnt = 1;
		}else{
			++cnt;
		}
	}
	ans += cnt&1;
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#include <list>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

signed main() {

	int q, h, s, d;

	int n;
	cin >> q >> h >> s >> d >> n;

	q *= 8;
	h *= 4;
	s *= 2;

	int sm = min({ q,h,s });
	sm /= 2;
	if (d < s && d < h && d < q) {
		printf("%lld\n", (n / 2LL) * d * 1LL + (n % 2) * sm);
	}
	else
		printf("%lld\n", 1LL * n * sm);


	return 0;
}

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

int main() {
  int H ,W ;
  cin >> H >> W ;
  for (int i=0; i<W+1; i++){
    cout << "#" ;
  }
  cout << "#"<< endl;
  
  for(int i=0; i<H; i++){
    cout << "#";
    vector<char>a(W);
    for(int k=0; k<W; k++){
      cin >> a.at(k);
      cout << a.at(k);
    }
    cout << "#" << endl;
  }
  for (int i=0; i<W+2; i++){
    cout << "#" ;
  }
  
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
int N, K;
vector<int> P;
int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int p;
		cin >> p;
		p += 1;
		P.push_back(p);
	}

	int tmp = 0;
	for (int i = 0; i < K; i++) {
		tmp += P[i];
	}
	int ANS = tmp;
	for (int i = 0; i + K <= N - 1; i++) {
		tmp -= P[i];
		tmp += P[i + K];
		ANS = max(ANS, tmp);
	}
	cout << ANS / 2;
	if (ANS % 2 == 1) cout << ".5";
	return 0;
}

Measured memory_bytes: 1528
//
//  main.cpp
//  C
//
//  Created by 曾憲揚 on 2020/9/7.
//  Copyright © 2020 曾憲揚. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;

int main(int argc, const char * argv[]) {
    int n, k; cin>>n>>k;
    
    double ans=0;
    
    for(int i=1; i<=n; i++){
        double sc = 1.0/n;
        int reg=i;
        while(reg<k){
            sc/=2;
            reg*=2;
        }
        ans+=sc;
    }
    
    printf("%.9f\n", ans);
    return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
	n=n%10; 
	if(n==2 || n==4 || n==5 || n==7 || n==9)
		cout<<"hon";
	else if(n==0 || n==1 || n==6 || n==8)
		cout<<"pon";
	else if(n==3)
		cout<<"bon";
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	ll N,K,h[100010],dp[100010];
	cin >> N >> K;
	REP(i,N) cin >> h[i];
	const ll INF = 100000000000;
	dp[0] = 0;
	for (int i = 1; i < N; ++i) {
		dp[i] = INF;
		for (int j = 1; j <= K && i-j >= 0; ++j) {
			dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
		}
	}
	println(dp[N-1]);
}


Measured memory_bytes: 1792
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
	int[] tetra;
	int ans;
	int[] dp1, dp2;

	int dp1(int sum) {
		if (sum < 0) {
			return 200;
		}
		if (sum == 0) {
			return 0;
		}
		if (0 <= dp1[sum]) {
			return dp1[sum];
		}
		int res = 200;
		for (int i = 199; 1 <= i; i--) {
			res = Math.min(res, dp1(sum - tetra[i]) + 1);
		}
		return dp1[sum] = res;
	}

	int dp2(int sum) {
		if (sum < 0) {
			return 200;
		}
		if (sum == 0) {
			return 0;
		}
		if (0 <= dp2[sum]) {
			return dp2[sum];
		}
		int res = 200;
		for (int i = 199; 1 <= i; i--) {
			if (tetra[i] % 2 == 0) continue;
			res = Math.min(res, dp2(sum - tetra[i]) + 1);
		}
		return dp2[sum] = res;
	}

	void run() {
		MyScanner sc = new MyScanner();

		tetra = new int[200];
		dp1 = new int[2000000];
		dp2 = new int[2000000];
		for (int i = 0; i < 200; i++) {
			tetra[i] = i*(i+1)*(i+2)/6;
		}

		Arrays.fill(dp1, -1);
		Arrays.fill(dp2, -1);
		while (true) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			System.out.print(dp1(n) + " ");
			System.out.println(dp2(n));
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}
		System.out.println("----------------------------" + '\n');
	}

	class MyScanner {
		int read() {
			try {
				return System.in.read();
			} catch (IOException e) {
				throw new InputMismatchException();
			}
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();
			return array;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();
			return array;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}

}

Measured memory_bytes: 36652
#include <stdio.h>
int main(void){
    char line[1024];
    while(fgets(line, sizeof(line),stdin) != NULL){
        int a,b,c,i=0;
        sscanf(line,"%d %d",&a,&b);
        c = a+b;
        while(c>=10) {
            c/=10;
            i++;
        }
        printf("%d\n",i+1);
    }
}

Measured memory_bytes: 1808
A,B=map(int,input().split())
N=0
flag=0
while N<1250 and flag==0:
  N += 1
  a = int(N * 0.08 // 1)
  b = int(N * 0.1 // 1)
  #print(N,a,b)
  if a==A and b==B:
    flag = 1
    
if flag==1:
  print(N)
else:
  print(-1)

Measured memory_bytes: 39880
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

#define LEN(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vpii = vector<pii>;

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

inline int fcmp(double x, double y)
{ return (x < y + EPS ? (x < y - EPS ? -1 : 0) : 1);}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    
    int n, m;
    cin >> n >> m;

    vi h(n), good(n, 1);

    for(int& i : h) cin >> i;

    while(m--)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        if(h[a] > h[b]) good[b] = 0;
        else if(h[a] < h[b]) good[a] = 0;
        else good[a] = good[b] = 0;
    }

    cout << count(ALL(good), 1) << endl;
    
    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> vec(H, vector<char> (W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> vec.at(i).at(j);
    }
  }
  
  vector<bool> row(H, false);
  vector<bool> col(W, false);
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (vec.at(i).at(j) == '#') {
        row.at(i) = true;
        col.at(j) = true;
      }
    }
  }
  
  for (int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if (row.at(i) && col.at(j)) {
        cout << vec.at(i).at(j);
      }
    }
    cout << endl;
  }
  
  
  
  
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,d; cin>>a>>b>>c>>d;
	int t=1;
	while(1)
	{
		if(t&1)
		{
			c=c-b;
			if(c<=0)
			{
			
			cout<<"Yes"; 
			return 0;
		}
	}
		else
		{
		a=a-d;
		if(a<=0)
		{
			cout<<"No";
			return 0;
			}	
		}
			
	t++;	
		
	}
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

class union_find {
    private:
        vector<int> par;
        vector<int> ran;
        vector<ll> size;
    public:
        union_find(int n);
        int find(int x);
        void unite(int x, int y);
        bool same(int x, int y);
        ll show_size(int x);
};

union_find::union_find(int n){
    par.resize(n);
    ran.resize(n);
    size.resize(n);
    rep(i,n) par[i] = i;
    rep(i,n) ran[i] = 0;
    rep(i,n) size[i] = 1;
};

int union_find::find(int x) {
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
};

void union_find::unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    ll t = show_size(x)+show_size(y);
    size[x] = size[y] = t;
    if(ran[x] < ran[y]){
        par[x] = y;
        //size[y] += size[x];
    }
    else{
        par[y] = x;
        //size[x] += size[y];
        if(ran[x] == ran[y]) ran[x]++;
    }
};

ll union_find::show_size(int x) {
    if(par[x] == x) return size[x];
    return show_size(par[x] = find(par[x]));
}

bool union_find::same(int x, int y) {
    return (find(x) == find(y));
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<int> a(m), b(m);
	rep(i,m){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}
	int ans = 0;
	rep(i,m){
		union_find uf(n);
		rep(j,m){
			if(i == j) continue;
			uf.unite(a[j], b[j]);
		}
		bool bridge = false;
		rep(j,n){
			if(!uf.same(0, j)) bridge = true;
		}
		if(bridge) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Blue ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,n) for(int i=a;i<n;++i)
typedef vector<int> vi;
typedef long long ll;
const int mod=1e9+7;

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


void solve(){
	ll n,a,b;
	cin>>n>>a>>b;
	ll x=n/(a+b);
	ll y=n-x*(a+b);
	cout<<x*a+min(a,y);

}


int main(){
	Blue;
	int test=1;
	//cin>>test;
	while(test--)
		solve();
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ss substr
typedef long long ll ;
typedef long double ld ;
typedef pair<ll, ll> pairs ;
typedef map<ll,ll> mapi ;
typedef map<string,string> maps ;


int main()
{
  //freopen("lifeguards.out", "w", stdout) ;
  //freopen("lifeguards.in", "r", stdin) ;
  ios_base::sync_with_stdio(0) ;
  cin.tie(NULL) ;
  cout.tie(NULL) ;
 
 //int t ; cin >> t ; while(t--){} 
 
 ll n ; cin >> n ;
 ll r = sqrt(n) + 1 ; 
 for ( ll i = r ; i >= 1 ; i-- )
 {
   if ( n % i == 0 )
   {
     cout << ( i - 1 ) + ( n/i - 1 ) ;
     return 0 ;
   }
 }

}
 
 



 


Measured memory_bytes: 256
board = [[False]*1000001]*1000001
while True:
    m = int(input())
    if m == 0: break
    star = tuple(tuple(map(int, input().split())) for i in range(m))
    sx, sy = star[0]
    
    n = int(input())
    starlist = [tuple(map(int, input().split())) for i in range(n)]
    for i in range(n):
        board[starlist[i][0]][starlist[i][1]] = True
    for i in range(n):
        flag = True
        for j in range(len(star)):
            dx = starlist[i][0] + star[j][0] - sx
            dy = starlist[i][1] + star[j][1] - sy
            if 0 <= dx <= 1000000 and 0 <= dy <= 1000000 and board[dx][dy] == False:
                flag = False
                break
        if flag == True:
            print("{} {}".format(str(starlist[i][0] - sx), str(starlist[i][1] -sy)))
            break
    

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

int main() {

  long long INF = 1LL<<60;

  long long N, M, X;
  cin >> N >> M >> X;

  vector<long long> C(N);
  vector<vector<long long>> A(N, vector<long long>(M));

  for (int i = 0; i < N; i++) {
    cin >> C[i];
    for (int j = 0; j < M; j++) {
      cin >> A[i][j];
    }
  }

  long long answer = INF;

  for(int bits = 1; bits < (1 << N); bits++) {

    vector<int> bit;

    for (int i = 0; i < N; i++) {
      if (bits >> i & 1) {
        bit.push_back(i);
      }
    }

    vector<int> master(M, 0);
    
    long long cost = 0;

    for (int i = 0; i < bit.size(); i++) {
      int v = bit[i];
      cost += C[v];
      for (int j = 0; j < A[v].size(); j++) {
        master[j] += A[v][j];
      }
    }

    bool flg = true;
    for (int i = 0; i < M; i++) {
      if (master[i] < X) {
        flg = false;
        break;
      }
    } 

    if (flg) { 
      answer = min(answer, cost);
    }

  }

  if (answer == INF) {
    cout << "-1" << endl;
  } else {
    cout << answer << endl;
  }

  return 0;
}

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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

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

    if(s=="ABC")cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}



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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> C(H);
  for(int i = 0; i < H; i++) {
    cin >> C.at(i);
  }
  for(int i = 0; i < H; i++) {
    cout << C.at(i) << endl;
    cout << C.at(i) << endl;
  }
}



Measured memory_bytes: 256
line = gets.split(' ').map(&:to_i)

ans = -1
x = 0
while x < 1263 do
  if 8 * x >= line[0] * 100 && 8*x < line[0] * 100 +100
    if 10 * x >= 100 * line[1] && 10*x < line[1] * 100 + 100
      ans = x
      break
    end
  end
  x += 1
end

p ans


Measured memory_bytes: 1788
n = int(input())
s_taro,s_hanako = 0,0

for trial in range(n):
    taro,hanako = list(map(str, input().split()))
    if taro > hanako:
        s_taro += 3
    elif taro < hanako:
        s_hanako += 3
    else:
        s_taro += 1
        s_hanako += 1

print(s_taro, s_hanako)

Measured memory_bytes: 7600
n,p=[int(i) for i in input().split()]
#print(n,p)

flag=0
for i in range(n+1):
  for j in range(n+1-i):
    k=n-i-j
    total=10000*i+5000*j+1000*k
    if total==p and flag==0:
      print(i,j,k)
      flag=1
        
if flag==0:
  print(-1,-1,-1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define dl double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define mod 1e9+7
#define P(a,b) pair<a,b>
#define CIN(V,s,n) for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n) for(int i=s;i<n;i++){cout <<  V[i] << " ";}

using namespace std;
bool sortBylen(string &a,string &b)
{
    if(a.size()>b.size())
        return true;
    else if(a.size()==b.size())
    {
        if(a>b)
        {
            return true;
        }
        else
            false;
    }
    else
        return false;
}
int main()
{
ll t=1;
//cin >> t;
while(t--)
{
    ll n,W,i,j,k=2,l,m;
    cin >> n >> W;
    vector<ll> w(n),v(n);
    ll maxV=0;
    for(i=0;i<n;i++)
    {
        cin >> w[i] >> v[i];
    }
    vector<vector<ll> > DP(n+1,vector<ll>(W+1,0));

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=W;j++)
        {
            DP[i][j] = DP[i-1][j];
            if(w[i-1]<=j)
            {
                DP[i][j] = max(DP[i-1][j],DP[i-1][j-w[i-1]] + v[i-1]);
            }
        }
    }

    cout << DP[n][W] << endl;
}

	return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    string s;
    cin >> s;
    int ans = 0;

    int scnt = 0;
    rep(i, s.size())
    {
        scnt += s.at(i) == 'S' ? 1 : 0;
        if (scnt == 0)
        {
            ans++;
            continue;
        }

        if (s.at(i) == 'T')
        {
            scnt -= 1;
            ans--;
        }
        else
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  lli a,b;
  cin>>a>>b;
  rep(k,0,1000000000){
    if(max(a,k)-min(a,k)==max(b,k)-min(b,k)){
      ou(k);
      return 0;
    }
  }
  ou("IMPOSSIBLE");
}

Measured memory_bytes: 256
/*
  AOJ 2069
  Title:Greedy Greedy
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
#define min(x,y) (((x)<(y))?(x):(y))
int table[50001];
char message[3][30]={"OK","Cannot pay some amount","Cannot use greedy algorithm"};

int greedy(int total,int coins[],int n)
{
  int i;

  if(total < coins[1])
    return(total);
  
  for(i=n-1;i>=1;i--)
    {
      if(coins[i]==total)
	return(1);

      if(coins[i]<total)
	{
	  return(1+greedy(total-coins[i],coins,n));
	}
    }
}
void dump_table(int table[],int lim)
{
  int i;
  for(i=0;i<min(lim,50);i++)
    {
      printf("[%-2d]%d:",i,table[i]);
      if((i % 10)==0)
	  printf("\n");
    }
  printf("\n");
}
check_1(int c[],int n)
{
  int i;
  for(i=1;i<n-1;i++)
    if(c[i+1] % c[i])
      return(0);
  return(1);
}

main()
{
  int i,j,k,f,g,n,c[50],ret,lim,cnt;

  cnt=0;
  while(scanf("%d",&n) && n)
    {
      cnt++;
      memset(table,0,sizeof(table));
      for(i=0;i<n;i++)
	scanf("%d",&c[i]);
      
      ret=-1;
      if(n==1)
	{
	  if(c[0]==1)
	    ret=0;
	  else
	    ret=1;
	}
      else if(c[0]!=1)
	ret=1;
      else if(check_1(c,n))
	ret=0;
      else
	{
	  lim = c[n-1]+c[n-2];
	  for(i=1;c[n-1]*i<=lim;i++)
	    table[c[n-1]*i]=i;
	  
	  for(i=n-1;i>=0;i--)
	    for(j=0;j<=lim;j++)
	      {
		if(table[j]>0||j==0)
		  {
		    f=table[j];
		    for(k=1;(g=(c[i]*k+j))<=lim;k++)
		      if(table[g]==0 || table[g]>f+k)
			table[g]=f+k;
		  }
	      }
	}
      //dump_table(table,lim);
      
      if(ret==-1)
	{
	  for(i=1;i<=lim;i++)
	    if(table[i]!=greedy(i,c,n))
	      {
		//printf("unmatch [%d] %d %d\n",i,table[i],greedy(i,c,n));
		ret=2;
		goto END;
	      }
	  ret=0;
	}
    END:
      printf("Case #%d: %s\n",cnt,&message[ret][0]);
      
    }
  return(0);
}

Measured memory_bytes: 804
A,N=%w(7 5 3),gets.to_i
def dfs(v); [v]+A.map{|a|dfs v+a} if v.to_i<=N; end
p A.map{|v|dfs v}.flatten.compact.select{|v| v[?3]&&v[?5]&&v[?7]}.length

Measured memory_bytes: 8188
object Main extends App {
  import scala.collection.mutable
  import scala.io.StdIn._

  val str = 'A' +: readLine.trim
  println(str.indices.tail.count(i ⇒ str(i) <= str(i - 1)))
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline def let[A](@inline func: T ⇒ A): A = func(value)
  }
}


Measured memory_bytes: 44000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll k; cin >> k;
    
    ll x = 0;
    zep(i, 0, k + 10){
    	x *= 10;
    	x += 7;
    	x %= k;
    	
    	if(x == 0){
    		print(i + 1) return 0;
    	}
    }
    
    print(-1)
    
    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
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; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int n;cin>>n;int c=1;
  rep(i,n){
    int a;cin>>a;
    if(c==a)c++;
  }
  cout<<(c==1?-1:n-c+1);
}

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

int main() {
	int N;
	int *pT,*pX,*pY;
	cin >> N;
	pT = new int[N+1];
	pX = new int[N+1];
	pY = new int[N+1];
	pT[0] = 0;
	pX[0] = 0;
	pY[0] = 0;
	for (int i = 1; i <= N; i++) {
		cin >> pT[i]>> pX[i]>> pY[i];
	}

	int count = 0;
	int j = 0;
	for (int i = 1; i <= pT[N]; i++) {
		if (pT[j + 1]== i) {
			int max = pT[j + 1] - pT[j];
			unsigned int needX = pX[j + 1] - pX[j];
			unsigned int needY = pY[j + 1] - pY[j];
			int needXY = needX + needY;
			if (max >= needXY) {
				if ((max-needXY) % 2 == 0) {
					count++;
				}
			}
			j++;
		}
	}
	
	if (count == N) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#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 {
#ifndef ONLINE_JUDGE
~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__) << "] "
int main() {
	int n;
	cin>>n;
	string s;
	cin>>s;
	string k = s;
	int count = 0;
	sort(k.begin(),k.end());
	for(int i=0;i<n;i++) {
		if(s[i]!=k[i]) {
			count++;
		}
	}
	//debug()<<imie(count);
	cout<<count/2;
}


Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <set>
#include <queue>

using namespace std;


int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        cout << "x";
    }
    return 0;
}

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

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

int main()
{
	int f[10][10]={0};
	for(int y=1; y<=8; y++)
	for(int x=1; x<=8; x++)
	{
		char c; cin>>c;
		if(c=='o') f[y][x]= 1;
		if(c=='x') f[y][x]=-1;
	}

	int turn=1,pass=0;
	while(pass<2)
	{
		int mx,my,mdcnt,mcnt=0;
		for(int y=1; y<=8; y++)
		for(int x=1; x<=8; x++)
		{
			if(f[y][x]!=0) continue;

			int dcnt=0,cnt=0;
			for(int d=0; d<8; d++)
			{
				int c=1;
				while(turn*f[y+c*dy[d]][x+c*dx[d]]==-1) c++;
				if(f[y+c*dy[d]][x+c*dx[d]]!=0)
				{
					cnt+=(c-1); dcnt|=(c-1)<<(d*3);
				}
			}
			if(turn== 1 && mcnt< cnt) { mx=x; my=y; mdcnt=dcnt; mcnt=cnt; }
			if(turn==-1 && mcnt<=cnt) { mx=x; my=y; mdcnt=dcnt; mcnt=cnt; }
		}

		if(mcnt==0)
		{
			pass++; turn*=-1; continue;
		}

		for(int d=0; d<8; d++)
		for(int c=0; c<=((mdcnt>>(d*3))&7); c++)
		{
			f[my+c*dy[d]][mx+c*dx[d]] = turn;
		}

		pass=0; turn*=-1;
	}

	const char s[3]={'x','.','o'};
	for(int y=1; y<=8; y++)
	{
		for(int x=1; x<=8; x++)
		{
			cout << s[f[y][x]+1];
		}
		cout << endl;
	}

}

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

using namespace std;

const int MAX_N = 10000;

vector<int> G[MAX_N];
int color[MAX_N];
deque<int> L;
bool flag;	//????????????

void visit(int u)
{
	if(color[u] == 0){
		flag = true;	//DAG??§??????
		return;
	}
	if(color[u] == 1){
		return;
	}
	color[u] = 0;
	for(int i=0;i<G[u].size();i++){
		visit(G[u][i]);
	}
	color[u] = 1;
	L.push_front(u);
}

int main()
{
	int n;
	int m;
	cin >> n >> m;
	for(int i=0;i<m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
	}
	for(int i=0;i<n;i++){
		color[i] = -1;
	}
	for(int i=0;i<n;i++){
		if(color[i] == -1){
			flag = false;
			visit(i);
		}
		if(flag == true){
			break;
		}
	}
	for(int i=0;i<n;i++){
		printf("%d\n",L[i]);
	}
}

Measured memory_bytes: 3960
#include <iostream>
using namespace std;
int main() {
	int a;
	cin >> a;
	int b;
	cin >> b;
	int c;
	int d = 0;
	cin >> c;
	if (a <= b){
		for(a; a <= b ; a++) {
			c % a;
			if (c % a == 0){
				d=d+1;
			}		
		}
		cout << d << endl;
	}
	return 0;
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int N; cin >> N;
    map<int, int> cnt;
    set<int> nums;
    rep(i, N) {
        int A; cin >> A;
        nums.insert(A);
        cnt[A]++;
    }

    bool ans;
    if (nums.size() > 2) {
        ans = false;
    } else {
        vector<int> a;
        for (auto n : nums) a.push_back(n);

        if (nums.size() == 1) {
            ans =  (a[0] == N-1 || a[0] <= N/2);
        } else {
            int h = a[1];
            ans = (a[0] + 1 == a[1] && N-h+1 <= cnt[h] && cnt[h] <= min((N-h)*2, N));
        }
    }

    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 9600
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        final int N = Integer.parseInt(sc.next());
        NextPermutation pe = new NextPermutation(N);
        int a = 0;
        int b = 0;
        int lap = 0;
        String p = "";
        String q = "";
        for (int i = 0; i < N; i++) {
            p += sc.next();
        }
        for (int i = 0; i < N; i++) {
            q += sc.next();
        }
        sc.close();
        
        do {
            ++lap;
            if (pe.toString().equals(p)) a = lap;
            if (pe.toString().equals(q)) b = lap;
        } while (pe.next());
        
        out.println(Math.abs(a - b));
        
        out.flush();
    }
}

class NextPermutation {
    final int n, a[];

    public NextPermutation(int n) {
        this.n = n;
        a = new int[n + 1];
        for (int i = 1; i <= n; i++) a[i] = i;
    }

    public boolean next() {  // 辞書式順序で次の順列
        a[0] = 0;  // 番人
        int i = n - 1;
        while (a[i] >= a[i + 1]) i--;
        if (i == 0) return false;  // 完了
        int j = n;
        while (a[i] >= a[j]) j--;
        int swap = a[i];  a[i] = a[j];  a[j] = swap;
        i++;  j = n;
        while (i < j) {
            swap = a[i];  a[i] = a[j];  a[j] = swap;  i++;  j--;
        }
        return true;  // 未了
    }

    @Override
    public String toString() {
        String s = "";
        for (int i = 1; i <= n; i++) s += a[i];
        return s;
    }

}

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

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

	long long ans = 0;
	map<pair<int, int>, int> m;
	for( int i = 1; i < N; i++ ) {
		if( i == N  - i ) continue;
		pair<int, int> p = make_pair( min(i, N - i), max(i, N - i) );
		if( m.count(p) == 0 ) {
			m[p]++;
			ans++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 31488
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int K = sc.nextInt();
        boolean ret = solve(K, A, B, C);
        System.out.println(ret ? "Yes" : "No");
    }

    boolean solve(int k, int a, int b, int c) {
        if (a < b && b < c)
            return true;
        if (k == 0)
            return false;
        boolean ret = false;
        ret |= solve(k - 1, a * 2, b, c);
        ret |= solve(k - 1, a, b, c * 2);
        ret |= solve(k - 1, a, b * 2, c);
        return ret;
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 35704
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int k = sc.nextInt();
    int max = Math.max(a,Math.max(b,c));
    int total = a+b+c-max;
    for(int i = 0;i<k;i++){
      max*=2;
    }
    System.out.println(total + max);
  }
}


Measured memory_bytes: 21844
#include <stdio.h>

int main(){

    int room[6][3][10]={0},n=0,i,j,k,a,b,c,d;

    scanf("%d",&n);

    for (i=0; i<n; i++) {
        scanf("%d %d %d %d",&a,&b,&c,&d);
        room[a][b][c]=room[a][b][c]+d;
    }

    for (i=1; i<5; i++)
    {
        for (j=1; j<4; j++)
        {
            for (k=1; k<11; k++)
            {
                printf(" %d",room[i][j][k]);
            }
            printf("\n");
        }
        if (i!=4)
        printf("####################\n");
    }

    return 0;
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define sl set<ll>
#define vs vector<string>
#define vl vector<ll>
#define vi vector<int>
#define vpl vector<pair<ll,ll>>
#define pb push_back
#define PI 3.14159265358979323846
#define ll long long
#define ld long double
#define endl "\n"
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repp(i,a,b) for (ll i = (a); i >= (b); i--)
#define rop(i,a,b)  for(ll i=(a); i>(b); i--)
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define tt long long t; cin>>t; while(t--)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
const int maxn=1e5+100;


int main()
{ 
float a,b,c;
cin>>a>>b>>c;
float p=a/c;
if(p<=b)cout<<"Yes";
else cout<<"No";
}

Measured memory_bytes: 3716
#include<iostream>
#include<cstdio>
main(){int a,b,c,d;while(std::cin>>a>>b>>c){d=a*10000+b*100+c;if(d<18680908){printf("pre-meiji\n");continue;}if(d<19120730){printf("meiji %d %d %d\n",a-1867,b,c);continue;}if(d<19261225){printf("taisho %d %d %d\n",a-1911,b,c);continue;}if(d<19890108){printf("showa %d %d %d\n",a-1925,b,c);continue;}printf("heisei %d %d %d\n",a-1988,b,c);}}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x,i,m,n,t=0;
  string s;
  cin>>s;
  if(s=="SUN") cout<<"7"<<endl;
    if(s=="MON") cout<<"6"<<endl;
      if(s=="TUE") cout<<"5"<<endl;
        if(s=="WED") cout<<"4"<<endl;
          if(s=="THU") cout<<"3"<<endl;
            if(s=="FRI") cout<<"2"<<endl;
              if(s=="SAT") cout<<"1"<<endl;


}


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

int main() {
 int X,Y;
 cin >> X >> Y;
 
  if(Y%2 == 1){
    cout << "No" << endl;
  }
  else if(4*X >= Y && 2*X <= Y){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3560
#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() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    string ans;
    while (true) {
        C -= B;
        A -= D;
        if (C <= 0) {
            ans = "Yes";
            break;
        }
        if (A <= 0) {
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setbitc(x) __builtin_popcount(x)
#define init(x,a) memset(x,a,sizeof(x))
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
ll n,m,k,ar[N],br[N];
string s,s1;
//Variables End

int main()
{
    ios
    int ti=1;
    //cin>>ti;
    while(ti--)
    {
    	ll dist,dam;
		cin>>n>>dist>>dam;
		vpii in(n);
		vi add(n+1,0);
		rep(i,0,n)cin>>in[i].F>>in[i].S;
		sort(all(in));
		ll ans=0;
		rep(i,0,n)
		{
			ll cur=add[i]+in[i].S;
			if(cur<=0)
			{
				add[i+1]+=add[i];
				continue;
			}
			ll cnt=(cur+dam-1)/dam;
			ll extra=dam*cnt;
			ans+=cnt;
			ll pos=upper_bound(all(in),mp(in[i].F+2*dist,inf))-in.begin();
			if(pos<n)add[pos]+=extra;
			add[i]-=extra;
			add[i+1]+=add[i];
		}        
		cout<<ans<<endl;
    }
    return 0;
        
}

Measured memory_bytes: 4992