akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            Console.WriteLine(int.Parse(s[0]+s[1]+s[2])%4==0?"YES":"NO");
        }
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}

Measured memory_bytes: 13140
#include "bits/stdc++.h"
using namespace std;
// #define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}

const long long INF=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;

const int N=0;



void solve(){
	int a,b;
	cin>>a>>b;
	if(b > a) swap(a,b);
	
	long long prod = 1LL * a * b - 1;
	
	int ans = 2*b - 2;
	
	int L = b, U = a - 1;
	
	if(U - L < 10000){
		while(L < U){
			int his = prod / L;
			if(his > U) his = U;
			if(his > b){
				U = his - 1;
				ans++;
			}
			else{
				cout<<ans<<"\n";
				return;
			}
			L++;
		}
		
		int U2 = a - 1;
		
		rep(x,b+1,U+1){
			int his = prod / x;
			if(his > U2) his = U2;
			if(his < L){
				cout<<ans<<"\n";
				return;
			}
			U2 = his - 1;
			ans++;
		}
		cout<<ans<<"\n";
	}
	else{
		int x;
		while(L <= U){
			int m = (L+U)/2;
			if(1LL*m*m >= prod + 1){
				x = m;
				U = m - 1;
			}
			else{
				L = m + 1;
			}
		}
		
		ans += x - b;
		
		int k = prod / x;
		
		ans += k - b;
		
		cout<<ans<<"\n";
	}
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SIEVE
		sieve();
	#endif
	#ifdef NCR
		init();
	#endif
	int t=1;
	cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h> 
typedef struct{
    int k,l,r;
}Node;
void insert(int, int);
void inParse(int);
void preParse(int);
void find(int,int);
Node T[500001];
int main(void)
{
    char s[8];
    int m;
    int num,count=0;
    int i;
  
    scanf("%d", &m);  
    for(i=0; i<m; i++){
        scanf("%s", &s);
        if(s[0]=='i'){ 
          scanf("%d", &num); 
          insert(count, num); 
          count++; 
        }
        if(s[0]=='f'){
            scanf("%d",&num);
            find(num,0);
        }
        if(s[0]=='p'){
          if(count>0) inParse(0);
            printf("\n");
            if(count>0) preParse(0);
            printf("\n");
        }
    }  
    return 0;  
}
  
void inParse(int p){
    if(T[p].l>=0) inParse( T[p].l);
    printf(" %d", T[p].k);
    if(T[p].r>=0) inParse( T[p].r);
}
  
void preParse(int p){
    printf(" %d", T[p].k);
    if(T[p].l>=0) preParse(T[p].l);
    if(T[p].r>=0) preParse(T[p].r);
}
  
void insert(int count, int z){
    int x=0, y;
    if(count<1) x=-1;
  
    T[count].k = z;
    T[count].l = -1;
    T[count].r = -1;
  
    while(x>=0){
        y = x; 
        if(z < T[x].k)x = T[x].l; 
        else x = T[x].r; 
    }
    if(count<1){}
    else if(z < T[y].k)T[y].l = count; 
    else T[y].r = count; 
}
void find(int num,int c){
  if (c==-1){
    printf("no\n");
  }
  else if (T[c].k==num){
    printf("yes\n");
  }
  else if (T[c].k > num && T[c].l != -1){
    find(num,T[c].l);
  }
  else {
    find(num,T[c].r);
  }
}

Measured memory_bytes: 5304
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    string s;
    cin >> s;
    if (s == "ABC")
        cout << "ARC";
    else
        cout << "ABC";
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int a[3][3], n;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }
    cin >> n;
    int b[n];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < n; k++) {
                if (a[i][j] == b[k]) {
                    a[i][j] = 0;
                }
            }
        }
    }
    bool ans = false;
    for (int i = 0; i < 3; i++) {
        if (a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0) {
            ans = true;
        }
    }
    for (int j = 0; j < 3; j++) {
        if (a[0][j] == 0 && a[1][j] == 0 && a[2][j] == 0) {
            ans = true;
        }
    }
    if (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) ans = true;
    if (a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0) ans = true;
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using lli = long long ;
using pii = pair<int,int>;
using pli = pair<lli,int>;

const int MOD=1e9+7;
const lli INF=1e15;

int n,m,vis[100001];
lli fcnt[100001],bcnt[100001];
lli fdist[100001],bdist[100001];
vector<pii> adj[100001];

void Dijk(int s,lli *dist,lli *cnt) {
    priority_queue<pli,vector<pli>,greater<pli>> que;
    que.push({0,s});
    fill(vis,vis+n+1,0);
    fill(dist,dist+n+1,INF);
    cnt[s]=1;
    dist[s]=0;

    while(!que.empty()) {
        int cur=que.top().se;que.pop();
        if(vis[cur]) continue;
        vis[cur]=1;
        for(auto &it:adj[cur]) {
            if(!vis[it.se] && dist[it.se] > dist[cur]+it.fi) {
                cnt[it.se]=cnt[cur];
                dist[it.se] = dist[cur]+it.fi;
                que.push({dist[it.se],it.se});
            } else if(dist[it.se]==dist[cur]+it.fi) {
                cnt[it.se] = (cnt[it.se] + cnt[cur])%MOD;
            }
        }
    }
}
lli pw(lli a) {return a*a%MOD;}

