akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int x, n; cin >> x >> n;
    if (n == 0) {cout << x << endl; return 0;}
    set<int> p;
    rep(i,n) {
        int x; cin >> x;
        p.insert(x);
    }
    int ans;
    int tmp = inf;
    for (int i = 0; i <= 1000; i++) {
        if (p.count(i)) continue;
        if (chmin(tmp,abs(i-x))) ans = i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
import java.util.Arrays

object Main extends App {
  val n = io.StdIn.readInt
  val score = Iterator.continually(io.StdIn.readInt)
    .take(n)
    .toArray
  
  Arrays.sort(score)

  val ans = {
    val sum = score.sum
    if(sum % 10 != 0) sum
    else {
      val a = score.find(_ % 10 != 0)
      val min = a match {
        case Some(x) => x
        case None => 0
      }
      if(min == 0) 0 else sum - min
    }
  }

  println(ans)
}

Measured memory_bytes: 27192
#include <stdio.h>
int main(){
    int x = 1, y = 1, s;
    while (1) {
        scanf("%d %d", &x, &y);
        if(x == 0 && y == 0) break;
        if(x > y){
            s = x;
            x = y;
            y = s;
        }
        printf("%d %d\n", x, y);
    }
    return 0;
}

Measured memory_bytes: 600
#include <iostream>

int main() {
  // 入力
  int payment, one_yen_num;
  std::cin >> payment >> one_yen_num;

  // 計算
  int required_one_yen_num = payment % 500;
  std::string ans;
  if (one_yen_num >= required_one_yen_num) {
    ans = "Yes";
  } else {
    ans = "No";
  }

  // 出力
  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int n, a, b;
vector<int> h;

bool f(int m){
    int cnt = 0;
    vector<int> t = h;
    rep(i, 0, n){
        t[i] -= m * b;
        if(t[i] > 0){
            cnt += (t[i] + a - b - 1) / (a - b);
        }
    }
    return cnt <= m;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> a >> b;
    h.resize(n, 0);
    rep(i, 0, n){
        cin >> h[i];
    }
    int l = 0, r = 1e9;
    rep(i, 0, 100){
        int mid = (l + r) / 2;
        if(f(mid)) r = mid;
        else l = mid;
    }
    cout << r << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;

int main()
{
    string s;
    cin >> s;
    int N=s.size();
    int ans=0;
    for(int i=0; i<N/2; i++){
        if(s[i]!=s[N-1-i]) ans++;
    }
    cout << ans << endl;




    return 0;
}

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

using namespace std;

typedef long long ll;

ll dp[202][202];
ll MOD=1000000007;

int main(void){

  int n;
  cin >> n;

  char c[202];

  for(int i=0;i<n;i++)cin >> c[i];

  dp[0][0]=1;

  for(int k=0;k<n;k++){
    for(int i=0;i<=k;i++){
      if(c[k]=='-')dp[k+1][i]=dp[k][i];
      else if(c[k]=='D'){
        if(i>0){
          dp[k+1][i-1]+=dp[k][i]*i*i;
          dp[k+1][i-1]%=MOD;
        }
        dp[k+1][i]+=dp[k][i]*i;
      }
      else if(c[k]=='U'){
        dp[k+1][i]+=dp[k][i]*i;
        dp[k+1][i+1]+=dp[k][i];
        dp[k+1][i+1]%=MOD;
      }
      dp[k+1][i]%=MOD;
    }
  }
  cout << dp[n][0] << endl;

  return 0;
}

Measured memory_bytes: 1472
'''
INPUT SHORTCUTS
N, K = map(int,input().split())
N ,A,B = map(int,input().split())
string = str(input())
arr = list(map(int,input().split()))
N = int(input())
'''
N = int(input())
arr = list(map(int,input().split()))
add = 1000000
cnt = 0
for i in range(N):
	if add>arr[i]:
		cnt+=1
		add = arr[i]
print(cnt)


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

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

using namespace std;

const int inf = 2e9;

int n;
int f[100];
int p[100][11];

int pop(int v){
    int x = 0;
    for(int i = 0; i < 10; ++i){
        x += (v >> i) & 1;
    }
    return x;
}

int main(){
    cin >> n;
    rep(i, n){
        rep(j, 10){
            int x;
            cin >> x;
            f[i] += x << j;
        }
    }
    rep(i, n){
        rep(j, 11){
            cin >> p[i][j];
        }
    }
    int ans = -inf;
    rep(i, 1 << 10){
        if (i == 0){
            continue;
        }

        int x = 0;
        rep(j, n){
            x += p[j][pop(i & f[j])];
        }

        ans = max(ans, x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N,T = [int(i) for i in input().split()]
ts = [int(i) for i in input().split()]
#ret = 0
# for ind in range (1, N):
#     ret += min(T,ts[ind]-ts[ind-1])
# for diff in [ts[ind+1]-ts[ind] for ind in range(N-1)]:
#     ret += T if T<diff else diff
ret = sum([min(T, ts[ind+1]-ts[ind]) for ind in range(N-1)])
print(ret+T)


Measured memory_bytes: 25200
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int x = Integer.parseInt(str[0]);
    int a = Integer.parseInt(str[1]);
    int b = Integer.parseInt(str[2]);
    System.out.println(Math.abs(x-a)>Math.abs(x-b)?"B":"A");
  }
}

Measured memory_bytes: 32504
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		string s;
		cin>>s;
		int n = s.size();
		if(n&1){
			return cout<<"No",0;
		}
		for(int i =0 ;i < n ;i++){
			if(i&1){
				if(s[i]!='i')return cout<<"No",0;
			}
			else{
				if(s[i]!='h')return cout<<"No",0;
			}
		}
		cout<<"Yes";
	
	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 256
input = gets.chomp.split(" ").map{ |v| v.to_i }
n = input[0]
t = input[1]

min = 1001
for i in 1..n
    input = gets.chomp.split(" ").map{ |v| v.to_i }
    next if input[1] > t
    min = input[0] if input[0] < min
end

if min > 1000
    puts 'TLE'
else
    puts min
end

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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp=0;
vector<pair<ll,ll>> A;
vector<ll> B;
set<ll> S;
priority_queue<ll, vector<ll>, greater<ll>> Q;

signed main(){
    cin >> N;
    S.insert(0);
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        S.insert(a);
        A.push_back(make_pair(a, i));
    }
    sort(A.begin(), A.end());
    set<ll>::iterator itr=S.end();
    itr--;
    ll tmp1, tmp2;
    B.resize(N, 0);
    while(itr!=S.begin()) {
        tmp1 = *itr;
        ll id1 = lower_bound(A.begin(), A.end(), make_pair(tmp1, 0LL))-A.begin();
        ll id2 = A.end()-lower_bound(A.begin(), A.end(), make_pair(tmp1, 0LL));
        itr--;
        tmp2 = *itr;
        Q.push(A[id1].second);
        B[Q.top()] += (tmp1-tmp2)*id2;
        //cout << "B[" << A[id1].second << "]=" << (tmp1-tmp2) << " " << id2 << endl;
    }
    for(int i=0;i<N;i++) {
        cout << B[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 11928
# ABC063c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
s = [int(input()) for _ in range(n)]

s.sort()
ans = sum(s)
if ans % 10 != 0:
    print(ans)
    exit(0)
for i in s:
    if i % 10 != 0:
        ans -= i
        print(ans)
        exit(0)
print(0)


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

const int Max = 1001;
char s[Max],t[Max];
int main()
{
	cin >> s >> t;
	int len_s = strlen(s);
	int len_t = strlen(t);

	if(strcmp(s,t) == 0)     //比较S和t
		cout << "Yes";
	else
	{
		for(int j = len_s ; j > 0 ; j--)    //对s进行操作
		{
			char temp;
			temp = s[len_s - 1];
			for(int i = len_s - 1 ; i > 0 ; i--)
			{
				s[i] = s[i - 1];
			}
			s[0] = temp;

			if(strcmp(s,t) == 0)    //s与t比较
			{
				cout << "Yes";
				break;
			}
			else
			{
				if(j == 1)
					cout << "No";
			}
		}
	}
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
ll M=1e9+7;


class DS{
    public:
    vector<ll > parent;
    vector<ll > nodes;
    DS(ll n){
        parent.resize(n+1);
        nodes.resize(n+1);
        for(ll i=0;i<=n;i++){parent[i]=i;nodes[i]=1;}
    }
    void join(ll a,ll b){
        ll x=findparent(a),y=findparent(b);
        if(x==y)return;
        parent[x]=y;
        nodes[y]+=nodes[x];
    }
    ll findparent(ll a){
        if(a==parent[a])return a;
        parent[a]=findparent(parent[a]);
        return parent[a];
    }
 };
 
 
int main()
{
	ll n,m;
	cin>>n>>m;
	map<pair<ll,ll> ,ll > map1;
	DS ds(n);
	for(ll i=1;i<=m;i++){
		ll a,b;
		cin>>a>>b;
		if(a>b) swap(a,b);
		if(map1.find({a,b})==map1.end()){
			ds.join(a,b);
		}
		map1[{a,b}]=1;
	}
	
	ll ans=1;
	for(ll i=1;i<=n;i++){
		ans=max(ans,ds.nodes[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 18816
n = int(input())
s = [input() for _ in range(n)]

s_dict = dict()
s_max = 0

for i in s:
    if i not in s_dict:
        s_dict[i] = 1
        s_max = max(s_max, s_dict[i])
    else:
        s_dict[i] += 1
        s_max = max(s_max, s_dict[i])

ans = list()
for k, v in s_dict.items():
    if v == s_max:
        ans.append(k)

ans.sort()
for i in ans:
    print(i)


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

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

    int N;
    while (cin >> N, N) {
        V L(N);
        VV want(N, V(16, 0));
        rep(i, N) {
            int M;
            cin >> M >> L[i];
            rep(j, M) {
                int s, t;
                cin >> s >> t;
                rep2(k, s, t) want[i][k - 6] = 1;
            }
        }

        V dp(1 << 16, 0);
        rep(s, 1 << 16) {
            rep(i, N) {
                bool ok = true;
                rep(j, 16) {
                    if ( ((s >> j) & 1) && want[i][j] ) {
                        ok = false;
                        break;
                    }
                }
                if (ok) {
                    int ns = s;
                    rep(j, 16) {
                        ns |= want[i][j] * (1 << j);
                    }
                    dp[ns] = max(dp[ns], dp[s] + L[i]);
                }
            }
        }

        cout << *max_element(all(dp)) << endl;
    }

}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pw(x) (1ll << (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl

//-----

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
  string s; cin >> s;
  cout << (((sz(s) & 1) ^ (s[0] == s[sz(s) - 1])) ? "First" : "Second");
  
	return 0;
}

Measured memory_bytes: 512
import java.util.*;
import java.util.stream.IntStream;

public class Main {

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

        int stickCounts = sc.nextInt();
        int stickJoinCounts = sc.nextInt();

        int sticks[] = IntStream
                .range(0, stickCounts)
                .map(v -> sc.nextInt())
                .boxed()
                .sorted(Comparator.reverseOrder())
                .mapToInt(Integer::new).toArray();

        int result = 0;

        for (int i = 0; i < stickJoinCounts; i++) {
            result += sticks[i];
        }

        System.out.printf(Integer.toString(result));
    }

}


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

using namespace std;
typedef long long ll;

vector<vector<int>> to;
vector<int> ans;

void dfs(int v, int p=-1) {
    for (int i = 0; i < to[v].size(); i++) {
        int u = to[v][i];
        if(u == p) continue;
        ans[u] += ans[v];
        dfs(u, v);
    }
}

int main() {
    int n, q; cin >> n >> q;
    to.resize(n);
    for (int i = 0; i < n-1; i++) {
        int a, b; cin >> a >> b; 
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }


    ans.resize(n);
    for (int i = 0; i < q; i++) {
        int p, x; cin >> p >> x;
        p--;
        ans[p] += x;
    }
    dfs(0);
    for (int i = 0; i < n; i++) {
        cout << ans[i] << " ";
    }
    cout << endl;


}


Measured memory_bytes: 23552
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main(){
    int n, k;
    vector<long long> v;
    long long h;
    cin >> n >> k;
    for(int i=0; i<n; i++){
        cin >> h;
        v.push_back(h);
    }
    if(k >= n){
      cout << 0 << endl;
      return 0;
    }

    long long att = 0;
    sort(v.begin(), v.end());
    for(int i=0; i<n-k; i++){
        att += v.at(i);
    }

    cout << att << endl;
    return 0;
}


Measured memory_bytes: 2420
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String inputString = scanner.next();

        String answer = "Yes";
        if (inputString.length() % 2 == 0) {
            answer = "No";
        } else {
            String firstPart = inputString.substring(0, inputString.length() / 2);
            String secondPart = inputString.substring((inputString.length() / 2) + 1);
            if (!firstPart.equals(secondPart)) {
                answer = "No";
            } else {
                char[] chars = firstPart.toCharArray();
                for (int i = 0; i < chars.length / 2; i++) {
                    if (chars[i] != chars[chars.length - (i + 1)]) {
                        answer = "No";
                        break;
                    }
                }
            }
        }

        System.out.println(answer);
    }
}

Measured memory_bytes: 23764
#include<stdio.h> 
int main(){ 
    int n,m,i,j; 
    int s[14]={0}; 
    int h[14]={0}; 
    int c[14]={0}; 
    int d[14]={0}; 
    char arf; 
    scanf("%d",&n); 
    for(i=0;i<n;i++){ 
        scanf(" %c %d",&arf,&m); 
        if(arf=='S'){ s[m]=1; } 
        if(arf=='H'){ h[m]=1; } 
        if(arf=='C'){ c[m]=1; } 
        if(arf=='D'){ d[m]=1; } } 
    for(i=0;i<4;i++){ 
        for(j=1;j<=13;j++){ 
            if(i==0){ if(s[j]==0){ printf("S %d\n",j); } } 
            if(i==1){ if(h[j]==0){ printf("H %d\n",j); } } 
            if(i==2){ if(c[j]==0){ printf("C %d\n",j); } } 
            if(i==3){ if(d[j]==0){ printf("D %d\n",j); } } } } 
            return 0; 
}


Measured memory_bytes: 2708
#include<stdio.h>

int main(){
  int S[100000],T[50000],n,q,i,l,m,r,count=0;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    scanf("%d",&S[i]);

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&T[i]);

    l=0;
    r=n;
    while(l<r){
    m=(l+r)/2;

    if(S[m]==T[i]){
      count++;
      break;
    }

    else if(S[m]<T[i])
      l=m+1;

    else
      r=m;
    }
  }

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

  return 0;
}
    



Measured memory_bytes: 2444
#include<iostream>
#include<vector>
#include<map>
#include<tuple>
#include<set>
#include<cmath>
#include<numeric>
#define ll long long
#define MOD = 1e9+7
 
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> a(N),c(N-1);
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  int ans=0;
  for(int i=0;i<N;i++){
    int b;
    cin >> b;
    ans+=b;
  }

  for(int i=0;i<N-1;i++){
    cin >> c[i];
  }

  for(int i=0;i<N-1;i++){
    if(a[i]+1==a[i+1]) ans += c[a[i]-1];
  }

  cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main()
{
    IOS

    int arr[4]={0};

    int n;
    cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        if(s=="AC")
            arr[0]++;
        if(s=="WA")
            arr[1]++;
        if(s=="TLE")
            arr[2]++;
        if(s=="RE")
            arr[3]++;

    }

    cout<<"AC x "<<arr[0]<<"\n";
    cout<<"WA x "<<arr[1]<<"\n";
    cout<<"TLE x "<<arr[2]<<"\n";
    cout<<"RE x "<<arr[3]<<"\n";


    return 0;
}


Measured memory_bytes: 3656
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
ArrayDequeではpopとpushはStackと同じ操作になる
//import static java.lang.System.*; はしばらく使わなそう(使うとしてもexit(0)のためだけ)←return;でよさそう
最後にout.flush()またはout.close()をするのを忘れずに！
*/
//入力終了→Ctrl+D
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        int[] a=new int[5];
        for (int i = 0; i < 5; i++) {
            a[i]=sc.nextInt();
        }
        int ans=Integer.MAX_VALUE;
        for (int i = 0; i < 5; i++) {
            int temp=0;
            for (int j = 0; j < 5; j++) {
                if(i==j){
                    temp+=a[j];
                }else {
                    int k=(10-a[j]%10);
                    if(k==10)k=0;
                    temp+=a[j]+k;
                }
            }
            ans=min(ans,temp);
        }
        out.println(ans);
        out.close();
    }

    static PrintWriter out = new PrintWriter(System.out);

    static class sc {
        static Scanner s = new Scanner(System.in);

        static String next() {
            return s.next();
        }

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

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

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

Measured memory_bytes: 23380
n=int(input())
a=sorted(list(map(int,input().split())))
mod=10**9+7
if n%2==1:
    if all([a[i]==2*((i+1)//2) for i in range(n)]):
        print((2**(n//2))%mod)
    else:
        print(0)
elif n%2==0:
    if all([a[i]==2*(i//2)+1 for i in range(n)]):
        print((2**(n//2))%mod)
    else:
        print(0)

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n;
  int ans = 0;
  cin>>n;
  while(n--){
    int l,r;
    cin>>l>>r;
    ans += r-l+1;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;
const ll INF = ll(1e18)+1;
const ll MAXN = 1e6;

int main()
{
    int n;
    cin>>n;
    int sum=0;
    int x[n];
    rep(i,n)
    {
        cin>>x[i];
        sum+=x[i];
    }

    sum=sum/n;
    int ans1=0;
    int ans2=0;
    rep(i,n)
    {
        ans1+=pow(abs(sum-x[i]),2);
    }
    sum+=1;
    rep(i,n)
    {
        ans2+=pow(abs(sum-x[i]),2);
    }
    cout<<min(ans1,ans2)<<endl;

}

Measured memory_bytes: 256
// https://teramonagi.hatenablog.com/entry/20130226/1361886714 参考 (というかソートするところまではほぼ丸パク)
#include <vector>
#include <algorithm>
#include <iostream>

//index-valueのペア

typedef std::pair<int,int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool greaterPair(const ipair& l, const ipair& r){return l.second > r.second;}
using namespace std;

int main(void) {

  int n;
  cin >> n;
  static const int MAX = 100000;
  vector<int> v_even(MAX, 0);
  vector<int> v_odd(MAX,0);
  
  for(int i = 0; i < n; ++i){
    int temp;
    cin >> temp;
    if(i%2 == 0){
      v_even[temp]++;
    } else {
      v_odd[temp]++;
    }
  }
  //インデックスと共にペアに突っ込む
  vector<ipair> even_pair;
  vector<ipair> odd_pair;
  for(int i = 0; i < MAX; i++){
    even_pair.push_back(ipair(i, v_even[i]));
    odd_pair.push_back(ipair(i, v_odd[i]));
  }
  
  //部分ソート、値の上位2位までは並び替え
  partial_sort(even_pair.begin(), even_pair.begin()+2, even_pair.end(), greaterPair);
  partial_sort(odd_pair.begin(), odd_pair.begin()+2, odd_pair.end(), greaterPair);

  int even_max1 = even_pair.begin() -> second;
  int el_even_max1 = even_pair.begin() -> first;
  int odd_max1 = odd_pair.begin() -> second;
  int el_odd_max1 = odd_pair.begin() -> first;

  int even_max2 = (even_pair.begin() + 1) -> second;
  int el_even_max2 = (even_pair.begin() + 1) -> first;
  int odd_max2 = (odd_pair.begin() + 1) -> second;
  int el_odd_max2 = (odd_pair.begin() + 1) -> first;

  if(el_even_max1 != el_odd_max1){
    cout << n - even_max1 - odd_max1 << endl;
  } else {
    int ans = min(n - even_max2 - odd_max1, n - even_max1 - odd_max2);
    cout << ans << endl;
  }
  
  return 0;
}

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

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


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)

//typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> divnum(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int keta(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p.size();
}

int N, P;
string S;
ll surp[1000000];
ll dp[1000000];
int main()
{
	cin >> N >> P;
	cin >> S;

	reverse(S.begin(), S.end());
	ll ans = 0;
	if (10 % P == 0) {
		rep(i, N) {
			if ((S[i] - '0') % P == 0) {
				ans += N - i;
			}
		}
		cout << ans << endl;
		return 0;
	}
	int X = 1;
	rep(i, N) {
		surp[i + 1] = (X * (S[i] - '0') + surp[i]) % P;
		//cout << S[i] << " " << X*S[i] << " " << surp[i + 1] << endl;
		X *= 10; X %= P;

	}
	dp[0] = 1;
	rep(i, N) {
		ans += dp[surp[i + 1]];
		dp[surp[i + 1]]++;
		//cout << S[i] << " " << surp[i + 1] << " " << dp[surp[i + 1]] << endl;
	}
	cout << ans << endl;

}

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

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

const string ddd= "Debug\n";
#define de_ar(arr,n) for(int i=0;i<n;i++)cout<<arr[i]<<" ";cout<<'\n';

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1; //cin>>t;
    while(t--)
    {
        ll n,k;
        cin>>n>>k;
        ll arr[n],dp[n];
        for(ll i=0;i<n;i++) cin>>arr[i];
        dp[0]=0;
        dp[1]=arr[1]-arr[0];
        for(ll i=1;i<n;i++)
        {
            dp[i]=INF;
            for(ll j=1;j<=min(i,k);j++)
            {
                dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
            }
        }
        cout<<dp[n-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 5128
#Insertion Sort
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A&lang=jp

n = int(input())
l = list(map(int,input().split()))
print (' '.join(map(str,l)))
for i in range(1,n):
    v = l[i]
    j = i -1
    while (j>=0 and l[j]>v ):
        l[j+1] = l[j]
        j -= 1
        l[j+1] = v
    print (' '.join(map(str,l)))



Measured memory_bytes: 5596
l, c = map(int, input().split())
tbl = [[] for _ in range(l)]
li_sum = [0 for _ in range(c+1)]

for i in range(l):
  a = input()
  tbl[i] = list(map(int, a.split()))
  print(a, end='')
  print(' ', sum(tbl[i]), sep ='')

  for j in range(c):
    li_sum[j] += tbl[i][j]
  li_sum[c] += sum(tbl[i])

print(' '.join(map(str, li_sum)))


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

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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define prvp(a) for(auto x : a) cout << "{" << x.ff << ',' << x.ss << "}";cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const int inf = 1e9;
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int bit32 = log2(inf) + 3;
const int bit64 = log2(INF) + 3;

inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}
inline int mul(int a, int b){return (int)((long long) a * b % mod);}
inline int modexpo(int a, int b){int res = 1; while(b > 0){ if(b & 1) res = mul(res, a); a = mul(a, a); b /= 2;} return res;}
inline int divide(int a, int b){ return mul(a, modexpo(b, mod - 2));}

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

void pre(){ // Reset each global variable (esp. for graphs)
  
}

const int N = 1e5 + 1;
const int K = 101;
int a[N], dp[N];

void solve(){
  int n, i, j, k;
  cin >> n >> k;
  for(i = 1; i <= n; i++){
    cin >> a[i];
    dp[i] = inf;
  }
  dp[1] = 0;
  for(i = 2; i <= n; i++){
    for(j = max(1, i - k); j < i; j++){
      dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
    }
  }
  cout << dp[n] << '\n';
}

int main(){
  fastio

  pre();

  int t = 1;
  // cin >> t;
  while(t--){
    solve();
  }

  ktj();
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin>>N;
  
  bool ans = false;
  
  for(int cake=0;cake<=N/4;cake++){
    if((N-cake*4)%7 == 0){
      ans = true;
      break;
    }
  }
  if(ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" <<endl;
  }
  
  return 0;
}

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

int main() {
  ll k, q; cin >> k >> q;
  ll d[k];
  for (ll i = 0; i < k; i++) {
    cin >> d[i];
  }
  for (ll i = 0; i < q; i++) {
    ll n, x, m; cin >> n >> x >> m;
    x = x%m;
    ll D = 0;
    ll num0 = 0;
    for (ll i = 0; i < k; i++) {
      D += (d[i]%m);
      if (d[i]%m == 0) {num0++;}
    }
    ll dsum = ((n-1)/k)*D;
    ll num = ((n-1)/k)*num0;
    for (ll i = 0; i < ((n-1)%k); i++) {
      dsum += (d[i]%m);
      if (d[i]%m == 0) {num++;}
    }
    
    cout << n-1-((dsum+x)/m)-num << endl;
  }
}

Measured memory_bytes: 384
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    m = I()
    s,d = 0,0
    for i in range(m):
        a,b = LI()
        s += b
        d += a*b
    print(s-1+(d-1)//9)
    return

#Solve
if __name__ == "__main__":
    solve()


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t1, t2, t3, t4;
    cin >> t1 >> t2 >> t3 >> t4;
    cout << max({t1 * t3, t1 * t4, t2 * t3, t2 * t4});
    return 0;
}


Measured memory_bytes: 3648
#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<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

const lint MOD = pow(10, 9) + 7;

lint gcd(lint a, lint b) {
	//aとbの最大公約数を返す
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}

lint lcm(lint a, lint b) {
	//aとbの最小公倍数を返す
	return a / gcd(a, b) * b;
}

/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/


int main() {
	string S;
	cin >> S;
	int Z = S.size();
	rep(i, Z-1) {
		if (S[i] == 'A' && S[i + 1] == 'C') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  string s, t;
  cin >> s >> t;
  unordered_map<char, char> mps, mpt;

  for (int i = 0; i < s.size(); ++i) {
    if (mps.count(s[i]) == 0)
      mps[s[i]] = t[i];
    else if (mps[s[i]] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
    if (mpt.count(t[i]) == 0)
      mpt[t[i]] = s[i];
    else if (mpt[t[i]] != s[i]) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 776
import java.util.Scanner;

public class Main {
  
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int S = scan.nextInt();
    int W = scan.nextInt();
    
    if(W-S >= 0) {
      System.out.println("unsafe");
    }
    else {
      System.out.println("safe");
    }
    scan.close();
  }
}

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



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

    string S,T;
    cin>>S>>T;

    map<char,char> m;
    rep(i,S.size()){
        m[S[i]]=T[i];
    }
    rep(i,S.size()){
        if(m[S[i]]!=T[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    for(char i='a';i<'z';i++){
        for(char j=i+1;j<='z';j++){
            if(m[i]-0==0) continue;
            if(m[i]==m[j]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;



}


Measured memory_bytes: 916
def binary_search(lst, key):
    left, right = 0, len(lst)

    while left < right:
        mid = (left+right) // 2
        if lst[mid] == key:
            return mid
        elif lst[mid] > key:
            right = mid
        else:
            left = mid + 1

    return None


def main():
    n = int(input())
    s = list(map(int, input().split()))
    q = int(input())
    t = list(map(int, input().split()))

    cnt = 0
    for i in range(q):
        if binary_search(s, t[i]) is not None:
            cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()



Measured memory_bytes: 16716
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>

typedef long long ll;

using namespace std;

int main(void) {
    int X, A;
    cin >> X >> A;
    if (X < A)
        cout << 0 << endl;
    else    
        cout << 10 << endl;
}

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 200000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	ll cost;
	edge(int _t, ll _cost) : t(_t)
		, cost(_cost) {
	}
};
bool isPrime(int n) {

	if (n == 1) return false;
	for (ll i = 2; i * i <= n; i++)
	{
		if (n % i == 0) return false;
	}
	return true;
}
int anyDigitSum(int n) {
	int res = 0;
	while (n > 0)
	{
		res += n % 10;
		n /= 10;
	}
	return res;
}

void Solve() {

	string s;
	cin >> s;
	int res = 0;
	for (size_t i = 0; i < s.size(); i++)
	{
		res += s[i] == '1';
	}
	cout << res;
	cout << endl;
}
int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int P = 1000000007;
int main() {
    int s;
    cin >> s;

    int dp[2001] = {};
    dp[0] = 1;

    for (int i = 3; i <= s; i++) {
        dp[i] = (dp[i - 1] + dp[i - 3]) % P;
    }

    cout << dp[s] << endl;

    return 0;
}


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

#define int long long
#define ff first
#define ss second
#define loop(i,k,n) for(int i=k;i<n;++i)
#define rloop(i,n,k) for(int i=n;i>=k;i--)
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpii vector<pair<int,int> >
#define all(v) v.begin(),v.end()
#define mset(a,i) memset(a,i,sizeof(a))
#define mii map<int,int>  
#define pii pair<int,int>
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define mp make_pair
#define pb push_back
#define mod 1000000007  
#define endl "\n"
#define inf 1e18

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { if(0) return; cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args){   
    if(0) return; 
    const char* comma = strchr (names + 1, ',');
    cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}
void get_it_done(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
int gcd(int a,int b){
    if(b==0) return a;
    if(a<b) return gcd(b,a);
    return gcd(b,a%b);
}
const int N = 3e5+5;

int32_t main(){
    get_it_done();
    int q=1;
    // cin >> q;
    while (q--){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        bool flag = 1;
        while(a>0 && c>0){
            if(flag){
                c-=b;
                flag = 0;
            }else{
                a -= d;
                flag = 1;
            }
        }
        if(flag){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }

        
    }
}


Measured memory_bytes: 3652
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()

using namespace std;

namespace Dump {
#define dump(...) Dump::print(#__VA_ARGS__, __VA_ARGS__)
static std::vector<string> dumpKey;
static string dumpKeyBuf;

void print() { cerr << endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
  if (dumpKey.empty()) {
    dumpKeyBuf = head;
    dumpKeyBuf.erase(std::remove_if(dumpKeyBuf.begin(), dumpKeyBuf.end(),
                                    [](char c) { return c == ' '; }),
                     dumpKeyBuf.end());

    std::istringstream stream(dumpKeyBuf);
    string field;
    while (std::getline(stream, field, ','))
      dumpKey.push_back(field);

    reverse(dumpKey.begin(), dumpKey.end());
  } else {
    cerr << dumpKey.back() << ":" << head << "  ";
    dumpKey.pop_back();
  }
  Dump::print(std::move(tail)...);
}
}

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef vector<unsigned long long> vull;
typedef pair<int, int> pii; // p.first p.second

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(long long N, vector<long long> t, vector<long long> x,
           vector<long long> y) {
  ll preT = 0;
  ll preX, preY;
  preX = preY = 0;

  REP(i, N) {
    ll diffT = t[i] - preT;
    ll diffP = abs(preX - x[i]) + abs(preY - y[i]);
    dump(t[i], preT, preX, preY, x[i], y[i], diffT, diffP);
    if (diffP <= diffT && abs(diffP - diffT) % 2 == 0) {
    } else {
      cout << "No" << endl;
      return;
    }
    preT = t[i];
    preX = x[i];
    preY = y[i];
  }
  cout << "Yes" << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  vector<long long> t(N - 1 + 1);
  vector<long long> x(N - 1 + 1);
  vector<long long> y(N - 1 + 1);
  for (int i = 0; i <= N - 1; i++) {
    cin >> t[i];
    cin >> x[i];
    cin >> y[i];
  }
  solve(N, t, x, y);
  return 0;
}


Measured memory_bytes: 4992
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

template<class T>
void print(const T &value) {
    std::cout << value << std::endl;
}

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);


//番号ズレ注意！！
int main() {
    int K, S, ans = 0;
    cin >> K >> S;
    REP(X, K + 1) {
        REP(Y, K + 1) {
            int Z = S - X - Y;
            if (Z >= 0 && Z <= K) { ans += 1; }
        }
    }
    print(ans);
}


Measured memory_bytes: 256
N, K = tuple(map(int, input().split()))
arr = list(map(int, input().split()))

left = 0
for i in range(N):
    for j in range(i+1, N):
        if arr[i] > arr[j]:
            left+= 1

right = 0
for i in range(N-1,-1,-1):
    for j in range(i-1,-1,-1):
        if arr[i] > arr[j]:
            right+= 1

print(((left * K*(K+1) // 2) + (right * K*(K-1)//2)) % (1000000007))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
// const ll MOD=998244353;

int u[2020][2020],d[2020][2020],r[2020][2020],l[2020][2020];
int A[2020][2020];

int main(){
  int H,W; cin>>H>>W;
  rep(i,H){
    string S; cin>>S;
    rep(j,W) A[i][j]=(S[j]=='#');
  }
  rep(j,W){
    rep(i,H){
      if(A[i][j]==1){
        u[i+1][j]=0;
      }else{
        u[i+1][j]=u[i][j]+1;
      }
    }
  }
  rep(j,W){
    for(int i=H-1;i>=1;i--){
      if(A[i][j]==1){
        d[i-1][j]=0;
      }else{
        d[i-1][j]=d[i][j]+1;
      }
    }
  }
  rep(i,H){
    rep(j,W){
      if(A[i][j]==1){
        l[i][j+1]=0;
      }else{
        l[i][j+1]=l[i][j]+1;
      }
    }
  }
  rep(i,H){
    for(int j=W-1;j>0;j--){
      if(A[i][j]==1){
        r[i][j-1]=0;
      }else{
        r[i][j-1]=r[i][j]+1;
      }
    }
  }
  int ans=0;

  rep(i,H) rep(j,W){
    if(A[i][j]) continue;
    ans=max(ans,u[i][j]+d[i][j]+l[i][j]+r[i][j]+1);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 79744
n,m = map(int, input().split())
l = [[] for _ in range(n)]
for _ in range(m):
  a,b = map(lambda i: int(i)-1, input().split())
  l[a].append(b)
  l[b].append(a)

for i in l[0]:
  if n-1 in l[i]:
    print("POSSIBLE")
    exit()
print("IMPOSSIBLE")

Measured memory_bytes: 41900
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <bitset>
#define N 82
#define M 512512
using namespace std;

int a[N][N], b[N][N];
bitset<M * 2> f[N][N];

int main(void)
{
    int n, m;
    int i, j;

    scanf("%d %d", &n, &m);
    // cout<<sizeof(f)/1024/1024<<endl;
    for(i = 1; i <= n; i ++)
        for(j = 1; j <= m; j ++)
            scanf("%d", &a[i][j]);
    for(i = 1; i <= n; i ++)
        for(j = 1; j <= m; j ++)
            scanf("%d", &b[i][j]);

    f[0][1][M] = true;
    for(i = 1; i <= n; i ++)
        for(j = 1; j <= m; j ++)
        {
            f[i][j] = f[i - 1][j] | f[i][j - 1];
            f[i][j] = (a[i][j] - b[i][j] < 0 ? f[i][j] >> (-(a[i][j] - b[i][j])) : f[i][j] << (a[i][j] - b[i][j])) | (b[i][j] - a[i][j] < 0 ? f[i][j] >> (-(b[i][j] - a[i][j])) : f[i][j] << (b[i][j] - a[i][j]));
        }
    for(i = 0; !f[n][m][M + i] && !f[n][m][M - i]; i ++)
        ;
    printf("%d\n", i);

    return 0;
}


Measured memory_bytes: 822272