akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
int main( ) {
    //freopen("C.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char s[256];
    map<char,ll> m;
    ll cnt=0;
    int n;
    scanf("%d",&n);
    while(n--){
        scanf("%s",&s);
        m[s[0]]++;
    }
    if(sz(m)<3){
        printf("%d",0);
        return 0;
    }
    // m['M']*m['A']*m['R']*m['C']*m['H']
    cnt = m['M']*m['A']*m['R']+m['M']*m['A']*m['C']+m['M']*m['A']*m['H']+m['A']*m['R']*m['C']+m['A']*m['R']*m['H']+m['R']*m['C']*m['H']+m['M']*m['R']*m['C']+m['M']*m['R']*m['H']+m['M']*m['C']*m['H']+m['A']*m['C']*m['H'];
    printf("%lld",cnt);
    return 0;
}

Measured memory_bytes: 3828
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a,b,c,d;
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        d = sc.nextInt();
        if((a+b)>(c+d)) {
            System.out.println("Left");
        }
        else if((a+b)<(c+d)) {
            System.out.println("Right");
        }
        else {
            System.out.println("Balanced");
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int a, b, c, k;

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

    if (a < b)
    {
        int tmp = a;
        a = b;
        b = tmp;
    }

    if (a < c)
    {
        int tmp = a;
        a = c;
        c = tmp;
    }

    for (int i = 0; i < k; ++i)
        a *= 2;

    cout << a + b + c << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

void push(int);
int pop(void);

int s[100],top;

int main()
{
  int n,m,f;
  top = 0;
  char t[100];
  while(1){
    f = scanf("%s",t);
    if(f==EOF) break;
    if(t[0]=='+'){
      n = pop();
      m = pop();
      push(n+m);
    }
    else if(t[0]=='-'){
      n = pop();
      m = pop();
      push(m-n);
    }
    else if(t[0]=='*'){
      n = pop();
      m = pop();
      push(n*m);
    }
    else{
      push(atoi(t));
    }
  }

  printf("%d\n",pop());

  return 0;
}

void push(int n)
{
  s[++top] = n;
}

int pop(void)
{
  top--;
  return s[top+1];
}


  
      
    
      

  



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

int main(){
    int n,ans=0;
    string s;
    cin>>n>>s;
    
    rep(i,n-1){
        int ka=0;
        vector<bool> ch(26,0);
        rep(j,i+1){
            ch[((int)s[j])-97]=true;
        }
        for(int k=i+1;k<n;k++){
            if(ch[((int)s[k])-97]){
                ka++;
                ch[((int)s[k])-97]=false;
            }
        }
        ans=max(ka,ans);
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 256
m,d = map(int,input().split())

ans = 0
for i in range(1, m + 1):
    for j in range(1, d + 1):
        if j > 10 :
            buf = str(j)
            d_1 = int(buf[-1])
            d_10 = int(buf[-2])

            if d_1 >= 2 and d_10 >= 2 and int(d_1 * d_10) == i:
                ans += 1
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
  int h,w,i,j;
  char a[101][101];
  char b[103][103];
  scanf("%d %d",&h,&w);
  for(i=0;i<h+2;i++){
    for(j=0;j<w+2;j++){
      b[i][j]='#';
    }
  }
  for(i=0;i<h;i++){
    scanf("%s",a[i]);
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      b[i+1][j+1]=a[i][j];
    }
  }
  for(i=0;i<h+2;i++){
    for(j=0;j<w+2;j++){
      printf("%c",b[i][j]);
    }
    printf("\n");
  }
  return 0;
}

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

using namespace std;

using int64 = long long;

vector<int> ReadIntVector(int n) {
  vector<int> xs(n);
  for (int i = 0; i < n; i++) cin >> xs[i];
  return xs;
}

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

  int n, k;
  cin >> n >> k;
  vector<int> hs = ReadIntVector(n);
  vector<int> dp(n, INT32_MAX);
  dp[0] = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = 1; j <= k; j++) {
      if (i + j < n) {
        dp[i + j] = min(dp[i + j], dp[i] + abs(hs[i + j] - hs[i]));
      }
    }
  }
  cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int C = Integer.parseInt(sc.next());
        if(A != B && B != C && C != A) {
            System.out.println("No");
        } else if(A == B && B == C) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse
// struct Edge {
//   int to, id;
//   Edge(int a, int b): to(a), id(b) {}
// };

const int MAX_C = 51;
long long Com[MAX_C][MAX_C];

void calc_com() {
    memset(Com, 0, sizeof(Com));
    Com[0][0] = 1;
    for (int i = 1; i < MAX_C; ++i) {
        Com[i][0] = 1;
        for (int j = 1; j < MAX_C; ++j) {
            Com[i][j] = (Com[i-1][j-1] + Com[i-1][j]);
        }
    }
}

ll v[60];

