akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    for (int i = 0; i < c/2; i++) {
        a /= 2;
        b += a;
        b /= 2;
        a += b;
    }
    if (c % 2 == 1) {
        a /= 2;
        b += a;
    }
    cout << a << " " <<  b <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int n;
  char s[10001];
  scanf("%d",&n);
  scanf("%s",s);
  
  for(int i=0;i<strlen(s);i++){
    if(s[i]+n>'Z')s[i]=s[i]-26;
    printf("%c",s[i]+n);
  }
  printf("\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int main(int argc, const char** argv) {
    int cnt = 0;
    int m = 0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='R'){
            cnt++;
            m = max(cnt, m);
        }else{
            cnt=0;
        }

    }
    cout<<m;
    return 0;
}

Measured memory_bytes: 3624
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Numerics;

namespace AtCoder
{
    class Program
    {

        const int BiggestMod = 1000000007;
        public static void Main()
        {

            var haveA = int.Parse(Console.ReadLine());
            var haveB = int.Parse(Console.ReadLine());
            var haveC = int.Parse(Console.ReadLine());
            var X = int.Parse(Console.ReadLine());
            var maxA = (X / 500);
            var ans = 0;
            if (haveA < maxA) maxA = haveA;


            for (int i = 0; i <= maxA; i++)
            {

                var maxB = ((X - (i * 500)) / 100);
                if (haveB < maxB) maxB = haveB;

                for (int j = 0; j <= maxB; j++)
                    if (haveC >= ((X - (i * 500 + j * 100)) / 50))
                        ans++;

            }

            Console.WriteLine(ans);

        }

    }

}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

int dis;
vector<vector<int>> G(101);
bool visited[101];
int d[101];
int f[101];

void dfs(int v) {
    if (visited[v]) return;
    visited[v] = true;
    d[v] = dis + 1;
    dis++;
    rep(i, G[v].size()) {
        dfs(G[v][i]);
    }
    f[v] = dis + 1;
    dis++;
}

int main()
{
    int N;
    cin >> N;

    rep(i, N) {
        int u, k;
        cin >> u >> k;
        rep(j, k) {
            int v;
            cin >> v;
            G[u - 1].push_back(v - 1);
        }
    }

    rep(i, N) {
        if (!visited[i]) dfs(i);
    }

    rep(i, N) {
        cout << i + 1 << " " << d[i] << " " << f[i] << endl;
    }
    return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int64 s;
    cin >> s;
    int64 r = (int64)sqrt(s);
    if(r * r == s){
        cout << 0 << " " << 0 << " " << 0 << " " << r << " " << r << " " << 0 << endl;
        return 0;
    }
    cout << 0 << " " << 0 << " " << r+1 << " " << (r + 1) * (r + 1) - s << " " << 1 << " " << r + 1 << endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a = n/100;
    int b = n%100;
    int o1 = 0;
    int o2 = 0;
    if(a>=1 and a<=12)
        o1 = 1;

    if(b>=1 and b<=12)
        o2 = 1;

    if(o1==0 and o2==1)
        cout << "YYMM" << endl;
    else if(o1==1 and o2==0)
        cout << "MMYY" << endl;
    else if(o1==1 and o2==1)
        cout << "AMBIGUOUS" << endl;
    else
        cout << "NA" << endl;
}  


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b,c,d;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  if(a+b > c+d)       printf("Left\n");
  else if(a+b < c+d)  printf("Right\n");
  else                printf("Balanced\n");

}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n=scan.nextInt();
		double k=scan.nextDouble();
		int cnt=0;
		double c=0;
		while(n-->0) {
			double a=scan.nextDouble();
			double b=scan.nextDouble();
			c=Math.sqrt((a*a)+(b*b));
			//System.out.println(Math.sqrt(c));
			if(c<=k) cnt++;
		}
		System.out.println(cnt);
	}

}


Measured memory_bytes: 51564
#include<bits/stdc++.h>
#define mem(dp,a) memset(dp,a,sizeof(dp))
#define pb(x) push_back(x)
#define m_p(x,y) make_pair(x,y)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repush_back(i,a,b) for(ll i=a;i>=b;i--)
#define f(n) for(ll i=0;i<n;i++)
#define r(n) for(ll j=0;j<n;j++)
#define F first
#define S second
#define pi 3.14159265359
#define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;
typedef long double ld;
ll ESP=1e18;
ll INF=1e9+7;

