akhauriyash/Code-Regression huggingface dataset:
int large(int a, int b, int c)
{
int x[5];
    x[0]=a;
    x[1]=b;
    x[2]=c;
    int max=x[0];
    for(int i=1;i<3;i++){
        if(max<x[i]) max=x[i];
    }
    return max;
}
#include<stdio.h>
int main()
{
    int a,b,sum,sub,mul;
    scanf("%d %d",&a,&b);
    sum=a+b;
    sub=a-b;
    mul=a*b;
    int l=large(sum,sub,mul);
    printf("%d\n",l);
}


Measured memory_bytes: 128
// #includes {{{
#ifdef MY_DEBUG
#include "header/header.hpp"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

template<class T>
constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity():(numeric_limits<T>::max()/2);

int __inf_ignore(){
	int t = inf<int>;
	return t;
}

typedef pair<int,int> pii;

#ifdef MY_DEBUG
#include"print.hpp"
#include"debug.hpp"
#endif
// }}}

const string YES = "Yes";
const string NO = "No";
Int N;

void solve(){
	if(__builtin_popcount(N)==1){
		cout<<NO<<endl;
		return;
	}
	cout<<YES<<endl;
	
	//node: b(center), N+b
	bool start = true;
	unordered_set<int> listed;
	vector<pii> ans;
	if(N%2==0){
		int b = 1;
		while((N&(b))==0)b<<=1;
		assert((N&b)!=0);

		listed.insert(N);
		listed.insert(b);
		listed.insert(b^1);
		listed.insert(N^b);
		listed.insert(N^b^1);
		
		ans.push_back({(N^b^1),1});
		ans.push_back({1,b^1});
		ans.push_back({b,1});
		ans.push_back({b,(b^1)+N});
		ans.push_back({b,N});
		ans.push_back({(N^b^1)+N,N});
		ans.push_back({(N^b^1)+N,N+1});
		start = false;
		ans.push_back({N,N^b});
		ans.push_back({N^b,b+N});
		ans.push_back({b+N,N+N});
		ans.push_back({N+N,(N^b)+N});
	}
	for(int i = 2;i <= N;i++){
		int j = (i^1);
		if(i>j)continue;
		if(N%2==0){
			if(i==N)continue;
			if(listed.find(i)!=listed.end() or listed.find(j)!=listed.end())continue;
		}
		//i < j
		ans.push_back({i,1});
		ans.push_back({j,1});
		ans.push_back({i,N+j});
		ans.push_back({j,N+i});
		if(start){
			ans.push_back({N+i,N+1});
			start = false;
		}
	}
	assert(ans.size()==2*N-1);
	for(auto &&e:ans){
		assert(e.first<=2*N and e.second<=2*N);
		cout<<e.first<<" "<<e.second<<endl;
	}
}
//{{{ main fucnction
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> N;
	solve();
	return 0;
}
//}}}

Measured memory_bytes: 3952
import sys
N, Y = map(int,input().split())

for x in range(N+1):
	for y in range(N+1-x):
		z = (Y - 10000*x - 5000*y) // 1000
		if z == N-x-y:
			print(x,y,z,sep = " ")
			sys.exit()

print("-1 -1 -1")

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

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