int main(int argc, char const *argv[])
{
	int n,a,b;cin>>n>>a>>b;

	rep(i,n) cin>>v[i];

	sort(v,v+n);reverse(v,v+n);

	map<ll,int> ma;

	rep(i,n) {
		if (!ma.count(v[i])) {
			ma[v[i]]=1;
		} else {
			ma[v[i]]++;
		}
	}

	calc_com();

	ma[0]=0;

	ll ans=0;

	if (ma[v[0]]>=a) {
		for (int i=a;i<=min(b,ma[v[0]]);i++) {
			ans+=Com[ma[v[0]]][i];
		}
		cout << fixed << setprecision(10) << (double)v[0] << endl;
		cout<<ans<<endl;
	} else {
		int cnt = 0;
		ll sum=0;
		for (auto it = ma.end();it!=ma.begin();it--) {
			if (it==ma.end()) continue;
			// cout<<it->first<<endl;
			if (cnt+(it->second)<=a) {
				sum+=(it->first)*(it->second);
				cnt+=it->second;
			} else {
				sum+=(it->first)*(a-cnt);
				ans+=Com[it->second][a-cnt];
				break;
			}
		}
		double ave = sum/(double)a;
		cout << fixed << setprecision(10) << ave << endl;
		cout<<ans<<endl;
	}

	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int32 res = 0, cnt = 0;
	REP(i, s.size()){
		if(s[i] == 'B') cnt++;
		else res += cnt;
	}
	cout << res << endl;
}


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

int main() {
	string S; cin >> S;
	int ans = 0, no = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S.at(i) == 'o') ans++;
		else no++;
	}
	if (no >= 8) {
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int x, k, q;
int r[maxn];
std::vector<int> v;
int min[maxn << 2], max[maxn << 2], add[maxn << 2], tag[maxn << 2];
struct Q {
	int t, a, id0, id1;
} a[maxn];
inline int cmp0(const Q & x, const Q & y) { return x.a < y.a; }
inline int cmp1(const Q & x, const Q & y) { return x.t < y.t; }
inline void putadd(int x,int v) {
	min[x] += v, max[x] += v, add[x] += v;
}
inline void put(int x,int v) {
	min[x] = max[x] = tag[x] = v, add[x] = 0;
}
inline void down(int x) {
	if(tag[x] >= 0) {
		put(x << 1, tag[x]);
		put(x << 1 | 1, tag[x]);
		tag[x] = -1;
	}
	putadd(x << 1, add[x]);
	putadd(x << 1 | 1, add[x]);
	add[x] = 0;
}
inline void update(int x) {
	min[x] = std::min(min[x << 1], min[x << 1 | 1]);
	max[x] = std::max(max[x << 1], max[x << 1 | 1]);
}
inline void build(int cur = 1,int l = 1,int r = q) {
	tag[cur] = -1;
	if(l == r) {
		min[cur] = max[cur] = a[l].a;
		return ;
	}
	int mid = l + r >> 1;
	build(cur << 1, l, mid);
	build(cur << 1 | 1, mid + 1, r);
	update(cur);
}
inline void uptmin(int cur = 1,int l = 1,int r = q) {
	if(max[cur] <= 0) return put(cur, 0);
	if(min[cur] >= 0) return ;
	int mid = l + r >> 1; down(cur);
	uptmin(cur << 1, l, mid);
	uptmin(cur << 1 | 1, mid + 1, r);
	update(cur);
}
inline void uptmax(int cur = 1,int l = 1,int r = q) {
	if(min[cur] >= x) return put(cur, x);
	if(max[cur] <= x) return ;
	int mid = l + r >> 1; down(cur);
	uptmax(cur << 1, l, mid);
	uptmax(cur << 1 | 1, mid + 1, r);
	update(cur);
}
inline int test(int pos,int cur = 1,int l = 1,int r = q) {
	if(l == r) return min[cur];
	int mid = l + r >> 1; down(cur);
	return pos <= mid ? test(pos, cur << 1, l, mid) : test(pos, cur << 1 | 1, mid + 1, r);
}
int ans[maxn];
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> x >> k;
	v.push_back(0);
	rep(i, 1, k) {
		cin >> r[i];
		v.push_back(r[i]);
	}
	cin >> q;
	rep(i, 1, q) {
		cin >> a[i].t >> a[i].a;
		a[i].id0 = i;
		v.push_back(a[i].t);
	}
	sort(v.begin(), v.end()), v.erase(unique(v.begin(), v.end()), v.end());
	std::sort(a + 1, a + q + 1, cmp0);
	rep(i, 1, q) {
		a[i].id1 = i;
	}
	build();
	std::sort(a + 1, a + q + 1, cmp1);
	for(int i = 0, qid = 1;i < v.size();++i) {
		if(i != 0) {
			int idx = std::lower_bound(r + 1, r + k + 1, v[i]) - r & 1;
			putadd(1, idx ? v[i - 1] - v[i] : v[i] - v[i - 1]);
			uptmin(), uptmax();
		}
		for(;qid <= q && a[qid].t == v[i];++qid) {
			ans[a[qid].id0] = test(a[qid].id1);
		}
	}
	rep(i, 1, q) {
		cout << ans[i] << '\n';
	}
}


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

#define double long double
#define vec vector
#define pb push_back
#define unset unordered_set
#define ii pair<int, int>
#define X first
#define Y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define bitcount(n) __builtin_popcountll(n)
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first,l.second+r.second};
} 
const long long ZERO = 0LL;
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0L);
const double EPS = static_cast<double>(1e-9);
typedef long long ll;

int norm(int a) {
  return ((a % MOD) + MOD) % MOD;
}

int mul(int a, int b) {
  return int(a * 1LL * b % MOD);
}

int binPow(int a, int k) {
  int ans = 1;
  for (; k > 0; k >>= 1) {
    if (k & 1) {
      ans = mul(ans, a);
    }
    a = mul(a, a);
  }
  return ans;
}

