akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<vector>
#include<math.h>
#include<algorithm>
#include<string>
#include<string>
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> >
#define vb vector<bool> 
#define vvb vector<vector<bool> >
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b:i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define INF 1123456789012345
using namespace std;

int main(){
	string s; cin>>s;
	vb table(26,false);
	rep(i,s.size()){
		if(table[s[i]-'a']){
			cout<<"no"<<endl;
			return 0;
		}table[s[i]-'a']=true;
	}cout<<"yes"<<endl;
	return 0;
}

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

int main(void){
  int w[10];
  string str;

  while(cin >> str){
    int num = 10;
    for(int i = 0 ; i < num ; i++) w[i] = str[i] - '0';

    int a[10] = {0};
    while(num > 1){
      for(int i = 1 ; i < num ; i++){
        a[i-1] = (w[i-1] + w[i]) % 10;
      }  
      for(int i = 0 ; i < num ; i++) w[i] = a[i];
      num--;
    }
    
    cout << a[0] << endl;
  }

  return 0;
}

Measured memory_bytes: 1180
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    String line = sc.next();
    int red = 0;
    for(int i = 0;i < num;i++){
      if(String.valueOf(line.charAt(i)).equals("R")){
        red++;
      }
    }
    int change = 0;
    for(int i = 0;i < red;i++){
      if(String.valueOf(line.charAt(i)).equals("W")){
        change++;
      }
    }
    System.out.println(change);
  }
}

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

int n,ba;
long long nep[100100];

main()
{
	nep[0]=1;
	scanf("%d %d",&n,&ba);
	for(int i=0;i<n;i++)
	{
		long long a,b;
		scanf("%lld %lld",&a,&b);
		for(int j=ba+10;j>=0;j--)
		{
			if(nep[j]&&j+a<=ba)
			{
				if(j==0)
				{
					nep[j+a]=max(nep[j+a],b);
				}
				else
				{
					nep[j+a]=max(nep[j+a],nep[j]+b);
				}
			}
		}
	}
	long long ans=0;
	for(int i=0;i<=ba;i++)
	{
		ans=max(ans,nep[i]);
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 1024
N,L=map(int,input().split())
T=[]
for i in range(N):
    T.append(L+(i+1)-1)    
output=0
if min(T)>0:
    for j in T:
        output=output+j
    output=output-min(T)
elif max(T)<0:
    for j in T:
        output=output+j
    output=output-max(T)
else:
    for j in T:
        output=output+j
print(output)
 

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>


using namespace std;

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

	if (a==(b+c)) {
		cout << "Yes" << endl;
	}
	else {
		if (b == (a + c)) {
			cout << "Yes" << endl;
		}
		else {
			if (c == (a + b)) {
				cout << "Yes" << endl;
			}
			else {

				cout << "No" << endl;
			}
		}

	}


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"
 
int32_t main()
{
	fast;
	string s;
	cin>>s;
	if(s=="Sunny")
	{
		cout<<"Cloudy"<<endl;
	}
	if(s=="Cloudy")
	{
		cout<<"Rainy"<<endl;	
	}
	if(s=="Rainy")
	{
		cout<<"Sunny"<<endl;
	}
	return 0;
}

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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll a; cin >> a;
    cout << a+a*a+a*a*a << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 3552
#include <cstdio>

int main()
{
	int h,w;
	scanf("%d %d",&h,&w);

	int a[h][w];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			scanf("%d",&a[i][j]);
		}
	}

	int from[h*w][2],to[h*w][2],tmp=0;
	for(int i=0;i<h;i++){
		int start,def;
		if(i%2){
			start=w-1; def=-1;
		}else{
			start=0; def=1;
		}

		for(int j=start;j>=0 && j<w;j+=def){
			if(j+def>=w || j+def<0) break;
			if(a[i][j]%2){
				a[i][j]--; a[i][j+def]++;
				from[tmp][0]=i; from[tmp][1]=j;
				to[tmp][0]=i; to[tmp][1]=j+def;
				tmp++;
			}
		}

		if(i==h-1) break;

		if(def==-1 && a[i][0]%2){
			a[i][0]--; a[i+1][0]++;
			from[tmp][0]=i; from[tmp][1]=0;
			to[tmp][0]=i+1; to[tmp][1]=0;
			tmp++;
		}

		if(def==1 && a[i][w-1]%2){
			a[i][w-1]--; a[i+1][w-1]++;
			from[tmp][0]=i; from[tmp][1]=w-1;
			to[tmp][0]=i+1; to[tmp][1]=w-1;
			tmp++;
		}

	}

	printf("%d\n",tmp);
	for(int i=0;i<tmp;i++){
		printf("%d %d %d %d\n",from[i][0]+1,from[i][1]+1,to[i][0]+1,to[i][1]+1);
	}

	return 0;
}


