akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;

vector<pair<int,int> > graph[100001];
vector<int> color;
vector<int> flag;

int input()
{
  int n;
  cin >> n;
  for(int i=0; i<n-1; i++)
  {
    int u,v,w;
    cin >> u >> v >> w;
    graph[u-1].push_back(make_pair(v-1,w));
    graph[v-1].push_back(make_pair(u-1,w));
    color.push_back(0);
    flag.push_back(0);
  }
  color.push_back(0);
  flag.push_back(0);
  return n;
}

int conv(int x)
{
  if(x==0){
    return 1;
  } else {
    return 0;
  }
}

void dfs(int s)
{
  flag.at(s) = 1;
  std::vector<pair<int,int> >::iterator itr;
  // for every edge from s
  for(itr=graph[s].begin(); itr!=graph[s].end(); itr++)
  {
    if(flag.at((*itr).first)==1){
      continue;
    }
    int v,w;
    v = (*itr).first;
    w = (*itr).second;
    if(w%2==0){
      color.at(v) = color.at(s);
    } else {
      color.at(v) = conv(color.at(s));
    }

    dfs(v);
  }
}

int main()
{
  int n;
  n = input();
  dfs(0);
  for(int i=0; i<n; i++)
  {
    cout << color.at(i) << endl;
  }
  return 0;
}


Measured memory_bytes: 9072
a = list(map(int,input().split()))
ev = a[0]
od = a[1]
if (ev==0)and(od==0):
  n = 0
elif ev==0:
  n = a[1]*(a[1]-1)/2
elif od==0:
  n = a[0]*(a[0]-1)/2
else:
  n = a[0]*(a[0]-1)/2+a[1]*(a[1]-1)/2