// If I need to find (x / a) % MOD, I need to use this function:
//    (x / a) % MOD = (x * inv(a)) % MOD
int inv(int a) {
  int b = binPow(a, MOD - 2);
  assert(mul(a, b) == 1);
  return b;
}

// Init variables here
const int N = 1e6 + 7;

void init() {
  //freopen("??.in", "r", stdin);
  //freopen("??.out", "w", stdout);

}

void solve() {
  int n; scanf("%d", &n);
  int a[n];
  FOR(i, 0, n) scanf("%d", &a[i]);
  int cnt = 0, res = 0;
  FOR(i, 1, n) {
    if (a[i] > a[i - 1]) {
      res = max(res, cnt);
      cnt = 0;
    } else {
      cnt++;
    }
  }
  res = max(res, cnt);
  printf("%d\n", res);
  // read the question correctly (is y a vowel?)
  // look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
}

int main() {
  //ios_base::sync_with_stdio(false); cin.tie();
  //auto beginProgram = chrono::steady_clock::now();
  //int t; scanf("%d", &t); while (t--) 
  {
    init();
    solve();
  }
  //auto endProgram = chrono::steady_clock::now();

  return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i = 0;i<n;i++)
		cin>>a[i];
	int b[n];
	memset(b,0x3f, 4*n);
	b[0]=0;
	for(int i = 1;i <min(k,n);i++)
		b[i] = abs(a[i]-a[0]);
	for(int i = k;i<n; i++)
	{
		for(int j = i-k; j<i; j++)
		{
			b[i]= min(b[i], b[j]+abs(a[i]-a[j]));
		}
	}
	cout<<b[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	s := next()
	zos := map[byte]int{}

	for i := 0; i < len(s); i++ {
		zos[s[i]]++
	}

	if zos['0'] < zos['1'] {
		fmt.Println(zos['0'] * 2)
	} else {
		fmt.Println(zos['1'] * 2)
	}
}


Measured memory_bytes: 896
from collections import defaultdict
 
H,W,M = map(int,input().split())
hw = defaultdict(int)
 
h = [0]*H
w = [0]*W
 
for _ in range(M):
    hh,ww = map(int,input().split())
    h[hh-1] += 1
    w[ww-1] += 1
    hw[(hh-1,ww-1)] = 1
 
def returnMaxs(a):
    m = max(a)
    ind = []
    for i in range(len(a)):
        if a[i] == m:
            ind.append(i)
    return ind
 
ind_h = returnMaxs(h)
ind_w = returnMaxs(w)
 
m = h[ind_h[0]]+w[ind_w[0]]
 
if len(ind_h)*len(ind_w) > M:
    print(m)
else:
    flag = False
    for i in ind_h:
        for j in ind_w:
            if hw[(i,j)] == 0:
                flag = True
    
    if flag:
        print(m)
    else:
        print(m-1)

Measured memory_bytes: 178784
#include <stdio.h>
#include <string.h>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, h, w;
  scanf("%lld%lld", &h, &w);
  char s[h][w + 10];
  ll dp[h][w];
  for(i = 0; i < h; ++i) scanf("%s", s[i]);
  for(i = 0; i < h; ++i) for(j = 0; j < w; ++j) dp[i][j] = 0;
  dp[0][0] = 1;
  for(i = 0; i < h; ++i) for(j = 0; j < w; ++j) if(s[i][j] == '.') {
    if(i) dp[i][j] += dp[i - 1][j];
    if(j) dp[i][j] += dp[i][j - 1];
    dp[i][j] %= mod;
  }
  printf("%lld", dp[h - 1][w - 1]);
  return 0;
}

