akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
#define int ll
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
// const int MOD = 1000000007;

template <typename T>
void __print__(std::ostream &os, const char *, const char *tail, const T &fst) {
    os << fst << tail;
}
template <typename Fst, typename... Rst>
void __print__(std::ostream &os, const char *del, const char *tail, const Fst &fst,
               const Rst &... rst) {
    os << fst << del;
    __print__(os, del, tail, rst...);
}

#ifdef LOCAL
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        __print__(os, ", ", "\n", __VA_ARGS__);           \
        std::cerr << os.str();                            \
    } while (0)
#else
#define dump(...)
#endif

template <typename Fst, typename... Rst>
void println(const Fst &fst, const Rst &... rst) {
    __print__(std::cout, "\n", "\n", fst, rst...);
}
template <typename Fst, typename... Rst>
void print(const Fst &fst, const Rst &... rst) {
    __print__(std::cout, " ", "\n", fst, rst...);
}

template <typename iter>
void println_(iter bgn, iter end) {
    while (bgn != end) println(*bgn++);
}

template <typename iter>
void print_(iter bgn, iter end) {
    while (bgn != end) {
        std::cout << *bgn++;
        std::cout << (bgn == end ? "\n" : " ");
    }
}

int _ = (std::cout.precision(10), std::cout.setf(std::ios::fixed), std::cin.tie(0),
         std::ios::sync_with_stdio(0), 0);

template <typename T>
std::vector<T> ndarray(int n, T v) {
    return std::vector<T>(n, v);
}
template <typename... Args>
auto ndarray(int n, Args... args) {
    auto val = ndarray(args...);
    return std::vector<decltype(val)>(n, move(val));
}

template <typename T>
bool umax(T &a, const T &b) {
    return a < b ? a = b, true : false;
}

template <typename T>
bool umin(T &a, const T &b) {
    return a > b ? a = b, true : false;
}

using namespace std;

signed main() {
    int A, B, C, D, E, F;
    while (cin >> A >> B >> C >> D >> E >> F && A) {
        int x = 0, y = 1;
        rep(a, 101) rep(b, 101) {
            rep(c, 101) rep(d, 101) {
                int water = A*a*100 + B*b*100;
                int sugar = C*c + D*d;
                if (water == 0) continue;
                if (sugar + water > F) continue;
                // if (sugar / water > E / 100)
                if (sugar * 100 > E * water) continue;
                // if (x / y < sugar / (sugar + water)
                if (x * (sugar + water) <= sugar * y) {
                    x = sugar, y = sugar + water;
                }
            }
        }
        print(y, x);
    }
}


Measured memory_bytes: 384
N,K=$<.read.split.map(&:to_i)
MOD=10**9+7

class Combination
    def initialize(size,mod)
        @size = size
        @mod = mod
        @fac = []
        @finv = []
        @inv = []
        @fac[0] = @fac[1] = 1;
        @finv[0] = @finv[1] = 1;
        @inv[1] = 1;

        i = 2
        while i < size
            @fac[i] = @fac[i - 1] * i % mod
            @inv[i] = mod - @inv[mod%i] * (mod / i) % mod
            @finv[i] = @finv[i - 1] * @inv[i] % mod
            i += 1
        end
    end

    def [](n,k)
        return 0 if n < k
        return 0 if n < 0 || k < 0
        @fac[n] * (@finv[k] * @finv[n-k] % @mod) % @mod
    end
end


comb=Combination.new(N,MOD)
blue = K
red = N-K
1.upto(K) do |i|
    if red < i-1 
        puts 0
    else
        puts comb[K-1,i-1] * comb[N-K+1,i] % MOD

    end
end

Measured memory_bytes: 14356
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}

module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust, fromMaybe )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import qualified Data.Array.IArray as A
import qualified Data.Array.Unboxed as UA
import Data.Bits
import Control.Monad.State.Strict
import qualified Data.Array.ST as STA
import qualified Data.Array.IO as IOA
import qualified Data.Array.MArray as MA
import Control.Monad.ST
import System.IO (stdin)
import Control.Arrow
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as UV
import qualified Data.Vector.Generic as GV
import qualified Data.Vector.Mutable as MV
import Data.Ix
import Data.Ord (Down(Down))
import qualified Data.Sequence as Seq
import Data.Foldable (toList)
import Data.Fixed
import Control.Lens

