akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

void print( vector<int> v )
{
    int n = v.size();
    for( int i = 0; i < n - 1; i++ )
    {
        cout << v[i] << " ";
    }
    cout << v[n-1] << endl;
}

int main()
{
    int n, m;
    vector<int> v;

    cin >> n;

    for( int i = 0; i < n; i++ )
    {
        cin >> m;
        v.push_back(m);
    }

    if( prev_permutation( v.begin(), v.end() ) == true )
        print(v);
    else
    {
        next_permutation( v.begin(), v.end() );
        print(v);
        if( next_permutation( v.begin(), v.end() ) == true )
            print(v);
        return 0;
    }

    if( next_permutation( v.begin(), v.end() ) == true )
        print(v);

    if( next_permutation( v.begin(), v.end() ) == true )
        print(v);

    return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;

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

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

int main()
{
  string n;
  cin >> n;
  rep(i, 3)
  {
    if (n[i] == '7')
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3628
loop do
    h, w = gets.split(" ").map(&:to_i)
    break if h == 0 && w == 0

    evenChess = (0...w).map  { |i| i.even? ? "#" : "." }.join
    oddChess = (0...w).map  { |i| i.even? ? "." : "#" }.join

    h.times do |i|
        chess = i.even? ? evenChess : oddChess
        puts chess
    end
    puts
end

Measured memory_bytes: 8628
n = gets.to_i
dic = {}
(0..n-1).each do |i|
  order, word = gets.chomp.split(" ")
  if(order=="insert") then
    dic[word] = true
  end
  if(order=="find")
    if (dic[word] == true) then
      puts "yes"
    else
      puts "no"
    end
  end
end

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define print(i) cout<<i<<endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    int q;
    cin >> q;
    while (q--) {
        ll a, b;
        cin >> a >> b;
        if (a > b) swap(a, b);
        if (a == b) {
            print(2 * a - 2);
        } else if (a + 1 == b) {
            print(2 * a - 2);
        } else {
            ll c = sqrt(a * b);
            if (c * c == a * b)
                c--;
            if (c == 0) {
                print(0);
            } else if (c * (c + 1) >= a * b) {
                print(2 * c - 2);
            } else {
                print(2 * c - 1);
            }

        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)

void printVec(std::vector<int> &vec) {
//    std::cout << "";
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        std::cout << *it << " ";
    }
    cout << '\n';
}

void printVec1(std::vector<string> &vec) {
//    std::cout << "";
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        std::cout << *it << " ";
    }
    cout << '\n';
}

void printVec2(std::vector<Int> &vec) {
//    std::cout << "";
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        std::cout << *it << " ";
    }
    cout << '\n';
}

Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

int main() {
    IOS;
    string s, t;
    cin >> s;
    string temp=s.substr(4,8);
    string temp2=s.substr(0,4);

    cout<<temp2<<" "<<temp;


    cout << endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);

int main() {
	cin.sync_with_stdio(false);
	int X, Y;
	cin >> X >> Y;
	cout << X + Y / 2 << endl;
	return 0;

}

Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF (int)(1e9+10)
#define LLINF (lint)(1e18+10)

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    rep(i, n){
        cin >> a[i];
        mp[a[i]]++;
    }
    SORT(a);
    int j = 0;
    while(j < a.size() - 1){
        if(a[j] == a[j+1]){
            a.erase(a.begin()+j);
            continue;
        }
        j++;
    }
    int cnt = 0;
    rep(i, a.size()){
        if(mp[a[i]] % 2 == 0){
            cnt++;
        }
    }
    int ans = a.size();
    if(cnt % 2 == 1){
        ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5376
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i

ans = 0
1.upto(1_000_000) do |a|
  1.upto(1_000_000) do |b|
    if a * b >= n
      break
    end
    ans += 1
  end
end

puts ans

Measured memory_bytes: 14696
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    while True:
        if A[0] == 1:
            print(1)
            return
        for i in range(len(A)):
            if i == 0:
                continue
            else:
                if A[i] % A[0] != 0:
                    A[i] = A[i] % A[0]
                    A.sort()
                    break
            if i == len(A) - 1:
                print(A[0])
                return


if __name__ == "__main__":
    main()


Measured memory_bytes: 15020
#include <bits/stdc++.h>
 
using namespace std;
 
int n,seq[300050];
bool flg[300050];
 
bool chk(int l,int r)
{
	if(l > r) return 0;
	if(l == r) return seq[l] != l;
	int minn = 300001,maxn = 0;
	for(int i = l;i <= r; ++ i) minn = min(minn,seq[i]),maxn = max(maxn,seq[i]);
	if(minn != l || maxn != r) return 1;
	for(int i = l + 1;i <= r;i += 2)
		if(!flg[i])
			return 1;
	for(int i = l;i <= r;i += 2)
		if(flg[i])
			return 1;
	int lst1 = 0,lst2 = 0;
	for(int i = l;i <= r;i += 2)
		if(seq[i] > i)
		{
			if(lst1 > seq[i])
				return 1;
			lst1 = seq[i];
		}
		else
		{
			if(lst2 > seq[i])
				return 1;
			lst2 = seq[i];
		}
	return 0;
}
 
int main()
{
	scanf("%d",&n);
	for(int i = 1;i <= n; ++ i)
	{
		scanf("%d",&seq[i]);
		flg[i] = seq[i] == i;
	}
	flg[0] = 1;
	int las = 1;
	for(int i = 1;i <= n; ++ i)
	{
		if(flg[i] && flg[i - 1])
		{
			if(chk(las,i - 2))
			{
				printf("No\n");
				return 0;
			}
			las = i + 1;
		}
		else if(flg[i] && flg[i - 2]);
		else if(flg[i] && flg[i - 3])
		{
			if(chk(las,i - 2))
			{
				printf("No\n");
				return 0;
			}
			las = i - 1;
		}
		else if(flg[i])
		{
			printf("No\n");
			return 0;
		}
	}
	if(chk(las,n)) printf("No\n");
	else printf("Yes\n");
} 

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

class Program
{
    int n;
    int m = 0;
    int res = 0;
    int[] c;
    int[] fix;
    bool[] visit;
    List<List<int>> g;
    void Run()
    {
        var sc = new Scanner();
        n = sc.NextInt();
        c = new int[n];
        fix = new int[n];
        visit = new bool[n];
        g = new List<List<int>>();
        for (int i = 0; i < n; i++)
        {
            g.Add(new List<int>());
            fix[i] = -1;
        }
        for (int i = 0; i < n - 1; i++)
        {
            int a = sc.NextInt() - 1;
            int b = sc.NextInt() - 1;
            g[a].Add(b);
            g[b].Add(a);
        }
        for (int i = 0; i < n; i++) c[i] = sc.NextInt();
        Array.Sort(c);

        if (n == 1)
        {
            Console.WriteLine(0);
            Console.WriteLine(c[0]);
            return;
        }
        if (n == 2)
        {
            Console.WriteLine(c.Min());
            Console.WriteLine(string.Join(" ", c));
            return;
        }

        for (int i = 0; i < n; i++)
        {
            if (g[i].Count > 1)
            {
                Dfs(i);
                break;
            }
        }

        Console.WriteLine(res - c[n - 1]);
        Console.WriteLine(string.Join(" ", fix));
    }

    void Dfs(int v)
    {
        if (visit[v]) return;
        visit[v] = true;
        foreach (int x in g[v])
        {
            if (!visit[x]) Dfs(x);
        }
        fix[v] = c[m];
        res += c[m++];
    }

    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)

    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 21820
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  for (int i = n / 2 - 1; ; --i) {
    if (s.substr(0, i) == s.substr(i, i)) {
      cout << 2 * i << '\n';
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using lint=long long;
using real=long double;
void cmx(real&x,real y){if(x<y)x=y;}
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::vector<std::pair<lint,lint>>data(n);
    for(lint i=0;i<n;i++)std::cin>>data.at(i).first;
    for(lint i=0;i<n;i++)std::cin>>data.at(i).second;
    lint V=100;
    std::vector<real>dp(V+1,-1);
    dp.at(0)=0;
    for(auto&&pair:data){
        std::vector<real>swp(V+1,-1);
        lint t,v;std::tie(t,v)=pair;
        for(lint i=0;i<=v;i++){
            if(dp.at(i)==-1)continue;
            for(lint j=0;j<=v;j++){
                if(t<std::abs(i-j))continue;
                double z=(i+j)/2.0;
                double w=std::abs(i-j)/2.0;
                double t2=t/2.0;
                cmx(swp.at(j),dp.at(i)+t2*(2*z+t2)-std::pow(w,2)-std::pow(std::max(0.0,z+t2-v),2));
            }
        }
        swp.swap(dp);
    }
    std::cout<<dp.at(0)<<'\n';
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String N = scan.next();
        int len = N.length();
        int K = scan.nextInt();
        long[][] dp = new long[len][4];
        // K == 1
        for (int i = len-1; 0 <= i; i--) {
            dp[i][1] = 9;
        }
        // K == 2
        for (int i = len - 2; 0 <= i; i--) {
            for (int j = i + 1; j < len; j++) {
                dp[i][2] += dp[i + 1][1] * 9;
            }
        }
        // K == 3
        for (int i = len - 3; 0 <= i; i--) {
            for (int j = i + 1; j < len; j++) {
                dp[i][3] += dp[j][2] * 9;
            }
        }
        char[] digits = N.toCharArray();
        int[] d = new int[len];
        for (int i = 0; i < len; i++) {
            d[i] = (int) (digits[i] - '0');
        }
        long ans = 0;
        // len-1桁目までの合計をansに追加する
        for (int i = 1; i < len; i++) {
            ans += dp[i][K];
        }
        // len桁の数字の計算を行う
        int non_zero_count = 0;
        for (int i = 0; i < len; i++) {
            if (0 == d[i]) {
                continue;
            }
            if (1 < d[i]) {
                if (i < len - 1) {
                    // len-i-1桁目(0-index)が1より大きい場合はansに(d[i]-1)*dp[i - 1][K]を追加
                    // 1-d-1まで
                    long s = 0;
                    for (int j = i + 1; j < len; j++) {
                        s += dp[j][K - non_zero_count - 1];
                    }
                    ans += (d[i] - 1) * s;
                }
            }
            // 0
            if (i != 0 && i < len - 1) {
                long s = 0;
                for (int j = i + 1; j < len; j++) {
                    s += dp[j][K - non_zero_count];
                }
                ans += s;
            }
            if (d[i] != 0) {
                non_zero_count += 1;
            }
            if (non_zero_count == K) {
                ans += d[i];
                break;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
int main(){
	int n,cnt;
	cin>>n;
	n--;
	for(cnt=0;n>0;cnt++) n/=3;
	cout << cnt<<endl;
}

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

int main()
{
  int N,M;
  int a,b;
  int ans=0;
  cin>>N>>M;
  vector< vector<int> > prof(M,vector<int>(2));
  for(int i=0;i<M;i++){
    cin>>a>>b;
    prof[i][0]=a;
    prof[i][1]=b;
  }
  int right=0;
  while(1){
    if(right==N)break;
    int max=-1;
    for(int i=0;i<M;i++){
      if(prof[i][0]>right+1)continue;
      if(prof[i][1]<=max)continue;
      max=prof[i][1];
    }
    if(max==-1)break;
    if(max<=right)break;
    ans++;
    right=max;
  }
  if(right==N)cout<<ans<<endl;
  else cout<<"Impossible"<<endl;
}

Measured memory_bytes: 0
import java.util.*;
public class Main {

	void doIt() {
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext()) {
			int[] input = new int[8];
			for(int r = 0; r < 8; r++) {
				input[r] = stdIn.nextInt();
			}
			int count = 0;
			ArrayList<Integer> temp = new ArrayList<Integer>();
			for(int r = 0; r < 8; r++) {
				if(input[r] != 0) {
					count++;
					temp.add(input[r]);
				}
			}
			switch(count) {
			case 1: System.out.println("C"); break;
			case 2:
				if(temp.get(0) - temp.get(1) == 0) {
					System.out.println("A");
				} else if(temp.get(0) > temp.get(1)) {
					System.out.println("E");
				} else if(temp.get(0) < temp.get(1)) {
					System.out.println("G");
				}
				break;
			case 3:
				if(temp.get(0) < temp.get(2)) {
					System.out.println("D");
				} else if(temp.get(0) > temp.get(2)) {
					System.out.println("F");
				}
				break;
			case 4: System.out.println("B"); break;
			}
		}
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().doIt();
	}

}

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

  
// Function to print Excel column name for a given column number 

int main()
{
	
	ll n,i,s=0LL;
	cin >> n;
	ll a[n];
	map<int,int>ck;
	for(i=0;i<n;i++)
	{
		cin >> a[i];
		s+=a[i];
		ck[a[i]]++;
	}
	int q;cin >> q;
	while(q--)
	{
		ll b,c;
		cin >> b >> c;
		s-=((ll)ck[b]*b);
		s+=((ll)ck[b]*c);
		ck[c]+=ck[b];
		ck[b]=0;
		cout << s << endl;
	}
}

Measured memory_bytes: 8840
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

from scipy.special import comb
n, m = map(int, input().split())
a = factorization(m)
M = 10**9 + 7

ans = 1
if m == 1:
    print(1)
    exit()
for i in a:
    ans *= comb(n, i[1], exact=True, repetition=True)
    ans = ans%M
print(ans)

Measured memory_bytes: 42400
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

int main() {
  int k, a, b, i;
  bool flag = false;
  cin >> k >> a >> b;
  for (i = a; i <= b; i++) {
    if (i % k == 0) {
      flag = true;
      break;
    }
  }
  cout << ((flag) ? "OK" : "NG") << endl;
}


Measured memory_bytes: 3576
//   __                    .__              ________ .________ ________   ______  
//  |  | __  ____    ______|  |__   __ __  /  _____/ |   ____//   __   \ /  __  \ 
//  |  |/ /_/ __ \  /  ___/|  |  \ |  |  \/   __  \  |____  \ \____    / >      < 
//  |    < \  ___/  \___ \ |   Y  \|  |  /\  |__\  \ /       \   /    / /   --   \
//  |__|_ \ \___  >/____  >|___|  /|____/  \_____  //______  /  /____/  \______  /
//       \/     \/      \/      \/               \/        \/                  \/

#include<bits/stdc++.h>
#define range 100005
#define mod 1000000007
#define eps 1e18
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<
#define int long long 

using namespace std;

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

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	int n;
	cin>>n;
	int output = eps;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			int x = i;
			int y = n/i;
			output = min(output,(x+y)-2);
		}
	}
	cout<<output;	
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
const ll N=405,mo=998244353;
ll f[N][N][N],g[N][N],a[N],b[N],n,q[N],s1,s2;
ll ny[N],jc[N];
ll move(ll &a,ll b){
	a=(a+b)%mo;
}
ll power(ll a,ll b=mo-2){
	ll ans=1;
	while (b){
		if (b&1)ans=ans*a%mo;
		a=a*a%mo;
		b>>=1;
	}return ans;
}
void prep(int lim=400){
	jc[0]=1;
	for (int i=1;i<=lim;i++)jc[i]=jc[i-1]*i%mo;
	ny[lim]=power(jc[lim]);
	for (int i=lim;i>=1;i--)ny[i-1]=ny[i]*i%mo;
}
int main(){
	cin>>n;
	prep();
	for (int i=1;i<=n;i++)
		scanf("%lld%lld",&a[i],&b[i]),s1+=a[i],s2+=b[i];
	for (int i=n;i>=1;i--)q[i]=a[i]+q[i+1];
	f[0][0][0]=1;
	ll ans=0,s_=power(s1);
	for (int i=1;i<=n;i++){
		for (int x=0;x<=s1;x++)
		for (int y=0;y<=s2;y++){
			if (!f[i-1][x][y])continue;
			move(f[i][x+a[i]][y],f[i-1][x][y]);
			ll h=s_*a[i]%mo,pw=1;
			for (int z=0;z<b[i];z++){
				move(f[i][x][y+z],f[i-1][x][y]*(mo-ny[z])%mo*pw),
				move(g[x+q[i+1]][y+z],f[i-1][x][y]*ny[z]%mo*pw);
				pw=pw*h%mo;
			}
		}
	}
	for (int x=0;x<s1;x++)
	for (int y=0;y<=s2;y++){
		ll x0=x*s_%mo;
		move(ans,g[x][y]*jc[y]%mo*power(1-x0+mo,(mo-2)*(y+1)));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 515584
n, m = map(int, input().split())
if abs(n-m) > 1:
    print(0)
    exit()

mod = 10**9 + 7
ans = 1
for i in range(1, n+1):
    ans *= i
    ans %= mod

for j in range(1, m+1):
    ans *= j
    ans %= mod

if n == m:
    ans *= 2
    ans %= mod

print(ans)


Measured memory_bytes: 9052
#include <stdio.h>

#define M 500010
int A[M];
int H;

int parent(int);
int left(int);
int right(int);
void maxheap(int);
void bmaxheap(void);

int main(int argc,char *argv[]){
  int i,num;
  scanf("%d",&num);
  H=num;
  for(i=1;i<=num;i++){
    scanf("%d",&A[i]);
  }
 
  bmaxheap();
 
  for(i=1;i<=num;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}

int parent(int i){
  return i/2;
}
 
int left(int i){
  return 2*i;
}
 
int right(int i){
  return 2*i+1;
}

void maxheap(int i){
  int l,r,largest,tmp;
  l=left(i);
  r=right(i);
  if(l<=H && A[l]>A[i]) largest=l;
  else largest=i;
 
  if(r<=H && A[r]>A[largest])  largest=r;
   
  if(largest!=i){
    tmp=A[i];
    A[i]=A[largest];
    A[largest]=tmp;
    maxheap(largest);
  }
}
 
void bmaxheap(void){
  int i;
  for(i=H/2;i>0;i--){
    maxheap(i);
  }
}



Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
int main(void){
  int N,K;
  cin>>N>>K;
  int l[N];
  for(int i=0;i<N;i++){
      cin>>l[i];
  }
  sort(l,l+N);
  int sum=0;
  for(int i=N-K;i<N;i++){
    sum=sum+l[i];
  }
  cout<<sum;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

class Dice {
    public:
        int D1;
        int D2;
        int D3;
        int D4;
        int D5;
        int D6;

        Dice(int d1, int d2, int d3, int d4, int d5, int d6);
        void Rotate_E();
        void Rotate_N();
        void Rotate_S();
        void Rotate_W();
        void Disp_D1();

};

Dice::Dice(int d1, int d2, int d3, int d4, int d5, int d6) {
    D1 = d1;
    D2 = d2;
    D3 = d3;
    D4 = d4;
    D5 = d5;
    D6 = d6;
}

void Dice::Rotate_E() {
    int tmp;

    tmp = D3;
    D3 = D1;
    D1 = D4;
    D4 = D6;
    D6 = tmp;
}

void Dice::Rotate_N() {
    int tmp;

    tmp = D5;
    D5 = D1;
    D1 = D2;
    D2 = D6;
    D6 = tmp;
}

void Dice::Rotate_S() {
    int tmp;

    tmp = D5;
    D5 = D6;
    D6 = D2;
    D2 = D1;
    D1 = tmp;
}

void Dice::Rotate_W() {
    int tmp;

    tmp = D3;
    D3 = D6;
    D6 = D4;
    D4 = D1;
    D1 = tmp;
}

void Dice::Disp_D1() {
    cout << D1 << endl;
}

int main() {

    int d1, d2, d3, d4, d5, d6;
    cin >> d1 >> d2 >> d3 >> d4 >> d5 >> d6;

    Dice Dice1(d1, d2, d3, d4, d5, d6);

    string order;
    cin >> order;

    for (int i = 0; order[i] != 0; i++) {
        
        switch (order[i]) {
            case 'E':
                Dice1.Rotate_E();
                break;
            case 'N':
                Dice1.Rotate_N();
                break;
            case 'S':
                Dice1.Rotate_S();
                break;
            case 'W':
                Dice1.Rotate_W();
                break;
        }
    }

    Dice1.Disp_D1();

    return 0;
}


Measured memory_bytes: 3192
#include <iostream>
using namespace std;
int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    if(c==1){
        cout << "Open" << endl;
    }
    else if(a == 1 && b == 1){
        cout << "Open" << endl;
    }
    else cout << "Close" << endl;
    
    return 0;
    
}



Measured memory_bytes: 3076
n,m =map(int,input().split())
a = list(map(int,input().split()))
cnt=0;s=0;
for i in range(n):
  s += a[i]

for i in a:
  if i *4*m>=s: cnt +=1
  if cnt >= m:
    print("Yes")
    break
  
else:
  print("No")

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

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

  c = a * b;
  if (0 == c % 2) {
    cout << "Even" << endl;
  }
  else {
  	cout << "Odd" << endl;
  }
}

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

int main(){
  ll a,b,c; cin >> a >> b >> c;
  if(a+b+c >=22)cout << "bust" << endl;
  else cout << "win" << endl;
}

Measured memory_bytes: 764
import java.util.*

fun main(args: Array<String>) {
    Scanner(System.`in`).use {
        val n = it.nextInt()
        var s: Char? = null
        val ww= mutableListOf<String>()
        for (i in 0 until n) {
            val w = it.next()
            if (s == null || s == w[0]) {
                for(www in ww){
                    if(www==w){
                        println("No")
                        return
                    }
                }
                s = w.last()
                ww.add(w)
            } else {
                println("No")
                return
            }
        }
        println("Yes")
    }
}


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

using namespace std;

#define pan(i,n) for(int i=0;i<n;i++)
#define pans(i,n,a) for(int i=a;i<n;i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF 1000000007
#define PI 3.141592653
#define inf 100007
#define pll pair<ll,ll>
#define pii pair<int,int>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

int main(){
    string s,t;
    cin>>s>>t;
    string x="";
    pan(i,(int)t.size()-1){
        x+=t[i];
    }
    if(s!=x) cout<<"No";
    else cout<<"Yes";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, a, b) for (long long i = a; i <= b; ++i)
#define ll long long
#define N 210
using namespace std;

ll n, m, l, ans, a[N];

inline ll read(){
    ll s = 0, w = 1;
    char ch = getchar();
    for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
    for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
    return s * w;
}

inline void work(){
    n = read(), m = read();                     //è¾“å…¥nå’Œm
    REP(i, 1, n) a[++l] = i * 2;                //ä¿å­˜é•¿åº¦ä¸ºnçš„æ•°åˆ—
    REP(i, 1, m) a[++l] = (i - 1) * 2 + 1;      //ä¿å­˜é•¿åº¦ä¸ºmçš„æ•°åˆ—
    sort(a + 1, a + l + 1);                     //æŽ’åº
    REP(i, 1, l)                                //è§åˆ†æž
        REP(j, i + 1, l)                        //è§åˆ†æž
            if ((a[i] + a[j]) % 2 == 0) ans++;  //è§åˆ†æž
    printf("%lld\n", ans);                      //è¾“å‡ºç­”æ¡ˆ
}

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

Measured memory_bytes: 256
/*Author--Vishwas Agrawal*/
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<ll>
#define pb push_back
#define test ll t; cin>>t; while(t--)
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007LL
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define inc(i,a,n) for (ll i=a;i<n;i++)
#define dec(i,a,n) for (ll i=n-1;i>=a;i--)

int main()
{
   ll a,b,c;
   cin>>a>>b>>c;
   a=abs(a);
   if(a==c)
   {
      if(b%2==1)
      cout<<0<<endl;
      else
      {
         cout<<a<<endl;
      }
      
   }
   if(c<a)
   {
      if(b<=a/c)
      {
         cout<<a-c*b<<endl;
      }
      else
      {
         if((b-a/c)%2==0)
         {
            cout<<a-(a/c)*c<<endl;
         }
         else
         {
            cout<<c-(a-(a/c)*c)<<endl;
         }
         
      }
      
   }
   if(c>a)
   {
      if(b%2==0)
      {
         cout<<a<<endl;
      }
      else
      {
         cout<<c-a<<endl;
      }
      
   }
  
   return 0;
}

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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;

/////////////////////////////////

ll const INF = 2e18;
int a, b;
ll c;

ll geta(ll k) {
	if (k >= a) k++;
	return k;
}

ll getb(ll k) {
	if (k >= b) k++;
	return k;
}

ll mult(ll a, ll b) {
	if (a == 0 || b == 0) return 0LL;
	if (INF / a < b) return INF;
	return a * b;
}

bool can(ll k) {	
//	k = 2;
	ll l1 = k / 2 - 10;
	ll r1 = k / 2 + 10;
	l1 = max(1LL, l1);	
	r1 = min(k, r1);
	ll y = 0;
	for (ll i = l1; i <= r1; i++) {
		ll v = mult(geta(i), getb(k - i + 1));
//		err("k = %lld l1 = %lld r1 = %lld y = %lld i = %lld v = %lld\n", k, l1, r1, y, i, v);
		y = max(y, v);			
	}
	return (y < c);
}

void solve() {
	c = (ll) a * b;
	ll l = 0;
	ll r = INF;
	while (r - l > 1) {
		ll h = (l + r) / 2;
		if (can(h)) {
//			err("can : h = %lld\n",h);
			l = h;
		} else {
			r = h;
		}
	}
	printf("%lld\n", l);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t;
	scanf("%d", &t);
	while (t--) {  
		scanf("%d %d", &a, &b);
		solve();		
	}

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

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

int main() {
	int a,b;

	std::cin >> a;
	std::cin >> b;

	if(a>b) std::cout << gcd(a,b) << std::endl;
	else std::cout << gcd(b,a) << std::endl;

	return 0;
}



Measured memory_bytes: 3088
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a.at(i);

  sort(a.begin(),a.end());
  cout<<abs(a.at(n-1)-a.at(0))<<endl;
}

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string up, down;
	cin >> up >> down;
	string answer = "NO";
	
	if (up[0] == down[2] && up[1] == down[1] && up[2] == down[0]) {
		answer = "YES";
	}
	
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 888
#include <iostream>

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
    int n, m;
    cin >> n >> m;

    int ans_1 = 0;
    int ans_2 = 0;
    int copy = n-1;
    rep(i, n-1)  {
        ans_1 += copy-i;
    }
    copy = m-1;
    rep(i, m-1) {
        ans_2 += copy-i;
    }

    cout << ans_1+ans_2 << endl;
    return 0;
}

Measured memory_bytes: 256
import sys


def main():
    N = int(input())
    A = list(map(int, input().split()))
    if 0 in A:
        print('0')
        sys.exit()
    ans = 1
    for i in range(1, N+1):
        if A[i-1] == 0:
            print('-1')
            sys.exit()
        ans *= A[i-1]
        if ans > 10**18:
            print('-1')
            sys.exit()
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 22144
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), w = sc.nextInt();
        int[] ws = new int[n];
        long[] vs = new long[n];

        long[][] dp = new long[n][w + 1];
        for (int i = 0; i < n; i++) {
            ws[i] = sc.nextInt();
            vs[i] = sc.nextInt();
        }
        //System.out.println(maxKnapsack(ws, vs, 0, w, dp));
        System.out.println(maxKnapsack(ws, vs, w));
    }


    private static long maxKnapsack(int[] ws, long[] vs, int w) {
        long[][] dp = new long[ws.length+1][w + 1];

        for (int i = 1; i <= ws.length; i++) {
            for (int s = 1; s <= w; s++) {
              	dp[i][s] = dp[i-1][s];
              	if(s >= ws[i - 1])
                	dp[i][s] = Math.max(dp[i-1][s - ws[i-1]] + vs[i-1], dp[i][s]);
            }
        }
        return dp[ws.length][w];
    }
}



Measured memory_bytes: 239316
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
int main() {
	int n; cin >> n;
	int ans = 0;
	long int a[201];
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(a[i]%2==1){
			cout << 0 << endl;
			return 0;
		}else{
			continue;
		}
	}
	long int b[201];
	for(int i=0;i<40;i++){
		ans++;
		for(int j=0;j<n;j++){
			b[j] = a[j]/2;
			if(b[j]%2==1){
				cout << ans << endl;
				return 0;
			}else{
				a[j] = b[j];
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n, m; cin >> n >> m;
	vector<int> G[100000];
	rep(i, m) {
		int u, v; cin >> u >> v; u--; v--;
		G[u].push_back(v); G[v].push_back(u);
	}
	int used[100000] = {}; bool f = true;
	queue<int> q; q.push(0);
	used[0] = 1;
	while (!q.empty()) {
		int ne = q.front(); q.pop();
		int len = G[ne].size();
		rep(j, len) {
			int v = G[ne][j];
			if (used[v]) {
				if (used[v] == used[ne])f = false;
			}
			else {
				used[v] = -used[ne]; q.push(v);
			}
		}
	}
	ll out = (ll)n * (ll)(n - 1) / (ll)2;
	if (!f) {
		cout << out - (ll)m << endl;
	}
	else {
		ll cnt = 0;
		rep(i, n) {
			if (used[i] == -1)cnt++;
		}
		cnt = cnt * (n - cnt);
		cout << cnt-(ll)m << endl;
	}
	return 0;
}

Measured memory_bytes: 6272
#include <stdio.h>

int main(void){
    int i;
    double a,n,out=0;
    scanf("%lf",&n);
    for(i=0;i<n;i++){
        scanf("%lf",&a);
        out+=a;
    }
    printf("%d\n",(int)(out/n));
    return 0;
}

Measured memory_bytes: 628
mod = 10 ** 9 + 7
s = input()
dp = [[0] * 4 for _ in range(len(s) + 1)]
dp[0][0] = 1
# dp[sの何文字目まで見たか][未取得0->A取得1->B取得2->C取得3]

for i, ss in enumerate(s):
    for j in range(4):
        dp[i + 1][j] += dp[i][j] * (1 if ss != '?' else 3)
        # i文字目を取らないケース

    if ss == 'A':
        dp[i + 1][1] += dp[i][0]
    elif ss == 'B':
        dp[i + 1][2] += dp[i][1]
    elif ss == 'C':
        dp[i + 1][3] += dp[i][2]
    elif ss == '?':
        dp[i + 1][1] += dp[i][0]  # Aに変えた
        dp[i + 1][2] += dp[i][1]  # Bに変えた
        dp[i + 1][3] += dp[i][2]  # Cに変えた
    # i文字目を取るケース

    for j in range(4):
        dp[i + 1][j] %= mod

print(dp[len(s)][3])

"""
i文字目の文字で処理を場合分け
それぞれ、取る場合と取らない場合の処理を書く
'?'のときで、文字を取らない場合、
ABCに変える3パターンそれぞれで取らない処理を行うので、3倍になる
"""


Measured memory_bytes: 27624
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,w,z;
    char ca,cb,cc;
    cin>>a>>b;
    if(a==2||b==2) No;
    else Yes;
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;

void solve()
{
	int k, x;
	cin>>k>>x;
	int start = max(-1000000, x-k+1);
	int end = min(1000000, x+k-1);
	for(int i=start; i<=end; i++)
	{
		cout<<i<<" ";
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <climits>
#define INF (INT_MAX / 2)
using namespace std;

constexpr int MAXN = 1e2 + 1;
constexpr int MAXV = 1e5 + 1;
int w[MAXN]; // weights
int v[MAXN]; // values
int table[MAXV];
// table[v]: minimum weight to get v values.

int main(void)
{
    fill(table + 1, table + MAXV, INF); // table[0] should be = 0
    int N, W;
    cin >> N >> W;
    for (int i = 1; i <= N; i++)
        cin >> w[i] >> v[i]; // {weight, value}

    for (int i = 1; i <= 100; i++)
    {
        // In reverse order to ensure an item is considered exactly only once:
        for (int j = MAXV - 1; j >= 0; j--)
            if (table[j] < W)
                table[j + v[i]] = min(table[j + v[i]], table[j] + w[i]);
    }

    int ans = 0;
    for (int v = MAXV - 1; v >= 0; v--)
    {
        if (table[v] <= W)
        {
            ans = v;
            break;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1272
#include <stdio.h>
#include <algorithm>

#define MAX 100

using namespace std;

int numbers[MAX];

int bubbleSort(int a[], int n)
{
    int i, j, swapNum = 0;
    bool flag = 1;
    for (i = 0; flag; i++) {
        flag = 0;
        for (j = n - 1; j >= i + 1; j--) {
            if (a[j] < a[j - 1]) {
                swap(a[j], a[j - 1]);
                flag = 1;
                swapNum++;
            }
        }
    }
    return swapNum;
}

int main()
{
    // input
    int n, i, swapNum;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &numbers[i]);
    }
    // processing
    swapNum = bubbleSort(numbers, n);
    // output
    for (int i = 0; i < n; i++) {
        if (i) printf(" ");
        printf("%d", numbers[i]);
    }
    printf("\n");
    printf("%d\n", swapNum);

    return 0;
}

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

int main(){
  string s;cin>>s;
  vector<int> c(4,0);
  for(int i=0;i<(int)s.size();i++){
    if(s[i]=='N') c[0]++;
    if(s[i]=='W') c[1]++;
    if(s[i]=='S') c[2]++;
    if(s[i]=='E') c[3]++;
  }
  if(((c[0]>0&&c[2]>0)||(c[0]==0&&c[2]==0))&&((c[1]>0&&c[3]>0)||(c[1]==0&&c[3]==0))){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

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

int main(){
    int n, d;
    scanf("%d%d", &n, &d);
    int cnt = 0;
    while (n --){
        int x, y;
        scanf("%d%d", &x, &y);
        if (1ll * x * x + 1ll * y * y <= 1ll * d * d){
            ++ cnt;
        }
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 3832
N = input()
A = list(map(int, input().split()))
A.sort()
if A[0] == 0:
    print(0)
else:
    isOverflow = False
    product = 1
    A.sort(reverse=True)
    for number in A:
        product = product * number
        if product > 10 ** 18:
            print(-1)
            isOverflow = True
            break
    if not isOverflow:
        print(product)


Measured memory_bytes: 21704
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<bits/stdc++.h>
#define ll long long 
#define d double
using namespace std;
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n;
  cin>>n;
  string s;
  cin>>s;
  size_t m=s.size();
  int i;
  for(i=0;i<m;i++){
  	
  	int p=int(s[i])+n;
  	if(p>90){
  		
  	   s[i]=p-26; 		
  		
	  }
	  
	else{
		
		s[i]=int(s[i])+n;
		
	} 
  	
  }
  
  
   cout<<s<<endl;
  
  
  return 0;
}

Measured memory_bytes: 3644
n = int(input())
flower = input().split()
for i in range(n):
    flower[i] = int(flower[i])
a = 0
def water():
    if sum(flower) == 0:
        a = -1
    elif 0 in flower:
        i = 0
        while flower[i] == 0:
            i += 1
        j = i
        try:
            while flower[j+1] != 0:
                j += 1
        except:
            abc = i
        for k in range(i,j+1):
            flower[k] -= 1
    else:
        for i in range(n):
            flower[i] -= 1
ans = 0
while sum(flower) != 0:
    water()
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 1000000000
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repM(i, n) for (int i = n; i > 0; i--)

int main() {
    int X,Y,Z;
    int C = 0;
    cin >> X >> Y >> Z;
    C = Y;
    Y = X;
    X = C;

    C = Z;
    Z = X;
    X = C;
    cout << X << " " << Y << " " << Z << endl;

    return 0;
}

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

l = [int(input()) for _ in range(N)]

inf = 10 ** 10

def mp(i,a,b,c):
  if i == N:
    return abs(A-a)+abs(B-b)+abs(C-c)-30 if min(a,b,c)>0 else inf
  mp0 = mp(i+1,a,b,c)
  mp1 = mp(i+1,a+l[i],b,c)+10
  mp2 = mp(i+1,a,b+l[i],c)+10
  mp3 = mp(i+1,a,b,c+l[i])+10
  return min(mp0,mp1,mp2,mp3)

print(mp(0,0,0,0))

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

char s[100];


int main()
{
    scanf("%s",s);
    if(strlen(s)<4)
        return printf("No"),0;
    bool flag=false;
    for(int i =0 ; i<4;i++){
        if(i==0&&s[i]!='Y'){
            flag=true;
            break;
        }
        if(i==1&&s[i]!='A'){
            flag=true;
            break;
        }
        if(i==2&&s[i]!='K'){
            flag=true;
            break;
        }
        if(i==3&&s[i]!='I'){
            flag=true;
            break;
        }
    }
    puts(flag?"No":"Yes");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // レート計算： (現在レート + 次回パフォーマンス) / 2 = 次回レート ;
  // パフォーマンス算出： 次回レート * 2 - 現在レート = 次回パフォーマンス;
  
  int r, g; // 現在レート；r,次回レート：g
  cin >> r >> g;
  cout << g * 2 - r << endl;

}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define ll long long
#define INF 1000000ll
using namespace std;
signed main(){
  ll k,s,ans=0;
  cin >> k >> s;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      int a = s - i - j;
      if (0 <= a && a <= k) {
        ans++;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int h,w;
  cin>>h>>w;
  vector<vector<char>>x;
  int i,j;
  char ans;
  for(i=0;i<h;i++)
  {
    vector<char>y;
    for(j=0;j<w;j++)
    {     
      cin>>ans;
      y.push_back(ans);
    }
    x.push_back(y);
  }
int dp[h][w]={0};
  for(i=0;i<h;i++)
    for(j=0;j<w;j++)
      dp[i][j]=0;
  dp[0][0]=1;
  
  for(i=1;i<w;i++)
  {
    if(x[0][i]=='.')
      dp[0][i]=1;
    else
     	break;
  }  
  
  for(i=1;i<h;i++)
  {
    if(x[i][0]=='.')
      dp[i][0]=1;
    else
      break;  
  } 
  
  for(i=1;i<h;i++)
  {
    for(j=1;j<w;j++)
    {
      if(x[i][j]=='.')
        dp[i][j]+=(dp[i-1][j]+dp[i][j-1])%1000000007;
      else
        continue;
    }
  }
  cout<<dp[h-1][w-1]<<"\n";
  return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;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 REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()



int main() {
	int n,ma = 0,sum = 0;
	cin >> n;
	REP(i, n) {
		int s;
		cin >> s;
		ma = max(ma, s);
		sum += s;
	}
	sum -= ma;
	cout << (sum > ma ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define EPS (1e-7)

MY_NAMESPACE(testbed)
int main()
{
	ll a;
	double b;
	cin >> a >> b;
	ll b100 = (ll)(100.0 * b + EPS);
	ll ans = a * b100;
	cout << ans / 100 << "\n";
	return 0;
}
MY_NAMESPACE_

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

ll a,b,c,n,h,m,q,x;
ll ans=100000000000;

string s;

#define MPI  3.14159265358979323846

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

  cin>>a>>b>>h>>m;
  double hk = 30*h + 30*(m/60.0);
  double mk = 360*(m/60.0);
  double k;
  if(hk>=mk){
    k = hk-mk;
  } else {
    k = mk-hk;
  }
  printf("%.20f", sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(k*MPI/180.0)));

  return 0;
}

Measured memory_bytes: 4180