akhauriyash/Code-Regression huggingface dataset:
def __is_even(num):
    return num % 2 == 0


DIVISOR = 10 ** 9 + 7
ITR_NUM = 1000

N = int(input())
reported_num_count = {}
power_num = 0
if __is_even(N):  # Nが偶数の場合
    # 報告が正しい場合、値は全て奇数であり、1 ~ N-1 (1つ飛ばし) が2回ずつ出現する
    for i in range(1, N, 2):
        reported_num_count[i] = 0
    for i in list(map(int, input().split())):
        if (1 <= i <= N - 1) and not __is_even(i) and reported_num_count[i] < 2:
            reported_num_count[i] += 1
        else:
            print(0)
            exit()
    power_num = int(N / 2)
else:  # N が奇数の場合
    # 報告が正しい場合、値は全て偶数であり、0 が 1回、 2 ~ N-1（1つ飛ばし）が2回ずつ出現する
    for i in range(0, N, 2):
        reported_num_count[i] = 0
    for i in list(map(int, input().split())):
        if (i == 0) and reported_num_count[0] < 1:
            reported_num_count[0] += 1
        elif (2 <= i <= N - 1) and __is_even(i) and reported_num_count[i] < 2:
            reported_num_count[i] += 1
        else:
            print(0)
            exit()
    power_num = int((N - 1) / 2)

result = 1
while power_num > ITR_NUM:
    result *= 2 ** ITR_NUM % DIVISOR
    result %= DIVISOR
    power_num -= ITR_NUM
result *= 2 ** power_num % DIVISOR
print(result % DIVISOR)


Measured memory_bytes: 18920
#include <iostream>

using namespace std;

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

  if (r < 1200) {
    cout << "ABC" << endl;
  } else if (r < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
n = int(input())
d = list(map(int, input().split()))
e = [0 for i in range(n)]
if d[0] > 0:
    exit(print(0))
for i in d:
    e[i] += 1
ans = 1
for i in range(1, n):
    ans *= e[d[i] - 1]
    ans %= 998244353
print(ans)

Measured memory_bytes: 20828
#include<stdio.h>

int main()
{
    int i=0,numa,numb,xa,xb,v=0;
	while(scanf("%d%d",&numa,&numb)!=EOF)
	{
		
		do{
			xa=numa%10;
			xb=numb%10;
			numa=numa/10;
			numb=numb/10;
			if((xa+xb+v)>=10){v=1;}
			else{v=0;}
			i++;
		}while(numa!=0||numb!=0);
		printf("%d\n",i+v);
		i=0;
	}
	
	return 0;
}

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

#define ll long long
#define ar array

const int mxN=1e7;
int n, c[mxN+1];

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

	cin >> n;
	for(int i=1; i<=n; ++i)
		for(int j=0; (j+=i)<=n; )
			++c[j];
	ll ans=0;
	for(int i=1; i<=n; ++i)
		ans+=(ll)i*c[i];
	cout << ans;
}

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

using namespace std;
const int maxn=100000+10;
char s[maxn];
int vis[26];
int main() {
	scanf("%s",s);
	int len=strlen(s);
	for(int i=0;i<26;i++) {
		char dd='a'+i;
		for(int j=0;j<len;j++) {
			if(s[j]==dd) {
				vis[i]++;
			}
		}
	}
	for(int i=0;i<26;i++) {
		if(!vis[i]) {
			printf("%c",'a'+i);
			return 0;
		}
	}
	printf("None\n");
	return 0;
}

Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AGrouping2 solver = new AGrouping2();
        solver.solve(1, in, out);
        out.close();
    }

    static class AGrouping2 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            out.println(in.nextInt() / 3);
        }

    }
}



Measured memory_bytes: 21844
#include "bits/stdc++.h"
#define puba push_back
#define ff first
#define ss second
#define bend(_x) begin(_x), end(_x)
#define szof(_x) ((int) (_x).size())
#define TASK_NAME ""

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7;
const ll INFL = 1e18 + 123;
const double PI = atan2(0, -1);

mt19937 tw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(tw) % (y - x + 1) + x; }




int main() {
    //freopen(TASK_NAME ".in", "r", stdin);
    //freopen(TASK_NAME ".out", "w", stdout);
    cerr << fixed << setprecision(15);
    cout << fixed << setprecision(15);
    
    
    ll a, b, c, d;
    ll n;
    cin >> a >> b >> c >> d >> n;

    b = min(b, a * 2);
    c = min(c, b * 2);
    d = min(d, c * 2);
    ll ans = 0;

    n *= 4;
    while (n >= 8) {
        n -= 8;
        ans += d;
    }

    while (n >= 4) {
        n -= 4;
        ans += c;
    }

    while (n >= 2) {
        n -= 2;
        ans += b;
    }

    while (n >= 1) {
        n -= 1;
        ans += a;
    }
    

    cout << ans << "\n";
    
    #ifdef LOCAL
        cerr << "time: " << clock() << endl;
    #endif
    return 0;
}