debug = False

ts :: Show a => a -> a
ts a = if debug then traceShowId a else a


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- readInts
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- readInts
    return (a, b, c)


readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

readIntV :: Int -> IO (UV.Vector Int)
readIntV n = GV.unfoldrN n (fmap (fmap BC.tail) . BC.readInt) <$> BC.getLine

readIntegersV :: Int -> IO (V.Vector Integer)
readIntegersV n = GV.unfoldrN n (fmap (fmap BC.tail) . BC.readInteger) <$> BC.getLine

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . BC.readInteger) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

primeFactors :: Int -> IM.IntMap Int
primeFactors 1 = IM.empty
primeFactors n = if r == 1 then mp else IM.insert r 1 mp
    where
    (mp, r) = foldl' go (IM.empty, n) [2..(ceiling $ sqrt $ fromIntegral n)]
    divCount divisor num acc = case num `divMod` divisor of
        (result, 0) -> divCount divisor result $ acc + 1
        (_, _) -> (acc, num)
    go (maps, num) divisor = case divCount divisor num 0 of
        (0, _) -> (maps, num)
        (m, num') ->  (IM.insert divisor m maps, num')

getCount :: Int -> Int
getCount 1 = 1
getCount n = go n 1 where
    go a i
      | a < i = i - 1
      | otherwise = go (a - i) $ i + 1

main :: IO ()
main = do
  n <- readInt
  let mp = ts $  IM.toList $ primeFactors $ n
      ans = sum $ getCount . snd <$> mp
  print ans







Measured memory_bytes: 5232
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define INF 1e9+7
#define roop(i,m,n) for(int i=m;i<n;i++)
#define mroop(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;

//(int)'a'は97 (int)'A'は65
//おまじない



int main() {
	
	int x, a, b;
	cin >> x >> a >> b;

	int e = b - a;
	if (e <=0) {
		cout << "delicious" << endl;
	}
	else if (e > 0 && e <= x) {
		cout << "safe" << endl;
	}
	else {
		cout << "dangerous" << endl;
	}



	return 0;
}


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

const int MOD = 1000000007;
const int INF = 1000000000;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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

// a = max(a, b), a = min(a, b)
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; }

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

int main(){
    int N, K;
    cin >> N >> K;
    double ans = 0;
    for(int i = 1; i <= N; i++){
        double x = 1.0 / N;
        int sum = i;
        while(sum < K){
            sum *= 2;
            x /= 2;
        }
    ans += x;
    }
    cout << fixed << setprecision(9) << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}

Vec fac, finv;

