akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int x = in.nextInt();
            out.println(x >= 30 ? "Yes" : "No");
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

    }

}

Measured memory_bytes: 33888
// 156  c

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

void printVec(std::vector<int> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}

int main() {
  int n;

  cin >> n;

  vector <int> x(n);
  int max_d;
  int min_d;
  for(int i = 0; i < n; ++i) {
    cin >> x[i];
    if (i == 0) {
      max_d = x[i];
      min_d = x[i];
    } else {
      max_d = max(max_d, x[i]);
      min_d = min(min_d, x[i]);
    }
  }
  int power_d = INT_MAX;
  for(int i = min_d; i <= max_d; ++i) {
    int power_temp = 0;
    for (int j = 0; j < n; ++j) {
      power_temp = power_temp + (x[j] - i) * (x[j] - i);
    }
    power_d = min(power_d, power_temp);
  }
  cout << power_d << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
const int max_ = 200005;
ll n,  res=0 ,a[max_], b[max_];
int main(){
     cin>>n;
    for(ll  i=1; i<=n;  i++){
        cin>>a[i];
        if(i-a[i]>=1)
            res+=b[i-a[i]];
         if(i+a[i]<=n)
            b[i+a[i]]++;
    }
    printf("%lld\n",res);
}


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

b = [0] #a[i]までのsum
c = [0] #a[i]までの+のみのsum

for i in range(n):
    b.append(b[-1]+a[i])
    if a[i] > 0:
        c.append(c[-1]+a[i])
    else:
        c.append(c[-1])


res = 0
for i in range(n-k+1):
    if b[i+k]-b[i] > 0:
        w = b[i+k]-b[i] + (c[i]-c[0]) + (c[n]-c[i+k])
    else:
        w = c[i]-c[0]+c[n]-c[i+k]
    res = max(res,w)
print(res)

Measured memory_bytes: 17472
#include<bits/stdc++.h>
#define MAX 100001
#define inf 1e9
using namespace std;

int n,pw;
double vw[MAX],pf[MAX],vf[MAX],th[MAX];

double f(double W){
  double cost=W*pw;

  for(int i=0;i<n;i++){
    if(W*vw[i]>th[i])continue;
    double sum1=th[i]-W*vw[i];
    double sum2=sum1/(double)vf[i];
    cost+=sum2*pf[i];
  }
  return cost;
}

int main()
{
  while(1){
    cin>>n>>pw;
    if(n==0)break;
    for(int i=0;i<n;i++)cin>>vw[i]>>pf[i]>>vf[i]>>th[i];

    double l=0,r=inf;
    for(int i=0;i<150;i++){
      double m1=(l*2.0+r)/3.0;
      double m2=(l+r*2.0)/3.0;
      double res1=f(m1);
      double res2=f(m2);
      if(res1<res2)r=m2;
      else l=m1;
    }
    printf("%.4f\n",f(l));
  }
  return 0;
}

Measured memory_bytes: 4372
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e9;
const ll M = 1e9 + 7;
double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}