Measured memory_bytes: 4992
from math import gcd
def main():
    K = int( input())
    ans = 0
    GCD = [0]*201
    for i in range(1,K+1):
        for j in range(1, K+1):
            GCD[gcd(i,j)] += 1
    for i in range(1, K+1):
        for k in range(1, K+1):
            ans += gcd(i, k)*GCD[i]
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 9128
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
using namespace std;

int main()
{
    int n, k, x, y;
    int ans;
    
    cin >> n >> k >> x >> y;
    
    if(n <= k) {
        ans = n * x;
    } else {
        ans = k * x + (n - k) * y;
    }
    
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
def main():
	n, m = list(map(int, input().split()))
	rqs = [list(map(int, input().split())) for _ in range(m)]

	rqs.sort(key = lambda x: x[1])

	b = -1
	cnt = 0
	
	for x in rqs:
		if b < x[0]:
			b = x[1] - 1
			cnt += 1

	print(cnt)

if __name__ == '__main__':
	main()

Measured memory_bytes: 29088
n = int(input())
light = 1
a = [0]
answer = 0
for _ in range(n):
    a.append(int(input()))
while True:
    light = a[light]
    answer += 1
    if light == 2:
        break
    if light == a[light]:
        answer = -1
        break
    if answer == n:
        answer = -1
        break
print(answer)

Measured memory_bytes: 7080
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<String,Integer> m = new HashMap<>();
        for(int i=0;i<N;i++){
            String S = sc.next();
            if(m.get(S)==null){
                m.put(S, 1);
            }else{
                int tmp = m.get(S);
                m.put(S, ++tmp);
            }
        }
        System.out.println(m.size());
    }
}

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

int num[100010];

int main(){
	int n, cnt = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		scanf("%d", &num[i]);
		if(num[i]%2)cnt++;	
	}
	if(cnt%2) cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}
	

Measured memory_bytes: 768
#include <algorithm>
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(c) c.begin(), c.end()
#define endl "\n"
#define sz(u) (int)(u.size())
#define L(x)(2*x)
#define R(x)(2*x+1)
#define M(x,y)((x+y)/2)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	int n,m;
	cin>>n>>m;
	vector<int> co[n+1];
	vector<int> bk[n+1];
	int indeg[n+1];
	memset(indeg,0,sizeof(indeg));
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		co[a].PB(b);
		bk[b].PB(a);
		indeg[b]++;
	}
	queue<int> q;
	for(int i=1;i<=n;i++)
		if(indeg[i]==0)
			q.push(i);
	bool vis[n+1];
	memset(vis,0,sizeof(vis));
	vector<int> tps;
	while(!q.empty()){
		int x=q.front();
		q.pop();
		for(auto y:co[x]){
			if(vis[y])
				continue;
			indeg[y]--;
			if(indeg[y]==0)
				q.push(y);
		}
		vis[x]=1;
		tps.PB(x);
	}
	int dp[n+1];
	memset(dp,0,sizeof(dp));
	int maxx=0;
	for(auto x:tps){
		for(auto y:bk[x])
			dp[x]=max(dp[x],dp[y]+1);
		maxx=max(maxx,dp[x]);
	}
	cout<<maxx;
		
		
}


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

