akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main() {
    vector<int> cand = {1};
    for(int i = 2; i <= 100; ++i) {
        int t = i * i;
        while(t <= 1000) {
            cand.push_back(t);
            t *= i;
        }
    }
    sort(begin(cand), end(cand));

    int x; cin >> x;
    cout << *(upper_bound(begin(cand), end(cand), x) - 1) << endl;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

constexpr int gcd(int a, int b) {
  while (b) b ^= a ^= b ^= a %= b;
  return a;
}

// deps: gcd
constexpr int lcm(const int &a, const int &b) {
  return a * b / gcd(a, b);
}

void solve() {
  int a, b;
  while (cin >> a >> b) cout << gcd(a, b) << ' ' << lcm(a, b) << endl;
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int H, W, D;
	cin >> H >> W >> D;
	vector<vector<int> > A(H, vector<int>(W, 0));
	unordered_map<int, pair<int, int> > a;
	for (int i = 0; i < H; i++)for (int j = 0; j < W; j++) {
		cin >> A[i][j];
		a[A[i][j]] = pair<int,int>(i+1, j+1);
	}
	vector<vector<int> > cost(D,vector<int>());
	for (int i = 0; i < D; i++) {
		for (int j = 0; (j+1) * D + i <= H*W; j++) {
			int tmp = abs(abs(a[j*D + i].first - a[(j + 1)*D + i].first) + abs(a[j*D + i].second - a[(j + 1)*D + i].second));
			cost[i].push_back(tmp);
		}
	}
	vector<vector<int> > cost2(D, vector<int>(1, 0));
	for (int i = 0; i < D; i++) {
		for (int j = 1; j < cost[i].size()+1; j++) {
			cost2[i].push_back(cost2[i][j - 1] + cost[i][j-1]);
		}
	}
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int L, R;
		cin >> L >> R;
		int tmp = cost2[L % D][R / D] - cost2[L % D][L / D];
		cout << tmp << endl;
	}

	return 0;
}

Measured memory_bytes: 11684
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(sc.hasNext()) {
      int c1 = sc.nextInt();
      int c2 = sc.nextInt();
      int c3 = sc.nextInt();
      int count=0;
      for(int i=1;i<=10;i++){
        if(i != c1 && i != c2 && i != c3 && (i+c1+c2) <= 20) {
	  count++;
	}
      }
      if(count > 3) {
        System.out.println("YES");
      }
      else {
	System.out.println("NO");
      }
    }    
  }
}

Measured memory_bytes: 26048
#include<iostream>
#include<stdio.h>
using namespace std;
int n,i,j,k,answer=0;
char s[301][301],other[301][301];
int main ()
{
	scanf("%d",&n);
	for (i=0;i<n;i++)
	scanf("%s",&s[i]);
	for (i=0;i<n;i++)
	{
		for (j=0;j<n;j++)
		for (k=0;k<n;k++)
		other[(i+j)%n][k]=s[j][k];
		for (j=0;j<n;j++)
		for (k=0;k<n;k++)
		if (other[j][k]!=other[k][j])
		goto abc;
		answer+=n;
		abc:;
	}
	printf("%d",answer);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    int n,m,l,r,l_max=0,r_min=100001;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        cin >> l >> r;
        l_max = max(l_max,l);
        r_min = min(r_min,r);
    }
    cout << max(0,r_min-l_max+1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    ll n, k; cin >> n >> k;
    cout << (n + k - 3) / (k - 1) << '\n';
}

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

    solve();
    return 0;
}
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  ll n,c=1LL;
  cin>>n;
  vector<ll> a(n);
  ll x=0LL,y=0LL,z=0LL;
  rep(i,n){
    cin>>a[i];
    if(x==a[i]){
      if(y==a[i]){
        if(z==a[i]){
          c*=3;c%=M;x++;
        }else{
          c*=2;c%=M;x++;
        }
      }else{
        c*=1;c%=M;x++;
      }
    }else if(y==a[i]){
      if(z==a[i]){
        c*=2;c%=M;y++;
      }else{
        c*=1;c%=M;y++;
      }
    }else if(z==a[i]){
      c*=1;c%=M;z++;
    }else{
      cout<<0;return 0;
    }
  }
  cout<<c;
}

Measured memory_bytes: 1024
N = int(input())
Alist = list(map(int, input().split()))
nums = [0, 0, 0]
ans = 1
for i in range(N):
    try:
        A = Alist[i]
        ans = (ans * nums.count(A)) % (10**9 + 7)
        nums[nums.index(A)] += 1
    except:
        print(0)
        break
else:
    print(ans)


