akhauriyash/Code-Regression huggingface dataset:
A, B, N = map(int, input().split())


if B < N:
    Max = int(A*(B-1)/B)
    X = int(N/B)
    fx = int(A*(B*X-1)/B) - A * int((B*X-1)/B)
    # Max = max(fx,Max)
    # for x in range(1,X):
    #     fx = int(A*x/B) - A * int(x/B)
    #     Max = max(Max,fx)
elif B == N:
    Max = int(A*(B-1)/B)
else:
    Max = int(A*N/B)
print(Max)


Measured memory_bytes: 9124
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
bool white[800001];
bool used[800001];
int b[800001];
int re;

int dx[4] = {-7, -1, 1, 7};
int count_a;

void dfs(int x){
  used[x] = true;
  b[x] = count_a;
  rep(i, 4){
    int nx = x + dx[i];
    if(x % 7 == 0 && nx % 7 == 6)continue;
    if(x % 7 == 6 && nx % 7 == 0)continue;
    if(nx >= 0 && nx < re){
      if(!used[nx] && white[nx]){
        dfs(nx);
      }
    }
  }
}

int main(int argc, char const* argv[])
{
  ll n;
  int m, q;
  cin >> n >> m >> q;
  vector<int> a(q);
  rep(i, q){
    cin >> a[i];
  }
  re = (m % 7 == 0) ? m: 7 * m;
  fill(white, white + re, true);
  rep(i, q){
    rep(j, 7){
      white[a[i] + j * m] = false;
    }
  }
  count_a = 0;
  rep(i, re){
    if(!used[i] && white[i]){
      count_a++;
      dfs(i);
    }
  }
  set<int> st;
  rep(i, 7){
    if(white[i] && white[re-7+i])st.insert(b[i]);
  }
  int count_b = int(st.size());
  cout << (ll)(count_a - count_b) * ((7 * n) / re) + (ll)count_b << endl;
	return 0;
}


Measured memory_bytes: 16768
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int k; cin >> k;
	int64_t ans = 0;
	for(int a = 1; a <= k; ++a) {
		for(int b = 1; b <= k; ++b) {
			int64_t g = gcd(a, b);
			for(int c = 1; c <= k; ++c) {
				ans += gcd(g, c);
			}
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    cout << max({a, b, c}) - min({a, b, c});
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		String s = in.next();
		int n = s.length();

		String[] array = new String[n];
		for (int i = 0; i < n; i++) {
			array[i] = s.substring(i, i + 1);
		}
		String ans = "";

		for (int i = 0; i < n; i++) {
			if (array[i].equals("0")) {
				ans = ans + "0";
			} else if (array[i].equals("1")) {
				ans = ans + "1";
			} else {
				if (ans.length() != 0) {
					ans = ans.substring(0, ans.length() - 1);
				}
			}
		}
		System.out.println(ans);
		in.close();

	}

}

Measured memory_bytes: 9424
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		map<string, int>mp;
		bool flag = true;
		for (int i = 0; i < N; ++i) {
			string st; cin >> st;
			mp[st]++;
			vector<int>v;

			v.emplace_back(0);
			string max_name;
			for (auto m : mp) {
				if (m.second >* max_element(v.begin(), v.end()))max_name = m.first;

				v.emplace_back(m.second);
				}
			sort(v.begin(), v.end(),greater<int>());
			if (v[0] > v[1] + (N - 1 - i)&&flag) {
				flag = false;
				cout << max_name << " " << i + 1 << endl;
			}
		}
		if (flag) {
			cout << "TIE" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3180
a,b = map(int,input().split())

x = []
i = 1
n = int(a/0.08) + int(b/0.1) + 2

for i in range(0,n):
  if(int(0.08*i) == a and int(0.1*i) == b):
    x.append(i)
    
if(len(x) != 0):
  print(min(x))
else:
  print(-1)

  



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

ll gcd(ll a, ll b) {
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    int N; cin >> N;
    ll lcm = 1;
    rep(i,N) {
        ll T; cin >> T;
        lcm = lcm/gcd(lcm,T)*T;
    }
    cout << lcm << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
}

int A,B,C,D;

int main(){
	cin>>A>>B>>C>>D;
	cout<<abs(A-C)+abs(B-D)-gcd(abs(A-C),abs(B-D))<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	void solve() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		if(n == 1) {
			System.out.println("Hello World");
			return;
		}
		int a = scan.nextInt();
		int b = scan.nextInt();
		System.out.println(a + b);
		scan.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}


Measured memory_bytes: 35776
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(18);
}
#define INF 10000000000
signed main(){
  init_io();
  ll n,ans=INF,full=0;
  cin >> n;
  vector<string> a(n);
  vector<bool> can(n,false);
  vector<ll> cnt(n,0),rcnt(n,0);
  ll cp=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    for(int j=0;j<n;j++){
      if(a[i][j]=='.'){
        cnt[i]++;
        cp++;
      }
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(a[j][i]=='#'){
        rcnt[i]++;
      }
    }
    if(rcnt[i]==n){
      full++;
    }
  }
  if(cp==n*n){
    cout <<"-1\n";
    return 0;
  }
  for(int i=0;i<n;i++){
    ll x = cnt[i];
    if(!rcnt[i]) x++;
    ans = min(ans,x+n-full);
  }
  if(ans==INF) cout << "-1\n";
  else cout << ans << endl;
}