int main() {
  int A, B;
  string S, T, U;
  cin >> S >> T >> A >> B >> U;
  
  cout << (S == U ? A - 1 : A) << " " << (T == U ? B - 1 : B) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  string s;
  cin>>s;
  if(s.size()%2){
    cout<<"No";
  }else{
    bool f=false;
    for(int i=0;i<s.size();i+=2){
      if(s[i]!='h'||s[i+1]!='i'){
        f=true;
      }
    }
    if(f)cout<<"No";
    else cout<<"Yes";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;

template<class T> inline T re(){
	T N = 0; char c = getchar(); bool neg = 0;
	for (; c < '0' || c > '9'; c = getchar()) neg |= c == '-';
	for (; c >= '0' && c <= '9'; c = getchar())
		N = (N<<3)+(N<<1) + c - '0';
	return neg ? -N : N;
}

const int N = 1e5 + 5;
int n;
int a[N];

int main(){
	n = re<int>();
	for (int i = 1; i <= n; i++)
		a[re<int>()] = i;
	for (int i = 1; i <= n; i++) printf("%d%c", a[i], " \n"[i==n]);
	return 0;
}


Measured memory_bytes: 1152
n = gets.to_i
a = gets.strip.split.map(&:to_i)
b = gets.strip.split.map(&:to_i)

fuckin_enemies = 0

(1..n).reverse_each do |i|
  v = b.pop
  if(a[i] <= v)
    fuckin_enemies = fuckin_enemies + a[i]
    if(a[i-1] <= v - a[i])
      fuckin_enemies = fuckin_enemies + a[i-1]
      a[i-1] = 0
    else
      fuckin_enemies = fuckin_enemies + (v - a[i])
      a[i-1] = a[i-1] - (v - a[i])
    end
  else
    fuckin_enemies = fuckin_enemies + v
  end
end
puts fuckin_enemies


Measured memory_bytes: 18464
# -*- coding: utf-8 -*-

import sys
from collections import deque

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

S = input()

que = deque(S)
is_rev = 0
for _ in range(INT()):
    q = input().split()
    if q[0] == '1':
        is_rev = 1 - is_rev
    else:
        _, a, c = q
        a = int(a)
        if (a == 1) ^ (not is_rev):
            que.append(c)
        else:
            que.appendleft(c)
ans = ''.join(que)
if is_rev:
    ans = ans[::-1]
print(ans)


Measured memory_bytes: 8544
#include <iostream>
#include <algorithm>

using namespace std;

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

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define endl "\n" 
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    double r; cin >> r;
    double ans = r * 2 * M_PI;
    printf("%.20f\n", ans);

    return 0;
}


Measured memory_bytes: 3808
n, m = map(int, input().split())
bridges = []
island_connection = [1] * n
unconfortable = (n * (n - 1)) // 2
unconfortable_list = [unconfortable]


class UnionFind():
    def __init__(self, n):
        self.parent = [-1 for _ in range(n)]
        # 正==子: 根の頂点番号 / 負==根: 連結頂点数

    def find(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return False
        else:
            if self.size(x) < self.size(y):
                x, y = y, x
            self.parent[x] += self.parent[y]
            self.parent[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        x = self.find(x)
        return -self.parent[x]

    def is_root(self, x):
        return self.parent[x] < 0


connection = UnionFind(n)

for i in range(m):
    array = list(map(int, input().split()))
    array[0] -= 1
    array[1] -= 1
    bridges.append(array)

bridges = bridges[::-1]

for i, j in bridges:
    if connection.same(i,j) == 0:
        p = connection.size(i)
        q = connection.size(j)
        if p == 1 and q == 1:
            unconfortable -= 1
            connection.unite(i, j)
        else:
            unconfortable -= (p * q)
            connection.unite(i, j)
    unconfortable_list.append(unconfortable)

for i in range(1, m+1):
    print(unconfortable_list[-1-i])



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

using namespace std;

int main(void){
    int N;
    cin >> N;
    map<string, int> m;
    int total_time = 0;
    for(int i = 0; i < N; i++){
        string s;
        int t;
        cin >> s >> t;
        total_time += t;
        m[s] = total_time;
    }
    string X;
    cin >> X;
    cout << total_time - m[X] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <fstream>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef map<int, int> mii;
typedef map<int, string> mis;
typedef map<string, int> msi;
typedef set<int> si;
typedef set<ll> sl;
typedef map<ll, ll> mll;
typedef queue<int> qi;
typedef queue<ii> qii;
typedef vector<string> vs;
typedef pair<ll, ll> iil;
typedef vector<iil> viil;

#define pb push_back
#define mp make_pair
#define rep(i, n) for (int i = 0 ; i < n ; i++)
#define INF 1000000000

void solve() {
    int n, m;
    cin >> n >> m;
    vi adj[n];
    int el[n];
    rep(i, n) {
        cin >> el[i];
    }
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    int sm = 0;
    rep(i, n) {
        bool f = true;
        for (int a : adj[i]) {
            if (el[a] >= el[i]) {
                f = false;
            }
        }
        if (f) {
            sm++;
        }
    }
    cout << sm << endl;
}

void querySolve() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    solve();
    //querySolve();
}


Measured memory_bytes: 9152
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<queue>	

using namespace std;

namespace MyLib {
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long
}

using namespace MyLib;


int main() {
	int n;
	while (cin >> n, n) {
		int count = 0;
		for (int i = 1; i < n; i++)
			for (int j = i + 1; j < n; j++)
				if (j*(j + 1) / 2 - i*(i - 1) / 2 == n)
					count++;
		cout << count << endl;



	}
	return 0;

}

Measured memory_bytes: 1156
-- B
local a,b,c,d,e = io.read("n", "n", "n", "n", "n")
local tbl = {a,b,c,d,e}
table.sort(tbl, function(x,y)
    local rx = x % 10
    if rx == 0 then
        rx = 10
    end
    local ry = y % 10
    if ry == 0 then
        ry = 10
    end
    return rx > ry
end)

local tm = 0
for i=1, #tbl-1 do
    local r = 10 - tbl[i] % 10
    if r == 10 then
        r = 0
    end
    tm = tm + tbl[i] + r
end
tm = tm + tbl[#tbl]

print(tm)


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

bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; 

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}

void solve() 
{
    ll n;cin>>n;
    if(IsPrime(n)){cout<<1<<endl;return;}
    ll ans=0;
    map<ll,ll>m;
    for(ll i=2;i*i<=n;i++){
        while(n%i==0){
            m[i]++;
            n/=i;
        }
    }
    if(n!=1)m[n]=1;
    for(auto it:m){
        ans+=(sqrt(it.second*8+1)-1)/2;
    }
    cout<<ans<<endl;
}

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

Measured memory_bytes: 3672
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int a[3];
    
    rep(i, 3){
        scanf("%d", &a[i]);
    }
    
    qsort(a, 3, sizeof(int), up_comp);
    
    printf("%d", a[0]+a[1]);
    
    return 0;
}



Measured memory_bytes: 1712
use std::cmp::*;
use std::io::*;

mod enumeration {
    pub struct Enumeration {
        fact: Vec<u64>,
        finv: Vec<u64>,
        modulo: u64,
    }
    impl Enumeration {
        pub fn new(n: usize, modulo: u64) -> Enumeration {
            let mut fact: Vec<u64> = vec![1; n];
            let mut inv: Vec<u64> = vec![1; n];
            let mut finv: Vec<u64> = vec![1; n];
            for i in 2..n {
                fact[i] = fact[i - 1] * (i as u64) % modulo;
                inv[i] = modulo - (modulo / (i as u64)) * inv[(modulo as usize % i)] % modulo;
                finv[i] = inv[i] * finv[i - 1] % modulo;
            }
            Enumeration {
                fact: fact,
                finv: finv,
                modulo: modulo,
            }
        }
        pub fn c(&self, n: usize, k: usize) -> u64 {
            if n < k {
                return 0;
            }
            self.fact[n] * self.finv[n - k] % self.modulo * self.finv[k] % self.modulo
        }
    }
}
fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: u64 = itr.next().unwrap().parse().unwrap();
    let m: u64 = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();

    const MOD: u64 = 1_000_000_007;
    let e = enumeration::Enumeration::new((n * m) as usize, MOD);

    // x
    // 2点を固定する。
    // それ以外の選び方はn*m - 2 C k - 2
    // 大きさがxとなる　-> n - x通り * m * m

    let mut ans = 0;
    for x in 1..n {
        ans += x * (n - x) % MOD * m % MOD * m % MOD;
      ans %= MOD;
    }
    for x in 1..m {
        ans += x * (m - x) % MOD * n % MOD * n % MOD;
      ans %= MOD;
    }
    ans = ans * e.c((n * m) as usize - 2, k - 2) % MOD;
    println!("{}", ans);
}


Measured memory_bytes: 6728
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();

        int z = x*y;
        int w = 2*(x+y);

        System.out.printf("%d %d\n",z,w);
    }
}



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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 200005;
int n, u, v, dp[MX];
vi adj[MX];