int main() {
    int s,t;
    scanf("%d%d",&n,&m);
    scanf("%d%d",&s,&t);
    
    for(int i=0;i<m;i++) {
        int u,v,w;
        scanf("%d%d%d",&u,&v,&w);
        adj[u].push_back(pii(w,v));
        adj[v].push_back(pii(w,u));
    }

    Dijk(s,fdist,fcnt);
    Dijk(t,bdist,bcnt);

    lli d=fdist[t],ans=fcnt[t]*bcnt[s]%MOD;
    if(d%2==0) {
        for(int i=1;i<=n;i++) if(fdist[i]==d/2 && fdist[i]+bdist[i]==d) {
            ans = (ans - pw(fcnt[i]*bcnt[i]%MOD) + MOD)%MOD;
        }
    }
    for(int i=1;i<=n;i++) for(auto &it:adj[i]) {
        if(fdist[i]+bdist[it.se]+it.fi==d &&
                fdist[i]<=d/2 && bdist[it.se]<=d/2 &&
                (d%2==1 || (fdist[i]!=d/2 && bdist[it.se]!=d/2))) {
            ans = (ans - pw(fcnt[i]*bcnt[it.se]%MOD) + MOD)%MOD;
        }
    }
    printf("%lld\n",ans);
    
    return 0;
}


Measured memory_bytes: 15444
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    private enum Digit {
        NINE("9", "1"), ONE("1", "9");

        private final String from;
        private final String to;

        Digit(String from, String to) {
            this.from = from;
            this.to = to;
        }

        public static Digit fromString(String from) {
            return Arrays.stream(values())
                    .filter(digit -> digit.from.equals(from))
                    .findFirst()
                    .orElseThrow(() -> new IllegalArgumentException("Unknown digit: " + from));
        }

        public String convert() {
            return to;
        }
    }

    public static String process(TestCase testCase) {
        final int N = testCase.N;

        return Arrays.stream(String.valueOf(N).split(""))
                .map(Digit::fromString)
                .map(Digit::convert)
                .collect(Collectors.joining());
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();

        return new TestCase(N);
    }

    private static void output(String result) {
        System.out.println(result);
    }

    public static class TestCase {
        final int N;

        public TestCase(int N) {
            this.N = N;
        }
    }
}


Measured memory_bytes: 27348
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cout << v << " ";  \
  }                    \
  cout << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int a[1010][1010];
int nowd[1010];
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;

  REP(i, N) {
    REP(j, N - 1) {
      cin >> a[i][j];
      a[i][j]--;
    }
  }
  int ans = 0;
  int count = 0;

  while (count != N * (N - 1)) {
    bool flg = false;
    bool flgI[1010];
    fill(flgI, flgI + N, false);

    REP(i, N) {
      // DEBUG(nowd[i]);
      if (flgI[i]) continue;
      if (nowd[i] >= N - 1) continue;
      int j = a[i][nowd[i]];
      if (flgI[j]) continue;
      if (nowd[j] >= N - 1) continue;
      int k = a[j][nowd[j]];
      if (i == k) {
        // DEBUG(ans);
        // DEBUG(count);
        // DEBUG(i);
        // DEBUG(j);

        flgI[i] = true;
        flgI[j] = true;
        flg = true;
        count += 2;
        nowd[i]++;
        nowd[j]++;
      }
    }
    if (!flg) {
      print("-1");
      return 0;
    }
    ans++;
  }
  print(ans);
}

Measured memory_bytes: 8192
import functools

def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)

def gcd(nums):
    return functools.reduce(euclid, nums)

N = int(input())
A = list(map(int,(input().split())))
L = [0]*N
R = [0]*N
L[0] = A[0]
R[0] = A[N-1]
for i in range(1,N):
    L[i] = gcd([L[i-1],A[i]])
for i in range(1,N):
    R[i] = gcd([R[i-1],A[N-1-i]])

p = []

for i in range(N):
    if i == 0:
        p.append(R[N-2])
    elif i == N-1:
        p.append(L[N-2])
    else:
        p.append( gcd([L[i-1], R[N-2-i]]) )

print(max(p))

Measured memory_bytes: 70380
using System;
using System.Collections.Generic;
using System.Linq;

class D
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var n = int.Parse(Console.ReadLine());
		var rs = new int[n - 1].Select(_ => read()).ToArray();
		var c = read(); Array.Sort(c);

		var ps = Enumerable.Range(0, n + 1).Select(i => new { i, ps = new List<int>() }).ToArray();
		foreach (var r in rs)
		{
			ps[r[0]].ps.Add(r[1]);
			ps[r[1]].ps.Add(r[0]);
		}
		var sorted_ps = ps.OrderBy(_ => _.ps.Count).ToArray();

		var M = 0L;
		var d = new int[n + 1];
		var ended = 0;
		while (ended < n - 1)
			foreach (var p in sorted_ps)
			{
				if (p.ps.Count != 1) continue;
				M += d[p.i] = c[ended++];

				if (ended < n - 1)
				{
					ps[p.ps[0]].ps.Remove(p.i);
					p.ps.RemoveAt(0);
				}
				else
				{
					d[p.ps[0]] = c[n - 1];
					break;
				}
			}
		Console.WriteLine(M);
		Console.WriteLine(string.Join(" ", d.Skip(1)));
	}
}


