akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll n,k,y,x;
  cin >> n >> k >> x >> y;
  ll ans=0;
  rep(i,n){
    if(i<k){
      ans+=x;
    }
    else{
      ans+=y;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
    static final long MOD = 1000000007;

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n + 1];
        long sum =0;
        for (int i = 0; i < n + 1; i++) {
            a[i] = scanner.nextInt();
            sum += a[i];
        }
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            b[i] = scanner.nextInt();
        }

        for (int i = 0; i < n; i++) {
            if (a[i] <= b[i]) {
                b[i] -= a[i];
                a[i] = 0;
            } else {
                a[i] -= b[i];
                b[i] = 0;
            }

            a[i+1] -= b[i];
            if (a[i+1] < 0) {
                a[i+1] = 0;
            }
        }
        long sum2 = 0;
        for (int i = 0; i < a.length; i++) {
            sum2 += a[i];
        }
        System.out.println(sum - sum2);
    }
}


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

vector<vector<int>> G;
vector<bool> visited;
vector<int> color, color_cnt;

void dfs(int cur, int col) {
  visited.at(cur) = true;
  color.at(cur) = col;
  color_cnt.at(col)++;
  for (auto nx : G.at(cur)) {
    if (visited.at(nx)) continue;
    dfs(nx, col);
  }
}

int main() {
  int N, M, K; cin >> N >> M >> K;
  G.resize(N);
  for (int i = 0; i < M; i++) {
    int a, b; cin >> a >> b; a--; b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }
  visited.resize(N);
  color.resize(N);
  color_cnt.resize(N);
  int col = 0;
  for (int i = 0; i < N; i++) {
    if (!visited.at(i)) {
      dfs(i, col);
      col++;
    }
  }
  vector<int> ans(N);
  for (int i = 0; i < N; i++) {
    ans.at(i) = color_cnt.at(color.at(i)) - G.at(i).size() - 1;
  }
  for (int i = 0; i < K; i++) {
    int a, b; cin >> a >> b; a--; b--;
    if (color.at(a) == color.at(b)) {
      ans.at(a)--;
      ans.at(b)--;
    }
  }
  for (int i = 0; i < N; i++) {
    if (i) cout << " ";
    cout << max(0, ans.at(i));
  }
  cout << endl;
}

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

int main()
{
    int arr[3];
    for (int i = 0; i < 3; i++)
    {
        cin >> arr[i];
    }
    sort(arr, arr + 3);
    cout << arr[0] + arr[1];
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll num[5][5]={};
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>num[i][j];
    }
  }
  ll b[3]={};
  ll mi=1e9;
  for(int i=0;i<3;i++){
    mi=min(mi,num[0][i]);
   
  }
  for(int i=0;i<3;i++){
    b[i]=num[0][i]-mi;
  }
  for(int i=1;i<3;i++){
    ll hoge;
    for(int j=0;j<3;j++){
      if(j==0)hoge=num[i][j]-num[0][j];
      else{
        if(hoge!=num[i][j]-num[0][j]){cout<<"No"<<endl;return 0;}
      }
    }
  }
  cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  string S, T;
  cin >> S >> T;

  int count = 0;
  for (ll i = 0; i < 3; i++) {
    if (S[i] == T[i]) count++;
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
  int A,B;
  int coin = 0;
  scanf("%d%d", &A, &B);
  for(int i = 0; i < 2; i++){
    if(A > B){
      coin += A;
      A -= 1;
    }
    else{
      coin += B;
      B -= 1;
    }
  }
  printf("%d\n", coin);
  return 0;
}


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

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

    string days[] = {"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
    string S;
    cin >> S;
    for (int i = 0; i < 7; i++) {
        if (S == days[i])
            cout << (i == 6 ? 7 : 6 - i) << '\n';
    }

    return 0;
}

Measured memory_bytes: 256
#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 {
#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__) << "] "

using ll = long long;

const int INF = 1e9 + 5;

int main() {
	int n;
	scanf("%d", &n);
	int k;
	scanf("%d", &k);
	vector<int > h(n);
	for(int& x : h) {
		scanf("%d", &x);
	}
	vector<int > dp(n, INF);
	dp[0] = 0;
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j <= i + k; j++) {
			if(j < n) {
				dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
			}
		}
	} 
	printf("%d\n", dp[n-1]);
    return 0;
}


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define ph push
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

typedef long long ll; 
typedef long double ld;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
typedef pair<ll,ll>pi; typedef pair<ll,pi>spi; typedef pair<pi,pi>dpi;