Measured memory_bytes: 256
s = input()
n = int(input())
for i in range(n):
    q = input().split()
    q1 = int(q[1])
    q2 = int(q[2]) + 1
    if q[0] == "print":
        sl = list(s)
        print("".join(sl[q1:q2]))
    elif q[0] == "reverse":
        sl = list(s)
        bb = sl[q1:q2]
        bb.reverse()
        s = "".join(sl[:q1] + bb + sl[q2:])
    elif q[0] == "replace":
        sl = list(s)
        s = "".join(sl[:q1]) + q[3] + "".join(sl[q2:])



Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b,c;
    while(1){
        cin>>a>>b>>c;
        if(a==-1&&b==-1&&c==-1){
            break;
        }
        if(a==-1||b==-1){
            cout<<"F"<<endl;
            continue;
        }
        if(a+b>=80){
            cout<<"A"<<endl;
            continue;
        }
        if(a+b>=65){
            cout<<"B"<<endl;
            continue;
        }
        if(a+b>=50){
            cout<<"C"<<endl;
            continue;
        }
        if(a+b>=30){
            if(c>=50){
                cout<<"C"<<endl;
                continue;
            }
            cout<<"D"<<endl;
            continue;
        }
        else{
            cout<<"F"<<endl;
        }
    }
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int a=0;
    int b=0;
    for(int i=0;i<s.size();i++){
        if (s[i]=='A'){
            a=i;
            break;
        }
    }
    for(int i=s.size()-1;i>=0;i--){
        if (s[i]=='Z'){
            b=i;
            break;
        }
    }
    printf("%d", b-a+1);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define prique priority_queue
