akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    vector<vector<ll>> dp(C + 1, vector<ll>(D + 1, 0));
    ll MOD = 998244353;
    for (int i = A; i <= C; i++) {
        for (int j = B; j <= D; j++) {
            if (i == A && j == B) {
                dp[i][j] = 1;
                continue;
            }            dp[i][j] = dp[i][j - 1] * i;
            dp[i][j] %= MOD;
            dp[i][j] += dp[i - 1][j] * j;
            dp[i][j] %= MOD;
            dp[i][j] -= (((dp[i - 1][j - 1] * (i - 1)) % MOD) * (j - 1)) % MOD;
            dp[i][j] += MOD;
            dp[i][j] %= MOD;
        }
    }
    cout << dp[C][D] << "\n";
    /*
    rep(i, C + 1) {
        rep(j, D + 1) {
            cout << dp[i][j] << " ";
        }
        cout << "\n";
    }
    */
}

Measured memory_bytes: 73676
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int imos[10005];

int main(void) {
    int N, X; cin >> N >> X;
    vector<int> L(N);
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }
    int D = 0;
    imos[0]++;
    for (int i = 0; i < N; i++) {
        D += L[i];
        if (D <= 10000) {
            imos[D]++;
        }
    }
    for (int i = 1; i <= 10000; i++) {
        imos[i] += imos[i-1];
    }
    cout << imos[X] << endl;
}   


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,m,a[101],k,i,j,x,y,z;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(i=1;i<=m;i++){
		for(j=1;j<n;j++){
			y=a[j]%i; z=a[j+1]%i;
			if(y>z){
				x=a[j];
				a[j]=a[j+1];
				a[j+1]=x;
			}
		}
	}
	for(i=1;i<=n;i++){
		printf("%d\n",a[i]);
	}
	return 0;
}
	
	
	
	


Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
long long dp[130];
int main()
{
    int n; cin>>n;
    string s; cin>>s;
    for(int i=0; i<n; ++i) dp[s[i]]++;
    long long ans=1, MOD=1e9+7;
    for(int i='a'; i<='z'; ++i) ans=(ans* (dp[i]+1))%MOD;
    ans = (ans-1+MOD)%MOD;
    cout<<ans;
}


Measured memory_bytes: 512
import numpy as np
A, B, C, D, E, F = map(int, input().split())

# 水を入れる量の候補を決める
waterA = np.arange(31) * 100 * A
waterB = np.arange(31) * 100 * B
water = np.add.outer(waterA, waterB).flatten()
water = np.unique(water[water <= F])
water = water[np.nonzero(water)]

# 容器にあとどれだけ入れれるか
rest = F - water

# 溶ける砂糖の量
can_solve = np.minimum(water * E // 100, rest)

# 砂糖を入れる量の候補うんぬん
sugarC = np.arange(101) * C
sugarD = np.arange(101) * D
sugar = np.add.outer(sugarC, sugarD).flatten()
sugar = np.unique(sugar[sugar <= F])
sugar.sort()

pos = np.searchsorted(sugar, can_solve, side="right") - 1
ans = np.argmax(sugar[pos] / (water + sugar[pos]))
print(sugar[pos[ans]] + water[ans], sugar[pos[ans]])


Measured memory_bytes: 12744
#include<bits/stdc++.h>
using namespace std;
const long long N=2e5+10;
long long a[N],b[N];
long long n,x,y;
int main(){
	scanf("%lld",&n);
	for(long long i=1;i<=n;i++){
		scanf("%lld%lld",&x,&y);
		a[i]=x+y;
		b[i]=x-y;
	}
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	printf("%lld",max(a[n]-a[1],b[n]-b[1]));
	return 0;
}

Measured memory_bytes: 6932
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
	
		MyScanner sc = new MyScanner();
		int n=sc.nextInt();
		int k=sc.nextInt();
		int h[]=new int[n];
		for(int i=0;i<n;i++) {
			h[i]=sc.nextInt();
		}
		int cost[]=new int[n];
		cost[0]=0;
		cost[1]=Math.abs(h[1]-h[0]);
		if(n>2) {
			for(int j=2;j<n;j++) {
				cost[j]=Math.abs(h[j]-h[j-1])+cost[j-1];
				for(int l=1;l<=Math.min(k,j);l++){
				cost[j]=Math.min(cost[j],Math.abs(h[j]-h[j-l])+cost[j-l]);
				}
			}
		}
		
		System.out.println(cost[n-1]);
	}
	
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				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());
		}

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	

}






Measured memory_bytes: 32056
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int sum = 0;
		int count = 0;

		for (count = 1; ;count++) {


			sum += count;
			if (n - sum <= 0){
				break;
			}
		}


//		if (n - sum == 0) {
//			for (int i = 1; i <= count; i++) {
//				System.out.println(i);
//			}
//			System.exit(0);
//		}

		int tmp = 0;
		for (int i = count; i >= 1;i--) {
			if (tmp + i > n) {
				continue;
			}

			tmp += i;

			System.out.println(i);
		}





		sc.close();
	}


}


Measured memory_bytes: 11700
s=input()
lens=len(s)
if lens!=26:
    for i in "abcdefghijklmnopqrstuvwxyz":
        if i not in s:
            print(s+i)
            break
