akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)
int main(){
    string S;
    cin>>S;
    
    if( (S[0]==S[1]) && (S[1]==S[2])){
        cout<<"No"<<endl;
    }else cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(int i=0;i<(n);i++)
 
using namespace std;
 
 
int main(){
    int n, m;
    cin >> n >> m;
    int x[m], y[m];
    rep(i, m){
        cin >> x[i] >> y[i];
    }
 
    vector<bool> red(n, false);
    red[0] = true;
    vector<int> white(n, 1);
 
    rep(i, m){
        int from = x[i]-1;
        int to = y[i]-1;

        white[from]--;
        white[to]++;
        if(red[from])   red[to] = true;
        if(white[from] == 0)    red[from] = false;
    }
 
    int sum = 0;
    rep(i, n){
        if(red[i])  sum++;
    }
    cout << sum << endl;
 
    return 0;
}

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

int main() {
  int n;
  cin>>n;
  if(n==1){
    cout<<"Yes"<<endl;
    return 0;
  }
  vector<long long int> vec(n);
  
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  
  for(int i=n-2;i>=0;i--){
    if(vec.at(i)>vec.at(i+1)){
      if(vec.at(i)-1==vec.at(i+1)){
        vec.at(i)+=-1;
      }
      else{
       cout<<"No"<<endl;
        return 0;
      }
   }
  }
         
         cout<<"Yes"<<endl;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
	"math"
)

func isInteger(x float64) bool {
	return math.Floor(x) == x
}

func main() {
	// Code for B - Crane and Turtle
	var a, b float64
	var x, y float64
	fmt.Scan(&a, &b)
	x = (4*a - b) / 2
	y = (b - 2*a) / 2

	if isInteger(x) && isInteger(y) && x >= 0 && y >= 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1836
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
X = input()

def popcount(n):
    cnt = 0
    while n:
        n %= "{:b}".format(n).count("1")
        cnt += 1
    return cnt

pl = [0]*(N+1)
for i in range(N+1):
    pl[i] = popcount(i)
bn = X.count("1")

modp = [0]*N
modm = [0]*N

for i in range(N):
    if X[i] == "1":
        modp[i] = pow(2, N-1-i, bn+1)
        if not bn == 1:
            modm[i] = pow(2, N-1-i, bn-1)

sp = sum(modp)
sm = sum(modm)
ans = [0]*N
for i in range(N):
    if X[i] == "1":
        if bn == 1:
            ans[i] = 0
            continue
        s = sm
        s -= modm[i]
        s %= bn-1
        ans[i] = pl[s]+1
    else:
        s = sp
        s += pow(2, N-1-i, bn+1)
        s %= bn+1
        ans[i] = pl[s]+1

print(*ans, sep="\n")


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

int main () {

 string s0, s1, s2, ans = "";
 cin >> s0 >> s1 >> s2;

 ans += 'A';
 ans += s1[0];
 ans += 'C';

 cout << ans << endl;

 return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define rep(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;

const ll mod=1e9+7;

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

/*-------------------------------------------*/
ll dp1[1<<17],dp2[1<<17];

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

    string l;
    cin>>l;

    dp2[0]=1;
    rep(i,l.size()){
        if(l[i]=='0'){
            dp1[i+1]=dp1[i]*3;
            dp2[i+1]=dp2[i];
        }else{
            dp1[i+1]=dp1[i]*3+dp2[i];
            dp2[i+1]=dp2[i]*2;
        }
        dp1[i+1]%=mod;
        dp2[i+1]%=mod;
    }
    cout<<(dp1[l.size()]+dp2[l.size()])%mod<<endl;
}

Measured memory_bytes: 2000
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = [inpl() for _ in range(n)]
res = 0
fin = set()
for k in range(n):
    for i in range(n):
        for j in range(n):
            d = a[i][k] + a[k][j]
            if a[i][j] > d:
                print(-1)
                quit()
            if a[i][j] == d and i != k and j != k:
                fin.add((i,j))

for i in range(n):
    for j in range(i+1,n):
        if (i,j) in fin: continue
        res += a[i][j]
print(res)

Measured memory_bytes: 78808
import sys
from collections import deque
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N, M = map(int, readline().split())
graph = [[] for _ in range(N + 1)]
check = []

for i in readlines():
    x, y, z = map(int, i.split())
    graph[x].append(y)
    graph[y].append(x)
    check.extend([x, y])

check = set(check)
answer = N - len(check)
while check:
    queue = deque([check.pop()])
    while queue:
        v = queue.popleft()
        for j in graph[v]:
            if j in check:
                queue.append(j)
                check.remove(j)
    answer += 1

print(answer)

Measured memory_bytes: 30920
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int MX=2e5+9;
string s;
int a[MX];
int main(){
    cin>>s;
    for(int i=0;i<s.size();i++)a[s[i]]=1;
    for(int i='a';i<='z';i++){
        if(!a[i]){
            cout<<char(i)<<endl;
            return 0;
        }
    }
    puts("None");
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define rep(I,N) for(int I = 0; I < (int)(N); I++)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);

int calc(int from, int to){
	if(from == to)return 0;
	int T = 0;
	if(from % 2 != 0){
			T++;
			from++;
	}
	if(to % 2 != 0){
		T++;
		to--;
	}
	T += calc(from/2, to/2);
	return T;
}

int main(void){
	int a, from, to; 
	cin >> a;
	rep(i, a){
		cin >> from >> to;
		FIN(calc(from, to));
	}
	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 1164
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <iostream>
#include <math.h>
using namespace std;
int main ()
{
	int k,x;
	scanf("%i%i",&k,&x);
	if(k*500>=x)
	{
		printf("Yes");
	}
	else printf("No");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int n, m;
map<int, vector<int>> dic;

int main() {
    cin >> n >> m;
    rep(i, m) {
        int a, b; cin >> a >> b;
        dic[a].emplace_back(b);
    }

    bool can_reach = false;
    for (auto mid: dic[1]) {
        for (auto end: dic[mid]) {
            if (end == n) {
                can_reach = true;
                break;
            }
        }
    }
    cout << (can_reach ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}


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

#define ff      first
#define ss      second
#define pb      push_back
#define ll      long long
#define MX      100005
#define inf     1000000
#define mod     1000000007
#define endl    "\n"

#define W(t)            while(t--)
#define all(v)          v.begin(),v.end()
#define ZERO(a)         memset(a,0,sizeof(a))
#define MINUS(a)        memset(a,-1,sizeof(a))
#define rep(i,a,b)      for(i = a; i < b; i++)
#define IOS             ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;

int main()
{
   int n, i, cnt = 0;
   cin >> n;

   for (int k = 1; k <= 1000000; k++)
   {
      if (k >= n)
         break;
      else
      {
         int tmp = n - k;

         for (int i = 1; i <= sqrt(tmp); i++)
            if (tmp % i == 0)
            {
               int d1 = i;
               int d2 = tmp / i;

               if (d1!=d2)
                  cnt += 2;
               else
                  cnt++;

            }

      }
   }
   cout << cnt;
}

Measured memory_bytes: 3668
x,n = map(int,input().split())
if n == 0:
    print(x)
else:
    p = list(map(int,input().split()))
    absolute = list(map(lambda i:abs(i-x),p))
    if 0 not in absolute:
        print(x)
    else:
        ab = set(p)
        i = 1
        while i < 100:
            if absolute.count(i) == 2:
                i += 1
            else:
                opt = set([x-i,x+i])
                ans = opt - ab
                break

        print(min(ans))


Measured memory_bytes: 9076
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

dp = [[float("inf")] * (h + 1) for _ in range(n + 1)]
for i in range(n + 1):
    dp[i][0] = 0

for i in range(1, n + 1):
    for j in range(1, h + 1):
        a, b = ab[i-1]
        dp[i][j] = min(dp[i-1][j], dp[i][max(j-a, 0)] + b)

ans = dp[n][h]
print(ans)


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;

ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

ll C(ll n,ll k)
{
  ll x=1,y=1;
  for(int i=1;i<=k;i++)
  {
    x=x*(n-i+1)%mod;
    y=y*i%mod;
  }
  return x * power(y,mod-2) % mod;
}
ll a; ll b;
ll num(ll c){
    return b/c-(a-1)/c;
}
int main(){
	
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    ll c,d;cin>>a>>b>>c>>d;
    cout << b-a+1-num(c)-num(d)+num(c/__gcd(c,d)*d)<<endl;
    return 0;
}

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

int main() {
  int a[10];
  for (int i = 0; i < 10; i++) {
    cin >> a[i];
  }
  sort(a, a + 10);
  cout << a[9] << "\n" << a[8] << "\n" << a[7] << endl;
  return 0;
}


Measured memory_bytes: 3144
# 解説と下記を参考に作成
# https://atcoder.jp/contests/abc113/submissions/15821617
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(H, W, K):
    mod = 10 ** 9 + 7
    dp = [[0] * W for _ in range(H + 1)]
    dp[0][0] = 1
    fibo = [1, 2, 3, 5, 8, 13, 21]
    for h in range(H):
        for w in range(W):
            if dp[h][w] == 0:
                continue
            for i in range(3):
                new_w = w - 1 + i
                if not 0 <= new_w < W:
                    continue
                l, r = min(w, new_w), max(w, new_w)
                tmp = fibo[max(l - 1, 0)] * fibo[max(W - 1 - (r + 1), 0)]
                dp[h + 1][new_w] += dp[h][w] * tmp
                dp[h + 1][new_w] %= mod
    print(dp[-1][K - 1])


if __name__ == '__main__':
    H, W, K = map(int, input().split())
    solve(H, W, K)

    # # test
    # from random import randint
    # from func import random_str
    # solve()


Measured memory_bytes: 9228
#atcorder beginner contest 142
#B roller coaster

person, limit_height = input().strip().split()
person = int(person)
limit_height = int(limit_height)


i = 0
can = 0
person_height = list(map(int, input().split()))

for i in person_height:
    if i >= limit_height:
        can += 1

print(can)


Measured memory_bytes: 11912
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

const ll MOD = 1e9 + 7;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second



int main() {
	int h, w;
	cin >> h >> w;
	char c[100][100];
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++)cin >> c[i][j];
	}
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			if (c[i][j] == '#') {
				bool fl = 0;
				for (int k = 0;k < 4;k++) {
					int nx = j + dx[k], ny = i + dy[k];
					if (nx >= 0 && nx < w&&ny >= 0 && ny < h) {
						if (c[ny][nx] == '#') {
							fl = 1;
						}
					}
				}
				if (!fl) {
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}
	cout << "Yes" << endl;
}


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

using namespace std;
const int N = 1e5 + 5;
typedef long long ll;

int main() {
    ll res_a = 1, res_b = 1;
    int n;
    scanf("%d", &n);
    int a, b;
    for(int i = 0; i < n; i++) {
        scanf("%d%d", &a, &b);

        if(a >= res_a && b >= res_b) {
            res_a = a;
            res_b = b;
            continue;
        }

        ll _min = max(res_a / a + (res_a % a == 0 ? 0 : 1), res_b / b + (res_b % b == 0 ? 0 : 1));
        res_a = a * _min;
        res_b = b * _min;

    }
    cout << res_a + res_b << endl;
    return 0;
}


Measured memory_bytes: 256
<?php
 
//1行目の空白までのデータをもらって$n1に入れる
fscanf(STDIN, '%d',$n);
//2行目をもらってきて、文字列から空白のスペースを取り除く
$line=trim(fgets(STDIN));
//空白を境目にして、文字列から配列を作る
$line=explode(' ',$line);
//配列の要素を一つずつint型にキャストする
$A=array_map(function ($val) {
  return (int)$val;
},$line);
//昇順に並び替える
sort($A);
//$Aの合計値
$sum=array_sum($A);
 
//3行目の空白までのデータをもらって$n2に入れる
fscanf(STDIN,'%d',$q);
//探索済みの配列を格納するための変数
//4行目の文字列を配列にして格納
$line=explode(' ',trim(fgets(STDIN)));
$arr=array();
// v($line);
foreach($line as $l) {
  $l = (int)$l;
  //Aの合計値より大きければ不可能
  if($l > $sum) {
    echo "no\n";
    $arr[$l] = false;
 
 
  }else {
    $bool = cal(0,$l);
    $arr[$l]=$bool;
    echo $bool ? "yes\n" : "no\n";
  }
  }
 
  function cal($i, $l){
    global $n, $A;
    if($l === 0) {
      return true;
    }elseif($i === $n) {
      return false;
    }elseif(cal($i + 1,$l)) {
      return true;
    }elseif(cal($i+1,$l-$A[$i])) {
      return true;
    }
    return false;
  }


Measured memory_bytes: 9408
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    ll n, h, w;
    while(cin>>h>>w){
        ll ans=0;
        ans=(h*w+1)/2;
        if(h==1 || w==1){
        	ans=1;
        } 
        cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

#define LL 1000000007

long long fact(long long k) {
  long long sum = 1;
  for (int i = 1; i <= k; ++i) {
    sum *= i;
    sum %= LL;
  }
  return sum;
}

int main() {
  long long n, m;
  long long ans = 0;
  cin >> n >> m;

  if (abs(n - m) > 1) {  //解なし
    cout << 0 << endl;
    return 0;
  }

  ans = fact(n);
  ans *= fact(m);
  ans %= LL;

  if (abs(n - m) == 0) {  // 2パターンある
    ans *= 2;
    ans %= LL;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<string>
#include<set>
#include<queue>
#include<cmath>
#include<tuple>
#include<utility>
#include<functional>
#include<algorithm>

#define LL long long
#define trio tuple<int,int,int>

using namespace std;

int N,M,A[111],tf=1,sum=0;

int main() {
	cin>>N>>M;
	for(int i=0;i<N;i++){
		cin>>A[i];
		sum+=A[i];
	}
	sort(A,A+N);
	reverse(A,A+N);
	for(int i=0;i<M;i++)
		if((double)A[i]<(double)sum/(double)(4*M))tf=0;
	cout<<(tf==1?"Yes":"No")<<endl;

	return 0;
}



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

int main(){
    int n,ans=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n-1;i++) cin>>a[i];
    ans+=a[0]+a[n-2];
    for(int i=0;i<n-2;i++) ans+=min(a[i],a[i+1]);
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

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

	int n;
	cin >> n;
	vi a(n + 1), b(n);
	for(int i = 0; i < n + 1; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> b[i];
	ll res = 0;
	for(int i = 0; i < n; i++){
		int mn = min(a[i], b[i]);
		res += mn;
		a[i] -= mn;
		b[i] -= mn;
		if(b[i] > 0){
			res += min(a[i + 1], b[i]);
			a[i + 1] -= min(a[i + 1], b[i]);
		}
	}
	cout << res;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fine cout<<"fine"<<endl;
#define ll long long int
#define pb push_back
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
const ll inf=(ll)2e18;
const int mod=1e9+7;
bool overflow(ll a,ll b){
    if (a <= (inf+b-1)/b) return false;
    return true;
}
int main(){
FASTIO;
char c;
cin>>c;
cout<<(char)((int)c+1)<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
def main():
    _ = int(input())
    A = [int(x) for x in input().split()]
    mod = 10 ** 9 + 7

    square_S = sum(A) ** 2 % mod
    diagonal = sum([x ** 2 % mod for x in A]) % mod
    #  By the Fermat's little theorem
    print(((square_S - diagonal) % mod * pow(2, mod - 2, mod)) % mod)


if __name__ == '__main__':
    main()


Measured memory_bytes: 31424
a, b, c, k = map(int, input().split())
"""
for i in range(k):
  a2 = b + c
  b2 = c + a
  c2 = a + b
  a = a2
  b = b2
  c = c2
if pow((a-b)**2,1/2) >= 10**18:
  print("Unfair")
else:
  print(a-b)
"""
if abs(a-b) >= 10**18:
  print("Unfair")
else:
  if k%2==1:
    print(b-a)
  else:
    print(a-b)

Measured memory_bytes: 38384
def f(line)
  x1, y1, x2, y2, x3, y3 = line.split(" ").map(&:to_f)
  aa = (x1 - x2) ** 2 + (y1 - y2) ** 2
  bb = (x2 - x3) ** 2 + (y2 - y3) ** 2
  cc = (x3 - x1) ** 2 + (y3 - y1) ** 2
  a = aa ** 0.5
  b = bb ** 0.5
  c = cc ** 0.5
  s = heron(a, b, c)
  x = (aa * (bb + cc - aa) * x3 + bb * (cc + aa - bb) * x1 + cc * (aa + bb - cc) * x2) / (16 * s ** 2)
  y = (aa * (bb + cc - aa) * y3 + bb * (cc + aa - bb) * y1 + cc * (aa + bb - cc) * y2) / (16 * s ** 2)
  r = a * b * c / ((a + b + c) * (a + b - c) * (b + c - a) * (c + a - b)) ** 0.5
  sprintf("%.3f %.3f %.3f\n", x, y, r)
end

def heron(aa, b, c)
  s = (aa + b + c) / 2
  (s * (s - aa) * (s - b) * (s - c)) ** 0.5
end

gets.to_i.times { puts f(gets) }

Measured memory_bytes: 6228
#include <cstdio>
#include <cstring>
#define mod 100000
int n, m, s;
int dp[3001][50];
int main() {
    while (scanf("%d%d%d",&n,&m,&s)) {
        if (!n&&!m&&!s) break;
        memset(dp,0,sizeof(dp));
        dp[0][0]=1;
        for (int i=1; i<=m; i++) {
            for (int j=n*n; j>0; j--) {
                for (int k=s; k>=i; k--) {
                    dp[k][j]=(dp[k][j]+dp[k-i][j-1])%mod;
                }
            }
        }
        printf("%d\n",dp[s][n*n]);
    }
}

Measured memory_bytes: 1344
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N;
  cin >> N;
  vector<int> W(N + 1);
  REP1(i, N) cin >> W[i];
  int ans = 1e9;
  for (int t = 1; t < N; ++t) {
    int sum1 = 0, sum2 = 0;
    for (int i = 1; i <= t; ++i) sum1 += W[i];
    for (int i = t + 1; i <= N; ++i) sum2 += W[i];
    ans = min(ans, abs(sum1 - sum2));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys


while True:
    n, r = map(int, sys.stdin.readline().split())
    if n == 0 and r == 0:
        break
    shuffle = []
    for i in xrange(r):
        shuffle.append(map(int, sys.stdin.readline().split()))
    shuffle.reverse()
    pile = range(n)
    for s in shuffle:
        pile[s[0] + s[1] - 1:s[0] + s[1] - 1] += pile[:s[1]]
        pile = pile[s[1]:]
#        print pile
    print len(pile) - pile.index(0)

"""10 9 8 7 6 5 4 3 2 1
1 10 9 8 7 6 5 4 3 2
4 3 2 1 10 9 8 7 6 5

0 1 2 3 4 5 6 7 8 9
3 4 5 6 7 8 9 0 1 2
4 5 6 7 8 9 0 1 2 3

5 4 3 2 1
3 5 4 2 1
4 3 5 2 1

0 1 2 3 4
1 2 0 3 4
2 0 1 3 4"""

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

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

    int a, b, c;
    
    for(a = n; a >= 0; a--){
        for(b = n - a; b >= 0; b--){
            for(c = n - a - b; c >= 0; c--){
                if(10000*a + 5000 * b + 1000 * c == y and a + b + c == n){
                    printf("%d %d %d\n", a, b, c);
                    return 0;
                }
            }
        }
    }

    printf("-1 -1 -1\n");
    return 0;
}

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

using namespace std;

int main(){
    int n, l;
    cin >> n >> l;
    vector<int> a(n);
    for(auto&& i : a){
        cin >> i;
    }
    for(int i = 1; i < n; i++){
        if(l <= a[i] + a[i - 1]){
            cout << "Possible\n";
            for(int j = 0; j < i - 1; j++){
                cout << j + 1 << "\n";
            }
            for(int j = n - 1; j >= i; j--){
                cout << j << "\n";
            }
            return 0;
        }
    }
    cout << "Impossible\n";
}

Measured memory_bytes: 1280
n = int(input())
T,A = map(int,input().split())
h = list(map(int,input().split()))

res = float("inf")
ans = 0

for i in range(n):
    t = T - h[i]*0.006
    #print(t)
    if abs(t-A) < abs(res-A):
        res = t
        ans = i+1

print(ans)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int k, n; cin >> k >> n;
  vector<int> v(n+1);
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  v[n] = k + v[0];

  int Max = -1;
  for(int i = 0; i < n; i++){
    Max = max(Max, abs(v[i+1] - v[i]));
  }
  cout << k - Max << endl;

  return 0;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    s = S()
    ans = [0, 0]
    for si in s:
        if si == "N":
            ans[0] |= 1
        elif si == "W":
            ans[1] |= 1
        elif si == "S":
            ans[0] |= 2
        else:
            ans[1] |= 2
    if ans[0] in [0, 3] and ans[1] in [0, 3]:
        print("Yes")
    else:
        print("No")
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 38576
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int Q = sc.nextInt();
		int[] l = new int[m];
		int[] r = new int[m];
		for(int i = 0; i < m; i++) {
			l[i] = sc.nextInt() - 1;
			r[i] = sc.nextInt() - 1;
		}
		int[] p = new int[Q];
		int[] q = new int[Q];
		for(int i = 0; i < Q; i++) {
			p[i] = sc.nextInt() - 1;
			q[i] = sc.nextInt() - 1;
		}
		// x[i][j]：区間[i, j]を走る電車の個数
		int[][] x = new int[n][n];
		for(int i = 0; i < m; i++) x[l[i]][r[i]]++;
		// query[i][j]：区間[i, i]〜区間[i, j]を走る電車の個数
		int[][] query = new int[n][n];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				for(int k = i; k <= j; k++) {
					query[i][j] += x[i][k];
				}
			}
		}
		for(int i = 0; i < Q; i++) {
			int cnt = 0;
			for(int j = p[i]; j <= q[i]; j++) {
				if(p[i] == 0) cnt += query[j][q[i]];
				else cnt += query[j][q[i]] - query[j][p[i] - 1];
			}
			System.out.println(cnt);
		}
	}
}


Measured memory_bytes: 162572
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)

int main(){
    string S;
    cin >> S;
    int index = -1;
    bool Flag1=false, Flag2=false, Flag3=true;
    if(S[0]=='A') Flag1 = true;
    string subS = S.substr(2,S.size()-3);
    if(string(subS).find('C') != string::npos){
        Flag2 = true;
        index = string(subS).find('C')+2;
        //cout << subS<< index << endl;
    }
    rep(i,1,S.size()){
        if(i==index) continue;
        if(isupper(S[i]))
            Flag3=false;
    }
    if(Flag1 && Flag2 && Flag3) cout << "AC" <<endl;
    else cout << "WA" << endl;
    //cout << Flag1 << Flag2 << Flag3 << endl;
}
   

Measured memory_bytes: 256
N=int(input())
S=input()
ans=0
for i in range(1,N):
 ct=0
 ansa=0
 for j in range(N-i):
  if S[j]==S[j+i]:
   ct+=1
   ansa=max(ct,ansa)
  else:
   ct=0
 ans=max(ans,min(ansa,i))
print(ans)

Measured memory_bytes: 41692
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define MOD 1000003
#define INF 1000000005
#define mp make_pair
#define pb push_back
#define ss second
#define ff first
#define endl '\n'
#define pl cout<<endl;
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); }
const long long INFll=1ll*INF*INF;
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define debug(x) cout << x << endl;
#define sz(a) int((a).size())
int mul(int a, int b,int mod = MOD) {
	return int(a * 1ll * b % mod);
}
int norm(int a,int mod = MOD) {
	while(a >= mod) a -= mod;
	while(a < 0) a += mod;
	//a = (a%mod+mod)%mod;
	return a;
}
int powmod(int x,int y,int mod = MOD){
	int res = 1;
	while(y>0)
	{
		if(y&1)
			res = mul(res,x,mod);
		x = mul(x,x,mod);
		y=y>>1;
	}
	return res;
}
int inv(int a,int mod = MOD) {
	return powmod(a, mod - 2);
}	

int main() {


	int n,k;
	cin>>n>>k;
	vector<int> h(n+1),dp(n+1);
	for(int i=1;i<=n;i++)
	{
		cin>>h[i];
	}	
	dp[1] = 0;
	for(int i=2;i<=n;i++)
	{
		dp[i] = INF;
		for(int j=i-1;j>=max(1,i-k);j--)
			dp[i] = min(dp[i],dp[j]+abs(h[i] - h[j]));
	}
	cout<<dp[n]<<endl;
	return 0;
}

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;

  if( a+b > c+d ){
    cout << "Left" << endl;
  }
  else if( a+b == c+d ){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Right" << endl;
  }
  
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

bool is_integer(double x) {
  if (floor(x) == ceil(x)) return true;
  else return false;
}

int main() {
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  rep(i, n) rep(j, d) cin >> x[i][j];
  int cnt = 0;
  for (int i = 0; i < n-1; i++) {
    for (int j = i+1; j < n; j++) {
      int D = 0;
      for (int k = 0; k < d; k++) {
        int dx = x[i][k] - x[j][k];
        D += dx * dx;
      }
      if (is_integer(sqrt(D))) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#import sys
MOD = 10 ** 9 + 7
#input = sys.stdin.readline
import math

import itertools

#import bisect

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]
def main():
    n=int(input())
    s=list(map(str,input()))
    temp=0
    count=0
    for i in range(n):
        if s[i]=="A":
            temp=1
        elif temp==1 and s[i]=="B":
            temp+=1
        elif temp==2 and s[i]=="C":
            temp=0
            count+=1
        else:
            temp=0
    print(count)




if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 5e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

ll n, q, c[N], Fen[N], last[N], l[N], r[N], ans[N];
vector<ll> vec[N];
void Add(ll x, ll val) {
	x ++;
	for (++ x; x < N; x += x & -x) Fen[x] += val;
}
ll Get(ll x) {
	ll res = 0;
	x ++;
	for (++ x; x; x ^= x & -x) res += Fen[x];
	return res;
}
ll Get(ll l, ll r) {
	return Get(r) - Get(l - 1);
}
int main () {
	ios::sync_with_stdio(0), cin.tie(0);
 	cin >> n >> q;
 	for (int i = 1; i <= n; i ++) {
 		cin >> c[i];
	 }
	 for (int i = 1; i <= q; i ++) {
		cin >> l[i] >> r[i];
		vec[r[i]].pb(i);
	 }
	 for (int i = 1; i <= n; i ++) {
	 	if (last[c[i]]) Add(last[c[i]], -1);
	 	last[c[i]] = i;
	 	Add(i, 1);
	 	for (auto id : vec[i]) {
	 		ans[id] = Get(l[id], N - 5);
	 		
		}
	 }
	 for (int i = 1; i <= q; i ++) {
	 	cout << ans[i] << '\n';
	 }
 	
}

Measured memory_bytes: 48840
import sys
sys.setrecursionlimit(10**5)
N, X = map(int,input().split())
l = [1]
for i in range(N):
    l.append(2*l[-1]+3)
d = {}
def f(n,x):
    if (n,x) in d:
        return d[(n,x)]
    if n == 0:
        ans = 1
    elif x == 1:
        ans = 0
    elif x <= l[n-1]+1:
        ans = f(n-1,x-1)
    elif x == l[n-1]+2:
        ans = f(n-1,l[n-1])+1
    elif x <= 2*l[n-1]+2:
        ans = f(n-1, l[n-1])+1+f(n-1, x-l[n-1]-2)
    else:
        ans = 2*f(n-1, l[n-1])+1
    d[(n,x)] = ans
    return ans
print(f(N, X))

Measured memory_bytes: 9188
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	int N;
	cin >> N;
	multiset<ll> mst;
	set<ll> st;
	REP(i, N) {
		ll A;
		cin >> A;
		mst.insert(A);
		st.insert(A);
	}
	ll x = 0, y = 0;
	for(auto itr = st.rbegin(); itr != st.rend(); itr++){
		if (mst.count(*itr) >= 4 && x == 0) {
			x = y = *itr;
		}
		if (mst.count(*itr) >= 2 && x == 0) {
			x = *itr;
		}
		if (mst.count(*itr) >= 2 && x != *itr && y == 0) {
			y = *itr;
		}
		if (x != 0 && y != 0) break;
	}
	cout << x*y << endl;

	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
    int n,k;
    cin>>n>>k;
    vector<int>a(n);
    vector<int>v;
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    ll sum=0;
    for (int i = 0; i < n; i++)
    {
        v.push_back(sum);
        sum+=a[i];
    }
    v.push_back(sum);
    vector<int>w;
    for (int i = 0; i < v.size(); i++)
    {
        for (int j = i+1; j < v.size(); j++)
        {
            w.push_back(v[j]-v[i]);
        }
        
    }
   // cerr<<w.size()<<endl;
    sort(ALL(w));
  //  show(w);
    ll ans=0;
    for (int i = 40; i >= 0; i--)
    {   
        int cnt=0;
        ll s=ans+(1LL<<i);
       // cerr<<s<<" ";
        for (int j = 0; j < w.size(); j++)
        {
           
           
           if((s&w[j]) == s){
               cnt++;
           }
        }
        if(cnt>=k) ans=s;
        
    }
    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 6524
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using static System.Console;

namespace ABC120A
{
    static class Program
    {
        static void Main(string[] args)
        {
            var line = ReadLine().SplitTryParseToList<int>();

            var a = line[0] * line[2] <= line[1] ? line[2] : (int)(line[1] / line[0]);

            WriteLine(a);
        }

        public static T TryParse<T>(this String input)
        {
            try
            {
                var converter = TypeDescriptor.GetConverter(typeof(T));
                if (converter != null)
                {
                    return (T)converter.ConvertFromString(input);
                }
                else
                {
                    throw new InvalidCastException("");
                }
            }
            catch
            {
                throw new InvalidCastException(typeof(T) + " is not supported.");
            }
        }

        public static List<T> SplitTryParseToList<T>(this String input)
        {
            return input.Split().Select(n => n.TryParse<T>()).ToList();
        }

        public static List<T> ListSwap<T>(this List<T> list, Int32 index1, Int32 index2)
        {
            var t = list[index1];
            list[index1] = list[index2];
            list[index2] = t;
            return list;
        }

        public static List<Tuple<T, int>> DuplicateCount<T>(this IEnumerable<T> list)
        {
            return list
                .GroupBy(i => i)
                .Where(g => g.Any())
                .Select(g => Tuple.Create(g.Key, g.Count()))
                .ToList();
        }
        public static List<Tuple<T, int>> DuplicateSort<T>(this IEnumerable<Tuple<T, int>> list)
        {
            return list.OrderByDescending((x) => x.Item2).ToList();
        }
        public static List<T> ReadLineOne<T>(int n)
        {
            var list = new List<T>();
            foreach (var i in Enumerable.Range(1, n))
            {
                list.Add(Console.ReadLine().TryParse<T>());
            }
            return list;
        }
        public static void PrintAll<T>(this IEnumerable<T> list)
        {
            foreach (var i in list)
            {
                Console.Write($"{i} ");
            }

            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 14432
#include <stdlib.h>
#include<iostream>
#include<bits/stdc++.h>
#include<cmath>
#define ll long long
const ll INF=0x3f3f3f3f;
#define mod 1000003
using namespace std;
//priority_queue
const ll Maxn=1e5;
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
ll f[1000004];
ll kc(ll a,ll b)
{
    ll c=1;
    while(b)
    {
        if(b&1)c=(c*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return c;
}
int main()
{f[0]=1;
   for(int i=1;i<1000003;i++)
    f[i]=(f[i-1]*i)%mod;
   int t;
   cin>>t;
   while(t--)
   {
       ll x,d,n;
       cin>>x>>d>>n;
       if(d){
       x=x*kc(d,mod-2)%mod;
     //  cout<<x<<endl;
       if((x+n-1)/mod-(x-1)/mod>=1)cout<<0<<endl;
       else {

        cout<<f[(x+n-1)%mod]*kc(f[(x-1)%mod],mod-2)%mod*kc(d,n)%mod<<endl;
       }}
       else{

        cout<<kc(x,n)<<endl;
       }
   }
}



Measured memory_bytes: 8704
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
signed main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int l=0,r=n-1;
	int ans=0;
	while (1){
		while (s[l]=='R' && l<n)  l++;
		while (s[r]=='W' && r>=0)  r--;
		if (l==r+1){
			cout<<ans;
			re 0;
		}
		swap(s[l],s[r]),ans++;
	} 
	re 0;
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
string s,t;
int main()
{
	 cin>>s>>t;
	 if(s.size()+1!=t.size())cout<<"No";
	 else 
	 {
	 	for(int i=0;i<=s.size()-1;i++)
	 		if(s[i]!=t[i])
	 		{
	 			cout<<"No";
	 			return 0;
	 		}
	 	cout<<"Yes";
	 }
	
}


Measured memory_bytes: 3636
#pragma GCC optimize ("Ofast", "unroll-loops", "loop-nest-optimize")

#include <bits/stdc++.h>

#define REP(i, n) REPI(i, 0, n)
#define REP1(i, n) REPI(i, 1, n)
#define REPI(i, init, n) for(int i = init; i < n; i++)
#define MS(arr, val) memset(arr, val, sizeof(arr))
#define SZ(x) (x).size()
#define ALL(x) (x).begin(), (x).end()
#define EB emplace_back
#define UB upper_bound
#define LB lower_bound
#define FS first
#define SC second

#ifdef __WIN32__
inline size_t fread_unlocked(void *_buf, int _sz, int _cnt, FILE *_stream)
{
	return fread(_buf, _sz, _cnt, _stream);
}//fread_unlocked
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;
typedef long double LDB;
//typedef pair<int, int> P;

char buf[100000];

inline char gc()
{
	static char *st = buf, *ed = buf;

	if (st >= ed)
	{
		st = buf;
		ed = st + fread_unlocked(buf, 1, sizeof(buf), stdin);

		if (st == ed) return EOF;
	}//if

	return *(st++);
}//gc

template<class T>
inline bool rit(T &_a)
{
	char _c = gc();
	bool neg = false;
	for (; _c < '0' || _c > '9'; _c = gc())
	{
		if (_c == EOF) return false;
		if (_c == '-') neg = true;
	}//for

	for (_a = 0; _c >= '0' && _c <= '9'; _c = gc())
		_a = _a * 10 + _c - '0';

	if (neg) _a = -_a;

	return true;
}//rit

template<class S, class ...T>
inline bool rit(S &_a, T&... _b)
{
	if (!rit(_a)) return false;
	return rit(_b...);
}//rit

//============================================================================//

const int MAX_N = 3e3 + 10;
//const int INF8 = 0x3f;
//const int INF32 = 0x3f3f3f3f;
//const int MOD = 1e9 + 7;
//const int MOD = 46337; //maximum prime int for multiplying
//const LL MOD = 2999999929; //maximum prime LL for multiplying
//const LL INF64 = 0x3f3f3f3f3f3f3f3f;
//const DB PI = acos(-1);

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	string s;
	bool vis[30] = {};
	
	cin >> s;
	for (auto x : s) vis[x - 'a'] = true;
	
	char c = -1;
	REP(i, 26)
	{
		if (!vis[i])
		{
			c = i + 'a';
			break;
		}//if
	}//REP i
	
	if (c != -1) cout.put(c);
	else cout << "None";
	
	return 0;
}//main


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF 1000000000
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOREACH(i, v) for(auto i = v.begin(); i != v.end(); i++)
#define P pair<int, int>

using namespace std;
using ll = long long;

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

struct edge {int from, to, cost; };

void solve(){
    ll n = 0;
    cin >> n;
    string s = to_string(n);
    if(n >= 10){
        int temp = 0;
        for(int i = 0; i < s.length(); i++){
            temp += s[i]-'0';
        }
        cout << max( (int)((s.length()-1)*9+(s[0]-'1')), temp) << endl;
    }else{
        cout << n << endl;
    }
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,string
from collections import defaultdict as D
from functools import reduce
import numpy as np
from numba import njit
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

N,D = LI()
_XY = [LI() for _ in range(N)]

XY = np.array(_XY)
#C = np.zeros(N + 1)
# print(XY)

# print(np.linalg.norm(XY[1]-XY[0]))

count = 0
for XiYi in XY:
    if (XiYi[0]**2 + XiYi[1]**2) <= D**2:
        count += 1
print(count)

Measured memory_bytes: 131440
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        y = (4 * h * n - N * (h + n))
        if 0 < y:
            x = (N * h * n)
            w, mod = divmod(x, y)
            if mod == 0:
                print(h, n, w)
                exit()

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <string>
#include <utility>

using namespace std;
int h,w,n;
char Field[51][51];
char field[51][51];
int cnt=0;
bool d[51][51];

bool search(){
	int sum=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(field[i][j]!='.') sum++;
		}
	}
	while(sum){
		for(int j=0;j<w;j++){
			for(int i=h-2;i>=0;i--){
				if(field[i][j]!='.'){
					char c=field[i][j];
					field[i][j]='.';
					for(int k=i;k<h;k++){
						if(k+1==h||field[k+1][j]!='.'){
							field[k][j]=c;
							break;
						}
					}
				}
			}
		}
	memset(d,0,sizeof(d));
	int dec=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(field[i][j]=='.') continue;
			int cnt=0;
		for(int k=i;k<h;k++){
			if(field[i][j]==field[k][j]) cnt++;
			else break;
		}
		if(cnt>=n){
			for(int k=i;k<h;k++){
				if(field[i][j]==field[k][j]) d[k][j]=true;
				else break;
			}
		}
		cnt=0;
		for(int k=j;k<w;k++){
			if(field[i][j]==field[i][k]) cnt++;
			else break;
		}
		if(cnt>=n){
			for(int k=j;k<w;k++){
				if(field[i][j]==field[i][k]) d[i][k]=true;
				else break;
			}
		}
	}
}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(d[i][j]) field[i][j]='.',dec++;
		}
	}
	if(dec==0) return false;
	sum-=dec;
	}		
return true;
}

int main(){
	cin>>h>>w>>n;
	bool ans=false;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>> Field[i][j];
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			for(int k=0;k<h;k++){
				for(int l=0;l<w;l++){
					field[k][l]=Field[k][l];
			}
			}
			cnt++;
					swap(field[i][j],field[i][j+1]);
					ans|=search();
			if(ans) break;
		}
		if(ans) break;
	}
	if(ans) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 1168