Measured memory_bytes: 8960
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define koto_memory(a) cout<<(sizeof(a)/1048576.0)<<" MB";
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int a[N],b[N];
void solve(){
	int n,m,k,ans=0;cin>>n>>m>>k;
	rep(i,1,n)cin>>a[i];
	rep(i,1,m)cin>>b[i];
	rep(i,1,max(n,m))a[i]+=a[i-1],b[i]+=b[i-1];
	rep(i,1,n){
		if(a[i]>k)break;
		int num=prev(upper_bound(b+1,b+1+m,k-a[i]))-b;
		ans=max(ans,i+num);
	}
	rep(i,1,m){
		if(b[i]>k)break;
		int num=prev(upper_bound(a+1,a+1+n,k-b[i]))-a;
		ans=max(ans,i+num);
	}
	cout<<ans;
}
int32_t main()
{
  ibs;cti;
  solve()
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <double, double> point;

const ll MOD=1000000007;

typedef double coord_t;         // coordinate type
typedef double coord2_t;  // must be big enough to hold 2*max(|coordinate|)^2

struct Point {
    coord_t x, y;
    
    bool operator <(const Point &p) const {
        return x < p.x || (x == p.x && y < p.y);
    }
};

// 2D cross product of OA and OB vectors, i.e. z-component of their 3D cross product.
// Returns a positive value, if OAB makes a counter-clockwise turn,
// negative for clockwise turn, and zero if the points are collinear.
coord2_t cross(const Point &O, const Point &A, const Point &B)
{
    return (A.x - O.x) * (B.y - O.y) - (A.y - O.y) * (B.x - O.x);
}

// Returns a list of points on the convex hull in counter-clockwise order.
// Note: the last point in the returned list is the same as the first one.
vector<Point> convex_hull(vector<Point> P)
{
    ll n = P.size(), k = 0;
    if (n <= 3) return P;
    vector<Point> H(2*n);
    
    // Sort points lexicographically
    sort(P.begin(), P.end());
    
    // Build lower hull
    for (ll i = 0; i < n; ++i) {
        while (k >= 2 && cross(H[k-2], H[k-1], P[i]) <= 0) k--;
        H[k++] = P[i];
    }
    
    // Build upper hull
    for (ll i = n-1, t = k+1; i > 0; --i) {
        while (k >= t && cross(H[k-2], H[k-1], P[i-1]) <= 0) k--;
        H[k++] = P[i-1];
    }
    
    H.resize(k-1);
    return H;
}

double ang(Point s, Point t,Point u){
    Point x,y;
    x=Point{s.x-t.x,s.y-t.y};
    y=Point{u.x-t.x,u.y-t.y};
    double T=((x.x*y.x+x.y*y.y)/(sqrt(x.x*x.x+x.y*x.y)*sqrt(y.x*y.x+y.y*y.y))>=1?double(1):(x.x*y.x+x.y*y.y)/(sqrt(x.x*x.x+x.y*x.y)*sqrt(y.x*y.x+y.y*y.y)));
    return acos(T);
}
int N;
double x[100],y[100];
vector<Point> A;
double ans[100];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    map<Point, ll> m;
    rep(i,0,N){
        cin>>x[i]>>y[i];
        A.pb(Point{x[i],y[i]});
        m[Point{x[i],y[i]}]=i;
    }
    vector<Point> conv=convex_hull(A);
    int s=sz(conv);
    double pi=acos(-1.0);
    rep(i,0,s){
        ans[m[conv[i]]]=(pi-ang(conv[(i-1+s)%s],conv[i],conv[(i+1)%s]))/(pi*2);
    }
    rep(i,0,N){
        cout <<setprecision(15)<<ans[i]<<"\n";
    }
}

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

using namespace std;

typedef long long ll;
const int mod = (int) 1e9 + 7;

int add(int a, int b) {
  a += b;
  if (a >= mod) {
    return a - mod;
  }
  if (a < 0) {
    return a + mod;
  }
  return a;
}

int mul(int a, int b) {
  return a * (ll) b % mod;
}

int pw(int a, int b) {
  int r = 1;
  while (b) {
    if (b & 1) {
      r = mul(r, a);
    }
    a = mul(a, a);
    b /= 2;
  }
  return r;
}

const int N = 400 + 7;
int n, c, a[N], b[N], sol[N][N];

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

  cin >> n >> c;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
  }
  sol[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int ad = 0; ad <= c; ad++) {
      int sum = 0;
      for (int x = a[i]; x <= b[i]; x++) {
        sum = add(sum, pw(x, ad));
      }
      for (int cur = 0; cur + ad <= c; cur++) {
        sol[i][cur + ad] = add(sol[i][cur + ad], mul(sol[i - 1][cur], sum));
      }
    }
  }
  cout << sol[n][c] << "\n";
}


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