elif s=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
else:
    temp=[]
    for i in range(25):
        temp.append(s[-i-1])
        if s[-i-2]<s[-i-1]:
            break
    for t in temp:
        if s[-i-2]<t:
            print(s[:-i-2]+t)
            break

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

int main()
{
    int n,ans=0;
    vector<char>s(n); 
    cin >> n ;
    rep(i, n) cin >> s[i];
    rep(i, n){
         vector<bool> x(26);
         vector<bool> y(26);
         int t = 0;
         forx(j,0,i){
             x[s[j] - 'a'] = true;
        }
         forx(j, i, n){
             y[s[j] - 'a'] = true;
        }
         rep(j,26){
             if(x[j]==true&&y[j]==true)
                 t++;
            }
            ans = max(ans, t);
        }
    
    cout << ans << endl;
    return 0;
}


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


int main() {
    int n, m;
    cin >> n >> m;
    vector<P> p(m);
    rep(i, m) cin >> p[i].first >> p[i].second;
    rep(x, 1000) {
        int keta = 1;
        int nx = x/10;
        vector<int> d(1, x%10);
        while (nx) {
            keta++;
            d.push_back(nx%10);
            nx /= 10;
        }
        if (keta != n) continue;
        bool ok = true;
        reverse(d.begin(), d.end());
        rep(i, m) {
            if (d[p[i].first-1] != p[i].second) ok = false;
        }
        if (ok) {
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3608
import sys
from bisect import bisect_left

input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    idx = bisect_left(A[1:-1], 0)
    m_group = A[1:1 + idx]
    p_group = A[1 + idx: -1]

    ans = []

    MAX = A[-1]
    for m in m_group:
        ans.append(f"{MAX} {m}")
        MAX -= m

    MIN = A[0]
    for p in p_group:
        ans.append(f"{MIN} {p}")
        MIN -= p

    ans.append(f"{MAX} {MIN}")
    M = MAX - MIN

    print(M)
    print("\n".join(ans))


if __name__ == "__main__":
    main()


Measured memory_bytes: 25616
fun main(args: Array<String>) {
    val (A, B) = readInputLine().split(" ").map { it.toInt() }
    
    if (A <= 9 && B <= 9) {
        println(A * B)
    } else {
        println(-1)
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 36336
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,n,a[10000],i,s=0;
    cin>>t>>n;
    for(i=0;i<t;i++)
        cin>>a[i];
    sort(a,a+t);
    for(i=0;i<n;i++)
    {
        s+=a[i];
    }
    cout<<s<<endl;

}


Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		long mod = (long)(1e9 + 7);
		int N = GetInt();
		string S = GetString();

		if(S[0] == 'W' || S[2 * N - 1] == 'W')
		{
			Console.WriteLine(0);
			return;
		}

		int[] type = new int[2 * N];
		type[0] = 0;
		for(int i = 1; i < 2 * N; i++)
		{
			if(S[i] == S[i - 1])
				type[i] = type[i - 1] ^ 1;
			else
				type[i] = type[i - 1];
		}

		if(type.Count(x => x == 0) != N)
		{
			Console.WriteLine(0);
			return;
		}

		long ans = 1;
		long L = 0;
		for(int i = 0; i < 2 * N; i++)
		{
			if(type[i] == 0)
			{
				L++;
			}
			else
			{
				ans = (ans * L) % mod;
				L--;
			}
		}

		for(long i = 2; i <= N; i++)
			ans = (ans * i) % mod;

		Console.WriteLine(ans);
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 14140
#include<bits/stdc++.h>
#define int long long
#define double long double
#define vi vector<int>
#define vpi vector<pair<int,int> >
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define msi map<string,int>
#define set set<int>
#define u_set unordered_set<int>
#define pb push_back
#define endl "\n"
#define ll long long int
#define vll vector<long long int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define umap unordered_map 
#define mod 1000000007
#define fori(a,n) for(int i=a;i<n;i++)
#define forj(a,n) for(int j=a;j<n;j++)
#define MAX 300303
using namespace std;
vvi dp(100001,vi(3,INT_MIN));
int n;
signed main()
{
    io
    cin >> n ;
    vvi hp(n,vi(3));
    fori(0,n)cin >> hp[i][0] >> hp[i][1] >> hp[i][2];
    dp[0][0] = hp[0][0];
    dp[0][1] = hp[0][1];
    dp[0][2] = hp[0][2];
    fori(1,n){
        dp[i][0] = max(dp[i-1][1],dp[i-1][2])+ hp[i][0];
        dp[i][1] = max(dp[i-1][0],dp[i-1][2])+ hp[i][1];
        dp[i][2] = max(dp[i-1][0],dp[i-1][1])+ hp[i][2];
    }
    cout << max(dp[n-1][0] , max(dp[n-1][1],dp[n-1][2])) << endl;
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define P pair<ll,ll>
#define Graph vector<vector<P>>
#define fi first
#define se second
constexpr ll mod=1000000007;
constexpr ll INF=(1ll<<60);
constexpr double pi=3.14159265358979323846;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<typename T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}


int main(){
    ll n;cin>>n;
    vector<ll> a(n+1),b(n);
    ll before=0;
    rep(i,n+1){
        cin>>a[i];
        before+=a[i];
    }
    rep(i,n) cin>>b[i];
    
    rep(i,n){
        ll retain=a[i];
        a[i]=max(0ll,a[i]-b[i]);
        b[i]=max(0ll,b[i]-retain);

        a[i+1]=max(0ll,a[i+1]-b[i]);
    }

    ll after=0;
    rep(i,n+1) after+=a[i];

    cout<<before-after<<endl;
    return 0;
}

Measured memory_bytes: 4836
#include <stdio.h>
 
int main() {
  int n;
  int p[20];
  int a = 0;
  scanf("%d", &n);
  for(int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }
  for(int i = 0; i < n - 2; i++) {
    if(p[i] < p[i + 1]) {
      if(p[i + 1] < p[i + 2]) {
        a++;
      }
    }
  }
  for(int i = n - 1; i > 1; i--) {
    if(p[i] < p[i - 1]) {
      if(p[i - 1] < p[i - 2]) {
        a++;
      }
    }
  }
  printf("%d", a);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        int x;
        cin >> x;
        x--;
        a[i]=x;
    }
    int ans=0;
    rep(i,n){
        if(a[a[i]]==i && a[i]>i) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#define N 100

int main(){
  int i,j,n,u,k,v;
  int V[N][N];
  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      V[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      V[u-1][v-1]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j) printf(" ");
      printf("%d",V[i][j]);
    }
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2052
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int n,a[100010],k;
	cin>>n>>k>>a[0];
	int s=a[0];
	for(int i=1;i<n;i++){
		cin>>a[i];
		int d=s,b=a[i];
		while(true){
			if(d<b)swap(d,b);//dが大きい
			d%=b;
			if(d==0)break;
		}
		s=b;
	}
	sort(a,a+n);
	if(k%s==0&&k<=a[n-1])cout<<"POSSIBLE"<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int maxn=5010;
#define printerr(...) fprintf(stderr,__VA_ARGS__)
int f[maxn],a[maxn];
int beg[maxn],tto[maxn<<1],nex[maxn<<1],e;
int ans[200100],num;
int c[maxn],dep[maxn];
bool under[maxn];
void putin(int s,int t){
	tto[++e]=t;
	nex[e]=beg[s];
	beg[s]=e;
}
void color(int u){
	int cnt=0;
	for(int i=beg[u];i;i=nex[i]){
		if(c[tto[i]]==2) continue;
		cnt++;
		color(tto[i]);
	}
	if(cnt==0)
		c[u]=1;
	else if(cnt==1){
		for(int i=beg[u];i;i=nex[i]){
			if(c[tto[i]]==2) continue;
			if(c[tto[i]]==1)
				c[u]=1;
		}
	}
	under[u]=0;
}
int change_color(int u){
	int res=0;
	for(int i=beg[u];i;i=nex[i]){
		if(c[tto[i]]==2) continue;
		res+=change_color(tto[i]);
	}
	if(a[u]==u&&c[u]==1){
		c[u]=2;
		for(int i=beg[u];i;i=nex[i]){
			if(c[tto[i]]!=2)
				c[u]=1;
		}
	}
	if(c[u]==1) res++;
	return res;
}
int find_val(int u,int v){
	int res=0;
	for(int i=beg[u];i;i=nex[i]){
		if(c[tto[i]]==2) continue;
		res=find_val(tto[i],v);
	}
	if((dep[a[u]]<dep[v]||!under[a[u]])&&res==0)
		res=u;
	return res;
}
int find(int u){
	int res=find_val(u,u);
	if(res==0) return u;
	return res;
}
int find_deep(int u){
	int res=0;
	for(int i=beg[u];i;i=nex[i]){
		if(c[tto[i]]==2) continue;
		res=find_deep(tto[i]);
		if(res) return res;
	}
	if(!under[a[u]]&&c[a[u]]==1)
		return u;
	return 0;
}
void rotate(int u){
	int v=a[1];
	for(;u;u=f[u]){
		if(c[a[u]]==2) exit(0);
		swap(a[u],v);
	}
}
void getdep(int u){
	dep[u]=dep[f[u]]+1;
	for(int i=beg[u];i;i=nex[i])
		getdep(tto[i]);
}
int main(){
//	freopen("H.in","r",stdin);
//	freopen("H.out","w",stdout);
	int n;
	scanf("%d",&n);
	for(int i=2;i<=n;i++){
		scanf("%d",&f[i]);
		f[i]++;
		putin(f[i],i);
	}
	getdep(1);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		a[i]++;
	}
	while(!c[1]){
		color(1);
		while(change_color(1)){
			if(c[a[1]]==1){
				under[a[1]]=1;
				ans[++num]=find(a[1]);
			}
			else
				ans[++num]=find_deep(1);
			rotate(ans[num]);
		}
	}
	printf("%d\n",num);
	for(int i=1;i<=num;i++)
		printf("%d\n",ans[i]-1);
	for(int i=1;i<=n;i++)
		if(a[i]!=i)
			exit(-1);
	return 0;
}


Measured memory_bytes: 512
r,g,b,n=map(int,input().split())

ans=0
for R in range(n//r+1):
    for B in range((n)//b+1):
        if (R*r+B*b-n)<=0 and (R*r+B*b-n)%g==0:
            ans+=1
            
print(ans)

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

using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using tpi = tuple<int, int, int>;

using vqi = vector<queue<int>>;
using vpi = vector<pii>;
using bs = bitset<60>;
using vbi = vector<bs>;

ll gcd(ll a, ll b) {
    if (a < b) {
        swap(a, b);
    }

    /* ユークリッドの互除法 */
    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

constexpr int64_t __pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int64_t t = __pow_mod(n, p / 2, mod);
        return (t * t) % mod;
    }
    return (n * (__pow_mod(n, p - 1, mod) % mod)) % mod;
}

constexpr int64_t pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    int64_t res = __pow_mod(n, p, mod);
    if (res == 0) {
        res = mod;
    }
    return res;
}

constexpr int64_t nCr_mod(int64_t n, int64_t r, int64_t mod) noexcept {
    int64_t count = 1;
    auto a = r;
    for (auto i = n; i > n - r; i--) {
        count *= i;
        if (count % mod != 0) {
            count %= mod;
        }
        int64_t inv = pow_mod(a, mod - 2, mod);
        count *= inv;
        if (count % mod != 0) {
            count %= mod;
        }
        a--;
    }
    return count;
}

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

void solve(long long N) {
    string S = to_string(N);
    if (S.find("7") != string::npos) {
        cout << YES << endl;
    } else {
        cout << NO << endl;
    }
}

int main() {
    long long N;
    std::cin >> N;
    solve(N);
    return 0;
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvd = vector<vd>;

constexpr int MOD = 1000000007;

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

    int n;
    cin >> n;

    vector<vector<bool>> mat(n, vector<bool>(n));
    rep(i, 0, n) {
        rep(j, 0, n) {
            int x;
            cin >> x;
            mat[i][j] = (x == 1 ? true : false);
        }
    }

    vll dp(1 << n, 0);
    dp[0] = 1;
    rep(bit, 1, 1 << n) {
        int prev_row = __builtin_popcount(bit) - 1;

        rep(col, 0, n) {
            // bitのcol番目が立っている && 次の要素が0じゃない．
            if ((bit & (1 << col)) && mat[prev_row][col]) {
                dp[bit] = (dp[bit] + dp[bit ^ (1 << col)]) % MOD;
            }
        }
    }
    cout << dp.back() << endl;
    return 0;
}

Measured memory_bytes: 16768
h, w = map(int, input().split())
floor = [[1] + list(map(int, input().split())) for i in range(h)]
max_square, prev = 0, [0] * (w + 1)
for i in range(h):
    current = [0] * (w + 1)
    for j in range(1, w + 1):
        if floor[i][j]:
            current[j] = 0
            continue
        current[j] = min(prev[j - 1], prev[j], current[j - 1]) + 1
    prev = current
    max_square = max(max_square, max(current))

print(max_square ** 2)

Measured memory_bytes: 23132
#include<bits/stdc++.h>
using namespace std;
main(){
  int H,W,line=0;
  vector<vector<int>> a;
  vector<vector<int>> out;
  cin>>H>>W;
  a.resize(H);
  for(int i=0;i<H;i++)a[i].resize(W);
  for(int i=0;i<H;i++)for(int j=0;j<W;j++)cin>>a[i][j];
  for(int i=0;i<H;i++){
    if(i%2){
      for(int j=0;j<W-1;j++){
        if(a[i][j]%2){
          a[i][j]--,a[i][j+1]++;
          //out.push_back(to_string(i+1)+" "+to_string(j+1)+" "+to_string(i+1)+" "+to_string(j+1+1));
          vector<int> k{i,j,i,j+1};
          out.push_back(k);
          line++;
        }
      }
      //j==W-1
      if(i==H-1)break;
      if(a[i][W-1]%2){
        a[i][W-1]--,a[i+1][W-1]++;
        //out.push_back(to_string(i+1)+" "+to_string(W-1+1)+" "+to_string(i+1+1)+" "+to_string(W-1+1));
        vector<int> k{i,W-1,i+1,W-1};
        out.push_back(k);
        line++;
      }
    }
    else{
      for(int j=W-1;j>0;j--){
        if(a[i][j]%2){
          a[i][j]--,a[i][j-1]++;
          //out.push_back(to_string(i+1)+" "+to_string(j+1)+" "+to_string(i+1)+" "+to_string(j-1+1));
          vector<int> k{i,j,i,j-1};
          out.push_back(k);
          line++;
        }
      }
      //j==0
      if(i==H-1)break;
      if(a[i][0]%2){
        a[i][0]--,a[i+1][0]++;
        //out.push_back(to_string(i+1)+" 1 "+to_string(i+1+1)+" 1");
        vector<int> k{i,0,i+1,0};
        out.push_back(k);
        line++;
      }
    }
  }
  cout<<line<<endl;
  for(int i=0;i<out.size();i++)cout<<out[i][0]+1<<" "<<out[i][1]+1<<" "<<out[i][2]+1<<" "<<out[i][3]+1<<endl;
}

Measured memory_bytes: 9904
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use std::cmp::min;

#[fastout]
fn main() {
    input! {
    n: usize,
    }
    let mut ans = std::usize::MAX;
    let d = divisor(n);
    for i in 0..d.len() {
        let t = d[i] + n / d[i] - 2;
        ans = min(ans ,t);
    }
    println!("{}", ans);
}
fn divisor(m: usize) -> Vec<usize> {
    let mut l = Vec::new();
    for i in 1.. {
        if i * i > m {break}
        if m % i == 0 {
            l.push(i);
            l.push(m / i);
        }
    }
    l.sort();
    l.dedup();
    l
}


Measured memory_bytes: 2176
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int m1, d1, m2, d2;
  scan(m1, d1, m2, d2);
  print(m2 - m1);

  return 0;
}


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

string s;
int a, b;

int main(){
	cin >> s;
	a = stoi(s.substr(0, 2));
	b = stoi(s.substr(2, 2));
	if ((a == 0 || a > 12) && (b == 0 || b > 12)){
		cout << "NA";
	}
	else if (a > 0 && a <= 12 && b > 0 && b <= 12){
		cout << "AMBIGUOUS";
	}
	else if (a == 0 || a > 12){
		cout << "YYMM";
	}
	else if (b == 0 || b > 12){
		cout << "MMYY";
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>

#define size_t int

using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  int A, B;
  scanf("%d", &N);
  if (N == 1) {
    printf("Hello World\n");
  } else {
    scanf("%d %d", &A, &B);
    printf("%d\n", A + B);
  }
  return 0;
}


Measured memory_bytes: 128
N = int(input())
A = [0]+list(map(int, input().split()))+[0]

ans = 0
for i in range(N+1):
    ans += abs(A[i]-A[i+1])

for i in range(1,N+1):
    print(ans+abs(A[i-1]-A[i+1])-(abs(A[i-1]-A[i])+abs(A[i]-A[i+1])))

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

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

    int A[1010];
    int sum = 0;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
        // if (A[i] >= 1 / (4 * M)) ans++; 
    }

    for (int i = 0; i < N; i++) {
        if ((double)A[i] >= (double)sum / (4 * (double)M)) ans++; 
    }

    // cout << "ans, M = " << ans << " " << M << endl;
    if (ans >= M) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n;
	int a[20];
	int b[20];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		cin >> b[i];
	for (int i = 0; i < n; i++)
	{
		a[i] = a[i] - b[i];
		if (a[i] < 0)
			a[i] = 0;
	}
	int tong = 0;
	for (int i = 0; i < n; i++)
		tong = tong + a[i];
	cout << tong;

	
	return 0;
}

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

struct DSU {
    int n;
    vector<int> par, sz;

    void init(int _n) {
        n = _n;

        par.resize(n + 1);
        sz.resize(n + 1);

        for(int i = 1; i <= n; i++){
            par[i] = i;
            sz[i] = 1;
        }
    }

    int getRoot(int u) {
        if(par[u] == u) {
            return u;
        }

        return par[u] = getRoot(par[u]);
    }

    bool unite(int u, int v) {
        u = getRoot(u);
        v = getRoot(v);

        if(u == v) {
            return false;
        }

        par[u] = v;
        sz[v] += sz[u];

        return true;
    }

    bool same(int u, int v) {
        return getRoot(u) == getRoot(v);
    }
};

const int maxN = 2e5 + 55;

int n, m, k;

int f[maxN];
set<int> g[maxN];

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

    cin >> n >> m >> k;

    DSU dsu;

    dsu.init(n);

    for(int i = 0; i < m; i++){
        int u, v;   cin >> u >> v;

        g[u].insert(v);
        g[v].insert(u);

        dsu.unite(u, v);
    }

    for(int i = 1; i <= n; i++){
        //cerr << dsu.sz[dsu.getRoot(i)] << ' ';
        f[i] = dsu.sz[dsu.getRoot(i)] - (int)g[i].size() - 1;
    }

    for(int i = 0; i < k; i++){
        int u, v;   cin >> u >> v;

        if(dsu.same(u, v)) {
            if(g[u].count(v)) {
                continue;
            }

            f[u]--; f[v]--;
        }
    }

    for(int i = 1; i <= n; i++){
        cout << f[i] << ' ';
    }
    cout << '\n';

    return 0;
}


Measured memory_bytes: 21120
#include <stdio.h>
#include <stdlib.h>
#define max(a, b) (a > b? a : b);

long long row[300000], col[300000], point[300000];

int binary_search(long long target, long long array[], long long n)
{
    long long fn = 0, bn = n - 1, tmp;
    while (fn <= bn)
    {
        tmp = (fn + bn) / 2;
        if (array[tmp] < target) {fn = tmp + 1;} else if (array[tmp] > target) {bn = tmp - 1;} else {return tmp;}
    }
    return fn;
}

int compare(const void *a, const void *b) {return *(long long*)a > *(long long*)b ? 1 : (*(long long*)a == *(long long*)b ? 0 : -1);}

int main(void)
{
    long long H, W, M;
    scanf("%lld %lld %lld", &H, &W, &M);
    long long maxRow = 0, maxCol = 0;

    for (long long i = 0; i < M; i++)
    {
        long long a, b;
        scanf("%lld %lld", &a, &b);
        row[a - 1]++;
        col[b - 1]++;

        if (row[a - 1] > maxRow)
            maxRow = row[a - 1];
        if (col[b - 1] > maxCol)
            maxCol = col[b - 1];

        point[i] = a * W + b;
    }

    long long r = maxRow + maxCol - 1;

    long long numRow = 0, numCol = 0;
    long long indexRow[M], indexCol[M];
    for (long long i = 0; i < H; i++)
    {
        if (row[i] == maxRow)
        {
            indexRow[numRow++] = i;
        }
    }

    for (long long i = 0; i < W; i++)
    {
        if (col[i] == maxCol)
        {
            indexCol[numCol++] = i;
        }
    }
    qsort(point, M, sizeof(long long), compare);

    for (long long i = 0; i < numRow; i++)
    {
        for (long long j = 0; j < numCol; j++)
        {
            long long key = (indexRow[i]+1)*W+indexCol[j]+1;
            if (point[binary_search(key, point, M)] != key)
            {
                printf("%lld", r + 1);
                return 0;
            }
        }
    }

    printf("%lld", r);
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

class ModCalc
{
	LLONG m_mod = MOD;
	vector<LLONG> m_fac;
	vector<LLONG> m_ifac;

public:
	ModCalc(const LLONG mod)
	{
		m_mod = mod;
	}

	// Combinationを計算したいときの前処理：O(max)
	ModCalc(const int max, const LLONG mod)
	{
		m_mod = mod;
		m_fac = vector<LLONG>(max + 1);
		m_ifac = vector<LLONG>(max + 1);
		m_fac[0] = m_ifac[0] = 1;
		for (int i = 0; i < max; ++i)
		{
			m_fac[i + 1] = m_fac[i] * (i + 1) % mod;    // n! (mod M)
			m_ifac[i + 1] = m_ifac[i] * ModPow(i + 1, mod - 2) % mod;   // k!^(M-2) (mod M)
		}
	}

	const LLONG ModAdd(LLONG a, LLONG b) const
	{
		return (a + b) % m_mod;
	}

	const LLONG ModSubtract(LLONG a, LLONG b) const
	{
		LLONG diff = a - b;
		return diff >= 0 ? diff : diff + m_mod;
	}

	const LLONG ModMulti(LLONG a, LLONG b) const
	{
		LLONG prod = a * b % m_mod;
		return prod >= 0 ? prod : prod + m_mod;
	}

	const LLONG ModDiv(LLONG a, LLONG b) const
	{
		LLONG c = m_mod, u = 1, v = 0;
		while (c)
		{
			LLONG t = b / c;
			b -= t * c; swap(b, c);
			u -= t * v; swap(u, v);
		}
		u %= m_mod;
		if (u < 0) u += m_mod;
		return (a % m_mod) * u % m_mod;
	}

	const LLONG ModPow(LLONG x, LLONG n) const
	{
		LLONG ret = 1;
		while (n != 0)
		{
			if (n & 1) ret = ret * x % m_mod;
			x = x * x % m_mod;
			n = n >> 1;
		}
		return ret;
	}

	const LLONG ModComb(LLONG n, LLONG r) const
	{
		if (n == 0 && r == 0) return 1;
		if (n < r || n < 0) return 0;
		LLONG tmp = m_ifac[n - r] * m_ifac[r] % m_mod;
		return tmp * m_fac[n] % m_mod;
	}
};

int main()
{
	LLONG S; cin >> S;
	ModCalc mod(2000, MOD);
	LLONG ans = 0;
	LLONG n = 1;
	while (S - n * 3 >= 0)
	{
		ans = mod.ModAdd(ans, mod.ModComb(S - n * 3 + n - 1, n - 1));
		++n;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3660
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double PI = 3.14159265358979;
const double E = 2.718281828459045;
const double root2 = sqrt(2);
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int x; bool g = true;
	while (cin >> x) {
		if (x == 0)break;
		if (!g)cout << endl;
		if (g)g = false;
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int memo[4];
		int mi = (int)MOD;
		for (int i = 0; i <= a; i++) {
			for (int j = 0; j <= b; j++) {
				for (int k = 0; k <= c; k++) {
					for (int l = 0; l <= d; l++) {
						if (10 * i + 50 * j + 100 * k + 500 * l >= x) {
							int count = a+b+c+d-(i + j + k + l);
							int aaa = 10 * i + 50 * j + 100 * k + 500 * l - x;
							int atmemo[4] = {};
							atmemo[3] = aaa / 500; count += atmemo[3]; aaa %= 500;
							atmemo[2] = aaa / 100; count += atmemo[2]; aaa %= 100;
							atmemo[1] = aaa / 50; count += atmemo[1]; aaa %= 50;
							atmemo[0] = aaa / 10; count += atmemo[0];
							if (mi > count) {
								bool f = true;
								if (atmemo[0] * i > 0)f = false;
								if (atmemo[1] * j > 0)f = false;
								if (atmemo[2] * k > 0)f = false;
								if (atmemo[3] * l > 0)f = false;
								if (f) {
									mi = count;
									memo[0] = i; memo[1] = j; memo[2] = k; memo[3] = l;
								}
							}
						}
					}
				}
			}
		}
		if (memo[0] > 0) {
			cout << 10 << " " << memo[0] << endl;
		}
		if (memo[1] > 0) {
			cout << 50 << " " << memo[1] << endl;
		}
		if (memo[2] > 0) {
			cout << 100 << " " << memo[2] << endl;
		}
		if (memo[3] > 0) {
			cout << 500 << " " << memo[3] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3008
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, i, j;
    scanf("%d",&n);
    int height[n+5];
    for(i=1;i<=n;i++)
        scanf("%d",&height[i]);
    int ans = 1e9;
    int dp[n+5];
    for(i=1;i<=n;i++) dp[i] = 1e9;
    dp[1] = 0;
    for(i=2;i<=n;i++)
    {
        for(j=1;j<=2;j++)
        {
            if(i > j) dp[i] = min(dp[i], dp[i-j] + abs(height[i] - height[i-j]));
        }
    }
    printf("%d\n", dp[n]);
    return 0;
}


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

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}


int main() {
  int a,b,c,X;
  cin >> a >> b >> c >> X;
  int cnt=0;
  rep(i,a+1) rep(j,b+1) rep(k,c+1) {
    if (500*i + 100*j + 50*k == X) cnt++;
  }
  cout << cnt << endl;
} 

Measured memory_bytes: 256
class Combinator
  MAX = 2000000 # nCkの最大のnより大きいこと。MODより小さいこと。
  MOD = 1000000007

  def initialize
    @fac = Array.new(MAX)
    @fac[0] = 1
    @fac[1] = 1
    @finv = Array.new(MAX)
    @finv[0] = 1
    @finv[1] = 1
    @inv = Array.new(MAX)
    @inv[1] = 1
    (2..(MAX-1)).each do |i|
      @fac[i] = @fac[i-1]*i%MOD
      @inv[i] = MOD-@inv[MOD%i]*(MOD/i)%MOD
      @finv[i] = @finv[i-1]*@inv[i]%MOD
    end
  end

  def call(all, select)
    return 0 if all < select
    return 0 if all < 0||select < 0
    @fac[all]*(@finv[select]*@finv[all-select]%MOD)%MOD
  end
end
@combinator = Combinator.new

x, y = gets.split.map(&:to_i)
m = (2 * y - x) / 3
n = (2 * x - y) / 3
if m < 0 || n < 0 || x != m + 2 * n || y != n + 2 * m
  puts 0
  exit 0
end
puts @combinator.call(n+m, n)



Measured memory_bytes: 48636
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C;
    cin >> A >> B >> C;
    if(A != B && A != C){
        cout << A << endl;
    }else if(B != A && B != C){
        cout << B << endl;
    }if(A != C && B != C){
        cout << C << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,x) for(i=1;i<=x;i++)
using namespace std;
using ll = long long int;
typedef vector<ll> vi;
ll k,b,ar[11]={};
void Next_letter()
{
	char k;
	cin>>k,k++;
	cout<<k<<"\n";
}
void concat()
{
	string a,b;
	cin>>b>>a;
	cout<<a+b<<"\n";
}
int main()
{
    concat();
    return 0;
}

Measured memory_bytes: 256
import sys
def t(A,p,r):
 x=A[r][1];i=p-1
 for j in range(p,r):
  if A[j][1]<=x:i+=1;A[i],A[j]=A[j],A[i]
 A[i+1],A[r]=A[r],A[i+1]
 return i+1
def k(A,p,r):
 if p<r:q=t(A,p,r);k(A,p,q-1);k(A,q+1,r)
def m(L,R):
 T=[]
 for l in L[::-1]:
  while R and R[-1][1]>=l[1]:T+=[R.pop()]
  T+=[l]
 return R+T[::-1]
def d(A):l=len(A);s=l//2;return m(d(A[:s]),d(A[s:]))if l>1 else A
n=int(input())
f=lambda x,y:(x,int(y))
A=[f(*e.split())for e in sys.stdin]
B=A[:]
k(A,0,n-1)
print(['Not s','S'][A==d(B)]+'table')
for e in A:print(*e)


Measured memory_bytes: 20172
import math
a, b = map(int, input().split())

flg = 0
for i in range(1, math.ceil(max(a, b)/0.08)+1):
    aa = math.floor(i * 0.08)
    bb = math.floor(i * 0.1)
    if a == aa and b == bb:
        print(i)
        flg = 1
        exit()

if flg == 0:
    print(-1)


Measured memory_bytes: 3060
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int a=s.nextInt();
        int b=s.nextInt();
        int ans=0;
        int ch=1;
        while(ch<b){
            ch=ch+a-1;
            ans++;
        }
        System.out.print(ans);
    }
}


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

int main() {
#ifdef DEBUG

#endif

	int N, A, B;
	scanf("%d %d %d", &N, &A, &B);
	printf("%d\n", (N*A) < B ? N*A : B);
}

Measured memory_bytes: 128
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
#define __int64 long long
int n;
int t[333333];
ll d[333333];
ll p[333333];
ll ans;
map<ll,ll>b;
int main(){	
	cin>>n;
	rep(i,n)cin>>t[i];
	
	rep(i,n)d[i]=t[i];
	for(int i=1;i<n;i++)d[i]+=d[i-1];
	
	
	rep(i,n){
		b[d[i]]++;
	}
	ll s=0;
	rep(i,n){
		ans+=b[s];
		b[d[i]]--;
		s+=t[i];
		//cout<<s<<" "<<b[s]<<endl;
	}

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


Measured memory_bytes: 16896
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn =2e5+10;
const int mod=1e9+7;
char s[1005][1005];
int h,w;
int sx,sy,ex,ey;
int xx[5]={58,0,0,1,-1};
int yy[5]={58,1,-1,0,0};
int min1=1e9;

struct ac
{
    int x,y,step;
};


void bfs()
{
    deque<ac>q;
    q.push_front({sx,sy,0});
    s[sx][sy]='#';
    while(!q.empty())
    {
        ac u=q.front();
        q.pop_front();
        int x=u.x,y=u.y;
        if(x==ex&&y==ey)
        {
            min1=u.step;
            return;
        }
        s[x][y]='#';
        for(int i=1;i<=4;i++)
        {
            int tx=x+xx[i];
            int ty=y+yy[i];
            if(tx<1||ty<1||tx>h||ty>w||s[tx][ty]=='#')
                continue;
            q.push_front({tx,ty,u.step});
        }
        for(int i=x-2;i<=x+2;i++)
        {
            for(int j=y-2;j<=y+2;j++)
            {
                if(i<1||j<1||i>h||j>w||s[i][j]=='#')
                    continue;
                q.push_back({i,j,u.step+1});
            }
        }
    }
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>h>>w;
    cin>>sx>>sy>>ex>>ey;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            cin>>s[i][j];
        }
    }
    bfs();
    if(min1==1e9)
        cout<<-1<<'\n';
    else
        cout<<min1<<'\n';



}


Measured memory_bytes: 11168
#include <stdio.h>

int main()
{
    int n, i;
    long long int kotae = 1;
    
    scanf("%d", &n);
    
    for (i = n; i > 1; i--){
        kotae *= i;
    }
    printf("%lld\n", kotae);
    
    return 0;
}

Measured memory_bytes: 592
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >


int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
void solve(){
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}

signed main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("data.in","r",stdin);
        freopen ("data.out","w",stdout);
    #endif*/
    int t;
    t=1;
    while(t--){
        solve();
    }

     return 0;

}
///Alhamdulillah




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

