akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	LD T, X;
	cin >> T >> X;
	cout << T / X << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


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

int main(){
    double pr,am,pr_sum=0,am_sum=0;
    int n=0;
    char c;

    while(cin>>pr){
        cin>>c>>am;
        pr_sum+=pr*am;
        am_sum+=am;
        n++;
    }

    cout<<int(pr_sum)<<endl;
    cout<<round(am_sum/n)<<endl;

    return 0;
}

Measured memory_bytes: 1296
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <set>
#include<algorithm>
using namespace std;
int a[105];
int b[105];
int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
   int n;
    scanf("%d",&n);
    int ma = 0;
    int i;
    multiset<int> s;
    multiset<int>::iterator I;
    for(i=1;i<=n;i++)
        {
        scanf("%d",&a[i]);
        ma = max(ma,a[i]);
        s.insert(a[i]);
        b[a[i]]++;
    }
    if(ma%2==0)
        {
        i = ma/2;
        I = s.find(i);
        if(I==s.end())return printf("Impossible\n")*0;
        s.erase(I);
        for(i++;i<=ma;i++)
            {
            I = s.find(i);
           if(I==s.end())return printf("Impossible\n")*0;
        s.erase(I);
            I = s.find(i);
             if(I==s.end())return printf("Impossible\n")*0;
        s.erase(I);
        }
    }
    else {
        for(i=(1+ma)/2; i<=ma;i++)
            {
            I = s.find(i);
             if(I==s.end())return printf("Impossible\n")*0;
        s.erase(I);
            I = s.find(i);
             if(I==s.end())return printf("Impossible\n")*0;
        s.erase(I);
        }
    }
   // printf("remaining %d\n",s.size());
   if(s.size()==0) return  printf("Possible\n")*0;
    int mi = (1+ma)/2 + 1;
    if(*s.begin()<mi)return printf("Impossible\n")*0;
    printf("Possible\n");
    return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,tmp = 1;
	vector<int> vec;
	cin >> n;
	if(!n){
		cout << 0 << endl;
		return 0;
	}
	while(n){
		if(n % 2 == 0) vec.pb(0);
		else{
			vec.pb(1);
			n--;
		}
		n /= -2;
	}
	for(int i = vec.size() - 1;i >= 0;i--) cout << vec[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
list_B = list(map(int, input().split()))
list_A = [0]*(len(list_B) + 1)

for i in reversed(range(len(list_B))):

    #書き換えるかどうかの判断
    if list_B[i] < list_A[i + 1]:
        list_A[i + 1] = list_B[i]

    list_A[i] = list_B[i]

#右端の処理
list_A[-1] = list_B[-1]

print(sum(list_A))

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>

#define INF 100000000
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;


   

int main(){
    int n; cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    
    int sum = 0;
    
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
            sum += d[i]*d[j];
        }
    }

    cout << sum << endl;
    
    
}


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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll add(ll x, ll y)
{
    x += y;
    if (x >= MOD)
        return x - MOD;
    return x;
}
ll sub(ll x, ll y)
{
    x -= y;
    if (x < 0)
        return x + MOD;
    return x;
}
ll mult(ll x, ll y)
{
    return (x * y) % MOD;
}
ll bin_pow(ll x, ll p)
{
    if (p == 0)
        return 1;
    if (p & 1)
        return mult(x, bin_pow(x, p - 1));
    return bin_pow(mult(x, x), p / 2);
}

int f(int x){
    return x * (x + 1) / 2;
}
signed main()
{
    int n, k;
    cin >> n >> k;
    COMinit();
    int x = bin_pow(10, 100);
    int cnt = 0;
    for (int i = 0; i <=n-k+1; i++)
    {
        cnt += COM(n, k - 1 + i);
        cnt %= MOD;
    }

    int ans = 0;
  //  cerr << x << endl;
    for (int i = k; i <= n+1; i++)
    {
        if(i==n+1){
            ans += 1;
            continue;
        }
        ans += f(n) - f(n - i)  - f(i-1)+1;
        ans %= MOD;
     //   cerr << f(n) - f(n - i) <<" "<<f(i-1)<< endl;
    }
    cout << ans%MOD << endl;
    return 0;
}

Measured memory_bytes: 15576
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
       
       //入力準備
       Scanner sc = new Scanner(System.in);
       
       //入力値の受け取り
       int a = sc.nextInt();
       int b = sc.nextInt();
       
       //計算して出力
        System.out.print(a*b);
        System.out.print(" ");
        System.out.println((a+b)*2);
   }
}



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

std::vector<std::vector<int>> s;
std::vector<int> p;
int N, M;

bool condition(int set_i)
{
	for (int m_i{}; m_i < M; m_i++)
	{
		int count{};
		for (int n_i{}; n_i < N; n_i++)
			if ((set_i >> n_i & 1) && s[m_i][n_i])
				count++;
		if (count % 2 != p[m_i])
			return false;
	}
	return true;
}

