akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef struct Way{
	int ri;
	int  riri;
	int  up;
	int  upup;
}Way;

int w,h;
int  ans;
Way area[101][101];

void dp(){
	for(int i = 0;i < 101;i++){
		for(int j = 0;j < 101;j++){
			area[i][j].ri = 0;
			area[i][j].riri = 0;
			area[i][j].up = 0;
			area[i][j].upup = 0;
		}
	}
	for(int i = 2;i < 101;i++){
		area[2][i].up = 1;
		area[i][2].ri = 1;
	}
	for(int i = 3;i < 101;i++){
		area[2][i].riri = 1;
		area[i][2].upup = 1;
	}

	for(int i = 3;i <101;i++){
		for(int j = 3;j <101;j++){
			area[i][j].ri = area[i][j - 1].upup % 100000; 
			area[i][j].riri = (area[i][j - 1].ri + area[i][j -1].riri) % 100000;
			area[i][j].up = area[i - 1][j].riri % 100000;
			area[i][j].upup = (area[i - 1][j].up + area[i - 1][j].upup) % 100000;
		}
	}
	return;
}

int main(){
	dp();
	while(cin >> w >> h,w){
		ans = (area[w][h].ri +area[w][h].riri + area[w][h].up + area[w][h].upup) % 100000;
		if( w == 1 || h == 1){
			cout << 1 << endl;
		}else{
			cout << ans << endl;
		}
		//cout << area[w][h].ri<<"  "<<area[w][h].up<< "  "<<area[w][h].riri<<"  "<<area[w][h].upup<<endl;
	}
	return 0;
}

Measured memory_bytes: 3212
n = int(input())
a = list(map(int,input().split()))
b = [0 for i in range(n+1)]
leaf = sum(a)

if n == 0 and a[0] != 1:
    print(-1)
    exit()
b[0] = 1 - a[0]
leaf -= a[0]
ans = 1
for i in range(1,n+1):
    kosu = min(b[i-1] * 2,leaf)
    ans += kosu
    b[i] = kosu - a[i]
    if b[i] < 0:
        print(-1)
        exit()
    leaf -= a[i]
print(ans)