int main()
{
 hs;
 ll n,m;
 cin>>n>>m;
 ll ans=(n*(n-1)/2)+(m*(m-1)/2);
 cout<<ans<<endl;
 return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        String s=sc.next();
        String s2=s;
        s=s.replace("01","0a1");
        s=s.replace("10","1a0");
        String ss[]=s.split("a",0);
        int po[];
        if(s.split("",0)[0].equals("0")){
            po=new int[(ss.length+1)/2*2+2];
            po[0]=0;
            po[1]=0;
            for(int i=0;i<ss.length;i++){
                po[i+2]=po[i+1]+ss[i].length();
            }
        }
        else{
            po=new int [(ss.length)/2*2+2];
            po=new int[ss.length+1];
            po[0]=0;
            for(int i=0;i<ss.length;i++){
                po[i+1]=ss[i].length()+po[i];
            }
            po[po.length-1]=(po[po.length-1]==0)?po[po.length-2]:po[po.length-1];
        }
        int ans=0;
        if(k*3>=po.length)System.out.println(s2.length());
        else{
        for(int i=0;i<po.length-k*2+1;i+=2){
            ans=Math.max(ans,po[i+k*2-1]-po[i]);
        }
        for(int i=0;i<po.length-k*2;i+=2){
            ans=Math.max(ans,po[i+k*2]-po[i]);
        }
        for(int i=0;i<po.length-k*2-1;i+=2){
            ans=Math.max(ans,po[i+k*2+1]-po[i]);
        }
            System.out.println(ans);
        }
    }
}



Measured memory_bytes: 61232
def gcd(a,b):
	while(b):
		a,b = b,a%b
	return a
def main():
	k = int(input())
	ans=0
	for a in range(1,k+1):
		for b in range(1,k+1):
			for c in range(1,k+1):
				ans+=gcd(a,gcd(b,c))

	print(ans)
if __name__ == '__main__':
	main()

Measured memory_bytes: 73880
#include<bits/stdc++.h>
#define sf1(n) scanf("%d",&n)
#define sf2(n,q) scanf("%d %d",&n,&q)
#define f first
#define ss second
#define pb push_back
#define lli long long
#define mem(ar,false) memset(ar,false,sizeof(ar))
#define mpr make_pair
#define endl "\n"
#define mod 1000000007
#define inf 9000000000000000000LL
using namespace std;

int ar[22][22];
lli dp[2097155];
vector<int>v[200005];
pair<lli,lli> dfs(int u,int par)
{
    lli white = 1;
    lli black = 0;
    for(int it : v[u])
    {
        if(it != par)
        {
            pair<lli,lli> p = dfs(it,u);  // p.first is the number of ways to color the subtree black,p.ss number of ways to color the subtree white

            black = (white*p.f) + black*(p.f+p.ss);
            black %= mod;
            white *= p.ss;
            white %= mod;
        }
    }

    return mpr(white,(white+black)%mod);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


    int n;
    cin >> n;

    for(int i=1;i<n;i++)
    {
        int a,b;
        cin >> a >> b;
        v[a].pb(b);
        v[b].pb(a);
    }

    pair<lli,lli>ans = dfs(1,-1);

    cout << (ans.f+ans.ss)%mod << endl;
    return 0;

}



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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    string s,t;
    double b,c,e,d,n,m,x,y;
    cin >> n >> m;
    vec<double> a(n);
    double cnt = 0;
    rep(i,n) {
        cin >> a[i];
        cnt += a[i];
    }
    int ans = 0;
    rep(i,n) {
        if(4*m*a[i] >= cnt) {
            ans++;
        }
    }




    cout <<    (ans >= m ? "Yes" : "No")   << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}

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