int main()
{
	scanf("%d%d", &N, &M);
	s.resize(M, std::vector<int>(N));
	for (int i{}; i < M; i++)
	{
		int k;
		scanf("%d", &k);
		for (int j{}; j < k; j++)
		{
			int tmp;
			scanf("%d", &tmp);
			tmp--;
			s[i][tmp]++;
		}
	}
	p.resize(M);
	for (auto& e: p) scanf("%d", &e);
	int count{};
	for (int set_i{}; set_i < (1 << N); set_i++)
		if (condition(set_i)) count++;

	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 256
SENTINEL = float('inf')
count = 0


def main():
    n = int(input())
    a_s = list(map(int, input().split(' ')))
    merge_sort(a_s, n, 0, n)
    print(' '.join(map(str, a_s)))
    print(count)


def merge_sort(A, n, left, right):
    if left+1 < right:
        mid = (left+right) // 2
        merge_sort(A, n, left, mid)
        merge_sort(A, n, mid, right)
        merge(A, n, left, mid, right)


def merge(A, n, left, mid, right):
    global count
    L = A[left:mid]
    R = A[mid:right]
    L.append(SENTINEL)
    R.append(SENTINEL)
    i = j = 0
    for k in range(left, right):
        count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1


if __name__ == "__main__":
    main()



Measured memory_bytes: 66784
/*  ex6_2
    pptenshi */

#include<stdio.h>
#include<string.h>
#define LIMIT 110

int main(void) {
    char string[LIMIT];
    int len_str;

    //input
    scanf("%s", string);
    len_str = strlen(string);


    //output
    printf("%c%d%c\n", string[0], len_str - 2, string[len_str - 1]);

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
 
int main()
{
    int x, y;
     
    while(1)
    {
        scanf("%d %d\n", &x, &y);
        if(x == 0 && y == 0) break;
   
        if(x < y)
        {
            printf("%d %d\n", x, y);
        }
        else
        {
            printf("%d %d\n", y, x);
        }
    }
    return 0;
}

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

int main(void) {
  string S;
  string ans = "keyence";
  cin >> S;
  int n = S.length();
  bool flag = false;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      string tmp = "";
      for (int k = 0; k < n; k++) {
        if (i <= k && k < j) continue;
        tmp += S[k];
      }
      if (tmp == ans) flag = true;
    }
  }
  cout << (flag || S == ans ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a[12][12];
	int x,y,size,i,j,m=0,cnt=0;
	
	for(i=0;i<12;i++){
		for(j=0;j<12;j++){
			a[i][j]=0;
		}
	}
	
	while(scanf("%d,%d,%d",&x,&y,&size)!=EOF){
		a[x][y]++;
		a[x-1][y]++;
		a[x+1][y]++;
		a[x][y-1]++;
		a[x][y+1]++;
		if(size>1){
			a[x+1][y+1]++;
			a[x+1][y-1]++;
			a[x-1][y+1]++;
			a[x-1][y-1]++;
		}
		if(size==3){
			a[x+2][y]++;
			a[x-2][y]++;
			a[x][y+2]++;
			a[x][y-2]++;
		}
	}
	
	for(i=0;i<10;i++){
		for(j=0;j<10;j++){
			if(a[i][j]==0) cnt++;
			if(a[i][j]>m) m=a[i][j];
		}
	}
	
	printf("%d\n%d\n",cnt,m);
	return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES(n)          cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n)          cout << ((n) ? "Yes" : "No"  ) << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

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

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int n; cin >> n;
  vector<int> a(n); rep(i, n) cin >> a[i];
  sort(a);
  outl(a[n-1] - a[0]);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 888
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
ans = []
for i in range(H):
  for j in range(W):
    if i == H-1 and j == W-1:
      continue
    if i == H-1:
      if A[i][j] % 2 == 1:
        A[i][j] -= 1; A[i][j+1] += 1;
        ans.append((i,j,i,j+1))
    elif A[i][j] % 2 == 1:
      A[i][j] -= 1; A[i+1][j] += 1;
      ans.append((i,j,i+1,j))
print(len(ans))
for i1, j1, i2, j2 in ans:
  print(i1+1, j1+1, i2+1, j2+1)

Measured memory_bytes: 22764
#
# File    : B.rb
# Author  : Kazune Takahashi
# Created : 2018-11-4 16:38:39
# Powered by Visual Studio Code
#

x = gets.to_i
ok = Array.new(1010){false}
ok[0] = ok[1] = true

for i in 2...1010 do
  for j in 2...1010 do
    if i ** j < 1010
      ok[i ** j] = true;
    else
      break
    end
  end
end

for i in 0...1010 do
  if ok[x - i]
    puts x - i
    exit
  end
end

Measured memory_bytes: 3836
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
         
        while(true){
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            
            if(m == -1 && f == -1 && r == -1)
                break;
            if(m == -1 || f == -1){
                System.out.println("F");
            }else if(m+f>=80){
                System.out.println("A");
            }else if(m+f>=65){
                System.out.println("B");
            }else if(m+f>=50||r>=50){
                System.out.println("C");
            }else if(m+f>=30){
                System.out.println("D");
            }else{
                System.out.println("F");
            }
        }
        sc.close();
    }
} 