#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
// #define cerr if(0)cout
#define MAXN (300006)
ll n, k, A[MAXN];
int main()
{
	FAST
	cin>>n>>k;
	FOR(i,0,n-1) cin>>A[i];
	sort(A,A+n);
	ll ans=0;
	FOR(i,0,n-k-1) {
		ans += A[i];
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		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();
		}

		Arrays.sort(h);

		long answer = 0;
		for (int i = 0; i < n - k; i++) {
			answer = answer + h[i];
		}

		print(answer);
		sc.close();
	}

	public static void print(Object obj) {
		System.out.println(obj);
	}

}


Measured memory_bytes: 65496
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll a[100010];

int main(){
    int n;
    cin >> n;
    rep(i, n+1) cin >> a[i];
    bool flag = true;

    if (a[0] != 0) flag = false;
    if (a[0] == 1 && n == 0) flag = true;

    ll y = 0;
    rep(i, n+1) y += a[i];

    y -= 1;
    ll cnt = 0;
    ll now = 1;

    rep(i, n){
        // cout << now << " " << y << endl;
        cnt += now;

        if (now < a[i]) flag = false;
        now -= a[i];
        ll tmp = min(y, now);
        now += tmp;
        y -= tmp;
    }

    // cout << now << " " << y << endl;


    if (now != a[n]) flag = false;
    else cnt += a[n];

    if (flag) cout << cnt << endl;
    else cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 4416
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 2000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

bool debug=false;
/*---------------------------------------------------*/

int main(){
  string s;
  cin>>s;
  rep(i,s.size()){
    if(i%2==0)cout<<s[i];
  }
  cout<<endl;
  
  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main(void){
    while(1){
        int h, w;
        scanf("%d%d", &h, &w);
        if(!h && !w) break;
        for(int i=0; i<h; i++){
            if(i==0 || i==h-1){
                for(int l=0; l<w; l++) printf("#");
                printf("\n");
            }else{
                for(int l=0; l<w; l++){
                    if(l==0 || l==w-1) printf("#");
                    else printf(".");
                }
                printf("\n");
            }
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2040
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

long long int INF = 1e18;
using namespace std;

typedef pair<long long int, long long int> P;

vector<int> E[1100];

vector<int> v3;
int A[100], B[100];

int f(int l1, int r1, int l2, int r2){
	//cout << l1 <<" "<< r1 <<" "<< l2 <<" "<< r2 << endl;
	if(l1 > r1 || l2 > r2){
		return -1;
	}
	int id = A[l1];
	int piv = l2;
	for(int i = l2; i <= r2; i++){
		if(B[i] == id){
			piv = i;
			break;
		}
	}
	int len = piv - l2;
	E[id].push_back(f(l1 + 1, l1 + len, l2, piv - 1));
	E[id].push_back(f(l1 + len + 1, r1, piv + 1, r2));
	return id;
}

void f3(int u){
	if(E[u][0] != -1){
		f3(E[u][0]);
	}
	if(E[u][1] != -1){
		f3(E[u][1]);
	}
	v3.push_back(u);
}


int main(){
	
	int n;
	cin >> n;
	
	for(int i = 0; i < n; i++){
		cin >> A[i];
		A[i]--;
	}
	
	for(int i = 0; i < n; i++){
		cin >> B[i];
		B[i]--;
	}
	
	f(0, n - 1, 0, n - 1);
	
	for(int i = 0; i < n; i++){
		//cout << E[i][0] << " " << E[i][1] << endl;
	}
	
	f3(A[0]);
	
	cout << v3[0] + 1;
	for(int i = 1; i < v3.size(); i++){
		cout << " " << v3[i] + 1;
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 3184
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		double a = saori.Hayamin();
		double b = saori.Hayamin();
		double t= saori.Hayamin() + 0.5;
		boolean flg = true;
		double num = 0;
		int ans = 0;
		while(flg){
			num += a;
			if(num > t){
				flg = false;
				break;
			} else {
				
				ans += b;
			}
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22484
using System;

class A{
  public static void Main(){
    int n,count = 0;
    n = int.Parse(Console.ReadLine());
    int[] array = new int[n];

    string[] str = Console.ReadLine().Split(' ');
    for(int i = 0;i < n;i++){
      array[i] = int.Parse(str[i]);
    }

    for(int i = 0;i < n - 1;i++){
      for(int j = n - 1;j > i;j--){
        if(array[j].CompareTo(array[j-1]) < 0){
          Swap(ref array[j],ref array[j-1]);
          count++;
        }
      }
    }

    for(int i = 0;i < n - 1;i++){
    Console.Write(array[i] + " ");
    }
    Console.Write(array[n - 1]);
    Console.WriteLine("");

    Console.WriteLine(count);
    }

    static void Swap(ref int x,ref int y){
      int temp;
      temp = x;
      x = y;
      y = temp;
    }
}


Measured memory_bytes: 9172
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		Map<Long, Long> divNum = new HashMap<>();
		long tmpN = N;
		if (N == 1) {
			System.out.println(0);
			System.exit(0);
		}
		for (long i = 2; Math.pow(i, 2) <= tmpN; i++) {
			if (N % i == 0) {
				N = N / i;
				if (divNum.get(i) == null) {
					divNum.put(i, (long) 1);
				} else {
					divNum.put(i, divNum.get(i) + 1);
				}
				if (N == 1) {
					break;
				}
				i--;
			}
		}
		// 1以外だったら残ったNも約数
		if (N != 1) {
			if (divNum.get(N) == null) {
				divNum.put(N, (long) 1);
			} else {
				divNum.put(N, divNum.get(N) + 1);
			}
		}
		long res = 0;
		loop: for (Entry<Long, Long> entry : divNum.entrySet()) {
			for (int i = 1; i < 48; i++) {
				long num = (i + 1) * (i + 2) / 2;
				if (entry.getValue() < num) {
					res += i;
					continue loop;
				}
			}
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 36344
import scala.io.StdIn.{readInt,readLine}

object Main {

  def main(args:Array[String]) = {
    Iterator.continually(readLine).takeWhile(_!=null).foreach { s =>
      val n = s.split("\\+")
      val m = n(1).split("=")
      val a = n(0);val b = m(0);val c = m(1)
      val range = if((a.length>1 && a(0)=='X') ||
                     (b.length>1 && b(0)=='X') ||
                     (c.length>1 && c(0)=='X')) '1' to '9' else '0' to '9'
      val result = range.find{ e =>
        BigInt(a.replace('X',e))+BigInt(b.replace('X',e)) == BigInt(c.replace('X',e))
      }.map(_.toString).getOrElse("NA")
      println(result)
    }
  }
}

Measured memory_bytes: 45040
#include <stdio.h>

int main(void)
{
  int n,k;
  int d[1000];
  int a[1000][1000];
  int sunuke[1000];
  int count=0;
  scanf("%d %d", &n, &k);
  for(int i=1;i<=k;i++){
    scanf("%d", &d[i]);
    for(int j=1;j<=d[i];j++){
      scanf("%d", &a[i][j]);
      sunuke[a[i][j]] += 1;
    }
  }
  for(int i=1;i<=n;i++){
    if(sunuke[i]==0){
      count += 1;
    }
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 2132
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const long long INF = 1LL << 60;

int k,a,b;

int main()
{
  cin >> k >> a >> b;
  if(a <= (b/k)*k) cout << "OK" << endl;
  else cout << "NG" << endl;
}

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

int main() {

  while(1) {

    int ice[10] = {0};
    int n;

    cin >> n;
    if(n == 0) break;
    
    int t;
    for(int i=0;i<n;i++) {
      cin >> t;
      ice[t]++;
    }


    for(int i=0;i<10;i++) {

      if(ice[i] == 0) cout << "-" << endl;
      else {
	for(int j=0;j<ice[i];j++)
	  cout << "*";
	cout << endl;
      }
    }

  }

  return 0;

}

Measured memory_bytes: 1152
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  char a, b; cin >> a >> b;
  string A = "", B = "";
  REP(_, b - '0') A += a;
  REP(_, a - '0') B += b;
  cout << min(A, B) << '\n';
  return 0;
}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    long long ans = 0, counter = 0, m = 2147483647;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        ans += abs(A[i]);
    }
    for (int i = 0; i < N; ++i) {
        m = min(m, abs(A[i]));
        if (A[i] == 0) {
            cout << ans << endl;
            return 0;
        }
        if (A[i] < 0) ++counter;
    }
    if (counter % 2 == 1) ans -= m * 2;

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


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <time.h>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(c) (c).begin(), (c).end()
#define P pair<int, int>
#define chmin(x, y) x = min(x, y)

const int p = 998244353;

int in_vec(vector<ll> vec, ll y)
{
  ll ret = -1;
  for (int i = 0; i < vec.size(); i++)
  {
    if (vec[i] == y)
    {
      ret = i;
    }
  }
  return ret;
}

int main()
{
  ll n, x, m;
  cin >> n >> x >> m;
  vector<ll> vec;
  vec.push_back(x);
  ll y = (x * x) % m;
  while (in_vec(vec, y) == -1)
  {
    vec.push_back(y);
    y = (y * y) % m;
  }
  ll lp_init = in_vec(vec, y);
  ll lp = vec.size() - lp_init;
  ll lp_init_sum = 0;
  for (int i = 0; i < lp_init; i++)
  {
    lp_init_sum += vec[i];
  }
  ll lp_sum = 0;
  for (int i = 0; i < lp; i++)
  {
    lp_sum += vec[lp_init + i];
  }

  ll ans = 0;
  if (n < lp_init)
  {
    for (int i = 0; i < n; i++)
    {
      ans += vec[i];
    }
  }
  else
  {
    ans = lp_init_sum + ((n - lp_init) / lp) * lp_sum;
    for (int i = 0; i < (n - lp_init) % lp; i++)
    {
      ans += vec[lp_init + i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4072
package main

import (
	"fmt"
	"time"
)

func main() {
	last := time.Date(2019, 4, 30, 0, 0, 0, 0, time.UTC)

	var s string
	fmt.Scan(&s)

	t, _ := time.Parse("2006/01/02", s)

	if t.After(last) {
		fmt.Println("TBD")
	} else {
		fmt.Println("Heisei")
	}
}


Measured memory_bytes: 512
n = int(input())
import numpy as np
a = np.zeros(n, dtype=int)
b = np.zeros(n, dtype=int)
buf1  = input().split()
buf2  = input().split()
for i in range(n):
	a[i] = int(buf1[i])
	b[i] = int(buf2[i])
r = 0
if(np.sum(a) < np.sum(b)):
	r = -1
else:
	c = a - b
	c = np.sort(c)
	if(c[0] >= 0):
		r = 0
	else:
		ii = -1
		for i in range(n):
			if(c[i] >= 0):
				ii = i
				break
		debt = np.sum(c[:i])
		for i in range(n):
			debt += c[n-1-i]
			if(debt >= 0):
				r = ii+(i+1)
				break
print(r)

Measured memory_bytes: 31404
import java.util.*;
import java.io.*;
public class Main {
    static InputStreamReader r;
    public static void main(String[] args) throws Exception {
        r = new InputStreamReader(System.in);
        int s[] = new int[3001];
        int t[] = new int[3001];
        int sc = setArray(s);
        int tc = setArray(t);

        int dp[][] = new int[3001][3001];
        for (int i = 0; i < sc; i++) {
            for (int j = 0; j < tc; j++) {
                if (s[i] == t[j]) {
                    dp[i+1][j+1] = Math.max(dp[i+1][j+1], dp[i][j]+1);
                }
                dp[i+1][j+1] = Math.max(dp[i+1][j+1], dp[i+1][j]);
                dp[i+1][j+1] = Math.max(dp[i+1][j+1], dp[i][j+1]);
            }
        }

        String ans = "";
        while (sc > 0 && tc > 0) {
            if (dp[sc][tc] == dp[sc-1][tc]) {
                sc--;
            } else if (dp[sc][tc] == dp[sc][tc-1]) {
                tc--;
            } else {
                ans = (char)s[sc-1] + ans;
                sc--;
                tc--;
            }
        }
        System.out.println(ans);
    }

    public static int setArray(int array[]) throws Exception {
        int count = 0;
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            array[count] = c;
            count++;
        }
        return count;
    }
}


Measured memory_bytes: 86272
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

fn is_small(a: &Vec<char>, b: &Vec<char>) -> bool {
    if a.len() != b.len() { return false; }

    for (i, &c) in a.iter().enumerate() {
        if c < b[i] {
            return true;
        } else if c > b[i] {
            return false;
        }
    }

    false
}

fn main() {
    scan!(s; String);
    scan!(t; String);

    let s_vec = s.chars().collect::<Vec<char>>();
    let t_vec = t.chars().collect::<Vec<char>>();

    let mut cands = Vec::new();

    for i in 0..(s.len()-t.len()+1) {
        let mut flag = true;
        for (j, &c) in t_vec.iter().enumerate() {
            if s_vec[i+j] != '?' && s_vec[i+j] != c {
                flag = false;
                break;
            }
        }
        if flag { cands.push(i); }
    }

    if cands.len() == 0 {
        println!("UNRESTORABLE");
        return;
    }

    let mut ans = s.chars().collect::<Vec<char>>();
    let mut flag = true;
    for i in cands {
        let mut u = s.chars()
            .map(|c| if c != '?' { c } else { 'a' })
            .collect::<Vec<_>>();
        for (j, t_c) in t.chars().enumerate() {
            u[i+j] = t_c;
        }

        if is_small(&u, &ans) || flag {
            ans = u;
            flag = false;
        }
    }

    println!("{}", ans.into_iter().collect::<String>());
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();

    int n;
    cin >> n;

    string s;
    cin >> s;
    rep(i, s.size()){
        s[i] = (s[i]-'A'+n)%26+'A';
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<random>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	ll ans=1;
	for(ll i=1; i*i<=m;i++) {
		if(m%i!=0) continue;
		ll a=i;
		ll b=m/i;
		if(m/a>=n) ans=max(ans,a);
		if(m/b>=n) ans=max(ans,b);
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll x;
    cin>>x;
    ll sum=0;
    ll c=x;
    while (c>0){
        sum+=c%10;
        c/=10;
    }
    bool flg=false;
    if(x%sum==0)flg=true;
    if(flg)puts("Yes");
    else puts("No");
    return 0;
}



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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
const double PI = acos(-1);
int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	double a, b, x, ans;
	cin >>a >>b >>x;

	if(x> a*a*b/2) ans = atan2((a*b-x/a)*2, a*a);
	else  ans = atan2(b*b, x*2/a);
	printf("%.14f\n", ans * 180/PI);
	return 0;
}


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

int main()
{
    string b;
    cin >> b;
    if (b == "A"){cout << "T";}
    if (b == "T"){cout << "A";}
    if (b == "G"){cout << "C";}
    if (b == "C"){cout << "G";}
}

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

int main(){
  double a, b, h;
  cin >> a >> b >> h;

  cout << (a+b)*h/2 << endl;


  return 0;
}


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

using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> a(n+1);
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int cnt=1;
	int len=0;
	for(int i=1;i<=n;i++){
		if(a[i]==cnt){
			++len;
			++cnt;
		}
	}
	if(len==0){
		cout<<-1<<endl;
	}else{
		cout<<n-len<<endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>


using namespace std;

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

const ll inf=1000000000LL*2000+1;

struct q_t
{
	int a, step;
	ll c;
	bool operator<(const q_t& r) const
	{
		return c<r.c;
	}
};


priority_queue<q_t> que;


void push(int a, ll c, int step)
{
	que.push((q_t){a, step, c});
}


int pop(int& a, ll& c, int& step)
{
	if(que.empty()) return 0;
	a=que.top().a;
	c=que.top().c;
	step=que.top().step;
	que.pop();
	return 1;
}


ll solve(vector<vector<pii> >& v)
{
	int n=v.size()-1;
	vector<pair<ll,int> > dp;
	int a=1, step=0;
	ll c=0;

	dp.clear();
	dp.resize(v.size(), make_pair(-inf, 0));
	push(a, c, step);
	while(pop(a, c, step))
	{
		if(c<=dp[a].first) continue;
		dp[a].first=c;
		dp[a].second=step;

		for(auto e: v[a])
		{
			int na=e.first;
			ll nc=c+e.second;

			if(dp[na].first<nc && dp[na].second<=2000)
			{
				push(na, nc, step+1);
			}
		}
	}
	if(dp[n].second>2000) return inf;
	return dp[n].first;
}


int main(void)
{
	int n, m;
	vector<vector<pii> > v;
	ll result;

	while(scanf("%d%d", &n, &m)==2)
	{
		v.clear();
		v.resize(n+1);
		for(int i=0;i<m;i++)
		{
			int a, b, c;
			scanf("%d%d%d", &a, &b, &c);
			v[a].push_back(make_pair(b, c));
		}
		result=solve(v);
		if(result==inf) printf("inf\n");
		else printf("%lld\n", result);
	}

	return 0;
}



Measured memory_bytes: 640
// A - 500 Yen Coins

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

int main()
{
    int K, X;
    cin >> K >> X;

    string ans;

    if (500 * K >= X) {
    	ans = "Yes";
    } else {
    	ans = "No";
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    int n,d,a;
    cin >> n >> d >> a;
    vector<pair<int,int>> m(n);
    for(int i = 0; i < n; i++){
        int x,h;
        cin >> x >> h;
        m[i] = {x,h};
    }    
    sort(m.begin(),m.end());
    ll total = 0;
    ll ans = 0;
    d = 2*d;
    queue<pair<int,int>> q;
    for(int i = 0; i < n; i++){
        int h = m[i].second;
        int x = m[i].first;
        while(q.size() && q.front().first < x){
            total -= q.front().second;
            q.pop();
        }
        h -= total;
        if(h > 0){
            int num = (h+a-1)/a;
            ans += num;
            total += num*a;
            q.push({x+d,num*a});
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2688
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int A,B;
  cin >> A >> B;
  int ans=0;
  for(int i=A;i<=B;i++){
    string s=to_string(i);
    string s_rev=s;
    reverse(s_rev.begin(),s_rev.end());
    if(s==s_rev) ++ans;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
// HEX

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
	char A, B;
	cin >> A >> B;

	if (A < B)
		cout << "<" << endl;
	else if (A == B)
		cout << "=" << endl;
	else
		cout << ">" << endl;

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <chrono>
#include <random>
#include <cstdio>
#define ll long long int
#define endl '\n'
#define pb push_back
#define mp make_pair
// #define mod 998244353
#define rep(i,n) for(ll i=0;i<n;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define pll pair<ll, ll>
#define pint pair<int, int>
#define S second
#define F first
#define all(c) (c).begin(),(c).end()
using namespace std;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
const int N=1000001;
// vector<pair<ll, ll> > adj[N];
// bool vis[N];
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
#define pi 3.14159265358979323846264338
using namespace std; 
ll max(ll a, ll b){ if(a>b)return a;return b;}
ll min(ll a, ll b){ if(a < b) return a;return b;}
ll inf = 100000000000000000;
vector <int> adj[N];


void solve() 
{
    string s;
    cin>>s;

    int n = s.size();

    ll run = 0;

    rep(i, n)
    {
        run += (s[i] - '0');
        run %= 9;
    }

    if(run == 0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

}

int main()
{
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)

    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
    }

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 27388
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n,a[N],b[N],c[N],d[N],fa[N],st[N],tp=0;
int getf(int x) {
    return x==fa[x]?x:fa[x]=getf(fa[x]);
}
int main() {
    n=gi();
    int sum=0;
    for(int i=1;i<=n;i++) a[i]=gi(),sum^=a[i];
    a[n+1]=sum;sum=0;
    for(int i=1;i<=n;i++) b[i]=gi(),sum^=b[i];
    b[n+1]=sum;
    ++n;
    for(int i=1;i<=n;i++) c[i]=a[i],d[i]=b[i];
    sort(c+1,c+n+1),sort(d+1,d+n+1);
    for(int i=1;i<=n;i++) if(c[i]!=d[i]) return puts("-1"),0;
    int ans=0;
    for(int i=1;i<=n;i++)
        if(a[i]!=b[i]||i==n) {
            st[++tp]=a[i],st[++tp]=b[i];
            if(i<n) ++ans;
        }
    sort(st+1,st+tp+1);
    tp=unique(st+1,st+tp+1)-st-1;
    for(int i=1;i<=tp;i++) fa[i]=i;
    for(int i=1;i<n;i++) {
        a[i]=lower_bound(st+1,st+tp+1,a[i])-st;
        b[i]=lower_bound(st+1,st+tp+1,b[i])-st;
        fa[getf(a[i])]=getf(b[i]);
    }
    for(int i=1;i<=tp;i++) if(getf(i)==i) ++ans;
    printf("%d\n",ans-1);
    return 0;
}


Measured memory_bytes: 5632
#　三井住友A
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
m1,d1 = nm()
m2,d2 = nm()
if m1==m2:
    print(0)
else:
    print(1)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;


struct edge{ int u, v, cost; };

bool comp(const edge& e1, const edge& e2){

  return e1.cost < e2.cost;

}

#define MAX_N 100000
#define MAX_E 100000

int par[MAX_N];

int rank[MAX_N];

void init(int n){

  for(int i = 0 ; i < n ; i++){

    par[i] = i;

    rank[i] = 0;

  }

}

int find(int x){

  if(par[x] == x) return x;

  else return par[x] = find(par[x]);

}

void unite(int x, int y){

  x = find(x);

  y = find(y);

  if(x == y) return;

  if(rank[x] == rank[y]) par[x] = y;

  else par[y] = x;

  if(rank[x] == rank[y]) rank[x]++;
 
}

bool same(int x, int y){

  return find(x) == find(y);

}

edge es[MAX_E];

int V, E;

int kruskal(){

  sort(es, es+E, comp);

  init(V);

  int res = 0;

  for(int i = 0 ; i < E ; i++){

    edge e = es[i];

    if(!same(e.u, e.v)){

      unite(e.u, e.v);

      res += e.cost;

    }

  }

  return res;

}

int main(){
  int n;
  cin>>n;
  V=n;
  int i,j,k;
  E=0;
  rep(i,n)rep(j,n){
    int t;
    cin>>t;
    if(t<0)continue;
    es[E].u=i;
    es[E].v=j;
    es[E].cost=t;
    E++;
  }
  cout<<kruskal()<<endl;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

const int MAX_N = 1e5 + 10;
ll dp[MAX_N][3][3];

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;

    for(int i = 0; i < n; i ++) {
        ll x[3];
        for(int j = 0; j < 3; j ++) {
            cin >> x[j];
        }
        for(int j = 0; j < 3; j ++) {
            for(int k = 0; k < 2; k ++) {
                for(int q = 0; q < 3; q ++) {
                    if(q == j && k < 1) {
                        chkmax(dp[i + 1][q][k + 1], dp[i][j][k] + x[q]);
                    } else if(q != j) {
                        chkmax(dp[i + 1][q][1], dp[i][j][k] + x[q]);
                    }
                }
            }
        }
        continue;
        for(int j = 0; j < 3; j ++) {
            for(int k = 0; k < 2; k ++) {
                cout << dp[i + 1][j][k] << " ";
            }
            cout << endl;
        }
        cout << endl;
    }
    ll ans = 0;
    for(int i = 0; i < 3; i ++) {
        for(int j = 0; j < 2; j ++) {
            chkmax(ans, dp[n][i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}




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

void mondai1();

int main()
{
	mondai1();
    return 0;
}

void mondai1() {
	int year,A,B;
	cin >> year;
	if (year == 1) {
		cout << "Hello World";
	}
	else if (year == 2) {
		cin >> A >> B;
		cout << A + B;
	}
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int ans = 700;
  char s;
  
  for(int i = 0;i < 3; i++)
  {
    cin >> s;
    
    if(s == 'o')
    {
      ans += 100;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;
int main()
{
    int a;
    cin>>a;
    if(a<2)
        cout<<"1"<<endl;
    else if(a>=2&&a<=3)
        cout<<"2"<<endl;
      else if(a>=4&&a<=7)
        cout<<"4"<<endl;
          else if(a>=8&&a<=15)
        cout<<"8"<<endl;
          else if(a>=16&&a<=31)
        cout<<"16"<<endl;
          else if(a>=32&&a<=63)
        cout<<"32"<<endl;
          else if(a>=64&&a<=100)
        cout<<"64"<<endl;




    return 0;
    }


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

int main()
{
    int h,n,x;
    cin>>h>>n;
    long long sum;
    
    while(n--){
        cin>>x;
        sum+=x;
    }
    
    cout<<(sum>=h?"Yes":"No")<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        String s=sc.next();
        int ans=1;
        for(int i=0;i<n-1;i++){
            if(s.charAt(i)!=s.charAt(i+1))ans++;
            
        }
        System.out.println(ans);
    }
    
    
}


Measured memory_bytes: 24756
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        B: chars,
    }
    let ans = match B[0]{
        'A' => 'T',
        'T' => 'A',
        'G' => 'C',
        'C' => 'G',
        _   => unreachable!(),
    };
    println!("{}",ans);
}

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

int main() {
  string A,B,C;
  cin>>A>>B>>C;
  int Na=A.size();
  int Nb=B.size();
  int Nc=C.size();
  //Aの先頭A.at(0) Aの最後A.at(Na-1)
  if(A.at(Na-1)==B.at(0) && B.at(Nb-1)==C.at(0)){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream> // C++の入出力
#include <stdio.h> // C の入出力
#include <algorithm> // sort などのアルゴリズム
#include <string.h> // C の文字列用
#include <ctype.h> // C の文字種用
#include <string> // C++の文字列
using namespace std;
int main(void){
    int in;
    while(1){
        int cnt=0;
        cin >> in;
        if(in==0)break;
        in = 1000-in;
        if(in>=500){
            cnt++;
            in-=500;
        }
        if(in>=100){
            cnt+=in/100;
            in=in%100;
        }
        if(in>=50){
            cnt++;
            in-=50;
        }
        if(in>=10){
            cnt+=in/10;
            in=in%10;
        }
        if(in>=5){
            cnt++;
            in-=5;
        }
        cnt+=in;
        cout << cnt <<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long T = 1;
		long A = 1;
		for (int i = 0; i < n; i++) {
			long t = sc.nextLong();
			long a = sc.nextLong();
			long x = Math.max((T+t-1)/t, (A+a-1)/a);
			T = t*x;
			A = a*x;
		}
		System.out.println(T+A);
		sc.close();
	}
}

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

struct num {
  int num_;
  int count_;
};

bool cmp (const num &a, const num &b) {
  if (a.count_ > b.count_) {
    return true;
  }
  if (a.count_ < b.count_) {
    return false;
  }
  if (a.num_ > b.num_) {
    return true;
  }
  if (a.num_ < b.num_) {
    return false;
  }
  return false;
}

int main() {

  int N;
  cin >> N;
  
  vector<int> v(N);
  map<int, int> odd;
  map<int, int> even;
  
  for (int i = 0; i < N; i++) {
    cin >> v[i];
    if (i % 2 == 0) {
      even[v[i]]++; 
    } else {
      odd[v[i]]++;
    }
  }

  vector<num> oddNums;
  
  for (auto item:odd) {
    num v_ = num();
    v_.num_ = item.first;
    v_.count_ = item.second;
    oddNums.push_back(v_);
  }

  vector<num> evenNums;

  for (auto item:even) {
    num v_ = num();
    v_.num_ = item.first;
    v_.count_ = item.second;
    evenNums.push_back(v_);
  }

  sort(oddNums.begin(), oddNums.end(), cmp);
  sort(evenNums.begin(), evenNums.end(), cmp);

  int firstOdd = oddNums[0].num_; 
  int firstEven = evenNums[0].num_;

  // 最も多い数が偶奇で異なる場合はそれに合わす
  if (firstOdd != firstEven) {
    int answer = N / 2 - oddNums[0].count_;
    answer += N / 2 - evenNums[0].count_;
    cout << answer << endl;
    return 0;
  }

  // 最も多い数が同じで要素数がお互い1つの場合
  if (oddNums.size() == 1 && evenNums.size() == 1) {
    cout << evenNums[0].count_ << endl;
    return 0;
  }
  if (oddNums.size() == 1) {
    cout << N / 2 - evenNums[1].count_ << endl;
    return 0;
  }
  if (evenNums.size() == 1) {
    cout << N / 2 - oddNums[1].count_ << endl;
    return 0;
  }

  int secondOdd = oddNums[1].num_;
  int secondEven = evenNums[1].num_;

  int answerOdd = 0;
  int answerEven = 0;

  // パターン1  
  // 偶数番目は最も多い数値に変える
  // 奇数番目は2番目に多い数値に変える
  answerOdd = N / 2 - oddNums[0].count_;
  answerOdd += N / 2 - evenNums[1].count_;

  // パターン2
  // 偶数番目は2番目に多い数値に変える
  // 奇数番目は最も多い数値に変える
  answerEven = N / 2 - oddNums[1].count_;
  answerEven += N / 2 - evenNums[0].count_;

  // パターン1と2で小さい方が答え
  cout << min(answerOdd, answerEven) << endl;

  return 0;

}

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

#define rep(i,f,n) for (int (i) =(f);(i)<(n);(i)++)
typedef  long long ll;

using namespace std;

int main(){
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    rep(i,0,n){
        cin>>a[i]>>b[i]>>c[i];
    }

  //  int dp[n][3];

    vector<vector<int> > dp(n+1,vector<int>(3,0));

    rep(i,0,n){
 
        dp[i+1][0]=max(dp[i+1][0],dp[i][1]+a[i]);
        dp[i+1][0]=max(dp[i+1][0],dp[i][2]+a[i]);
        dp[i+1][1]=max(dp[i+1][1],dp[i][2]+b[i]);
        dp[i+1][1]=max(dp[i+1][1],dp[i][0]+b[i]);
        dp[i+1][2]=max(dp[i+1][2],dp[i][0]+c[i]);
        dp[i+1][2]=max(dp[i+1][2],dp[i][1]+c[i]);
                 //      printf("%d  %d  %d  %d\n",i,dp[i+1][0],dp[i+1][1],dp[i+1][2]);

    }
    int ans=max({dp[n][0],dp[n][1],dp[n][2]});
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,true):false;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,true):false;}

int nextInt() {
  int x; scanf("%d", &x); return x;
}

const ll MOD = 1000000007;


int f(string s, char ch) {
  int res = 0;
  for (; count(s.begin(), s.end(), ch) != s.size(); res++) {
    string t;
    for (int i = 0; i + 1 < (int)s.size(); i++) {
      t += (s[i] == ch || s[i+1] == ch) ? ch : s[i];
    }
    s = t;
  }
  return res;
}

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

  int ans = s.size();
  for (int c = 0; c < 26; c++) {
    chmin(ans, f(s, c+'a'));
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int n,a,b;
    scanf("%d %d %d",&n,&a,&b);
    if(n*a<b){
        printf("%d\n",n*a);
    }else{
        printf("%d\n",b);
    }
    return(0);
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<queue>


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

	std::cout<< 3* n* n<<std::endl;

	return 0;
	
}

Measured memory_bytes: 256