int n;
int v[50],c[50];
int cnt=0;
signed main(){
    cin>>n;
    rep(i,n)cin>>v[i];
    rep(i,n)cin>>c[i];
    rep(i,n){
        if(v[i]>c[i])cnt+=v[i]-c[i];
    }
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate
# from pprint import pprint

def grid_wall(grid, h, w, wall='#'):
    G = [[wall]*(w+2) for _ in range(h+2)]
    for hi in range(h):
        G[hi+1][1:w+1] = grid[hi]
    return G

def solve():
    H, W = MI()
    G = LLS(H)

    black_cnt = 0
    for i in range(H):
        for j in range(W):
            if G[i][j] == '#':
                black_cnt += 1
    # print(black_cnt)

    G[-1][-1] = 'G'
    G[0][0] = '#'

    G2 = grid_wall(G, H, W, '#')
    # print(np.array(G2))

    q = deque([(1, 1, 1)])
    move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
    cost = INF
    while q:
        x, y, d = q.popleft()
        for dx, dy in move:
            nx, ny = x+dx, y+dy
            if G2[nx][ny] == 'G':
                cost = min(cost, d + 1)
            elif G2[nx][ny] == '#': continue
            else:
                q.append((nx, ny, d+1))
                G2[nx][ny] = '#'
    if cost == INF:
        print(-1)
        return
    # print(cost)
    print(H * W - black_cnt - cost)
if __name__ == '__main__':
    solve()


Measured memory_bytes: 3420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N;
const ll maxN = 2 * 1E5 + 10;
ll a[maxN];
int main () {
    ios::sync_with_stdio(false);
    cin >> N;
    ll total = 0;
    for(int i = 0; i < N; ++i) {
        cin >> a[i];
        total += a[i];
    }
    ll pre = 0;
    ll ret = 1LL << 60;
    for(int i = 0; i < N -1; ++i) {
        pre += a[i];
        ret = min(ret, abs(total - pre - pre));
    }

    cout << ret << endl;
    
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;

// ****************************************CODE***************************************//

ll n, m;
ll dp[100100];
vector<vector<ll> > g;

ll rec(ll i) {
    if(dp[i] != -1) return dp[i];

    ll res = 0;
    for(auto j : g[i]){
        res = max(res, rec(j) + 1);
    }

    return dp[i] = res;
}

int main() {
    cin >> n >> m;
    g.assign(n, vector<ll>());
    for(int i = 0; i < m; i++) {
        ll x, y;
        cin >> x >> y;
        x--; y--;
        g[x].push_back(y);
    }
    for(int i = 0; i < 100100; i++) dp[i] = -1;

    ll res = 0;
    for(int i = 0; i < n; i++){
        res = max(res, rec(i));
    }

    cout << res << endl;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  vector<int> vec(N,0);
  rep(i,N)
  {
    cin >> A[i];
  }
  rep(i,N)
  {
    vec[A[i]-1] ++;
  }
  sort(RALL(vec));
  rep(i,K)
  {
    N -= vec[i];
  }
  cout << N << endl;
  return 0;
}


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

using namespace std;
using ll = long long int;

int main() {
	ll a, b, c;
	cin>>a>>b>>c;
	if ( c <= a + b ) {
		cout<<"No\n";
		return 0;
	}
	ll q = c - a - b;

	if((4*a*b) < q*q) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256
import numpy as np
n,d=map(int,input().split( ))

line=[]
count=0

for i in range(n):
    line.append(list(map(int,input().split( ))))
    # print(line[i])
    if i>=1:
        for j in range(i):
            # print(float(np.linalg.norm(np.array(line[i])-np.array(line[j])))
            if float(np.linalg.norm(np.array(line[i])-np.array(line[j]))).is_integer():
                count+=1

print(count)


Measured memory_bytes: 20756
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
S = input()
w = I()
ans = []
for i in range(0,len(S),w):
    ans.append(S[i])
print(*ans,sep="")


Measured memory_bytes: 5212
#include<bits/stdc++.h>
using namespace std;
int n;
char s[111], tmp[222];
int main(){
    cin>>s + 1;
    n = strlen(s + 1);
    for(int i = 1;i <= 2 * n + 1; i++){
        if(i & 1)tmp[i] = '#';
        else tmp[i] = s[i / 2];
    }
    n = 2 * n + 1;
    int mid = n / 2 + 1, ans = 0;
    for(int i = 1;mid - i >= 1; i++){
        if(tmp[mid - i] != tmp[mid + i])ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//#define int long long  ←保留
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/*-------------ここまで---------------------------------------------*/

//C++(GCC9.2.1)

signed main() {
    int n,k,count=0;
    cin>> n >> k;
    vector<int> vec(n);
    rep(i, n) {
        cin >> vec[i];
        if (vec[i] >= k) ++count;
    }
    cout << count << "\n";
    return 0;
}

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            var s1 = int.Parse(S.Substring(0, 2));
            var s2 = int.Parse(S.Substring(2, 2));

            bool YYMM = true;
            bool MMYY = true;

            if (!(1 <= s1 && s1 <= 12))
            {
                MMYY = false;
            }
            if (!(1 <= s2 && s2 <= 12))
            {
                YYMM = false;
            }

            if (YYMM)
            {
                if (MMYY)
                {
                    Console.WriteLine("AMBIGUOUS");
                }
                else
                {
                    Console.WriteLine("YYMM");
                }
            }
            else
            {
                if (MMYY)
                {
                    Console.WriteLine("MMYY");
                }
                else
                {
                    Console.WriteLine("NA");
                }
            }
        }
    }
}

Measured memory_bytes: 11092
# https://atcoder.jp/contests/abc072/tasks/arc082_a
from collections import defaultdict
n = int(input())
nums = [int(i) for i in input().split()]

c = defaultdict(int)
for num in nums:
    c[num - 1] += 1
    c[num] += 1
    c[num + 1] += 1

ans = 0
for v in c.values():
    ans = max(ans, v)
print(ans)

Measured memory_bytes: 65324
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A= sc.nextInt();
		int B = sc.nextInt();
		String temp = String.valueOf(B);
		A= (int) (A*Math.pow(10, temp.length())+B);
		boolean b = false;
		for (int i=1;i*i<=A;i++) {
			if (i*i==A) {
				b= true;
			}
		}
		if (b==true) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 35688
#include <iostream>
using namespace std;
void trace(int A[], int N) {
	int i;
	for (i = 0; i < N; i++) {
		if (i > 0)  cout << " ";
		cout << A[i];
	}
	cout << endl;
}

int bubbleSort(int A[], int N) {
	int j, i,t=0,num=0;
	for (i = 0; i < N; i++) {
		for (j = 0; j < N - i-1; j++) {
			if (A[j] > A[j + 1]) { t = A[j]; A[j] = A[j + 1]; A[j + 1] = t; num++; }
		}
		
	}
	return num;
}
int main() {
	int N, i, j;
	int A[100] = {0};
	cin >> N;
	for (i = 0; i < N; i++)
		cin >> A[i];
	int n= bubbleSort(A, N);
	trace(A, N);
	cout << n << endl;
	return 0;
}

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

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

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)
#define ll long long

string s;
ll dp[80000][11];

int main(){
    while(1){
        cin >> s;
        if(s=="0") break;

        REP(i, s.size()) REP(j, 11) dp[i][j] = 0;
        REP(i, s.size()){
            if(i%2==0){
                if(s[i]!='0') dp[i][(s[i]-'0')%11] = 1;
                if(i>0) REP(j, 11) dp[i][(j+(s[i]-'0'))%11] += dp[i-1][j];
            } else {
                if(s[i]!='0') dp[i][(11-(s[i]-'0'))%11] = 1;
                if(i>0) REP(j, 11) dp[i][(11+j-(s[i]-'0'))%11] += dp[i-1][j];
            }
        }
        
        ll output = 0;
        REP(i, s.size()) output += dp[i][0];
        cout << output << endl;
    }
}

Measured memory_bytes: 10112
#include<stdio.h>
int main()
{
    int a[101],i,n;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=n;i>=1;i--)
    {
        if(i>1)
            printf("%d ",a[i]);
        else
            printf("%d",a[i]);
    }
    printf("\n");
    return 0;

}