Measured memory_bytes: 26300
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <iostream>
using namespace std;
typedef pair<int,int> P;
#define pb push_back
#define INF 1000000000
#define fi first
#define sec second
struct edge{int to,cost;};
vector<edge> g[5050],newg[5050];
int c[5050],p[5050],d[5050],dist[5050];
int n,k;
void bfs(int s)
{
	queue<P> q;
	fill(d,d+n,INF);
	d[s]=0;
	q.push(P(0,s));
	while(!q.empty())
	{
		P a=q.front();q.pop();
		int v=a.sec;
		if(d[v]<a.fi)continue;
		for(int i=0;i<g[v].size();i++)
		{
			edge e=g[v][i];
			if(d[e.to]>d[v]+e.cost)
			{
				d[e.to]=d[v]+e.cost;
				q.push(P(d[e.to],e.to));
			}
		}
	}
	return;
}
int dijkstra()
{
	priority_queue<P,vector<P>,greater<P> > q;
	fill(dist,dist+n,INF);
	dist[0]=0;
	q.push(P(0,0));
	while(!q.empty())
	{
		P a=q.top();q.pop();
		int v=a.sec;
		if(dist[v]<a.fi)continue;
		for(int i=0;i<newg[v].size();i++)
		{
			edge e=newg[v][i];
			if(dist[e.to]>dist[v]+e.cost)
			{
				dist[e.to]=dist[v]+e.cost;
				q.push(P(dist[e.to],e.to));
			}
		}
	}
	return dist[n-1];
}
int main()
{
	cin >> n >> k;
	for(int i=0;i<n;i++)cin >> c[i] >> p[i];
	for(int i=0;i<k;i++)
	{
		int a,b;
		cin >> a >> b;
		a--;b--;
		edge in;
		in.to=b;
		in.cost=1;
		g[a].pb(in);
		in.to=a;
		g[b].pb(in);
	}
	for(int i=0;i<n;i++)
	{
		bfs(i);
		for(int j=0;j<n;j++)
		{
			if(i==j)continue;
			if(d[j]<=p[i])
			{
				edge ne;
				ne.to=j;ne.cost=c[i];
				newg[i].pb(ne);
			}
		}
	}
	cout << dijkstra() << endl;
	return 0;
}

Measured memory_bytes: 126144
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double PI = 3.14159265358979323846;
template <class T, class U>
void chmin(T& t, const U& u) {
  if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
  if (t < u) t = u;
}

int main(void) {
  int x;
  cin >> x;
  cout << (x == 1 ? 0 : 1) << endl;
  return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main{
	
	public static void main (String []args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		
		int []a = new int [n];
		
		for(int i = 0 ; i < n ;i++) {
			int b = Integer.parseInt(sc.next());
			a[i] = m - b;
		}
		
		long [][]dp = new long [n+1][2* m * n +1];
		
		dp[0][m*n] = 1;
		
		for(int i = 1 ; i <= n ;i++) {
			for(int j = 0 ; j <= 2 * m * n ; j++) {
				if(j - a[i-1]  > 2 * m * n || j - a[i-1] < 0) {
					dp[i][j] = dp[i-1][j];  
				}
				else {
					dp[i][j] = dp[i-1][j] + dp[i-1][j-a[i-1]];
				}
			}
		}
		
		long ans = dp[n][m*n];
		System.out.println(ans-1);
		
		
		
 			
		}

}


Measured memory_bytes: 25556
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << a*b/2 << endl;
    return 0;
}

Measured memory_bytes: 256
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 10;
int x[N], y[N], nxt[N];
int n, a[N], b[N];
bool mark[N];

inline void read_input() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[x[i] = i];
	for (int i = 0; i < n; i++)
		cin >> b[y[i] = i];
}

inline void solve() {
	sort(x, x + n, [] (int i, int j) {
		return a[i] < a[j];
	});
	sort(y, y + n, [] (int i, int j) {
		return b[i] < b[j];
	});
	sort(a, a + n);
	sort(b, b + n);
}

inline void write_output() {
	bool ok = false;
	for (int i = 0, p = 0; i < n; i++) {
		while (p < n && b[i] >= a[p])
			p++;
		if (p <= i) {
			cout << "No";
			return;
		}
		ok |= p > i + 1, nxt[x[i]] = y[i];
	}
	if (ok) {
		cout << "Yes";
		return;
	}
	for (int i = 0; !mark[i]; i = nxt[i])
		mark[i] = true;
	for (int i = 0; i < n; i++)
		if (!mark[i]) {
			cout << "Yes";
			return;
		}
	cout << "No";
}