vector<ll> fac(3000010); //n!(mod M)
vector<ll> ifac(3000010); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main(){

    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<3000000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    ll x, y;
    cin >> x >> y;
    if((x+y)%3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    ll k = (x+y)/3;
    x -= k;
    y -= k;
    if(x < 0 || y < 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << comb(x+y, x) << endl;
    return 0;
}

Measured memory_bytes: 47232
#include<stdio.h>
#define LENn 10000
#define LENq 10000

int main(){
  int n,s[LENn],q,t[LENq];
  scanf("%d",&n);
  for(int i = 0; i < n; i++){
    scanf("%d",&s[i]);
  }
  scanf("%d",&q);
  for(int i = 0; i < q; i++){
    scanf("%d",&t[i]);
  }
  int cnt=0;
  for(int i = 0; i < q; i++){
    for(int j = 0; j < n; j++){
      if(s[j]==t[i]) {
        cnt++;
        break;
      }
    }
  }

  printf("%d\n",cnt);

}



Measured memory_bytes: 2132
import java.io.*;
import java.util.*;
import java.lang.reflect.Array;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.Stack;


class Main {
	public static void main(String[] a) throws IOException {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			double weight = scan.nextDouble();
			if(weight <= 48.0){
				System.out.println("light fly");
			}else if(weight > 48.0 && weight <= 51.0){
				System.out.println("fly");
			}else if(weight > 51.0 && weight <= 54.0){
				System.out.println("bantam");
			}else if(weight > 54.0 && weight <= 57.0){
				System.out.println("feather");
			}else if(weight > 57.0 && weight <= 60.0){
				System.out.println("light");
			}else if(weight > 60.0 && weight <= 64.0){
				System.out.println("light welter");
			}else if(weight > 64.0 && weight <= 69.0){
				System.out.println("welter");
			}else if(weight > 69.0 && weight <= 75.0){
				System.out.println("light middle");
			}else if(weight > 75.0 && weight <= 81.0){
				System.out.println("middle");
			}else if(weight > 81.0 && weight <= 91.0){
				System.out.println("light heavy");
			}else if(weight > 91.0){
				System.out.println("heavy");
			}
			
		}
		
 }
}

Measured memory_bytes: 28264
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N, K;
	cin >> N >> K;
	int x[100010];
	for (int i = 0; i < N; ++i) {
		cin >> x[i];
	}
	int a[100010];
	int ans = INF;
	for (int i = 0; i < N - K + 1; ++i) {
		a[i] = min(abs(x[i]) + abs(x[i + K - 1] - x[i]), abs(x[i + K - 1]) + abs(x[i] - x[i + K - 1]));
		ans = min(a[i], ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long m = sc.nextLong();
    HashMap<Long, Long> map = new HashMap<Long, Long>();
    long[] a = new long[(int)n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
      long b = sc.nextLong();
      if(map.containsKey(a[i])) {
        map.put(a[i], map.get(a[i]) + b);
      } else {
        map.put(a[i], b);
      }
    }
    Arrays.sort(a);
    long ans = 0;
    for(int i = 0; i < n; i++) {
      long kosuu = map.get(a[i]);
      if(m > kosuu) {
        ans += (a[i] * kosuu);
        m -= kosuu;
        map.put(a[i], (long)0);
      } else {
        ans += (a[i] * m);
        break;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 100600
#include <cstdio>
int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	printf("%d %d %d\n%d %d %d\n%d %d %d\n",a,b,c*3-a-b,c*3-(c-(c*3-a-b-c))-a,c,c*3-(c*3-a-b)-(c-(a-c)),c-(c*3-a-b-c),c*2-b,c-(a-c));
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
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>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int n;
vi a;

void solve(int m) {
  vector<vi> dp(n + 1, vi(m + 1, 0));
  dp[0][0] = 1;
  rep(i, n) rep(j, m + 1) {
    dp[i + 1][j] += dp[i][j];
    int nj = j + a[i];
    if(nj <= m) dp[i + 1][nj] += dp[i][j];
  }
  cout << (dp[n][m] > 0 ? "yes" : "no") << endl;
}

int main() {
  int q;
  cin >> n;
  a = vi(n);
  rep(i, n) cin >> a[i];
  cin >> q;
  vi m(q);
  rep(i, q) cin >> m[i];
  rep(i, q) solve(m[i]);
}


Measured memory_bytes: 3288
#Biginner Contest 157 B-Bingo
#二次元配列を使う(3*3)
bingonum=[[0,0,0],[0,0,0],[0,0,0]]
bingo=[["False","False","False"],["False","False","False"],["False","False","False"]]
for i in range(3):
    bingonum[i][0],bingonum[i][1],bingonum[i][2] = map(int,input().split())

N = int(input())
b=[]
for _ in range(N):
    b.append(int(input()))

for x in range(N):
    for i in range(3):
        for j in range(3):
            if bingonum[i][j]==b[x]:
                bingo[i][j]="True"

IsBingo = "No"
for i in range(3):
    if bingo[i][0] =="True" and bingo[i][1] =="True" and bingo[i][2] =="True":
        IsBingo="Yes"
    if bingo[0][i] =="True" and bingo[1][i] =="True" and bingo[2][i] =="True":
        IsBingo="Yes"
if (bingo[0][0] =="True" and bingo[1][1] =="True" and bingo[2][2] =="True") or (bingo[0][2] =="True" and bingo[1][1] =="True" and bingo[2][0]=="True"):
    IsBingo="Yes"
print(IsBingo)



Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main() {
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    for (int hi = 0; hi < h; hi++) {
        for (int wi = 0; wi < w; wi++) {
        int cur = (hi < b) ^ (wi < a);
        cout << cur;
        }
        cout << '\n';
    }
    
}

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

int main()
{
	int n, t, a;
	cin >> n >> t >> a;
	t *= 1000;
	a *= 1000;
	int ans = 0, near = 1000000000;
	for(auto i = 0; i < n; ++i){
		int h;
		cin >> h;
		int b = t - h * 6;
		if(abs(b - a) < abs(near - a)){
			near = b;
			ans = i + 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
   
public class Main{
  public static void main(String... args){
    Scanner scanner = new Scanner(System.in);
    StringBuilder sb = new StringBuilder('\n' + scanner.next() + '\n');

    if(sb.charAt(sb.length() - 2) == '?'){
      sb.setCharAt(sb.length() - 2, 'D');
    }

    for(int i = sb.length() - 1; i > 0; i--){
      if(sb.charAt(i) == '?'){
        if(sb.charAt(i - 1) == 'P'){
          sb.setCharAt(i, 'D');
        }else if(sb.charAt(i + 1) == 'D'){
          sb.setCharAt(i, 'P');
        }else if(sb.charAt(i + 1) == 'P'){
          sb.setCharAt(i, 'D');
        }
      }
    }
     
    System.out.println(sb.substring(1, sb.length() - 1));
  }
}

Measured memory_bytes: 43412
N = input().split()
A = int(N[0])
B = int(N[1])
if A+B >= A-B and A+B >= A*B:
    print(A+B)
elif A-B >= A+B and A-B >= A*B:
    print(A-B)
elif A*B >= A+B and A*B >= A-B:
    print(A*B)

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, clock()*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;


int solve(string A, string B, int len) {
  B = B + B;
  int ans = 1e9;
  vector<int> l(len), r(len);

  int last = 2 * len;
  for (int i = 2 * len - 1; i >= 0; i--) {
    if (B[i] == '1') {
      last = i;
    }
    if (i < len) {
      assert(last != 2 * len);
      r[i] = last - i;
    }
  }
  last = -1;
  for (int i = 0; i < 2 * len; i++) {
    if (B[i] == '1') {
      last = i;
    }
    if (i >= len) {
      assert(last != -1);
      l[i - len] = i - last;
    }
  }

  for (int shift = 0; shift <= len; shift++) {
    vector<bool> need(len);
    int cnt = 0;
    for (int i = 0; i < len; i++) {
      need[i] = (A[i] != B[i + shift]);
      cnt += need[i];
    }

    vector<pair<int, int>> v;
    for (int i = 0; i < len; i++) {
      if (need[i]) {
        v.push_back({l[i], r[i]});
      }
    }
    sort(v.rbegin(), v.rend());
    int rv = shift;

    for (int i = 0; i < (int)v.size(); i++) {
      ans = min(ans, 2 * (v[i].first + rv) - shift + cnt);
      rv = max(rv, v[i].second);
    }
    ans = min(ans, 2 * rv - shift + cnt);
  }
  return ans;
}

int main() {
#ifdef LOCAL
  freopen("d.in", "r", stdin);
  freopen("d.out", "w", stdout);
#endif

  static char A[2010], B[2010];
  while (scanf("%s%s", A, B) == 2) {
    int n = strlen(A);
    if (find(B, B + n, '1') == B + n) {
      if (find(A, A + n, '1') != A + n) {
        printf("-1\n");
        continue;
      } else {
        printf("0\n");
        continue;
      }
    }
    int ans1 = solve(A, B, n);
    reverse(A, A + n);
    reverse(B, B + n);
    int ans2 = solve(A, B, n);
    printf("%d\n", min(ans1, ans2));
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * @author yoshizaki
 * abc157
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        String[] up = scanner.nextLine().split(" ");
        String[] middle = scanner.nextLine().split(" ");
        String[] down = scanner.nextLine().split(" ");
        
        String[][] bingo = {up, middle, down};
        
        String answer = "No";
        
        int[][] hit = new int[3][3];
        for (int i = 0; i<3 ; i++) {
            for (int j = 0; j<3 ; j++) {
                hit[i][j] = 0;
            }
        }
        int nCount = Integer.parseInt(scanner.nextLine());
        
        String[] numbers = new String[nCount];
        
        for(int i=0 ; i < nCount; i++) {
            numbers[i] = scanner.nextLine();
        }
        check : for (String number: numbers) {
            for (int i = 0; i<3 ; i++) {
                for (int j = 0; j<3 ; j++) {
                    if (number.equals( bingo[i][j] )) {
                        hit[i][j] = 1;
                        continue check;
                    }
                }
            }
        }
        
        if(hit[0][0] + hit[0][1] +hit[0][2] == 3) answer = "Yes";
        if(hit[1][0] + hit[1][1] +hit[1][2] == 3) answer = "Yes";
        if(hit[2][0] + hit[2][1] +hit[2][2] == 3) answer = "Yes";
        if(hit[0][0] + hit[1][0] +hit[2][0] == 3) answer = "Yes";
        if(hit[0][1] + hit[1][1] +hit[2][1] == 3) answer = "Yes";
        if(hit[0][2] + hit[1][2] +hit[2][2] == 3) answer = "Yes";
        if(hit[0][0] + hit[1][1] +hit[2][2] == 3) answer = "Yes";
        if(hit[2][0] + hit[1][1] +hit[0][2] == 3) answer = "Yes";
        
        System.out.println(answer);
    }
}

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

using namespace std;
#define X first
#define Y second
#define pb push_back
typedef double db;
typedef long long ll;
typedef pair<int,int> P;
const int MAXN=1e5+10;
int n,a,b,pos[MAXN];ll res;

int main()
{
	scanf("%d%d%d",&n,&a,&b);
	for(int i=1;i<=n;i++) scanf("%d",&pos[i]);
	for(int i=2;i<=n;i++)
		res+=min(1ll*(pos[i]-pos[i-1])*a,1ll*b);
	printf("%lld",res);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
  ll h, w; cin >> h >> w;
  ll n, m; cin >> n >> m;
  ll res = h*w;
  res -= n*w + m*h;
  res += n*m;
  cout << res << endl;
}

Measured memory_bytes: 3600
def solve(N, Hs):
    # print(f"assert (solve ({N},{Hs}) == )")
    ans = [0, abs(Hs[0] - Hs[1])]
    for i in range(2, N):
        ans.append(
            min(ans[i - 2] + abs(Hs[i - 2] - Hs[i]),
                ans[i - 1] + abs(Hs[i - 1] - Hs[i]))
        )
    return ans[N - 1]


assert (solve(4, [10, 30, 40, 20]) == 30)
assert (solve(2, [10, 10]) == 0)
assert (solve(6, [30, 10, 60, 10, 60, 50]) == 40)

if __name__ == "__main__":
    N = int(input())
    Hs = list(map(int, input().split(" ")))
    print(solve(N, Hs))


Measured memory_bytes: 13928
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;


/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// 4-direction
int dy4[] = {0,  1, -1,  0};
int dx4[] = {1,  0,  0, -1};

// 8-direction
int dy8[] = {0,  1,  1,  1,  0, -1, -1, -1};
int dx8[] = {1,  1,  0, -1, -1, -1,  0,  1};

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

int main() {
  int n, x;
  cin >> n >> x;
  int now = 0;
  int cnt = 1;
  rep(i, n) {
    int l;
    cin >> l;
    now += l;
    if(now <= x) {
      cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
int main()
{
	int a;
	cin >> a;
	cout << a + a*a + a*a*a << endl;
	return 0;
}

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

using namespace std;

using Weight=int;
struct Edge{
    int src,dst;
    Weight weight;
    Edge(int src,int dst,Weight weight):
    src(src),dst(dst),weight(weight){}
};

auto operator < (const Edge &e,const Edge &f){
    if(e.weight!=f.weight)return e.weight>f.weight;
    else if(e.src!=f.src)return e.src<f.src;
    else return e.dst<f.dst;
}

using Edges=vector<Edge>;
using Graph=vector<Edges>;

template<typename T>
struct UnionFind{
    vector<T>data;
    UnionFind(T n):data(n,-1){}
    bool unite(T x,T y){
        x=root(x);y=root(y);
        if(x!=y){
            if(data[y]<data[x])swap(x,y);
            data[x]+=data[y];data[y]=x;
        }
        return x!=y;
    }
    T root(T x){
        return data[x]<0?x:data[x]=root(data[x]);
    }
    bool same(T x,T y){
        return root(x)==root(y);
    }
    T size(T x){
        return -data[root(x)];
    }
};

pair<Weight,Edges>kruskal(const Graph &g){
    int n=g.size();
    UnionFind<int> uf(n);
    priority_queue<Edge>q;
    for(int i=0;i<n;++i){
        for(auto e:g[i]){
            if(i<e.dst)q.push(e);
        }
    }
    Weight total=0;
    Edges forest;
    while(forest.size()<n-1 && !q.empty()){
        Edge e=q.top();q.pop();
        if(uf.unite(e.src,e.dst)){
            forest.push_back(e);
            total+=e.weight;
        }
    }
    return pair<Weight, Edges>(total,forest);
}

int main(){
    int v,e;cin>>v>>e;
    Graph g(v);
    for(int i=0;i<e;++i){
        int s,t,w;cin>>s>>t>>w;
        g[s].emplace_back(s,t,w);
        g[t].emplace_back(t,s,w);
    }
    cout<<kruskal(g).first<<endl;
    return 0;
}

Measured memory_bytes: 8756
// Problem: B - Judge Status Summary
// Contest: AtCoder - AtCoder Beginner Contest 173
// URL: https://atcoder.jp/contests/abc173/tasks/abc173_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)



    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define FAST ios_base::sync_with_stdio(false);cin.tie(0);
    const double EPS = 1e-9;
    const double PI = acos(-1);
    const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
    //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
    //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
    const int dx[] = {0 , 1 , 0 , -1};
    const int dy[] = {1 , 0 , -1 , 0};
    //#define MOD         1000000007LL
    #define MAX         1000005
    const ll MOD = 1000000000 + 7;
    
    int main()
    {
        FAST
        int t;
        t = 1;

        while(t--)
        {
           int n;
           cin >> n;
           map<string , int> mp;
           for(int i = 0 ; i < n ; i++)
           {
               string s;
               cin >> s;
               mp[s]++; 
           }
           
           cout << "AC x " << mp["AC"] << endl;
           cout << "WA x " << mp["WA"] << endl;
           cout << "TLE x " << mp["TLE"] << endl;
           cout << "RE x " << mp["RE"] << endl;
        }
    }



Measured memory_bytes: 3620
import static java.lang.Integer.parseInt;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/**
 * Longest Steps
 */
public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while (!(line = br.readLine()).equals("0 0")) {

			int n = parseInt(line.substring(0, line.indexOf(' ')));
			int k = parseInt(line.substring(line.indexOf(' ') + 1));

			boolean[] cards = new boolean[n + 1];
			for (int i = 0; i < k; i++) {
				cards[parseInt(br.readLine())] = true;
			}

			int sum = 0;
			List<Integer> list = new ArrayList<Integer>();
			list.add(0);
			for (int i = 1; i < n + 1; i++) {
				if (cards[i]) {
					sum += 1;
				} else {
					if (sum > 0) {
						list.add(sum);
					}
					list.add(0);
					sum = 0;
				}
			}
			if (sum > 0) {
				list.add(sum);
			}
			list.add(0);

			int max = 0;
			if (cards[0]) {
				for (int i = 1; i < list.size() - 1; i++) {
					if (list.get(i) == 0) {
						if (list.get(i - 1) + 1 + list.get(i + 1) > max) {
							max = list.get(i - 1) + 1 + list.get(i + 1);
						}
					}
				}
			} else {
				for (int i = 1; i < list.size() - 1; i++) {
					if (list.get(i) > max) {
						max = list.get(i);
					}
				}
			}
			System.out.println(max);
		}

	}
}

Measured memory_bytes: 29776
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char s[1010];
int main(int argc, char *argv[]) {
    scanf("%s", (s + 1)); int len = strlen((s + 1));
    for(int i = 1; i <= len; ++i) if(s[i] == '7') {puts("Yes"); return 0;}
    puts("No"); return 0;
}

Measured memory_bytes: 3152
#include "bits/stdc++.h"

#define ll long long
#define f first
#define s second
#define pb push_back

using namespace std;

const ll MOD = 998244353;
ll n;
vector<ll> v;
map<ll, ll> m;
int main(){
    cin >> n;
    ll i; cin >> i;
    if(i != 0){
        cout << 0;
        return 0;
    }
    for(int i = 0; i < n - 1; ++i){
        ll x; cin >> x;
        v.pb(x);
    }
    sort(v.begin(), v.end());
    m[0] = 1;
    ll res = 1;
    for(int i = 0; i < n - 1; ++i){
        res *= m[v[i] - 1];
        m[v[i]]++;
        res %= MOD;
    }
    cout << res;
    return 0;
}

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

const double PI=3.1415926535;

int main(){

  int c,d,p;
  double a,b,x,y,z,ans;
  cin >> c >> d >> p;
  a = c, b = d, x = p;
  if(x>=a*a*b/2.) {
    // 台形
    ans = atan((2.*b - 2.*x/a/a)/a)*180./PI;
  }else{
    // 三角形
    ans = 90. - atan(2.*x/a/b/b)*180./PI;
  }
  cout << setprecision(11) << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int N,A,B;
  cin>>N>>A>>B;
  cout << min(A*N,B) << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		boolean second = false;
		while (true)
		{
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (a == 0 && b == 0) break;
			if (second)System.out.println();
			second = true;
			boolean flg = false;
			for (; a <= b; a++)
			{
				if ((a % 4 == 0 && a % 100 != 0) || a % 400 == 0)
				{
					System.out.println(a);
					flg = true;
				}
			}
			if (!flg)System.out.println("NA");
		}
	}
}

Measured memory_bytes: 12000
import java.util.*;

class Main {
    Scanner sc = new Scanner(System.in);
    int[][] dp = new int[201][201];

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

    private void run() {
        int k = sc.nextInt();
        long sum = 0;
        for (int i = 1; i <= k; i++) {
            for (int j = 1; j <= k; j++) {
                for (int l = 1; l <= k; l++) {
                    sum += gcd(gcd(i, j),l);
                }
            }
        }
        System.out.println(sum);
    }

    private int gcd(int m, int n) {
        if (dp[m][n] > 0) return dp[m][n];
        if (n == 0) {
            dp[m][n] = dp[n][m] = m;
            return m;
        }
        return gcd(n, m % n);
    }
}


Measured memory_bytes: 37364
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  long long n;
  cin >> n;
  long long ans = n + 5;
  for (int i = 1; 1ll * i * i <= n; i++) {
    if (n % i) continue;
    ans = min(ans, i + n / i - 2);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
  while True:
    try:
      n,k = map(int,input().split())
      if n == 0 and k == 0: break
      lst = [0 for _ in range(n)]
      lst2 = []
      flag = 0
      for _ in range(k):
        i = int(input())
        if not i:
          flag = 1
        else:
          lst[i - 1] = 1
      l = -1
      r = -1
      for i in range(n):
        if lst[i] == 0:
          if r != -1:
            lst2.append((l,r))
            l = -1
            r = -1
        else:
          if l == -1:
            l = i
            r = i
          else:
            r += 1
      else:
        if r != -1:
          lst2.append((l,r))
      ans = 0
  #    print(lst)
  #    print(lst2)
      if not flag:
        for t in lst2:
          ans = max(ans,t[1] - t[0] + 1)
      else:
        for i in range(len(lst2)):
          if i == 0:
            ans = max(ans,lst2[0][1] - lst2[0][0] + 1)
          elif lst2[i][0] - lst2[i - 1][1] == 2:
            ans = max(ans,lst2[i][1] - lst2[i - 1][0] + 1)
          else:
            ans = max(ans,lst2[i][1] - lst2[i][0] + 1)
      print(ans)
    except EOFError:
      break
if __name__ == '__main__':
  main()


Measured memory_bytes: 8440
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

bool same(string s) {
    bool res = true;
    for(int i=1; i < s.size(); ++i) {
        if (s[0] != s[i]) {
            res = false;
            break;
        }
    }
    return res;
}

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


    int res = 111;
    
    string t = s;
    for (auto c : s) {
        int count = 0;
        while (!same(t)) {
            for (int i = 0; i < t.size(); ++i) {
                if (t[i + 1] == c) t[i] = c;
            }
            t.pop_back();
            ++count;
        }
        if (count < res) res = count;
        t = s;
    }

    cout << res << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;

int main(){
    int k; cin >> k;
    int chu = k / 2;
    vector<int> d(k);
    rep(i, k) cin >> d[i];
    sort(d.begin(), d.end());
    if(d[chu-1] == d[chu]) {
        cout << 0 << endl;
        return 0;
    }

    cout << d[chu] - d[chu-1] << endl;

    return 0;
}

Measured memory_bytes: 3744
import sys
import numpy as np
readline = sys.stdin.buffer.readline

N,K = map(int,readline().split())
A = np.array(readline().split(),np.int64)
F = np.array(readline().split(),np.int64)

A.sort()
F.sort()
F=F[::-1]

def test(x):
    # 全員がx秒以下に収めるための必要コストがK以下である
    return np.maximum(0,A-x//F).sum() <= K

left = -1 # 不可能目標
right = 10**13 # 可能目標
while left+1 < right:
    mid = (left+right)//2
    if test(mid):
        right = mid
    else:
        left = mid

answer = right
print(answer)
# maspyのやつのほぼコピペ
# 二分探索 時間計算量はO(nlogx)


Measured memory_bytes: 26152
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>
#include <map>

using std::cin;
using std::cout;
using std::endl;
using std::terminate;
using std::string;
using std::map;
using std::make_pair;
using std::pair;

template<class T> inline T max(T X, T Y) {
    return X > Y ? X : Y;
}

void solve() {
    int N; cin >> N;
    map<string, int> m;
    int x = 1;
    for (int i = 0; i < N; ++i) {
        string S; cin >> S;
        decltype(m)::iterator it = m.find(S);
        if (it != m.end()) {
            m[S]++;
            x = max(x, m[S]);
        } else {
            m.insert(make_pair(S, 1));
        }
    }

    for (pair<string, int> p : m) {
        if (p.second == x) {
            cout << p.first << endl;
        }
    }

}

int main() {

#ifdef DEV
    std::ifstream in("input");
    cin.rdbuf(in.rdbuf());

    int t; cin >> t;
    for (int x = 1; x <= t; ++x) {
        solve();
    }
#else
    solve();
#endif

    return 0;
}


Measured memory_bytes: 19036
#include <map>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

const int mod=998244353;
string str;
map <string,int> f;
map <string,int> g;

int F(string s);
int G(string s) {
	if(g.find(s)!=g.end()) return g[s];
	if(s.size()==1) return g[s]=s[0]-'0'+1;
	for(int i=1;i<(int)s.size();++i) if(!(s.size()%i)) {
		string t;
		for(int j=0;j<i;++j) {
			bool flag=true;
			for(int k=0;k<(int)s.size()/i;++k) if(s[i*k+j]=='0') flag=false;
			t+=(char)(flag+'0');
		}
		g[s]=(g[s]+F(t))%mod;
	}
	return g[s];
}
int F(string s) {
	if(f.find(s)!=f.end()) return f[s];
	for(int i=1;i<=(int)s.size();++i)
		f[s]=(f[s]+1ll*F(s.substr(0,s.size()-i))*G(s.substr(s.size()-i,s.size()))%mod)%mod;
	return f[s];
}

int main() {
	cin>>str,f[""]=1,cout<<F(str)<<endl;
	return 0;
}


Measured memory_bytes: 12928
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

vector<vector<int>> g;

pair<int, int> dfs(int x, int p) {
    pair<int, int> res = {0, x};
    for (int i = 0; i < g[x].size(); i++) {
        int y = g[x][i];
        if (y != p) {
            auto q = dfs(y, x);
            if (q.first + 1 > res.first) {
                res = {q.first + 1, q.second};
            }
        }
    }
    return res;
}

int c;

bool dfs2(int x, int p, int z, int d) {
    bool res = x == z;
    for (int i = 0; i < g[x].size(); i++) {
        int y = g[x][i];
        if (y != p) {
            if (dfs2(y, x, z, d - 1)) {
                res = true;
            }
        }
    }
    if (res && d == 0) {
        c = x;
    }
    return res;
}

vector<int> ch;

void dfs3(int x, int p, int d) {
    int cc = 0;
    for (int i = 0; i < g[x].size(); i++) {
        int y = g[x][i];
        if (y != p) {
            cc++;
            dfs3(y, x, d + 1);
        }
    }
    ch[d] = std::max(ch[d], cc);
}

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

    int n;
    cin >> n;
    g.resize(n);
    for (int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    int x = dfs(0, -1).second;
    int y = dfs(x, -1).second;

    int d = dfs(x, -1).first;
    cout << (d + 2) / 2 << " ";
    if (d % 2 == 0) {
        dfs2(x, -1, y, d / 2);
        ch.assign(n, 0);
        dfs3(c, -1, 0);
        long res = 1;
        for (int i = 0; i < n; i++) {
            if (ch[i] == 0) break;
            res *= ch[i];
        }
        for (int c2 : g[c]) {
            ch.assign(n, 0);
            dfs3(c, c2, 0);
            dfs3(c2, c, 0);
            long res2 = 2;
            for (int i = 0; i < n; i++) {
                if (ch[i] == 0) break;
                res2 *= ch[i];
            }
            if (res2 < res) {
                res = res2;
            }
        }
        cout << res << "\n";
    } else {
        dfs2(x, -1, y, d / 2);
        int c1 = c;
        dfs2(x, -1, y, d / 2 + 1);
        int c2 = c;
        ch.assign(n, 0);
        dfs3(c1, c2, 0);
        dfs3(c2, c1, 0);
        long res = 2;
        for (int i = 0; i < n; i++) {
            if (ch[i] == 0) break;
            res *= ch[i];
        }
        cout << res << "\n";
    }

    return 0;
}

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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

#define si(a)           scanf("%d",&a)
#define sii(a,b)        scanf("%d %d",&a,&b)
#define siii(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define sl(a)           scanf("%lld",&a)
#define sll(a,b)        scanf("%lld %lld",&a,&b)
#define slll(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)

#define un(x)           x.erase(unique(all(x)), x.end())
#define xx              first
#define yy              second
#define pb              push_back
#define mp              make_pair
#define all(v)          v.begin(),v.end()
#define D(x)            cerr << #x " = " << x << '\n'
#define DBG             cerr << "Hi!" << '\n'

#define CLR(a)          memset(a,0,sizeof(a))
#define SET(a)          memset(a,-1,sizeof(a))

#define PI              acos(-1.0)

//inline int setBit(int n,int pos) { return n = n | (1 << pos); }
//inline int resetBit(int n,int pos) { return n = n & ~(1 << pos); }
//inline bool checkBit(int n,int pos) { return (bool)(n & (1 << pos)); }
//inline int countBit(ll n) { return __builtin_popcountll(n); }


//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction

/******************************************************************************************/

const int MAX = 100010;
const int INF = 0x3f3f3f3f;
//const double inf = 1.0/0.0;
//const int MOD = 1000000007;

vector <int> ed[MAX];
int dp[MAX];

int call(int nd) {
    if(dp[nd]!=-1) return dp[nd];
    int ret = 0;
    for(int i=0;i<ed[nd].size();i++) {
        ret = max(ret,1 + call(ed[nd][i]));
    }
    return dp[nd] = ret;
}


int main() {
//    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);


    int n,m,x,y;
    sii(n,m);


    for(int i=1;i<=m;i++) {
        sii(x,y);
        ed[x].pb(y);
    }

    SET(dp);
    int ans = 0;
    for(int i=1;i<=n;i++) ans = max(ans,call(i));

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 8192
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;


int main(){
    int n;
    scanf("%d",&n);
    list<int> lst;
    for(int i=0;i<n;i++){
        char s[11];
        int p;
        scanf("%s",&s);
        if(s[0]=='i'){
            scanf("%d",&p);
            lst.push_front(p);
        }else if(s[6]=='F'){
            lst.pop_front();
        }else if(s[6]=='L'){
            lst.pop_back();
        }else{
            scanf("%d",&p);
            for(auto itr=lst.begin(); itr!=lst.end();itr++){
                if(*itr==p){
                    lst.erase(itr);
                    break;
                }
            }
        }
    }
    int l=lst.size();
    for(int i=0;i<l-1;i++){
        printf("%d ",*lst.begin());
        lst.pop_front();
    }
    printf("%d\n",*lst.begin());
    return 0;
}

Measured memory_bytes: 32360
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(math.sqrt(n)) + 2):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(stdin.readline().rstrip())
a = factorization(n)

m = 0
for b in a:
    bb = b[1]
    i = 0
    while True:
        bb -= i+1
        if bb >= 0:
            i += 1
        else:
            break
    m = m + i

if n != 1: print(m)
if n == 1: print(0)

Measured memory_bytes: 9508
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e18

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, m;
	cin >> n >> m;
	if(n>=2){
		n-=2;
	}
	if(m>=2){
		m-=2;
	}
	cout<<n*m << endl;
	return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())

result = []
for h in range(1, H//2+1):
    Sa = W * h

    remain = H - h
    h2 = (remain + 1) // 2
    Sb1 = W * h2
    Sc1 = W * (remain - h2)
    result.append(max(Sa, Sb1, Sc1) - min(Sa, Sb1, Sc1))

    w = (W + 1) // 2
    Sb2 = w * remain
    Sc2 = (W - w) * remain
    result.append(max(Sa, Sb2, Sc2) - min(Sa, Sb2, Sc2))

for w in range(1, W//2+1):
    Sa = H * w

    remain = W - w
    w3 = (remain + 1) // 2
    Sb1 = H * w3
    Sc1 = H * (remain - w3)
    result.append(max(Sa, Sb1, Sc1) - min(Sa, Sb1, Sc1))

    h = (H + 1) // 2
    Sb2 = h * remain
    Sc2 = (H - h) * remain
    result.append(max(Sa, Sb2, Sc2) - min(Sa, Sb2, Sc2))

print(min(result))


Measured memory_bytes: 11032
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	int a,b;
	rep(i,0,7){
		cin>>a>>b;
		o(a-b);
	}
}

Measured memory_bytes: 1160
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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


int main(void) {
	int n;

	cin >> n;

	if (n % 111 == 0) {
		cout << n << endl;
	}
	else {
		cout << (n / 111) * 111 + 111 << endl;
	}


	return 0;
}

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

int main() {
    ll n;
    cin >> n;
    map<ll,ll> m, p;
    rep(i,n/2) {
        ll a, b;
        cin >> a >> b;
        m[a]++, p[b]++;
    }
    vector<P> even, odd; //回数 値
    for(auto x : m) even.push_back(make_pair(x.second, x.first));
    for(auto x : p) odd.push_back(make_pair(x.second, x.first));
    sort(all(even)); sort(all(odd));;
    reverse(all(even)); reverse(all(odd));
    ll A = 0, B = 0, ans;
    if(even[0].second==odd[0].second){
        ans = min(n-even[0].first-odd[1].first, n-even[1].first-odd[0].first);
    }
    else{
        A = even[0].first;
        B = odd[0].first;
        ans = n-A-B;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    int a[N], i, j = 0, k = 0, count = 0;
    for(i=0; i<N; ++i) {
        cin >> a[i];
    }

    for(i=0; i<N; ++i) {
        if(a[j] == 2) {
            cout << i+1 << endl;
            return 0;
        }
        k = j;
        j = a[j] - 1;
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    ll n, t;
    cin >> n >> t;
    ll st = 0, inv = 0;
    while (n--)
    {
        ll h;
        cin >> h;
        inv = max(inv, h);
        ll index = (t - st) / inv;
        if ((t - st) % inv >= h)
            index++;
        index = max(index, 0LL);
        cout << index + 1 << endl;
        st += h;
    }
}



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

int main(){
    ll N, x; cin >> N >> x;
    vector<int> A(N+1);
    A.push_back(0);
    for(int i = 1; i <= N; i++) cin >> A[i];
    ll res = 0;
    for(int i = 1; i <= N; i++){
        if(A[i-1] + A[i] > x){
            res += A[i-1] + A[i] - x;
            A[i] -= A[i-1] + A[i] - x;
        }
    }
    cout << res <<endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>

using namespace std ;

const int MaxN = 100000 + 5 ;
int N ;
long long A[MaxN] ;

long long Abs( long long A ) {
	return A < 0 ? -A : A ;
}
long long Max( long long A , long long B ) {
	return A > B ? A : B ;
}

int main() {
	
	scanf( "%d" , &N ) ;
	for(register int i = 0 ; ++i <= N ; )
		scanf( "%d" , &A[i] ) ;
	sort( A + 1 , A + 1 + N ) ;
	long long Ans , Maxans = 0 ;
	int L , R , Last ;
	bool Tag ;
	if( N & 1 ) {
		L = 1 ;
		R = N ;
		Last = N + 1 >> 1 ;
		Ans = 0 ;
		Tag = true ;
		for(register int i = 1 ; ++i <= N ; ) {
			if( Tag ) {
				Ans += Abs( A[Last] - A[R] ) ;
				Last = R-- ;
			}
			else {
				Ans += Abs( A[Last] - A[L] ) ;
				Last = L++ ;
			}
			Tag ^= 1 ;
		}
		Maxans = Max( Maxans , Ans ) ;
		L = 1 ;
		R = N ;
		Last = N + 1 >> 1 ;
		Ans = 0 ;
		Tag = false ;
		for(register int i = 1 ; ++i <= N ; ) {
			if( Tag ) {
				Ans += Abs( A[Last] - A[R] ) ;
				Last = R-- ;
			}
			else {
				Ans += Abs( A[Last] - A[L] ) ;
				Last = L++ ;
			}
			Tag ^= 1 ;
		}
		Maxans = Max( Maxans , Ans ) ;
	}
	else {
		L = 1 ;
		R = N ;
		Last = N >> 1 ;
		Ans = 0 ;
		Tag = true ;
		for(register int i = 1 ; ++i <= N ; ) {
			if( Tag ) {
				Ans += Abs( A[Last] - A[R] ) ;
				Last = R-- ;
			}
			else {
				Ans += Abs( A[Last] - A[L] ) ;
				Last = L++ ;
			}
			Tag ^= 1 ;
		}
		Maxans = Max( Maxans , Ans ) ;
		L = 1 ;
		R = N ;
		Last = N + 2 >> 1 ;
		Ans = 0 ;
		Tag = false ;
		for(register int i = 1 ; ++i <= N ; ) {
			if( Tag ) {
				Ans += Abs( A[Last] - A[R] ) ;
				Last = R-- ;
			}
			else {
				Ans += Abs( A[Last] - A[L] ) ;
				Last = L++ ;
			}
			Tag ^= 1 ;
		}
		Maxans = Max( Maxans , Ans ) ;
	}
	return not printf( "%lld\n" , Maxans ) ;
}

Measured memory_bytes: 896
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


a=nl()
j=0
for i in range(0,10):
    if i in a:
        j+=1

if j==2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064