Measured memory_bytes: 2120
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ll long long
#define MOD 1000000007
#define MAX 100010
#define aout(a) REP(i,sizeof(a)) cout << a[i] << " "; cout << endl;
#define vout(v) REP(i,v,size()) cout << v[i] << " "; cout << endl;
using namespace std;
using Graph = vector<vector<int>>;
 
int main(){
  int X; cin>>X;
  if(X>=30) cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 3588
#include<iostream>
#include<array>
#include<string>
#include<algorithm>
using namespace std;

int main() {
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e>>k;

	if (e - a > k ){
		cout <<":(" << endl;
	}
	else {
		cout << "Yay!"  << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int time;
	int h,m,s;
	int tmp;
	scanf("%d",&time);
	h = time / (60 * 60);
	tmp = time % (60 * 60);
	m = tmp / 60;
	s = tmp % 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int ans[2000];

void solve(long long N, long long X, long long Y){
    X--;
    Y--;
    REP(i, N) {
        REP2(j, i+1, N) {
            int len1 = j - i;
            int len2 = abs(X - i) + abs(Y - j) + 1;
            int len3 = abs(Y - i) + abs(X - j) + 1;
            ans[min(len1, min(len2, len3))-1]++;
        }
    }

    REP(i, N-1) {
        cout << ans[i] << endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(N, X, Y);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
cnt1, cnt2, cnt4 = 0, 0, 0
for i in range(n):
  t = 0
  while a[i]%2==0:
    a[i] //= 2
    t += 1
  if t==0:
    cnt1 += 1
  elif t==1:
    cnt2 += 1
  else:
    cnt4 += 1
if cnt2>=1:
  cnt1 += 1
if cnt1<=cnt4+1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 14252
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
	int r, c;
	cin >> r >> c;

	int v[r][c];
	for(int i = 0; i < r; i++){
		for(int j = 0; j < c; j++){
			cin >> v[i][j];
		}
	}

	int w[r+1][c+1];
	for(int i = 0; i < r+1; i++){
		for(int j = 0; j < c+1; j++){
			w[i][j] = 0;
		}
	}//初期化

	for(int i = 0; i < r; i++){
		for(int j = 0; j < c; j++){
			w[i][j] = v[i][j];
		}
	}//代入

	for(int i = 0; i < c; i++){
		int sum = 0;
		for(int j = 0; j < r; j++){
			w[r][i] += v[j][i];
		}
		w[r][c] += w[r][i];
	}//列ごとの合計
	for(int i = 0; i < r; i++){
		for(int j = 0; j < c; j++){
			w[i][c] += v[i][j];
		}
		//w[r][c] += w[i][c];
	}//行ごとの合計

	for(int i = 0; i < r+1; i++){
		for(int j = 0; j < c+1; j++){
			cout << w[i][j];
			if(j != c) cout << " ";
		}
		cout << endl;
	}

	return 0;
}



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

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

    long long diff = abs(A - B) ;

    if (diff % 2 == 1) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    cout << min(A, B) + (diff / 2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<vector<ll>> graph(N);

    ll a, b;
    rep(0, i, M)
    {
        cin >> a >> b;
        a--;
        b--;
        graph.at(a).push_back(b);
        graph.at(b).push_back(a);
    }

    queue<ll> que;
    for (auto g : graph.at(0))
    {
        que.push(g);
    }

    while (!que.empty())
    {
        ll x = que.front();
        que.pop();
        for (auto g : graph.at(x))
        {
            if (g == N - 1)
            {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }

    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 16480
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n, h, w;
    cin >> n >> h >> w;

    int ans = (n - h + 1) * (n - w + 1);
    cout << ans << endl;

    return 0;
}


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

int main(){
  int a, b;
  cin >> a >> b;
  
  int delta = b - a;
  
  int A = 0;
  for (int i=1; i<delta ; i++)
    A += i;
  
  cout << A - a << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x,y;
    cin >> x >> y;
    if (x == 2 || y == 2) cout << "No" << endl;
    else if((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) && (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12))cout << "Yes" << endl;
    else if( (x == 4 || x == 6 || x == 9 || x == 11) &&  (y == 4 || y == 6 || y == 9 || y == 11)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

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

  if(A.size() > B.size()){
      cout << "GREATER" << endl;
      return 0;
  }else if(A.size() < B.size()){
      cout << "LESS" << endl;
      return 0;
  }else{
      for(int i=0;i < A.size();i++){
          if(A[i]==B[i]) continue;
          else if(A[i] > B[i]){
              cout << "GREATER" << endl;
              return 0;
          }else{
              cout << "LESS" << endl;
              return 0;
          }
      }
      cout << "EQUAL" << endl;
  }
      
  return 0;
}

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

#define pb(a) push_back(a)
#define INF 1145141919810364364931
#define mod 1000000007

typedef long long ll;

const int MAX_N = 1e5+5;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
vector<ll> prime;

ll inv[MAX_N],fac[MAX_N];

template <class T = ll> T in(){T x;cin >> x;return (x);}
inline ll GCD(ll a,ll b){ll c;while(b!=0){c=a%b;a=b;b=c;}return a;}
inline ll LCM(ll a,ll b){return a*b/GCD(a,b);}
inline ll POW(ll a,ll b){ll c=1;while(b>0){if(b&1){c=a*c%mod;}a=a*a%mod;b>>=1;}return c;}
inline void _nCr(){fac[0]=1;for(int i=1;i<MAX_N;i++){fac[i]=fac[i-1]*i%mod;}for(int i=0;i<MAX_N;i++){inv[i]=POW(fac[i],mod-2);}}
inline ll nCr(ll n,ll r){return (fac[n]*inv[r]%mod)*inv[n-r]%mod;}
inline void PRI(ll n){bool a[n+1];for(int i=0;i<n+1;i++){a[i]=1;}for(int i=2;i<n+1;i++){if(a[i]){prime.pb(i);ll b=i;while(b<=n){a[b]=0;b+=i;}}}}

int start,fin;

typedef struct {
	int I;
	int from;
	ll cost;
	vector<pair<ll,ll>> to;
} _node;

bool operator > (const _node& a,const _node& b) {
	return a.cost > b.cost;
}
class Dijkstra {
public:
	vector<_node> node;
	string ans;
	priority_queue<_node,vector<_node>,greater<_node>> pque;
	void ds_init(int n) {
		node = vector<_node>(n);
		for (int i = 0;i < n;i++) {
			node[i].I = i;
			node[i].from = i;
			node[i].cost = INF;
		}
	}
	void dijkstra(int s) {
		node[s].cost = 0;
		for (int i = 0;i < node[s].to.size();i++) {
			node[node[s].to[i].first].cost = node[s].to[i].second + node[s].cost;
			node[node[s].to[i].first].from = s;
			pque.push(node[node[s].to[i].first]);
		}
		while (!pque.empty()) {
			_node next = pque.top();
			pque.pop();
			if (next.cost > node[next.I].cost) continue;
			for (int i = 0;i < next.to.size();i++) {
				if (node[next.to[i].first].cost > next.cost + next.to[i].second) {
					node[next.to[i].first].cost = next.cost + next.to[i].second;
					node[next.to[i].first].from = next.I;
					pque.push(node[next.to[i].first]);
				}
			}
		}
	}
	void searchpath(int now) {
		if (node[now].from != now) {
			ans = to_string(node[now].from) + " " + ans;
			searchpath(node[now].from);
		} else {
			return;
		}
	}
};
Dijkstra dj;
int main() {
	int n;cin >> n;
	dj.ds_init(n);
	for (int i = 0;i < n-1;i++) {
		ll a,b,c;
		cin >> a >> b >> c;
		dj.node[a-1].to.push_back({b-1,c});
		dj.node[b-1].to.push_back({a-1,c});
	}
	int q=in(),k=in();
	dj.dijkstra(k-1);
	for (int i = 0;i < q;i++) {
		int x=in(),y=in();
		cout << dj.node[x-1].cost+dj.node[y-1].cost << endl;
	}
}

Measured memory_bytes: 19796
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string st;
    cin >> st;
    int l = (int)st.size();
    int ns = 0;
    int nt = 0;
    int f = 0;
    int ans = 0;
    REP(i,l){
        if(f==0){
            if(st[i]=='S'){
                ns++;
            }else{
                nt++;
                f=1;
            }
        }else{
            if(st[i]=='S'){
                if(ns>=nt){
                    ns = ns-nt+1;
                    nt=0;
                }else{
                    ans+=nt-ns;
                    ns=1;
                    nt=0;
                }
                f=0;
            }else{
                nt++;
            }
        }
    }
    ans+=abs(ns-nt);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;

int main(){
	int n5=0,n7=0;
	rep(i,3) {
		int a;cin >> a;
		if(a == 5) n5++;
		if(a == 7) n7++;
	}
	if(n5 == 2 && n7 == 1) cout <<"YES"<< endl;
	else cout << "NO"<< endl;

	
}
 
 

Measured memory_bytes: 3584
//package atcoderdp;

import java.util.*;

class Main {
    static HashMap<String, Integer> states;

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int a[][] = new int[n][3];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                a[i][j] = s.nextInt();
            }
        }
        states = new HashMap<>();
        int res = Math.max(Math.max(find(a, n,  0, 0), find(a, n,  0, 1)), find(a, n,  0, 2));
        System.out.println(res);
    }

    public static int find(int a[][], int n,  int start, int index) {
        String state = index + " " + start;
        if (states.containsKey(state))
            return states.get(state);
        if (start == n-1) {
            //System.out.println(a[start][index]);
            return a[start][index];
        }

        else {
            int val1 = find(a, n,  start + 1, (index + 1) % 3);
            int val2 = find(a, n,  start + 1, (index + 2) % 3);
            // System.out.println(val1+" "+val2);
            int val = Math.max(val1 + a[start][index], val2 + a[start][index]);
            states.put(state, val);
            return val;
        }
    }
}
/*150 150
90 90
150 90
150 150
90 150
150 150
150 150
150 150
150 150
150*/
/*150 150
90 90
150 90
120 120
150 150
120 150
150 150
150 150
180 180
150 180
120 120
150 150
120 150
180 150
150 150
180 180
150 180
210 210
150 150
210 150
180 210
210*/

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

#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1e9)

int main(){
  int a,b,k,cnt=0;
  cin >> a >> b >> k;
  for(int i=100; i>0; i--){
    if(a%i==0 && b%i==0){
      cnt++;
      if(cnt == k){
        cout << i << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
const int INT_INF = 500000000;
const long long LONG_LONG_INF = (long long)pow(10, 18);
const int MOD = pow(10, 9) + 7;
/* contest template */
int N;
int X[200000];
int Y[200000];

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> X[i];
    Y[i] = X[i];
  }
  sort(X, X + N);
  for (int i = 0; i < N; i++) {
    if (Y[i] <= X[N / 2 - 1]) {
      cout << X[N / 2] << endl;
    } else {
      cout << X[N / 2 - 1] << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3712
// https://atcoder.jp/contests/dp/tasks/dp_f
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef pair<int,int> pii;

const int N = 3005;
const int MOD = int(1e9)+7;
const int INF = int(2e9)+5;
const ll INF64 = 1e18;

pair<int,int> lst[N][N];
ll dp[N][N];
vector<int> ans;

int main () {
    string s,t;cin>>s>>t;
    memset(dp,0,sizeof(dp));
    int n = s.size();
    int m = t.size();
    for (int i=1;i<=n;i++) {
        for (int j=1;j<=m;j++) {
            dp[i][j] = dp[i-1][j];lst[i][j] = {i-1,j};
            if (dp[i][j-1] > dp[i][j]) {
                dp[i][j] = dp[i][j-1];lst[i][j] = {i,j-1};
            }
            if (s[i-1] == t[j-1] && dp[i-1][j-1]+1 > dp[i][j]) {
                dp[i][j] = dp[i-1][j-1]+1;lst[i][j] = {i-1,j-1};
            }
        }
    }
    int i = n, j = m;
    while (i != 0 && j != 0) {
    	int pi = lst[i][j].first;
        int pj = lst[i][j].second;
        // cout<<i<<" "<<j<<" "<<pi<<" "<<pj<<endl;
        if (pi == i-1 && pj == j-1) {
            ans.push_back(i-1);
        }
        i = pi;j = pj;
    }
    reverse(ans.begin(),ans.end());
    for (auto x : ans) {
    	cout<<s[x];
    }
    return 0;
}

Measured memory_bytes: 141312
N,K = map(int,input().split())
P = list(map(int,input().split()))
cnt = 0
for i in range(K):
    cnt += P[i]
cmax = cnt
for i in range(K,N):
    cnt = cnt+P[i]-P[i-K]
    cmax = max(cmax,cnt)
print((K+cmax)/2)

Measured memory_bytes: 71792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(a,i,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);	
}
ll gcd(ll a,ll b)
{
	int p=a,q=b;
	return (ll)__gcd(p,q);
}
ll lcm(ll a,ll b)
{
	return (a*b)/gcd(a,b); 
}
int f(int x)
{
	int re=0;
	while(x%2==0){
		x/=2;re++;
	}
	return re;
}
int main()
{
	//fopen();
	int n;
	cin>>n;
	string s[n];int a[n];
	rep(i,n){
		cin>>s[i]>>a[i];
	}
	string p;
	cin>>p;
	rep(i,n){if(s[i]==p){int c=0;repA(i+1,j,n)
		{
				c+=a[j];
		
		}
		cout<<c;
		return 0;
	}
	}//cout<<c;
}


Measured memory_bytes: 256
h,w = map(int,input().split())
L = [[]*w for i in range(h)]

for i in range(h):
    L[i] = list("#" + input() + "#")
L = [["#" for i in range(w+2)]] + L + [["#" for i in range(w+2)]]
#print(L)

from collections import deque
ans = 0
q = deque([])
for j in range(1,h+1):
    for i in range(1,w+1):
        cost = [[-1]*(w+2) for i in range(h+2)]
        li = ((1,0),(0,1),(-1,0),(0,-1))
        #print(j,i)
        if L[j][i] == ".":
            cost[j][i] = 0
        cost_max = 0
        q.append((j,i))
        while q:
            #print(q)
            r,s = q.popleft()
            
            for dh,dw in li:
                nh,nw = r+dh,s+dw
                #print(L[nh][nw],)
                if L[nh][nw] =="." and cost[nh][nw] == -1 :
                    cost[nh][nw] = cost[r][s] + 1
                    #print(cost[nh][nw],cost[j][i])
                    #print(cost)
                    cost_max = max(cost_max,cost[nh][nw])
                    q.append((nh,nw))
        ans = max(ans,cost_max)
print(ans)

Measured memory_bytes: 9488
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>


int than(int a, int b,int c);
int main(void)
{
	int a, b, c= 0;
	scanf("%d%d%d", &a,&b,&c);
	than(a, b, c);
	return 0;
}
int than(int a,int b,int c)
{
	if (a < b && b< c ){
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2096
import numpy as np

N=int(input())
B=list(map(int,input().split()))

result=0
A=[]
A.append(B[0])
for i in range(len(B)):
    if i!=0:
        A.append(min(B[i],tmp))
    tmp=B[i]
A.append(B[N-2])
result=np.sum(A)
print(result)


Measured memory_bytes: 12388
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;
const int mod = 1000000007;
int kakuketanowa(int n) {//各桁の和
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}


int main(){
int a,b;
cin>>a>>b;
if((a*b)%2==1){
    cout<<"Odd"<<endl;
}
else{cout<<"Even"<<endl;}
}














Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

typedef struct node{
	int key;
	int priority;
	struct node *left;
	struct node *right;
}node;


node * Delete(node **,int);
node * _delete(node **,int);

int find(node *t,int x){

	while(t!=NULL){
		if(t->key == x) return 1;
		else if(t->key > x) t=t->left;
		else t=t->right;
	}

	return 0;

}

void inorder(node *t){

	if(t->left!=NULL)inorder(t->left);

	printf(" %d",t->key);

	if(t->right!=NULL)inorder(t->right);

	return;

}

void preorder(node *t){

	printf(" %d",t->key);

	if(t->left!=NULL)preorder(t->left);

	if(t->right!=NULL)preorder(t->right);

	return;

}

void print(node *t){

	inorder(t);
	printf("\n");

	preorder(t);
	printf("\n");

	return;

}

node * Node(int x,int y){
	node *n=malloc(sizeof(node));
	n->key=x;
	n->priority=y;
	n->left=NULL;
	n->right=NULL;
	return n;
}

node *rightRotate(node *t){
	node *s=t->left;
	t->left=s->right;
	s->right=t;
	return s;
}

node *leftRotate(node *t){
	node *s=t->right;
	t->right=s->left;
	s->left=t;
	return s;
}


node* insert(node **t,int key,int priority){
	node *n;

	if((*t)==NULL)
		return n=Node(key,priority);
	if ((*t)->key==key)
		return *t;

	if(key < (*t)->key){
		(*t)->left=insert(&(*t)->left,key,priority);
		if((*t)->priority < (*t)->left->priority)
			(*t)=rightRotate((*t));
	}
	else {
		(*t)->right=insert(&(*t)->right,key,priority);
		if((*t)->priority < (*t)->right->priority)
			(*t)=leftRotate((*t));
	}

	return *t;
}


node * Delete(node **t,int key){
	if((*t)==NULL)
		return NULL;

	if(key < (*t)->key)
		(*t)->left=Delete(&((*t)->left),key);

	else if(key > (*t)->key)
		(*t)->right=Delete(&((*t)->right),key);

	else return _delete(t,key);

	return *t;
}

node * _delete(node **t,int key){
	if((*t)->left==NULL && (*t)->right==NULL)
		return NULL;
	else if((*t)->left==NULL)
		(*t)=leftRotate(*t);
	else if((*t)->right==NULL)
		(*t)=rightRotate(*t);
	else {
		if((*t)->left->priority > (*t)->right->priority)
			(*t)=rightRotate(*t);
		else
			(*t)=leftRotate(*t);
	}
	return Delete(t,key);
}


int main(){
	int n,x,y;
	char c[8];
	node *t=NULL;

	scanf("%d",&n);

	for(int i=0;i<n;i++){
		scanf("%s",c);

		switch(c[0]){

			case 'i':scanf("%d %d",&x,&y);
					 t=insert(&t,x,y);
					 break;

			case 'd':scanf("%d",&x);
					 t=Delete(&t,x);
					 break;


			case 'f':scanf("%d",&x);
					 if(find(t,x))printf("yes\n");
					 else printf("no\n");
					 break;

			case 'p':print(t);
					 break;

		}

	}

	return 0;

}



Measured memory_bytes: 8008
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>
#include<random>



#define REP(i, n) for(int i = 0;i < n;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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;
int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 500050;

int a[1000];
long long gcd(long long x, long long y) {
	long long m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int rem = B - A + 1;
	int res1 = B / C - (A-1) / C;
	int res2 = B / D - (A-1) / D;
	int res3 = B / (lcm(C,D)) - (A-1) / (lcm(C,D));
	rem += -res1 - res2 + res3;
	print(rem);
}


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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//turn on extra precision
//#pragma GCC target("fpmath=387")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define watch(x) cout << (#x) << " is : " << (x) << newl

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
vi dirx = {0,0,1,-1};
vi diry = {1,-1,0,0};
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122) return char(x-32);
    if( 65 <= int(x) && int(x) <= 90) return x;
    return -1;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122) return x;
    if( 65 <= int(x) && int(x) <= 90) return char(x+32);
    return -1;
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57) return int(x-'0');
    if(97 <= int(x) && int(x) <= 122) return int(x-96);
    if(65 <= int(x) && int(x) <= 90) return int(x-64);
    return -1;
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1 = {l1,r1};
    pii p2 = {l2,r2};
    if(p1>p2)swap(p1,p2);
    return (p2.fi <= p1.se);
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1%MOD;
    else if(num2==1)return num1%MOD;
    else{
        ll temp = quickpow (num1,num2>>1LL,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2&1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
bool has[400];
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    pii p = {INT_MAX,INT_MAX};
    int x,n; cin >> x >> n;
    for(int i = 1; i <= n; ++i){
        int a; cin >> a; has[a] = true;
    }

    for(int i = 0; i <= 300; ++i){
        if(has[i]) continue;
        int ab = abs(i-x);
        p = min(p,{ab,i});
    }

    cout << p.se << newl;


    return 0;
}


Measured memory_bytes: 3624
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    //孤立した黒マスがなければ塗ることができる
    int H = sc.nextInt();
    int W = sc.nextInt();
    String grid[][] = new String[H+2][W+2];
    String answer="Yes";
    boolean flg = false;
    for(int i=0;i<W+2;i++){
    grid[0][i]=".";
    grid[H+1][i]=".";
    }
    for(int i=0;i<H+2;i++){
    grid[i][0]=".";
    grid[i][W+1]=".";
    }
    String tmp ="";
    for(int i=1;i<H+1;i++){
      tmp = sc.next();
      for(int j=1;j<W+1;j++){
        grid[i][j]=tmp.substring(j-1,j);
      }
    }
    //(2,2)～(H+1,W+1)のすべてのマスについて、
    //自分が#のとき、上下左右すべてが.だったらアウト
    //判定を繰り返し行う。
    for(int i=1;i<H+1;i++){
      for(int j=1;j<W+1;j++){
        if(grid[i][j].equals("#")&&
           grid[i][j-1].equals(".")&&
           grid[i][j+1].equals(".")&&
           grid[i-1][j].equals(".")&&
           grid[i+1][j].equals(".")){
          answer="No";
          flg=true;
          break;
        }
      }
      if(flg){
        break;
      }
    }
    System.out.println(answer);
        
    

    
    
  }
  
  //最大公約数・最小公倍数（セットで使う）
static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
static int lcm (int a, int b) {return a*b/gcd(a,b);}


//素数判定
static boolean isPrime (int n) {
	if (n==2) return true;
	if (n<2 || n%2==0) return false;
	double d = Math.sqrt(n);
	for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
	return true;
}


//倍数判定（10進数以外のときに有用）
static boolean isMultiple (String s, int base, int m) {
	int temp = 0;
	for (int i=0; i<s.length(); i++) {
		temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
	}
	if (temp==0) {return true;}
	return false;
}


//階乗
static long factorial (int i) {
	if (i==1) {return 1;}
	else {return i*factorial(i-1);}
}


//進数変換
static String toNbase (String sm, int m, int n) {
	return Long.toString(Long.parseLong(sm,m),n);
}
  
}

Measured memory_bytes: 21844