int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	read_input(), solve(), write_output();
	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int ag=0,bg=0;
  if((a-2)==0){
    ag=1;
  }else if((a-4)*(a-6)*(a-9)*(a-11)==0){
    ag=2;
  }else{
    ag=3;
  }
  
  if((b-2)==0){
    bg=1;
  }else if((b-4)*(b-6)*(b-9)*(b-11)==0){
    bg=2;
  }else{
    bg=3;
  }
  (ag==bg?cout<<"Yes":cout<<"No")<<endl;  
}

Measured memory_bytes: 256
n = int(input())
ans = 0
lis = []
for i in range(1,n):
    r = n - i
    ti = list(str(i))
    tr = list(str(r))
    for k in range(len(ti)):
        ti[k] = int(ti[k])
    for k in range(len(tr)):
        tr[k] = int(tr[k])
    lis.append(sum(ti)+sum(tr))
print(min(lis))

Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  vector<int> b(N);
  vector<bool> comp(N);
  for (int j = 0; j < N; j++) {
    for (int k = 0; k < N; k++) { 
      if (comp.at(k) == true) {
        continue;
      }
      if (b.at(j) < d.at(k)) {
        b.at(j) = d.at(k);
      }
    }
    for (int l = 0; l < N; l++) {
      if (b.at(j) == d.at(l)) {
        comp.at(l) = true;
      }
    }
  }      
  for (int m = 0; m < N; m++) {
    if (b.at(N - m - 1) == 0) {
      b.pop_back();
    }
    else {
      break;
    }
  }
  cout << b.size() << endl;
}

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

int main(int argc, char *argv[])
{
    int X;
    std::cin >> X;
    if ((X == 3) || (X == 5) || (X == 7)) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO"  << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		long N = sc.nextLong();
		long P = sc.nextLong();
		if (N == 1){
			System.out.println(P);
			return;
		}
		long temp = P;
		long mul = 1;
		for (long i = 2; i*i <= P; i++) {
			int counter = 0;
			while (temp % i == 0){
				temp /= i;
				counter++;
				if (counter >= N){
					mul *= i;
					counter = 0;
				}
			}
		}
		System.out.println(mul);
	}
}