int main() {
	int n;
	cin >> n;
	int sum = 0, l[n];
	for (int i = 0; i < n; i++) {
		cin >> l[i];
		sum += l[i];
	}
	sort(l, l + n);
	cout << (l[n-1] * 2 < sum ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int n, a;
  cin >> n >> a;
  cout << n*n-a << endl;
}


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

using namespace std;

using ll = long long;

const ll MOD = 1e9 + 7;

ll dp[42][1 << 16];
bool memo[1 << 16][11];

void decode(int state, deque<int>& a) {
	while (state > 0) {
		for (int i = 1, j = 1; ; i++, j <<= 1) {
			if (state & j) {
				a.push_front(i);
				state >>= i;
				break;
			}
		}
	}
}

bool judge(int c, deque<int> a, deque<int> b) {
	a.push_back(c);
	while (!a.empty() && !b.empty()) {
		int x = a.back();
		if (x > b.back()) return false;
		b.back() -= x;
		a.pop_back();
		if (b.back() == 0) b.pop_back();
	}
	return b.empty();
}

int encode(int state, int x, int mask) {
	int res = state;
	res <<= x;
	res |= (1 << (x - 1));
	res &= mask;
	return res;
}

ll modpow(ll x, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % MOD;
		x = x * x % MOD;
		n >>= 1;
	}
	return res;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, X, Y, Z;
	cin >> N >> X >> Y >> Z;
	int sum = X + Y + Z;
	int mask = (1 << (sum - 1)) - 1;
	dp[0][0] = 1;
	for (int i = 0; i <= mask; i++) {
		deque<int> a;
		decode(i, a);
		deque<int> b = {X, Y, Z};
		for (int j = 1; j <= 10; j++) {
			memo[i][j] = judge(j, a, b);
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= mask; j++) {
			for (int k = 1; k <= 10; k++) {
				if (memo[j][k]) continue;
				int state = encode(j, k, mask);
				(dp[i + 1][state] += dp[i][j]) %= MOD;
			}
		}
	}

	ll ans = 0;
	for (int i = 0; i <= mask; i++) {
		(ans += dp[N][i]) %= MOD;
	}
	ans = (modpow(10, N) - ans + MOD) % MOD;
	cout << ans << endl;
	return 0;
}

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

int main(void){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  if(a >= b && a >= c){
    for(int i = 0;i < k;i++){
      a *= 2;
    }
  }
  else if(b >= a && b >= c){
    for(int i = 0;i < k;i++){
      b *= 2;
    }
  }
  else if(c >= a && c >= b){
    for(int i = 0;i < k;i++){
      c *= 2;
    }
  }
  cout << a+b+c << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()

{
    int n,x,i,j,k;


    while(1)
    {
        int count=0 ;
        scanf("%d %d",&n,&x);

        if(x==0 && n==0)
            break;
        else
        {
            for(i=1; i<=n; i++)
            {
                for(j=i+1; j<=n; j++)
                {
                    for(k=j+1; k<=n; k++)
                    {
                        if(i+j+k==x)
                            count++;
                    }

                }
            }
            printf("%d\n",count);
        }
    }
    return 0;
}


Measured memory_bytes: 2040
#include <stdio.h>

int main() {
  int N;
  double x;
  char u[3];

  double sum;
  int i;

  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    scanf("%lf %s", &x, u);
    if (u[0] == 'J') {
      sum += x;
    } else {
      sum += x * 380000.0;
    }
  }
  printf("%f\n", sum);
  return 0;
}


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

#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define rf(i, a, b) for (int(i) = (a); (i) <= (b); (i)++)
#define rb(i, b, a) for (int(i) = (b); (i) >= (a); (i)--)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;

const int N = 1e5 + 1;
const int INF = 2e9;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    ll ans = 0;
    rf(i, 1, n) {
        if (i % 3 != 0 && i % 5 != 0)
            ans += i;
    }
    cout << ans;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define MAXN	100005