ii dfs (int u, int p) {
	ii res(0, u);
	for (int v : adj[u])
		if (v != p)
			res = max(res, dfs(v, u));
	if (p != -1) res.fi++;
	return res;
}

int obtRes (int u) {
	if (dp[u] != -1) return dp[u];
	if (u == 0) return dp[u] = 0;
	if (u == 1) return dp[u] = 1;
	if (u == 2) return dp[u] = 0;
	return dp[u] = !obtRes(u-1) || !obtRes(u-2);
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	memset(dp, -1, sizeof(dp));
	
	cin >> n;
	for (int i = 1; i < n; i++) {
		cin >> u >> v;
		adj[u].pb(v);
		adj[v].pb(u);
	}

	if (obtRes(dfs(dfs(1, -1).se, -1).fi + 1)) cout << "First" << endl;
	else cout << "Second" << endl;

	return 0;
}


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

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

	int N;
	cin >> N;
	long long po = 1;
	while (N>1) {
		po *= N;
		if (po > 1000000007) {
			po %= 1000000007;
		}
		N--;
	}
	cout << po;
}

Measured memory_bytes: 256
from sys import stdin
#input=stdin.readline().strip()
input=[]
for i in range(4):
  input.append(stdin.readline().strip())

end_t=int(input[0].strip())
start_t=int(input[1].strip())
start_c=int(input[2].strip())
end_c=int(input[3].strip())
sum=0
if end_t>start_t:
  sum=start_t*start_c+(end_t-start_t)*end_c
