akhauriyash/Code-Regression huggingface dataset:
import Control.Monad
import Data.Array

main = do
  li <- getLine
  let n = read li
  xyss <- forM [1..n] (\_ -> do
    li <- getLine
    let k = read li
    forM [1..k] (\_ -> do
      li <- getLine
      let [x,y] = map read $ words li
      return (x,y)
      )
    )
  let ans = compute n xyss
  print ans

{-
全員分の正直1/不親切0の組み合わせを生成し、矛盾が生じないものの、
正直者の最大数を返す、で時間は間に合うだろうか？
ようは、不親切とラベルされた人の発言を除いたセットが矛盾しなければよい。
-}

compute :: Int -> [[(Int,Int)]] -> Int
compute n xyss = maximum $ map (check1 n xyss) $ sequence (replicate n [True,False])

{- 一つの設定について判定し、矛盾がなければ人数、あれば0を返す -}
check1 :: Int -> [[(Int,Int)]] -> [Bool] -> Int
check1 n xyss bs = if result then ts else 0
  where
    ba = listArray (1, n) bs
    xys = [xy | (xys, b) <- zip xyss bs, b, xy <- xys]
    f (x,1) = ba ! x
    f (x,0) = not (ba ! x)
    result = all f xys
    ts = length $ filter id bs


Measured memory_bytes: 4220
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = {False: 'No', True: 'Yes'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def main():
    N = I()
    abc = [[0, 0, 0]] * N
    dp = [0] * 3
    dp[0] = 0

    for i in range(N):
        abc[i] = LI()

    for i in range(N):
        dp_next = [0] * 3
        for k in range(3):
            dp_next[k] = max(dp_next[k], dp[k])
            for j in range(3):
                if j != k:
                    dp_next[j] = max(dp[k] + abc[i][j], dp_next[j])
        dp = dp_next
        # print(dp_next)

    print(max(dp))


if __name__ == '__main__':
    main()


Measured memory_bytes: 53720
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,X;
  cin>>N>>X;
  vector<int> L(N);
  for(int i=0;i<N;i++)cin>>L[i];
  int ans=1;
  int now=0;
  for(int i=0;i<N;i++){
    now+=L[i];
    if(now<=X)ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
from itertools import permutations

N,M = list(map(int, input().split()))
S = set([])
for _ in range(M):
    A,B = list(map(int, input().split()))
    S.add((A,B))
    S.add((B,A))
count = 0
node = [i for i in range(1,N+1)]
lis = list(permutations(node))

for v in lis:
    flag = 0
    if v[0] != 1:
        continue
    for i in range(N-1):
        if (v[i],v[i+1]) in S:
            continue
        else:
            flag += 1
    if flag == 0:
            count += 1

print(count)

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

using namespace std;

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define INF 1000000007
#define ull unsigned long long
#define PI 3.141592653589793238
#define pb push_back
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))
#define mp make_pair
#define pre(a,b) cout << fixed << setprecision(a) << b  //a for precision b for answer
#define MAX 1e18
#define all(x) (x).begin(), (x).end()
#define lb lower_bound //lower_bound(first_iterator, last_iterator, x) – returns an iterator pointing to the first element in the range [first,last) which has a value not less than ‘x’.
#define ub upper_bound //upper_bound(first_iterator, last_iterator, x) – returns an iterator pointing to the first element in the range [first,last) which has a value greater than ‘x’.
#define maxe *max_element
#define mine *min_element
#define acc(x) accumulate(x.begin(), x.end(), 0)
#define dst distance
#define sz(x) (int)x.size()

ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y % 2 == 0) 
        return power(x, y / 2) * power(x, y / 2); 
    else
        return x * power(x, y / 2) * power(x, y / 2); 
}