vector <int> a[MAXN];
int perfect(int pos, int fa) {
	int cnt = 0;
	for (unsigned i = 0; i < a[pos].size(); i++)
		if (a[pos][i] != fa) cnt += perfect(a[pos][i], pos);
	if (cnt >= 2) return 2;
	else return cnt ^ 1;
}
int main() {
	int n; scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	if (perfect(1, 0)) printf("First\n");
	else printf("Second\n");
	return 0;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll n;
    cin >> n;
    vector<string> s(n);
    loop(i, n) cin >> s[i];
    vector<ll> count(4);
    loop(i, n)
    {
        if (s[i] == "AC")
            count[0]++;
        if (s[i] == "WA")
            count[1]++;
        if (s[i] == "TLE")
            count[2]++;
        if (s[i] == "RE")
            count[3]++;
    }
    cout << "AC x " << count[0] << endl;
    cout << "WA x " << count[1] << endl;
    cout << "TLE x " << count[2] << endl;
    cout << "RE x " << count[3] << endl;
    return 0;
}


Measured memory_bytes: 6424
#include <stdio.h>

int solve(int,int);

int A[20],n;

int main() {

  int i,q,x,m[200];

  scanf("%d",&n);
  for(i = 0; i < n; i++)
    scanf("%d",&A[i]);

  scanf("%d",&q);
    for(i = 0; i < q; i++)
      scanf("%d",&m[i]);

  for(i = 0; i < q; i++) {
   x = solve(0,m[i]);
   if(x == 1)
     printf("yes\n");
   else if(x == -1)
     printf("no\n");
  }
  

  return 0;
}

int solve(int i,int m)
{
  int res, res1;
  
  if(m == 0)
    return 1;
  if(i >= n)
    return -1;

  res = solve(i + 1, m);
  res1 = solve(i + 1, m - A[i]);

  if(res == 1 && res1 == 1)
    return 1;
  else if(res == 1 && res1 == -1)
    return 1;
  else if(res == -1 && res1 == 1)
    return 1;
  else return -1;
}



Measured memory_bytes: 2108
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 998244353;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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


string s, t;
bool f = true, j = true;