else:
  sum=end_t*start_c
print(sum)

Measured memory_bytes: 3064
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	int i,n;cin>>n;
	vector<int>dp(n);
	for(i=1;i<n;i++){
		int b=i,p=0;
		while(b>0){
			if(b%2==1){p++;}
			b/=2;
		}
		dp[i]=dp[i%p]+1;
		//cerr<<dp[i]<<endl;
	}
	string X;cin>>X;
	REV(X);
	int p=0;
	for(auto c:X){
		if(c=='1'){p++;}
	}
	//cerr<<"p="<<p<<endl;
	llint ro=1,ri=1,wo=0,wi=0;
	for(i=0;i<n;i++){
		if(X[i]=='1'){wo+=ro;wi+=ri;wo%=p+1;if(p>1){wi%=p-1;}}
		ro*=2;ri*=2;ro%=p+1;if(p>1){ri%=p-1;}
	}
	vector<int>ans(n);
	ro=1,ri=1;
	for(i=0;i<n;i++){
		if(X[i]=='0'){ans[i]=dp[(wo+ro)%(p+1)]+1;}
		else if(p>1){ans[i]=dp[(wi-ri+p-1)%(p-1)]+1;}
		else{ans[i]=0;}
		ro*=2;ri*=2;ro%=p+1;if(p>1){ri%=p-1;}
	}
	REV(ans);
	for(i=0;i<n;i++){cout<<ans[i]<<endl;}
	return 0;
}


Measured memory_bytes: 5172
#include <stdio.h>
#include <limits.h>

int main(void)
{
	int n,i;
	long long int sum=0;
	int max = INT_MIN;
	int min=INT_MAX;
	int tmp;

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

}

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

int main()
{
    int a,b,d,r;
    double f;

    cin>>a>>b;

    d = a/b;
    r = a%b;

    f = (double)a/(double)b;

    cout<<d<<endl;
    cout<<r<<endl;

    cout<<setprecision(10)<<fixed;
    cout<<f<<endl;

    return 0;
}


Measured memory_bytes: 3284
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

long long A(long long n) {

	return;
}

int main(void) {
	long long a, b, c, k;
	int fa=0, fb=0, fc=0;
	scanf("%d %d %d %d", &a, &b, &c, &k);
	/*for (int i = 0; i < k; i++) {
		int tempa, tempb, tempc;
		tempa = b + c;
		tempb = a + c;
		tempc = a + b;
		a = tempa;
		b = tempb;
		c = tempc;
		if (a < 0)fa = 1;
		if (b < 0)fb = 1;
		if (c < 0)fc = 1;
	}*/
	if (k % 2 == 0) {
		long long ans = a - b;
		if (ans < -(long long)(1e18) || ans > (long long)(1e18)) {
			printf("Unfair\n");
		}
		else {
			printf("%lld\n", ans);
		}
	}
	else {
		long long ans = a - b;
		if (ans < -(long long)(1e18) || ans >(long long)(1e18)) {
			printf("Unfair\n");
		}
		else {
			printf("%lld\n", -ans);
		}
	}
	
	return 0;
}
//a_n-b_n = (b_(n-1)+c_(n-1)) - (a_(n-1)+c_(n-1)) = -(a_(n-1)-b_(n-1)) + 2c_(n-1)

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll dp[55][55];

ll c(int n, int r)
{
	if (n == r) return dp[n][r] = 1;
	if (r == 0)return dp[n][r] = 1;
	if (r == 1) return dp[n][r] = n;
	if (dp[n][r])return dp[n][r];
	return dp[n][r] = c(n - 1, r) + c(n - 1, r - 1);
}