print(int(n))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdlib>
using namespace std;
int main(void) {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if (abs(a-c)<=d) cout<<"Yes"<<endl;
    else if (abs(a-b)<=d&&abs(b-c)<=d){
        cout<<"Yes"<<endl;
    }
        else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    vec<ll> A(N),B(N),C(N);
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    rep(i,N) cin >> C[i];
    sort(all(A));sort(all(B));sort(all(C));

    ll ans = 0;
    rep(i,N){
        ll b = B[i];
        ll a = lower_bound(all(A),b) - A.begin();
        ll c = upper_bound(all(C),b) - C.begin();
        ans+=a*(C.size()-c);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    ll A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    ll ans = 0;
    if (A + B > 2 * C) {
        ll res = min(X, Y);
        ans += 2 * C * res;
        X -= res;
        Y -= res;
    }
    ans += (A > 2 * C) ? 2 * C * X : A * X;
    ans += (B > 2 * C) ? 2 * C * Y : B * Y;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
x1,x2,x3,x4,x5 = map(int,input().split())
if x1 == 0:
    print(1)
    exit()
if x2 == 0:
    print(2)
    exit()
if x3 == 0:
    print(3)
    exit()
if x4 == 0:
    print(4)
    exit()
if x5 == 0:
    print(5)
    exit()


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

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

  ll X; cin >> X;
  for (ll i = 1; i < 500; i++) {
    if ((X * i) % 360 == 0) {
      cout << i << '\n';
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

//AtCoder Beginner Contest 159
//A	The Number of Even Pairs
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		sc.close();

		System.out.println((N*(N-1))/2+(M*(M-1))/2);
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b;
    c=a-(2*b);
    if(c>0)cout << c;
    else cout <<0;
    return 0;
}

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

using namespace std;
#define NIL -1
#define ll long long
#define MAX 100
#define pb push_back

int main()
{
	int n;
	cin >> n;
	int m=-1;
	int ans = 0;
	for(int i=1; i<=n; i++) {
		int x = i;
		int cnt = 0;
		while(x%2==0) {
			x/=2;
			cnt++;
		}
		if(m < cnt) {
			ans = i;
			m = cnt;
		}
	}
	cout << ans<< endl;
	return 0;
}


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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define Fix( x ) setprecision( x ) << fixed
#define mem( a , x ) memset( a , x , sizeof( a ) )
#define bug( a , b ) cerr<< #a <<" = "<<a<<" , "<< #b <<" = "<<b<<"\n";
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define FOR( i , a , b ) for( int i = a; i <= b; i++ )
#define ROF( i , a , b ) for( int i = a; i >= b; i-- )
#define sz( V ) (int)V.size( )
#define all( V ) V.begin( ),V.end( )
#define Found( S , val ) S.find( val ) != S.end( )
#define Unique( V ) sort( all( V ) ), V.erase( unique( all( V ) ), V.end() )
typedef pair < int , int > ii;
typedef pair < int , ii > iii;
typedef long long int LL;
typedef unsigned long long uLL;
const int inf = (int)1e9;
const LL INF = (LL)1e18;
const int N = 100005;
const int mod = 1000000007;
const double eps = 1e-8;
const double pi = acos( -1.0 );


int main( int argc, char const *argv[] ) {
        fast_io;
        int n = 0;
        string s;
        cin >> s;
        for( auto x : s ) {
                if( x == '+' ) n++;
                else n--;
        }
        cout << n << endl;
        return 0;
}








Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 4e5 + 33, mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll n, q, tp;
deque<char> s;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string t;
	cin >> t;
	for(auto i : t) s.pb(i);
	cin >> q;
	int rev = 0;
	int f;
	char c;
	while(q--) {
		cin >> tp;
		if(tp==1) {
			rev^=3;
			continue;
		}
		cin >> f >> c;
		f ^= rev;
		if(f==1) s.push_front(c);
		else s.push_back(c);
	}
	t.clear();
	for(auto i : s) t.pb(i);
	if(rev) reverse(all(t));
	cout << t;
}



Measured memory_bytes: 1168
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#define int long long
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define fcout cout << fixed << setprecision(10)
using namespace std;

signed main() {
  string s;
  cin >> s;
  if(s[(int)s.size()-1] == 's') cout << s << "es\n";
  else cout << s << "s\n";
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  long long m = 1;
  for (int i = 0; i < n; i++) m *= a[i];
  long long ans = 0;
  for (int i = 0; i < n; i++)
  {
    ans += a[i] - 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3648
#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

const double PI = acos(-1);
constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class Task{
public:
    void solve(istream& in, ostream& out){
        int N;
        in>>N;
        vc<int> A(N);
        REP(i, N) in>>A[i];
        lint ans = 1000;
        REP(i, N-1){
            if(A[i]<A[i+1]){
                ans += ans / A[i] * (A[i+1]-A[i]);
            }
        }
        out<<ans<<'\n';
    }
};

int main(){
    istream& in(cin);
    ostream& out(cout);
    ios_base::sync_with_stdio(false);
    in.tie(nullptr), out.tie(nullptr);
    Task solver;
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 3660
N, K = map(int, input().split())

h_list = [int(input()) for _ in range(N)]
h_list.sort(reverse=True)

minmax = 10e10
for i in range(N - K + 1):
    minmax = min(minmax, h_list[i] - h_list[i + K - 1])

print(minmax)


Measured memory_bytes: 50508
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n = get!(i64);
    let mut v = get!([i64]);
    for i in 0..v.len() {
        v[i] = v[i] - i as i64 - 1;
    }
    v.sort();
    let b = v[(n / 2) as usize];

    let mut ans = 0;
    for i in 0..v.len() {
        ans += (b - v[i]).abs();
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(input())
S = input()

ans = 0
for i in range(1000):
    secret = ('0' * 2 + str(i))[-3:]
    j = 0
    for c in S:
        if c == secret[j]:
            j += 1
        if j >= 3:
            ans += 1
            break
print(ans)


        

Measured memory_bytes: 74172
// C - 2D Plane 2N Points
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
	int N; cin>>N;
	vector<vi> AB(N, vi(2)), CD(N, vi(2));
	rep(i, N) cin>>AB[i][0]>>AB[i][1];
	rep(i, N) cin>>CD[i][0]>>CD[i][1];

	sort(all(CD));
	sort(all(AB), [](vi a, vi b){ return a[1] > b[1]; });

	vi vis_r(N, false);
	rep(b, N)
		rep(r, N)
			if(!vis_r[r] && AB[r][0] < CD[b][0] && AB[r][1] < CD[b][1])
				{ vis_r[r] = true; break; }

	cout<< accumulate(all(vis_r), 0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    string s;cin>>s;
    if(n%2==0&&s.substr(0,n/2)==s.substr(n/2,n/2))cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

template<i64 M>
struct modint {
    i64 x;

    constexpr modint(const i64 y = 0) noexcept : x(y >= 0 ? y % M : (M - (-y) % M) % M) {}

    constexpr modint operator-() const noexcept { return modint(-x); }
    constexpr modint operator+(const modint &rhs) const noexcept { return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const noexcept { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const noexcept { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const noexcept { return modint(*this) /= rhs; }

    constexpr modint &operator+=(const modint &rhs) noexcept {
        x += rhs.x;
        if (x >= M) x -= M;
        return *this;
    }

    constexpr modint &operator-=(const modint &rhs) noexcept {
        if (x < rhs.x) x += M;
        x -= rhs.x;
        return *this;
    }

    constexpr modint &operator*=(const modint &rhs) noexcept {
        x = x * rhs.x % M;
        return *this;
    }

    constexpr modint &operator/=(const modint &rhs) noexcept {
        i64 a = rhs.x, b = M, u = 1, v = 0;
        while (b > 0) {
            i64 t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        *this *= u;
        return *this;
    }

    friend ostream &operator<<(ostream &os, const modint &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, modint &a) {
        i64 t;
        is >> t;
        a = modint(t);
        return is;
    }
};

// constexpr i64 MOD = 1'000'000'007;
constexpr i64 MOD = 998'244'353;
using m64 = modint<MOD>;

void solve() {
    i64 n, s;
    cin >> n >> s;

    vector<vector<m64>> dp(n + 1, vector<m64>(s + 1));
    dp[0][0] = 1;
    for (i64 i = 0; i < n; i++) {
        i64 a;
        cin >> a;

        for (i64 j = s; j - a >= 0; j--) dp[i + 1][j] += dp[i][j - a];
        for (i64 j = 0; j <= s; j++) dp[i + 1][j] += dp[i][j] * 2;
    }

    cout << dp[n][s] << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 73672
#include<iostream>

using namespace std;

int main(void){
  int n,k,x,y;
  cin>>n>>k>>x>>y;
  int sum=0;
  for(int i=1;i<=n;i++){
    if(i>k){
     sum+=y; 
    }else{
      sum+=x;
    }
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 256
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
using namespace std;
long long mod = 1000000000 + 7;


int main()
{
	string s;
	cin >> s;
	
	int k = s.size();

	int win = 0;
	for (int i = 0; i < k; i++) {
		if (s[i] == 'x') {
			win++;
		}
	}
	string ans = "YES";

	if (win >= 8) {
		ans = "NO";
	}

	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
unsigned long long lcd(unsigned long long a,unsigned long long b)
{
	return a*b/__gcd(a,b);
}
int main()
{
	unsigned long long a,b,c,d;
	cin>>a>>b>>c>>d;
	unsigned long long sum1=b/c-(a-1)/c;
	unsigned long long sum2=b/d-(a-1)/d;
	unsigned long long all=b/lcd(c,d)-(a-1)/lcd(c,d);
	cout<<(b-a+1)-sum1-sum2+all;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int i, sum=0;
  char s[3];
  
  scanf("%s", s);
  
  for(i=0;i<3;i++){
    if(s[i] == '1'){
      sum++;
    }
  }
  
  printf("%d", sum);
  
  return 0;
}

Measured memory_bytes: 128
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a > mod)a %= mod;
}
// void multiply(ll F[2][2], ll M[2][2]) {
//    ll a = (F[0][0] * M[0][0] + F[0][1] * M[1][0])%m;
//    ll b= (F[0][0] * M[0][1] + F[0][1] * M[1][1])%m;
//    ll c = (F[1][0] * M[0][0] + F[1][1] * M[1][0])%m;
//    ll d = (F[1][0] * M[0][1] + F[1][1] * M[1][1])%m;
//    F[0][0] = a;
//    F[0][1] = b;
//    F[1][0] = c;
//    F[1][1] = d;
// }
// void power(ll F[2][2], ll n) {
//    if (n == 0 || n == 1)
//       return;
//    ll M[2][2] = {{1,1},{1,0}};
//    power(F, n / 2);
//    multiply(F, F);
//    if (n % 2 != 0)
//       multiply(F, M);
// }
const int maxn = 51;
vector<vector<ll> > M;
vector<vector<ll> > F;
int n;
void multiply(vector<vector<ll> > M1){
	ll temp[n][n];
	rep(i,n){
		rep(j,n){
			temp[i][j] = 0;
			// cout<<M1[i][j]<<" ";
			rep(k,n){
				temp[i][j] += F[i][k]*M1[k][j];
				temp[i][j] %= mod;
			}
		}
		// cout<<"\n";
	}
	rep(i,n){
		rep(j,n){
			F[i][j] = temp[i][j];
		}
	}
}
void fastmatrixexp(ll a){
	if(a == 0 || a == 1)
		return;
	// ll C[n][n];
	fastmatrixexp(a/2);
	multiply(F);
	if(a % 2)multiply(M);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin>>n;
	ll k;
	cin>>k;
	rep(i,n){
		vector<ll> temp(n);
		rep(j,n){
			cin>>temp[j];
			// cin>>M[i][j];
			// F[i][j] = M[i][j];
		}
		F.pb(temp);
		M.pb(temp);
	}
	fastmatrixexp(k);
	ll ans = 0;
	rep(i,n){
		rep(j,n){
			add(ans,F[i][j]);
			// cout<<F[i][j]<<" ";
		}
		// cout<<"\n";
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
long double dis(long long a,long long b){
  return sqrt(a*a+b*b);
}
int main(){
  int n;
  long double d;
  cin>>n>>d;
  int cnt=0;
  vector<int> x(n),y(n);
  for(int i=0;i<n;i++){
    cin>>x.at(i)>>y.at(i);
    if(dis(x.at(i),y.at(i))<=d)cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 4860
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.StringTokenizer;

public class Main {

	public static void main(String args[]) throws Exception {
		MyScanner sc = new MyScanner();
		int t = sc.nextInt();
		BigDecimal r = new BigDecimal(Integer.toString(t));
		BigDecimal area = new BigDecimal("0");
		BigDecimal two = new BigDecimal("2.0");
		BigDecimal pi = new BigDecimal(Double.toString(Math.PI));
		area = two.multiply(r).multiply(pi);
		System.out.println(area);
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}

Measured memory_bytes: 33656
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int N = 0;
    int value[100] = {0};
    int valueA = 0,valueB = 0;
    int result = 0;
    int minResult = 1000;
    
    scanf("%d",&N);
    for (int i=0; i<N; i++) {
        scanf("%d",&value[i]);
        if (i==0) {
            valueA = value[i];
        }else{
            valueB += value[i];
        }
    }
    for (int i=1; i<N; i++) {
        result = valueA - valueB;
        if (result < 0) {
            result = valueB - valueA;
        }
        if (minResult > result) {
            minResult = result;
        }
        
        valueA = valueA + value[i];
        valueB = valueB - value[i];
    }
    printf("%d",minResult);
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <queue>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int W, H, n;

int compress(vector<int> &x1, vector<int> &x2, int w) {
	vector<int> xs;

	rep(i, n) {
		for(int d = -1; d <= 1; d++) {
			int tx1 = x1[i] + d, tx2 = x2[i] + d;
			if(1 <= tx1 && tx1 < w) xs.push_back(tx1);
			if(1 <= tx2 && tx2 < w) xs.push_back(tx2);
		}
	}

	xs.push_back(0);
	xs.push_back(w-1);

	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(),xs.end()),xs.end());

	rep(i, n) {
		x1[i] = find(xs.begin(), xs.end(), x1[i]) - xs.begin();
		x2[i] = find(xs.begin(), xs.end(), x2[i]) - xs.begin();
	}

	return xs.size();
}

bool used[1000 * 6 + 5][1000 * 6 + 5];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

bool can(int y,int x) {
	if(0 <= y && y < H && 0 <= x && x < W) return true;
	return false;
}

int main() {

	while(cin >> W >> H) {
		if(W == 0 && H == 0) break;
		cin >> n;

		vector<int> x1(n), x2(n), y1(n), y2(n);
		rep(i, n) {
			cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
		}

		W = compress(x1, x2, W);
		H = compress(y1, y2, H);

		memset(used, 0, sizeof(used));
		rep(i, n) {
			REP(y, y1[i], y2[i]) {
				REP(x, x1[i], x2[i]) {
					used[y][x] = true;
				}
			}
		}

		int ans = 0;
		rep(i, H) {
			rep(j, W) {
				if(used[i][j]) continue;
				ans++;

				queue<P> que;
				que.push(mp(i, j));
				used[i][j] = true;

				while(que.size()) {
					P p = que.front();
					que.pop();

					rep(k, 4) {
						int ny = p.first + dy[k];
						int nx = p.second + dx[k];

						if(can(ny, nx) && !used[ny][nx]) {
							used[ny][nx] = true;
							que.push(mp(ny, nx));
						}
					}
				}
			}
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 36464
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  int N;
  cin >> N;
  int A[N];
  rep(i,N) cin >> A[i];
  sort(A,A+N,greater<int>());
  int max=A[0];
  int mid1=ceil((double)max/2),mid2=max/2;
  int ans=INF;
  for(int i=1;i<N;i++){
    if(abs(ans-mid1)>abs(A[i]-mid1)) ans=A[i];
    if(abs(ans-mid2)>abs(A[i]-mid2)) ans=A[i];
  }
  cout << max << " " << ans << endl;
}

Measured memory_bytes: 640
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    vector<int> a(n), b(n), c(n-1);
    for(int i=0; i<n; i++) cin>>a[i];
    for(int i=0; i<n; i++) cin>>b[i];
    for(int i=0; i<n-1; i++) cin>>c[i];

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

    cout << accumulate(b.begin(), b.end(), 0) + csum << endl;
}


Measured memory_bytes: 256
"use strict";
    
function lowerBound(arr, n) {
    var first = 0, last = arr.length - 1, middle;
    while (first <= last) {
        middle = 0 | (first + last) / 2;
        if (arr[middle] < n) first = middle + 1;
        else last = middle - 1;
    }
    return first;
}

function upperBound(arr, n) {
    var first = 0, last = arr.length - 1, middle;
    while (first <= last) {
        middle = 0 | (first + last) / 2;
        if (arr[middle] <= n) first = middle + 1;
        else last = middle - 1;
    }
    return first;
}

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const A = arg[1].split(" ").map(n=>parseInt(n)).sort((a,b)=>a-b);
    const B = arg[2].split(" ").map(n=>parseInt(n)).sort((a,b)=>a-b);
    const C = arg[3].split(" ").map(n=>parseInt(n)).sort((a,b)=>a-b);
    
    let answer = 0;
    
    for(let i=0; i<N; i++) {
        let top = lowerBound(A, B[i]);
        let bottom = upperBound(C, B[i]);
        
        answer += top * (N - bottom)
        
        // console.log("top:" + top);
        // console.log("bottom:" + bottom);
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 56560
#include<bits/stdc++.h>
#define f first
#define s second
#define inf 999999999999
#define N  500009
#define M  (L+R)/2
#define ll long long
#define pb push_back
using namespace std;

struct node{
	ll MAX;
	node *left, *right;
	node(): MAX(0), left(NULL), right(NULL){}
};

node *root(NULL);

void upd(node *&parent, ll L, ll R, ll ind, ll x){
	
	if(!parent){
		parent=new node();
	}
	if(L+1==R){
		parent->MAX=x;
		return;
	}
	if(ind<M){
		upd(parent->left,L,M,ind,x);
	} else {
		upd(parent->right,M,R,ind,x);	
	}
	parent->MAX=max((parent->left?parent->left->MAX:0),(parent->right?parent->right->MAX:0));
}

ll get(node *&parent, ll L, ll R, ll l, ll r){
	if(parent){
		if(L>=r || R<=l)return 0;
		if(l<=L && R<=r)return parent->MAX;
		return max(get(parent->left,L,M,l,r),get(parent->right,M,R,l,r));
	}
	return 0;
}

ll n,a[N],ans,pre1,pre2,suf1,suf2;

void answerpre(node *&parent, ll L, ll R, ll l, ll r, ll x){
	
	if(parent){	
		if(parent->MAX>x){
			if(l<=L && R<=r && L+1==R){
				pre2=max(pre2,L);
				return;
			}
			if(!(M>=r || R<=l) && pre2<R)answerpre(parent->right,M,R,l,r,x);
			if(!(L>=r || M<=l) && pre2<M)answerpre(parent->left,L,M,l,r,x);
		}	
	}
	return;
}

void answersuf(node *&parent, ll L, ll R, ll l, ll r, ll x){
	
	if(parent){	
		if(parent->MAX>x){
			if(l<=L && R<=r && L+1==R){
				suf2=min(suf2,L);
				return;
			}
			if(!(L>=r || M<=l) && suf2>L)answersuf(parent->left,L,M,l,r,x);
			if(!(M>=r || R<=l) && suf2>M)answersuf(parent->right,M,R,l,r,x);	
		}	
	}
	return;
}


int main()
{

	ios::sync_with_stdio(0);

	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		upd(root,1,n+1,i,a[i]);
	}
	
	for(int i=1;i<=n;i++){
		pre1=pre2=0;
		suf1=suf2=n+1;
		
		answerpre(root,1,n+1,1,i,a[i]);
		pre1=pre2;
		pre2=0;
		answerpre(root,1,n+1,1,pre1,a[i]);
		
		answersuf(root,1,n+1,i+1,n+1,a[i]);
		suf1=suf2;
		suf2=n+1;
		answersuf(root,1,n+1,suf1+1,n+1,a[i]);
	//	cout<<pre2<<" "<<pre1<<" "<<suf1<<" "<<suf2<<endl;
		ans+=((pre1-pre2)*(suf1-i)+(suf2-suf1)*(i-pre1))*a[i];
	//	cout<<(pre1-pre2)*(suf1-i)+(suf2-suf1)*(i-pre1)<<endl;
	}

	cout<<ans<<endl;

return 0;
}




Measured memory_bytes: 7296
#include <iostream>
#include <set>
#include <string>
using namespace std;
int main(){
    string s; cin >> s;
    set<char> st;
    for(int i=0;i<3;i++) st.insert(s[i]);
    if(st.size()==1) puts("No");
    else puts("Yes");
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

    int[] h = new int[n];
    for (int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
    }

    int[] dp = new int[h.length];
    Arrays.fill(dp, Integer.MAX_VALUE);

    dp[0] = 0;
    dp[1] = Math.abs(h[1] - h[0]);
    for (int i = 2; i < h.length; i++) {
      int v1 = Math.abs(h[i] - h[i-2]) + dp[i-2];
      int v2 = Math.abs(h[i] - h[i-1]) + dp[i-1];
      dp[i] = Math.min(v1, v2);
    }
    System.out.println(dp[dp.length - 1]);
  }
}

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

using ll = long long;

#define for_(i, a, b) for(int i = (a);i < (b);++i)
#define rfor_(i, a, b) for(int i = (b)-1;i >= (a);--i)
#define rep(i, n) for_(i, 0, n)
#define rrep(i, n) rfor_(i, 0, n)

string S;
int L;

int dp[12][2][2][2][2][2][2]; // pos, less, 3, 5, 7, other, non-zero

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

  cin>>S;
  L = S.length();

  dp[0][0][0][0][0][0][0] = 1;

  rep (i, L) rep (j, 2) rep(k, 2) rep(l, 2) rep(m, 2) rep(n, 2) rep(o, 2) {
    int lim = j ? 9 : S[i] - '0';
    rep (d, lim + 1) {
      dp[i + 1][j || d < lim][k || d==3][l || d==5][m || d==7][n || !(d==3||d==5||d==7||(!o&&d==0))][o || d>0] += dp[i][j][k][l][m][n][o];
    }
  }

  int ans = 0;
  rep (j, 2) ans += dp[L][j][1][1][1][0][1];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import fractions

N = int(input())
Ai = list(map(int, input().split()))
if Ai == [Ai[0]] * len(Ai):
    print(Ai[0])
    quit()

#Ai.sort()

i = 1
min = 1000000000
a = Ai[0]
for a2 in Ai[1:]:
    a_gcd = fractions.gcd(a, a2)
    if min > a_gcd:
        min = a_gcd
        if min <= 2:
            print(min)
            quit()

print(min)

Measured memory_bytes: 16284
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> *i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> " " >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

ll gcd(ll a,ll b) { return a?gcd(b%a,a):b; }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
signed main() {
    int n;
    cin>>n;
    int l=1;
    REP(i,n) {
        int t;
        cin>>t;
        l=lcm(l,t);
    }
    cout<<l<<endl;
    return 0;
}


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

class UnionFind{
    public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> parent;

    //-1で初期化
    //最初はすべてバラバラ
    UnionFind(int N){
        parent = vector<int>(N,-1);
    }

    //Aがどのグループに属しているか(Aの根)を調べる
    int root(int A){
        if(parent[A] < 0) return A;
        return parent[A]=root(parent[A]);
    }

    //自分のいるグループの頂点数を調べる
    int size(int A){
        return -parent[root(A)];
    }

    //AとBをくっつける
    bool connect(int A, int B) {
    //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        //既にくっついているからくっつけない
        if(A == B) return false; 

        //大きいほう(A)に小さいほう(B)をくっつける
        //大証が逆ならひっくり返す
        if(size(A) < size(B)) swap(A,B);

        //Aのサイズを更新する
        parent[A] += parent[B];
        //Bの親をAに変更する
        parent[B] = A;

        return true;
    }

    //AとBが同じグループならtrueを返す
    bool same(int A, int B){
        return root(A)==root(B);
    } 
};

int main(){
    int n,k,l;
    cin>>n>>k>>l;
    int p,q;
    UnionFind road(n),tetu(n);
    for(int i=0;i<k;i++){
        cin>>p>>q;
        p--,q--;
        road.connect(p,q);
    }
    int r,s;
    for(int i=0;i<l;i++){
        cin>>r>>s;
        r--,s--;
        tetu.connect(r,s);
    }

    map<pair<int,int>,int> cnt;
    for(int i=0;i<n;i++){
        cnt[make_pair(road.root(i),tetu.root(i))]++;
    }
    
    for(int i=0;i<n;i++){
        cout<<cnt[make_pair(road.root(i),tetu.root(i))]<<" ";
    }

}

Measured memory_bytes: 13568
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int all;
double res;
int n, m, k;

void solve(int num, int sum) {
  if (num == n) {
    res += (double)max(sum-k, 1) / all;
    return;
  }
  REP(i, m) {
    solve(num+1, sum+i+1);
  }
}

int main() {
  while(cin>>n>>m>>k,n||m||k) {
    all = 1;
    REP(i, n) all*=m;
    res = 0;
    solve(0, 0);
    printf("%.12f\n", res);
  }
}

Measured memory_bytes: 0
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var abk = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var vals = new List<int>();
            var max = GCD(abk[0], abk[1]);
            var count = 0;
            for (var i = max; i >= 1; i--)
            {
                if (max % i == 0) count++;
                if (count == abk[2])
                {
                    Console.WriteLine(i);
                    return;
                }
            }
        }

        static int GCD(int a, int b) => b == 0 ? a : GCD(b, a % b);
    }
}


Measured memory_bytes: 13396
a, b = map(str, input().split())
if a == 'H' and b == 'H':
    print('H')
elif a == 'H' and b == 'D':
    print('D')
elif a == 'D' and b == 'H':
    print('D')
elif a == 'D' and b == 'D':
    print('H')


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

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

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

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

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

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

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

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

#[allow(unused_imports)]
fn main() {
    use std::cmp::max;
    use std::cmp::min;
    use std::collections::HashMap;

    input!{
        s: chars,
    }

    let mut ans = 0;
    for c in s {
        if c == '1' {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>

#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head=0, tail=0, n;

void enqueue(P x){
  Q[tail]=x;
  if(tail+1==LEN)
    tail=0;
  else tail++;
}

P dequeue(){
  P x;
  x=Q[head];
  if(head+1==LEN)
    head=0;
  else head++;
  return x;
}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d%d",&n,&q);

  for (i=1;i<=n;i++){
    scanf("%s", u.name);
    scanf("%d", &u.t);
    enqueue(u);
  }
  while(head!=tail){
    u=dequeue();
    if(q<u.t){
      elaps=elaps+q;
      u.t=u.t-q;
      enqueue(u);
    }
    else {
      elaps=elaps+u.t;
      printf("%s %d\n",u.name,elaps);

    }
  }
  
  return 0;
}



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

int main(){
	int A,B;
	cin >> A >> B;
	if((B-1)%(A-1) == 0){
		cout << (B-1)/(A-1) << endl;
	}
	else{
		cout << (B-1)/(A-1) +1 << endl;
	}
}


Measured memory_bytes: 256
MM = input().split()
N = int(MM[0])
M = int(MM[1])
X = int(MM[2])
LL = input().split()
a = 0
b = 0
for i in LL:
  if int(i) <X:
    a +=1
  else:
    b +=1
if a <= b:
  print(a)
else:
  print(b)
  

Measured memory_bytes: 9116
import java.util.*

fun main(args:Array<String>){
    val (w,h,x,y) = readLine()!!.split(" ").map{it.toInt()}
    var k = 0
    if(w % 2 == 0 && h % 2 == 0 && w / 2 == x && h / 2 == y) k = 1
    val a = w.toDouble() * h.toDouble() / 2
    println("$a $k")
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

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

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

int main(){
	string a,b;
	cin>>a>>b;
	cout<<b<<a<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){ 
   int a,b,c;
   cin>>a>>b>>c;
   vector<int> s(b);
   rep(i,b){
      s[i]=0;
   }
   for(int i=a;i<=a*b;i++){
      if(i%a!=0) continue;
      s[i%b]++;
   }
   
   if(s[c]!=0) cout<<"YES";
   else cout<<"NO";




return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int l = ni();
		int all = l * n + (n * (n - 1) / 2);
		int result = 0;
		if(l >= 0) {
			result = all - l;
		} else {
			if(l + n - 1 >= 0) {
				result = all;
			} else {
				result = all - (l + n - 1);
			}
		}
		System.out.println(result);
	}
	
	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 22996
#include<cstdio>
using namespace std;

long gcd(long a,long b){
  if(b==0)
    return a;
  else
    return gcd(b,a%b);
}
int main(){
  long n,x;
  scanf("%ld %ld",&n,&x);
  printf("%ld\n",3*(n-gcd(n,x)));
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,one=0,four=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a%4==0){
			four++;
		}
		if(a%2==1){
			one++;
		}
	}
	if(n%2==1){
		if(four+1<one){
			cout<<"No"<<endl;
		}
		else{
			cout<<"Yes"<<endl;
		}
	}
	else{
		if(four<one){
			cout<<"No"<<endl;
		}
		else{
			cout<<"Yes"<<endl;
		}
	}
    return(0);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#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 REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll K = 0;
ll t;
ll ret = 0;
string s;
ll A[9];
bool a[9];
vl b;


void input() {
  REP(i, 9) {
    IN(t);
    A[i] = t;
  }
  IN(N);
  REP(i, N) {
    IN(t);
    b.pb(t);
  }
}

void solve() {
  REP(i, 9) {
    a[i] = false;
    REP(j, N) {
      if (A[i] == b[j]) {
        a[i] = true;
        break;
      }
    }
  }
  bool ok = false;
  if (a[0] && a[1] && a[2]) ok = true;
  if (a[3] && a[4] && a[5]) ok = true;
  if (a[6] && a[7] && a[8]) ok = true;
  if (a[0] && a[3] && a[6]) ok = true;
  if (a[1] && a[4] && a[7]) ok = true;
  if (a[2] && a[5] && a[8]) ok = true;
  if (a[0] && a[4] && a[8]) ok = true;
  if (a[2] && a[4] && a[6]) ok = true;

  PRINT(ok?"Yes":"No");
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 100010
ll n[2],x[2][N];

int main(){
	cin>>n[0]>>n[1];
	rep(i, 2) rep(j, n[i]) cin>>x[i][j];
	rep(i, 2) rep(j, n[i]-1) x[i][j] = x[i][j+1]-x[i][j];
	ll res = 1;
	rep(i, 2) {
		ll r = 0;
		rep(j, n[i]-1){
			(r+=(j+1)*(n[i]-1-j)%mod*x[i][j])%=mod;
		}
		(res*=r)%=mod;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstring>
using namespace std;
#define INF 0x3f3f3f3f3f3f3f3f;
typedef long long LL;
const int maxn=100005;
LL p1[maxn], p2[maxn];
LL n,res[maxn*3];
LL c1, c2, ans;

priority_queue<int, vector<int>, greater<int> > Q1;
priority_queue<int>Q2;

int main()
{
    cin>>n;
    c1=c2=0;
    for(int i=1;i<=3*n;i++){
        cin>>res[i];
        if(i<=n){
            Q1.push(res[i]);
            c1+=res[i];
        }
        else if(i>2*n){
            Q2.push(res[i]);
            c2+=res[i];
        }
    }
    p1[0]=c1;
    p2[0]=c2;
    for(int i=1;i<=n;i++){
        c1+=res[n+i];
        Q1.push(res[n+i]);
        c1-=Q1.top();
        Q1.pop();
        p1[i]=c1;
        c2+=res[2*n+1-i];
        Q2.push(res[2*n+1-i]);
        c2-=Q2.top();
        Q2.pop();
        p2[i]=c2;
    }
    ans=-INF;
    for(int i=0;i<=n;i++){
        ans=max(ans, p1[i]-p2[n-i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5112
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  int D;
  cin >> D;
  if(D == 25) print("Christmas");
  else if(D== 24) print("Christmas Eve");
  else if(D == 23) print("Christmas  Eve Eve");
  else if(D == 22) print("Christmas Eve Eve Eve");

  return 0;
}


Measured memory_bytes: 256