akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE FlexibleContexts #-}

import Control.Applicative
import Control.Monad.ST
import Control.Monad.State
import Control.Monad
import Data.Array.ST
import Data.Array.IO
import Data.List
import Data.Array
import qualified Data.Set as Set

type Node = Int
type Cost = Int
type Edge = (Node, Cost)
type Graph = Array Node [Edge]
type Route = [Edge]

inf = maxBound :: Int

dijkstra :: Graph -> Node -> Array Node Cost
dijkstra graph start = runST $ do
  cost <- newArray (bounds graph) inf :: ST s (STUArray s Node Cost)
  check <- newArray (bounds graph) False :: ST s (STUArray s Node Bool)
  writeArray cost start 0
  evalStateT (dijkstra' cost check) (Set.singleton (0, start))
  freeze cost
  where
    dijkstra' cost check = do
      isNull <- Set.null <$> get
      when (not $ isNull) $ do
        (curCost, cur) <- state Set.deleteFindMin
        let nextNodes = graph ! cur

        lift $ writeArray check cur True

        forM_ nextNodes $ \(next, edgeCost) -> do
          nextCost <- lift $ readArray cost next
          
          if nextCost == -1 then do
            lift $ writeArray cost next (curCost + edgeCost)
            modify $ Set.insert (curCost + edgeCost, next)
            else do
            when (curCost + edgeCost < nextCost) $ lift $ writeArray cost next (curCost + edgeCost)
            isChecked <- lift $ readArray check next
            unless isChecked $ do
              (\x -> modify $ \s -> Set.insert (x, next) $ Set.delete (nextCost, next) s) =<< (lift $ readArray cost next)
        dijkstra' cost check

modifyArray arr i f = writeArray arr i =<< f <$> readArray arr i

main :: IO ()
main = do
  k <- readLn :: IO Int

  graph <- newArray (0,k-1) [] :: IO (IOArray Int [(Int, Int)])

  forM_ [0..k-1] $ \i -> do
    when (i `mod` 10 /= 9) $ do
      modifyArray graph i (((i+1)`mod`k, 1):)
    modifyArray graph i (((i*10)`mod`k, 0):)

  g <- freeze graph

  print $ (dijkstra g 1) ! 0 + 1
  


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

int n, k;

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

    scanf("%d%d", &n, &k);
    int gcd = 0, mx = -1;
    for (int i = 1; i <= n; ++i) {
        int x; scanf("%d", &x);
        gcd = __gcd(x, gcd);
        mx = max(mx, x);
    }
    if (k % gcd == 0 && k <= mx) puts("POSSIBLE"); else puts("IMPOSSIBLE");

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>

using namespace std;

int main(){
    int x, y, four, legs, lastlegs;
    bool flag = true;
    cin >> x >> y;

    four = y / 4;

    for (int i = four; i >= 0;i--){
        legs = 4 * i;
        lastlegs = y - legs;
        if(lastlegs%2==0){
            if((lastlegs/2)+i==x){
                flag = false;
                cout << "Yes";
                break;
            }
        }
    }

    if(flag){
        cout << "No";
    }
}

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

int shoujun(const void* a, const void* b){return *((char*)b)-*((char*)a);}
int koujun(const void* a, const void* b){return *((char*)a)-*((char*)b);}

int main()
{
	int line;
	cin >> line;
	for(int i=1;i<=line;i++)
	{
		char dataline[10];
		cin >> dataline;
		
		qsort(dataline,8,sizeof(char),shoujun);
		int largest = atoi(dataline);
		qsort(dataline,8,sizeof(char),koujun);
		int smallest = atoi(dataline);
		cout << largest - smallest << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

void swap(string* a, string* b)
{
    string t = *a;
    *a = *b;
    *b = t;
}

void swapi(int* a, int* b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

int partition ( string array[], int array1[], int array2[], int l, int r) {

    string pivot = array[r];
    int pivoti = array1[r];
    int i = (l - 1);

    for (int j = l; j <= r - 1; j++) {
        if (array[j] < pivot) {
            i++;
            swap (&array [i], &array [j]);
            swapi(&array1[i], &array1[j]);
            swapi(&array2[i], &array2[j]);
        }
        else if (array[j] == pivot) {
            if (array1[j] > pivoti) {
                i++;
                swap(&array[i], &array[j]);
                swapi(&array1[i], &array1[j]);
                swapi(&array2[i], &array2[j]);
            }
        }
    }
    swap (&array[i + 1], &array[r]);
    swapi(&array1[i + 1], &array1[r]);
    swapi(&array2[i + 1], &array2[r]);
    return (i + 1);
}

void quickSort( string array[], int array1[], int array2[], int l, int r) {
    if (l < r) {
        int pivot = partition(array, array1, array2, l, r);
        quickSort(array, array1, array2, l, pivot - 1);
        quickSort(array, array1, array2, pivot + 1, r);
    }
}

int main()
{
    int r, d, x;
    cin >> r >> d >> x ;
    
    rep(i,10){
        x = r*x - d;
         cout << x << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int main()
{
   int cur=0,ans=0,i;
   string s;
   cin>>s;
   int n=s.length();
   for(i=0;i<n;i++)
   {
       if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')
        cur++;
       else
        cur=0;
  ans=max(cur,ans);
   }
   cout<<ans<<e;
}


Measured memory_bytes: 256
#include<iostream>
#include<deque>
#include<iterator>
#include<list>
#include<queue>
#include<stack>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<math.h>
#include<utility>
#include<functional>
const int MOD = 1e9 + 7;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for (int i = 0; i < (n); i++);

int main() {
    int N,K;
    cin >> N >> K;
    vector<ll> height(N);
    for (int i = 0; i < N; i++) {
        cin >> height.at(i);
    }
    sort(height.begin(),height.end());
    ll m = 1e9+1;
    for (int i = 0; i <= N-K; i++) {
        int j = i + K - 1;
        ll del = abs(height.at(j) - height.at(i));
        m = min(m,del);
    }
    cout << m << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,p;
map<int,int>mp;
int sum[400001];
int a[400001];
signed main()
{
	cin>>n>>p;
	for(int i=1;i<=n;i++)
		scanf("%1lld",&a[i]);
	if(p==2)
	{
		int ans=0;
		for(int i=n;i>=1;i--)
			if(a[i]%2==0)
				ans+=i;
		printf("%lld",ans);
			return 0;
	}	
	if(p==5)
	{
		int ans=0;
		for(int i=n;i>=1;i--)
			if(a[i]%5==0)
				ans+=i;
		printf("%lld",ans);
			return 0;
	}
	long long poww=1;
	for(int i=n;i>=1;i--)
	{
		sum[i]=poww*a[i]+sum[i+1];
		poww*=10;
		poww%=p;
		sum[i]%=p;
	}
	int ans=0;
	for(int i=0;i<=n;i++)
		ans+=mp[sum[i]],mp[sum[i]]++;
	printf("%lld",ans);
	return 0;
}
/*
4 2
2212
*/

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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int main()
{
    string S;
    cin >> S;
    int64_t L = S.size();
    reverse(S.begin(), S.end());
    vector<vector<int64_t>> dp(L, vector<int64_t>(13, 0));

    if (S[0] == '?')
        for (int64_t i = 0; i < 10; i++)
            dp[0][i] = 1;
    else
        dp[0][S[0] - '0'] = 1;

    int64_t keta = 10, x, y;
    char z;
    for (int64_t i = 1; i < L; i++)
    {
        char z = S[i];
        if (z == '?')
        {
            for (int x = 0; x < 10; x++)
            {
                for (int j = 0; j < 13; j++)
                {
                    y = (x * keta + j) % 13;
                    dp[i][y] += dp[i - 1][j];
                    dp[i][y] %= MOD;
                }
            }
        }
        else
        {
            x = z - '0';
            for (int j = 0; j < 13; j++)
            {
                y = (x * keta + j) % 13;
                dp[i][y] += dp[i - 1][j];
                dp[i][y] %= MOD;
            }
        }
        keta = (keta * 10) % 13;
    }
    cout << dp[L - 1][5];
}

Measured memory_bytes: 16640
#include<cstdio>
#include<algorithm>
#define maxn 505
#define LL long long
using namespace std;
int n,k,sum,ans,a[maxn],b[maxn];
inline char nc(){
	static char buf[100000],*L=buf,*R=buf;
	return L==R&&(R=(L=buf)+fread(buf,1,100000,stdin),L==R)?EOF:*L++;
}
inline int read(){
	int ret=0,f=1;char ch=nc();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=nc();}
	while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=nc();
	return ret*f;
}
inline bool check(int p){
	for (int i=1;i<=n;i++) b[i]=a[i]%p;
	sort(b+1,b+n+1);
	LL sx=b[1],sy=p-b[n];
	for (int i=2;i<n;i++)
	if (sx+b[i]<=k) sx+=b[i];
	else sy+=p-b[i];
	return sy<=k;
}
int main(){
	n=read();k=read();
	for (int i=1;i<=n;i++) a[i]=read(),sum+=a[i];
	for (int j=1;j*j<=sum;j++)
	if (sum%j==0){
		if (check(j)) ans=max(ans,j);
		if (check(sum/j)) ans=max(ans,sum/j);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define rep1(i,n) for(ll i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
typedef long long ll;
bool dp[40001];
ll imos[40002];
int main(){
	ll N,L,M,R;
	cin>>N>>L>>M>>R;
	L*=2,M*=2,R*=2;
	dp[M]=true;
	rep1(j,40001) imos[j+1]=imos[j]+(dp[j]?1:0);
	rep1(i,N){
		ll m;
		cin>>m;
		ll mn=m*R,mx=m*L/2;
//		show(i);
		rep(j,2*M+1){
			ll l=max(0LL,j-mx),r=j-mn;
			dp[j]=false;
			if(r>=0) if(imos[r+1]-imos[l]>0) dp[j]=true;
			l=j+mn,r=min(j+mx,M*2);
			if(l<=M*2) if(imos[r+1]-imos[l]>0) dp[j]=true;
//			cout<<"j:"<<j<<"  ";
//			show(dp[j]);
		}
//		cout<<endl;
		rep(j,40001) imos[j+1]=imos[j]+(dp[j]?1:0);
	}
	cout<<(imos[2*M]>0?"Yes\n":"No\n");
}

Measured memory_bytes: 1468
n, k, q = map(int, input().split())
a = [int(input()) - 1 for i in range(q)]
ans = [k-q]*n
for i in range(q):
    ans[a[i]] += 1
for i in range(n):
    if ans[i] > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 15568
#ABC141-E Who Says a Pun?
"""
ロリハ解
探索する文字列の長さを二分探索し、重複を探す。
計算量はO((n+m)*log(n//2)) ※mは探索する文字列の長さ
log部分は100には間違いなく収まるので、O(10^5)程度。十分に間に合う。
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
s = readline().rstrip().decode('utf-8')

class RollingHash(): #衝突を防ぐため、res1とres2の基数の異なるハッシュによって判定する。
    BASE1 = 1007
    BASE2 = 2009
    MOD1 = 1000000007
    MOD2 = 1000000009
 
    def __init__(self, s):
        self.n = len(s)
        self.hash1 = [0] * (self.n + 1)
        self.hash2 = [0] * (self.n + 1)
        self.power1 = [1] * (self.n + 1)
        self.power2 = [1] * (self.n + 1)
        for i, e in enumerate(s):
            self.hash1[i + 1] = (self.hash1[i] * self.__class__.BASE1 + ord(e)) % self.__class__.MOD1
            self.hash2[i + 1] = (self.hash2[i] * self.__class__.BASE2 + ord(e)) % self.__class__.MOD2
            self.power1[i + 1] = (self.power1[i] * self.__class__.BASE1) % self.__class__.MOD1
            self.power2[i + 1] = (self.power2[i] * self.__class__.BASE2) % self.__class__.MOD2
 
    def get(self, l: int, r: int):
        res1 = self.hash1[r] - self.hash1[l] * self.power1[r - l] % self.__class__.MOD1
        if(res1 < 0):
            res1 += self.__class__.MOD1
        res2 = self.hash2[r] - self.hash2[l] * self.power2[r - l] % self.__class__.MOD2
        if(res2 < 0):
            res2 += self.__class__.MOD2
        return (res1, res2)


def func(mid): #ここが関数部分
    dic1 = dict()

    for i in range(n-mid+1):
        res = roliha.get(i,i+mid)
        if res in dic1:
            #部分重複があってはならない。(2つの文字列は独立)
            if i-dic1[res] >= mid: #先頭文字がmidの幅以上あるならば
                return True
            else:
                continue #更新処理を飛ばさないといけない
        dic1[res] = i
    return False 


def binary_search(): #2分探索
    ok = 0
    ng = n//2+1
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if func(mid):
            ok = mid
        else:
            ng = mid

    return ok

roliha = RollingHash(s)

print(binary_search())

Measured memory_bytes: 74856
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

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

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

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

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

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

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

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

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input!{
        source = src,
        t: String,
    }

    return t.replace("?", "D");
}


Measured memory_bytes: 2708
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

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

  vector<int> vec(n);
  rep(i, n) {
    cin >> vec[i];
  }

  int cnt = 0;
  int smallest = vec[0];
  rep(i, n){
    int p = vec[i];
    if (smallest >= p) {
      cnt++;
      smallest = p;
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
const int inf = 1 << 28;

int solve(int h, int w, vector<vector<int> >& G){
    vector<int> mem(h*100 + w, inf); mem[0] = 1;
    priority_queue<pair<int, int> > q;
    for(q.emplace(-1, 0); !q.empty();){
        int c = -q.top().first, v = q.top().second; q.pop();
        if(mem[v] != c)continue;
        for(auto u: G[v]){
            if(mem[u] <= c + 1)continue;
            mem[u] = c + 1;
            q.emplace(-mem[u], u);
        }
    }
    return mem[(h-1)*100 + w-1] != inf? mem[(h-1)*100 + w-1]: 0;
}

int main(){
    int w, h;
    while(cin >> w >> h, w|h){
        vector<vector<int> > G(h*100 + w);
        rep(i, 2*h-1)rep(j, i&1? w: w-1){
            int wall;
            cin >> wall;
            if(wall)continue;
            G[(i/2)*100 + j].emplace_back((i/2 + (i&1))*100 + (j + (~i&1)));
            G[(i/2 + (i&1))*100 + (j + (~i&1))].emplace_back((i/2)*100 + j);
        }
        cout << solve(h, w, G) << '\n';
    }
    return 0;
}

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

using namespace std;

#define int long long

bool codejam = 0;

typedef long long li;
typedef long double ld;

void solve();

int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t = 1; 
	// cin >> t;
	int tt = t;
	while (t--) { 
		if (codejam) cout << "Case #" << tt - t << ": ";
		solve();
	}
	return 0;
}
int n;
// smallest multiple of a >= b
int cil (int a, int b) {
	if (b == 0)
		return a; 
	if (b % a == 0)
		return b;
	int mul = b / a;
	int aa = a;
	a *= mul;
	a += aa;
	return a;
}
void solve() {
	cin >> n;
	int cura = 0, curb = 0, a, b;
	for (int i = 1; i <= n; ++i) {
		cin >> a >> b;
		int mul_a = cil(a, cura) / a;
		int mul_b = cil(b, curb) / b; 
		mul_a = max(mul_a, mul_b);
		a *= mul_a, b *= mul_a;
		cura = a;
		curb = b;
	}
	cout << a + b;
}	


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


int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  for(int i = k; i < n; i++) {
    if(a[i]>a[i-k]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

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

int n,q;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>n;
    vector <int> a(n);
    vector <int> frec(1e5+5,0);
    ll sum=0;
    for (int i=0; i<n; i++){
        cin>>a[i];
        sum+=(ll) a[i];
        frec[a[i]]++;
    }
    cin>>q;
    vector <int> b(q);
    vector <int> c(q);
    for (int i=0; i<q; i++){
        cin>>b[i];
        cin>>c[i];
        if (frec[b[i]]){
            sum-=(ll)((ll)b[i]*(ll)frec[b[i]]);
            sum+=(ll)frec[b[i]]*(ll)c[i];
            frec[c[i]]+=frec[b[i]];
            frec[b[i]]=0;
        }
        cout<<sum<<"\n";
    }
    
    
    
    
    return 0;
}

Measured memory_bytes: 4784
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int inf = 0x3f3f3f3f;
ll MAX=10000110000001;
ll MIN=-1*MAX;
ll P=1000000007;
vector<ll> adj[201];
 
ll smallest_prime[2000001];
void seive()
{
     ll i,j,k,l,m,n,o,p;
     for(i=1;i<=2000000;i++)
     {
         smallest_prime[i]=1;
     }
     smallest_prime[0]=smallest_prime[1]=1;
     for(i=2;i<=2000000;i++)
     {
         if(smallest_prime[i]==1)
         {
             for(j=2*i;j<=2000000;j+=i)
             {
                 if(smallest_prime[j]==1)
                 smallest_prime[j]=i;
             }
             smallest_prime[i]=i;
         }
     }
}
vector<pair<ll,ll>> prime_divisors(ll n)
    {
     ll i,j,k,l,m,o,p,q,r,s,t;
     vector<pair<ll,ll>> vp;
     if(n<=1)
     return vp;
 
     while(n!=1)
     {
        p=0;
        k=smallest_prime[n];
        while(n%k==0)
        {
            n/=k;
            p++;
        }
        if(p>0)
     vp.push_back(make_pair(k,p));
     }
     if(n>1)
     {
         vp.push_back({n,1});
     }
     return vp;
    } 
 void solve()
 {
     ll i,j,k,l,m,n,o,p,q,r,a[1000001],prefix[300001];
     seive();
     cin>>n;
     //cout<<n<<" "<<m<<endl;
     memset(a,0,sizeof(a));
     for(i=1;i<=n;i++)
     {
         cin>>j;
         vector<pair<ll,ll>> vp=prime_divisors(j);
         for(auto it:vp)
         {
             a[it.first]++;
         }
     }
     ll flag=0;
     for(i=2;i<=1000000;i++)
     {
         if(a[i]>=2)
         {
             flag=1;
         }
     }
     if(!flag)
     {
         cout<<"pairwise coprime\n";
         return;
     }
     flag=0;
      for(i=2;i<=1000000;i++)
     {
        
         if(a[i]==n)
         {
              //cout<<a[i]<<endl;
             flag=1;
         }
     }
     //cout<<flag<<endl;
     if(!flag)
     {
         cout<<"setwise coprime\n";
         return;
     }
     cout<<"not coprime\n";
 }
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(0);
     ll t=1;
    // cin>>t;
     while(t--)
     {
         solve();
     }
    return 0;
}


Measured memory_bytes: 27056
import java.util.Scanner;
public class Main {

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

		if(A<=8 && B<=8) {
			System.out.println("Yay!");
		}else {
			System.out.println(":(");
		}

	}

}


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

int main(){
  ll N;
  cin >> N;
  vector<P>A(N);
  rep(i,N){
    cin >> A[i].first;
    A[i].second = i+1;
  }
  sort(A.begin(),A.end());
  rep(i,N)cout << A[i].second << " ";
  cout << endl;
}

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

int isPrime(int x){
    if(x < 2) return 0;
    else if(x == 2) return 1;
    else if(x%2 == 0) return 0;
    else{
        for(int i=3; i*i<=x; i+=2){
            if(x%i == 0) return 0;
        }
    }
    return 1;
}
int main(){
  int ans=0;
  int n,d;
  cin >> n;
  int i,j;
  for(i=0;i<n;i++){
    cin >> d;
    if(isPrime(d) == 1){
        ans++;
    }  
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3104
import java.util.Scanner

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]) = {
    val sc = new Scanner(System.in)
    val r, D, x = sc.nextInt()

    (1 to 10).scanLeft(x)((pre, _) => r * pre - D).tail.foreach(println(_))
  }
}

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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

template <class T1, class T2>
inline void chmax(T1 &a, const T2 &b)
{
    if (a < b)
    {
        a = b;
    }
}
template <class T1, class T2>
inline void chmin(T1 &a, const T2 &b)
{
    if (a > b)
    {
        a = b;
    }
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;

int main()
{
    ll N;
    cin >> N;
    string c;
    cin >> c;
    ll w_cnt = 0;
    ll r_cnt = 0;
    rep(i, c.size())
    {
        if (c[i] == 'W')
        {
            ++w_cnt;
        }
        else
        {
            ++r_cnt;
        }
    }

    ll ans = 0;
    rep(i, r_cnt)
    {
        if (c[i] == 'W')
        {
            ++ans;
        }
    }
    cout << ans << endl;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

LL dp[SIZE][2];

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

    string s;
    cin >> s;
    for(int i = 0; i < s.size(); ++i) {
        if(i == 0) {
            dp[i][1] = 2;
            dp[i][0] = 1;

        } else {
            dp[i][0] = dp[i - 1][0] * 3 % MOD;
            if(s[i] == '1') {
                dp[i][0] = (dp[i][0] + dp[i - 1][1]) % MOD;

            }

            if(s[i] == '1') {
                dp[i][1] = dp[i - 1][1] * 2 % MOD;

            } else {
                dp[i][1] = dp[i - 1][1];

            }
        }
    }
    cout << (dp[s.size() - 1][1] + dp[s.size() - 1][0]) % MOD << endl;
    return 0;
}



Measured memory_bytes: 2000
def main():
    a, b, c = map(int, input().split())
    ans = 0
    if c > 0:
        ans += 1
        c -= 1
    if c <= b:
        ans += c + b
    else:
        ans += 2*b
        c -= b
        ans += min(c, a)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  int n,m;
  cin>>n>>m;
  vector<ll>a(n),b(n);
  vector<ll>c(m),d(m);
  rep0(i,n)cin>>a[i]>>b[i];
  rep0(i,m)cin>>c[i]>>d[i];
  int ans = 0;
  rep0(i,n){
    int tmp = INF;
    rep0(j,m){
      if(tmp > abs(a[i]-c[j])+abs(b[i]-d[j])){
        tmp = abs(a[i]-c[j])+abs(b[i]-d[j]);
        ans = j + 1;
      }
    }
    cout << ans << endl;
  }
  return 0;
} 

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0003
{
    class Program
    {
        static void Main(string[] args)
        {
            int order = int.Parse(Console.ReadLine());
            List<string> answer = new List<string>();
            for (int i = 0; i < order; i++)
            {
                int[] sides = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                Array.Sort(sides);

                if (Math.Pow(sides[2], 2) == Math.Pow(sides[1], 2) + Math.Pow(sides[0], 2))
                {
                    answer.Add("YES");
                }
                else
                {
                    answer.Add("NO");
                }
            }
            foreach (string item in answer)
            {
                Console.WriteLine(item);
            }
        }
    }
}



Measured memory_bytes: 16300
#include <stdio.h>

int main()
{
        int D = 0;
        int N = 0;

        scanf ("%d %d", &D, &N);

        switch(D)
        {
                case 0:
                        if( N < 100 )
                                printf ("%d\n", 1 * N);
                        else
                                printf ("%d\n", 1 * (N + 1));
                        break;
                case 1:
                        if( N < 100 )
                                printf ("%d\n", 100 * N);
                        else
                                printf ("%d\n", 100 * (N + 1));
                        break;
                case 2:
                        if( N < 100 )
                                printf ("%d\n", 10000 * N);
                        else
                                printf ("%d\n", 10000 * (N + 1));
                        break;
        }

        return 0;
}

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

using namespace std;


void solve() {
    int n,m,x;
    cin >> n >> m >> x;
    n = max(n,m);
    cout << (x+n-1)/n;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> cnt(n, 0);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        a--;
        cnt[a]++;
    }

    vector<int> v;
    for (int i = 0; i < n; i++) {
        if (cnt[i] > 0) v.push_back(cnt[i]);
    }
    sort(v.begin(), v.end());

    vector<int> sum(n + 1, 0);
    for (int i = 1, j = 0; i <= n; i++) {
        sum[i] += sum[i - 1];
        sum[i - 1] += (i - 1) * max((int)v.size() - j, 0);
        while (j < v.size()) {
            if (v[j] < i) {
                sum[i] += v[j];
                j++;
            } else {
                break;
            }
        }
        if (i == n) sum[i] += i * max((int)v.size() - j, 0);
    }

    vector<int> ans(n + 1, 0);
    for (int i = n, j = 0; i >= 1; i--) {
        while (j <= n) {
            if (sum[j] >= i * j) {
                j++;
            } else {
                break;
            }
        }
        ans[i] = j - 1;
    }

    for (int i = 1; i <= n; i++) {
        cout << ans[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 5488
a=list(input().split(" "))
A=int(a[0])
B=int(a[1])
C=int(a[2])
X=int(a[3])
Y=int(a[4])

minprice = X*A+Y*B

N = max(X,Y)
Z=0
for i in range(N):
    if X>0:
        X-=1
    if Y>0:
        Y-=1
    Z+=2
    price =X*A+Y*B+Z*C
    minprice=min(minprice, price)
print(minprice)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pbi pair<bool,int>
#define pob pop_back
#define all(a) a.begin(),a.end()
#define fio ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define i64 long long int
#define mem(x,y) memset(x,y,sizeof(x))
#define fill(arr,b) fill(arr, arr+sizeof(arr)/sizeof(arr[0]), b)
#define maxarr(n,arr,m) m =-1e9;for(int i=0;i<n;i++)if(arr[i]>m) m=arr[i];
#define read freopen("input.txt","r",stdin);


const int maxn = (i64)1e9+7;
const double pi = acos(-1.0);

int main()
{
    //read;
    double a,b,h,m;
    scanf("%lf%lf%lf%lf",&a,&b,&h,&m);

    h = 0.5*(h*60+m);
    m = 6*m;
    double  x = abs(h - m);
    x = min(360-x,x);
    x=x*(pi/180);
    x=sqrt((a*a)+(b*b)-(2*a*b*cos(x)));
    printf("%.20lf",x);
    return 0;
}


Measured memory_bytes: 4164
/*
 * ABC081_D.cpp
 *
 *  Created on: May 17, 2018
 *      Author: 13743
 */
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}



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

	int N;
	int a[51];
	cin >> N;

	int minI=1, maxI = 1;
	FOR(i, 1, N) {
		cin >> a[i];
		minI = (a[i] < a[minI]) ? i : minI;
		maxI = (a[i] > a[maxI]) ? i : maxI;
	}
	int piv = minI;
	if(a[minI] + a[maxI] > 0) {
		piv = maxI;
	}

	cout << 2*N-1 << "\n";
	FOR(i, 1, N) {
		cout << piv << " " << i << "\n";
	}
	if(a[piv] > 0) {
		FOR(i, 1, N-1) {
			cout << i << " " << i+1 << "\n";
		}
	}
	else {
		FORD(i, N, 2) {
			cout << i << " " << i-1 << "\n";
		}
	}
	cout << flush;
}






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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

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

  ll ans = 0;
  for (int a = 1; a <= k; a++) {
    for (int b = 1; b <= k; b++) {
      for (int c = 1; c <= k; c++) {
        ans += gcd(a, gcd(b, c));
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int main(void) {
	int num, i, j, k = 2;
	double l, ans = 0;
	cin >> num;
	vector<double> x(num), y(num);
	for (i = 0; i < num; i++) {
		cin >> x[i] >> y[i];
	}
	for (i = 2; i < num; i++)
		k *= i;
	for (i = 0; i < num - 1; i++) {
		for (j = i + 1; j < num; j++) {
			l = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
			ans += sqrt(l) * k;
		}
	}
	for (i = 2, k = 1; i <= num; i++)
		k *= i;
	ans /= k;
	printf("%.10lf\n", ans);
	return 0;
}

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

using namespace std;

int n,len,ans,bj[100010];
long long int num[100010],lisan[100010];

int cmp1(long long int a,long long int b)
{
	return a<b;
}

long long int search(long long int x)
{
	long long int l=1,r=n;
	while(l+1<r)
	{
		long long int mid=(l+r)/2;
		if(x>lisan[mid])
		    l=mid;
		else
		    r=mid;
	}
	long long int mid=(l+r)/2;
	if(x>lisan[mid])
		l=mid;
	else
	    r=mid;
	return r;
}


int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
	    scanf("%lld",&num[i]);
		lisan[i]=num[i];	
	}    
	sort(lisan+1,lisan+n+1,cmp1);
	for(int i=1;i<=n;i++)
		num[i]=search(num[i]);
	for(int i=1;i<=n;i++)
	{
		if(len==0)
		{
			len++;
			bj[len]=num[i];
		}
		else
		{
			int l=1,r=len;
        	while(l+1<r)
	        {
		        long long int mid=(l+r)/2;
		        if(num[i]>bj[mid])
		            r=mid;
		        else
		            l=mid;
	        }
	        long long int mid=(l+r)/2;
	        if(num[i]>bj[mid])
		        r=mid;
	        else
	            l=mid;
	        if(bj[r]>=num[i])
	        {
	        	len++;
	        	bj[len]=num[i];
			}
			else
			{
				bj[r]=num[i];
			}
			    
		}
		
	}
	printf("%d\n",len);
	return 0;
} 

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
	return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
	os << "{";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << *it;
	}
	return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin()) os << ", ";
		os << *it;
	}
	return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << it -> first << " = " << it -> second ;
	}
	return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
	for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
	cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/



int main()
{
	FASTIO
	///*
// #ifndef ONLINE_JUDGE
// 	freopen("in.txt", "r", stdin);
// 	freopen("out.txt", "w", stdout);
// 	freopen("error.txt", "w", stderr);
// #endif
//*/
	int T;
	//scanf("%d", &T);
	T = 1;
	for (int cs = 1; cs <= T; cs++) {
		int n;
		cin >> n;
		double ans = 0;
		for (int i = 0; i < n; i++) {
			double x;
			cin >> x;
			ans += (1.0 / x);
		}
		cout << setprecision(15) << (1.0 / ans) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, j, n) for (int i = j; i < (int)(n); i++)
#define brep(i, n) for (int i = n; i > 0; i--)
#define BREP(i, j, n) for(int i = n; i > j; i--)
#define TEST cout << "PASS" << endl
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 1e6 + 1e3 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
    int h, w, m;
    cin >> h >> w >> m;
    unordered_map<int, int> mpx, mpy;
    map<pair<int, int>, int> mp;
    int mx = 0, my = 0;
    rep(i, m){
        int y, x;
        cin >> y >> x;
        mpx[x]++;
        mpy[y]++;
        mp[make_pair(x, y)] = 1;
        mx = max(mx, mpx[x]);
        my = max(my, mpy[y]);
    }
    vector<int> dx, dy;
    bool ok = false;
    for(P x : mpx) if(x.second == mx) dx.push_back(x.first);
    for(P x : mpy) if(x.second == my) dy.push_back(x.first);
    ll k = ll(dx.size()), l = ll(dy.size());
    if(k * l > m){
        cout << mx + my << endl;
        return 0;
    }
    for(int x : dx){
        for(int y : dy){
            if(!mp.count(make_pair(x, y))){
                ok = true;
            }  
        }
    }
    if(ok) cout << mx + my << endl;
    else cout << mx + my -1<< endl;
    
}

Measured memory_bytes: 53224
def main():
    n = int(input())
    s_dic = {}
    for _ in range(n):
        s = input()
        if s in s_dic:
            s_dic[s] += 1
        else:
            s_dic[s] = 1
    m = int(input())
    t_dic = {}
    for _ in range(m):
        t = input()
        if t in t_dic:
            t_dic[t] += 1
        else:
            t_dic[t] = 1
    ans = 0
    for s in s_dic.keys():
        tmp = s_dic[s]
        if s in t_dic:
            tmp -= t_dic[s]
        ans = max(ans, tmp)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
    int i,r=0;
    char s[16];
    scanf("%s",s);
    for(i=0;s[i]!='\0';i++)if(s[i]=='o')r++;
    r+=15-i;
    if(r>7)puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def YesNo(x): return 'Yes' if x else 'No'
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    X, A = LI()
    ans = 0 if X < A else 10
    return ans

print(main())

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>
using namespace std;
#define ll long long int
#define pp pair<ll, ll>
#define pps pair<ll, string>
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define srep(i, s) rep(i, s.size())
#define fi first
#define se second
ll a, b, c;
int main()
{
    cin >> a >> b >> c;
    if (a + b + 1 < c)
        cout << a + b + 1 + b << endl;
    else
        cout << b + c << endl;
    return 0;
}

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

map<int,int> m;
vector<int> v;

int main(){
    int n,ans;
    cin>>n;
    for(register int i=1;i<=n;++i){
        int x;
        cin>>x;
        if(m[x]==0) v.push_back(x);
        ++m[x];
    }
    for(register int i=0;i<v.size();++i) 
        if(m[v[i]]>=v[i]) 
            ans+=m[v[i]]-v[i]; 
        else 
            ans+=m[v[i]];
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5112
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define int ll
#define For(a, b, c) for(int a = b; a <= c; ++a)
#define Ford(a, b, c) for(int a = b; a >= c; --a)
#define All(a, b) for(auto &a : b)
#define Rep(a, b, c) for(int a = b; a < c; ++a)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define all(a) a.begin(),a.end()
#define reset(a, b) memset(a, b, sizeof(a))
#define bit(x, i) (x >> (i - 1) & 1ll)
#define onbit(x, i) (x | (1ll << (i - 1)))
#define offbit(x, i) (x & ~(1ll << (i - 1)))
#define bitone(i) __builtin_popcountll(i)
#define bitl(i) __builtin_clz(i)
#define bitr(i) __builtin_ctz(i)
#define vll vector<ll>
/********************************************************

Digvijay Bahadur Singh
MNNIT

*********************************************************/
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}


const int MOD=1e9+7;
const int N = 1e6+100;
/********************************************************************/
                 /* GRAPH*/
//vector<vector<ll>> g;
//vector<bool> vis1,vis2;
/*******************************************************************/
ll power(ll a,ll b)
{
   ll ans =1;
   while(b>0){
   if(b&1) ans = (ans%MOD * a%MOD)%MOD;
   a = (a%MOD * a%MOD)%MOD;
   b=b>>1;
   }
   return ans%MOD;
}


signed main(){
  ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
  ll n;

  
  ll T=1;
 //cin>>T;
  
   // T=1;
    
    while(T--)
  {
    
        
     int a[3];
     cin>>a[0]>>a[1]>>a[2];
     sort(a,a+3);
     if((a[0]==a[1]&&a[1]!=a[2])||(a[0]!=a[1]&&a[1]==a[2]))
     {
       cout<<"Yes\n";
     }
     else cout<<"No\n";
	
  }

       
   
  

   
 


      

  }

  



Measured memory_bytes: 384
use proconio::input;


fn main() {
    input! {
        a: usize,
        b: usize,
        m: usize,
        va: [i32; a],
        vb: [i32; b],
        x: [(usize, usize, i32); m]
    }

    let mut ans = va.iter().min().unwrap() + vb.iter().min().unwrap();
    for (ai, bi, c) in x {
        ans = std::cmp::min(ans, va[ai-1] + vb[bi-1] - c);
    }

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


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

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

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

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
  string t, p;
  cin >> t >> p;

  int ts = t.size();
  int ps = p.size();
  if (ts >= ps) {
    rep(i,ts-ps+1)
      if (t.substr(i,ps) == p) cout << i << endl;
  }

  return 0;
}



Measured memory_bytes: 3216
#include<stdio.h>
#include<stdlib.h>
 
int t = 0;
 
typedef struct {
  int t1;
  int t2;
  int *v;
  int d;
  int k;
}DP;
 
void visit(DP *G, int i){
  int j;
  for(j=0; j<G[i].k; j++){
    if(G[G[i].v[j]-1].d > G[i].d || G[G[i].v[j]-1].d == -1){
      G[G[i].v[j]-1].d = 1 + G[i].d;
      visit(G, G[i].v[j]-1);
    }
  }
 
  return;
}
 
int main(){
 
  int n, i, j, u, k, l[100];
  DP *G;
 
  scanf("%d", &n);
  G = (DP *)malloc(sizeof(DP)*n);
 
  for(i=0; i<n; i++){
    scanf("%d%d", &u, &k);
    G[u-1].v = (int *)malloc(sizeof(int)*(k+1));
    G[u-1].k = k;
    G[u-1].d = -1;
    for(j=0; j<k; j++){
      scanf("%d", &G[u-1].v[j]);
    }
  }
  G[0].d = 0;
  visit(G, 0);
 
  for(i=0; i<n; i++){
    printf("%d %d\n", i+1, G[i].d);
  }
 
  return 0;
}



Measured memory_bytes: 2052
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c=0,d,x,y,z;
string s,t;
//

signed main() {
  RAPID;
  IN(s);
  bool flg = false;
  if(s[0]==s[1] && s[1]==s[2]) flg=true;
  else if(s[1]==s[2] && s[2]==s[3]) flg=true;
  Yes(flg);
}

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

int main()
{
	//Couldn't solve it myself. Needed to check the editorial and other submission.
	int n;
	cin >> n;
	string str;
	cin >> str;

	int sum = 0;
	string prefix, suffix;

	for (int i = 0; i < str.length(); ++i)
	{
		if (str[i] == '(') sum++;
		else sum--;

		if (sum < 0) 
		{
			prefix += '(';
			sum++;
		}
	}

	while (sum--)
	{
		suffix += ')';
	}

	cout << prefix << str << suffix;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;

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

    ll n, w, uu, v;
    cin>>n>>w;
    ll mofo = n*1000 + 1;
    vector<ll> dp(mofo, 1e12);
    dp[0] = 0;
    //dp[i] = min weights sum for which value sum is i
    loop(n){
        cin>>uu>>v;
        ll from = mofo - v;
        for(from; from>=0; from--){
            dp[from+v] = min(dp[from+v], dp[from]+uu);
        }
    }   
    ll ans = 0;
    loop(mofo){
        if(dp[i]<=w) ans = max(ans, i);
    }
    cout<<ans<<"\n";
    return 0;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

int dp[1000001][2];
string s;

signed main() {
    cin >> s;
    rep(i,s.size()) s[i] -= '0';
    dp[0][1] = 1;
    rep(i,s.size()) {
        dp[i+1][0] = min(dp[i][0]+s[i],  dp[i][1]+10-s[i]);
        if (s[i] == 9) dp[i+1][1] = dp[i][1];
        else dp[i+1][1] = min(dp[i+1][0]+1, dp[i][1]+9-s[i]);
    }
    cout << min(dp[s.size()][0], dp[s.size()][1]+1) << endl;
}



Measured memory_bytes: 17028
import java.util.Scanner;
import java.math.*;
import java.math.*;
public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		//int a = sc.nextInt();
		// スペース区切りの整数の入力
		//int b = sc.nextInt();
		//int c = sc.nextInt();
		// 文字列の入力
		//String s = sc.next();
		//1文字ずつ
		//s.atChar(i);
		// 出力
		//System.out.println("");
		int count=0;
		int N=sc.nextInt();
		int NN=N;
		int sum=0;
		while(N!=0){
			sum+=(N%10);
			N=N/10;
		}
		if(NN%sum==0){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23124