Measured memory_bytes: 23132
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  int n;
  string s;
  cin >> n >> s;
  int w = 0;
  REP(i, n) {
    if (s[i] == 'W') w++;
  }
  int e = n - w;
  int ans = n;
  int cw = 0;
  int ce = e;
  REP(i, n) {
    if (s[i] == 'W') {
      cw++;
      ans = min(ans, cw + ce - 1);
    } else {
      ce--;
      ans = min(ans, cw + ce);
    }
  }
  print(ans);

  return 0;
}

Measured memory_bytes: 900
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int N = Integer.parseInt(sc.next());
            int[] a = new int[N];
            int[] num = new int[100001];
            long sum = 0;

            for (int i = 0; i < N; i++) {
                int input = Integer.parseInt(sc.next());
                a[i] = input;

                num[a[i]]++;
                sum += input;
            }

            int Q = Integer.parseInt(sc.next());
            for (int i = 0; i < Q; i++) {
                int b = Integer.parseInt(sc.next());
                int c = Integer.parseInt(sc.next());


                int cnt = num[b];
                if (cnt > 0) {
                    num[c] += cnt;
                    num[b] = 0;
                }
                sum += (c - b) * cnt;
                System.out.println(sum);
            }
        }
    }
}

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A[i][j];
        }
    }
    
    vector<pair<int, int>> from, to;
    
    for (int i = 0; i < H; i++) {
        if (i%2==0) for (int j = 0; j < W; j++) {
            if (i+1 == H && j+1 == W) break;
            if (A[i][j]%2 == 1) {
                A[i][j]--; from.emplace_back(i, j);
                if (j+1 == W) { A[i+1][j]++; to.emplace_back(i+1, j); }
                else { A[i][j+1]++; to.emplace_back(i, j+1); }
            }
        }
        if (i%2==1) for (int j = W-1; j >= 0; j--) {
            if (i+1 == H && j == 0) break;
            if (A[i][j]%2 == 1) {
                A[i][j]--; from.emplace_back(i, j);
                if (j == 0) { A[i+1][j]++; to.emplace_back(i+1, j); }
                else { A[i][j-1]++; to.emplace_back(i, j-1); }
            }
        }
    }
    
    int com = from.size();
    cout << com << endl;
    for (int i = 0; i < com; i++) {
        cout << from[i].first+1 << " " << from[i].second+1 << " " << to[i].first+1 << " " << to[i].second+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 5228
N = int(input())
A = sorted(list(map(int, input().split())))

from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)

m = A[0]
for i in range(1, N):
    m = lcm(m, A[i])
m -= 1

ans = 0
for i in range(N):
    ans += m % A[i]

print(ans)