Measured memory_bytes: 14396
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
   long long n,k ;
   cin >> n >> k ;
   long long h[n] ;
   for(int i=0;i<n;i++) cin >> h[i];
  
   sort(h,h+n,greater<int>());
   long long count = 0;
  
   long long ind = n-k ;
   if(k>=n){
     cout << 0 << endl ;     
     return 0;
   }else{
     for(long long i=k;i<n;i++)
     {
       count+= h[i] ;
     }
   }
     cout << count << endl ;     
     return 0;       
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(1); 
const ll mod=998244353;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=101000;
int p[N],n,a[N],rk[N];
void gao(string s,int t) {
	VI x,y;
	rep(i,0,n) if (s[i]=='1') {
		if (a[i]%2==0) x.pb(a[i]); else y.pb(a[i]);
	}
	if (t==1) x.swap(y);
	for (auto u:y) x.pb(u);
	int tt=0;
	rep(i,0,n) if (s[i]=='1') a[i]=x[tt++];
	
	/*rep(i,0,n) printf("%d ",a[i]);
	puts("");*/
	
	printf("%d %s\n",t,s.c_str());
}
int main() {
	scanf("%d",&n);
	int c=(n+1)/2;
	int even=0,odd=1;
	rep(i,0,n) {
		if (i<c) {
			if (i%2==0) p[i]=even,even+=2;
		} else {
			if (i%2==0) p[i]=odd,odd+=2;
		}
	}
	rep(i,0,n) {
		if (i<c) {
			if (i%2==1) p[i]=even,even+=2;
		} else {
			if (i%2==1) p[i]=odd,odd+=2;
		}
	}
	//rep(i,0,n) printf("%d ",p[i]);
	puts("29");
	rep(i,0,n) {
		if (p[i]%2==0) rk[p[i]]=i;
		else rk[p[i]]=n-i-1+(n%2);
		//printf("%d %d\n",p[i],rk[p[i]]);
	}
	rep(i,0,n) scanf("%d",a+i);
	//random_shuffle(a,a+n);
	rep(i,0,14) {
		gao(string(n,'1'),0);
		string s(n,'0');
		rep(j,0,n) {
			if (a[j]%2==0&&(rk[a[j]]&(1<<i))!=0) s[j]='1';
			if (a[j]%2==1&&(rk[a[j]]&(1<<i))!=0) s[j]='1';
		}
		gao(s,1);
	}
	string s(n,'0');
	rep(i,0,n) if (p[i]!=i) s[i]='1';
	gao(s,1);
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int M = 8;

const int m[M] = {1, 2, 1, 2, 1, 4, 1, 4};
int p[M];

typedef pair<int, int> pp;
typedef pair<pp, int> ppp;

int main()
{
    bool ends = 0;
    while(cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4]>> p[5]>> p[6]>> p[7])
    {

        int rest[M] = {}, num[M] = {};
        vector<ppp> ans;

        REP(M)
        {
            rep(j,M){ rest[i] += max(0, p[j] - m[(j + i)% M]) ; num[i] = num[i] * 10 + m[(j+i) % M];}
            ans.push_back(ppp(pp(rest[i], num[i]), i));
        }
        sort(all(ans));
        
        REP(M){ cout << m[(i+ans[0].second) % 8] ; if(i==M-1)break; cout << " ";}
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 0
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

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

from collections import defaultdict

n, t = li()
ab = [tuple(li()) for _ in range(n)]
ans = 0

# dp
dp = [[0]*t for _ in range(n+1)]

for i, (ai, bi) in enumerate(ab):
    for ti in range(t):
        if ti + ai < t:
            dp[i+1][ti + ai] = max(dp[i][ti + ai], dp[i][ti] + bi)
        dp[i+1][ti] = max(dp[i+1][ti], dp[i][ti])

# 経路復元
chose = set()
maxtime = dp[n].index(max(dp[n]))

for idx in range(n, 0, -1):
    if dp[idx][maxtime] != dp[idx-1][maxtime]:
        chose.add(idx-1)
        maxtime -= ab[idx-1][0]

allitem = set(range(n))
notchose = allitem - chose

notchosemax = 0
if notchose:
    for i in notchose:
        notchosemax = max(notchosemax, ab[i][1])

print(max(dp[n]) + notchosemax)


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

int main()
{
    int volumeBuckwheat;
    
    while (std::cin >> volumeBuckwheat) {
        if (volumeBuckwheat == 0) break;
        
        volumeBuckwheat /= 100;
        
        int money = 1000000;
        for (int i = 0; i < 26; ++i) {
            for (int j = 0; j < 17; ++j) {
                for (int k = 0; k < 11; ++k) {
                    if (2 * i + 3 * j + 5 * k == volumeBuckwheat) {
                        money = std::min(money, 
                                         i / 5 * 1520 + i % 5 * 380 +
                                         j / 4 * 1870 + j % 4 * 550 +
                                         k / 3 * 2244 + k % 3 * 850);
                    }
                }
            }
        }
        
        std::cout << money << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1160
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
//R 82 L 76
	
	static long D=0;
	public static void main(String[] args) {
		long N=sc.nextLong();
		
		p(N*(N-1)/2);
			
			//String S=sc.next();
			
			//int a[]=new int[N];
			//for(int i=0;i<N;i++) {}
	}
	/*static boolean v(int i,long sum1,long sum2) {
		if(i==N) {
			long b=Math.abs(sum1-sum2);
			if(b==0) {
				if(sum1<=K) {
					return true;
				}else return false;
			}else if(b%D==0) {
				if(Math.max(sum1, sum2)<=K)return true;
				else return false;
			}
			else return false;
		}
		
		if(v(i+1,sum1,sum2+v[i]%D))return true;
		
		if(v(i+1,sum1+D-v[i]%D,sum2))return true;
		return false;
		
	}*/
	
	
	
	//static int memo[][]=new int[501][1000];
	

	

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 21716
//Heaplax
#include<bits/stdc++.h>
#define N 10005
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int n,c[N],now,a[N];
int cnt,head[N],nxt[N+N],to[N+N];
void dfs(int u,int fa=0)
{
	a[u]=c[now--];
	for(int i=head[u],v;i;i=nxt[i])
		if((v=to[i]) != fa)
			dfs(v,u);
}
int main()
{
	re(n);
	for(int u,v,i=1;i<n;++i)
	{
		re(u),re(v);
		add_edge(u,v);
		add_edge(v,u);
	}
	for(int i=1;i<=n;++i)
		re(c[i]);
	sort(c+1,c+n+1);
	now=n;
	dfs(1);
	int ans=0;
	for(int i=1;i<n;++i)
		ans+=c[i];
	printf("%d\n",ans);
	for(int i=1;i<=n;++i)
		printf("%d ",a[i]);
	puts("");
}


Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] inputstr = br.readLine().trim().split(" ");
        int a = Integer.parseInt(inputstr[0]) * Integer.parseInt(inputstr[1]);
        int b = Integer.parseInt(inputstr[2]);
        System.out.println(Math.min(a, b));
    }
}

Measured memory_bytes: 23124
#include<iostream>
using namespace std;
int main(){
    char b;
    cin >> b;
    if(b == 'A'){
        cout << "T";
    }
    if(b == 'T'){
        cout << "A";
    }
    if(b == 'C'){
        cout << "G";
    }
    if(b == 'G'){
        cout << "C";
    }

}

Measured memory_bytes: 256
import itertools

N=int(input())
m = [0] * 5
for i in range(N):
  S = input()
  if S[0] == 'M':
    m[0] += 1
  elif S[0] == 'A':
    m[1] += 1
  elif S[0] == 'R':
    m[2] += 1
  elif S[0] == 'C':
    m[3] += 1
  elif S[0] == 'H':
    m[4] += 1
ans = 0
for (a,b,c) in itertools.combinations([0,1,2,3,4], 3):
  ans += m[a] * m[b] * m[c]
print(ans)



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

using namespace std;

typedef long long ll;

vector<int> calc(int n)
{
  const int sz = 55556;
  vector<int> sieve(sz, 1);
  sieve[0] = sieve[1] = 0;

  for (int i = 2; i < (int)sieve.size(); ++i) {
    for (int m = 2; i * m < sz; ++m) {
      sieve[i * m] = 0;
    }
  }
  int cnt = 0;
  vector<int> ret;
  for (int i = 2; i < (int)sieve.size() && cnt < n; ++i) {
    if (sieve[i] && (i % 5 == 1)) {
      ++cnt;
      ret.push_back(i);
    }
  }

  return ret;
}

int main()
{
  int n;
  scanf("%d", &n);
  vector<int> p = calc(n);
  copy(p.begin(), p.end(), ostream_iterator<int>(cout, " "));
  printf("\n");

  return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(){
    int n;
    char s[101]={};

    cin >> n >> s;

    int res = 0;

    if(n%2 == 1){
        cout << "No" << endl;
        return 0;
    }

    for(int i = 0; i < n/2; i++){
        if(s[i] != s[i+n/2]){
            res = 1;
            break;
        }
    }

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

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void){

  int a1,a2,a3;
  scanf("%d %d %d", &a1, &a2, &a3);
  int max = abs(a1-a2);
  if (abs(a2-a3) > max) {
    max = abs(a2-a3);
  }
  if (abs(a3-a1) > max) {
    max = abs(a3-a1);
  }
  int answer = abs(a1-a2)+abs(a2-a3)+abs(a3-a1)-max;
  printf("%d\n", answer);

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<vector>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#define int long long int
#define function function2
#define mod 1000000007
int function(int initial,int final,int memo[][101],int d,int sum)
{
	if(initial>final)
	{
		if(initial==1)
		  return 0;
		return sum==0?1:0;
	}
	if(memo[initial][sum]!=-1)
	   return memo[initial][sum];
	else
	{
		if(initial==1)
		{
			int answer=0;
			int j;
			for(j=1;j<=9;j++)
			{
				answer+=function(initial+1,final,memo,d,(sum+j)%d);
				answer%=mod;
			}
			memo[initial][sum]=answer;
			return answer;
		}
		else
		{
			int answer=0;
			if(sum==0)
			  answer++;
			for(int j=0;j<=9;j++)
			{
				answer+=function(initial+1,final,memo,d,(sum+j)%d);
				answer%=mod;
			}
			memo[initial][sum]=answer;
			return answer;
		}
	}
}
int function(int arr[],int initial,int final,int memo[][101][2],int status,int d,int sum)
{
	if(initial>final)
	{
		return sum==0?1:0;
	}
	if(memo[initial][sum][status]!=-1)
	  return memo[initial][sum][status];
	else
	{
		int val=arr[initial];
		if(initial==0)
		{
			int j;
			int answer=0;
			for(j=1;j<=val;j++)
			{
				int next=(sum+j)%d;
				int nextstatus=0;
				if(j<val)
				  nextstatus=1;
				answer+=function(arr,initial+1,final,memo,nextstatus,d,next);
				answer%=mod;
			}
			memo[initial][sum][status]=answer;
			return answer;
		}
		else
		{
			int j,answer=0;
			if(status==1)
			{
				for(j=0;j<=9;j++)
				{
					answer+=function(arr,initial+1,final,memo,1,d,(sum+j)%d);
					answer%=mod;
				}
				memo[initial][sum][status]=answer;
				return memo[initial][sum][status];
			}
			else
			{
				for(j=0;j<=val;j++)
				{
					int next=(sum+j)%d;
					int nextstatus=0;
					if(j<val)
					  nextstatus=1;
					answer+=function(arr,initial+1,final,memo,nextstatus,d,next);
					answer%=mod;
				}
				memo[initial][sum][status]=answer;
				return memo[initial][sum][status];
			}
		}
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string str;
	int d;
	cin>>str>>d;
	int n=str.size();
	int j,arr[n];
	for(j=0;j<n;j++)
	   arr[j]=str[j]-48;
	int answer=0;
	int memo[n+1][101];
	int i;
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=100;j++)
		{
			memo[i][j]=-1;
		}
	}
	answer+=function(1,n-1,memo,d,0);
	answer%=mod;
	int memo2[n+1][101][2];
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=100;j++)
		{
			for(int k=0;k<2;k++)
			{
				memo2[i][j][k]=-1;
			}
		}
	}
	int here=function(arr,0,n-1,memo2,0,d,0);
	answer+=here;
	answer%=mod;
	cout<<answer<<endl;
}