int main(){
  int K,T;
  cin >> K >> T;
  vector<int> L(T);
  for(int i=0;i<T;i++)
    cin >> L.at(i);
  sort(L.begin(),L.end());
  int a = L.at(T-1);
  a = K-1-2*(K-a);
  if(a<=0)
    cout << 0;
  else
    cout << a;
}

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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    int tmp = 0;
    rep(i, 3) {
        if (s[i] == 'R')
            tmp++;
        else
            tmp = 0;
        ans = max(ans, tmp);
    }
    out(ans);

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector< vector<int> > p(N, vector<int>(3));
  for (int i = 0; i < N; i++) for (int j = 0; j < 3; j++) cin >> p[i][j];

  for (int i = 0; i < N; i++) sort(p[i].begin(), p[i].end());

  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (p[j][0] != -1 && p[i] == p[j]) {
        ans++;
        p[j][0] = -1;
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3212
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n = I()
    a = list(IL())
    c = 0
    for rep in range(0,n,2):
        if a[rep]%2:
            c += 1
    print(c)
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 27096
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
#define pi 3.1415926

int a[(int)2e5][11];

int main(){
    int a, b;
    string s, t, u;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    if(u == s)
        a = a - 1;
    else
        b = b - 1;

    cout << a << ' ' << b;
    
    
    
}

    

		


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;
const char ENDL = '\n';

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int k,t;
    cin >> k >> t;
    VI a(t);
    REP(i,t){
        cin >> a[i];
    }

    int m = *max_element(ALL(a));

    cout << max(2*m-k-1,0LL) << ENDL;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,sum;
int main() {
	cin>>a>>b;
	if(a<b) {
		swap(a,b);
	}
	sum+=a;
	a--;
	if(a<b) {
		swap(a,b);
	}
	sum+=a;
	cout<<sum<<endl;
	return 0;
} 

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,m,r;
int d[35];
int g[35][35];
vi gg[35];
// pos,time,prev -> max num
int dp[35][1252][35][2];
const int INF = 830252521;

int main(){
  scanf("%d%d%d",&n,&m,&r);
  REP(i,n)scanf("%d",d+i);
  REP(i,n)REP(j,n)g[i][j] = INF;
  REP(i,n)g[i][i] = 0;
  REP(i,m){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    --a;--b;
    g[a][b] = g[b][a] = c;
    gg[a].push_back(b);
    gg[b].push_back(a);
  }
  REP(i,n)REP(j,r+1)REP(k,n)REP(b,2)dp[i][j][k][b] = -INF;
  dp[0][0][0][0] = 0;
  REP(tm,r+1)REP(pos,n)REP(prv,n)REP(b,2){
    int now = dp[pos][tm][prv][b];
    if(now<0)continue;
    // printf("%d %d %d %d -> %d\n",tm,pos,prv,b,now);
    int prvlast = g[pos][prv];
    REP(i,gg[pos].size()){
      int to = gg[pos][i];
      int nxtprv = pos;
      if(b)nxtprv = to;
      if(to==prv){
        if(prvlast*2 >= 15){
          // go
          CHMAX(dp[to][tm+prvlast][nxtprv][0],now+d[to]);
        }else{
          // no wait
          CHMAX(dp[to][tm+prvlast][nxtprv][1],now);
          // wait and go
          CHMAX(dp[to][tm+15-prvlast][to][0],now+d[to]);
        }
      }else{
        // go
        CHMAX(dp[to][tm+g[pos][to]][nxtprv][0],now+d[to]);
      }
    }
    // all wait
    CHMAX(dp[pos][tm+15][pos][0],now+d[pos]);
  }
  int ans = 0;
  REP(tm,r+1)REP(prv,n)REP(b,2)CHMAX(ans,dp[n-1][tm][prv][b]);
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 11240
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    
    if((abs(a-b)<=d&&abs(b-c)<=d)||abs(a-c)<=d) printf("Yes\n");
    else printf("No\n");
    
    return 0;
}


Measured memory_bytes: 128
N, K = map(int, input().split())
have = [0 for _ in range(N)]

for k in range(K):
    d = int(input())
    Alist = list(map(int, input().split()))
    for i in Alist:
        have[i-1] = 1

ans = 0
for i in range(N):
    if have[i] == 0:
        ans += 1

print(ans)

Measured memory_bytes: 9212
N=int(input())
A=list(map(int,input().split()))


ABS=[abs(A[i]) for i in range(N)]

x=max(ABS)
ki=ABS.index(x)

ANSLIST=[]
for i in range(ki):
    ANSLIST.append((ki+1,i+1))

for j in range(ki+1,N):
    ANSLIST.append((ki+1,j+1))

if A[ki]>0:
    for i in range(N-1):
        ANSLIST.append((i+1,i+2))
elif A[ki]<0:
    for i in range(N-1,0,-1):
        ANSLIST.append((i+1,i))

print(len(ANSLIST))

for ans in ANSLIST:
    print(ans[0],ans[1])



Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7, INF = 1e9, maxn = 1e9;
int n, k; vector<vector<int>>sum;

int f(int i, int j) {
	return sum[i][j] - sum[i - k][j] - sum[i][j - k] + sum[i - k][j - k];
}

int main() {
	cin >> n >> k;
	int t = 2 * k, s = 4 * k;
	sum.resize(s + 5, vector<int>(s + 5, 0));
	for (int i = 0, x, y; i < n; i++) {
		char c; cin >> x >> y >> c;
		x %= t, y %= t;
		if (c == 'B')x += k;
		x %= t;
		sum[x][y]++, sum[x + t][y]++, sum[x][y + t]++, sum[x + t][y + t]++;
	}
	for (int i = 1; i < s; i++)for (int j = 1; j < s; j++) {
		sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
	}
	int ans = 0;
	for (int i = 0; i < t; i++)for (int j = 0; j < t; j++) {
		ans = max(ans, f(i + k, j + k) + f(i + t, j + t));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 63104
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
using ll = long long;
int main() {
    int n,d;
    cin >> n >> d;
    vector<int> x(n),y(n);
    for(int i=0;i<n;i++){
        cin >> x[i] >> y[i];
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        ll p = pow(x[i],2.0);
        ll q = pow(y[i],2.0);
        ll sqinput = p + q;
        if(d >= sqrt(sqinput)){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4900
#include <stdio.h>
#include <utility>
#include <algorithm>
typedef long long ll;
using namespace std;

bool cmp(pair<ll, ll> &a, pair<ll, ll> &b) {
  if(a.first > b.first) return true;
  if(a.first < b.first) return false;
  if(a.second < b.second) return true;
  return false;
}

int main(void) {
  ll i, j, k, n, cnt = 1, now = 0, max, sum = 0;
  scanf("%lld", &n);
  pair<ll, ll> a[n];
  ll ans[n];
  for(i = 0; i < n; ++i) {
    scanf("%lld", &a[i].first);
    a[i].second = i;
    ans[i] = 0;
  }
  sort(a, a + n, cmp);
  now = a[0].second, max = sum = a[0].first;
  for(i = 1; i < n; ++i) {
    if(now > a[i].second) {
      ans[now] = sum - cnt * a[i].first + (i - cnt) * (max - a[i].first);
      now = a[i].second, cnt = 1, max = sum = a[i].first;
    } else sum += a[i].first, cnt++;
  }
  ans[now] = sum + (n - cnt) * max;
  for(i = 0; i < n; ++i) printf("%lld\n", ans[i]);
  return 0;
}

Measured memory_bytes: 3328
def cookies_exchanges(a, b, c):
    counter = 0

    olds = []
    while int(a%2) is 0 and int(b%2) is 0 and int(c%2) is 0:
        if (a, b, c) in olds:
            return -1

        olds.append((a,b,c))
        o_a, o_b, o_c = olds[counter]
        a = o_b/2 + o_c/2
        b = o_a/2 + o_c/2
        c = o_a/2 + o_b/2
        counter += 1

    return counter

a, b, c = map(int, input().split())
print(cookies_exchanges(a, b, c))


Measured memory_bytes: 3064
#
import sys
import math
import numpy as np
import itertools


# ひとつ入力
n = int(input())
# リストに入れる
v = [int(i) for i in input().split()] 
# リストに入れる
c = [int(i) for i in input().split()] 
answer = 0
for i in range(n):
    if(v[i]-c[i] > 0):
        answer += (v[i]-c[i])
print(answer)



Measured memory_bytes: 21564
import java.util.*;
import static java.lang.Math.*;
public class Main {
	final Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	Main(){
		new AOJ1203();
	}
	
	class AOJ1203{
		AOJ1203(){
			while(sc.hasNextLine()){
				str=sc.nextLine();
				str = str.toUpperCase();
				str = str.replaceAll("[^A-Z]", "");
				solve();
			}
		}
		String str;
		char[] cs;
		Set<String> ans,ng;
		void solve(){
			ans=new HashSet<String>();
			ng=new HashSet<String>();
			cs=str.toCharArray();
			for(int c=0; c<str.length(); ++c){
				int l=c-1, r=c+1;
				if(0<=l && r<str.length() && cs[l]==cs[r]){
					String ret=f(l,r);
					if(ret.length()>2)	ans.add(ret);
				}
				l=c+1; r=c;
				if(0<=l && r<str.length()){
					String ret=f(l,r);
					if(ret.length()>2)	ans.add(ret);
				}
			}
			int cnt=0;
			for(String s:ans){
				if(!ng.contains(s)){
					if(cnt>0)	System.out.print(" ");
					System.out.print(s);
					++cnt;
				}
			}
			System.out.println();
//			System.out.println(ng);
		}
		String f(int l,int r){
			while(0<=l-1 && r+1<str.length()){
				if(cs[l-1]==cs[r+1]){
					ng.add(str.substring(l, r+1));
				}else{
					return str.substring(l, r+1);
				}
				--l;	++r;
			}
			return str.substring(l, r+1);
		}
	}
}

Measured memory_bytes: 20204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
signed main(){
	ll N;
	cin >> N;
	vector<ll> A(N);
	for(int i = 0; i < N; i++){
		cin >> A.at(i);
	}
	ll sum = 0;
	ll last = A.at(0);
	for(int i = 1; i < N; i++){
		ll prev = A.at(i);
		if(prev < last){
			sum += last-prev;
			A.at(i) = A.at(i-1);
		}
		last = A.at(i);
	}
	cout << sum << endl;
 
	return 0;
}

Measured memory_bytes: 4840
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
l=[]
def fun(itm):
    return itm[1]
for i in range(m):
    l.append(list(map(int,input().split())))
l.sort(key=fun,reverse=True)
idx=0
for i in l:
    for j in range(i[0]):
        if(idx==n):
            break
        if(a[idx]<i[1]):
            a[idx]=i[1]
            idx+=1
        else:
            break
    else:
        continue
    break
print(sum(a))

Measured memory_bytes: 32980
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
	int N;
	int A, B;

	cin >> N >> A >> B;

	int costA = A * N;
	int costB = B;

	cout<< min(costA, costB) << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int h = scanner.nextInt();
			int w = scanner.nextInt();
			char[][] input = new char[h][];
			IntStream.range(0, h).forEach(i -> input[i] = scanner.next().toCharArray());
			char[][] output = new char[2 * h][w];
			IntStream.range(0, 2 * h).forEach(i -> IntStream.range(0, w).forEach(j -> output[i][j] = input[i / 2][j]));
			IntStream.range(0, 2 * h).forEach(i -> System.out.println(output[i]));
		}
	}
}


Measured memory_bytes: 30164
X, Y = map(int, input().split())

sum = 0
if X == 1:
    sum += 300000
elif X == 2:
    sum += 200000
elif X == 3:
    sum += 100000

if Y == 1:
    sum += 300000
elif Y == 2:
    sum += 200000
elif Y == 3:
    sum += 100000

if sum == 600000:
    sum += 400000

print(sum)


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

using namespace std;
const int N = 5e5 + 10;
char s[N];
int t[26][N];
int n,q;
int lowbit(int x)
{
    return x & -x;
}
void update(int x,int c,int *a)
{
    for(int i = x;i <= n;i += lowbit(i))a[i] += c;
}

int sum(int x,int *a)
{
    int res = 0;
    for(int i = x;i >= 1;i -= lowbit(i))res += a[i];
    return res;
}

int main()
{
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#endif
    cin >> n >> s >> q;
    for(int i = 0;i < n;i++)update(i + 1,1,t[s[i] - 'a']);

    while(q--)
    {
        int a;
        cin >> a;
        if(a == 1)
        {
            int b;char tt;
            cin >> b >> tt;
            update(b,-1,t[s[b-1]-'a']);
            s[b-1] = tt;
            update(b,1,t[tt -'a']);
        }
        else 
        {
            int ans = 0;
            int l,r;
            cin >> l >> r;
            for(int i = 0;i < 26;i++)
            {
                if(sum(r,t[i]) - sum(l-1,t[i]) >= 1)ans++;
            }
            cout << ans <<"\n";
        }
    }

    return 0;
}

Measured memory_bytes: 51584
a[100];*p;i,j;main(m){for(scanf("%*d%d",&m);~scanf("%d",a+i++););for(;j++<m;)for(p=a;a+i-p-2;p++)*p%j>p[1]%j?*p^=p[1]^=*p^=p[1]:0;for(p=a;j=a+i-p-1;printf("%d\n",*p++));}

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

typedef long long ll;

int main() {
    ll X, ans = 0, A = 100;
    cin >> X;
    while (A < X) {
        ans++;
        A *= 1.01;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3588
#include<iostream>
#include<cstdlib>
#include "bits/stdc++.h"
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  int x[n],i0 = 0;
  for(int i=0;i<n;i++) {
    cin >> x[i];
    if (i > 0 && x[i] >= 0 && x[i-1] < 0) i0 = i;
  }
  int t_min=INT_MAX;
  for(int i=0;i<n-k+1;i++){
    int t = min(x[i+k-1]-x[i]+abs(x[i+k-1]), x[i+k-1]-x[i]+abs(x[i]));
    if(t < t_min)t_min = t;
  }
  cout << t_min << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    REP(i, 1e6) {
        if((b*i + c) % a == 0) {
            puts("YES");
            return 0;
        }
    }
    puts("NO");
    return 0;
}

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

void EAST(int* dice) {
    int copy = dice[0];
    dice[0] = dice[3];
    dice[3] = dice[5];
    dice[5] = dice[2];
    dice[2] = copy;
}

void NORTH(int* dice) {
    int copy = dice[0];
    dice[0] = dice[1];
    dice[1] = dice[5];
    dice[5] = dice[4];
    dice[4] = copy;
}

void SOUTH(int* dice) {
    int copy = dice[0];
    dice[0] = dice[4];
    dice[4] = dice[5];
    dice[5] = dice[1];
    dice[1] = copy;
}

void WEST(int* dice) {
    int copy = dice[0];
    dice[0] = dice[2];
    dice[2] = dice[5];
    dice[5] = dice[3];
    dice[3] = copy;
}

int main(void) {
    int dice[6];
    string order;
    
    for(int i = 0; i < 6; ++i) {
        cin >> dice[i];
    }
    cin >> order;
    
    for(int i = 0; i < order.length(); ++i) {
        switch(order[i]) {
            case 'E' : EAST(dice);   break;
            case 'N' : NORTH(dice);  break;
            case 'S' : SOUTH(dice);  break;
            case 'W' : WEST(dice);   break;
        }
    }
    cout << dice[0] << endl;
    
    return 0;
}


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

int main()
{
    int n,k;
    cin >> n >> k;
    vector<ll> a(n);
    for(auto& ai:a) cin >> ai;

    ll asum = accumulate(a.begin(),a.end(),ll(0));
    vector<ll> x;
    for(ll i=1,i_max=(ll)sqrt(asum);i<=i_max;++i) {
        if(asum%i == 0) {
            x.push_back(i);
            if(i*i != asum) x.push_back(asum/i);
        }
    }
    sort(x.begin(),x.end(),greater<ll>());

    for(auto xi:x) {
        vector<ll> y(n);
        rep(i,n) y[i] = a[i] % xi;
        sort(y.begin(),y.end());
        ll rsum = 0;
        rep(i,n) rsum += (xi-y[i]) % xi;
        ll sum = 0;
        rep(i,n) {
            rsum -= (xi-y[i]) % xi;
            sum += y[i];
            if(sum >= rsum) break;
        }
        if(sum <= k) {
            cout << xi << endl;
            return 0;
        }
    }

    cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n); i++)
#define sz(x) int(x.size())
using namespace std;

int main(){
    int n, a, b;

    cin >> n >> a >> b;

    cout << min(b, a*n) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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());
		int[] cases = new int[M];
		int[] expects = new int[M];

		for (int i = 0; i < M; i++) {
			int k = Integer.parseInt(sc.next());
			for (int j = 0; j < k; j++) {
				int n = Integer.parseInt(sc.next()) - 1;
				cases[i] += 1 << n;
			}
		}

		for (int i = 0; i < M; i++) {
			expects[i] = Integer.parseInt(sc.next());
		}
		sc.close();

		int ans = 0;
		for (int i = 0; i < 1 << N; i++) {
			boolean ok = true;
			for (int j = 0; j < M; j++) {
				if (Integer.bitCount(cases[j] & i) % 2 != expects[j]) {
					ok = false;
					break;
				}
			}
			if (ok) {
				ans++;
			}
		}

		System.out.println(ans);

	}

}

Measured memory_bytes: 23252
from itertools import permutations
from scipy.sparse.csgraph import floyd_warshall

INF = 10 ** 18
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
dp = [[INF for _ in range(N)] for _ in range(N)]
for i in range(N):
    for j in range(N):
        if i == j:
            dp[i][j] = 0

for i in range(M):
    a, b, c = map(int, input().split())
    dp[a - 1][b - 1] = c
    dp[b - 1][a - 1] = c

wf = floyd_warshall(dp)
ans = INF
for i in permutations(r):
    tmp = 0
    for j in range(1, len(i)):
        tmp += wf[i[j - 1] - 1][i[j] - 1]
    ans = min(ans, tmp)

print(int(ans))

Measured memory_bytes: 18972
using System;
class Program
{
    static void Main(string[] args)
    {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            if (t.Substring(0, s.Length) != s)
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
    }
}

Measured memory_bytes: 25880
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector <ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <vector<ll>> vv;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;

#define Endl endl


/*--------------------template--------------------*/



int main() {
    cin >> s;
    bool a = (s.size() % 2 == 0 ? true : false);
    bool b = (s[0] == s.back() ? true : false);
    cout << (a^b ? "Second" : "First") << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned ll
#define F first
#define S second
#define mp make_pair
#define pb push_back

using namespace std;

const int MIN = 1e3 + 2;
const int MXN = 1e6 + 3;
const int INF = 1e9 + 7;
const ll LINF = 1e18 + 15;
const double EPS = 1e-9;

ld q, h, s, d, n;
pair <ld, ld> a[5];

double f (double x){
    if (x == 0.25) return q;
    if (x == 0.5) return h;
    if (x == 1.0) return s;
    if (x == 2.0) return d;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> q >> h >> s >> d;
    cin >> n;
    a[1].S = 0.25;
    a[2].S = 0.5;
    a[3].S = 1.0;
    a[4].S = 2.0;
    a[1].F = q / 0.25;
    a[2].F = h / 0.5;
    a[3].F = s / 1.0;
    a[4].F = d / 2.0;
    sort (a + 1, a + 5);
    if (a[1].S == 2.0 && ((ll)n) % 2)
        cout << (ll)(((ll)n) / 2 * (ll)d + 1.0 / a[2].S * f(a[2].S));
    else
        cout << (ll)(n / a[1].S * f(a[1].S));

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <iomanip>

using namespace std;

typedef complex<double> Point;
#define rep(i, n) for(int i=0; i<(n); ++i)
const double eps = 1e-8, inf = 1e8, pi = acos(-1.);

template<typename T> inline void chmin(T& t, T f){if(t > f)t = f;}

double cross(const Point& a, const Point& b){
    return imag(conj(a) * b);
}

double dot(const Point& a, const Point& b){
    return real(conj(a) * b);
}

int ccw(Point a, Point b, Point c){
    b -= a; c -= a;
    if(cross(b, c) > eps)return 1;
    if(cross(b, c) < -eps)return -1;
    if(dot(b, c) < 0)return 2;
    if(norm(b) < norm(c))return -2;
    return 0;
}

struct Line : vector<Point> {
    Line(const Point& a, const Point& b){
        push_back(a); push_back(b);
    }
};

Point proj(const Line& l, const Point& p){
    double t = dot(p - l[0], l[1] - l[0]) / norm(l[0] - l[1]);
    return l[0] + (l[1] - l[0]) * t;
}

bool interSP(const Line& s, const Point& p){
    return abs(s[0] - p) + abs(s[1] - p) - abs(s[1] - s[0]) < eps;
}

bool interSS(const Line& s, const Line& t){
    return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 &&
           ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0;
}

double distSP(const Line& s, const Point& p){
    const Point r = proj(s, p);
    return interSP(s, r)? abs(r - p): min(abs(s[0] - p), abs(s[1] - p));
}

double distSS(const Line& s, const Line& t){
    return interSS(s, t)? 0: min({distSP(s, t[0]), distSP(s, t[1]), distSP(t, s[0]), distSP(t, s[1])});
}

int N, M, L;

double solve(vector<vector<Line> >& pent){
    vector<vector<double> > dist(N, vector<double>(N));
    rep(i, N)rep(j, i){
        dist[i][j] = inf;
        for(auto s: pent[i])for(auto t: pent[j])chmin(dist[i][j], distSS(s, t));
        dist[j][i] = dist[i][j];
    }
    rep(k, N)rep(i, N)rep(j, N)chmin(dist[i][j], dist[i][k] + dist[k][j]);
    return dist[M][L];
}

int main(){
    while(cin >> N >> M >> L, N|M|L){
        M--; L--;
        vector<vector<Line> > pent(N);
        rep(i, N){
            int x, y, a, r;
            cin >> x >> y >> a >> r;
            vector<Point> v;
            rep(j, 5)v.push_back(Point(x, y) + polar(1. * r, (a + 72 * j) * pi / 180 + pi / 2));
            rep(j, 5)pent[i].emplace_back(v[j], v[(j + 2) % 5]);
        }
        cout << fixed << setprecision(20) << solve(pent) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1436
if __name__ == '__main__':

	n,k = map(int,input().split())
	A = list(map(int,input().split()))

	ans = float("inf")

	for i in range(k+1):
		if i+k > n:
			break

		left = A[i]
		right = A[i+k-1]

		#1 abs(left) < abs(right) の場合
		tmp2 = abs(left) + abs(right - left)

		#2 abs(right) > abs(left)の場合
		tmp3 = abs(right) + abs(left - right)

		ans = min(ans,min(tmp2,tmp3))

	print(ans)


Measured memory_bytes: 20128
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll MOD=(ll)998244353;
//}}}

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

int main(){
  int N, X;
  cin >> N >> X;
  int ans = 0;
  rep(i, N){
    int a;
    cin >> a;
    if(i == 0){
      ans = abs(X - a);
    }else{
      ans = gcd(abs(X - a), ans);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
d = list(map(int, input().split())) + [0]
d.sort()
d = [j if i%2 else (24-j)%24 for i, j in enumerate(d)]
d.sort()
ans = float("Inf")
for i in range(n+1):
    k = abs(d[i-1]-d[i])
    ans = min(ans, min(k, 24-k))
print(ans)

Measured memory_bytes: 3064