Measured memory_bytes: 512
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

s = ins()
n = len(s)
t = [-1]*(n+1)
r = [0]*2019
c = 1
t[n] = 0
r[0] = 1
t[n-1] = int(s[n-1])
r[t[n-1]] = 1
for i in range(n-2,-1,-1):
    c = (c*10)%2019
    t[i] = (t[i+1]+int(s[i])*c)%2019
    r[t[i]] += 1
#ddprint(t)
sm = 0
for i in range(2019):
    sm += r[i]*(r[i]-1)//2
print(sm)


Measured memory_bytes: 69704
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        sc.close();
        int pattern1 = A*2-1;
        int pattern2 = B*2-1;
        int pattern3 = A+B;
        System.out.println(Math.max(pattern3, Math.max(pattern1, pattern2)));      
    }
}

Measured memory_bytes: 21844
import java.util.*;

class Main {

	static int indexMax(int x[]) {
		int y=-1;
		int max=0;
		for (int i=0;i<x.length;i++) {
			if (x[i]>max) {
				max=x[i];
				y=i;
			}
		}
		return y;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a[] = new int[N];
		for (int i=0;i<N;i++) {
			a[i]=sc.nextInt();
		}
		int A=0;
		int B=0;
		int cnt=0;
		while(true) {
			int x=indexMax(a);
			A+=a[x];
			a[x]=0;
			cnt++;
			if(cnt==N) {
				break;
			}

			int y=indexMax(a);
			B+=a[y];
			a[y]=0;
			cnt++;
			if(cnt==N) {
				break;
			}
		}
		System.out.println(A-B);
	}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std ;
#define eps 1e-10
#define equals(a , b) (fabs((a) - (b)) < eps)

class Point
{
public:
    double x , y;

    Point(double x = 0 ,double y = 0):x(x) , y(y) {}

    Point operator +(Point p){return Point(x + p.x , y + p.y) ;}
    Point operator -(Point p){return Point(x - p.x , y - p.y) ;}
    Point operator *(double a){return Point(a * x , a * y) ;}
    Point operator /(double a){return Point(x / a , y / a) ;}

    double abs() {return sqrt(norm()) ;}
    double norm() {return x * x + y * y ;}

    bool operator < (const Point &p) const
    {
        return x != p.x ? x < p.x : y < p.y ;
    }