void Main(){
    int N,K; cin >> N >> K;
    VI a(N); REP(i,N) cin >> a[i];
    VI n(N+1,0);

    int ans=INF, type=0, l=0;
    REP(r,N){
        n[a[r]]++;
        if(a[r]<=K && n[a[r]]==1) type++;

        while(l<r && (n[a[l]]>1 || a[l]>K)){
            n[a[l]]--;
            l++;
        }

        if(K<=type) chmin(ans,r-l+1);
    }
    
    cout << (ans<INF ? ans : 0) << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


Measured memory_bytes: 3620
use proconio::*;

fn main() {
    input!{
        n: usize,
        a: [usize; n],
    }

    let mut ans = 0;
    for i in 0..n {
        if i % 2 == 0 && a[i] % 2 == 1 {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2172
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//for(int i = ; i < ; i++){}

int main(){
  string s;
  cin>>s;
  bool v = false;
  for(int i = 0; i<s.length()-1; i++){
    if(s[i]==s[i+1]){
      v = true;
    }
  }
  if(v)cout<<"Bad"<<endl;
  else cout<<"Good"<<endl;
  return 0;
}




Measured memory_bytes: 256
#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 i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; 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) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(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; }

void solve() {
  i64 a, b, c;
  cin >> a >> b >> c;
  if (c - a - b >= 0 && a * b * 4 < (c - a - b) * (c - a - b)) {
    yes();
  } else {
    no();
  }
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;

    int a;
    int sum = 0;
    rep(0, m) {
        cin >> a;
        sum += a;
    }

    if (sum <= n) {
        cout << (n - sum);
    } else {
        cout << -1;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3592
N = int(input())
p = list(map(int, input().split()))

num = 0
for i, pi in enumerate(p):
    need = 1 <= i <= len(p) - 1 - 1
    if not need: continue
    
    left = p[i - 1]
    center = p[i]
    right = p[i + 1]

    if (left < center < right) or (right < center < left):
        num += 1

print(num)


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  string S;
  cin >> S;

  string r(S.size(), 'x');
  cout << r;
}
#endif


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cctype>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	int b = min(n, m);
	int a = max(n, m);
	int ans = 0;
	for (int i = 1, j = 0; j < a; i *= 10, j++) {
		ans += i * b;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int n, count = 0;
  while (cin >> n) {
    for (int a = 0; a <= 9; a++)
      for (int b = 0; b <= 9; b++)
        for (int c = 0; c <= 9; c++)
          for (int d = 0; d <= 9; d++)
            if (a+b+c+d == n)
              count++;
    cout << count << endl;
    count = 0;
  }
}

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

using namespace std;

#define ll long long

const int mod  = 1e9 + 7;
const ll INF = 1e14;

void solve(){

    int x, n; cin >> x >> n;
    unordered_set<int> set;
    while(n--){
        int num; cin >> num;
        set.insert(num);
    }
    int pos = 0;
    while(true){
        if(set.find(x-pos) == set.end()){
            cout << x-pos;
            return;
        }
        if(set.find(x+pos) == set.end()){
            cout << x+pos;
            return;
        }
        ++pos;
    }

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    solve();

	return 0;
}



Measured memory_bytes: 3528
#include <stdio.h>

int main(void){
	int a, b, c, x;
	int i, j, k, count = 0;

	scanf("%d%d%d%d", &a, &b, &c, &x);
	
	for (i = 0; i <= a; i++){
		for (j = 0; j <= b; j++){
			for (k = 0; k <= c; k++){
				int res = 500 * i + 100 * j + 50 * k;
				if (res == x) count++;
			}
		}
	}
	printf("%d\n", count);
}

/*
int main(void){
	int n, i, j, a[110], b[110], c[110],d[110];
	int count = 0;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%d%d", &a[i], &b[i]);
	}
	for (i = 0; i < n; i++){
		scanf("%d%d", &c[i], &d[i]);
	}
	
	for (i = 0; i < n;i++){
		for (j = i; j < n; j++){
			if (a[i] < c[j] && b[i] < d[j]){
				count++;
				break;
			}
		}
	}
	printf("%d\n", count);
	return 0;
}*/



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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

typedef long long ll;
typedef pair<int, int> ii;

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

	for(ll i = 0; i < 10; i++){
		ll x = b * 10 + i;
		if(ll(x * 0.08) == a){
			cout << x << endl;
			return 0;
		}
	}

	cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 384
N,M=gets.split.map(&:to_i)
a=gets.split.map(&:to_i).sort
BC=M.times.map{gets.split.map(&:to_i)}.sort_by{|a|-a[1]}

ans = 0
BC.each do |b,c|
    t = a.bsearch_index{|x| x>c} || a.size
    t = b if t > b
    #t = a[0, b].index {|x| x >= c } || [b, a.size].min

    break if t == 0
    ans += c*t
    a.shift(t)
end

puts ans + (a.inject(:+) || 0)


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 1000000007;

struct FiniteField {
 private:
  int64 x;
  static inline int64 Normalize(int64 x) {
    if (0 <= x && x < P) return x; x %= P; if (x < 0) x += P; return x;
  }
 public:
  FiniteField(int64 x) : x(Normalize(x)) {}
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

ostream& operator<<(ostream& s, const FiniteField& v) { s << v.Value(); return s; }

FiniteField Power(FiniteField x, int p) {
  if (p < 0) return FiniteField(1) / Power(x, -p);
  FiniteField value = 1;
  while (p) {
    if (p % 2) value *= x;
    x *= x;
    p /= 2;
  }
  return value;
}

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

  int n, a, b;
  cin >> n >> a >> b;

  FiniteField ans = Power(2, n);
  ans -= 1;

  auto c_fn = [&](int k) -> FiniteField {
    FiniteField r = 1;
    for (int i = 0; i < k; i++) {
      r *= (n - i);
    }
    for (int i = 0; i < k ;i++) {
      r /= (i + 1);
    }
    return r;
  };

  ans -= c_fn(a);
  ans -= c_fn(b);
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Scanner;

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

	void run() {
		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 c0 = 0, c1 = 0, c2 = 0;
		for (int i = 0; i < N; ++i) {
			int c = 0;
			while (a[i] % 2 == 0) {
				a[i] /= 2;
				++c;
			}
			c = Math.min(2, c);
			if (c == 0)
				++c0;
			else if (c == 1)
				++c1;
			else if (c == 2)
				++c2;
		}
		long[] ret = new long[N];
		for (int i = 0; i < N; ++i) {
			if (i == 0) {
				if (c0 > 0) {
					ret[0] = 0;
					--c0;
				} else if (c1 > 0) {
					ret[0] = 1;
					--c1;
				} else if (c2 > 0) {
					ret[0] = 2;
					--c2;
				}
				continue;
			} else {
				if (ret[i - 1] == 0) {
					if (c2 == 0) {
						System.out.println("No");
						return;
					} else {
						ret[i] = 2;
						--c2;
					}
				} else if (ret[i - 1] == 1) {
					if (c1 > 0) {
						ret[i] = 1;
						--c1;
					} else if (c2 > 0) {
						ret[i] = 2;
						--c2;
					} else {
						System.out.println("No");
						return;
					}
				} else if (ret[i - 1] == 2) {
					if (c0 > 0) {
						ret[i] = 0;
						--c0;
					} else if (c1 > 0) {
						ret[i] = 1;
						--c1;
					} else if (c2 > 0) {
						ret[i] = 2;
						--c2;
					} else {
						System.out.println("No");
						return;
					}
				}
			}
		}
		System.out.println("Yes");
	}
}

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

int N, K;

int main() {
	cin >> K;
	N = (K+3) >> 2 << 1;
	if(1 == K) N = 1;
	printf("%d\n", N);
	for(int i = 0; i < N; i++) {
		for(int j = 0, c; j < N; j++) {
			c = (i+j) % N;
			if(i&1) c += N;
			if(K <= c) c -= N;
			printf("%d ", c+1);
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 1152
using System;
 
class Program
{      
  static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);
            int count = 0;

            if(a + b < c)
            {
                count += a + b + 1;
            }
            else
            {
                count += c;
            }

            count += b;

            Console.WriteLine(count);
        }
}

Measured memory_bytes: 13140
#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;

int main() {
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	int a = 0, b = 0;
	rep(i, 2 * n) {
		if (i % 2 == 0) {
			cout << s[a];
			a++;
		}
		else {
			cout << t[b];
			b++;
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import deque
import sys 
input = sys.stdin.readline
N, D, A = map(int, input().split())
xh = [list(map(int, input().split())) for _ in range(N)]
xh = sorted(xh)
total = 0 # 今与えているダメージの総和
D = 2*D
ans = 0
q = deque()
for i in range(N):
  x, h = xh[i]
  # 今いる場所が前回までの爆撃の範囲外になるならその分totalから引く
  while len(q) >= 1 and q[0][0] < x:
    total -= q.popleft()[1]
  h -= total

  if h > 0:
    num = (h-1)//A+1
    ans += num
    damage = num*A
    total += damage
    q += ([[x+D, damage]])

print(ans)


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i = 0;i < n;i ++){
        ll a;
        cin >> a;
        if(a%2){cout<<"first"<<endl;return 0;}
    }
    cout << "second" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  ll ans=b-a;
  for(ll i=0;i<n;i++){
    ll l1=c*i,r1=d*i;
    ll l2=c*(n-i-1)+ans,r2=d*(n-i-1)+ans;
    if(l1<=r2&&l2<=r1){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
  return 0;
}


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

ans = 1
max_num = 0

for i in range(1, N+1):
    i_org = i
    tmp = 0
    while i % 2 == 0:
        tmp += 1
        i /= 2
    if max_num < tmp:
        ans = i_org
        max_num = tmp

print(ans)


Measured memory_bytes: 2940
fun main() {
    val n: Int = readLine()!!.toInt()
    val list: List<Long> = readLine()!!.split(" ").map { it.toLong() }
    var ans: Long = 1
    if (0 in list) {
        println(0)
        return
    }
    for (i in list) {
        if (i <= 1_000_000_000_000_000_000/ans) {
            ans *= i
        }
        else {
            println(-1)
            return
        }
    }
    println(ans)
}

Measured memory_bytes: 61512
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    LLONG A, B, N; cin >> A >> B >> N;
    LLONG x = min(B - 1, N);
    LLONG t1 = A * x / B;
    LLONG t2 = x / B;
    t2 *= A;
    cout << t1 - t2 << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
//*******************KEEP LEARNING AND STRIVING FOR PERFECTION**********************//
#define vi vector
#define lli long long int
#define vli vi<lli>
#define pb push_back
#define pll pair<lli,lli>
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).begin(),(x).end(),greater<lli>()
#define clear(x) x.clear()
#define rep(i,n) for(lli i=0;i<(lli)n;i++)
#define rep1(i,n) for(lli i=1;i<=(lli)n;i++)
#define rep2(i,n) for(lli i=1;i<(lli)n;i++)
#define refor(i,n) for(lli i=(lli)n;i>=0;i--)
#define range(i,l,r) for(lli i=(lli)l;i<=(lli)r;i++)
#define big(x,y) (x>y)?x:y
#define small(x,y) (x<y)?x:y
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mod 1000000007
using namespace std;
lli gcd(lli a,lli b) {return b==0?a:gcd(b,a%b);}
lli lcm(lli a,lli b) {return (a*b)/gcd(a,b);}
bool isprime(lli x) {for(lli i=2;i<=sqrt(x);i++) { if(x%i == 0) return false;} return true;}
lli modpow(lli x,lli y) {lli res=1;while(y>0){if(y&1) res*=x; y=y>>1; x=x*x;} return res;}
lli ncr(lli n,lli k) {lli res=1; if(k>n-k) k=n-k; rep(i,k){res*=(n-i);res/=(i + 1);} return res;}
lli bintodec(lli n) {lli decimal=0,i=0,rem;while (n!=0){rem = n%10;n/=10;decimal += rem*pow(2,i);++i;}return decimal;}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
   lli g,n,m,x,i,j,count=0,s=0,temp,aa=0,bb=0;
   vli a;
   vli b;
    //cin>>g;
    
     cin>>n>>m>>x;
	  rep(i,n)
       { cin>>aa;
         a.pb(aa);
	   }
	   //i=0;
	 rep(i,m)
	   { cin>>bb;
	     b.pb(bb);
		}
	/*rep(i,n)
	cout<<a[i]<<" ";
	cout<<endl;
	rep(i,m)
	cout<<b[i]<<" ";
	cout<<endl;*/	
	 i=0,j=0;
	 while(i<a.size() && s+a[i]<=x)
	   { s+=a[i];
	     i++;
	   }
	 count=i;
	 while(j<b.size() && i>=0)
	 { s+=b[j];
	   j++;
	   
	   while(s>x && i>0)
	     { i--;
	       s-=a[i];
		 }
	    
	    if(s<=x && i+j>count)
	       count=i+j;
	 }  
     cout<<count<<'\n';
     /*count=0;
     s=0;
     i=0;
     j=0;
     clear(a);
     clear(b);*/
     
    
    return 0;
}








Measured memory_bytes: 7964
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a, b, c, d;
  cin >> N;
  
  a = N / 1000;
  b = N / 100 - 10*a;
  c = N / 10 - 100*a - 10*b;
  d = N % 10;
  
  if ( b != c) {
    cout << "No" << endl;
  }
  
  else {
    if (a == b){
    cout << "Yes" << endl;
    }
    
    else{
      if (c == d){
    cout << "Yes" << endl;
      }
      else{
        cout << "No" << endl;
      }
    }
    
  }
  
}

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

money = 1000

init = A[0]
maxA = 0
for i in range(1,len(A)):
    if A[i-1] > A[i]:
        if maxA != 0:
            money = ((money // init) * maxA) + (money % init)
            maxA = 0
        init = A[i]
    elif init < A[i]:
        maxA = A[i]

if init < A[-1]:
    money = ((money // init) * maxA) + (money % init)

print(money)


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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(){
    ll n,k;
    cin>>n>>k;
    vvl s(n);
    rep(i,n){
        int t,d;
        cin>>t>>d;
        t--;
        s[t].PB(d);
    }
    rep(i,n){
        sort(all(s[i]));
        reverse(all(s[i]));
        if(s[i].empty())s[i].PB(-1e9);
    }
    sort(s.begin(), s.end(), [&](vector<long long> a, vector<long long> b) { return a[0] > b[0];});
    ll ans=0;
    priority_queue<ll>q;
    rep(i,k){
        ans+=s[i][0];
        for(int j=1;j<s[i].size();++j)q.push(s[i][j]);
    }
    for(int i=k;i<n;++i)rep(j,s[i].size())q.push(s[i][j]);
    ll z=ans;
    ans+=k*k;
    for(ll i=k-1;i>=1;--i){
        ll x=s[i][0],y=q.top();
        if(x<y){
            q.pop();
            q.push(x);
            z+=y-x;
        }
        ans=max(ans,z+i*i);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 11432
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

int main(){
    string s;
    int q;
    cin >> s >> q;

    string right, left;
    bool flg = true;
    for (auto i = 0; i < q; i++) {
        int t, f; char c;
        cin >> t;
        if(t == 2) {
            cin >> f >> c;
            if(f == ((flg) ? 2 : 1)) right.push_back(c);
            else left.push_back(c);
        } else flg = not flg;
        // cout << i << " " << left << " " << s << " " << right << " " << flg << endl;
    }

    if(flg) {
        reverse(left.begin(), left.end());
        s = left + s + right;
    }
    else {
        reverse(s.begin(), s.end());
        reverse(right.begin(), right.end());
        s = right + s + left;
    }

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 1348
# 最大公約数GCD(x,y)
def GCD(x,y):
    x,y=max(x,y),min(x,y)
    if x%y==0:
        return y
    else:
        return GCD(y,x%y)

def divide(g,p):
    if g%p!=0:
        return g
    if g%p==0:
        global n
        n+=1
        while g%p==0:
            g//=p
        return g

A,B=map(int,input().split())
g=GCD(A,B)

n=1 # gの素因数の個数

if g>=2:
    g=divide(g,2)
p=3 # 最初の奇素数
while g>1 and p<1000000:
    g=divide(g,p)
    p+=2
if g>1:
    n+=1
print(n)

Measured memory_bytes: 3064
inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
l = inp.shift().split(' ')
N = l.shift() * 1
K = l.shift() * 1 
a = inp.shift().split(' ').map(x => +x)
for (i=0; i<N-K; i++) {
    console.log(a[i] < a[i+K] ? "Yes" : "No")
}


Measured memory_bytes: 62332
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

s = ns()
print('Yes' if s[2] == s[3] and s[4] == s[5] else 'No')


Measured memory_bytes: 3060
#include<iostream>
#include<vector>

int main(){
    
    size_t n, ans = 0;

    std::cin >> n;

    std::vector<size_t> b(n - 1);

    for(size_t i = 0; i < n - 1; i++){
        std::cin >> b.at(i);
    }

    for(long long i = n - 2; i >= 1; i--){
        if(b.at(i - 1) > b.at(i)){
            ans += b.at(i);
        }else{
            ans += b.at(i - 1);
        }
    }

    ans += b.at(n - 2) + b.at(0);

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> vec, sor;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        vec.push_back(a);
        sor.push_back(a);
    }
    sort(sor.begin(), sor.end());
    bool g = true;
    for (int i = 0; i < n; i++)
        if (vec[i] != sor[i])
            g = false;
    if (g) return cout << "YES\n", 0;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            vector<int> v;
            for (auto a: vec) v.push_back(a);
            swap(v[i], v[j]);
            bool good = true;
            for (int k = 0; k < n; k++)
                if (v[k] != sor[k]) good = false;
            if (good) return cout << "YES", 0;
        }
    }
    cout << "NO";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<fstream>
#include<queue>
#include<set>
using namespace std;
void ll(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(0);
}
int main()
{
	ll();

	int n;
	int arr[1000];
	cin >> n;
	set<int> s;
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
		s.insert(arr[i]);
	}
	cout << s.size() << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long	
int h,w;
char arr[1005][1005];
int mod = 1000*1000*1000+7;



int main()
{
	cin>>h>>w;
	
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		cin>>arr[i][j];
	}
	
	int dp[h][w];
	dp[0][0]=1;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(arr[i][j]=='#')
			{
				dp[i][j]=0;
				continue;
			}
			if(i==0&&j==0)
			continue;
			
			else if(i==0)
			dp[i][j]=dp[i][j-1];
			
			else if(j==0)
			dp[i][j]=dp[i-1][j];
			else
			{
				dp[i][j]=(dp[i][j-1]%mod+dp[i-1][j]%mod)%mod;
			}
		}
	}
	cout<<dp[h-1][w-1];
}
	


Measured memory_bytes: 8460
import math

A, B = map(int, input().split())

A_min = math.ceil(12.5*A)
A_max = math.ceil(12.5*(A+1)) - 1

B_min = math.ceil(10*B)
B_max = math.ceil(10*(B+1)) - 1

for i in range(B_min, B_max+1):
    if A_min <= i <= A_max:
        print(i)
        break
    if i == B_max:
        print(-1) 

Measured memory_bytes: 9104
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define eb emplace_back
#define precision(n) cout << fixed << setprecision(n);
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{
    fast;
    int f=0;
    string n;
    cin>>n;
    for(int i=0;i<n.size();i++)
    {
        if(n[i]=='7')
        {
            f=1;
        }
    }
    if(f==1)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3608
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] s = saori.nextHayami().split("");
		boolean flg = false;
		if(!s[0].equals("A")){
			flg = true;
		}
		int count = 0;
		for(int i = 2;i < s.length - 1;i++){
			if(s[i].equals("C")){
				count++;
			}
		}
		if(!(count == 1)){
			flg = true;
		}
		for(int i = 0;i < s.length;i++){
			if(Character.isUpperCase( s[i].charAt( 0 ))){
				if(!(s[i].equals("A") || s[i].equals("C"))){
					flg = true;
				}
			}
		}
		if(s[s.length-1].equals("C")){
			flg = true;
		}
		if(flg){
			System.out.println("WA");
		} else {
			System.out.println("AC");
		}

		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21332
#include<cstdio>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
char p[201000];
int Mod = 998244353, n, s;
long long D[201000][3][3], res = 1;
map<string, int>Map;
int main() {
	int i, ck = 0, j, k, ii;
	scanf("%s", p);
	for (i = 0; p[i]; i++) {
		s += (p[i] - 'a');
		if (i)res = 3 * res%Mod;
	}
	n = i;
	if (n <= 6) {
		Map[p] = 1;
		while (1) {
			int ckk = 0;
			for (auto &t : Map) {
				string tp = t.first;
				for (j = 0; j < tp.size() - 1; j++) {
					if (tp[j] != tp[j + 1]) {
						for (char tt = 'a'; tt <= 'c'; tt++) {
							if (tt != tp[j] && tt != tp[j + 1]) {
								string u = tp;
								u[j] = u[j + 1] = tt;
								if (!Map.count(u)) {
									Map[u] = 1;
									ckk = 1;
								}
								break;
							}
						}
					}
				}
			}
			if (!ckk)break;
		}
		printf("%d\n", Map.size());
		return 0;
	}
	s %= 3;
	int ckk = 0;
	for (i = 0; i < n - 1; i++) {
		if (p[i] == p[i + 1])ck = 1;
		if (p[i] != p[i + 1])ckk = 1;
	}
	if (!ckk) {
		printf("1\n");
		return 0;
	}
	D[1][0][0] = D[1][1][1] = D[1][2][2] = 1;
	for (i = 2; i <= n; i++) {
		for (j = 0; j < 3; j++)for (k = 0; k < 3; k++) {
			for (ii = 0; ii < 3; ii++) {
				if (ii == k)continue;
				D[i][(j + ii) % 3][ii] = (D[i][(j + ii) % 3][ii] + D[i - 1][j][k]) % Mod;
			}
		}
	}
	for (i = 0; i < 3; i++) {
		res = (res - D[n][s % 3][i] + Mod) % Mod;
	}
	res += 1 - ck;
	printf("%lld\n", res%Mod);
}

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

int main() {
    ll X;
    cin >> X;
    ll A, B;
    for (ll i=-200; i<=200; i++) {
        for (ll j=-200; j<=200; j++) {
            if (pow(i,5)-pow(j,5)==X) {
                A = i;
                B = j;
                break;
            }
        }
    }
    cout << A << ' ' << B << endl;
}

Measured memory_bytes: 4056
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int w, h;
string s[50];
bool B[50][50] = {}, W[50][50] = {};

void solve_b(int y, int x, bool visited[50][50]){
  B[y][x] = true;
  REP(i,4){
    int ny = dy[i] + y, nx = dx[i] + x;
    if(ny >= 0 && ny < h && nx >= 0 && nx < w){
      if(!visited[ny][nx] && s[ny][nx] == '.'){
        visited[ny][nx] = true;
        solve_b(ny, nx, visited);
      }
    }
  }
  
}

void solve_w(int y, int x, bool visited[50][50]){
  W[y][x] = true;
  REP(i,4){
    int ny = dy[i] + y, nx = dx[i] + x;
    if(ny >= 0 && ny < h && nx >= 0 && nx < w){
      if(!visited[ny][nx] && s[ny][nx] == '.'){
        visited[ny][nx] = true;
        solve_w(ny, nx, visited);
      }
    }
  }
  
}



int main(){

  while(true){
    cin >> w >> h;

    if(w == 0 && h == 0) break;

    REP(i,h){
      cin >> s[i];
    }

    REP(i,50){
      REP(j,50){
        B[i][j] = false;
        W[i][j] = false;
      }
    }
    
    REP(i,h){
      REP(j,w){
        if(s[i][j] == 'B'){

          bool visited[50][50] = {};
          visited[i][j] = true;
          solve_b(i, j, visited);
        }else if(s[i][j] == 'W'){

          bool visited[50][50] = {};
          visited[i][j] = true;
          solve_w(i, j, visited);
        }
      }
    }

    int ans_b = 0, ans_w = 0;

    
    
    REP(i,h){
      REP(j,w){
        if(s[i][j] == '.'){
          if(B[i][j] == true && !W[i][j]) ans_b++;
          else if(!B[i][j] && W[i][j]) ans_w++;
        }
      }
    }

    cout << ans_b << " " << ans_w << endl;
  }
  return 0;
}




Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

bool dbgflag = false;

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

  int h, n;
  cin >> h >> n;
  vector<pll> magic(n);
  for (int i = 0; i < n; i++) cin >> magic[i].first >> magic[i].second;
  ll max_w = 0;
  for (int i = 0; i < n; i++) max_w = max(max_w, magic[i].first);

  //for (int i = 0; i < n; i++) cout << magic[i].first << " " << magic[i].second << endl;
  vector<vector<ll>> dp(n+1, vector<ll>(max_w+h+1, INF));
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= max_w+h; j++) {
      if (j - magic[i-1].first >= 0) dp[i][j] = min(dp[i-1][j], dp[i][j-magic[i-1].first] + magic[i-1].second);
      else dp[i][j] = dp[i-1][j]; 
    }
  }

  /*int rec = -1;
  double best = -1.0;
  for (int i = 0; i < n; i++) {
    if (best * magic[i].second < magic[i].first) {
      best = (double)magic[i].first / magic[i].second;
      rec = i;
      //cout << best << endl;
    }
  }

  //cout << "ok "  << rec << endl;
  
  ll usemagic = 0;
  usemagic = (h / magic[rec].first) * magic[rec].second;
  //cout << "m: " << magic[rec].second << endl;
  h %= magic[rec].first;
  //cout << usemagic << endl;

  //cout << h << endl;
  ll bestm = INF + 1;
  for (int j = h; j < dp[0].size(); j++) bestm = min(bestm, dp[n][j]);
  usemagic += bestm;*/
  ll usemagic = INF+1;
  for (int i = h; i < dp[n].size(); i++) usemagic = min(usemagic, dp[n][i]);

  cout << usemagic << endl;
}

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

#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define IOS ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define MOD 1000000007
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define all(x) x.begin(),x.end()
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

int main(){

    IOS;

    ll t,n,m,k;
    t=1;
    while(t--)
    {
        cin >> n >> m;
        vector<vector<char>> v(n,vector<char>(m));
        vector<vector<ll>> dp(n,vector<ll>(m,-1));
        for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<m;j++)
            {
                cin >> v[i][j];
            }
        }
        k=1;
        for(ll j=m-1;j>=0;j--)
        {
            if(v[n-1][j]=='#')
            {
                k=0;
            }
            dp[n-1][j]=k;
        }
        k=1;
        for(ll i=n-1;i>=0;i--)
        {
            if(v[i][m-1]=='#')
            {
                k=0;
            }
            dp[i][m-1]=k;
        }

        for(ll i=n-2;i>=0;i--)
        {
            for(ll j=m-2;j>=0;j--)
            {
                if(v[i][j]=='#')
                    dp[i][j]=0;
                else
                    dp[i][j] = (dp[i+1][j]+dp[i][j+1])%MOD;
            }
        }
        cout << dp[0][0] << endl;
    }
    return 0;
}


Measured memory_bytes: 9088
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int k = scanner.nextInt();
        int count = 0;
        for (int i = Math.min(a, b ); i >= 1; --i) {
            if (a % i == 0 && b % i == 0) {
                ++count;
                if (count == k) {
                    System.out.println(i);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 24276
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
int dp[MAXN];
bool chk[MAXN];
pii tree[4*MAXN];


pii getv(pii a,pii b)
{
    int mn = min(a.f,b.f);
    int mx = max(a.s,b.s);

    return pii(mn,mx);
}


pii getans(int L,int R)
{
    pii res = pii(INF,0);

    while(L<=R){
        if(L&1){res=getv(res,tree[L]); L++;}
        if(!(R&1)){res=getv(res,tree[R]); R--;}
        L>>=1; R>>=1;
    }

    return res;
}

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int idx = -1;
    int tc;
    int base = 1;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>k;

    for(int i=0;i<n;i++)
        cin>>A[i];

    for(;base<n;base<<=1);

    for(int i=0;i<n;i++)
        tree[base+i] = pii(A[i],A[i]);

    for(int i=n;i<base;i++)
        tree[base+i] = pii(INF,0);

    for(int i=base-1;i>=1;i--)
        tree[i] = getv(tree[i<<1],tree[(i<<1)|1]);

    pii cur;

    int res = n-k+1;

    dp[0] = 1;

    for(int i=1;i<n;i++)
        if(A[i]>A[i-1])dp[i] = dp[i-1]+1;
        else dp[i] = 1;

    if(dp[k-1]>=k)chk[k-1] = true;

    for(int i=0;i<n-k;i++){
        cur = getans(base+i,base+i+k);
        if(chk[i])cnt++;
        if(dp[i+k]>=k)chk[i+k] = true;

        if(cur.f==A[i]&&cur.s==A[i+k])res--;
        else if(cnt&&dp[i+k]>=k)res--;
    }

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 8192
def main():
  s = list(input())
  start = -1
  end = -1
  for i, c in enumerate(s):
    if start == -1 and c == 'A':
      start = i
    if start != -1 and c == 'Z' and end < i:
      end = i
  print(end - start + 1)

main()


Measured memory_bytes: 4840
package main

import "fmt"
import "os"
import "sort"

var N int
var A []int

func main() {
	fmt.Scan(&N)
	A = make([]int, N)
	tmp := 0
	sum := 0
	for i := 0; i < N; i++ {
		fmt.Scan(&tmp)
		A[i] = tmp
		sum += tmp
	}
	sort.Ints(A)
	if sum%10 != 0 {
		fmt.Println(sum)
		os.Exit(0)
	} else {
		for i := 0; i < N; i++ {
			if A[i]%10 != 0 {
				fmt.Println(sum - A[i])
				os.Exit(0)
			}
		}
	}
	fmt.Println(0)

}


Measured memory_bytes: 512
#!/usr/bin/env python3
import sys
import math


def solve(N: int, X: "List[int]"):
    t = sum(X)
    c1 = math.ceil(t/N)
    c2 = math.floor(t/N)
    ans1 = sum(map(lambda x: (x -c1)** 2, X))
    ans2 = sum(map(lambda x: (x -c2)** 2, X))
    print(min(ans1, ans2))

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, X)

if __name__ == '__main__':
    main()


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

const ll MOD = 998244353;

ll dp[3005][3005];

int main2() {
  int N, S; cin >> N >> S;
  vector<int> A(N);
  REP(i, N) cin >> A[i];

  CLR(dp, 0);
  dp[0][0] = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= S; j++) {
      (dp[i+1][j] += 2 * dp[i][j]) %= MOD;
      if (j + A[i] <= S)
        (dp[i+1][j+A[i]] += dp[i][j]) %= MOD;
    }
  }
  ll ans = dp[N][S];
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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

public class Main {

    static String A;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        A = sc.next();

        System.out.println( solve() );
    }

    static long solve() {
        if( A.length() == 1 ) return 1;

        long ans = 0;
        int[] cnt = new int[26];
        int len = A.length();

        for (int i = A.length()-1; i >= 0; i--) {
            int c = A.charAt(i) - 'a';

            int n = len - i - 1;
            ans += n - cnt[c];

            cnt[c]++;
        }

        return ans + 1;
    }

    @SuppressWarnings("unused")
    static class FastScanner {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

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

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

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}



Measured memory_bytes: 25680