using namespace std;

const int md = 1e9 + 7;
const int N = 21;

void add(int& a, int b) {
  a += b;
  if (a >= md) {
    a -= md;
  }
}

int n;
int dp[N][1 << N];
bool vis[N][1 << N];
int g[N][N];

int solve(int i, int t) {
  if (i == n) {
    return 1;
  }
  if (!vis[i][t]) {
    vis[i][t] = true;
    for (int j = 0; j < n; j++) {
      if (!(t & 1 << j) && g[i][j]) {
        add(dp[i][t], solve(i + 1, t | 1 << j));
      }
    }
  }
  return dp[i][t];
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &g[i][j]);
    }
  }
  printf("%d\n", solve(0, 0));
  return 0;
}


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

#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define rrep(i, a, b) for (int i = int(a) - 1; i >= b; i--)
#define sz(x) (int)(x).size()

using namespace std;
using ll = long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main(){
  ll N, K;
  cin >> N >> K;
  cout << min((K - N % K), (N % K)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()


int main() {
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int counter = 0;

	rep(i, 0, a+1){
		rep(j, 0, b+1){
			rep(k, 0, c+1){
				if (500 * i + 100 * j + 50 * k == x) ++counter;
			}
		}
	}

	cout << counter << endl;

}


Measured memory_bytes: 256
import * as fs from 'fs'
const inputs = fs.readFileSync('/dev/stdin', 'utf8').split(/\r?\n/)
const list: {l:string, d:number}[] = []
const n = parseInt(inputs.shift()!)
for (let i = 0; i < n; i++) {
    list.push({l:inputs.shift()!, d:1})
}
const m = parseInt(inputs.shift()!)
for (let i = 0; i < m; i++) {
    list.push({l:inputs.shift()!, d:-1})
}
const count = new Map<string, number>()
list.forEach(v => count.set(v.l, (count.get(v.l) || 0) + v.d))
console.log(Math.max(0, ...Array.from(count.values())))

Measured memory_bytes: 7500
#include <bits/stdc++.h>
#define optimize ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define INF 2000000020LL
#define ALL(x) x.begin(), x.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define POS(n, x) (lower_bound(ALL(n), x) - (n).begin())
#define ll long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define PB push_back
#define EB emplace_back
#define MOD 1000000007
#define PRIME 101 
#define MAXN 200020
#define MAXL 23
#define endl '\n'

using namespace std;

// (1 + sqrt(5)) / 2
const ld GOLDEN_RATIO = 1.6180339887498949025257388711906969547271728515625;
const ld PI = acos(-1.0);
const int BLOCK = 333;

int dp[MAXN], N, nums[MAXN];

int main(int argc, char const *argv[])
{
	optimize;	
	int K;

	cin >> N >> K;

	for(int i = 1; i <= N; i++)
		cin >> nums[i];

	for(int k = 1; k <= K; k++)
		for(int i = 1; !dp[k] && i <= N; i++)
			if(nums[i] <= k && !dp[k - nums[i]])
				dp[k] = true;

	cout << (dp[K] ? "First" : "Second") << endl;

	return 0;
}

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

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 FAST        ios_base :: sync_with_stdio(false); cin.tie(NULL);
typedef long long int ll;


int main()
{
	FAST;

	int n,m,c;
	cin >> n >> m >> c;

    vector<int> b(m);
	rep(i , m)
		cin >> b[i];
		
	vector<vector<int> > a(n , vector<int>(m));
	rep(i , n)
	{
	    rep(j , m)
	        cin >> a[i][j];
	}
		
	int ans = 0;
	rep(i , n)
	{
	    int sum = 0;
	    rep(j , m)
	        sum += b[j]*a[i][j];
	    if(sum+c > 0)
	        ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256