Measured memory_bytes: 28664
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
const lli inf=1e18;
const int mod=1e9+7;
int main(){
IOS;
int n,i;
cin>>n;
int a[n];
for(i=0;i<n;i++){
    cin>>a[i];
}
int left[n];
left[0]=0;
int maxi=0;
for(i=1;i<n;i++){
    if(a[i]>a[i-1])
        left[i]=i;
    else left[i]=left[i-1];
    maxi=max(maxi,i-left[i]);
}
cout<<maxi<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	int a, b, c, d,f;
	int e=0;
	while (cin >> e){
		f = 0;
		for (a = 0; a < 10; a++){
			for (b = 0; b < 10; b++){
				for (c = 0; c < 10; c++){
					for (d = 0; d < 10; d++){
						if (e == a + b + c + d){
							f = f + 1;
						}
					}
				}
			}
		}
		cout << f << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	while(1)
	{
		int m,f,r;
		cin >> m >> f >> r;
		if(m==-1&&f==-1&&r==-1)
		{
			break;
		}
		
		if(m==-1||f==-1)
		{
			cout<<'F'<<endl;
		}
		else if(m+f>=80)
		{
			cout<<'A'<<endl;
		}
		else if(m+f>=65)
		{
			cout<<'B'<<endl;
		}
		else if(m+f>=50||(r>=50&&m+f>=30))
		{
			cout<<'C'<<endl;
		}
		else if(m+f>=30)
		{
			cout<<'D'<<endl;
		}
		else
		{
			cout<<'F'<<endl;
		}
		
		
		
		
		
	}
	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;

int main(){
    double l;
    cin>>l;
    printf("%.12f\n", l*l*l/27);
    return 0;
}  


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

int main(){
	string num[101];
	int money[101];
	string tre[1001];
	int n,m;
	while(cin >> n >> m , n){
		int ans = 0;
		for(int i=0;i<n;i++){
			cin >> num[i] >> money[i];
		}
		for(int i=0;i<m;i++){
			cin >> tre[i];
			for(int j=0;j<n;j++){
				int flg = 1;
				for(int k=7;k>=0;k--){
					if(num[j][k] != '*'){
						if(num[j][k] != tre[i][k]){
							flg = 0;
							break;
						}
					}
					else break;
				}
				if(flg){
					ans += money[j];
					break;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1264
#include<stdio.h>
int main()
{
    int ary[5],count=0,bry[5];

    for(int i=0;i<5;i++)
        scanf("%d",&ary[i]);

    for(int i=0;i<5;i++)
    {
        count+=ary[i]/10;
        bry[i]=ary[i]%10;
        if(ary[i]%10==0)
            bry[i]=10;
        if((ary[i]%10)!=0)
            count++;

    }
    int small;
    small=10;
    for(int i=0;i<5;i++)
    {
        if(small>bry[i])
            small=bry[i];
    }
    printf("%d",count*10-((10-small)%10));

}


Measured memory_bytes: 128
N,Y=map(int,input().split())

Y/=1000

s=0

for i in range(N+1):
    for j in range(N+1-i):
        if i*10+j*5+(N-i-j)==Y:
            s=1
            print('{} {} {}'.format(i,j,N-i-j))
            break
    else:
        continue
    break

if s==0:
    print('-1 -1 -1')


Measured memory_bytes: 40684
#include<stdio.h>
#include<map>
#include<algorithm>
#include<stack>
#include<queue>
#include<string.h>
#include<math.h>
#include<iostream>
using namespace std;
char s[15];
int main()
{
    scanf("%s",s);
    if(s[2]==s[3]&&s[4]==s[5])printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 256
eval"A,B,_,*I="+`dd`.split*?,+"
s,t=[A,B].map{|a|[-F=1e15,*I.shift(a),F]}
I.map{|x|p s[s#{a='.bsearch_index{|y|y>x}-1,2].map{|'}s|t[t#{a}t|[(s-x).abs,(t-x).abs].min+(t-s).abs}.min}.min}"

Measured memory_bytes: 99056
#include<cstdio>
#include<iostream>
#include<string>

using namespace std;

int main(void){

	string komozi("abcdefghijklmnopqrstuvwxyz");
	string oomozi("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
	char inp;
	char retsu[1000000];
	
	for(int i=0;;i++){
		inp=getchar();
		if(inp=='\n'){
			retsu[i+1]='\0';
			break;
		}
		if(komozi.find(inp)!=-1) retsu[i]=oomozi[komozi.find(inp)];
		else if(oomozi.find(inp)!=-1) retsu[i]=komozi[oomozi.find(inp)];
		else retsu[i]=inp;
	}

	cout<<retsu<<endl;

	return 0;
}

Measured memory_bytes: 1172
a,b=input().split()
a,b=int(a),int(b)
c=a+b

#A,B,A+Bそれぞれについて3で割り切れるか判定

if a%3!=0 and b%3!=0 and c%3!=0:
	print("Impossible")
else:
	print("Possible")

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

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

using ll = long long;
using ull = unsigned long long;

int main() {
  string w, s;
  cin >> w;
  transform(w.begin(), w.end(), w.begin(), ::tolower);
  int ans = 0;
  while (true) {
    cin >> s;
    if (s == "END_OF_TEXT") break;
    transform(s.begin(), s.end(), s.begin(), ::tolower);
    if (s == w) ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3048
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
template <typename T>
using priority_queue_lo = priority_queue<T, vector<T>, greater<T>>;
#endif


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

    int N;  cin >> N;
    vl A(N*3);
    REP(i, N*3) cin >> A[i];

    priority_queue_lo<ll> pql;
    ll sum1 = 0;
    REP(i, N) {
        pql.push(A[i]);
        sum1 += A[i];
    }

    priority_queue<ll> pq;
    ll sum2 = 0;
    FOR(i, N*2, N*3) {
        pq.push(A[i]);
        sum2 += A[i];
    }

    vl sumL(N+1,0);
    sumL[0] = sum1;
    FOR(k,N,2*N) {
        pql.push(A[k]);
        sum1 += A[k];
        sum1 -= pql.top();
        sumL[k-N+1] = sum1;
        pql.pop();
    }

    vl sumR(N+1,0);
    sumR[N] = sum2;
    for (int k = 2 * N - 1; k >= N; k--) {
        pq.push(A[k]);
        sum2 += A[k];
        sum2 -= pq.top();
        sumR[k-N] = sum2;
        pq.pop();
    }

    ll ans = -LINF;
    REP(i,N+1) {
        ans = max(ans, sumL[i] - sumR[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5876
q=->a,*z,b{puts"? #{a} #{b}";$>.flush;gets[?N]}
A,B=gets.split.map &:to_i
A>B ? (
N,*g=A+B
N.times{|i|g[0]&&q[i,*g]?g.pop: g<<i}
puts"! "+N.times.map{|i|q[*g,i]?0:1}*''
):puts(:Impossible)


Measured memory_bytes: 22476
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  int n; cin >> n;
  
  set<int> s;
  rep(i, n){
    int d; cin >> d;
    s.insert(d);
  }

  cout << s.size() << endl;

  return 0;
}


Measured memory_bytes: 256
/*
 * じょえチャンネル
 * 高評価・チャンネル登録よろしくおねがいします！
 * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
 */
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define inf (int)(3e18)
#define P pair<int,int>
#define mod (int)(1e9+7)
template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}

int a[7];
signed main(){
	rep(i,7)cin>>a[i];
	int ans=0;
	ans+=a[1];

	int p=a[0],q=a[3],r=a[4];
	int pp=p,qq=q,rr=r;

	int ans1=0,ans2=0;
	if(p&&q&&r){
		ans1+=3;p--;q--;r--;
		ans1+=p/2*2;
		ans1+=q/2*2+r/2*2;
	}
	ans2+=pp/2*2;
	ans2+=qq/2*2+rr/2*2;
	cout<<ans+max(ans1,ans2)<<endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<cstdio>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<queue>
#include<unordered_set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull; 
const ll maxn = 100000 + 5;
int like[100];
int main(){
//	ios::sync_with_stdio(false);
//	ifstream cin("data.txt");
//	freopen("data.txt", "r", stdin);
	memset(like, 0, sizeof(like));
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		for(int j = 0; j < x; j++){
			int y;
			cin >> y;
			like[y]++;
		}
	}
	int sum = 0;
	for(int i = 1; i <= m; i++){
		if(like[i] == n)sum++;
	}
	cout << sum;
	return 0;
}

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

int main()
{
    int n, m;
    std::cin >> n>>m;
    std::vector<int> num(n, -1);

    for (int i = 0; i < m; i++) {
        int s, c;
        std::cin >> s >> c;
        bool ok = (num[s-1] == -1 || num[s-1] == c);
        if (!ok || (n > 1 && s == 1 && c == 0)) {
            std::cout << -1 << std::endl;
            return 0;
        }
        num[s-1] = c;
    }

    if (n == 1) {
        std::cout << std::max(0,num[0]) << std::endl;
        return 0;
    }

    std::cout << std::max(1,num[0]);
    for (int i = 1; i < n; i++) {
        std::cout << std::max(0,num[i]);
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
        cout<<'x';
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author P.Alizadeh
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long int   ll;
typedef long double     ld;
typedef pair<ll,ll>     pll;
typedef complex<ld>     cld;

#define all(x)          x.begin(),x.end()
#define Sort(x)         sort(all(x))
#define kill(x)         return cout << x << endl, 0;
#define Mp              make_pair
#define X               first
#define Y               second
#define sep             " "
#define endl            "\n"
#define fastio          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io         freopen("in.txt" , "r" , stdin) ; freopen("out.txt" , "w" , stdout);
#define ld_io           cout << setprecision(10) << fixed;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll pw(ll a, ll b, ll md) {
    if (!b)
        return 1;
    if (b & 1)
        return a * pw(a * a % md, b / 2, md) % md;
    return pw(a * a % md, b / 2, md) % md;
}

const ll MAXN = 2e5 + 10,
         INF  = 8e18,
         MOD  = 1e9 + 7,
         LOG  = 32;
//const ld PI   = M_PI;

template <ll N>
struct BITreeMAX {
    ll fen[N];

    BITreeMAX() {
        fill(fen, fen+N, 0);
    }

    void update(ll ind, ll val) {
        ind++;
        for (; ind <= N; ind += ind&(-ind)) {
            fen[ind] = max(fen[ind], val);
        }
    }

    ll get(ll r) {
        ll ans = 0;
        r++;
        for(; r > 0; r -= r&(-r)) {
            ans = max(ans, fen[r]);
        }
        return ans;
    }
};

ll n, h[MAXN], a[MAXN];
BITreeMAX<MAXN> fen;

int main()
{
    fastio;
    //ld_io;

    cin >> n;
    for (ll i = 0; i < n; i++)
        cin >> h[i];
    for (ll i = 0; i < n; i++)
        cin >> a[i];

    for (ll i = 0; i < n; i++) {
        ll mx = fen.get(h[i]);
        fen.update(h[i], mx + a[i]);
    }

    cout << fen.get(n) << endl;

    return 0;
}



Measured memory_bytes: 4992
#include "bits/stdc++.h"
using namespace std;

int main(){
    int N , Num , Sum = 0;
    scanf( "%d" , &N );
    int Max = 0;

    for( int i = 1 ; i <= N ; ++i ){
        scanf( "%d" , &Num );
        Max = max( Max , Num );
        Sum += Num;
    }

    Sum -= Max;

    if( Max < Sum ) puts( "Yes" );
    else puts( "No" );
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[][] graph = new int[n][n];
      String[] vInfo;
      int degree;

      for(int i=0,v=0; i<n; i++) {
        vInfo = br.readLine().split(" ");
        degree = Integer.parseInt(vInfo[1]);
        for(int j=0,k=2; j<degree; j++) {
          v = Integer.parseInt(vInfo[k++]);
          graph[i][v-1] = 1;
        }
      }

      StringBuilder buf = new StringBuilder(n*n);
      for (int[] vertex : graph) {
        for (int v : vertex) {
          buf.append(v).append(" ");
        }
        buf.setLength(buf.length()-1);
        buf.append("\n");
      }

      System.out.print(buf);
    }
    catch (IOException e) {
      System.err.println(e);
    }
  }
}


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

namespace ConsoleApp9
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var N = int.Parse(input);

            var items = new List<double>();

            for(var i = 0; i<N; i++)
            {
                var p_input = Console.ReadLine();
                items.Add(double.Parse(p_input));
            }

            double sum = 0;

            sum += (items.OrderByDescending(x => x).First())/2;

            sum += items.OrderByDescending(x => x).Skip(1).Sum();

            Console.WriteLine(sum);

            //Console.ReadKey();

        }
    }
}


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

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

	vector<int> h(N);
	for (int i = 0; i < N; i++) {
		cin >> h.at(i);
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (h.at(i) - K >= 0) {
			ans++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    vector<bool> v(b, false);
    for (int i = 1;;i++) {
        int amari = (a * i) % b;
        if (v[amari]) {
            cout << "NO" << endl;
            return 0;
        }
        if (amari == c) {
            cout << "YES" << endl;
            return 0;
        }
        v[amari] = true;
    }
}


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>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
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-2;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
int a[1 << 17], b[1 << 17];

int comp[1 << 17];
int num[1 << 17];
struct uf {
private:
	vector<int> par, ran;
public:
	void init(int n) {
		par.resize(n, 0);
		ran.resize(n, 0);
		rep(i, n) {
			par[i] = i;
			comp[i] = 1, num[i] = 0;
		}
	}
	int find(int x) {
		if (par[x] == x)return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x), y = find(y);
		num[x]++;
		if (x == y)return;
		if (ran[x] < ran[y]) {
			par[x] = y; num[y] += num[x]; comp[y] += comp[x];
		}
		else {
			par[y] = x; num[x] += num[y]; comp[x] += comp[y];
			if (ran[x] == ran[y])ran[x]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};
map<int, int> mp;

bool used[1 << 17];
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}
	vector<int> va, vb;
	int sa=0, sb=0;
	rep(i, n) {
		va.push_back(a[i]); sa ^= a[i];
		vb.push_back(b[i]); sb ^= b[i];
	}
	va.push_back(sa); vb.push_back(sb);
	sort(va.begin(), va.end());
	sort(vb.begin(), vb.end());
	if (va != vb) {
		cout << -1 << endl;
	}
	else {
		int cnt = 1;
		rep(i, n) {
			if (mp[a[i]] == 0) {
				mp[a[i]] = cnt; cnt++;
			}
		}
		if (mp[sa] == 0) {
			mp[sa] = cnt; cnt++;
		}
		uf u; u.init(cnt);
		rep(i, n) {
			if (a[i] == b[i])continue;
			u.unite(mp[a[i]], mp[b[i]]);
		}
		int ans = 0;
		rep1(i, cnt-1) {
			if (used[i])continue;
			int p = u.find(i);
			if (used[p])continue;
			if (comp[p] == 1)continue;
			ans += num[p];
			if (!u.same(p, mp[sa]))ans++;
			used[p] = true;
		}
		cout << ans << endl;
	}
	//stop
	return 0;
}

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

typedef long long ll;
#define PI 3.1415926535897932384626433
#define mod 1000000007

int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

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

int main(){
    string s;
    cin >> s;
    bool c = false, f = false;
    for (int i = 0; i < s.size(); i++){
        if(s[i] == 'C'){
            c = true;
        }
        if(s[i] == 'F' && c == true){
            f = true;
        }
    }
    if(c && f){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
const ll MX = 1e18;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};

int main(){
  ll n;
  cin>>n;
  vll a(n);
  rep(i,n){
    cin>>a[i];
    if(a[i]==0){
      COUT(0);
      return 0;
    }
  }
  ll ans=1;
  rep(i,n){
    if(ans>MX/a[i]){
      COUT(-1);
      return 0;
    }
    else{
      ans*=a[i];
    }
  }
  COUT(ans);
}

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

#define INF 1e9
using namespace std;
typedef long long ll;

int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

int main() {

    int h, w; cin >> h >> w;

    vector<string> s(h);
    for (int i = 0; i < h; ++i) {
        cin >> s[i];
    }

    bool res = true;

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (s[i][j] == '#') {
                //4方向を確認
                bool find = false;

                for (int k = 0; k < 4; ++k) {
                    int nh = i + dh[k];
                    int nw = j + dw[k];

                    if (0 <= nh && nh < h && 0 <= nw && nw < w && s[nh][nw] == '#') {
                        find = true;
                    }
                }

                if (!find) {
                    res = false;
                }
            }
        }
    }

    if (res) {
        puts("Yes");
    } else {
        puts("No");
    }
}

Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
c=0
l=[0]*n
while l!=h:
  if l[0]!=h[0]:
    c+=1
    for i in range(1,n-1):
      if l[i]==h[i] and l[i+1]!=h[i+1]:
        c+=1
  else:
    for i in range(n-1):
      if  l[i]==h[i] and l[i+1]!=h[i+1]:
        c+=1
  for i in range(n):
    if l[i]!=h[i]:
      l[i]+=1    
print(c)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
#include <atcoder/mincostflow>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()




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

	int n, k;
	cin >> n >> k;
	int a[50][50];
	rep(i, n)rep(j, n)cin >> a[i][j];

	int nodes = n + n * n + n + 2;
	atcoder::mcf_graph<int, long long> g(nodes);

	rep(i, n)rep(j, n) {
		g.add_edge(n * n + i, i * n + j, 1, INF - a[i][j]);
		g.add_edge(i * n + j, n * n + n + j, 1, 0);
	}
	rep(i, n) g.add_edge(nodes - 2, n* n + i, k, 0);
	rep(i, n) g.add_edge(n* n + n + i, nodes - 1, k, 0);


	int maxf = 0;
	long long maxs = 0;
	vector<pair<int, long long>> slope = g.slope(nodes - 2, nodes - 1);
	for (auto s: slope) {
		long long score = (long long)INF * s.first - s.second;
		if (maxs < score) {
			maxs = score;
			maxf = s.first;
		}
	}


	auto edges = g.edges();
	g = atcoder::mcf_graph<int, long long>(nodes);
	for (auto e: edges) {
		g.add_edge(e.from, e.to, e.cap, e.cost);
	}
	g.flow(nodes - 2, nodes - 1, maxf);

	cout << maxs << endl;
	rep(i, n) {
		rep(j, n) {
			auto e = g.get_edge(2 * (i * n + j));
			if (e.flow == 1)cout << 'X';
			else cout << '.';
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 4344
#include <bits/stdc++.h>
using namespace std;
int a,b,c,d;
int main() {
	cin>>a>>b>>c>>d;
	if(a*b>c*d)cout<<a*b<<endl;
	else if(c*d>a*b)cout<<c*d<<endl;
	else cout<<a*b<<endl;
		return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int main()
{
	string a,b,c;
	cin>>a>>b>>c;
	cout<<a[0]<<b[1]<<c[2]; 
}


Measured memory_bytes: 256
from math import sqrt,floor

def main():
    n = int(input())
    rn = floor(sqrt(n))
    movesteps = set()
    for i in range(1, rn + 1):
        if n % i == 0:
            movesteps.add(i + int(n / i) - 2)
    print(min(movesteps))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    ll A[N+1]={0};
    FORI(i,2,N+1)
    {
        READV(x);
        A[x]++;
    }
    FORI(i,1,N+1)
    {
        cout<<A[i]<<endl;
    }

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


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

Measured memory_bytes: 5376
Module Module1

    Dim SS() As String

    Sub Main()
        Dim str = Console.ReadLine
        Dim S(str.Length - 1) As String
        For i As Integer = 0 To str.Length - 1
            S(i) = str.Substring(i, 1)
        Next
        SS = S
        Console.WriteLine(Dfs(0, SS(0)))
        'Debug.WriteLine(Dfs(0, SS(0)))
    End Sub

    Function Dfs(i As Integer, str As String) As Long

        If i >= SS.Length - 1 Then
            Dim r As Long = 0
            Dim arr() As String = str.Split("+")
            For Each a As String In arr
                r += a
            Next
            Return r
        End If

        Return Dfs(i + 1, str + SS(i + 1)) + Dfs(i + 1, str + "+" + SS(i + 1))

    End Function

End Module


Measured memory_bytes: 28224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k,m;
  m=0;
  cin >> n >> k;
  vector<int>a(n);
  for (int i=0;i<n;i++) {
    cin >> a.at(i); 
  }
  sort(a.begin(),a.end());
  for (int i=0;i<k;i++) {
    m+=a.at(i); 
  }
  cout << m << endl;
}

Measured memory_bytes: 3628
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
  s = input()
  if (s == "AC"):
    ac += 1
  elif (s == "WA"):
    wa += 1
  elif (s == "TLE"):
    tle += 1
  elif(s == "RE"):
    re += 1
    
print("AC x {0}".format(ac))
print("WA x {0}".format(wa))
print("TLE x {0}".format(tle))
print("RE x {0}".format(re))

Measured memory_bytes: 9196