int main() {

	cin >> s >> t;

	sort(all(s));
	sort(all(t));
	reverse(all(t));

	rep(i, min(s.size(), t.size())) {
		if (s[i] == t[i])continue;
		else if (s[i] > t[i])f = false;
		else {
			j = false;
			break;
		}
	}

	if (j && s.size() >= t.size())f = false;

	if (f)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
/**
 * @Author:      G_bg
 * @DateTime:    2019-04-27 21:56:38
 * @Description: 
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int mod = 1e9+7;
const int maxn=1e5+10;
int a[maxn],q[maxn],h[maxn];
int gcd(int a,int b){
    return b == 0?a:gcd(b,a%b);
}
int main(int argc, char const *argv[]) {
    ios::sync_with_stdio(0);cin.tie(0);
    int n;cin >> n;
    for(int i = 0;i < n;i++) cin >> a[i];
    q[0] = a[0];
    for(int i = 1;i < n;i++) q[i] = gcd(a[i],q[i-1]);
    h[n-1] = a[n-1];
    for(int i = n-2;i >= 0;i--) h[i] = gcd(a[i],h[i+1]);
    int ans = 0;
    for(int i = 0;i < n;i++){
        if(i == 0) ans = max(ans,h[i+1]);
        else if(i == n-1) ans = max(ans,q[i-1]);
        else ans = max(ans,gcd(q[i-1],h[i+1]));
    }
    cout << ans << endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
void SelectionSort(vector<int> &A, int N){
    int bf;
    int minj;
    int Count = 0;

    for ( int i = 0; i < N; i++ ){
        minj = i;
        for ( int j = i; j < N; j++ ){
            if ( A.at(j) < A.at(minj) ) minj = j;
        }
        if ( minj != i ){
            bf = A.at(i);
            A.at(i) = A.at(minj);
            A.at(minj) = bf;
            Count++;
        }
    }

    for ( int i = 0; i < N - 1; i++ ){
        cout << A.at(i) << " ";
    }
    cout << A.at(N-1) << endl;
    cout << Count << endl;
}
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for ( int i = 0; i < N; i++ ) cin >> A.at(i);
    
    SelectionSort( A, N );

    return 0;
}


Measured memory_bytes: 3092
// ITP1_5_A:   Print a Rectangle
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int H, W;
	int h, w;

	while (1) {
		scanf("%d%d", &H, &W);
		if (H == 0 && W == 0) break;
		for (h = 0; h < H; h++) {
			for (w = 0; w < W; w++) {
			if(w%2==0&&h%2==0)
			putchar('#');
			if(w%2==1&&h%2==0)
			putchar('.');
			if(w%2==0&&h%2==1)
			putchar('.');
			if(w%2==1&&h%2==1)
			putchar('#');
		}
		
			putchar('\n');
		}
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 2052
#include<stdio.h>

int main(void)
{
    int n;
    int min;
    int max;
    long int sum = 0;
    int i;
    scanf("%d", &n);
    int ai[n];
    

    for(i = 0; i < n; i++)
    {
        scanf("%d ", &ai[i]);
        if(i == 0)
        {
            min = ai[0];
            max = ai[0];
        }
        
        if(ai[i] < min)
        {
            min = ai[i];
        }
        
        if(ai[i] > max)
        {
            max = ai[i];
        }
        
        sum += ai[i];
    }
    printf("%d %d %ld\n", min, max, sum);
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define MINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e, v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int N;
string S;

void _main() {
    cin >> N >> S;
    REP(i, SZ(S)) cout << char((S[i] - 'A' + N) % 26 + 'A');
    cout << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n;
ll a[101010];
int main() {
    cin>>n;
    REP(i, 0, n) cin>>a[i];

    ll x=a[0];
    REP(i, 1, n){
        x^=a[i];
    }

    if(x==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>
 
#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)
#define ll_cin(X) scanf("%lld", &X)
 
#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)
 
typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)
 
#define S_RTN(S)  s_cout(S);return 0
 
 
#define _itoa(A,N) sprintf(A, "%d", N);
 
int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);
 
int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);
 
 
int s_asorts(const void* a, const void* b);
 
//昇順
int s_asorts(const void* a, const void* b) {
    return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
    return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
    return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
    int i;
    rept(i, 0, n) {
        l_cin2(*(a + i), *(b + i));
    }
    return 0;
}
int i_cins(int n, int* a) {
    int i;
    for (i = 0; i < n; i++) {
        i_cin(*(a + i));
    }
 
    return 0;
}
int _gcd(int a, int b) {
    int r, tmp;
    if (a < b) { tmp = a; a = b; b = tmp; }
    r = a % b;
    while (r) {
        if (!r) break;
        a = b; b = r;
        r = a % b;
    }
    return(b);
}
 
long _max(long a, long b) {
    return a > b ? a : b;
}
long _min(long a, long b) {
    return a < b ? a : b;
}
int _swp(int* a, int* b)
{
    int tmp;
    tmp = *b; *b = *a; *a = tmp;
    return 0;
}

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


int main(){
    int N;
    i_cin(N);
    int a[N];
    rept(i,0,N)
    i_cin(a[i]);
    qsort(a,N,sizeof(int),compare_int);
    rept(i,0,N-1){
        if(a[i]==a[i+1]){
            printf("NO");
            return 0;
        }
    }
    printf("YES");
    
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "-1" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N,L,Q;
    int a[114514],b[114514];
    vector<int> x;
    cin >> N;
    int y;
    REP(i,N){cin >> y;y--;x.push_back(y);}
    cin >> L >> Q;
    REP(i,Q){cin >> a[i] >> b[i];a[i]--;b[i]--;if(b[i]<a[i])swap(a[i],b[i]);}
    
    int dp[20][114514];
    REP(i,N){
        dp[0][i]=-1+(int)(upper_bound(x.begin(),x.end(),x[i]+L)-x.begin());
    }
    for(int k=0;(1<<k)<N;k++){
        REP(i,N){
            dp[k+1][i]=dp[k][dp[k][i]];
        }
    }
    
    REP(j,Q){
        int P=a[j],R=b[j];
        int l=0,r=N,mid;
        while(abs(r-l)>1){
            mid=(l+r)/2;
            int now=P;
            int m=mid,k=0;
            while(m>0){
                if(m%2==1){
                    now=dp[k][now];
                }
                k++;
                m/=2;
            }
            if(now>=R){
                r=mid;
            }else{
                l=mid;
            }
        }
        cout << l+1<< endl;
    }
    
    return 0;
}



Measured memory_bytes: 21236
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( iter = $ iter : ident , $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut $ iter = s . split_whitespace ( ) ; input_inner ! { $ iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , mut $ var : usize $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , $ var : usize $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , { chars : $ base : expr } ) => { read_value ! ( $ iter , String ) . chars ( ) . map ( | c | ( c as u8 - $ base as u8 ) as usize ) . collect ::< Vec < usize >> ( ) } ; ( $ iter : expr , { char : $ base : expr } ) => { read_value ! ( $ iter , { chars : $ base } ) [ 0 ] } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , char ) => { read_value ! ( $ iter , chars ) [ 0 ] } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
fn two(
    t1: (usize, Option<usize>),
    t2: (usize, Option<usize>),
    a: &Vec<usize>,
) -> (usize, Option<usize>) {
    let mut v = vec![t1.0, t2.0];
    if let Some(p) = t1.1 {
        v.push(p);
    }
    if let Some(p) = t2.1 {
        v.push(p);
    }
    v.sort_by_key(|&i| a[i]);
    let x = v.pop().unwrap();
    while let Some(p) = v.pop() {
        if x != p {
            return (x, Some(p));
        }
    }
    (x, None)
}
fn main() {
    input! { n, a: [usize; 1<<n] };
    let mut dp = (0..1 << n).map(|i| (i, None)).collect::<Vec<_>>();
    for i in 0..1 << n {
        for j in 0..n {
            if i & 1 << j == 0 {
                dp[i | 1 << j] = two(dp[i | 1 << j], dp[i], &a);
            }
        }
    }
    let mut ans = 0;
    for i in 1..1 << n {
        ans = std::cmp::max(ans, a[dp[i].0] + a[dp[i].1.unwrap_or(0)]);
        println!("{}", ans);
    }
}


Measured memory_bytes: 18424
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
int x[10][10];
signed main(){
	int a,b;
	cin>>a>>b;
	if(a==b)puts("Yes");
	else puts("No");
}


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

using namespace std;

#define f0r(a, b) for (long long a = 0; a < b; a++)
#define f1r(a, b, c) for (long long a = b; a < c; a++)
#define f0rd(a, b) for (long long a = b; a >= 0; a--)
#define f1rd(a, b, c) for (long long a = b; a >= c; a--)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define f first
#define s second

#define ao(a, n) {for (int ele = 0; ele < n; ele++) { if (ele) cout << " "; cout << a[ele]; } cout << endl;}

typedef long long ll;
typedef double ld;
typedef long double lld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

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


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

  ll n; cin >> n;

  ll arr[n];
  
  f0r(i, n) {
    cin >> arr[i];
  }

  ll ret = 0;

  f0r(i, n) {
    if (i - ret + 1 != arr[i]) {
      ret++;
    } 

  }

  if (ret == n) {
    ret = -1;
  }

  cout << ret << endl;

}

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

const int MAX_N = 101010;
int N, K;
int h[MAX_N];
int cost[MAX_N];

int main(){

    for(int i = 1; i < MAX_N; i++)cost[i] = 1145141919;
    cin >> N >> K;
    for(int i = 0; i < N; i++)cin >> h[i];
    for(int i = 0; i < N; i++){
        for(int k = 1; k <= K; k++){
            cost[i + k] = min(cost[i + k], cost[i] + abs(h[i] - h[i + k]));
        }
    }
    cout << cost[N - 1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define All(a) a.begin(), a.end()
typedef pair<long long, long long> P;
const int MOD = 998244353;
const int MAX = 410000;

long long fac[MAX], finv[MAX], inv[MAX];
//invの要素にはiの逆元が格納されている
//前処理
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;//i!(mod MOD)を計算
        inv[i] = MOD - inv[MOD%i]* (MOD / i) % MOD;//iの逆元を計算
        finv[i] = finv[i - 1] * inv[i] % MOD;//i!(mod MOD)の逆元を計算
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;//nCk = n!/(k!*(n-k)!)を計算
}
long long mod_pow(long long x, long long n){//x^nのmodのmodを計算する
    if(n == 0) return 1;
    if(n % 2 == 0){
        long long t = mod_pow(x, n / 2) % MOD; //nが偶数のときはx^n = x^(n / 2) * x^(n / 2)
        return t * t % MOD;
    } 
    return x * mod_pow(x, n - 1)% MOD;//nが奇数のときはx^n = x * x^(n - 1)
}
int main(){
    COMinit();
    long long N, M, K;
    cin >> N >> M >> K;
    long long ans = 0;
    for(long long i = 0; i <= K; i++){
        ans += ((M*mod_pow(M - 1, N - 1 - i)) % MOD * COM(N - 1, i))%MOD;
        ans = (ans+MOD) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 13248
import sys
from collections import defaultdict

n, a, *x = map(int, sys.stdin.read().split())

def main():
    for i in range(n):
        x[i] -= a
    
    c = defaultdict(int)
    c[0] = 1
    for i in x:
        nex = c.copy()
        for val, cnt in c.items():
            nex[val+i] += cnt
        c = nex
    ans = c[0] - 1
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

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

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

        public static void Solve()
        {
            var abn = Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
            Func<long, long> f = x => (long)(Math.Floor((abn[0] * x) / (double)abn[1]) - abn[0] * Math.Floor(x / (double)abn[1]));
            var max = 0L;
            var index = (abn[1] < abn[2]) ? (long)(abn[1] - 1) : (long)abn[2];
            while (index <= abn[1] && index >= 0)
            {
                var tmp = f(index--);
                if (tmp >= max) max = tmp;
                else break;
            }
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 28104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        string input = Console.ReadLine();
        char a = input[0];
        for (int i = 1; i < input.Length; i++)
        {
            if (a == input[i])
            {
                Console.WriteLine("Bad");
                return;
            }
            else
            {
                a = input[i];
            }
        }
        Console.WriteLine("Good");
    }
}

Measured memory_bytes: 13140
from collections import Counter
from math import gcd, atan2

MOD = 10**9 + 7
class mint:
    def __init__(self, i):
        self.i = i
    def __add__(self, m):
        t = self.i + (m.i if isinstance(m, mint) else m)
        if t > MOD:
            t -= MOD
        return mint(t)
    def __radd__(self, m):
        t = self.i + (m.i if isinstance(m, mint) else m)
        if t > MOD:
            t -= MOD
        return mint(t)
    def __mul__(self, m):
        return mint(self.i * (m.i if isinstance(m, mint) else m) % MOD)
    def __sub__(self, m):
        t = self.i - (m.i if isinstance(m, mint) else (m % MOD))
        if t < 0:
            t += MOD
        return mint(t)
    def __pow__(self, m):
        i = self.i
        return mint(pow(i, m, MOD))
    def __truediv__(self, m):
        return mint(self.i * pow(m, MOD - 2, MOD) % MOD)
    def __repr__(self):
        return repr(self.i)


n = int(input())
ab = [tuple(map(int, input().split())) for _ in range(n)]
zeros = len(list(filter(lambda x: x[0] == x[1] == 0, ab)))
ab = list(filter(lambda x: x[0] ** 2 + x[1] ** 2 > 0, ab))

t = []
for a, b in ab:
    g = gcd(a, b)
    a //= g
    b //= g
    if a < 0:
        a *= -1
        b *= -1
    elif a == 0:
        b = abs(b)
    t.append((a, b)) # a >= 0
m = Counter()
for a, b in t:
    m[(a, b)] += 1
l = []
for a, b in m:
    if b > 0 and ((b, -a) in m):
        continue
    l.append((m[(a, b)], m[(-b, a)]))
ans = mint(1)

for v, w in l:
    #print('hi', ans, v, w)
    ans *= pow(2, v, MOD) - 1 + pow(2, w, MOD) - 1 + 1
#print(ans)
print(ans + zeros - 1)


Measured memory_bytes: 104468
#include<bits/stdc++.h>
using namespace std;
//#define int long long
typedef long long ll;
#define sqr(x) ((x)*(x))
#define pb push_back 
const int N=1000002,M=998244353;
int pw(int x,int y){int z=1;for(;y;y>>=1,x=1ll*x*x%M)if(y&1)z=1ll*z*x%M;return z;}
//struct node{int to,ne}e[];
//void add(int x,int y){e[++tot]=(node){y,h[x]},h[x]=tot;}
int n,k;
signed main(){
	scanf("%d%d",&n,&k);
	if (k>1) printf("%d",n-k);
	else printf("%d",0);
}

Measured memory_bytes: 256
#K

N,K=map(int,input().split())
a=list(map(int,input().split()))

#先手が勝つ：1，負ける0
dp=[0]*(K+1)

for i in range(N):
    dp[a[i]]=1
    
for i in range(K+1):
    if dp[i]==0:
        for j in range(N):#a[j]だけ引いたところに0があれば先手は勝てる
            if i-a[j]>=0:
                if dp[i-a[j]]==0:
                    dp[i]=1
                    break
                    
if dp[-1]==1:
    print("First")
else:
    print("Second")
    




Measured memory_bytes: 42480
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <utility>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
using namespace std;
const int INF = 1000000;
typedef pair<int, int> P;
char A[1000][1000];
int d[1000][1000];
int H, W;
int dh[4] = {1,0,-1,0}, dw[4] = {0,1,0,-1};
typedef pair<int, int> P;
queue<P> que;

int bfs(){
  int cnt = 0;
  for(int i=0; i<H+W;i++){
    vector<P> tmp;
    while(!que.empty()){
      P p = que.front(); que.pop();
      for (int i=0; i<4; i++){
        int nh=p.first + dh[i], nw = p.second + dw[i];
        if (nh>=0 && nh<H && nw>=0 && nw<W && A[nh][nw] != '#' && d[nh][nw] == INF){
          tmp.push_back(P(nh, nw));
          d[nh][nw] = d[p.first][p.second] + 1;
        }   
      }
    }
    if (tmp.size() == 0) break;
    else{
      cnt++;
      for(int i=0; i<tmp.size(); i++) que.push(tmp[i]);
    }
    
  }
  return cnt;
}
 
 
int main(){
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  
  cin >> H >> W;
  int b_cnt = 0;
  for (int i=0; i<H;i++){
    for(int j=0; j<W; j++){
      cin >> A[i][j];
      if (A[i][j] == '#') {
      	d[i][j] = 0;
        que.push(P(i, j));
      }
      else d[i][j] = INF;
    }
  }
  
  int res = bfs();
  cout << res << endl; 
  
}

Measured memory_bytes: 14264
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import Counter

n = ni()
a = list(li())

even = Counter(a[::2])
odd = Counter(a[1::2])

es = even.most_common(2)
os = odd.most_common(2)

es = es + [(0,0)]
os = os + [(0,0)]

if es[0][0] != os[0][0]:
    print((n//2-es[0][1]) + (n//2-os[0][1]))
else:
    print(min((n//2-es[1][1]) + (n//2-os[0][1]),
              (n//2-es[0][1]) + (n//2-os[1][1])))

Measured memory_bytes: 18720
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *H = map(int, read().split())
    
    ans = sum(h >= K for h in H)
    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 18760
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		
		int n = cin.nextInt();
		
		int[] fr = new int[n];
		int friends = 0;
		
		for (int i = 0; i < n; i ++) {
			fr[i] = cin.nextInt();
		}
		
		for (int i = 0; i < n; i ++) {
			int j = fr[i]-1;
//			System.out.println(j);
//			System.out.println(i+1);
			if (fr[j] == (i+1)) {
				friends++;
			}
		}
		
		System.out.println(friends/2);
	}

}


Measured memory_bytes: 32216
#include <bits/stdc++.h>
#define ll long long
#define M 33010
#define rep(i, a, b) for (int i = a; i<= b; ++i)
using namespace std;
const ll mod = 998244353;
ll n, s, a[M], dp[M], ans;

int main() {
	int n, s; cin >> n >> s;
	rep(i, 1, n) cin >> a[i];
	rep(i, 1, n) {
		for (int j = s; j >= a[i]; --j) {
			dp[j] += dp[j - a[i]];
			dp[j] %= mod;
		}
		if (a[i] <= s) dp[a[i]] = (dp[a[i]] + i) % mod;
		ans = (ans + dp[s]) % mod;
	}
	cout << ans;
}

Measured memory_bytes: 256