    bool operator == (const Point &p) const
    {
        return fabs(x - p.x) < eps && fabs(y - p.y) < eps ;
    }
    
};

typedef Point Vector;

struct Segment  //表示线段结构体
{
    Point p1 , p2 ;
};

double dot(Vector a , Vector b)  // 向量a,b的内积
{
    return a.x * b.x + a.y * b.y ;
}

double cross(Vector a, Vector b)  //向量a,b外积
{
	return a.x * b.y - a.y * b.x ;
}

bool isOrthogonal(Vector a , Vector b)  //判断是否正交
{
    return equals(dot(a , b) , 0.0) ;
}

bool isOrthogonal(Point a1 , Point a2 , Point b1 , Point b2)
{
    return isOrthogonal(a1 - a2 , b1 - b2) ;
}

bool  isOrthogonal(Segment s1 , Segment s2)
{
    return equals(dot(s1.p2 - s1.p1 , s2.p2 - s2.p1) , 0.0) ;
}

bool isParallel(Vector a, Vector b)  //判断是否平行
{
	return equals(cross(a, b), 0.0) ;
}

bool isParallel(Point a1, Point a2, Point b1, Point b2)
{
	return isParallel(a1 - a2, b1 - b2) ;
}

bool isParallel(Segment s1, Segment s2)
{
	return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0) ;
}
/*
Point project(Segment s1 , Point p)
{
    Vector base = s.p2 - s.p1 ;
    double r = dot(p - s.p1 , base) / norm(base) ;
    return s.p1 +base * r ;
}
*/
int main()
{
    int n ;
    cin >> n ;
    Point p1 , p2, p3 ,p4 ;
    while(n --)
    {
        cin >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y >> p4.x >> p4.y ;
        if(isOrthogonal(p1 , p2 , p3 , p4))
        {
			cout << 1 << endl ;
        }
        else if(isParallel(p1 , p2 , p3 ,p4))
        {
            cout << 2 << endl ;
        }
        else
        {
            cout << 0 <<endl ;
        }
    }
    return 0 ;
}



Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
bool ispalin(string s){
	ll n=s.size();
	bool ok=1;
	for(ll i=0,j=n-1;i<j;++i,--j){
		if(s[i]!=s[j]){
			ok^=1;
			break;
		}
	}
	return ok;
}
int main(){
	fast;
	string s; cin>>s;
	if(ispalin(s)){
		string tmp1="",tmp2="";
		ll n=s.size();
		for(auto i=0;i<(n-1)/2;++i)tmp1+=s[i];
		for(auto i=(n+3)/2-1;i<n;++i)tmp2+=s[i];
		if(ispalin(tmp1) && ispalin(tmp2))cout<<"Yes\n";
		else
			cout<<"No\n";
	}
	else
		cout<<"No\n";
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    for(int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
    }
    int ans = Integer.MAX_VALUE;
    for(int k = -100; k <= 100; k++) {
      int sum = 0;
      for(int i = 0; i < N; i++) {
        sum += (a[i] - k) * (a[i] - k);
      }
      ans = Math.min(ans, sum);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans;
ll n,m,q;
void solve()
{
    cin>>n;ll ar[n];
    for(int i=0;i<n;i++)
        cin>>ar[i];
    for(int i=1;i<n;i++)
    {
        if(ar[i]>ar[i-1])
            ar[i]--;
        else  if(ar[i]-ar[i-1]<0)
            {cout<<"No";return;}
    }
    cout<<"Yes"<<endl;
}   

int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
   // int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}


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 = sc.nextInt();
		int B = sc.nextInt();
		String ans = "";

		if (A == B) {
			ans ="Draw";
		} else if (A == 1) {
			ans = "Alice";
		} else if (B == 1) {
			ans = "Bob";
		} else if(A < B) {
			ans = "Bob";
		} else if (B < A) {
			ans = "Alice";
		}
		System.out.println( ans );
	}
}

Measured memory_bytes: 21844
import math
import itertools

N = int(input())

xys = []
for _ in range(N):
	x,y = map(float,input().split())
	xys.append((x,y))
	
#print(xys)

#print(math.factorial(N))

ps = [i for i in range(N)]

ds = 0
for arr in itertools.permutations(ps):
	#print(arr)
	for j in range(N-1):
		p1 = arr[j]
		p2 = arr[j+1]
		#print(p1,p2)
		d = ((xys[p2][0]-xys[p1][0])**2+(xys[p2][1]-xys[p1][1])**2)**(1/2)
		ds += d
		#print("*",d,ds)
		
print(ds/math.factorial(N))

Measured memory_bytes: 40684
I=lambda:map(int,input().split());F=1e21;r=range;n,m=I();f=[-F,F];X=[0]+f;Y=X[:];R=[(f,F),(f,-F)];H=[(F,f),(-F,f)]
for i in r(n):*a,c=I();R+=[(a,c)];Y+=c,;X+=a
for i in r(m):a,*b=I();H+=[(a,b)];X+=a,;Y+=b
def g(X):s=dict(enumerate(sorted(set(X))));return{s[i]:i for i in s},s,len(s)+1
h,s,K=g(X);w,t,L=g(Y);j=lambda:[[0]*-~K for i in r(L+1)];V=j();U=j();v=j()
for(a,b),c in R:U[w[c]][h[a]]+=1;U[w[c]][h[b]]+=-1
for d,(e,f)in H:V[w[e]][h[d]]+=1;V[w[f]][h[d]]+=-1
for i in r(L):
 for j in r(K):U[i][j+1]+=U[i][j];V[i+1][j]+=V[i][j]
q=[(h[0],w[0])];v[w[0]][h[0]]=1;a=0
while q:
 x,y=q.pop();a+=(s[x]-s[x+1])*(t[y]-t[y+1])
 for e,f in[(-1,0),(1,0),(0,1),(0,-1)]:
  c=x+e;d=y+f
  if(K>c>=0<=d<L)*v[d][c]==0and(U[(f>0)+y][x]|e==0)|(V[y][(e>0)+x]|f==0):q+=[(c,d)];v[d][c]=1
print([a,'INF'][a>F])

Measured memory_bytes: 551556
#pragma region
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
#pragma endregion