int main()
{
	int N, P;
	cin >> N >> P;
	ll E = 0, O = 0;
	REP(i, N)
	{
		int a;
		cin >> a;
		if (a % 2 == 0)
		{
			E++;
		}
		else
		{
			O++;
		}
	}

	ll ans = 0;

	REP(e, E + 1)
	{
		for (ll o = P; o <= O; o += 2)
		{
			ans += c(E, e)*c(O, o);
		}
	}

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

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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N; cin >> N;
    string S; cin >> S;
    int ans = 1;
    for(int i = 1; i < N; i++){
        if(S[i] != S[i-1]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
def sumall(a):
    n = 0
    while a > 0:
        n += a % 10 
        a = a // 10
    return n
 
 
n, a, b = map(int, input().split())
 
c = [0 for i in range(n)]
for i in range(n):
    c[i] = sumall(i+1)
    
d = 0
for i in range(n):

    if a <= c[i] <= b:
        d += i+1
        
print(d)

Measured memory_bytes: 3060
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef unsigned long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

//---------------------------------------------


int main(void)
{
int n;
string s;

cin>>n;
cin>>s;
int ans =0;

rep(i,n-2)
{
if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ans++;
}   


cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	k = int(input())
	#b , c = tin()
	#s = input()
	if k % 2 == 0 or k%5 == 0:
		return -1
	amari = 0
	for i in range(mod*mod):
		amari += 7*pow(10, i, k)
		amari %= k
		if amari == 0:
			return i+1
			
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 9212
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";
 
ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}
 
 
int main(){
    fast;
 
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
    ll n;
    cin>>n;
    
    vlli a(n);
    forn(i,0,n)cin>>a[i];
    sort(all(a), greater<ll>());
    
    
    ll ans=0;
    forn(i, 1, n){
        ans+=a[i/2];
    }
    cout<<ans<<endl;
}

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

namespace codefestival_2016_final_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            string[,] s = new string[x[0], x[1]];
            for (int i = 0; i < x[0]; i++)
            {
                string[] a = Console.ReadLine().Split();
                for (int j = 0; j < x[1]; j++)
                {
                    s[i, j] = a[j];
                }
            }
            bool find = false;
            for (int i = 0; !find; i++)
            {
                for (int j = 0; j < x[1]; j++)
                {
                    if (s[i, j] == "snuke")
                    {
                        find = true;
                        Console.Write((char)(j + 65));
                        Console.WriteLine(i + 1);
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 13396
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

char a[10];
int main()
{
	scanf("%s", a);
	int len = strlen(a);
	for(int i = 0; i <= len - 1; i++)
	{
		if(a[i] == 'A' && a[i + 1] == 'C') {
			printf("Yes\n");
			break;
		}
		if(i == len - 1) printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {

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

		BigDecimal N =new BigDecimal(sc.nextLine());
		BigDecimal money =new BigDecimal(100);
		BigDecimal r = new BigDecimal("100");
		int con = 0;
		while (money.compareTo(N) < 0) {
			money =money.add(money.divide(r, RoundingMode.FLOOR));
			con++;
		}

		System.out.println(con);

	}
}

Measured memory_bytes: 36352
#include<iostream>
using namespace std;
int main() {
	int n, ans[3],m, dai[5];
	for (int x = 1; x <= 2; x++) {
		for (int i = 1; i <= 4; i++) {
			dai[i] = 0;
		}
		for (int i = 1; i <= 10; i++) {
			cin >> m;
			if (dai[1] <= m) {
				dai[3] = dai[2];
				dai[2] = dai[1];
				dai[1] = m;
				m = 0;
			}
			if (dai[2] <= m) {
				dai[3] = dai[2];
				dai[2] = m;
				m = 0;
			}
			if (dai[3] <= m) {
				dai[3] = m;
				m = 0;
			}
		}
		ans[x] = dai[1] + dai[2] + dai[3];
	}
	cout << ans[1] << " " << ans[2] << endl;
}


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

public class Main {
    static final int MOD = 998244353;

    public static void main(String args[]) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        int n = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        long k = in.nextLong();

        int[] fact = new int[n + 1];
        int[] inv = new int[n + 1];

        fact[0] = 1;

        for (int i = 1; i <= n; i++) {
            fact[i] = (int) ((1l * i * fact[i - 1]) % MOD);
        }

        for (int i = 0; i <= n; i++) {
            inv[i] = mod_pow(fact[i], MOD - 2);
        }

        if (a > b) {
            int temp = a;
            a = b;
            b = temp;
        }

        int[] c = new int[b];
        int cycleLength;

        for (int i = 0; i < b; i++) c[i] = -1;

        for (int i = 0; ; i++) {
            if (c[(int) (1l * i * a % b)] != -1) {
                cycleLength = i;
                break;
            }

            c[(int) (1l * i * a % b)] = i;
        }

        if (c[(int) (k % b)] == -1) {
            out.println(0);
        } else {
            int needA = c[(int) (k % b)];
            int needB = (int) ((k - 1l * needA * a) / b);

            int res = 0;

            while (needA <= n && needB >= 0) {
                if (needA <= n && needB <= n) res = (int) ((1l * res + 1l * comb(n, needA, fact, inv) * comb(n, needB, fact, inv)) % MOD);
                needA += cycleLength;
                needB = (int) ((k - 1l * needA * a) / b);
            }

            out.println(res);
        }

        out.close();
    }

    private static long comb(int n, int k, int[] fact, int[] inv) {
        return (long) fact[n] * inv[k] % MOD * inv[n - k] % MOD;
    }

    private static int mod_pow(int n, int k) {
        if (k == 0) return 1;

        int res = mod_pow(n, k >> 1);
        res = (int) ((1l * res * res) % MOD);

        if ((k & 1) > 0) res = (int) ((1l * res * n) % MOD);
        return res;
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f), 32768);
            st = null;
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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


Measured memory_bytes: 25940
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int m;
  cin >> m;
  cout << 48 - m << endl;
  return 0;
}


Measured memory_bytes: 256
data class Node(var parentNodeNum: Int = -1, var left: Pair<Int, Node>? = null, var right: Pair<Int, Node>? = null)

fun main(args: Array<String>) {
    val inputList = List(readLine()?.toInt() ?: return) {
        readLine()?.split(" ".toRegex())?.map(String::toInt) ?: listOf()
    }
    val nodeMap = mutableMapOf<Int, Node>()
    inputList.forEach { input ->
        val nodeNum = input[0]
        nodeMap.putIfAbsent(nodeNum, Node())
        nodeMap[nodeNum]?.let { node ->
            if (input[1] != -1) {
                val leftNum = input[1]
                nodeMap.putIfAbsent(leftNum, Node())
                nodeMap[leftNum]?.let { left ->
                    left.parentNodeNum = nodeNum
                    node.left = leftNum to left
                }
            }
            if (input[2] != -1) {
                val rightNum = input[2]
                nodeMap.putIfAbsent(rightNum, Node())
                nodeMap[rightNum]?.let { right ->
                    right.parentNodeNum = nodeNum
                    node.right = rightNum to right
                }
            }
        }
    }
    val tree = Tree(nodeMap)
    tree.preorderTreeWalk()
    tree.inorderTreeWalk()
    tree.postorderTreeWalk()
}

class Tree(private val nodeMap: Map<Int, Node>) {
    val root = nodeMap.toList().first { it.second.parentNodeNum == -1 }

    fun preorderTreeWalk() {
        println("Preorder")
        preorderTreeWalk(root)
        println()
    }

    private fun preorderTreeWalk(node: Pair<Int, Node>?) {
        if (node != null) {
            print(" ${node.first}")
            preorderTreeWalk(node.second.left)
            preorderTreeWalk(node.second.right)
        }
    }

    fun inorderTreeWalk() {
        println("Inorder")
        inorderTreeWalk(root)
        println()
    }

    private fun inorderTreeWalk(node: Pair<Int, Node>?) {
        if (node != null) {
            inorderTreeWalk(node.second.left)
            print(" ${node.first}")
            inorderTreeWalk(node.second.right)
        }
    }

    fun postorderTreeWalk() {
        println("Postorder")
        postorderTreeWalk(root)
        println()
    }

    private fun postorderTreeWalk(node: Pair<Int, Node>?) {
        if (node != null) {
            postorderTreeWalk(node.second.left)
            postorderTreeWalk(node.second.right)
            print(" ${node.first}")
        }
    }
}


Measured memory_bytes: 29828
r, c = map(int, input().split())
out = [[]] * (r + 1)
sumrow = [0 for i in range(c + 1)]
for line in range(0, r):
    vals = list(map(int, input().split()))
    vals.append(sum(vals))
    for itm in vals[:-1]:
        print(itm, end = ' ')
    print(vals[-1])
    for ids in range(c + 1):
        sumrow[ids] += vals[ids]
for itm in sumrow[:-1]:
    print(itm,end = ' ')
print(sumrow[-1])



Measured memory_bytes: 5632
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int A = int.Parse(input[0]);
		int B = int.Parse(input[1]);
		int C = int.Parse(input[2]);
		int K = int.Parse(input[3]);
		int Ans = 0;

   		Ans = A * 1 + B * 0 - (K-A-B) * 1;        

        if(K <= A + B)
        {
		  Ans = A * 1 + (K-A) * 0;
        }

        if(K <= A)
        {
          Ans = K * 1;
        }

    Console.WriteLine(Ans);

	}
}

Measured memory_bytes: 27536
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 6005, M = MX/2;
typedef v(double) vd;

int main() {
  int n;
  scanf("%d",&n);

  vd dp(MX);
  dp[M] = 1;
  rep(i,n) {
    vd e(MX); swap(dp,e);
    double p;
    cin>>p;
    double q = 1-p;
    rrep(j,MX-2) {
      dp[j-1] += e[j]*q;
      dp[j+1] += e[j]*p;
    }
  }
  double ans = 0;
  srep(i,M,MX) ans += dp[i];
  printf("%.10f\n",ans);
  return 0;
}






















Measured memory_bytes: 384
#include <cstdio>
#define N 100010
int n,a[N],f[N];
int main(){
//	freopen("a.in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	int op=-1;
	for(int i=1;i<=n;++i){
		if(op==0 && a[i]==a[i-1]) f[i]=f[i-1],op=0;
		else if((op==0 || op==1) && a[i]>=a[i-1]) f[i]=f[i-1],op=1;
		else if((op==0 || op==2) && a[i]<=a[i-1]) f[i]=f[i-1],op=2;
		else{
			f[i]=f[i-1]+1;
			op=0;
		}
	}
	printf("%d\n",f[n]);
	return 0;
}

Measured memory_bytes: 896
def solve(a):
    dp = [[0]*3 for _ in range(len(a)+1)]
    for i in range(len(a)):
        for j in range(3):
            for k in range(3):
                if j != k:
                    dp[i+1][j] = max(dp[i+1][j], a[i][j] + dp[i][k])
    return max(dp[-1])
  
n = int(input())
a = []
for _ in range(n):
    a.append(list(map(int, input().split())))
print(solve(a))

Measured memory_bytes: 75352
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <numeric>
using namespace std;



typedef unsigned long ul;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i,n) for(int i=0;i<n;i++)

ul N, M;
std::string S, T;

ul gcd( ul m, ul n )
{
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd

ul lcm( ul m, ul n )
{
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

ul eng;
ul damage;
ul k;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    cin >> S;
    cin >> T;
    auto length = lcm(N, M);
    ul S_itr = length/N;
    ul T_itr = length/M;
    // cout <<S_itr<< endl;
    auto check = lcm(S_itr, T_itr);
    // cout << check << endl;
    ul itr = 0;
    ul S_it = 0;
    ul T_it = 0;
    while (S_it < N && T_it < M) {
      S_it = check/S_itr * itr;
      T_it = check/T_itr * itr;
      if(S[S_it] != T[T_it]) {
        // cout << S_it << " " << T_it << endl; 
        // cout << S[S_it]  << " " <<  T[T_it] << endl;
        cout << -1 <<endl;
        return 0;
      }
      ++itr; 
    }
    cout << length << endl;
    // REP(i,S_itr_goal){
    //   i * T_itr_goal +1
    // }
    if(S[0] != T[0]) {
      return 0;
    }

    // ul x = A+B+C;
    // if ((S-3 <= x) && ((x)<= S) ) {
    //   cout << "Yes"<< endl;
    // } else {
    //   cout << "No"<< endl;
    // }
}

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

int main() {
  int k,x; cin>>k>>x;
  for(int i=x-k+1; i<x+k;i++){
    if(-1000000<=i&&i<=1000000){ cout<<i<<" ";}
  }
}



Measured memory_bytes: 256
l1=input().split(" ")
n=int(l1[0])
k=int(l1[1])
list=[range(n)]
kashi=[]
for i in range(k):
  tmp=input()
  num=input().split(" ")
  for j in num:
    kashi.append(j)
kashi=set(kashi)
print(n-len(kashi))

Measured memory_bytes: 9512
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	s := readString()
	for i, r := range s {
		if i%2 == 0 {
			printf("%c", r)
		}
	}
	println()
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ld = long double;
int main(){
    while(1){
        ld x, h;
        cin >> x >> h;
        if(!x && !h) break;
        ld po = sqrt(pow(h, 2) + pow(x / 2, 2));
        printf("%.100Lf\n", x * po * 2 + x * x);
    }
    return 0;
}


Measured memory_bytes: 3116