ll SieveOfEratosthenes(int n) 
{  
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    {  
        if (prime[p] == true) 
        {   
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    /*for (int p=2; p<=n; p++) 
       if (prime[p]) 
          cout << p << " "; */
    return prime[n + 1];
}

int main()
{
    IOS;
    int n;
    cin >> n;
    double p[n];
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    double dp[n][n + 1];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1 - p[0];
    dp[0][1] = p[0];
    for (int i = 1; i < n; i++)
    {
        dp[i][0] = dp[i - 1][0] * (1 - p[i]);
        for (int j = 1; j <= i + 1; j++)
        {
            dp[i][j] = (dp[i - 1][j - 1] * p[i]) + (dp[i - 1][j] * (1 - p[i]));
        }
    }
    double sum = 0.0;
    for (int i = n/2 + 1; i <= n; i++)
    {
        sum += dp[n - 1][i];
    }
    pre(12, sum);
    return 0;
}

Measured memory_bytes: 70528
fn main() {
    let vec_num : Vec<i64> = read_vec();

    let m = vec_num[0];
    let n = vec_num[1];

    let mut ans : i64 = 0;
    // 最初がEven
    // 次がEven
	for x in 2..m+1 {
		ans += x-1;
	}

    // 最初がOdd
    // 次がOdd
	for x in 2..n+1 {
		ans += x-1;
	}

    println!("{}", ans );
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define MAXN 100005
#define INF int(1e9)
#define dis(l,r) (x[r] - x[l])
#define LL long long
using namespace std;

int N,L,Q;
LL x[MAXN];

int dp[MAXN][21];

void init(){
	
	int p = 1;
	for(int i=1;i<=N;i++){
		while(p+1<=N && dis(i,p+1)<=L) ++p;
		
		dp[i][0] = p;
	}
	
	for(int j=1;j<=20;j++){
		for(int i=1;i<=N;i++){
			dp[i][j] = dp[dp[i][j-1]][j-1];
		}
	}
}

int walk(int s, int t){
	int ans = 0;
	for(int j=20;j>=0;j--){
		if(dp[s][j] && dp[s][j] < t){
			ans += (1<<j);
			s = dp[s][j];
		}
	}
	return ans + 1;
}

int main(){
	
	cin>>N;
	
	for(int i=1;i<=N;i++){
		cin>>x[i];
	}	
	
	cin>>L>>Q;
	
	init();
	
	int s,t;
	while(Q--){
		cin>>s>>t;
		if(s > t) swap(s,t);
		cout<<walk(s,t)<<endl;
	}
	return 0;
}



Measured memory_bytes: 9856
a, b, c, d = map(int, list(input()))

for op1 in ["+", "-"]:
    for op2 in ["+", "-"]:
        for op3 in ["+", "-"]:
            total = a
            if op1 == "+":
                total += b
            else:
                total -= b
            if op2 == "+":
                total += c
            else:
                total -= c
            if op3 == "+":
                total += d
            else:
                total -= d
            if total == 7:
                print(a, op1, b, op2, c, op3, d, "=7", sep="")
                quit()


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

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

    int n, k;
    cin >> n >> k;

    vector<int64_t> s(n + 1), t(n + 1);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        s[i + 1] = s[i] + a;
        t[i + 1] = t[i] + (a < 0 ? 0 : a);
    }

    int64_t r = 0;
    for (int i = 0; i <= n - k; i++) {
        int64_t u = max(s[i + k] - s[i], (int64_t)0);
        u += t[i] - t[0];
        u += t[n] - t[i + k];
        r = max(r, u);
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-

import sys
import os


def max_seq(A):
    s = []
    s.append(A[0])
    for i in range(1, len(A)):
        v = max(A[i], A[i] + s[i-1])
        s.append(v)
    return max(s)

while True:
    s = input().strip()
    if s == '0':
        break

    N = int(s)
    A = []
    for i in range(N):
        v = int(input())
        A.append(v)

    print(max_seq(A))

Measured memory_bytes: 7800
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

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

signed main()
{
    int n;
    cin >> n;
    vector<int> a, b, c;
    rep(i, n)
    {
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    rep(i, n)
    {
        int tmp;
        cin >> tmp;
        b.push_back(tmp);
    }
    rep(i, n)
    {
        int tmp;
        cin >> tmp;
        c.push_back(tmp);
    }
    sort(a.begin(), a.end(), greater<int>());
    sort(b.begin(), b.end(), greater<int>());
    sort(c.begin(), c.end(), greater<int>());

    vector<int> n_use_b(n, 0);
    int index = 0;
    for (int i = 0; i < b.size(); i++)
    {
        while (index <= n && c[index] > b[i])
        {
            index++;
        }
        n_use_b[i] = index;
    }

    index = 0;
    int pre = 0;
    vector<int> n_use_a(n, 0);
    for (int i = 0; i < a.size(); i++)
    {
        while (index <= n && b[index] > a[i])
        {
            index++;
        }
        n_use_a[i] = index;
    }

    int ans = 0;
    vector<int> n_ans(n, 0);
    for (int j = 0; j < n_use_a[0]; j++)
    {
        ans += n_use_b[j];
    }
    n_ans[0] = ans;

    for (int i = 0; i < n - 1; i++)
    {
        n_ans[i + 1] += n_ans[i];
        for (int j = n_use_a[i]; j < n_use_a[i + 1]; j++)
        {
            n_ans[i + 1] += n_use_b[j];
        }
        ans += n_ans[i + 1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 5108
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a >= 13){
        cout << b << endl;
    }else if(a >= 6 && a <= 12){
        cout << b / 2 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    string N; cin >> N;

    if(N[N.size()-1]=='3') cout << "bon" << endl;
    else if (N[N.size() - 1] == '0' or N[N.size() - 1] == '1' or N[N.size() - 1] == '6' or N[N.size() - 1] =='8'){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }

        return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <cmath>
#include <math.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++) 
int main(void){
    int n;
    int y;
    cin>>n>>y;
    int max_man=y/10000;
    FOR(i,max_man+1){
        int max_sen=(y-10000*i)/5000;
        FOR(j,max_sen+1){
            int nokori=(y-10000*i-5000*j)/1000;
            if(n-i-j==nokori){
                cout<<i<<" "<<j<<" "<<nokori<<"\n";
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1"<<"\n";
    return 0;
    
}


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

int main() {
  int n,x,y,z;
  cin>>n;
  vector<long int> a(n);
  x=y=z=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]%4==0)x++;
    if(a[i]%4==2)y++;
    if(a[i]%2==1)z++;
  }
  if(z-1>x || (z-1==x && y>0))cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int H, W, h, w;

  cin >> H >> W >> h >> w;

  cout << (H - h) * (W - w) << endl;

  return 0;
}


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

#define fi first
#define se second
#define mk(a,b) make_pair(a,b)

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

int N;
int A[100010];

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

    ll l = 0, r = 1000000001;
    int ans = 10;
    for(int i = 0; i < 100; i++)
    {
        int mid = (l + r) / 2;
        ll tmp[100010];
        for(int j = 0; j < N; j++)tmp[j] = A[j];
        tmp[0] -= mid;
        tmp[1] -= mid;
        for(int j = 1; j < N - 1; j++)
        {
            tmp[j + 1] -= tmp[j];
            tmp[j] = 0;
        }
        if(tmp[0] == tmp[N - 1])
        {
            ans = mid;
            break;
        }
        if(tmp[0] < tmp[N - 1])r = mid;
        if(tmp[0] > tmp[N - 1])l = mid;
    }

    vector<int> V;
    V.push_back(ans * 2);
    A[0] -= ans;
    A[1] -= ans;
    for(int i = 1; i < N - 1; i++)
    {
        V.push_back(A[i] * 2);
        A[i + 1] -= A[i];
        A[i] -= A[i];
    }
    V.push_back(A[N - 1] * 2);

    for(int i = 0; i < N; i++)
    {
        cout << V[(i - 1 + N) % N];
        if(i != N)cout << " ";
    }
    cout << endl;
    return 0;
}




Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bits/stdc++.h>
#include <array>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int main(int argc, const char * argv[]) {
    // source code
    int n;
    cin >> n;
    repd(i, 1, 10) repd (j, 1, 10) if (n == i * j) {
        cout << "Yes";
        return 0;
    }
    cout << "No";
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

string S;
    ll rCnt[500010]={};
    ll lCnt[500010]={};
int main(){
    cin>>S;
    lCnt[0]=0;
    for(ll i=1;i<=S.length();i++){
        if(S[i-1]=='<'){
            lCnt[i]=lCnt[i-1]+1;
        }else{
            lCnt[i]=0;
        }
    }
    rCnt[S.length()]=0;
    for(ll i=S.length()-1;i>=0;i--){
        if(S[i]=='>'){
            rCnt[i]=rCnt[i+1]+1;
        }else{
            rCnt[i]=0;
        }
    }
    ll ans=0;
    for(ll i=0;i<S.length()+1;i++){
        ans+=max({0ll,lCnt[i],rCnt[i]});
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8708
#include <cstdio>
#include <cstring>
#include <algorithm>
#include<iostream>
using namespace std;
int main(){
    int n,x,a1=0,a2=0,a4=0;
    scanf("%d\n",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&x);
        if(x%4==0) a4++;
        else if(x%2==0&&x%4!=0)a2++;
        else a1++;
    }
    if(a2==0&&a1<=a4+1)printf("Yes\n");
    else if(a2!=0&&a1<=a4)printf("Yes\n");
    else printf("No\n");
    return 0;
}

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

int main(){
		int n; cin>>n;
		vector<int> v(n);
		int check = 0;
		for(int i = 0 ; i < n ; i++){

				cin >> v.at(i);

			}

			
			
			for (int i=0; i<n-1 ; i++){
				if(v.at(i)!=(i+1)){
				int a = v.at(i);//5
			//	cout<<a<<endl;
				int b = a-1;//5-1 ha 4
			//	cout<<b<<endl;
				int c =v.at(a-1);//4banme ha 1 ;
			//	cout << c << endl;
				v.at(i)=c;
			//	cout << v.at(i)<<endl;
				

				v.at(b)=a;
			//cout << v.at(b)<<endl;
					break;
				}
			}
			for(int i =0 ;i<n-1;i++){//跡は順番通りになってるかみるだけ
					if(v.at(i)<v.at(i+1)){		
				//		cout<<"順番通りだよ"<<endl;
							}
					else if(v.at(i)>v.at(i+1)){
				//		cout<<"順番ごちゃごちゃやで"<<endl;
						check = 1;
						break;
					}
				}
			if(check==1){
				cout<<"NO"<<endl;
			}
			else if(check==0){
				cout<<"YES"<<endl;	
				}
	}





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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

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

	if (s[0] == s[1] || s[0] == s[2] || s[1] == s[2]) cout << "No" << endl;
	else cout << "Yes" << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func bsort(s []byte) (r string) {
	for i := 0; i < len(s); i++ {
		for j := 0; j < len(s)-i-1; j++ {
			if s[j] > s[j+1] {
				s[j+1], s[j] = s[j], s[j+1]
			}
		}
	}
	return string(s)
}

func bsortr(s []byte) string {
	for i := 0; i < len(s); i++ {
		for j := len(s) - 1; j-i > 0; j-- {
			if s[j] > s[j-1] {
				s[j], s[j-1] = s[j-1], s[j]
			}
		}
	}
	return string(s)
}

func main() {
	var s, t string
	fmt.Scan(&s)
	fmt.Scan(&t)
	if s == t {
		fmt.Println("No")
		return
	}
	ss := make([]string, 2)
	css := make([]string, 2)
	ss[0] = bsort([]byte(s))
	ss[1] = bsortr([]byte(t))

	copy(css, ss)
	sort.Strings(css)
	if css[0] == ss[0] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int main()
{
  long long N , K , A , B;
  cin >> N >> K ;
	
  A = K;
  B = N;
  
  if(N>K){
    A = (B/K);
    A = A *K;
    B = B-A;
    B = min(B,-1*(B-K));
    cout << B << endl;
  }
  else if(N==K)
    cout << 0 << endl;
  else{
    N = min(N,-1*(N-K));
    cout << N << endl;}
  
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int main(){
    int N; cin >> N;
    vector<int> x(N), y(N), h(N);
    rep(i,N) cin >> x[i] >> y[i] >> h[i];

    rep(cy,101){
        rep(cx,101){
            int H = -1;
            bool isOK = true;
            rep(i,N){
                if (h[i] > 0){
                    if (H == -1){
                        H = h[i] + abs(x[i]-cx) + abs(y[i]-cy);
                    }
                    else{
                        if (h[i] != H - abs(x[i]-cx) - abs(y[i]-cy)){
                            isOK = false;
                            break;
                        } 
                    }
                }
            }
            if(!isOK) continue;
            rep(i,N){
                if (h[i] == 0){
                    if (H - abs(x[i]-cx) - abs(y[i]-cy) > 0) {
                        isOK = false;
                        break;
                    }
                }
            }
            if (!isOK) continue;
            cout << cx << " " << cy << " " << H << endl;
            return 0;
        }
    }
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int H,W;
int sx,sy;
int bcnt;
bool field[7][7];
bool res = false;
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};

void solve(int nowx,int nowy,int ncnt){
  if(res) return;
  if(bcnt-1 == ncnt){
    for(int i=0;i<4;i++){
      int gx=nowx+dx[i],gy=nowy+dy[i];
      if(sx == gx && sy == gy){
	res = true;
	return;
      }
    }
  }
  int neigh_cnt = 0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(field[i][j]) continue;
      neigh_cnt = 0;
      for(int k=0;k<4;k++){
	int nx=j+dx[k],ny=i+dy[k];
	if(sx == nx && sy == ny) {
	  neigh_cnt++;
	  continue;
	}
	if(nowx == nx && nowy == ny){
	  neigh_cnt++;
	  continue;
	}
	if(nx>=0 && nx<W && ny>=0 && ny<H && field[ny][nx] == false){
	  neigh_cnt++;
	}
      }
      if(neigh_cnt == 1) {
	return;
      }
    }
  }
  for(int i=0;i<4;i++){
    int nx=nowx+dx[i],ny=nowy+dy[i];
    if(nx>=0 && nx<W && ny>=0 && ny<H && field[ny][nx] == false){
      field[ny][nx] = true;
      solve(nx,ny,ncnt+1);
      field[ny][nx] = false;
    }
  }
  return;
}

int main(){
  while(cin >> W >> H, H){
    res = false;
    bcnt = 0;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin >> field[i][j];
	if(!field[i][j]){
	  if(bcnt==0){
	    sx = j;
	    sy = i;
	  }
	  bcnt++;
	}
      }
    }
    if(bcnt % 2 == 1) cout << "No" << endl;
    else {
      bool flg = true;
      int neigh_cnt;
      for(int i=0;i<H;i++){
	for(int j=0;j<W;j++){
	  if(field[i][j]) continue;
	  neigh_cnt = 0;
	  for(int k=0;k<4;k++){
	    int nx = j+dx[k],ny = i+dy[k];
	    if(nx>=0&&nx<W&&ny>=0&&ny<H&&field[ny][nx] == false) {
	      neigh_cnt++;
	    }
	  }
	  if(neigh_cnt == 1){
	    flg = false;
	    break;
	  }
	}
	if(!flg) break;
      }
      if(!flg){
	cout << "No" << endl;
      } else {
	field[sy][sx] = true;
	solve(sx,sy,0);
	if(res) cout << "Yes" << endl;
	else cout << "No" << endl;
      }
    }
  }
}

Measured memory_bytes: 3084
#!/usr/bin/env pypy3

import math


def solve(n):
    res = 0
    for q in range(1, math.floor(math.sqrt(n)) + 1):
        m1, mo = divmod(n, q)
        if mo != 0 or m1 - q < 2:
            continue
        res += m1 - 1
    return res


def main():
    n = int(input())
    res = solve(n)
    print(res)


if __name__ == "__main__":
    main()

Measured memory_bytes: 38768
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    int ans1 = A * 100, ans2 = 0;
    rep(i, 31) {
        rep(j, 31) {
            int water = 100 * A * i + 100 * B * j;
            if(water > F) break;
            int limit = (water/100) * E;
            rep(s, 1501) {
                rep(t, 1501) {
                    int sugar = C * s + D * t;
                    if(water + sugar > F) break;
                    if(sugar > limit) break;
                    if(100 * sugar * (ans1 + ans2) > 100 * ans2*(sugar + water)) {
                        ans1 = water;
                        ans2 = sugar;
                    }

                }
            }
        }
    }
    cout << ans1 + ans2 << " " << ans2 << endl;

    return 0;
}
// 100b/(a + b) > 100B/(A + B)
// 100b(A + B) > 100B(a + b);

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,i;
    cin>>n;
    string s;
    cin>>s;
    vector<char> ch; 
    for (i=0;i<n;i++)
    {
        if (i==0)
            ch.pb(s[i]);
        else
        {
            if (s[i]!=ch[ch.size()-1])
                ch.pb(s[i]);
        }
    }
    cout<<ch.size();
}

Measured memory_bytes: 592
#include <algorithm>
#include <cassert>
#include <vector>

namespace atcoder {

// Implement (union by size) + (path compression)
// Reference:
// Zvi Galil and Giuseppe F. Italiano,
// Data structures and algorithms for disjoint set union problems
struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};

}  // namespace atcoder

using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, Q;
  cin >> N >> Q;
  dsu d(N);
  REP(q, Q) {
    int t, u, v;
    cin >> t >> u >> v;
    if(t == 0) d.merge(u, v);
    else {
      if(d.same(u, v)) cout << 1 << "\n";
      else cout << 0 << "\n";
    }
  }
}


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

int main(){
    int A,B,K;
    cin>>A>>B>>K;
    if(K>=static_cast<int>((B-A+2)/2)){
        for(int i=A;i<=B;i++){
            cout<<i<<endl;
        }
    }else {
        for(int i=A;i<A+K;i++){
        cout<<i<<endl;
        }
        for(int i=B-K+1;i<=B;i++){
            cout<<i<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define sbits(a) __builtin_popcount(a)
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000001
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

const int N = 3001;
int dp[N][N];

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s, t;
    cin >> s >> t;
    s = '.' + s;
    t = '.' + t;

    int i = 1, j;

    for (; i < s.ln; i++) {
        for (j = 1; j < t.ln; j++) {
            if (s[i] == t[j])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }

    i = s.ln - 1, j = t.ln - 1;
    string res;

    while (dp[i][j]) {
        while (dp[i][j] == dp[i - 1][j] && i > 0)
            --i;
        while (dp[i][j] == dp[i][j - 1] && j > 0)
            --j;
        res += s[i];
        --i, --j;
    }

    reverse(res.B, res.E);
    cout << res;

    return 0;
}


Measured memory_bytes: 35456
#include <cstdio>
#include <map>
#define mod ((ll)1e9+7)
using namespace std;
typedef long long ll;
ll N;
map<ll,ll> m;
ll f(ll n) {
	if (m[n]>0)
		return m[n];
	m[n]=((f(n/2)+f((n-1)/2))%mod+f((n-2)/2))%mod;
	return m[n];
}
int main() {
	scanf("%lld",&N);
	m[0]=1; m[1]=2;
	printf("%lld\n",f(N));
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		int count = 0;
		for (String cell : cells) {
			if (cell.equals("1")) {
				count++;
			}
		}
		System.out.println(count);
	}

	/**
	 * *汎用メソッド<br>
	 * 入力した配列に対する順列を取得
	 *
	 * @param numArray
	 * @return
	 */
	private static List<Integer[]> getPermutation(int[] numArray) {
		List<Integer[]> permutation = new ArrayList<>();
		Integer[] ans = new Integer[numArray.length];
		boolean[] used = new boolean[numArray.length];

		return buildPermutaion(permutation, numArray, ans, used, 0);
	}

	/**
	 * *汎用メソッド(内部)<br>
	 * 入力した配列に対する順列を作成
	 *
	 * @param list
	 * @param numArray
	 * @param ans
	 * @param used
	 * @param depth
	 * @return
	 */
	private static List<Integer[]> buildPermutaion(List<Integer[]> list, int[] numArray, Integer[] ans, boolean[] used,
			int depth) {

		// 全部使い切った時=>できた順列を返す
		if (depth == numArray.length) {
			list.add(ans.clone());
			return list;
		}
		// 使い切っていない場合

		for (int i = 0; i < numArray.length; i++) {
			if (used[i]) {
				continue;
			}
			ans[depth] = numArray[i];
			used[i] = true;
			list = buildPermutaion(list, numArray, ans, used, depth + 1);

			used[i] = false;
		}

		return list;
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}


Measured memory_bytes: 22740
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = input().rstrip()

    if (N[0] == '7') | (N[1] == '7') | (N[2] == '7'):
        print('Yes')
    else:
        print('No')



main()


Measured memory_bytes: 9120
import sys
line = list(map(lambda x: int(x), input().split(" ")))
a, b, c, k = line[0], line[1], line[2], line[3]
 
if a >= k:
  print(k)
  sys.exit(0)
 
tmp = k - a
if b >= tmp:
  print(a)
  sys.exit(0)
 
print(a - (k - a -b))

Measured memory_bytes: 9064
// https://atcoder.jp/contests/nikkei2019-2-qual/tasks/nikkei2019_2_qual_a
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, [ next / $t:tt ]) => {
        {
            let len = read_value!($iter, usize);
            (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: i32
    };

    println!("{}", (n-1)/2);
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, m, q;
string s[2000];
int a[2000][2000], sum[2001][2001] = {}, hor[2001][2001] = {}, ver[2001][2001] = {};

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> m >> q;
    forn(i, n) cin >> s[i];
    forn(i, n) forn(j, m) {
        a[i][j] = s[i][j] - '0';
        sum[i + 1][j + 1] = sum[i][j + 1] + sum[i + 1][j] - sum[i][j] + a[i][j];
    }
    forn(i, n) forn(j, m - 1) {
        hor[i + 1][j + 1] = hor[i + 1][j] + hor[i][j + 1] - hor[i][j] + (a[i][j] == 1 && 1 == a[i][j + 1]);
    }
    forn(i, n - 1) forn(j, m) {
        ver[i + 1][j + 1] = ver[i + 1][j] + ver[i][j + 1] - ver[i][j] + (a[i][j] == 1 && 1 == a[i + 1][j]);
    }
    forn(_, q) {
        int r, c, rr, cc;
        cin >> r >> c >> rr >> cc;
        --r, --c;
        int ans = sum[rr][cc] - sum[r][cc] - sum[rr][c] + sum[r][c];
//        cerr << ": " << ans << ' ';
        ans -= hor[rr][cc - 1] - hor[r][cc - 1] - hor[rr][c] + hor[r][c];
//        cerr << ans << ' ';
        ans -= ver[rr - 1][cc] - ver[rr - 1][c] - ver[r][cc] + ver[r][c];
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 68608
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        static void Main()
        {
            var S = Console.ReadLine();
            var sr = new string(S.Reverse().ToArray());

            var s1 = S.Substring(0, (S.Length - 1) / 2);
            var s1r = new string(s1.Reverse().ToArray());

            var s2 = S.Substring((S.Length + 1) / 2);
            var s2r = new string(s2.Reverse().ToArray());

            if (S == sr && s1 == s1r && s2 == s2r)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13268
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n, m; cin >> n >> m;
  int x[m], y[m];
  rep(i, m) {
    cin >> x[i] >> y[i];
    --x[i]; --y[i];
  }

  bool possible[n] = {};
  int cnt[n];
  fill(cnt, cnt + n, 1);
  possible[0] = true;

  rep(i, m){
    --cnt[x[i]]; ++cnt[y[i]];
    if (possible[x[i]]) possible[y[i]] = true;
    if (cnt[x[i]] == 0) possible[x[i]] = false;
  }
  int ans = 0;

  rep(i, n) ans += possible[i];
  print(ans);
  
  return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>

using namespace std;

int N;
int K;
int A[200000];
int x;

void solve()
{
	int res = 0;
	int e = x;
	sort(A, A + 200000, greater<int>());
	for (int i = e - 1; x > K && i >= 0; i--) {
		res += A[i];
		x--;
	}
	cout << res << endl;
}


int main()
{
	x = 0;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int t;
		cin >> t;
		x += A[t] ? 0 : 1;
		A[t]++;
	}
	solve();
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  if(N%2==1){
    cout << "No";
    return 0;
  }
  for(int i = 0; i < N/2; i++){
    if(S[i]!=S[N/2+i]){
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}

Measured memory_bytes: 256
import java.util.*;

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

        int N = sc.nextInt();
        int R = sc.nextInt();
        sc.nextLine();

        if(N >= 10){
            System.out.println(R);
        }else if(0 < N && N < 10){
            System.out.println(R + (100*(10-N)));
        }
        sc.close();
    }
}

Measured memory_bytes: 21844
#include <iostream>

int main() {
  int a, b, c;
  std::cin >> a >> b >> c;
  if (a + b == c || b + c == a || a + c == b) {
    std::cout << "Yes" << "\n";
  } else {
    std::cout << "No" << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Product Max
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

int main() {
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);

  printf("%lld\n", max(max((ll)a * c, (ll)b * d), max((ll)a * d, (ll)b * c)));

  return 0;
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
typedef long long ll;

int n;
int a[N];
ll ans;
ll ps[N];
map<ll, int> freq;

int main() {

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

    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        ps[i] = ps[i - 1] + a[i];
    }
    sort(ps, ps + n + 1);
    ans = 0;
    for(int i = 0; i <= n; i++) {
        ans += freq[ps[i]];
        freq[ps[i]]++;
    }
    cout << ans << "\n";
}

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

using namespace std;

string s, t;

int main() {
    //freopen("test.out", "w", stdout);
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++)
            if (s[i] != t[i]) {
                cout << "No" << endl;
                return 0;
            }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(ll (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

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

    REP(i, s.length()){
        if(s[i] == '?') s[i] ='D';
    }
    cout << s << endl;
}


Measured memory_bytes: 3756
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
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;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<long long> dp(110000);
    vector<long long> h(110000);
    const long long INF = 1LL << 60;
    rep(i, 110000) dp[i] = INF;
    dp[0] = 0;
    for(int i = 0; i < n; i++) {
        cin >> h[i];
    }
    for(int i = 0; i < n; i++) {
        for(int j = 1; j <= k; j++) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 5096
function main()
  n,k = parse.(Int,split(readline()))

  n_arr = zeros(n)

  for i in 1:k
    d = readline()
    for n_i in parse.(Int,split(readline()))
      n_arr[n_i] += 1
    end
  end
  println(count(iszero, n_arr))
end
main()


Measured memory_bytes: 175892