void solve() {
  string s;
  cin >> s;
  int n = s.size();
  int k;
  cin >> k;
  {
    bool f = true;
    char p = s[0];
    reps(i, n - 1) if (p != s[i]) f = false;
    if (f) {
      cout << ((i64) n * k / 2) << endl;
      return;
    }
  }
  i64 ans = 0;
  {
    int cnt = 0;
    int cntl = 0;
    int cntr = 0;
    int l = 0, r = n;
    if (s[0] == s.back()) {
      char p = s[0];
      rep(i, n) {
        if (s[i] == p) cnt++, cntl++;
        else {
          l = i;
          break;
        }
      }
      rrep(i, n) {
        if (s[i] == p) cnt++, cntr++;
        else {
          r = i + 1;
          break;
        }
      }
    }
    ans += (i64) cnt / 2 * (k - 1);
    ans += cntl / 2;
    ans += cntr / 2;
    int cnt2 = 1;
    char p = s[l];
    repi(i, l + 1, r) {
      if (s[i] == p) cnt2++;
      else {
        p = s[i];
        ans += (i64) cnt2 / 2 * k;
        cnt2 = 1;
      }
    }
    ans += (i64) cnt2 / 2 * k;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll a[3];
  rep(i,3) R a[i];
  sort(a,a+3);
  pr(a[0]+a[1]);
}

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, p, ans = 0; cin >> n;
	int a[30] = { 0 };
	for (int i = 0; i < n; i++) {
		cin >> p; a[i] = p;
	}
	for (int i = 0; i < n - 2; i++) {
		if (a[i] < a[i + 1] && a[i + 1] < a[i + 2]) {
			ans++;
		}
		else if (a[i] > a[i + 1] && a[i + 1] > a[i + 2]) {
			ans++;
		}
	}
	cout << ans << endl;
	cin >> n;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  int n, k;
  cin >> n >> k;
  vi a;
  REP(i, n) { a.PB(read()); }
  int min = *min_element(ALL(a)), tmp, g = 1;
  while (n > (tmp = (k * g) - g + 1)) {
    g++;
  }
  print(g);
}


Measured memory_bytes: 1400
#include <stdio.h>
#include <queue>
#include <set>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;
#define N (2001)
set<int> s;
int f[N];
int main(){
	int n, k, Q, ans=1e9;
	scanf("%d %d %d", &n, &k, &Q);
	for(int i=1; i<=n; i++){
		scanf("%d", &f[i]);
		s.insert(f[i]);
	}
	s.insert(0);
	for(auto it=s.begin(); it!=s.end(); it++){
		int val = *it;
		priority_queue<int, vector<int>, greater<int> > q, tmp_q;
		for(int i=1; i<=n+1; i++){
			if(f[i] > val && i != n+1)tmp_q.push(f[i]);
			else{
				int how = tmp_q.size() - k + 1;
				for(int j=0; j<how; j++){
					q.push(tmp_q.top());
					tmp_q.pop();
				}
				while(tmp_q.size())tmp_q.pop();
			}
		}
		if(q.size() < Q)break;
		int mini = q.top(), maxi=0, iter=Q;
		while(q.size() && iter--){maxi=q.top();q.pop();}
		ans = min(ans, maxi-mini);
	}
	printf("%d\n", ans);
	return 0;
}

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