Measured memory_bytes: 89888
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word
// also tink all answers possible for a question
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
#define sz 100005
ll inf = 1e9;
ll power(ll x, ll n, ll mod)
{
  ll res = 1;
  x %= mod;
  while (n)
  {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res%mod;
}
int main()
{
 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  string s;
  cin>>s;
  ll ans=0;
  for(ll i=0;i<3;i++)
  {
    if(s[i]=='R')
      ans=1;
  }
  ll i=0;
  if(s[i]=='R' && s[i+1]=='R' && s[i+2]=='R')
      ans=3;
  else if((s[0]=='R' && s[1]=='R') || (s[1]=='R' && s[2]=='R'))
    ans=2;
  cout<<ans;
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    string s[n];
    set<string> x;
    for(int i=0; i<n; i++){
        cin >> s[i];
        x.insert(s[i]);
    }

    cout << x.size() << endl;
    return 0;
}

Measured memory_bytes: 25504
import sys
input= sys.stdin.readline

N,M = map(int,input().split())
g=M//N#最大公約数になる可能性のある最大値
for i in range(g):
  if M%(g-i)==0:
    print(g-i)
    exit()
  if M%(N+i)==0:
    print(M//(N+i))
    exit()

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)
#define fill(x,t) memset(x,t,sizeof(x))

const int N=400005;

int f[N],g[N],p[N],L[N],R[N],ans[N];
int left[25][N],righ[25][N],bel[N];
int n,V,tot;

int read() {
	int x=0,v=1; char ch=getchar();
	for (;ch<'0'||ch>'9';v=(ch=='-')?(-1):(v),ch=getchar());
	for (;ch<='9'&&ch>='0';x=x*10+ch-'0',ch=getchar());
	return x*v;
}

void pre(int v,int id) {
	for (int i=1,j;i<=n;i=j+1) {
		for (j=i;j<n&&p[j+1]-p[j]<=v;) j++;
		rep(k,i,j) left[id][i]=j,righ[id][j]=i;
	}
}

void solve() {
	for (int i=0,lim=(1<<tot);i<lim;++i) {
		g[i]=n+1;
	}
	for (int i=0,lim=(1<<tot);i<lim;++i) {
		rep(j,0,tot-1) if ((i>>j)&1) {
			f[i]=std:: max(f[i],left[j][f[i-(1<<j)]+1]);
			g[i]=std:: min(g[i],righ[j][g[i-(1<<j)]-1]);
		}
	}
	for (int i=0,lim=(1<<tot);i<lim;++i) {
		int j=lim-i-1;
		if (f[i]+1>=L[bel[f[i]+1]]&&g[j]-1<=R[bel[f[i]+1]]) {
			ans[bel[f[i]+1]]=1;
		}
	}
}

int main(void) {
	fill(righ,63);
	n=read(),V=read();
	rep(i,1,n) p[i]=read();
	for (int v=V/2;;v>>=1) {
		pre(v,tot++);
		if (!v) break;
	}
	for (int i=1,j;i<=n;i=j+1) {
		bel[i]=++bel[0];
		for (j=i;j<n&&p[j+1]-p[j]<=V;) bel[++j]=bel[0];
		L[bel[0]]=i,R[bel[0]]=j;
	}
	solve();
	rep(i,1,n) if (ans[bel[i]]) puts("Possible");
	else puts("Impossible");
	return 0;
}

Measured memory_bytes: 81792
Ns=int(input())
S=list(map(int,input().split()))
Nt=int(input())
T=list(map(int,input().split()))

answer=0

for i in range(0,len(T)):
    a=0
    b=len(S)-1
    
    while b-a>1:
        x=(a+b)//2
        
        if T[i]>=S[x]:
            a=x
        else:
            b=x
            
    if T[i]==S[a] or T[i]==S[b]:
        answer+=1
        
print(answer)


Measured memory_bytes: 16712
#include <cstdio>

int n;
int w[400040];

int main(void)
{
    int l,r,x;
    int i;
    bool reverse;

    //freopen("x.in","r",stdin);

    scanf("%d",&n);
    l = 200020;
    r = 200020 - 1;
    reverse = 0;
    for(i = 1;i <= n;++i)
    {
        if(reverse)
            scanf("%d",&w[--l]);
        else
            scanf("%d",&w[++r]);
        reverse ^= 1;
    }

    if(reverse)
        for(i = r;i >= l;--i)
            printf("%d%c",w[i]," \n"[i == l]);
    else
        for(i = l;i <= r;++i)
            printf("%d%c",w[i]," \n"[i == r]);

    return 0;
}

Measured memory_bytes: 2944
n=int(input())
h=list(map(int,input().split()))
no=[0]
if n!=0:
  for i in range(n-1):
    if h[i]-h[i+1]<0:
      no.append(i)
  no.append(n-1)
  if len(no)!=2:
    max=0
    for i in range(len(no)-1):
      if no[i+1]-no[i]-1>max:
        max=no[i+1]-no[i]-1
    print(max)
  else:
    print(n-1)
else:
  print(0)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 16;

int n, i, d, j, r, k, tab[N][N], bat[1<<N], d2;
LL S[1<<N], R[1<<N];

int main() {
scanf("%d", &n);
for (i=0;i<n;i++) for (j=0;j<n;j++) scanf("%d", &tab[i][j]);
for (i=0;i<(1<<n);i++) {
	for (j=0;j<n;j++) if (i & (1<<j)) {
		S[i] = S[i - (1 << j)];
		for (k = j + 1;k<n;k++) if (i & (1<<k)) S[i] += tab[j][k];
		break;
	}
	//cout << i << " " << S[i] << endl;
}
for (i=0;i<(1<<n);i++) {
	R[i] = S[i];
	d = 1;
	bat[0] = 0;
	for (j=0;j<n;j++) if (i & (1<<j)) {
		d2 = d;
		for (k=0;k<d2;k++) {
			bat[d] = bat[k] + (1<<j);
			R[i] = max(R[i], R[bat[d]] + R[i - bat[d]]);
			d++;
		}
	}
	//cout << i << " " << R[i] << endl;
}
cout << R[(1<<n) - 1] << endl;
return 0;
}

Measured memory_bytes: 1536
#include <cstdio>
#include <cassert>

using namespace std;
struct Node{
  char term;
  Node *left,*right;
};
Node reserved[1000];

char peek(){
  char c=getchar();
  ungetc(c,stdin);
  return c;
}

int cnt;
Node* read(){
  char c=getchar();
  int cur=cnt++;
  switch(c){
  case '(':
    reserved[cur].left=read();
    if(peek()=='-'){
      getchar();
      reserved[cur].term=getchar();
    }else
      reserved[cur].term=getchar();
    reserved[cur].right=read();
    assert(getchar()==')');
    return reserved+cur;
  case '-':
    reserved[cur].term='-';
    reserved[cur].left=read();
    return reserved+cur;
  default:
    reserved[cur].term=c;
    return reserved+cur;
  }
}

int eval(Node *n,int vars){
  bool l,r;
  switch(n->term){
  case 'T':
    return 1;
  case 'F':
    return 0;
  case '-':
    return !(eval(n->left,vars));
  case '*':
    l=eval(n->left,vars),r=eval(n->right,vars);
    return l&&r;
  case '+':
    l=eval(n->left,vars),r=eval(n->right,vars);
    return l||r;
  case '>':
    l=eval(n->left,vars),r=eval(n->right,vars);
    return !l||r;
  default:
    int var=n->term-'a';
    return (vars>>var)&1;
  }
}

int main(){
  Node *l,*r;
  while(peek()!='#'){
    cnt=0;
    l=read(); assert(getchar()=='=');
    r=read(); assert(getchar()=='\n');
    bool flag=true;
    for(int vars=0; vars<1<<11; vars++){
      if(eval(l,vars)!=eval(r,vars)){
	flag=false;
      }
    }
    if(flag)
      printf("YES\n");
    else
      printf("NO\n");
  }
}

Measured memory_bytes: 732
(let* ((n (read))
       (m (read))
       (x (read))
       (y (read))
       (xn (first (sort (loop :for p :from 1 :upto n collect(read)) #'>)))
       (xm (first (sort (loop :for q :from 1 :upto m collect(read)) #'<))))
  (if (and (< x xm) (>= y xm) (< xn xm))
      (princ "No War")
      (princ "War")))

Measured memory_bytes: 4200
#include<bits/stdc++.h>
#define Abra_Ka_Dabra ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;

int main() {

	Abra_Ka_Dabra

	string x;
	cin>>x;
	int ans=0, res=0;
	for(int i=0; i<x.size(); i++){
        if(x[i]=='R') ans++;
        else{
            res = max(res, ans);
            ans = 0;
        }
	}
	res = max(res, ans);
	cout<<res<<"\n";

	return 0;
}



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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

const int MAX = 1000000;
const int MOD = 1000000007;


int main(){
    int n;
    string s;
    cin >> s;
    n = s.size();
    int sum1=0, sum2=0;
    rep(i, 0, n){
        if(i%2==0){
            if(s[i]=='0'){
                sum1++;
            }else{
                sum2++;
            }
        }else{
           if(s[i]=='0'){
                sum2++;
            }else{
                sum1++;
            } 
        }
    }
    cout << min(sum1, sum2) << endl;
}

Measured memory_bytes: 3744
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int main(){

  int x1,x2,x3,x4,y1,y2,y3,y4;
  scanf("%d%d%d%d",&x1,&y1,&x2,&y2);

  x3 = x2 - (y2-y1);
  y3 = y2 + (x2-x1);
  x4 = x1 - (y2-y1);
  y4 = y1 + (x2-x1);

  printf("%d %d %d %d", x3, y3, x4, y4);

  return 0;
}


Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A;
    cin >> A;

if(A<=9)
{
    cout << A <<endl;
}
if(A>=10&&A<100)
{
    cout << 9 <<endl;
}
if(A>=100&&A<1000)
{
    cout << 9+A-99 <<endl;
}
if(A>=1000&&A<10000)
{
    cout << 909 <<endl;
}
if(A>=10000&&A<100000)
{
    cout << 909+A-9999 <<endl;
}
if(A==100000)
{
    cout << 90909 <<endl;
}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private void calc(){
		Scanner scanner = new Scanner(System.in);
		int x =scanner.nextInt();
		int y =scanner.nextInt();
		
		int d=x/y;
		int r=x%y;
		double f=(double)x/(double)y;
		
		System.out.printf("%d %d %05f", d, r, f);
	}
	
	public static void main(String[] args) {
		Main run =new Main();
		run.calc();

	}
}

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

int main(){
    int r0, w0, c, r;
    while(cin >> r0 >> w0 >> c >> r, r0 != 0){
        int x = 0;
        while(r0 + x * r < c * w0)x++;
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
using namespace std;
int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + (int)(c - '0');
        c = getchar();
    }
    return x * f;
}
int r1[102], r2[102], r3[102], cnt;
void add(int f, int t, int w) {
    r1[++cnt] = f;
    r2[cnt] = t;
    r3[cnt] = w;
    return ;
}
int main() {
    int l = read(), tmp = 1;
    int n = 0;
    while (tmp <= l) tmp <<= 1, n++;
    int t = n;
    while (l > 1) {
        add(t - 1, t, l / 2);
        add(t - 1, t, 0);
        if (l & 1) add(1, t, l - 1);
        l >>= 1;
        t--;
    }
    cout << n << ' ' << cnt << endl;
    for (int i = 1; i <= cnt; ++i) {
        printf("%d %d %d\n", r1[i], r2[i], r3[i]);
    }
    return 0;
}

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

typedef long long ll;

const ll MOD = 1e9 + 7;
ll n, k, Out;
ll ans[100005];

ll Pow(ll a, ll b){
	ll x = 1;
	while(b > 0){
		if(b & 1) x = x * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return x;
}

int main(){
	scanf("%lld%lld", &n, &k);
	for(ll i = k; i >= 1; i--){
		ans[i] = Pow(k / i, n);
		for(ll j = 2;j * i <= k; j++){
			ans[i] = ((ans[i] - ans[i * j]) % MOD + MOD) % MOD;
		}
		Out = (Out + ans[i] * i) % MOD;
	}
	printf("%lld\n", Out);
	return 0;
}

Measured memory_bytes: 4536
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}
int main() {
	int a,b,c; cin >> a >> b >> c;
	if (b-a == c-b){
		print("YES");
	}else {
		print("NO");
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<double> x(n),y(n);
  rep(i,n) cin>>x[i]>>y[i];
  double ans=0;
  vector<int> a;
  rep(i,n) a.push_back(i);
  do{
	  double cnt=0;
	  rep(i,n-1){
		  cnt+=pow((x[a[i]]-x[a[i+1]])*(x[a[i]]-x[a[i+1]])+(y[a[i]]-y[a[i+1]])*(y[a[i]]-y[a[i+1]]),0.5);
	  }
	  ans+=cnt;
  }while(next_permutation(begin(a),end(a)));
  FOR(i,1,n+1){
	  ans/=(double)i;
  }
  cout<<setprecision(20)<<ans<<endl;
}

Measured memory_bytes: 640
#![allow(dead_code, unused_imports, non_snake_case)]

use std::io::*;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::str::FromStr;

const MOD: i32 = 1_000_000_007;

mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;

    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }

    pub fn gets<T: FromStr>() -> Vec<T>
        where
            <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }

    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}

macro_rules! max {($x:expr)=>{$x};($x:expr,$($xs:tt)+)=>{max($x,max!($($xs)+))};}
macro_rules! min {($x:expr)=>{$x};($x:expr,$($xs:tt)+)=>{min($x,min!($($xs)+))};}
macro_rules! get {($t:ty)=>{{let mut line:String=String::new();stdin().read_line(&mut line).unwrap();line.trim().parse::<$t>().unwrap()}};($($t:ty),*)=>{{let mut line:String=String::new();stdin().read_line(&mut line).unwrap();let mut iter=line.split_whitespace();($(iter.next().unwrap().parse::<$t>().unwrap(),)*)}};($t:ty;$n:expr)=>{(0..$n).map(|_|get!($t)).collect::<Vec<_>>()};($($t:ty),*;$n:expr)=>{(0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()};($t:ty;;)=>{{let mut line:String=String::new();stdin().read_line(&mut line).unwrap();line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()}};($t:ty;;$n:expr)=>{(0..$n).map(|_|get!($t;;)).collect::<Vec<_>>()};}
macro_rules! debug {($($a:expr),*)=>{eprintln!(concat!($(stringify!($a),"={:?},"),*),$($a),*);}}

fn main() {
    let _ = get!(usize);
    let a = util::gets::<i64>();
    println!("{}", min!(solve(&a, true), solve(&a, false)));
}

fn solve(a: &Vec<i64>, even_plus: bool) -> i64 {
    let mut total = 0;
    let mut res = 0;
    for (i, &x) in a.iter().enumerate() {
        total += x;
        if (i % 2 == 0 && even_plus && total <= 0) || (i % 2 != 0 && !even_plus && total <= 0) {
            res += 1 - total;
            total = 1;
        } else if (i % 2 == 0 && !even_plus && total >= 0) || (i % 2 != 0 && even_plus && total >= 0) {
            res += total + 1;
            total = -1;
        }
    }
    res
}

Measured memory_bytes: 6396
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim a As Integer = NextInt()
        Dim b As Integer = NextInt()

        WriteLine(New String() {"Negative", "Zero", "Positive"}(Calc(a, b) + 1))
    End Sub

    Function Calc(a As Integer, b As Integer) As Integer
        If a <= 0 AndAlso 0 <= b Then
            Return 0
        ElseIf a > 0 Or (b - a) Mod 2 <> 0 Then
            Return 1
        Else
            Return -1
        End If
    End Function

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


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

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> B(N);
  for(int i = 1; i <= N-1; ++i){
      cin >> B[i];
  }
    
  int ans = B[1] + B[N-1];
  for(int i = 1; i <= N-2; ++i){
      ans += min(B[i], B[i + 1]);
  }
      
  cout << ans << endl;
}

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

int n, u, v, root;
int visited[100001], a[100001];
vector <int> adj[100001];

bool dfs(int u) {
    visited[u] = 1;
    if(adj[u].size() == 1) return 1;
    int sum = 0, mx = -1;
    for(auto v : adj[u]) {
        if (!visited[v]) {
            if(!dfs(v)) return 0;
            sum += a[v];
            mx = max(mx, a[v]);
        }
    }
    if(mx <= a[u] && a[u] <= sum && sum <= a[u] << 1) {
        a[u] = (a[u] << 1) - sum;
        if (u == root) return !a[u];
        return 1;
    }
    return 0;
}
int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i < n; i++) cin >> u >> v, adj[u].push_back(v), adj[v].push_back(u);
    root = 1;
    for (int i = 1; i <= n; i++) if (adj[i].size() > adj[root].size()) root = i;
    if (adj[root].size() == 1) cout << (a[1] == a[2] ? "YES" : "NO");
    else cout << (dfs(root) ? "YES" : "NO");
}

Measured memory_bytes: 13184
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main() {
   int n,m; cin >> n >> m;
   vector<int> a(n);
   int count = 0;
   int sum = 0;
   rep(i,n){
       cin >> a[i];
       sum += a[i];
   }
   rep(i,n){
       if(sum % (4 * m) == 0){
        if(a[i] >= sum / (4 * m))count++;
       }else{
           if(a[i] >= 1 + sum / (4 * m))count++;
       }
   }
   if(count >= m)print("Yes");
   else print("No");
}

Measured memory_bytes: 256
def test():
    a,b,c,x,y = map(int,input().split())
    result = float("inf")
    for i in range(x+y):
        result = min(result,2*c*i + a*max(0,x-i) + b*max(0,y-i))
    print(result)


if __name__ == "__main__":
    test()


Measured memory_bytes: 3060
<?php
  $n = trim(fgets(STDIN));
  $x = explode(" ",trim(fgets(STDIN)));
  $xx = $x;
  sort($x);
  $center = $x[$n/2];
  $center2 = $x[($n/2)-1];
  for($i=0; $i<$n; $i++){
      if($xx[$i] >= $center){
          echo $center2."\n";
      }else{
          echo $center."\n";
      }
  }

Measured memory_bytes: 33140
n = int(input())

k = (1 + (1 + 8 * n)** 0.5) * 0.5
if k.is_integer():
    k, num = int(k), 1
    ans = [[] for _ in range(k)]
    print('Yes')
    print(k)
    for i in range(k):
        for j in range(i + 1, k):
            ans[i].append(num)
            ans[j].append(num)
            num += 1
        print(k - 1, *ans[i])
else:
    print('No')


Measured memory_bytes: 76964
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
using namespace std;
const int N = 110;

char s[N];

template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}

int main() {
    scanf("%s", s + 1);
    int len = strlen(s + 1), ans = 0;
    for (R int i = 1; i <= len / 2; ++i)
        if (s[i] != s[len - i + 1]) ++ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int read(){
	char c=getchar();int f=1,sum=0;
	while(c>'9' or c<'0') if(c=='-'){f=-1;c=getchar();}
	while(c<='9' and c>='0'){sum=sum*10+c-'0';c=getchar();}
	return sum*f;
}
int main(){
	int ans=1,n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		ans+=min(ans,k);
	}

	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
/*
Author: CNYALI_LK
LANG: C++
PROG: c.cpp
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define all(x) x.begin(),x.end()
using namespace std;
const double eps=1e-8;
const double PI=acos(-1.0);
typedef long long ll;
template<class T>void chkmin(T &a,T b){a=a<b?a:b;}
template<class T>void chkmax(T &a,T b){a=a>b?a:b;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
#define min mmin
#define max mmax
#define abs aabs
char dt[128];
int sum[10],tot[50];
void out(char *s){
	printf(s);
	exit(0);
}
int main(){
#ifdef cnyali_lk
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
	int h,w;
	scanf("%d%d\n",&h,&w);
	for(int i=1;i<=h;++i){
		scanf("%s",dt+1);
		for(int j=1;j<=w;++j){
			++tot[dt[j]-'a'];
		}
	}
	for(int i=0;i<26;++i)++sum[tot[i]%4];

	if(h&w&1){
		if(sum[1]+sum[3]-1){
			out("No\n");
		}	
		if(sum[1])--sum[1];
		else {++sum[2];--sum[3];}
		if(sum[2]>(h+w-2)>>1||(((h+w-2)>>1)-sum[2])&1)out("No\n");
		out("Yes\n");
	}
	else if(h&1){
		if(sum[1]||sum[3])out("No\n");
		if(sum[2]>w/2||(w/2-sum[2])&1)out("No\n");
		out("Yes\n");
	}
	else if(w&1){
		if(sum[1]||sum[3])out("No\n");
		if(sum[2]>h/2||(h/2-sum[2])&1)out("No\n");
		out("Yes\n");
	}
	else if(sum[1]||sum[2]||sum[3])out("No\n");else out("Yes\n");
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+5,MOD=1e9+7;

/*int cnt,head[N];
struct edge{int next,to;}e[N<<1];
inline add(int u,int v)
{
	cnt++;
	e[cnt].next=head[u];
	e[cnt].to=v;
	head[u]=cnt;
}   */
	
int n,ans;
int a[N],sum[N];
signed main(){
	scanf("%lld",&n);
	for (register int i=1; i<=n; ++i) scanf("%lld",&a[i]),sum[i]=(sum[i-1]+a[i])%MOD;
	for (register int i=1; i<n; ++i)
	{
		ans=(ans+a[i]*((sum[n]-sum[i]+MOD)%MOD)%MOD)%MOD;	
	}
	printf("%lld\n",ans);
	
return 0;	
}

Measured memory_bytes: 6948
N = int(input())

R = [list(map(int, input().split())) for _ in range(N)]
B = [list(map(int, input().split())) for _ in range(N)]

R = sorted(R, key=lambda x: -x[1])  # 赤い点はy座標が大きい順にする
B = sorted(B, key=lambda x: x[0])  # 青い点はx座標が小さい順にする

for a, b in B:  # 青い点, x座標が小さい順になっている
    for c, d in R:  # 赤い点, y座標が大きい順になっている
        if a > c and b > d:  # 青い点のx座標より赤い点のx座標が小さく, 青い点のy座標より赤い点のy座標が小さければペアにする
            R.remove([c, d])
            break

print(N - len(R))


Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
using namespace std;
const int INF = 0X3f3f3f3f;
int main()
{
    int n, a, b = INF, ans = 1;
    cin >> n;
    cin >> a;
    for (int i = 1; i < n;i++){
        a = min(a, b);
        cin >> b;
        if(b<=a)
        {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
S = input()

if len(S) % 2 == 1:
    S += "L"

for i in range(0, len(S), 2):
    l = S[i]
    r = S[i + 1]

    if not (l == "R" or l == "U" or l == "D"):
        print("No")
        break

    if not (r == "L" or r == "U" or r == "D"):
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
using namespace std;
typedef pair<int,int> P;

int main(){
    int N,M;
    cin >> N >> M;
    vector<vector<int>> v(N+1);
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    if(M%2==1){
        cout << -1 << endl;
        return 0;
    }
    vector<vector<int>> tree(N+1);
    vector<int> cnt(N+1,0),vis(N+1,0);
    vector<pair<int,int>> ans;
    function<void(int,int,int)> dfs = [&](int n,int m,int num){
        vis[n] = num;
        for(auto x:v[n]) if(x!=m){
            if(vis[x] && vis[n]>vis[x]){
                ans.push_back({n,x});
                cnt[n]++;
            }else if(!vis[x]){
                tree[n].push_back(x);
                dfs(x,n,num+1);
            }
        }
    };
    dfs(1,0,1);
    function<void(int,int)> dfs2 = [&](int n,int m){
        for(auto x:tree[n]) if(x!=m){
            dfs2(x,n);
            if(cnt[x]%2==0){
                ans.push_back({n,x});
                cnt[n]++;
            }else{
                ans.push_back({x,n});
            }
        }
    };
    dfs2(1,0);
    for(auto x:ans) cout << x.first << " " << x.second << endl;
}

Measured memory_bytes: 24952
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;
using ll = long long;
const ll mod = 998244353;
const int MM = 2e5+5;

ll gcd(ll gcd_a, ll gcd_b){return gcd_b == 0 ? gcd_a : gcd(gcd_b, gcd_a % gcd_b);}
ll fpow(ll fpow_b, ll fpow_exp, ll fpow_mod){if(fpow_exp == 0) return 1;ll t = fpow(fpow_b,fpow_exp/2,fpow_mod);if(fpow_exp&1) return t*t%fpow_mod*fpow_b%fpow_mod;return t*t%fpow_mod;}
ll divmod(ll divmod_i, ll divmod_j, ll divmod_mod){divmod_i%=divmod_mod,divmod_j%=divmod_mod;return divmod_i*fpow(divmod_j,divmod_mod-2,divmod_mod)%divmod_mod;}

int n, m, k;
ll ans, f[MM], inv[MM];

ll val(int a, int b){
    return f[a]*inv[b]%mod*inv[a-b]%mod;
}

int main(){
    scan(n, m, k);
    
    f[0] = inv[0] = 1;
    for(int i = 1; i < MM; i++){
        f[i] = f[i-1]*i%mod;
        inv[i] = fpow(f[i], mod-2, mod);
    }
    
    for(int i = n; i >= n-k; i--){
        ans += m*fpow(m-1, i-1, mod) % mod * val(n-1, n-i) % mod;
        ans %= mod;
    }
    
    print(ans);
    
    return 0;
}

Measured memory_bytes: 6764
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <queue>
#include <stack>
#include <bitset>
#include <set>
#include <chrono>
#include <string>
#include <assert.h>

using namespace std;

#define endl '\n'

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

    int h, w, R;
    cin >> h >> w >> R;

    vector<string> b(h);

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

    int answer = h + w;

    for (int i = 0; i < (1 << (h - 1)); ++i) {
        int cur = 0;

        for (int j = 0; j < h; ++j)
            cur += i >> j & 1;

        vector<int> total(h);
        for (int j = 0; j < w; ++j) {
            int ss = 0;

            while (true) {
                int ix = 0;

                for (int k = 0; k < h; ++k) {
                    total[ix] += b[k][j] == '1';
                    if (i >> k & 1) ix++;
                }

                bool should_reset = false;
                for (int k = 0; k < h; ++k) {
                    if (total[k] > R) {
                        should_reset = true;
                    }
                }

                if (should_reset) {
                    total = vector<int>(h);
                    cur++;
                    ss++;

                    if (ss == 2)
                        break;
                } else {
                    break;
                }
            }

            if (ss == 2) {
                cur = h + w;
                break;
            }
        }

        answer = min(answer, cur);

        // cout << bitset<3>(i) << " " << cur << endl;
    }

   cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import Counter

n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]

num, seta = Counter(a), set(a)
for b, c in bc:
    num[c] += b
    seta.add(c)
sorta = sorted(list(seta), reverse=True)
cnt, ans = n, 0
for i in sorta:
    ans += i * min(num[i], cnt)
    cnt -= num[i]
    if cnt <= 0:
        break
print(ans)


Measured memory_bytes: 167224
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

num = ['0', '3', '5', '7']
cand = []
for i1 in num:
	for i2 in num:
		for i3 in num:
			for i4 in num:
				for i5 in num:
					for i6 in num:
						for i7 in num:
							for i8 in num:
								for i9 in num:
									for i10 in num:
										s = i1+i2+i3+i4+i5+i6+i7+i8+i9+i10
										cand.append(int(s))

N = INT()
ans = []
for c in cand:
	if c <= N and	str(c).count('3') >= 1 and str(c).count('5') >= 1 and str(c).count('7') >= 1 and str(c).count('0') < 1:
		ans.append(c)

print(len(ans))

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

const long long mod = 1000000007;

long long ans;

long long fac(int x)
{
	long long ret = 1;
	for (int i = 1;i <= x;i++) ret = (ret*i)%mod;
	return ret;
}

int main()
{
	int n, m; scanf("%d%d", &n, &m);
	if (n < m) swap(n, m);
	if (n == m+1)
	{
		ans = fac(n)*fac(m);
		ans %= mod;
	} else if (n == m)
	{
		ans = fac(n)*fac(m)*2;
		ans %= mod;
	}
	printf("%lld\n", ans);
	return 0;
}


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

class UnionFind {
 private:
  std::vector<int> parent;
  std::vector<int> rank;
  std::vector<int> sizes;

 public:
  UnionFind(int n) : parent(n), rank(n), sizes(n, 1) {
    for (int i = 0; i < n; i++) parent[i] = i;
  }
  void Unite(int a, int b) {
    a = Find(a);
    b = Find(b);
    if (a == b) return;
    if (rank[a] < rank[b]) {
      parent[a] = b;
    } else {
      parent[b] = a;
      if (rank[a] == rank[b]) rank[a]++;
    }
    sizes[Find(a)] = sizes[a] + sizes[b];
  }
  int Find(int a) { return parent[a] == a ? a : parent[a] = Find(parent[a]); }
  int Size(int a) { return sizes[Find(a)]; }
};

int main() {
  int n;
  cin >> n;
  vector<set<int>> xys(1e5 + 1), yxs(1e5 + 1);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    xys[x].insert(y);
    yxs[y].insert(x);
  }

  UnionFind uf(1e5 + 1);
  for (auto s : yxs) {
    for (auto e : s) {
      uf.Unite(*begin(s), e);
    }
  }

  ll r = 0;
  for (int i = 0; i < xys.size(); i++) {
    int f = uf.Find(i);
    if (i == f) continue;
    for (auto e : xys[i]) {
      if (xys[f].count(e)) continue;
      xys[f].insert(e);
      r++;
    }
  }
  for (int i = 0; i < xys.size(); i++) {
    int f = uf.Find(i);
    if (i == f) continue;
    r += (ll)xys[f].size() - xys[i].size();
  }
  cout << r << endl;
}


Measured memory_bytes: 22528
fn main() {
    let a: usize = read();
    let b: usize = read();
    let c: usize = read();
    if max(a, max(b, c)) == 7 && min(a, min(b, c)) == 5 && a+b+c == 17 {
        println!("YES");
    } else {
        println!("NO");
    }
}

// 以下関数

use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 1_000_000_007;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}

pub fn abs(n: i32) -> i32 {
    if n >= 0 {
        n
    } else {
        -n
    }
}

pub fn max(n: usize, m: usize) -> usize {
    if n >= m {
        n
    } else {
        m
    }
}

pub fn min(n: usize, m: usize) -> usize {
    if n <= m {
        n
    } else {
        m
    }
}

pub fn factorial(n: u32) -> u32 {
    if n == 0 {
        return 1;
    }
    let mut r = n;
    for i in 0..n - 1 {
        r *= n - i - 1;
    }
    r
}

pub fn combination(n: u32, m: u32) -> u32 {
    factorial(n) / factorial(m) / factorial(n - m)
}


Measured memory_bytes: 4352
//Next Trip
#include <iostream>

using namespace std;

int main(){
	int aimL;//旅行費用
	int nowL;//現在貯蓄
	int M, N;//貯蓄額/出費額
	bool isoutput;
	while (1){
		cin >> aimL;
		if (aimL == 0)break;

		nowL = 0;
		isoutput = false;
		for (int i = 0; i < 12; ++i){
			cin >> M >> N;
			nowL += (M - N);
			if (nowL >= aimL && !isoutput){
				cout << (i + 1) << endl;
				isoutput = true;
			}
		}
		if (!isoutput)cout << "NA" << endl;
	}


	return 0;
}

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

struct edge{
  int to;
  int dist;
};

int main(){
  int n,m;
  cin >> n >> m;
  vector<edge> Graph[n+1];
  int l[m], r[m], d[m];
  for(int i = 0; i < m; i++){
    cin >> l[i] >> r[i] >> d[i];
    edge e;
    e.to = r[i];
    e.dist = d[i];
    Graph[l[i]].push_back(e);
    e.to = l[i];
    e.dist = -d[i];
    Graph[r[i]].push_back(e);
  }
  int x[n+1];
  bool visited[n+1];
  for(int j = 1; j <= n; j++){
    visited[j]=false;
  }
  for(int j = 1; j <= n; j++){
    if(visited[j]==false){
      queue<int> wait;
      wait.push(j);
      x[j] = 0;
      visited[j] = true;
      while(wait.size()>0){
        int node = wait.front();
        wait.pop();
        for(edge e : Graph[node]){
          if(visited[e.to]==false){
            x[e.to] = x[node] + e.dist;
            visited[e.to] = true;
            wait.push(e.to);
          }
        }
      }
    }
  }
  for(int i = 0; i < m; i++){
    if(x[r[i]]-x[l[i]]!=d[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 11776
#[allow(unused_imports)]
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::Chars;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused)]
const ALPHA_SMALL: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];
#[allow(unused)]
const ALPHA: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];
fn main() {
    input!(n: usize);
    let mut s = vec![];
    for _ in 0..n {
        input!(t: String);
        s.push(t);
    }
    let mut ans = vec![0; 4];
    for i in 0..n {
        if s[i] == "AC" {
            ans[0] += 1;
        } else if s[i] == "WA" {
            ans[1] += 1;
        } else if s[i] == "TLE" {
            ans[2] += 1;
        } else {
            ans[3] += 1;
        }
    }

    println!("AC x {}", ans[0]);
    println!("WA x {}", ans[1]);
    println!("TLE x {}", ans[2]);
    println!("RE x {}", ans[3]);
}


Measured memory_bytes: 7876
#include<stdio.h>

int main(){
	
	int A,B,C,i;
	scanf("%d %d %d",&A,&B,&C);
	
	for(i=1;i<=B;i++){
		if(i*A%B==C){
			printf("\nYES\n");
			return 0;
		}
	}
	
	printf("\nNO\n");
	
	return 0;
	
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

vector<string> an;
int main()
{
	ll X; cin >> X;
	for (int i = 1; i <= X; i++) {
		if (i * (i + 1) / 2 >= X) {
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int N;
    cin >> N;
    cout << (1000 - N % 1000) % 1000 << endl;
    
    return 0;
}

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

int main(void){
  int n, d; cin >> n >> d;
  int cover = d * 2 + 1;
  if(n % cover == 0) cout << n / cover << endl;
  else cout << n / cover + 1 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<limits>
using ll = long long;
using namespace std;

int main() {
	long double a, b;
	cin >> a >> b;
	long double c = a * b;
	ll d = (ll)c;
	printf("%lld",d);

	return 0;
}

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

#define ran 303303

int n;
int a[ran];
pair<int, int> q[ran]; int lq;
pair<int, int> s[ran]; int ls;

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

int main() {
	scanf("%d", &n);
	for(int i=0;i<n;i++) {
		scanf("%d", &a[i]);
	}
	sort(a, a+n);
	
	lq = 0;
	pair<int, int> p = make_pair(a[0], 1);
	for(int i=1;i<n;i++) {
		if(a[i] == p.first) p.second++;
		else {
			q[lq++] = p;
			p = make_pair(a[i], 1);
		}
	}
	q[lq++] = p;
	sort(q, q+lq, cmp);
	
	ls = 0;
	p = make_pair(q[0].second, 1);
	for(int i=1;i<lq;i++)
		if(q[i].second == p.first) p.second++;
		else {
			s[ls++] = p;
			p = make_pair(q[i].second, 1);
		}
	s[ls++] = p;
	
	int tot = n, it = 0;
	for(int i=1;i<=n;i++) {
		int dest = tot/i;
		while(it<ls && s[it].first > dest) {
			for(int j=it;j<ls;j++)
				if (s[j].first > dest) {
					tot -= (s[j].first-dest) * s[j].second;
					s[j].first = dest;
				}
				
			while(it<ls-1 && s[it].first == s[it+1].first) {
				s[it+1].second += s[it].second;
				it++;
			}
			
			dest = tot / i;
		}
		
		printf("%d\n", dest);
	}
	
	return 0;
}

Measured memory_bytes: 4608
from typing import List


class Node:
    left = -1
    right = -1
    parent = -1


def get_root(nodes: List[int]) -> int:
    for i, node in enumerate(nodes):
        if node.parent == -1:
            return i


def show_preorder(node_id: int)-> None:
    print(f' {node_id}', end='')
    if nodes[node_id].left != -1:
        show_preorder(nodes[node_id].left)
    if nodes[node_id].right != -1:
        show_preorder(nodes[node_id].right)


def show_inorder(node_id: int)-> None:
    left = nodes[node_id].left
    if left != -1:
        show_inorder(left)

    print(f' {node_id}', end='')

    right = nodes[node_id].right
    if right != -1:
        show_inorder(right)


def show_postorder(node_id: int) -> None:
    left = nodes[node_id].left
    if left != -1:
        show_postorder(left)

    right = nodes[node_id].right
    if right != -1:
        show_postorder(right)

    print(f' {node_id}', end='')


N = int(input())
nodes = [Node() for i in range(N)]
for _i in range(N):
    node_id, left, right = map(int, input().split())
    nodes[node_id].left = left
    nodes[node_id].right = right
    if left != -1:
        nodes[left].parent = node_id
    if right != -1:
        nodes[right].parent = node_id
root = get_root(nodes)

print('Preorder')
show_preorder(root)
print()

print('Inorder')
show_inorder(root)
print()

print('Postorder')
show_postorder(root)
print()



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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<ll> Vec;
typedef vector<vector<ll>> Mat;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD =  1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    Mat graph(n+1);
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        graph[a].pb(b);
        graph[b].pb(a);
    }

    ll start = 0;
    rep(i,graph.size()){
        if(graph[i].size()==1){
            start = i;
            break;
        }
    }
    ll ans = k;
    queue <pair<ll,ll>> q;
    //p.secondが親
    q.push(make_pair(start,0));
    while (q.size()>0){
         P p = q.front();
         Vec &childen = graph[p.first];
//         dbg(p);
//         dbg(childen);
            ll loop = 0;
         rep(i,childen.size()){
             if(p.second==0){
                 q.push(make_pair(childen[i],p.first));
                    // dbg(k-1-loop);
                     ans *= (k-1-loop);
                     ans %= MOD;
                     //dbg(ans);
                     loop++;
             }else{
                 if(childen[i]!=p.second){
                    // dbg(k-2-loop);
                     q.push(make_pair(childen[i],p.first));
                     ans *= (k-2-loop);
                     ans %= MOD;
                     //dbg(ans);
                     loop++;
                 }
             }
         }
         q.pop();
    }
    cout<<ans<<endl;
    return  0;
}


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

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

    long long b_num = b / x;
    long long a_num = (a - 1) >= 0?(a - 1) / x:-1;
    printf("%lld\n", b_num - a_num);

    return 0;
}


Measured memory_bytes: 3692
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define rep(i,x,y) for(int (i)=(x);(i)<(y);(i)++)

typedef struct{
  int teamid;
  int seikai;
  int time;
  int fuseikai[10];
}Team;

int main()
{
  while(true){
    int M,T,P,R;
    cin>>M>>T>>P>>R;
    if(M==0&&T==0&&P==0&&R==0){
      break;
    }

    vector<Team> team(T);
    rep(i,0,T){
      team[i].teamid=i;
      team[i].seikai=0;
      team[i].time=0;
      rep(j,0,10){
        team[i].fuseikai[j]=0;
      }
    }

    rep(i,0,R){
      int m,t,p,j;
      cin>>m>>t>>p>>j;

      if(j==0){
        team[t-1].seikai++;
        team[t-1].time+=m;
        if(team[t-1].fuseikai[p-1]!=0){
          team[t-1].time+=team[t-1].fuseikai[p-1]*20;
        }
      }else{
        team[t-1].fuseikai[p-1]++;
      }
    }

    for(int i=team.size()-1;i>=0;i--){
      for(int j=0;j<i;j++){
        if(team[j+1].seikai>team[j].seikai){
          swap(team[j],team[j+1]);
        }else if(team[j].seikai==team[j+1].seikai){
          if(team[j+1].time<team[j].time){
            swap(team[j],team[j+1]);
          }else if(team[j+1].time==team[j].time){
            if(team[j].teamid<team[j+1].teamid){
              swap(team[j],team[j+1]);
            }
          }
        }
      }
    }

    rep(i,0,T){
      cout<<team[i].teamid+1;
      if(i!=T-1){
        if(team[i+1].seikai==team[i].seikai&&team[i+1].time==team[i].time){
          cout<<"=";
        }
        else{
          cout<<",";
        }
      }
    }
    cout<<endl;
  }

  return 0;
}

Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  cin >> a ;
  int count = 0;
  for (int i = 0; i < a.size() ; i++){
    if (a.at(i) == 'o'){
      count++;
    }
  }

    cout << count * 100 +700 << endl;

 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t=1;
	//cin >> t;
	while(t--){
		string s;
      	long long int k=0;
      	cin >> k >> s;
      	long long int i=0,n= s.size();
		if(n>k){
        	for(i=0;i<k;i++){
            cout << s[i];
            }
          cout << "..."<<endl;
        }
      else{
      cout << s << endl;
      }
    }
}

Measured memory_bytes: 3624