ll PowMod(ll a, ll n){
    if(n == 1) return a;
    if(n%2 == 0) return PowMod(a*a%MOD, n/2);
    return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
    if(k>n) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

int main(){
    int a, b, k, cnt=0;
    R a>>b>>k;
    repr(i, 100){
        if(a%i==0&&b%i==0){
            cnt+=1;
            if(cnt==k){
                co(i);
                return 0;
            }
        }
    }
}

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

using namespace std;

int main(void) {
    int k, q;
    cin >> k >> q;
    vector<int> d(k);
    for(int i=0; i<k; i++) {
        cin >> d[i];
    }

    while(q--) {
        int n, x, m;
        cin >> n >> x >> m;
        x %= m;
        vector<int> tmp(k);
        transform(d.begin(), d.end(), tmp.begin(), [m](int d) {return d % m;});
        int64_t sum = accumulate(tmp.begin(), tmp.end(), 0L);
        int64_t zero = count(tmp.begin(), tmp.end(), 0);
        sum *= (n-1) / k;
        zero *= (n-1) / k;
        for(int i=0; i<(n-1)%k; i++) {
            sum += tmp[i];
            if(tmp[i] == 0) zero++;
        }
        sum += x;
        cout << n-1 - zero - (sum / m) << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#define ll long long int
#include <bits/stdc++.h>
//#include <fstream>
using namespace std;
 
#define         ff               first
#define         ss               second
#define         mp               make_pair
#define         pb               push_back
#define         pf               push_front
#define         vi               vector<ll>
#define         pii              pair<ll,ll>
#define         qi               queue<ll>
#define         mem(a,b)         memset(a,b,sizeof(a))
#define         print(a)         cout<<a<<'\n'
#define         sorted(arr)      sort(arr.begin(),arr.end())
#define         gcd(a,b)         gcd((a),(b))
#define         lcm(a,b)         ((a)*(b))/gcd((a),(b))
#define         all(v)           v.begin(),v.end()
#define         read(a)          scanf("%d", &a)
#define         f(a,n)           for(ll i=a;i<n;i++)
#define         in2(n,m,arr)     for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cin>>arr[i][j];}
#define         debug(a)         cerr<<a<<" ";
#define         debug1(a)        cerr<<a<<'\n'
 
/*typedef tree<int, null_type, less<int>, rb_tree_tag , tree_order_statistics_node_update> Set;*/
 
 
const unsigned ll mod = 1e9 + 7 ;
const ll inf = (ll)1e18 + 2;
const ll N = (ll)1e6 + 2;
//
//template<typename... T>
//void write(T&... args)
//{
//    ((cout << args << ' '), ...);
//}
//ll power ( ll x , ll y)
//{
//    ll res = 1;
//    while (y > 0)
//    {
//        if (y & 1)
//            res = (res * x) ;
//        y = y >> 1;
//        x = (x * x) ;
//    }
//    return res  ;
//}
//
//struct node{
//    ll x , y , z;
//};
//map<pair<ll, ll>,ll> c;
//vector<set<ll>> tree;
//vector<ll> ar ;
//set<ll> s;
//ll get(ll x)
//{
//    if(x == ar[x])
//        return x;
//    return ar[x] = get(ar[x]);
//}
//void merge(ll a ,ll b)
//{
//    a = get(a);
//    b = get(b);
//    if(a == b)
//    {
//        return ;
//    }
//    ar[b] = ar[a];
// }
//
//ll sev[100006];
//vector<ll> pri;
//void seive()
//{
//    for(ll i = 2 ; i < 100006 ; i ++)
//    {
//        if(!sev[i])
//        {
//            for(ll j = i ; j < 100006 ; j += i)
//            {
//                if(!sev[j])
//                    sev[j] = i;
//            }
//        }
//        if(sev[i] == i)
//            pri.pb(i);
//    }
//}
void solve()
{
    ll n , k;
    cin >> n >> k;
    double arr[n];
    for(ll i = 0 ; i < n ; i ++)
    {
        cin >> arr[i];
        arr[i] = (arr[i] + 1) / 2;
    }
    double sum = 0;
    for(ll i = 0 ; i < k ;i ++)
        sum += arr[i];
    ll l = 0 ;double ans = 0;
    ans = max(ans , sum);
    for(ll i = k ; i < n ; i ++)
        sum -= arr[l] , sum += arr[i] ,ans = max(ans , sum) , l ++;
    cout << fixed << setprecision(10) << ans << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t ;
    t = 1;
    //cin >> t;
    //seive();
    while(t --)
    {
        solve();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}
 


Measured memory_bytes: 1792
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N = int(input())
C = list(input())[:-1]
r = 0
w = 0
for s in C:
    if s == "R":
        r += 1
    elif s == "W":
        w += 1
ans = 0
if w == 0 or r == 0:
    print(0)
else:
    for i in range(r):
        if C[i] == "W":
            ans += 1
    print(ans)


Measured memory_bytes: 83880
#include<cstdio>
#include<cstring>
using namespace std;
#define M 1046527
#define NIL (-1)
#define L 14
#define ll long long int

char H[M][L];

int getchar(char ch)
{
    if(ch=='A') return 1;
    else if(ch=='C') return 2;
    else if(ch=='G') return 3;
    else if(ch=='T') return 4;
    else return 0;
}

ll getKey(char str[])
{
    ll sum=0, p=1, i;
    for(i=0; i<strlen(str); i++)
    {
        sum+=p*(getchar(str[i]));
        p*=5;
    }
    return sum;
}

int h1(int key){return key%M; }
int h2(int key){return 1+(key%(M-1)); }

int Find(char str[])
{
    ll key, i, h;
    key=getKey(str);
    for(i=0;; i++)
    {
        h=(h1(key)+i*h2(key))%M;
        if(!strcmp(H[h], str)) return 1;
        else if(strlen(H[h])==0) return 0;
    }
    return 0;
}

int Insert(char str[])
{
    ll key, i, h;
    key=getKey(str);
    for(i=0; ; i++)
    {
        h=(h1(key)+i*h2(key))%M;
        if(!strcmp(H[h], str)) return 1;
        else if(strlen(H[h])==0)
        {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main()
{
    int i, n, h;
    char str[L], com[9];
    for(i=0; i<M; i++) H[i][0]=0;
    scanf("%d", &n);
    for(i=0; i<n; i++)
    {
        scanf("%s%s", com, str);
        if(com[0]=='i') Insert(str);
        else if(Find(str)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}

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

using namespace std;

int main(){
    string input;
    while(cin >> input, input != "."){
        string ret;
        for(int i=input.size()-1; 0 <= i; i--){
            if(input[i] != '+' && input[i] != '-'){
                if(input[i] == '?'){
                    ret = 'A'+ret; i--;
                    while(input[i] == '+' || input[i] == '-') i--;
                    i++;
                } else {
                    ret = input[i]+ret;
                }
            } else {
                if(input[i] == '+'){
                    if(ret[0] == 'Z') ret[0] = 'A';
                    else ret[0]++;
                }
                else {
                    if(ret[0] == 'A') ret[0] = 'Z';
                    else ret[0]--;
                }
            }
        }
        input = ret;
        while(true){
            bool is = false;
            for(int i=0; i < input.size(); i++){
                if(input[i] == '['){
                    is = true;
                    int p = 0, count = 1;
                    for(int j=i+1; j< input.size(); j++){
                        if(input[j] == '[') count++;
                        else if(input[j] == ']') count--;
                        if(count == 0){p = j; break;}
                    }
                    string a, b, c;
                    a = input.substr(0, i);
                    b = input.substr(i+1, p-i-1);
                    c = input.substr(p+1);
                    reverse(b.begin(), b.end());
                    for(int j=0; j < b.size(); j++){
                        if(b[j] == '[') b[j] = ']';
                        else if(b[j] == ']') b[j] = '[';
                    }
                    input = a+b+c;
                    break;
                }
            }
            if(!is) break;
        }
        cout << input << endl;
    }
}

Measured memory_bytes: 1196
sx, sy, tx, ty = map(int, input().split())

for i in range(tx - sx):
    print("R",end="")

for i in range(ty - sy):
    print("U",end="")

for i in range(tx - sx):
    print("L",end="")

for i in range(ty - sy):
    print("D",end="")

print("D",end="")
    
for i in range(tx - sx + 1):
    print("R",end="")

for i in range(ty - sy + 1):
    print("U",end="")

print("L",end="")
print("U",end="")

for i in range(tx - sx + 1):
    print("L",end="")

for i in range(ty - sy + 1):
    print("D",end="")

print("R",end="")

Measured memory_bytes: 51820
program A322C
    implicit none
    integer(8)::N,i,ans
    integer(8),allocatable,dimension(:)::A,Asum
    read*,N
    allocate(A(N))
    allocate(Asum(N+1))
    read*,A
    Asum=0
    do i=2,N+1
        Asum(i)=Asum(i-1)+A(i-1)
    end do
    
    do i=2,N
        if(i==2)then
            ans=abs(Asum(N+1)-2*Asum(i))
        else
            ans=min(ans,abs(Asum(N+1)-2*Asum(i)))
        end if
    end do

    print'(i0)',ans
end program A322C

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

using namespace std;

int main(void) {
  string s[100] = {};
  string t[100] = {};
  int n;
  int m;
  int i, j;

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

  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> t[i];
  }

  int max = 0;
  int count = 0;
  for (i = 0; i < n; i++) {
    count = 0;
    string str = s[i];
    for (j = 0; j < n; j++) {
      if (str == s[j]) {
        count++;
      }
    }

    for (j = 0; j < m; j++) {
      if (str == t[j]) {
        count--;
      }
    }

    if (count > max) {
      max = count;
    }
  }

  cout << max << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
ll n,m,k,ans=0,tmp=1;
ll power(ll a,ll b) {return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
int main()
{
    cin>>n>>m>>k;
    for(ll i=0;i<=k;i++){
        ans=(ans+(tmp*m%mod)*power(m-1,n-i-1))%mod;
        tmp=tmp*(n-i-1)%mod*power(i+1,mod-2)%mod;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 1; i <= n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
#define MP make_pair
#define FI first
#define SE second
#define VI vector<int>
#define CLR(x) memset(x, 0, sizeof(x))
#define SZ(x) (x.size())
#ifdef QWERTIER
#define err(x) cerr<<x<<endl;
#else
#define err(x)
#endif

typedef long long LL;

int n;
#define N 100010
int a[N], rt;
vector<int> adj[N];
LL up[N];
bool dfs(int u, int fa) {
  LL s = 0;
  for (auto v : adj[u]) {
    if (v == fa)
      continue;
    if (!dfs(v, u))
      return false;
    s += up[v];
  }
  //printf("%d %I64d %d\n", u, s, a[u]);
  if (adj[u].size() == 1) {
    up[u] = a[u];
    return true;
  }
  LL c;
  if (u != rt) {
    if (s < a[u])
      return false;
    c = s-a[u];
  } else {
    if (s != 2ll*a[u])
      return false;
    c = a[u];
  }
  up[u] = a[u] - c;
  if (up[u] < 0)
    return false;
  int maxa = 0;
  for (auto v : adj[u]) {
    if (v == fa)
      continue;
    maxa = max((LL)maxa, up[v]);
  }
  if (s - maxa < c)
    return false;
  return true;
}

int main() {
#ifdef QWERTIER
  freopen("in.txt", "r", stdin);
#endif
  scanf("%d", &n);
  FOR (i, n) {
    scanf("%d", &a[i]);
  }
  FOR (i, n-1) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  if (n==2) {
    puts(a[1]==a[2]?"YES":"NO");
  } else {
    FOR (i, n) {
      if (adj[i].size() > 1) {
        rt = i;
        break;
      }
    }
    puts(dfs(rt, 0)  ? "YES" : "NO");
  }
  return 0;
}
 


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

int main() {
	string w;	
	int c, i, s;
	while (cin >> w) {
		if (w == "-") break;
		cin >> c;
		for (i = 0; c-- ;) {
			cin >> s;
			i += s;
		}
		i %= w.length();
		cout << w.substr(i) + w.substr(0, i) << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
def main():
    N, M = map(int, input().split())
    cities = dict()
    for i in range(M):
        P, Y = map(int, input().split())
        if P not in cities:
            cities[P] = [[Y, i]]
        else:
            cities[P].append([Y, i])

    ans = [0 for _ in range(M)]
    for P in cities:
        cities[P] = sorted(cities[P])
        id = 1
        for _, j in cities[P]:
            ans[j] = "0"*(6-len(str(P)))+str(P)+ "0"*(6-len(str(id))) + str(id)
            id += 1
    for s in ans:
        print(s)

if __name__ == '__main__':
    main()

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

int main(){
  while(true){
    int n;
    cin >> n;
    if(n==0){
      break;
    }

    int INF=1000000000;
    int T[10][10];
    for(int i=0; i<10; i++){
      for(int j=0; j<10; j++){
        T[i][j] = INF;
        if(i==j){
          T[i][j] = 0;
        }
      }
    }

    int a,b,cost,m=0;
    for(int i=0; i<n; i++){
      cin >> a >> b >> cost;
      T[a][b] = T[b][a] = cost;

      if(m<a){
        m=a;
      }
      if(m<b){
        m=b;
      }
    }

    for(int k=0; k<m+1; k++){
      for(int i=0; i<m+1; i++){
        for(int j=0; j<m+1; j++){
            if(T[i][j] > T[i][k] + T[k][j]){
              T[i][j] = T[i][k] + T[k][j];
            }
        }
      }
    }

  //  cout << "ekinokazu " << m << endl;
    int total=0,total2=10000,nummber;

    for(int i=0; i<m+1; i++){   //どこの駅から始まるか
      for(int j=0; j<m+1; j++){   //どこの駅で終わるか
        total = total + T[i][j];
        //cout << i << "駅start" << j << "駅まで " << T[i][j] << endl;
        if(j==m){
          //cout << i << "駅start " << total << endl;
          if(total2>total){
            total2 = total;
            nummber = i;
          }
          total = 0;
        }
      }
    }
    cout << nummber << ' ' << total2 << endl;

  }

  return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    cout << fixed << setprecision(10) << 1.0 * ((n + 1) / 2) / n << endl;
}

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


Measured memory_bytes: 3764
#include <iostream>
using namespace std;
string s;
int main(){
	int n;
	cin >> n;
	cin >> s;
	int r = 0, g = 0, b = 0;
	long long ans = 0;
	for(int i = 0; i < n; i++){
		long long cur;
		if(s[i] == 'R'){
			r++;
			cur = g * b;	
		}
		if(s[i] == 'G'){
			g++;
			cur = r * b;
		}
		if(s[i] == 'B'){
			b++;
			cur = g * r;
		}
		for(int j = 1; j <= i; j++){
			int f = i;
			int e = i - j;
			int t = e - j;
			if(t < 0) break;
			if(s[f] != s[e] && s[f] != s[t] && s[e] != s[t]) cur--;
		}
		ans += cur;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
A, B, C, D, E, F = map(int, input().split())

density = 0
max_density = 0
ans = []
for a in range(31):
    if a*A*100> F:
        break
    for b in range(31):
        if a==0 and b==0:
            continue
        if a*A*100+b*B*100>F:
            break
        for c in range(101):
            for d in range(101):
                density = 100*(c*C+d*D)/(a*A*100 + b*B*100 + c*C + d*D)
#                 if c==0 and d==0 and max_density <= density:
#                     ans.append("{} {}".format(a*A*100+b*B*100+c*C+d*D, c*C+d*D))
                if a*A*100+b*B*100*c*C+d*D>F:
                    break
#                 print(a*A*100 + b*B*100 + c*C + d*D)
                if ( a*A*100 + b*B*100 + c*C + d*D <= F ) and ( 100*(c*C+d*D)/(a*A*100 + b*B*100 + c*C + d*D) <= 100*E/(100+E) ):
#                     print(density)
#                     print("{} {}".format(a*A*100+b*B*100, c*C+d*D))
                    if max_density <= density:
#                         print(max_density)
                        max_density = density
                        ans.append("{} {}".format(a*A*100+b*B*100+c*C+d*D, c*C+d*D))


print(ans[-1])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




int main(){

	int r,g,b;
	scanf("%d %d %d",&r,&g,&b);

	if((100*r+10*g+b)%4 == 0){

		printf("YES\n");

	}else{

		printf("NO\n");
	}

	return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    int N;
    cin >> N;
    int ans = 0;
    int tmp = 1;
    while(true){
        tmp *= 2;
        if(N >= tmp){
            ans++;
            continue;
        }else{
            break;
        }

    }
    cout << pow(2, ans) << endl;
    return 0;
}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 1e6;
int dp[maxn]; VI G[maxn];

bool topsort(const int n)
{
    VI degree(n);
    FOR(u,0,n) FOR_ALL(v,G[u])
        degree[*v]++;
    queue<int> Q;
    FOR(u,0,n) if (!degree[u])
        Q.push(u);
    int m = 0;
    while (Q.size()) {
        const int u = Q.front(); Q.pop();
        FOR_ALL(v,G[u]) if (--degree[*v] == 0)
            Q.push(*v);
        m++;
    }
    return n == m;
}

int dfs(const int u)
{
    int& ans = dp[u];
    if (-1 == ans) {
        ans = 1;
        FOR_ALL(v,G[u])
            ans = max(ans, dfs(*v)+1);
    }
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    while (cin >> n) {
        int cnt = 0; map<PII,int> node; const int nmatch = n*(n-1)/2;
        FOR(i,0,nmatch)
            G[i].clear();
        FOR(i,1,n+1) FOR(j,i+1,n+1)
            node[PII(i,j)] = cnt++;
        FOR(i,1,n+1) {
            int pre = -1;
            FOR(j,0,n-1) {
                int u = i; int v; cin >> v;
                if (v < u)  
                    swap(u,v);
                const int x = node[PII(u,v)];
                if (pre != -1)
                    G[pre].push_back(x);
                pre = x;
            }
        }
        if (!topsort(nmatch))
            cout << -1 << endl;
        else {
            memset(dp,-1,sizeof(dp));
            int ans = 0;
            FOR(i,0,nmatch)
                ans = max(ans,dfs(i));
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 74464
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N,Q;
	string s;
	cin >> N >> Q >> s;
	V<char> t(Q),d(Q);
	rep(i,Q){
		cin>>t[i]>>d[i];
	}
	auto Doit = [&](int x){
		rep(i,Q){
			if(t[i] == s[x]){
				if(d[i] == 'L') x--;
				else x++;
				if(x == -1 || x == N) break;
			}
		}
		return x;
	};
	int ans = 0;
	{
		int lb = -1, ub = N;
		while(ub-lb>1){
			int m = (lb+ub)/2;
			if(Doit(m) == -1) lb = m;
			else ub = m;
		}
		ans += ub;
	}
	{
		int lb = -1, ub = N;
		while(ub-lb>1){
			int m = (lb+ub)/2;
			if(Doit(m) == N) ub = m;
			else lb = m;
		}
		ans += N-ub;
	}
	cout << N-ans << endl;
}


Measured memory_bytes: 976
#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 VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#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 != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=1,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vi DV(n);
  VIN(DV)
  RSORT(DV);
  FOR(i,1,n){
  	if(DV[i] < DV[i-1]) c++;
  }
  x = max(x,c);
  OUT(x);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long       ll;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define fore(i, b, e)      for(int i = b; i < e; i++)
#define forr(i, b, e)      for(int i = b; i < e; i++)
#define forg(i, b, e, m)  for(int i = b; i < e; i+=m)
#define F first
#define S second
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;

typedef pair<int, int>  ii;
typedef pair<int, ii>  iii;
typedef vector<int>     vi;

typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int INF = int(1e9 + 7);
const double PI = acos(-1);
const double EPS = 1e-9;
#define tam 1234567

int main()
{
   ll a,b;
   cin>>a>>b;
   forr(i,1,tam)
   {
        if (ll((i*8)/100)==a && ll((i/10))==b)
        {
            cout<<i<<endl;
            return 0;
        }
   }
   cout<<"-1\n";
   
}
// PLUS ULTRA!

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>//printf("%.*f\n",*********);
#include<vector>//s.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char('a'=32+'A')
//to_string,string,substr
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap

#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(a,n) rep(i,n)cin>>a[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

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

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}

bool KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */

int main(void) {

	int a, b;
	cin >> a >> b;
	if ((a + b) % 2 == 0) {
		cout << (a + b) / 2 << rt;
	}
	else {
		cout << "IMPOSSIBLE" << rt;
	}

	please AC;
}
//参考：---

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int d, n;
	cin >> d >> n;
	if (n == 100) n++;
	int ans = n * pow(100, d);
	cout << ans << endl;
	return 0;
}


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

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

// 無限大の値
const long long INF = 1LL << 60;

int main(){
    int N;
    long long h[100000];
    long long dp[100000]; // i番目の石場にいくための最短のコスト

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

    dp[0] = 0;
    for(int i = 1; i < N; i++){
        dp[i] = INF;
    }
    
    long long res1 = INF;
    long long res2 = INF;
    for(int i=1; i<N; i++){
        res1 = dp[i-1] + abs(h[i] - h[i-1]);
        if(i > 1) res2 = dp[i-2] + abs(h[i] - h[i-2]);
        dp[i] = min(res1, res2);
    }

    cout << dp[N-1] << endl;
    
    return 0;
}

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

using namespace std;
typedef long long ll;

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

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

	int multi = a;
	rep(i, 100)
	{
		if (multi % b == c)
		{
			cout << "YES" << '\n';
			return 0;
		}
		multi += a;
	}
	cout << "NO" << '\n';
	return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int sx,sy,tx,ty;
ll a[200003];
ll b[2003];
bool vis[1009][1009];
struct threeElements{
int f,s,t;
};
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
   int n;
char c;
cin>>c;
if(isupper(c))
    cout<<"A";
else
    cout<<"a";
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw	 "\n"
#define mod 1000000007

ll w,e;
int main(void)
{
	CIN;
	ll tc,l,k=0,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	cin>>n;
  n++;
	l=to_string(n).size()-1;
	cout<<l*9+to_string(n)[0]-'1';
}

Measured memory_bytes: 3712
#include <string>
#include <iostream>
using namespace std;
int main() {
    string str;
    
    cin >> str;

    int last = str.length()-1;
    int result = 0;
    for(int i = 0; i < last/2+1; i++) {
//        cout << "str[i]:" << str[i] << "\n";
//        cout << "str[last-i]:" << str[last-i] << "\n";
        if (str[i] != str[last-i])
            result++;
    }
    cout << result;

    return 0;
}


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

int main() {

	int n;
	vector<int> S(23);
	vector<int> sort(3);
	int count=0;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> S.at(i);
	}

	for (int i = 0; i <n-2; i++) {
		sort.at(0) = S.at(i);
		sort.at(1) = S.at(i+1);
		sort.at(2) = S.at(i+2);

		//for (int j = i; j < 3; j++) {
			std::sort(sort.begin(), sort.end());
			if (sort.at(1) == S.at(i + 1)) count++;
		//}
	}


	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
// Minimum Spanning Tree

#include <iostream>
#include <algorithm>
#include <vector>
#define MAX 10000
#define INFTY 1 << 29
  
using namespace std;
vector<int> par,rank1;
 
struct Edge{
  int source, target, cost;
 
  Edge(int source, int target, int cost) : source(source), target(target), cost(cost) {}
   
  /*bool operator < (const Edge &e) const {
    return cost < e.cost;
  }*/
};
  
void init_UnionFind(int v){
  par = vector<int>(v);
  rank1 = vector<int>(v);
  for(int i = 0 ; i < v; i++){
    par[i] = i; 
    rank1[i] = 0;
  }
}
  
int find(int x){ 
  if(par[x] == x) return x; 
  return par[x] = find(par[x]);
}
  
void unite(int x,int y){ 
  x = find(x); y = find(y);
  if(y == x) return;
    
  if(rank1[x] < rank1[y]){
    par[x] = y;
  } else {
    par[y] = x;
    if(rank1[x] == rank1[y]) rank1[x]++;
  }
}
  
bool same(int x,int y){
  return find(x) == find(y);
}
 
bool comp(const Edge& e1, const Edge& e2){
  return e1.cost < e2.cost;
}
 
int kruskal(int V, vector<Edge> e){
  int ansCost = 0;
  //sort(e.begin(), e.end());
  sort(e.begin(), e.end(), comp);
 
  init_UnionFind(V);
  for(int i = 0; i < e.size(); i++){
    Edge edge = e[i];
    if(!same(edge.source, edge.target)){
      ansCost += edge.cost;
      unite(edge.source, edge.target);
    }
  }
  return ansCost;
}
 
int main(){
  int V, E, source, target, cost;
  vector<Edge> e;
 
  cin >> V >> E;
 
  for(int i = 0; i < E; i++){
    cin >> source >> target >> cost;
    e.push_back(Edge(source, target, cost));
  }
 
  cout << kruskal(V,e) << endl;
  return 0;
}


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

int main(){
    int n,m;
    int aa[200005];
    long long int ans=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        scanf("%d",&aa[i]);
    }
    sort(aa+1,aa+1+n);
    if(m>=n)
        cout<<"0";
    else{
        for(int i=1;i<=n-m;i++){
            ans=ans+aa[i];
        }
        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 1024
from collections import deque
def max_dis_from(xi,yi):
    d = deque([(xi,yi)])
    dis = [[-1]*(w+2) for i in range(h+2)]
    dis[yi][xi] = 0
    while d:
        x,y = d.popleft()
        for i in range(4):
            newy = y+dy[i]
            newx = x+dx[i]
            if maze[newy][newx] == "." and dis[newy][newx] == -1:
                d.append((newx,newy))
                dis[newy][newx] = dis[y][x] + 1
    return dis[y][x]   
h,w = map(int,input().split())
maze = []
maze.append(["#"]*(w+2))
for i in range(h):
    maze.append(["#"]+list(input())+["#"])
maze.append(["#"]*(w+2))
dx = [0,1,0,-1]
dy = [1,0,-1,0]
maxdis = 1
for i in range(1,h+1):
    for j in range(1,w+1):
        if maze[i][j] == ".":
            maxdis = max(maxdis,max_dis_from(j,i))
print(maxdis)

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

#define ran 1011

int n, k;
int a[ran];

int main() {
	scanf("%d%d", &n, &k);
	for(int i=0;i<n;i++) scanf("%d", &a[i]);
	sort(a, a+n);
	
	int ans = 0;
	for(int i=0;i<k;i++)
		ans += a[i];
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 3840
import numpy as np
n=int(input())
w=[int(x) for x in input().split()]
list=[]
list2=[]
for i in range(n):
  list.append(sum(w[:i+1]))
  list2.append(sum(w[i+1:]))
comb = [x - y for (x, y) in zip(list, list2)]
ans=np.abs(comb)
print(min(ans))


Measured memory_bytes: 21800