int main() {
  int n, m;
  cin>>n>>m;
  long long x[n], y[n], z[n];
  for (int i=0; i<n; i++) {
    cin>>x[i]>>y[i]>>z[i];
  }
  long long ans = 0;
  for (int i=0; i<8; i++) {
    long long a[n];
    int op_x = i & 1? 1 : -1;
    int op_y = i & 2? 1 : -1;
    int op_z = i & 4? 1 : -1;

    for (int j=0; j<n; j++) {
      a[j] = x[j] * op_x + y[j] * op_y + z[j] * op_z;
    }
    sort(a, a + n);
    reverse(a, a + n);
    long long v = 0;
    for (int j=0; j<m; j++) {
      v += a[j];
    }
    ans = max(v, ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define int ll
#define all int i=0; i<n; i++
#define pb push_back
#define pf push_front
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int> >
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define mod 1000000007
#define mp make_pair
#define pii pair<int,int>
#define T int t;cin>>t;while(t--)
#define I 
#define	rep(i,k,n) for(int i=k; i<n; i++)
#define think 
#define we 
#define should 

bool sortinrev(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{ 
       return (a.first > b.first); 
}	
int perm[10];
vector<pii>v; 
int n;
long double dist(){
	long double k = 0;
	for(int i=0; i<n-1; i++){
		k+=sqrt( double(pow((v[perm[i]].first - v[perm[i+1]].first), 2) )+ double(pow((v[perm[i]].second - v[perm[i+1]].second), 2)) );
	}
	return k;
}
int fact(int n){
	for(int i=n-1; i>=1; i--)n*=i;
	return n;
}
int32_t main() 
{ 
	cin>>n;
	for(all)perm[i] = i;
	for(all){
		int a,b;
		cin>>a>>b;
		v.pb({a,b});
	}
	long double ans = 0;
	do{
		ans += dist();
	}while(next_permutation(perm, perm+n));
	cout<<setprecision(11)<<(ans/fact(n) * 1.00)<<endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll A; string B;

int main(){
  cin >> A >> B;

  ll newB = 0;
  for (int i = 0; i < 4; i++){
    if (B[i] == '.') continue;
    newB *= 10;
    newB += B[i] - '0';
  }

  ll ans = A * newB;
  ans /= 100;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
def main():
    n = int(input())
    abc = [[0, 0, 0] for _ in range(n + 1)]
    for i in range(1, n + 1):
        abc[i] = list(map(int, input().split()))
    dp = [[0, 0, 0] for _ in range(n + 1)]
    dp[1] = abc[1]

    for i in range(1, n + 1):
        for j in range(3):
            for k in range(3):
                if j == k:
                    continue
                dp[i][j] = max(dp[i][j], dp[i - 1][k] + abc[i][j])

    print(max(dp[-1]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 110584
using System;
using System.Linq;

class prog{
  static void Main(){
    
    int N = int.Parse(Console.ReadLine());
    string[] input = Console.ReadLine().Split().ToArray();
    int[] a = new int[N];
    
    for(int i = 0; i < N; i++){
      a[i] = int.Parse(input[i]);
    }
    
    for(int i = 0; i < N; i++){
      for(int j = i + 1; j < N; j++){
        if(a[i] < a[j]){
          int tmp = a[i];
          a[i] = a[j];
          a[j] = tmp;
        }
      }
    }
    
    int alice = 0, bob = 0;
    if(N % 2 == 0){
      for(int i = 0; i <= N - 2; i += 2){
        alice += a[i];
      }
      for(int i = 1; i <= N - 1; i += 2){
        bob += a[i];
      }
    }else{
      for(int i = 0; i <= N - 1; i += 2){
        alice += a[i];
      }
      for(int i = 1; i <= N - 2; i += 2){
        bob += a[i];
      }
    }
    Console.WriteLine(alice - bob);
      
  }
}

Measured memory_bytes: 13268
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[]) {
	string s;
	cin>>s;
	int n=s.length()-1;
	int m=(n-1)/2;
	int l=0,r=n,flag=1;
	while(l<r){
		if(s[l]==s[r]){l++; r--;}
		else {flag=0; break;}
	}
	if(!flag){cout<<"No"<<endl; return 0;}
	l=0;
	while (l<m) {
		if(s[l]==s[m]){l++; m--;}
		else {flag=0; break;}
	}
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

int main() {
  int T, J, S, Y, H;
  cin >> T >> J >> S >> Y >> H;

  if(T<40){
  T = 40;
  }
  if(J<40){
  J = 40;
  }
  if(S<40){
  S = 40;
  }
  if(Y<40){
  Y = 40;
  }
  if(H<40){
  H = 40;
  }

 cout << (T + J + S + Y + H)/5 << endl;

return 0;
}


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

int main(){
    int K;
    cin>>K;
    int count=0;
    for(int i=1;i<K;i++){
        for(int j=i+1;j<=K;j++){
            if((i+j)%2) count++;
        }
    }
    cout<<count<<endl;
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main(){
	int n;
	cin >> n;
	ll ans=1;
	ll gcd;
	ll t;
	FOR(i,n){
		cin >> t;
		gcd=__gcd(t,ans);
		ans=t*  (ans /gcd);
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem (B) in C++
// MAIN IDEA   : brute force on length + divisors
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define rw freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 2e6 + 5, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
vl v;
int main() {
#ifdef ONLINE_JUDGE
    FAST
#endif
	int n;
	cin >> n;
	lp(i,1,n)
	{
		int x;
		cin >> x;
		v.pb(x - i);
	}
	sort(all(v));
	/*
	 int mn = INT_MAX, idx;
	 lp(i,v[0],v.back())
	 {
	 int sum = 0;
	 for (auto u : v)
	 sum += abs(i - u);
	 if (mn >= sum) {
	 mn = sum;
	 idx = i;
	 }
	 }
	 cout << idx << "\n";
	 */
	ll tar = v[v.size() / 2], sum = 0;
	for (auto u : v)
		sum += abs(u - tar);
	f(sum);
	return 0;
}


Measured memory_bytes: 2420
#include <stdio.h>

int main(void)
{
	int a,b,c,x;
	int count=0;
	int i,j;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &x);
	x=x/50;
	for(i=0;i<=a;i++){
		for(j=0;j<=b;j++){
			if(x-10*i-2*j>=0&&x-10*i-2*j<=c){
				count++;
			}
		}
	}
	printf("%d",count);
		
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<math.h>
#include<utility>
#include<climits>

using namespace std;

int main(){
	int n,temp,k;
	cin>>n>>k;
	vector<int> cost;
	for(int i=0;i<n;i++){
		cin>>temp;
		cost.push_back(temp);
	}
	vector<int> dp(n,0);
	dp[0]=0;
	dp[1]=abs(cost[1]-cost[0]);
	for(int i=2;i<n;i++){
		int temp = INT_MAX;
		for(int j=1;j<=k;j++){
			if(i-j>=0)
				temp = min(temp, dp[i-j]+abs(cost[i]-cost[i-j]));
		}
		dp[i] = temp;
	}
	cout<<dp[n-1];
}

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

#define int long long int 

const int maxN=1e18;
int32_t main()
{
    int n;
    cin>>n;
    int m=1,flag=0;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x==0 || m==0)
         m=0;
        else if(flag || maxN/m<x)
        flag=1;
        else
        m*=x;
    }
    if(flag && m!=0)
    cout<<-1<<endl;
    else
    cout<<m<<endl;
}

Measured memory_bytes: 3636
a = 0
b = 0

while line = gets
  line = line.chomp.split(" ").map {|num| num.to_i}

  # game start
  if a == 0 && b == 0 && line.length < 2
    next
  end

  # game end
  if line.length < 2
    print a, " ", b, "\n"
    a = 0
    b = 0
    next
  end

  if line[0] > line[1]
    a += line[0] + line[1]
  elsif line[0] < line[1]
    b += line[0] + line[1]
  else
    a += line[0]
    b += line[1]
  end
end

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

int main()
{
    int a,b,c,x,l;
    int cnt = 0;
    cin >> a >> b >> c >> x;
    for(int i = 0; i <= a; i++)
    {
        for(int j = 0; j <= b; j++)
        {
            for(int k = 0; k <= c; k++)
            {
                l = 500*i + 100*j + 50*k;
                if(x == l) cnt++;
                else if(l > x) break;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import bisect
import sys,io
import math
from collections import deque
from heapq import heappush, heappop

input = sys.stdin.buffer.readline

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7
#DIV = 998244353

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    R,C,K = isRaw()
    mas = [[0 for _ in range(C)]for _ in range(R)]
    for k in range(K):
        r,c,v = isRaw()
        mas[r-1][c-1]=v
    dp = [[[0 for _ in range(C)] for _ in range(R)] for _ in range(3)]

    dp0 = dp[0]
    dp1 = dp[1]
    dp2 = dp[2]

    dp0[0][0]=mas[0][0]
    dp1[0][0]=mas[0][0]
    dp2[0][0]=mas[0][0]

    for r in range(R):
        for c in range(C):
            mrc = mas[r][c]
            
            dp0[r][c] = mrc
            dp1[r][c] = mrc
            dp2[r][c] = mrc

            if r>0:
                dp0[r][c] = max(dp0[r][c], dp2[r-1][c]+mrc)
                dp1[r][c] = max(dp1[r][c], dp2[r-1][c]+mrc)
                dp2[r][c] = max(dp2[r][c], dp2[r-1][c]+mrc)
            if c>0:
                dp0[r][c] = max(dp0[r][c], dp0[r][c-1], mrc)
                dp1[r][c] = max(dp1[r][c], dp1[r][c-1], dp0[r][c-1]+mrc)
                dp2[r][c] = max(dp2[r][c], dp2[r][c-1], dp1[r][c-1]+mrc)

    print(max([dp[ni][-1][-1] for ni in range(3)]))

main()


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

int main(){
    int count = 0;
    string s1;
    string s2;
    cin >>s1;
    cin >>s2;
    rep(i,3){
        if(s1[i]==s2[i]){
            count ++;
        }
    }
    cout << count << endl;
}   

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

using namespace std;

typedef long long ll;
const ll INF = -4e18;
ll n, m;
ll a[1005][1005];


int main()
{
    scanf("%d%d", &n, &m);
    for(ll i = 1; i <= n; i++)
    {
        for(ll j = 1; j <= n; j++)
        {
            a[i][j] = INF;
        }
        a[i][i] = 0;
    }
    for(ll i = 1; i <= m; i++)
    {
        ll u, v, w;
        scanf("%lld%lld%lld", &u, &v, &w);
        a[u][v] = w;
    }
    for(ll k = 1; k <= n; k++)
    {
        for(ll i = 1; i <= n; i++)
        {
            if(a[i][k] == INF)continue;
            for(ll j = 1; j <= n; j++)
            {
                if(a[i][k] + a[k][j] > a[i][j] ) a[i][j] = a[i][k] + a[k][j];
            }
        }
    }
//    for(ll i = 1; i <= n; i++)
//    {
//        if(a[i][i] > 0 && a[1][i] > INF)
//        {
//            printf("inf");
//            return 0;
//        }
//    }
    if(a[1][1] > 0)
    {
        printf("inf");
        return 0;
    }
    printf("%lld", a[1][n]);
    return 0;
}


Measured memory_bytes: 8064
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

minv = 1000000
for i, x in enumerate(H):
    tmp = T - x * 0.006
    if minv > abs(A-tmp):
        minv = abs(A-tmp)
        ans = i+1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  ll h,w;
  cin>>h>>w;
  if(h==1) cout<<1<<endl;
  else if(w==1) cout<<1<<endl;
  else cout<<(h*w+1)/2<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    double xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2;

    while (scanf("%lf", &xa1)!=EOF){
        scanf("%lf %lf %lf", &ya1, &xa2, &ya2);
        scanf("%lf %lf %lf %lf",&xb1, &yb1, &xb2, &yb2);
        if (xa1 > xb2){
            printf("NO\n"); continue;
        }
        if (xa2 < xb1){
            printf("NO\n"); continue;
        }
        if (ya1 > yb2){
            printf("NO\n"); continue;
        }
        if (ya2 < yb1){
            printf("NO\n"); continue;
        }
        printf("YES\n");
    }

    return 0;
}

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

int main(){
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  int ans = 0;
  rep(is, 1<<h) rep(js, 1<<w){
    int cnt = 0;
    rep(i,h) rep(j,w){
      if(is>>i&1) continue;
      if(js>>j&1) continue;
      if(s[i][j] == '#') cnt++;
    }
    if(cnt == k) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

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

func main() {
	n, _ := strconv.Atoi(input())
	m, _ := strconv.Atoi(input())
	x := make([]int, m)
	for i := 0; i < m; i++ {
		x[i], _ = strconv.Atoi(input())
	}

	ans := 0
	if n < m {
		sort.Sort(sort.IntSlice(x))
		diffList := make([]int, m-1)
		for i := 0; i < m-1; i++ {
			diffList[i] = x[i+1] - x[i]
		}
		sort.Sort(sort.Reverse(sort.IntSlice(diffList)))
		ans = x[m-1] - x[0]
		for i := 0; i < n-1; i++ {
			ans -= diffList[i]
		}
	}
	fmt.Println(ans)
}


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

int main(){
  long long n,m,ans=0;cin>>n>>m;
  vector<pair<long long,long long>> p(n);
  REP(i,n){
    long long a,b;cin>>a>>b;
    p.at(i)=make_pair(a,b);    
  }
  sort(p.begin(),p.end());
  REP(i,n){
    if(m-(p.at(i).second)>0){
      m-=p.at(i).second;
      ans+=(p.at(i).second)*(p.at(i).first);
    }else{
      ans+=m*(p.at(i).first);
      break;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int q=sc.nextInt();
		String s = sc.next();
		int cnt[] = new int[n];

		for(int i=1; i<n; i++) {
			if(s.substring(i-1, i+1).equals("AC")){
				cnt[i]=cnt[i-1]+1;
			}else {
				cnt[i]=cnt[i-1];
			}
		}

		for(int i=0; i<q; i++) {
			int l=sc.nextInt();
			l--;
			int r=sc.nextInt();
			r--;
			System.out.println(cnt[r]-cnt[l]);
		}
		sc.close();
	}

}


Measured memory_bytes: 68020
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll x; cin >> x;

    ll balance = 100;
    ll year = 0;

    while(balance < x){
        balance *= 1.01;
        year++;
    }

    cout << year << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
pii arr[100005];
int main(){
    int n, k; cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> arr[i].first >> arr[i].second;
    }
    ll ans = 0;
    for(int i = 0; i < 32; i++){
        int bit= ( 1 << i);
        int kcop = k;
        if(k & bit){
            kcop^=bit;
            for(int e = i-1; e >= 0; e--){
                kcop|=(1<<e);
            }
        }
        ll local = 0;
        for(int e = 0; e < n; e++){
            int tcop = arr[e].first;
            bool ok = true;
            for(int z = 1; z<=32; z++){
                if(tcop&(1<<z) && !(kcop&(1<<z))){
                    ok = false;
                    break;
                }
            }
            if(ok)
                local+=arr[e].second;
        }
        ans= max(ans,local);

    }
    cout << ans;




    return 0;
}


Measured memory_bytes: 1152
//Code By CXY07
#include<bits/stdc++.h>
using namespace std;

//#define FILE
#define int long long
//#define LL long long
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fst first
#define scd second
#define inv(x) ksm((x),mod - 2)
#define lowbit(x) ((x) & (-(x)))

const int MAXN = 1;
const int INF = 2e9;
const double PI = acos(-1);
const double eps = 1e-6;
const int mod = 1e9 + 7;
//const int mod = 998244353;
//const int G = 3;

int n,ans;

template<typename T> inline void read(T &a) {
	a = 0; char c = getchar(); int f = 1;
	while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9') {a = a * 10 + (c ^ 48); c = getchar();}
	a *= f;
}

int qpow(int x,int n) {
	int res = 1;
	for(int i = 1;i <= n; ++i)
		(res *= x) %= mod;
	return res;
}

signed main () {
#ifdef FILE
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	read(n);
	ans = (((qpow(10,n) - qpow(9,n)) % mod - qpow(9,n)) % mod + qpow(8,n)) % mod;
	ans = (ans % mod + mod) % mod;
	printf("%lld\n",ans);
	return 0;
}



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

const int N = 2e5 + 10;
int neg, t[N], cnt[N], ans, a[N], n, m;

void add(int i){
	if(i - t[i] <= 0){
		t[i]++;
		return;
	}
	
	cnt[i - t[i]]++;
	if(cnt[i - t[i]] == 1)
		ans--;
	t[i]++;
}
void del(int i){
	//t[i]--;
	
	if(i - t[i] <= 0)
		return;
	
	cnt[i - t[i]]--;
	if(!cnt[i - t[i]])
		ans++;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> n >> m;
	ans = n;
	
	for (int i = 0; i < n; i++){
		cin >> a[i];
		add(a[i]);
	}
	
	for (int i = 0; i < m; i++){
		int ind, x;
		cin >> ind >> x;
		ind--;
		
		t[a[ind]]--;
		del(a[ind]);
		a[ind] = x;
		add(a[ind]);
		
		cout << ans << '\n';
	}
}

Measured memory_bytes: 3840
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<stack>
#include<queue>
#include<map>
#include<cstring>
#include<functional>

using namespace std;

int main()
{
	//freopen("input.txt", "r", stdin);

	int a;

	scanf("%d", &a);

	printf("%d\n", a + a*a+ a*a*a);

	return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};

int main() {
  int n, m;

  cin >> n >> m;
  string a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  string b[m];
  for (int i = 0; i < m; i++)
    cin >> b[i];

  for (int i = 0; i <= n - m + 1; i++) {
    for (int j = 0; j <= n - m + 1; j++) {
      bool can = true;
      for (int y = 0; y < m; y++) {
        for (int x = 0; x < m; x++) {
          if (a[i + y][j + x] != b[y][x])
            can = false;
        }
      }

      if (can) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


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

int main()
{

    int x, y;
    cin >> x >> y;
    int asi = x * 2;
    if (asi == y)
    {
        cout << "Yes" << endl;
        return 0;
    }
    for (int i = 0; i < x; ++i)
    {
        asi += 2;
        if (asi == y)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3636
var i,n,c,kq:longint;
begin
        readln(n);
        c:=1;
        for n:=n-1 downto 0 do begin
                read(i);
                if i=c then inc(c) else inc(kq);
        end;
        if c=1 then writeln(-1) else writeln(kq);
end.


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
	int l[10], v[2], d[10], i, r;
	double L;
	char c;
	while (cin >> l[0] >> c >> l[1] >> c >> l[2] >> c >> l[3] >> c >> l[4] >> c >> l[5] >> c >> l[6] >> c >> l[7] >> c >> l[8] >> c >> l[9] >> c >> v[0] >> c >> v[1])
	{
		for (i = 1, d[0] = l[0]; i < 10; i++)
			d[i] = d[i-1] + l[i];
		L = ((double)d[9]*(-(double)v[0])) / (-(double)v[0]-(double)v[1]);
		     if (0.0 <= L && L <= d[0])	r = 1;
		else if (d[0] < L && L <= d[1])	r = 2;
		else if (d[1] < L && L <= d[2])	r = 3;
		else if (d[2] < L && L <= d[3])	r = 4;
		else if (d[3] < L && L <= d[4])	r = 5;
		else if (d[4] < L && L <= d[5])	r = 6;
		else if (d[5] < L && L <= d[6])	r = 7;
		else if (d[6] < L && L <= d[7])	r = 8;
		else if (d[7] < L && L <= d[8])	r = 9;
		else if (d[8] < L && L <= d[9])	r = 10;
		cout << r << endl;
	}
}

Measured memory_bytes: 0