Measured memory_bytes: 66792
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long sum = T.Sum();
		for(int i=0;i<M;i++){
			Console.WriteLine(sum - T[P[i]] + X[i]);
		}
		
		
	}
	int N;
	long[] T;
	int M;
	int[] P;
	long[] X;
	public Sol(){
		N = ri();
		T = rla();
		M = ri();
		P = new int[M];
		X = new long[M];
		for(int i=0;i<M;i++){
			var d = ria();
			P[i] = d[0] - 1;
			X[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <math.h>
using namespace std;

int main(){
	int D, N;

	cin >> D >> N;
	if (N == 100)
		++N;
	D = pow(100., D);

	cout << D * N << endl;

	return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC079C
{
    class Program
    {
        static void Main(string[] args)
        {
            string target = Console.ReadLine();
            int[] s = new int[4];
            for(int i=0;i<4;i++)
               s[i] = int.Parse(target[i].ToString());
            int ans = 100;
            for(int i=0;i < (1 << 3);i++){
                int tmp = s[0];
                for(int j = 0; j<3;j++){
                    if( (i & (1 << j)) >> j == 1){
                        tmp += s[j+1];
                    } else tmp -= s[j+1];
                }
                if(tmp == 7) { ans = i; break;}
            }
            string answer = s[0].ToString();
            for(int j = 0; j<3;j++)
               if( (ans & (1 << j)) >> j == 1){
                    answer += "+" + s[j+1].ToString();
                    } else answer += "-" + s[j+1].ToString();
            Console.WriteLine(answer+"=7");
//            Console.WriteLine(ans);
        }
    }
}


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

inline bool check_YYMM(int aa, int bb){
	return 1 <= bb and bb <= 12;
}

inline bool check_MMYY(int aa, int bb){
	return 1 <= aa and aa <= 12;
}

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

	string S;
	cin >> S;

	int aa, bb;
	sscanf(S.substr(0, 2).c_str(), "%d", &aa);
	sscanf(S.substr(2, 2).c_str(), "%d", &bb);

	if(check_MMYY(aa, bb) and check_YYMM(aa, bb))
		puts("AMBIGUOUS");
	else if(check_MMYY(aa, bb))
		puts("MMYY");
	else if(check_YYMM(aa, bb))
		puts("YYMM");
	else
		puts("NA");
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>
#include <ctgmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll mod = 1000000007;
const ll inf = 10e17;
const ld eps = 10e-9;



ll solve(void);
ll gcd(ll x, ll y);

int main(void)
{
	while (solve())
	{
	}
	return 0;
}

ll gcd(ll x, ll y)
{
	if (y == 1) { return 1;}
	if (x % y == 0) { return y; }
	return gcd(y, x % y);
}

ll n;
ll x, y;
vector<vector<ll>> dist;

void dijkstra(ll num)
{
	vector<ll> d(n, inf);
	queue<ll> q;
	q.push(num);
	d[num] = 0;

	while (!q.empty())
	{
		auto p = q.front();
		q.pop();

		vector<ll> c = {p+1, p-1};
		if (p == x) { c.push_back(y); }
		if (p == y) { c.push_back(x); }

		for (auto node : c)
		{
			if (node < 0 || node >= n ) { continue; }
			if (d[p] + 1 < d[node])
			{
				d[node] = d[p] + 1;
				dist[num][node] = d[node];
				q.push(node);
			}
		}
	}
}

bool judge(ll src, ll dst)
{
	return (src < n && dst < n && src >= 0 && dst >= 0) &&
		(abs(src - dst) == 1 || 
		(src == x && dst == y) ||
		(src == y && dst == x)
	);
}

ll solve(void)
{
	cin >> n;
	cin >> x >> y;
	x --;
	y --;

	dist = vector<vector<ll>>(n, vector<ll>(n, inf));

	for (ll i = 0; i < n; i++)
	{
		dijkstra(i);
	}

	vector<ll> ans(n + 1, 0);
	for (ll i = 0; i < n; i++)
		for (ll j = 0; j < i; j++)
		{
			if (dist[i][j] == inf) { continue; }
			ans[dist[i][j]] ++;
		}

	for (ll i = 1; i < n; i++)
	{
		cout << ans[i] << endl;
	}

	return 0;
}



Measured memory_bytes: 31616
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{

    ll i,j,n,d,x,t,a;
    double p,minn=999999999999999;
    cin>>p;
    p=2*p*3.14159;
    cout<<fixed<<setprecision(20)<<p<<endl;
    return 0;
}


Measured memory_bytes: 3804
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
using namespace std;

int main() {
	map<string, int> mp;
	int n;
	cin >> n;
	
	for(int i = 0; i < n; i++) {
		string s, t;
		cin >> s;
		cin >> t;
		//cout << "s:" << s << endl;
		//cout << "t :" << t << endl;
		if(s == "insert") {
			mp.insert(make_pair(t, 1));
		}
		
		else if(s == "find") {
			if(mp.count(t)) {
				cout << "yes" << endl;
			}
			else {
				cout << "no" << endl;
			}
		}
	}

	return 0;
}




Measured memory_bytes: 36408
// ABC072 C - Together.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <stack>


using lolo=long long;
using namespace std;
using vec=vector<lolo>;
using pari=pair<lolo, lolo>;
using vvec=vector<vec>;
using vecb=vector<bool>;
using Rpriority_queue=priority_queue<lolo, vector<lolo>, greater<lolo>>;
using priority_Q = priority_queue<lolo>;

#define FOR(i,n) for (lolo i=0; i<n; ++i)
#define FORIT(it,V) for (auto it=V.begin(); it!=V.end(); ++it)
#define FORANGE(v, V) for (auto v : v)
#define FORN(i,a,b) for (lolo i=a; i<b; ++i)
#define REV(i,a,b) for (lolo i=a; i>b; --i)
#define REVCNT(i, const_cnt, N) for (lolo i=N-1, cnt=const_cnt; cnt > 0; --cnt, --i)
#define ALL(x) x.begin(), x.end()
template <class T>
void chmax(T& ans, const T& b)
{
	if (ans < b) {
		ans = b;
	}
}

int main()
{
	lolo N;
	cin >> N;
	vec A(N);
	map<lolo, lolo> cnt;
	lolo a;
	FOR(i, N) {
		cin >> a;
		cnt[a] += 1;
	}
	constexpr lolo MAXA = 100000LL;
	vec Line(MAXA + 1, 0);
	FOR(i, MAXA + 1) {
		Line[i] = cnt[i];
	}
	constexpr lolo LEN = 3;
	lolo nowVal = 0;
	FOR(i, LEN) {
		nowVal += Line[i];
	}
	lolo ans = nowVal;
	for (int i = LEN; i < MAXA + 1; ++i) {
		nowVal -= Line[i - LEN];
		nowVal += Line[i];
		chmax(ans, nowVal);
	}
	cout << ans << endl;


}



Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

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

  for(int i = 0; i < n; i++){
    int a; cin >> a;
    for(int j = 1; j <= d; j++){
      int temp = j * a + 1;
      if(temp <= d) x++;
    }
  }
  cout << x+n << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	double r,f,e;
	double n=3.141592653589;
	scanf("%lf",&r);
	f=(double)(r*r*n);
	e=(double)(2*n*r);
	printf("%lf ",f);
	printf("%lf\n",e);
	return 0;
}



Measured memory_bytes: 1976
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
typedef long long int ll;
const int N=2e3+5,MAX=1e9;
int n,x,y,dist[N][N];
map <int,int> mp;
void fw(){
    for(int i=1;i<=n;i++)
    for(int j=i+1;j<=n;j++){
        dist[i][j]=j-i;
        dist[i][j]=min(dist[i][j],min(abs(i-x)+abs(y-j),abs(i-y)+abs(j-x))+1 );
    }

}
int main(){
    cin.tie(NULL);
    cout.tie(NULL);
    ios_base::sync_with_stdio(false);
    cin>>n>>x>>y;
    fw();
    for(int i=1;i<=n;i++)
    for(int j=i+1;j<=n;j++)
        mp[dist[i][j]]++;
    for(int i=0;i<n-1;i++){
        cout<<mp[i+1]<<'\n';
    }
    return 0;
}


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

using namespace std;

int H, W, N;

int numBlackAround(int i, int j, const set<pair<int, int>>& blacks) {
    if (0 < i && i < H - 1 && 0 < j && j < W - 1) {
        return blacks.count(make_pair(i - 1, j - 1))
            + blacks.count(make_pair(i - 1, j))
            + blacks.count(make_pair(i - 1, j + 1))
            + blacks.count(make_pair(i, j - 1))
            + blacks.count(make_pair(i, j))
            + blacks.count(make_pair(i, j + 1))
            + blacks.count(make_pair(i + 1, j - 1))
            + blacks.count(make_pair(i + 1, j))
            + blacks.count(make_pair(i + 1, j + 1));
    }
    else {
        return 0;
    }
}

void reg(int i, int j, const set<pair<int, int>>& blacks, map<pair<int, int>, int>& hasBlack) {
    if (0 < i && i < H - 1 && 0 < j && j < W - 1) {
        pair<int, int> p = make_pair(i, j);
        if (hasBlack.count(p) == 0) {
            hasBlack.insert(make_pair(p, numBlackAround(i, j, blacks)));
        }
    }
}

void Main() {
    cin >> H >> W >> N;
    set<pair<int, int>> blacks;
    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        blacks.insert(make_pair(a, b));
    }

    map<pair<int, int>, int> hasBlack;
    for (auto p : blacks) {
        int i = p.first;
        int j = p.second;
        reg(i - 1, j - 1, blacks, hasBlack);
        reg(i - 1, j, blacks, hasBlack);
        reg(i - 1, j + 1, blacks, hasBlack);
        reg(i, j - 1, blacks, hasBlack);
        reg(i, j, blacks, hasBlack);
        reg(i, j + 1, blacks, hasBlack);
        reg(i + 1, j - 1, blacks, hasBlack);
        reg(i + 1, j, blacks, hasBlack);
        reg(i + 1, j + 1, blacks, hasBlack);
    }

    map<int, long long> ans;
    for (int i = 1; i < 10; ++i) {
        ans.insert(make_pair(i, 0LL));
    }
    for (auto e : hasBlack) {
        ++ans[e.second];
    }

    long long zero = ((long long)H - 2) * ((long long)W - 2);
    for (auto p : ans) {
        zero -= p.second;
    }
    cout << zero << endl;
    for (int i = 1; i < 10; ++i) {
        cout << ans[i] << endl;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 64524
#include <iostream>

using namespace std;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  
  if (a < b) swap(a, b);
  if (a < c) swap(a, c);
  if (b < c) swap(b, c);
  
  cout << (a == 7 && b == 5 && c == 5 ? "YES" : "NO");
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int a,b;
	char c;
	while(scanf("%d %c %d",&a,&c,&b)!=EOF)
	{
		if(c=='+')
		printf("%d\n",a+b);
		if(c=='-')
		printf("%d\n",a-b);
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>

int rel_c_c( double, double, double, double, double, double );

int main( void ) {
	int n;
	double xa, ya, ra, xb, yb, rb;

	for ( scanf( "%d", &n ); n--; printf( "%d\n", rel_c_c( xa, ya, ra, xb, yb, rb ) ) )
		scanf( "%lf %lf %lf %lf %lf %lf", &xa, &ya, &ra, &xb, &yb, &rb );

	return 0;
}

int rel_c_c( double x1, double y1, double r1, double x2, double y2, double r2 ) {
	int sign;
	double R, r, d = sqrt( ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ) );

	if ( d > r1 + r2 )
		return 0;

	if ( r1 >= r2 ) {
		sign = 1;
		R = r1;
		r = r2;
	} else {
		sign = -1;
		R = r2;
		r = r1;
	}
	if ( R - r <= d && d <= R + r )
		return 1;
	if ( d < R - r )
		return sign * 2;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;



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

	string S;
	int K;
	cin >> S >> K;
	int N = S.size();
	int dp[N+1][2][K+2];
	rep(i,N+1){
		rep(j,2){
			rep(k,K+1){
				dp[i][j][k] = 0;
			}
		}
	}
	dp[0][0][0] = 1;
	rep(i,N){
		int n = S[i] - '0';
		rep(smaller, 2){
			rep(j,K+1){
				rep(x,(smaller ? 10 : n+1)){
					if(x == 0){
						dp[i+1][smaller || x<n][j] += dp[i][smaller][j];
					}
					else{
						dp[i+1][smaller || x<n][j+1] += dp[i][smaller][j];
					}
				}
			}
		}
	}
	cout << dp[N][0][K] + dp[N][1][K] << endl;
	
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <vector>

#include <stdio.h>

using ll = long long;
using namespace std;

ll to5(ll a) { return a * a * a * a * a; }

int main() {
    ios::sync_with_stdio(false);
    ll ans = 0;
    string s;
    cin >> s;

    int n = s.size();
    for (int i = 0; i < pow(2, n - 1); i++) {
        int len = 0;
        int st = 0;
        int f = n >= 2 ? 1 << (n - 2) : 0;
        while (f > 0) {
            if ((f & i) > 0) {
                // cout << s.substr(st, len + 1) << ",";
                ans += stoll(s.substr(st, len + 1));
                st += len + 1;
                len = 0;
            } else {
                len++;
            }
            f = f >> 1;
        }
        // cout << s.substr(st, len + 1) << endl;
        ans += stoll(s.substr(st, len + 1));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2202;
int n,i,j,cnt,pr[N],a[100002],b[100002][2],t,tot,x,y,k,c1,c2,ans;
map<int,int>c,used;
bool vis[N];
signed main(){
	scanf("%lld",&n);
	for (i=1;i<=n;i++) scanf("%lld",&a[i]);
	for (i=2;i<N;i++)
		if (!vis[i]){
			pr[tot++]=i;
			for (j=i+i;j<N;j+=i) vis[j]=1;
		}
	for (i=1;i<=n;i++){
		x=y=1;
		for (j=0;j<tot;j++)
			if (a[i]%pr[j]==0){
				cnt=0;
				while (a[i]%pr[j]==0) cnt++,a[i]/=pr[j];
				if ((cnt%=3)==0) continue;
				for (k=0;k<cnt;k++) x*=pr[j];
				for (k=cnt;k<3;k++) y*=pr[j];
			}
		t=sqrt(a[i]);
		if (t*t==a[i]) x*=t*t,y*=t;
		else x*=a[i],y*=a[i]*a[i];
		b[i][0]=x,b[i][1]=y;
		c[x]++;
	}
	for (i=1;i<=n;i++){
		c1=b[i][0],c2=b[i][1];
		if (used[c1] || used[c2]) continue;
		x=c[c1]>c[c2]?c1:c2,used[x]=1;
		ans+=x==1?1:c[x];
	}
	printf("%lld",ans);
}


Measured memory_bytes: 27648
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N,K;
vector <int > H;





int main()
{

	cin >> N >> K;

	cout << max(N-K,0) << endl;





}

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();
        int m = sc.nextInt();
        int[][] a = new int[2][n];
        int[][] c = new int[2][m];
        for(int i = 0 ; i < n ; i++){
            for(int j = 0 ; j < 2 ; j++){
                a[j][i] = sc.nextInt();
            }
        }
        for(int i = 0 ; i < m ; i++){
            for(int j = 0 ; j < 2 ; j++){
                c[j][i] = sc.nextInt();
            }
        }
        for(int i = 0 ; i < n ; i++){
            int yono = 0;
            for(int j = 0 ; j < m ; j++){
                if(Math.abs(c[0][yono] - a[0][i]) + Math.abs(c[1][yono] - a[1][i]) > Math.abs(c[0][j] - a[0][i]) + Math.abs(c[1][j] - a[1][i])){
                    yono = j;
                }
            }
            System.out.println(yono + 1);
        }
    }
}
//鶏になれ


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

int main() {
 int a, b, c;
 cin >> a >> b >> c;
 if (a < b) {
  if (b < c) {
   cout << "Yes" << endl;
   }
   else
  cout << "No" << endl;
  }
 else
  cout << "No" << endl;
 
 return 0;
 
}


Measured memory_bytes: 3080
#include<stdio.h>
#include<algorithm>
using namespace std;
#define NIL -2000000001
#define MAX 500000

int A[MAX];

void maxHeapify(int i, int n) {
  int left = 2*(i+1)-1;
  int right = 2*(i+1)+1-1;
  int largest;
  if (left < n && A[left] > A[i]) {
    largest = left;
  } else {
    largest = i;
  }
  if (right < n && A[right] > A[largest]) {
    largest = right;
  }
  if (largest != i) {
    swap(A[i], A[largest]);
    maxHeapify(largest, n);
  }
}

void buildMaxHeap(int n) {
  for ( int i = n/2-1; i >= 0; i-- ) {
    maxHeapify(i, n);
  }
}

void printHeap(int n) {
  for ( int i = 0; i < n; i++ ) {
    printf(" %d", A[i]);
  }
  printf("\n");
}

int main() {
  for ( int i = 0; i < MAX; i++ ) {
    A[i] = NIL;
  }
	int n;
  scanf("%d", &n);
  for ( int i = 0; i < n; i++ ) {
    scanf("%d", &A[i]);
  }
  buildMaxHeap(n);
  printHeap(n);

  return 0;
}



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

void swap(int *a, int *b){
	if(*a != *b){
		*a ^= *b;
		*b ^= *a;
		*a ^= *b;
	}
}

int gcd(int a, int b){
	int t;
	if(a < b)swap(&a, &b);
	while(b != 0){
		t = b;
		b = a % b;
		a = t;
	}
	return a;
}

void ExtendEuclid(int a, int b, int *x, int *y){
	int x1, y1, z1, x2, y2, z2, z, t;
	
	x1 = 1; y1 = 0; z1 = a;
	x2 = 0; y2 = 1; z2 = b;
	*x = x2;
	*y = y2;
	
	while(z2 != 1){
		t = (z1 - (z1 % z2)) / z2;
		
		*x = x1 - t * x2;
		*y = y1 - t * y2;
		z = z1 - t * z2;
		
		x1 = x2;
		y1 = y2;
		z1 = z2;
		
		x2 = *x;
		y2 = *y;
		z2 = z;
	}
}


int main() {
	int a, b, g, x, y;
	
	cin >> a >> b;
	g = gcd(a, b);
	a /= g;
	b /= g;
	ExtendEuclid(a, b, &x, &y);
	cout << x << " " << y << endl;
	return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	ll N;	cin>>N;
	vl A(N);
	rep(i,0,N){
		cin>>A[i];
	}
	sort(all(A));
	reverse(all(A));
	ll ans=A[0];
	ll cnt=1;
	rep(i,1,N){
		if(cnt>=N-1) break;
		ans+=A[i];
		cnt++;
		if(cnt>=N-1) break;
		ans+=A[i];
		cnt++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4716
mod = pow(10,18)
N = int(input())
A = list(map(int,input().split()))

res = 1
flag = True
if 0 in A:
    print(0)
else:
    for i in range(len(A)):
        res = res * A[i]
        if res > mod:
            flag = False
            break
    if flag:
        print(res)
    else:
        print(-1)

Measured memory_bytes: 21680
#include<stdio.h>

int main(void)
{
  int H, M, h, m, ans;
  
  scanf("%d %d", &H, &M);
  scanf("%d %d", &h, &m);
  
  ans = (H - h) * (M-m);
  
  printf("%d", ans);
  
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
    int n,i,count=0,ans=0;
    scanf("%d",&n);
    int h[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&h[i]);
    }
    for(i=0;i<n-1;i++)
    {
        if(h[i]>=h[i+1])
        {
            count++;
            if(ans<count){
                ans=count;
                }
        }
        else
        {
        count = 0;
        }

    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n;
    while(cin >> n)
    {
        int a[102];
        ll avg,ty1,ty2,ty3,sum = 0;
        for(int i = 0;i < n;i++)
        {
            cin >> a[i];
            sum += a[i];
        }
        ll sum1 = 0,sum2 = 0,sum3 = 0;
        avg = sum / n;
        for(int i = 0;i < n;i++)
        {
            ty1 = avg - a[i];
            ty2 = ty1 + 1;
            ty3 = ty1 - 1;
            sum1 = sum1 + ty1 * ty1;
            sum2 = sum2 + ty2 * ty2;
            sum3 = sum3 + ty3 * ty3;
        }
        sum = sum1 > sum2 ? sum2 : sum1;
        sum = sum3 > sum ? sum : sum3;
        cout << sum << endl;
    }
    return 0;
}


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

public class Main{

	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public String next(){
			try{
				while(st==null||!st.hasMoreElements()){
					st = new StringTokenizer(br.readLine());
				}
			}catch(Exception e){
				e.printStackTrace();
			}
			return st.nextToken();
	
		}
		public int nextInt(){
			return Integer.parseInt(next());
		}
		public long nextLong(){
			return Long.parseLong(next());
		}
		public double nextDouble(){
			return Double.parseDouble(next());
		}
		public String nextLine(){
			String s = "";
			try{
				s = br.readLine();
			}catch(Exception e){
				e.printStackTrace();
			}	
			return s;		
		}
	} 
	
	public static void main(String[] args){
		FastReader in = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		char[] s = in.next().toCharArray();
		int start = -1;
		boolean done = false;
		int end = -1;
		for(int i = 0; i < s.length; i++){
			if(!done&&s[i] == 'A'){
				start = i;
				done = true;
			}
			else if (s[i]=='Z'){
				end = i;
			}
		}
		int len = end - start +1;
		out.println(len);	
		out.flush();
		out.close();  
	}

}





Measured memory_bytes: 25648
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll h,w;cin>>h>>w;
    if(h==1||w==1)cout<<1<<endl;
    else cout<<(h*w+1)/2<<endl;
}

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  ll A,V,B,W,T;
  cin>>A>>V>>B>>W>>T;
  if(abs(A-B)<=T*(V-W)) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
const int N=2e5+11;
int a[N],b[N],sz[N],fa[N];
int n,cnt,m;
long long Ans,ans[N];
inline int find(int x){
	return fa[x]==x?x:fa[x]=find(fa[x]);
}
int main(){
	scanf("%d%d",&n,&m);
	Ans=1ll*(n-1)*n/2;
	rep(i,1,n)
		fa[i]=i,sz[i]=1;
	rep(i,1,m)
		scanf("%d%d",a+i,b+i);
	for(int i=m;i;--i){
		int x=a[i],y=b[i];
		x=find(x),y=find(y);
		ans[i]=Ans;
		if(find(x)==find(y));
		else{
			Ans-=1ll*sz[x]*sz[y];
			fa[x]=y;
			sz[y]+=sz[x];
		}
	}
	rep(i,1,m)
		printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

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

	int h, w, n;
	cin >> h >> w >> n;
	vector<vi> ls(w);
	rep(_,0,n){
		int x, y;
		cin >> x >> y;
		--x, --y;
		ls[y].push_back(x);
	}
	trav(v, ls){
		sort(all(v));
		v.push_back(h);
	}

	int x = 0, y = 0, cur = 0;
	int ans = 1e6;
	while(true){
		auto it = lower_bound(all(ls[y]), x);	
		ans = min(ans, cur + *it-x-1);
		if(*it==x+1) break;
		++x, ++cur;
		if(y == w-1) break;
		it = lower_bound(all(ls[y+1]), x);
		if(*it != x) ++y;
	}
	cout << ans+1 << endl;
}

Measured memory_bytes: 11392
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n=gets
fx=n.chomp.split("").map(&:to_i).inject(:+)
puts yn_judge((n.to_i%fx).zero?)

Measured memory_bytes: 3836
n = int(input())
ps = [int(item) for item in input().split()]

l = 0
change = 0
last_f = 0
while l < n - 1:
    if ps[l] == l+1:
        change += 1
        last_f = l+1
        l += 2 
    else:
        last_f = l
        l += 1

if ps[-1] == n and last_f == n-2:
    change += 1

print(change)

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

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

    int cnt_x = min(N, K);
    int cnt_y = max(0, N - K);

    cout << X * cnt_x + Y * cnt_y << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
//const long long mod = 1000000007;
//const long long mod = 998244353;

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d", a < 2 * b ? 0 : a - 2 * b);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;
#define rep(i, n) for(long long int (i) = 0; (i) < (int) (n); (i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const ll LINF = 1e18;

int main(int argc, char const *argv[])
{
    int n, a, b;
    cin >> n >> a >> b;
    int answer1, answer2;
    if (a > b) {
        answer1 = b;
    } else {
        answer1 = a;
    }
    if (a + b <= n) {
        answer2 = 0;
    } else {
        answer2 = a + b - n;
    }
    cout << answer1 << " " << answer2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using  namespace std;
int main(){
  int n,sum=0;
  cin >> n;
  string s[n];
  int a[n];
  for(int i=0;i<n;i++)cin >> s[i] >> a[i];
  string x;
  cin >> x;
  for(int i=0;i<n;i++){
    if(x==s[i]){
      for(int k=i+1;k<n;k++)sum+=a[k];
      break;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3624
//============================================================================
// Name        : AOJCpp.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 1000000;
static int cnt;


void trace(int A[],int n) {
	for (int j = 0; j < n; j++) {
		cout << A[j] << endl;
	}
}
void isort(int A[],int n, int g){
	for(int i = g; i < n; i++) {
		int v = A[i];
		int j = i - g;
		while(j >= 0 && A[j] > v) {
			A[j+g] = A[j];
			j=j-g;
			cnt++;
		}
		A[j+g] = v;
	}
}

int main() {


	int n;
	int A[MAX];

	cin >> n;

	for(int i=0; i < n; i++) {
		cin >> A[i];
	}

	cnt = 0;


	int m=1;
	for (int i = n/3/3; i > 0; i/=3) {
		m++;
	}
	int G[m];
	int d = 3;
	G[m-1] = 1;
	for(int i = m-2; i >= 0; i--,d*=3) {
		G[i] = G[i+1] + d;
	}
	for(int i = 0; i < m; i++) {

		isort(A, n,G[i]);
	}
	cout << m << endl;
	for(int i = 0; i < m-1; i++) {
		cout << G[i] << " ";
	}
	cout << G[m-1] << endl;
	cout << cnt << endl;
	trace(A,n);



}





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


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (abs(x-a) < abs(x-b)) cout << "A" << endl;
  else cout << "B" << endl;
}


Measured memory_bytes: 256
from itertools import accumulate

N = int(input())
A = [int(i) for i in input().split()]
A.sort()
Acum = list(accumulate(A))

cnt = [1] * N
for i in range(N-1):
    # Acum[i]がA[i+1]を吸収できるか
    if A[i+1] <= Acum[i] * 2:
        cnt[i+1] += cnt[i]

print(cnt[-1])

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

using namespace std;

typedef long long ll;

int main() {
    int n;
    ll x;
    cin >> n >> x;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

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

    if (x < a[0]) {
        cout << 0 << endl;
        return 0;
    }

    int cnt;
    for (int i = 0; i < n + 1; ++i) {
        if (i == n){
            cnt = n - 2;
            break;
        }
        x -= a[i];
        if (x == 0) {
            cnt = i;
            break;
        } else if (x < 0) {
            cnt = i - 1;
            break;
        }
    }

    cout << cnt + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int x,a,b;
  
  scanf("%d %d %d",&x,&a,&b);
  
  x=x-a;
  
  while(x>=0)
    x=x-b;
  printf("%d",x+b);
  
  return 0;
}

Measured memory_bytes: 128