class Main {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 23636
void main() {
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], m = tmp[1];
    string[] a = new string[n], b = new string[m];
    foreach (i; 0 .. n) {
        a[i] = readln.chomp;
    }
    foreach (i; 0 .. m) {
        b[i] = readln.chomp;
    }
    bool ok;
    foreach (i; 0 .. n-m+1) {
        foreach (j; 0 .. n-m+1) {
            bool check = true;
            foreach (k; 0 .. m) {
                if (a[j+k][i..i+m] != b[k]) {
                    check = false;
                }
            }
            if (check) ok = true;
        }
    }
    writeln(ok ? "Yes" : "No");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N, K = rl()
S = rs()

import itertools
g = list(itertools.groupby(S))

print(N-max(len(g)-1-2*K, 0)-1)


Measured memory_bytes: 56412
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    double a,b,c,d=0,e=0;
    cin>>a>>b;
    if(a==1 && b==2 || a==2 && b==1){cout<<3;}
    if(a==1 && b==3 || a==3 && b==1){cout<<2;}
    if(a==2 && b==3 || a==3 && b==2){cout<<1;}
    return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#define rep(i, a, n) for(int i = a;i < n;i++)
using namespace std;


int n;
int a[100000];


int count(int s, int v){
	int cnt = 0;
	rep(i, s, n){
		if(a[i] > v) return cnt;
		if(a[i] == v) cnt++;
	}
	return cnt;
}


int solve(){
	int cnt = 0;
	sort(&a[0], &a[n]);
	for(int i = 0;i < n;){
		int c = count(i, a[i]);
		if(a[i] > c) cnt += c;
		else if(a[i] < c) cnt += c - a[i];
		i += c;
	}
	return cnt;
}


int main(){
	cin >> n;
	rep(i, 0, n) cin >> a[i];

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
using namespace std;
 
int n,k;
long long a[200015];
 
int c(long long p){
    int i=0;
 
    for(int j=0;j<k;j++){
        long long s=0;
        while(s+a[i]<=p){
            s+=a[i];
            i++;
            if(i==n)
                return n;
        }
    }
    return i;
}
 
int s(){
    long long left=0;
    long long right=1000000000;
    long long mid;
    while(right-left>1){
        mid=(right+left)/2;
        int v=c(mid);
        if(v>=n) right=mid;
        else left=mid;
    }
    return right;
}
 
int main(){
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    printf("%d\n",s());
    return 0;
}

Measured memory_bytes: 3512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int K;
    cin >> K;
    int ret = 0;
    for(int i = 1;i <= K;i++) {
        for(int j = 1;j <= K;j++) {
            for(int k = 1;k <= K;k++) {
                ret += gcd(i,gcd(j,k));
            }
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define ll long long
using namespace std;
long long T,n;
int a[200005],d[200005];
int main(){
   
	cin>>n;
	FOR(i,1,n-1) cin>>a[i],++d[a[i]];
	FOR(i,1,n){
        cout<<d[i]<<"\n";
	}
}



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

int main(){
    string a,b;
    cin>>a>>b;
    int sum=0;
    for(int i=0;i<a.size();i++){
        if(a[i]-b[i]){
            sum++;
        }
    }
    printf("%d",sum);
    return 0;
}


Measured memory_bytes: 3856
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    string s;
    cin >> s;
    string ac = "AC";

    auto pos = s.find(ac);

    auto ans = pos != string::npos ? "Yes" : "No";
    cout << ans << endl;


    return 0;
}


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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << ":" << #x << " = " << (x) << endl;
#else
#define dbg
#endif

#pragma endregion Macros

int main()
{
    ll K;
    cin >> K;

    ll s = 0;

    for (int i = 1;i<1100100;i++){
        s *= 10;
        s += 7;

        s %= K;
        if(s==0){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;

}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define num(a) a-'0'
#define charr(a) (a - 'A' + 1)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define maxs(a,b) if(b>a)a=b
#define mins(a,b) if(b<a)a=b
#define debug(x) cerr<<"["<<#x<<":"<<x<<"] "
#define debug2(a,b) debug(a);debug(b)
#define debug3(a,b,c) debug2(a,b);debug(c)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/(__gcd(a,b))
#define print(arr) for(auto it = arr.begin();it < arr.end();it ++){cout << *it << " ";}cout << ln;
#define all(a) (a).begin(), (a).end()
#define vi vector<long long>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"
typedef long double ld;
typedef double d;
using namespace std;
int modF=1e9+7;
int INF=1e11;

void solve(){
	string s;
	cin>>s;
	int l=s.length();
	if(s[l-1]=='s'){
		cout<<s<<"es\n";
	}
	else{
		cout<<s<<"s\n";
	}
}

signed main(){
	boost_io;
	solve();
	return 0;
}

Measured memory_bytes: 3652
//Apparat : drobucs, aleonov, vit_72
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <iomanip>
#include <algorithm>
#include <string>
#include <queue>
#include <numeric>

//#pragma warning(disable : 4996)
//#pragma GCC optimize("O3")

using namespace std;

#define nptr nullptr
#define all(x) (x).begin(), (x).end()
#define drobucs ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define ff first
#define ss second
#define pb push_back
#define sz(x) (int)(x).size()

typedef  long long ll;

const int maxn = (int)2e6 + 13;
const ll INFL = 9223372036854775807;
const ll INF = 2147483647;
const ll MOD = (int)1e9 + 7, MOD2 = 998244353;//1e9 + 21, 1e9 + 33, 1e9 + 87, 1e9 + 93
const ll base = 101, base2 = 37;



int main() {
	drobucs;

	string s, t;
	cin >> s >> t;
	ll ans = 0;
	for (int i = 0; i < sz(s); ++i)ans += (s[i] != t[i]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 3816
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int N, M;
    cin >> N >> M;
    vector< pair<int, string> > vp(M);

    int p;
    string s;
    rep (i, M)
    {
        cin >> p >> s;
        vp[i] = make_pair(p, s);
    }

    typedef pair<int, string> pis;
    auto cmp = [](const pis& x, const pis& y) { return x.first < y.first; };
    stable_sort(vp.begin(), vp.end(), cmp);

    int ac = 0;
    int wa = 0;
    p = 0;
    int i = 0;
    while (i < M)
    {
        for (; i < M && vp[i].first <= p; ++i);
        if (i == M) break;
        p = vp[i].first;
        int temp = 0;
        while (i < M && vp[i].first == p && vp[i].second == "WA")
        {
            ++temp;
            ++i;
        }
        if (i < M && vp[i].first == p && vp[i].second == "AC")
        {
            wa += temp;
            ++ac;
        }
    }

    cout << ac << " " << wa << "\n";
    return 0;
}



Measured memory_bytes: 8064
#include <iostream>
using namespace std;
int main() {
	int n, x, m, min = 1001;
	cin >> n >> x;
	for (int i = 1; i <= n; i++) {
		cin >> m;
		x -= m;
		if (m < min)
			min = m;
	}
	cout << int(x / min) + n;
	return 0;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "uncopyrightable" ].parse.expand.solve == "yes" );
	assert( [ "different" ].parse.expand.solve == "no" );
	assert( [ "no" ].parse.expand.solve == "yes" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.strip.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	return ( s.sort().group.count!( ( a ) => 2 <= a[ 1 ] ) == 0 ) ? "yes" : "no";
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        static List<List<int>> tree = new List<List<int>>();

        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int[] nq = sc.intarr;
            int n = nq[0];

            wr.wri(n * n * n);
   
        }

        static void judge(int now, int point)
        {
            for (int i=0; i<tree.Count; i++)
            {
                if(tree[i][1] == now)
                {
                    tree[i][2] += point;
                    judge(tree[i][1], point);
                }
            }
            return;
        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 13396
#include<stdio.h>

int main(){
	int i, a, b, c, sum = 0;
	scanf("%d %d %d", &a, &b, &c);
	for(i = a;i < b + 1;i++){
		if(c % i == 0){
			sum++;
		}
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 1848
import Control.Monad
import Data.Array.ST
import Data.Array

main :: IO ()
main = do
  [n,m] <- map (read :: String -> Int) . words <$> getLine
  am <- map (read :: String -> Int) <$> getNLine_ m
  print $ ans n am ! n

ans :: Int -> [Int] -> Array Int Integer
ans n am = runSTArray $ do
  ary <- newArray (0,n) 1
  sequence_ [do
    writeArray ary i 0
    | i <- am]
  sequence_ [do
    a <- readArray ary (i-2)
    b <- readArray ary (i-1)
    c <- readArray ary i
    when (c /= 0) $ writeArray ary i ((a+b) `mod` (10^9+7))
    | i <- [2..n]]
  return ary

getNLine_ :: Int -> IO [String]
getNLine_ n = replicateM n getLine


Measured memory_bytes: 37244
from fractions import gcd
A,B = map(int, input().split())
g=gcd(A,B)
def prime_factorization(n):
    prime_num = []
    for i in range(2, int(n**.5)+1):
        num = 0
        while True:
            x,y = divmod(n, i)
            if y!= 0:
                break
            n = x
            num += 1
        if num>0:
            prime_num.append(i)
    if n > 1:
        prime_num.append(n)
    return prime_num
print(len(prime_factorization(g))+1)


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


#define ll long long
#define ull unsigned ll
#define vi vector <int>
#define ii pair <int, int>
#define vii vector <ii>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define INF (int)1e9
#define EPS 1e-9
#define all(i, a, b) for(int i=a; i < b; i++)
#define all(a) a.begin(), a.end()
#define in(a,b) ( (b).find(a) != (b).end())
#define pb push_back
#define fill(a,constant) memset(a, constant, sizeof(a))
#define mp make_pair
#define checkbit(n,b) ( (n >> b) & 1)
#define PI acos(-1.0)
#define DEBUG 0
int main ()
{
    fast;

    int k, n;
    cin >> k >> n;

    vi house(n);
    for (int i=0; i<n; i++)
    {
        cin >> house[i];
    }
    vi distances1(n);
    vi distances2(n);
    int max1=-100, max2=-100, index1, index2;
    //1 for clockwise and 2/-1 for anti-clockwise
    for (int p=1; p<=n-1; p++)
    {
        distances1[p] = house[p] - house[p-1];
    }
    distances1[0] = k + house[0] - house[n-1];

    for (int p=n-2; p>=0; p--)
    {
        distances2[p] = house[p+1] - house[p];
    }
    distances2[n-1] =  k + house[0] - house[n-1];

    for (int o=0; o<n; o++)
    {
       //max1 = max(max1, distances1[o]);
       if (max1 < distances1[o])
       {
           max1 = distances1[o];
           index1 = o;
       }
       //max2 = max(max2, distances2[o]);
       if (max2 < distances2[o])
       {
           max2 = distances2[o];
           index2 = o;
       }
    }


    int distance1 = fabs(house[n-1] - house[0]);
    int distance2 = fabs(house[0] + k - house[n-1]);

    int flag = (distance1 > distance2) ? -1 : 1;

    int start = (flag == 1) ? index1 : index2;

    int dis = 0;

    if (flag == 1)
    {
        for (int p=start+1; p<n; p++)
        {
            dis += distances1[p];
        }
        for (int p=0; p<start; p++)
        {
            dis += distances1[p];
        }
    }
    else
        {
            for (int p=start+1; p<n; p++)
        {
            dis += distances2[p];
        }
        for (int p=0; p<start; p++)
        {
            dis += distances2[p];
        }
        }

        if (DEBUG)
        {
            cout << "Distances1 being printed out!" << endl;
            for (int o=0; o<n; o++)
            {
                cout << distances1[o] << " ";
            }
            cout << endl;
            cout << "Distances2 being printed out!" << endl;
            for (int o=0; o<n; o++)
            {
                cout << distances2[o] << " ";
            }
            cout << endl;
            cout << max1 << " " << max2 << endl;
            cout << "Flag is " << flag << endl;
            cout << start << " is the starting point" << endl;
        }

    cout << dis << endl;


    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define RFOR(i, begin, end) for(int i=(end)-1, i##_begin_=(begin);i>=i##_begin_;i--)
#define rep(i, N) FOR(i, 0, N)
#define rrep(i, N) RFOR(i, 0, N)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long int;
using V = vector<ll>;
using P = pair<ll, ll>;
using VP = vector<P>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
constexpr int inf = 1e9;
constexpr int mod = 1e9+7;
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() {
    ll n, k, q;
    cin >> n >> k >> q;

    ll sum = 0;
    V cnt(n);
    rep(i, q) {
        ll a;
        cin >> a;
        a--;
        cnt[a]++;
        sum++;
    }

    rep(i, n) {
        if (k - sum + cnt[i] <= 0) {
            cout << "No" << endl;
        }
        else {
            cout << "Yes" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1408
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    boolean[] color = new boolean[8];
    int over = 0;
    for(int i = 0; i < N; i++){
      int n = sc.nextInt();
      if(n <= 399){
        color[0] = true;
      }else if(n <= 799){
        color[1] = true;
      }else if(n <= 1199){
        color[2] = true;
      }else if(n <= 1599){
        color[3] = true;
      }else if(n <= 1999){
        color[4] = true;
      }else if(n <= 2399){
        color[5] = true;
      }else if(n <= 2799){
        color[6] = true;
      }else if(n <= 3199){
        color[7] = true;
      }else{
        over++;
      }
    }
    
    int min = 0;
    int max = 0;
    for(int i = 0; i < 8; i++){
      if(color[i]){
        min++;
      }
    }
    max = min + over;
    if(min == 0 && over > 0){
      min = 1;
    }
    
    System.out.println(min + " " + max);
  }
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;

namespace arc080_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = int.Parse(Console.ReadLine());
            List<int> a = Console.ReadLine().Split().Select(int.Parse).ToArray().ToList();
            int now = 1;
            for (int i = 0; i < x[0]; i++)
            {
                int[] ret = new int[x[1]];
                for (int j = 0; j < x[1]; j++)
                {
                    ret[j] = now;
                    a[0]--;
                    if (a[0] == 0)
                    {
                        a.RemoveAt(0); now++;
                    }
                }
                if (i % 2 == 1) Array.Reverse(ret);
                Console.Write(ret[0]);
                for (int j = 1; j < x[1]; j++)
                {
                    Console.Write(" " + ret[j]);
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define repx(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)

int main(){
    
    // 1. 入力情報.
    char c[101010];
    scanf("%s", c);
    int l = strlen(c);
    
    // 2. 計算を行う.
    char mc[101010];
    repr(i, l - 1, 0){
        mc[i] = c[l - 1 - i];
        if(mc[i] == 'b') mc[i] = 'd';
        else if(mc[i] == 'd') mc[i] = 'b';
        else if(mc[i] == 'p') mc[i] = 'q';
        else if(mc[i] == 'q') mc[i] = 'p';
    }
    
    // 3. 判定.
    bool ok = true;
    rep(i, l) if(c[i] != mc[i]) ok = false;
    
    // 4. 出力.
    printf("%s\n", ok ? "Yes" : "No");
    return 0;
    
}

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

using namespace std;

class range {
private:
  struct Iterator {
    int val;
    int operator*() {return val;}
    bool operator!=(Iterator &itr) {return val < itr.val;}
    void operator++() {++val;}
  };
  Iterator i, n;
public:
  range(int n) : i({0}), n({n}) {}
  range(int i, int n) : i({i}), n({n}) {}
  Iterator &begin() {return i;}
  Iterator &end() {return n;}
};

template<class T> T at(vector<T> v, int i) {return v[(i % (int)v.size() + v.size()) % v.size()];}

typedef int Weight;
struct Edge {
  int from, to;
  Weight weight;
  Edge(int from, int to, Weight weight) :
    from(from), to(to), weight(weight) {}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void debug(const Graph &g) {
  for (const Edges &es : g) for (const Edge &e : es) {
    cerr << e.from << " " << e.to << " " << e.weight << endl;
  }
}

Matrix adjacency(const Graph &graph) {
  int n = graph.size();
  Matrix distance(n, Array(n, 1e9));
  for (const Edges &edges : graph) for (const Edge &edge : edges) {
    distance[edge.from][edge.to] = edge.weight;
  }
  return distance;
}

bool visit(const Graph &g, int v, vector<int> &order, vector<int> &color) {
  color[v] = 1;
  for (const Edge &e : g[v]) {
    if (color[e.to] == 2) continue;
    if (color[e.to] == 1) return false;
    if (!visit(g, e.to, order, color)) return false;
  }
  order.emplace_back(v);
  color[v] = 2;
  return true;
}

bool topologicalSort(const Graph &g, vector<int> &order) {
  vector<int> color(g.size(), 0);
  order.clear();
  for (int u : range(g.size())) if (!color[u] && !visit(g, u, order, color)) return false;
  reverse(order.begin(), order.end());
  return true;
}

int main() {
  int n, m;
  cin >> n >> m;
  Graph g(n);
  for (int k : range(m)) {
    int i, j;
    cin >> i >> j;
    g[i - 1].emplace_back(i - 1, j - 1, 1);
  }
  vector<int> order(n);
  assert(topologicalSort(g, order));
  for (int i : order) cout << i + 1 << endl;
  //debug(g);
  for (int i : range(n - 1)) {
    bool found = false;
    for (const Edge &e : g[order[i]]) if (e.to == order[i + 1]) found = true;
    if (!found) {
      cout << 1 << endl;
      return 0;
    } 
  }
  cout << 0 << endl;
}

Measured memory_bytes: 3272
#include<stdio.h>
#include<math.h>

int main(void)
{
	int x;
	int ret;
	
	x = 0;
	ret = 0;
	
	// 数値読込
	scanf("%d", &x);
	
	// 数値を3乗にする
	ret = pow(x, 3);
	
	// 数値出力
	printf("%d\n", ret);
	
	return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

int main() {
    cin>>H>>W>>K;
    string s(W, 'R');
    vector<string> ans(H, s);
    vector<char> color = {'R', 'G', 'Y', 'B'};
    ll plus = K * 5000;
    rep(i,H){
        rep(j,W){
            bool a = (i + j + plus)%(K * 2) >= K, b = (i - j + plus)%(K * 2) >= K;
            //cout<<a<<' '<<b<<endl;
            ans[i][j] = color[a * 2 + b];
        }
    }
    rep(i,H) cout<<ans[i]<<endl;
}

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

using namespace std;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    while( true ){

        int n;
        cin >> n;

        if(!n)
            break;

        int l = 0, r = 0, u = 0;
        int ans = 0;

        for(int i = 0; i < n; i++){

            string t;
            cin >> t;

            if( t == "lu" )
                l = 1;
            else if(t == "ru")
                r = 1;
            else if(t == "ld")
                l = 0;
            else
                r = 0;

            if(!(r^l))
                if( u^l ){
                    ans++;
                    u ^= 1;
                }

        }

        cout << ans << endl;

    }

    return 0;

}


Measured memory_bytes: 3232
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<cstdio>

using namespace std;

double EPS = 1e-10;
const double PI = acos(-1);

double add(double a, double b){
if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
return a+b;
}

struct point{
double x, y;
point(){}
point(double x,double y) : x(x) , y(y){}

point operator + (point p){
return point(add(x,p.x), add(y,p.y));
}

point operator - (point p){
return point(add(x,-p.x), add(y,-p.y));
}

point operator * (double d){
return point(x*d,y*d);
}

point operator / (double d){
return point(x/d,y/d);
}

bool operator == ( const point &p ) const {
return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
}
};

double areaPol(vector<point> t){
t.push_back(t[0]);
int tsz=t.size();
double area=0;
for(int i=0;i<tsz-1;i++){
area+=(t[i].x-t[i+1].x)*(t[i].y+t[i+1].y);
}
return abs(area)/2.0;
}

int main(void){
point p;
vector<point>t;
double x,y;
char k;

while(cin>>x>>k>>y){
p.x = x;
p.y = y;
t.push_back(p);
}

printf("%.6f\n",areaPol(t));

return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
int main()
{
  LL n,m;
  double sum=0.0;
  cin>>n>>m;
  vector <LL> a(n,0);
  for(LL j=0;j<n;j++)
  {
    cin>>a[j];
    sum+=a[j];
  }
 // cout<<sum<<endl;
  sum=sum/(4*m);
  //cout<<sum<<endl;
  LL c=0,f=0;
  for(LL j=0;j<n;j++)
  {
    if(a[j]>=sum)
      c++;
    if(c==m)
    {
      f=1;
      break;
    }
  }
  if(f==1)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
//lover~ crazy~
#include<bits/stdc++.h>
using namespace std;
int n;
int main() {
	cin>>n;
    for(int i=0;i<=30;i++)
        for(int j=0;j<=15;j++)
            if(i*4+j*7==n) {cout<<"Yes";return 0;}
    cout<<"No";
	return 0;
}
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//

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

int main() {
  int a, b, c, X;
  cin >> X;
  
  b = X;
  c = 100000000;
  for ( ;b != 0; ){
    a += b / c;
    b %= c;
    c /= 10;
  }
  
  if (X % a) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = sorted([int(i) for i in input().split()], reverse=True)
INF = 10**10
matches = [2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [-INF for _ in range(N+100)]
dp[0] = 0

for i in range(N+1):
    for a in A:
        dp[i+matches[a-1]] = max(dp[i+matches[a-1]], dp[i]+1)

ans = ''
while N != 0:
    for a in A:
        if dp[N-matches[a-1]] == dp[N]-1:
            ans = ans+str(a)
            N -= matches[a-1]
            break

print(ans)


Measured memory_bytes: 3444