akhauriyash/Code-Regression huggingface dataset:
x = input() # mokuhyo
x = int(x)
chokin = 100
rishi = 0.01 # 1% 切り捨て
counta = 0

while True:
    if chokin >= x:
        break
    else:
        chokin += int(chokin * rishi)
        counta += 1

print(counta)

Measured memory_bytes: 9188
import java.io.*;

public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String s=reader.readLine();
			if(s==null)System.exit(0);
			String[] t=s.split(" ");
			int a,b;
			a=Integer.parseInt(t[0]);
			b=Integer.parseInt(t[1]);
			int sum=a+b;
			int co=0;
			while(sum>0){
				co++;
				sum/=10;
			}
			System.out.println(co);
		}
	
	}
}

Measured memory_bytes: 17012
a = input()
count = 0
mx = 0
for i in range(len(a)):
    if a[i] == "A" or a[i] == "C" or a[i] == "G" or a[i] == "T":
        count += 1
    else:
        count = 0
    if mx < count:
        mx = count
print(mx)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int mx=2e3+10;
vector<int>g[mx];
int h[mx];
int cnt[mx][2];
int k;
int color[mx];
void dfs(int u,int pu){
   if(h[u]<=k/2){
      cnt[color[u]][0]++;
   }
   if(h[u]<=(k+1)/2){
      cnt[color[u]][1]++;
   }
   for(int v:g[u])if(v!=pu){
      h[v]=1+h[u];
      color[v]=color[u];
      dfs(v,u);
   }
}
int main(){
   int n,u,v;
   scanf("%d %d",&n,&k);
   for(int i=0;i<n-1;i++){
      scanf("%d %d",&u,&v);
      g[--u].push_back(--v);
      g[v].push_back(u);
   }
   if(k==1){
      printf("%d\n",n-2);
      return 0;
   }
   int ans=n-2;
   for(int u=0;u<n;u++){
      memset(cnt,0,sizeof cnt);
      h[u]=0;
      for(int i=0;i<int(g[u].size());i++){
         int v=g[u][i];
         h[v]=1;
         color[v]=i;
         dfs(v,u);
      }
      int t0=0;
      for(int i=0;i<int(g[u].size());i++)t0+=cnt[i][0];
      int sz=1;
      for(int i=0;i<int(g[u].size());i++){
         int bet=1+t0-cnt[i][0]+cnt[i][1];
         sz=max(sz,bet);         
      }
      //      cout<<"u="<<u+1<<" sz="<<sz<<endl;
      ans=min(ans,n-sz);
   }
   printf("%d\n",ans);
   return 0;
}


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

int check(int i, int num[])
{
    string pay = to_string(i);
    for(int p = 0; p < pay.length(); p++){
        if(num[pay[p]-'0']==1) {
            return 0;
        }
    }
    return 1;
}

int main(void)
{
    int N, K;
    int num[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    int n;
    cin >> N >> K;
    for(int i = 0; i < K; i++) {
        int n;
        cin >> n;
        num[n] = 1;
    }
    while(!check(N, num)) N++;
    cout << N << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
  
using namespace std;

/********** TEMPLATE STARTS HERE ***********/
  
#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define test int t; cin >> t; while(t--)
#define skip continue
#define stop break
#define sz(v) (int)v.size()
#define endl '\n'
#define PI 3.1415926535897932384626433832795
#define EPS 1e-9
#define gcd __gcd 
#define FO(i, a) for(auto & i : a)
#define debug(a) cout << #a << ": " << a << endl
#define debug1(a, l, r) FR(i, l, r) cout << a[i] << " "; cout << endl
#define SET(a, b) memset(a, b, sizeof(a));
#define refresh fflush(stdout);
  
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pii> vii;
typedef vector <pll> vll;
  
const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;
  
template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
 
/*********** TEMPLATE ENDS HERE *************/

unordered_map <string , bool> H;

main()
{
	IOS
	
	int n;
	cin >> n;
	
	string prev;
	cin >> prev;
	
	H[prev] = 1;
	
	for(int i = 2; i <= n; i++)
	{
		string s;
		cin >> s;
		if(H[s] == 1 || s[0] != prev[prev.size() - 1])
			return cout << "No", 0;
		prev = s;
		H[s] = 1;
	}
	
	cout << "Yes";
}

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

double maxpercent(int water, int C, int D, int E, int F, int &G){
  int maxsugar = water / 100 * E;
  int sugar = 0;
  for(int i = 0; i <= maxsugar/C; i++){
    for(int j = 0; j <= maxsugar/D; j++){
      int x = C * i + D * j;
      if(x > sugar && (water + x) <= F && x <= maxsugar) sugar = x;
    }
  }
  G = sugar;
  return 100*(double)sugar / ((double)water + (double)sugar);
}

int main(){
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  set<int> waterpattern;
  for(int i = 0; i <= F/(100*A); i++){
    for(int j = 0; j <= F/(100*B); j++){
      waterpattern.insert(100*A*i + 100*B*j);
    }
  }
  
  int G;
  double percent = 0;
  int wresult = 0, sresult = 0;
  for(int i = 1; i <= 30; i++){
    if(waterpattern.count(i * 100) && percent < maxpercent(i*100, C, D, E, F, G)){
      percent = maxpercent(i*100, C, D, E, F, G);
      wresult = i * 100;
      sresult = G;
    }
  }
  if(wresult == 0) wresult = A * 100;
  cout << wresult + sresult << ' ' << sresult << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 10000
#define NIL -1

struct Node{
  int p, l, r;
};

struct Node T[MAX];

int n;

void preParse(int u){
  if(u == NIL) return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u == NIL) return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main(){
  int i, v, l, r, root;

  scanf("%d", &n);
  for(i=0; i<n; i++)
  {
    T[i].p=NIL;
  }

  for(i=0; i<n; i++)
  {
    scanf("%d %d %d", &v, &l, &r);
    T[v].l=l;
    T[v].r=r;

    if(l != NIL) T[l].p=v;
    if(r != NIL) T[r].p=v;
  }

  for(i=0; i<n; i++){
    if(T[i].p == NIL)
    root=i;
  }

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2112
c = [list(map(int, input().split())) for _ in range(3)]

ans = "Yes"
for i in range(1,3):
  if c[i][0] - c[0][0] != c[i][1] - c[0][1] or c[i][1] - c[0][1] != c[i][2] - c[0][2]:
    ans = "No"
print(ans)

Measured memory_bytes: 3060
n = int(input())
s = [input() for _ in range(n)]
t = ""
for i in set(s[0]):
    #print(i)
    if all(i in s[j] for j in range(n)):
        t += i * min(s[k].count(i) for k in range(len(s)))
    #print(t)
    
print(''.join(sorted(t)))

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

using namespace std;

int N;
int x[100][100];
int y[100][100];
int f[100][100];
int cnt;

bool input() {
  int i, j;

  scanf("%d", &N);
  if (!N) return false;
  for (i = 0; i < N; i++) {
    for (j = 0; j < N; j++) {
      scanf("%d %d", &x[i][j], &y[i][j]);
    }
  }

  return true;
}

int main(){
  int i, j, a, b, tmp, k, l;

  while(input()){
    cnt = 0;
    fill(f[0], f[0] + 100 * 100, 0);

    for (i = 0; i < N; i++) {
      for (j = 0; j < N; j++) {
        if (f[i][j] != 0) continue;
        f[i][j]++;
        a = x[i][j];
        b = y[i][j];
        while (true) {
          if (f[b][a] == -1 || f[b][a] == 2) break;
          f[b][a]++;
          if (f[b][a] == 2) {
            cnt++;
            break;
          }
          tmp = x[b][a];
          b   = y[b][a];
          a   = tmp;
        }

        for (k = 0; k < N; k++) {
          for (l = 0; l < N; l++) {
            if (f[k][l] == 1) f[k][l] = -1;
          }
        }

      }
    }

    printf("%d\n", cnt);

  }
  return 0;
}

Measured memory_bytes: 880
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=9999999999999999;

int main() {
   int N,L;
   cin>>N>>L;
   int sum=0;
   int ans=9999;
   for(int i=L;i<=L+N-1;i++){
    sum+=i;
    if(abs(i)<abs(ans)){ans=i;}
   }
   cout<<sum-ans<<endl;
return 0;}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
vector<int>g[200001];
int main()
{
	int n,m;
	int go,to;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)
	{
		scanf("%d%d",&go,&to);
		g[go].push_back(to);
	}
	for(int i=0;i<g[1].size();i++)
	{
		int v=g[1][i];
		for(int j=0;j<g[v].size();j++)
		{
			if(g[v][j]==n)
			{
				printf("POSSIBLE");return 0;
			}
			else continue;
		}
	}
	printf("IMPOSSIBLE");
	return 0; 
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[500][500],b[250000][4],w,h,i,j,k=0;
	cin>>h>>w;
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
			cin>>a[i][j];
	}
	for(i=0;i<h;i++)
	{
		for(j=0;j<w-1;j++)
		{
			
			if(a[i][j]%2==1)
			{
				b[k][0]=i;
				b[k][1]=j;
				b[k][2]=i;
				b[k][3]=j+1;
				k++;
				a[i][j]--;
				a[i][j+1]++;
			}
		}
	}
	for(i=0;i<h-1;i++)
	{
		if(a[i][w-1]%2==1)
		{
			b[k][0]=i;
			b[k][1]=w-1;
			b[k][2]=i+1;
			b[k][3]=w-1;
			k++;
			a[i][j]--;
			a[i+1][j]++;
		}
	}
	cout<<k<<endl;
	for(i=0;i<k;i++)
	{
		cout<<b[i][0]+1<<" ";
		cout<<b[i][1]+1<<" ";
		cout<<b[i][2]+1<<" ";
		cout<<b[i][3]+1<<endl;
	}
    return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;



int main()
{
  int n,i;
  cin>>n;
  vector< pair<int,string> > v;
  map<string,int> mp;
  while(n--)
  {
      string s;
      cin>>s;
       mp[s]++;
  }
  //sort(mp.begin(),mp.end());
  map<string,int>:: iterator it;
  for(it=mp.begin();it!=mp.end();it++)
  {
      //cout<<it->first<<' '<<it->second<<endl;
      v.push_back(make_pair(it->second,it->first));
  }
  sort(v.begin(),v.end());
  int len=v.size();
  int d=v[len-1].first;
  int left=0;
   for(i=len-1;i>=0;i--)
   {
       if(v[i].first!=d) {

           left=i+1;
           break;
          }

   }
   for(i=left;i<len;i++)
   {
       cout<<v[i].second<<endl;
   }
}


Measured memory_bytes: 28400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
ll a, b, c, n, m, x, y, z, w, h, ans, cnt, mx, mn;
string s, t;
vll dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
//vll dx = {-1, 0, 1, -1, 1, -1, 0, 1}, dy = {-1, -1, -1, 0, 0, 1, 1, 1};
string alphabet = "abcdefghijklmnopqrstuvwxyz";

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n){
        ll v[n] = {};
        rep(i, n){
            cin >> a;
            v[a]++;
        }
        if(v[0] == (n % 2 ? 1 : 0)){
            rep(i, 1, (n + 1) / 2 + 1){
                if(i % 2 == (n % 2 ? 0 : 1) && v[i] != 2){
                    print(0);
                    return 0;
                }
            }
            ans = 1;
            rep(i, n / 2){
                ans *= 2;
                ans %= MOD;
            }
            print(ans);
        }else{
            print(0);
        }
    }
}


Measured memory_bytes: 1024
import Control.Monad
import Data.List
import Data.Char
import Data.Array.Unboxed

main=do
    [h,w]<-map read.words<$>getLine::IO[Int]
    mp <- listArray ((0,0),(h+1,w+1)).
            flip (++) (replicate (w+3) 'x'). (++) (replicate (w+1) 'x').
            concat.map ((++) "xx")<$> replicateM h getLine::IO (Array (Int,Int) Char)
    mapM_ putStrLn $ sep w $ filter (/='x') $ map (snd.mine mp) $ assocs mp

sep::Int -> [a] -> [[a]]
sep w [] = []
sep w s = liftM2 (:) (take w) (sep w.drop w) s

mine :: (Array (Int,Int) Char) -> ((Int,Int), Char) -> ((Int,Int), Char)
mine _ e@(hw,'#') = e
mine _ e@(hw,'x') = e
mine mp (hw@(h,w), _) =
    (,) hw $ intToDigit $ length $
    filter (=='#') $ map ((!) mp) [(h-1,w-1),(h,w-1),(h+1,w-1),(h-1,w),(h+1,w),(h-1,w+1),(h,w+1),(h+1,w+1)]

Measured memory_bytes: 1020
var
  a,b,c,che5,che7:integer;
begin
  readln(a,b,c);
  if a=5 then che5:=che5+1;
  if a=7 then che7:=che7+1;
  if b=5 then che5:=che5+1;
  if b=7 then che7:=che7+1;
  if c=5 then che5:=che5+1;
  if c=7 then che7:=che7+1;
  if (che5=2) and (che7=1) then writeLN('YES')
                          ELSE WRITELN('NO');
END.

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef unsigned long long ll;



int main(){
  string S;
  ll K,sum=0;

  cin >> S;
  cin >> K;

  for(int i = 0; i < S.length(); i++){
    if(S[i] != '1' || (i+1== K)){
      cout << S[i] << endl;
      return 0;
    }
  }

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, M;
    cin >> N;
    vl D(N);
    rep(i, N) cin >> D[i];
    cin >> M;
    vl T(M);
    rep(i, M) cin >> T[i];

    sort(all(D)), sort(all(T));

    ll di = 0;
    rep(i,M){
        while (di < N and D[di] < T[i]) di++;
        if(di==N or D[di]>T[i]){
            cout << "NO" << endl;
            return 0;
        }
        di++;
    }

    cout << "YES" << endl;
}

Measured memory_bytes: 3456
import java.util.Scanner;

class Main{
	public static void main(String[] ag) {
		Scanner sc=new Scanner(System.in);
		long A=sc.nextLong();
		long B=sc.nextLong();
		long C=sc.nextLong();
      
      if(Math.abs(B-A)>Math.abs(C-A)){
        System.out.println("B");
      }
      else{
        System.out.println("A");
      }
	}
}

Measured memory_bytes: 21588
#include <iostream>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
//#define hell        1000000007
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e7+1;
const long long mod = (long long) 998244353 ;
const long long hell = (long long) 1000000007;

using namespace std;
#include <stdio.h>

ll power(ll x,ll y)
{
  ll res=1;
  while(y>0){
    if(y%2) res=(x%hell*res%hell)%hell;
    x=(x%hell*x%hell)%hell;
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/


void solve(){
  int test;
  //cin>>test;
  test=1;
  
  while(test--){
        int n;
        cin>>n;
        int a[n];
        forn(i,0,n)
        cin>>a[i];
        
        bool flag=true;
        forn(i,0,n){
            if(a[i]%2==0){
                if(a[i]%3!=0 and a[i]%5!=0){
                    flag=false;
                    break;
                }
            }
        }
        if(flag){
            cout<<"APPROVED";
        }
        else
        cout<<"DENIED";
  }         
}    

    




///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll a,ll b)
{
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}





Measured memory_bytes: 256
n = int(input())
x = list(map(int,input().split()))
x.sort()
ans = 10 ** 8
for p in range(x[0],x[-1]+1):
    m = 0
    z = 0
    for i in range(n):
        z = x[i] - p
        m += (z ** 2)
    ans = min(ans,m)
print(ans)

Measured memory_bytes: 8952
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N;
    cin >> N;
    vector<ll> a(N);
    for(int i=0; i<N; i++) cin >> a[i];

    vector<vector<ll>> dp(N, vector<ll>(N));
    vector<vector<ll>> values(N, vector<ll>(N));

    for(int i=0; i<N; i++) values[i][i] = a[i];
    for(int i=0; i<N; i++)
        for(int j=i+1; j<N; j++)
            values[i][j] = values[i][j-1] + a[j];

    for(int i=0; i<N; i++) dp[i][i] = a[i];
    for(int l=1; l<N; l++)
        for(int i=0; i<N-l; i++) {
            ll min_cost = INF;
            for(int k=i; k<i+l; k++) {
                ll tmp = values[i][k] + values[k+1][i+l];
                if(i!=k) tmp += dp[i][k];
                if(k+1!=i+l) tmp += dp[k+1][i+l];
                
                if(min_cost > tmp) {
                    min_cost = tmp;
                }
            }
            dp[i][i+l] = min_cost;
        }

    cerr << "values" << endl;
    for(auto v: values) {
        for(auto x: v) cerr << x << " ";
        cerr << endl;
    }

    cerr << "debug" << endl;
    for(auto v: dp) {
        for(auto x: v) cerr << x << " ";
        cerr << endl;
    }

    cout << dp[0][N-1] << endl;
    return 0;
}

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


template <typename T>
void cout_vector(vector<T> A){
    for (T a : A) cout << a << " ";
cout << endl;
}
int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    int ans = 0;
    for (int i = 0; i < 1000; i++){
        vector<int> password_list(3);
        password_list[0] = i / 100;
        password_list[1] = i / 10 % 10;
        password_list[2] = i % 10;
        int search_idx = 0;
        for (int j = 0; j < N; j++){
            if ((password_list[search_idx] + '0') == S[j]) search_idx++;
            if (search_idx == 3) break;
        }
    if (search_idx == 3) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
// Problem : A - Number of Multiples
// Contest : AtCoder - AIsing Programming Contest 2020
// URL : https://atcoder.jp/contests/aising2020/tasks/aising2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,b) for(int i=a;i>=b;i--)
//vector
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pp pop_back
//pair
#define pi pair<int ,int >
#define mk make_pair
#define ff first
#define ss second
//set
#define si set<int>
#define sit set<int>::iterator 
using namespace std;
int main()
{
fast;
int a,b,c;
cin>>a>>b>>c;
int ans=0;
fr(i,a,b+1)
{
	if(i%c==0) ans++;
}
cout<<ans;
return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	int P,Q,R;
	cin>>P>>Q>>R;
	cout<<min(P+Q,min(Q+R,R+P))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 20 
using namespace std;
int nt[N],n,ans,l,r;
vector<pair<int,int> >test[N];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>nt[i];
        for(int j=1;j<=nt[i];j++){
            cin>>l>>r;
            test[i].push_back({l,r});
        }
    }
    for(int i=0;i<(1<<n);i++){
        int cnt=0,flag=0;
        for(int j=0;j<n;j++){
            if((i>>j)&1==1){
                cnt++;
                for(int k=0;k<nt[j+1];k++){
                    int l=test[j+1][k].first,r=test[j+1][k].second;
                    if((i>>(l-1)&1)!=r){
                        flag=true;
                        break;
                    }
                }
            }
            if(flag==true)break;
        }
        if(flag==false)ans=max(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define mod 1000000007
#define reg register
#define int long long
#define maxn 200001
using namespace std;
inline int  read() {
    reg int s = 0, t = 0; reg char ch = getchar();
    while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
    while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}
int c[3][3], f[3][3], dp[maxn][3], n, m, pos[maxn], d[3][3];
int inc(int x, int y){
    return x + y >= mod ? x + y - mod : x + y;
}
void mul(int op){
    for(int i = 0; i <= 2; i++)
        for(int j = 0; j <= 2; j++){
            int res = 0;
            for(int k = 0; k <= 2; k++){
                if(op == 1) res = inc(res, 1ll * c[i][k] * f[k][j] % mod);
                else res = inc(res, 1ll * f[i][k] * f[k][j] % mod);
                d[i][j] = res;
            }
        }
    for(int i = 0; i <= 2; i++)
        for(int j = 0; j <= 2; j++)
            for(int k = 0; k <= 2; k++) 
            if(op == 1) c[i][j] = d[i][j];
            else f[i][j] = d[i][j];
}
void ksm(int poww){
    memset(c, 0, sizeof c);
    c[0][0] = 1; c[1][1] = 1; c[2][2] = 1;
    for(int i = poww; i; i >>= 1){
        if(i & 1) mul(1);
        mul(2);
    }
    memcpy(f, c, sizeof f);
}
void solve(int i, int l, int r){
    dp[i][0] = dp[i - 1][0];
    dp[i][1] = inc(dp[i - 1][1], dp[i - 1][0] * 2ll % mod);
    dp[i][2] = inc(dp[i - 1][2], dp[i - 1][1]);
    dp[i][2] = inc(dp[i][2], dp[i - 1][0]);
    f[0][0] = 1; f[0][1] = 2; f[0][2] = 1;
    f[1][0] = 0; f[1][1] = 1; f[1][2] = 1;
    f[2][0] = 1; f[2][1] = 2; f[2][2] = 2;
    ksm(r - l);
    f[0][0] = 1ll * f[0][0] * dp[i][0] % mod;
    f[0][1] = 1ll * f[0][1] * dp[i][0] % mod;
    f[0][2] = 1ll * f[0][2] * dp[i][0] % mod;
    f[1][0] = 1ll * f[1][0] * dp[i][1] % mod;
    f[1][1] = 1ll * f[1][1] * dp[i][1] % mod;
    f[1][2] = 1ll * f[1][2] * dp[i][1] % mod;
    f[2][0] = 1ll * f[2][0] * dp[i][2] % mod;
    f[2][1] = 1ll * f[2][1] * dp[i][2] % mod;
    f[2][2] = 1ll * f[2][2] * dp[i][2] % mod;
    int x = f[0][0] + f[1][0] + f[2][0]; x = x % mod;
    dp[i][0] = x;

    x = f[0][1] + f[1][1] + f[2][1]; x = x % mod;
    dp[i][1] = x;
    
    x = f[0][2] + f[1][2] + f[2][2]; x = x % mod;
    dp[i][2] = x;
}
signed main(){
    n = read(); m = read(); dp[0][0] = 1;
    for(int i = 1; i <= m; i++) pos[i] = read() + 1;
    pos[++m] = 1; pos[++m] = n + 1;
    sort(pos + 1, pos + m + 1);
    m = unique(pos + 1, pos + m + 1) - pos - 1;
    for(int i = 1; i < m; i++) solve(i, pos[i], pos[i + 1] - 1);
    cout << dp[m - 1][2] << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define pi 3.14159265358979323846264338327950288
using namespace std;
inline long long read(){
	long long ret=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9') {if (ch=='-') f=-f;ch=getchar();}
	while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return ret*f;
}
long long X1,Y1,X2,Y2;
long long a[200005],c[200005],n=0,m,len,iter;
struct node{
	long long x,y;
};
node tmp[200005];
bool cmp(node a,node b){
	if (X1>X2){
		return a.x>b.x;
	}
	return a.x<b.x;
}
int main(){
    //freopen("loveround.in","r",stdin);
    //freopen("loveround.out","w",stdout);
	X1=read();Y1=read();X2=read();Y2=read();
	if (Y1>Y2){
		swap(X1,X2);
		swap(Y1,Y2);
	}
	m=read();
	for (long long i=1;i<=m;i++){
		tmp[i].x=read(),tmp[i].y=read();
	}
	sort(tmp+1,tmp+1+m,cmp); 
	for (long long i=1;i<=m;i++){
		if (min(X1,X2)<=tmp[i].x&&tmp[i].x<=max(X1,X2)){
			if (min(Y1,Y2)<=tmp[i].y&&tmp[i].y<=max(Y1,Y2)){
				a[++n]=tmp[i].y;
			}
		}
	}
	c[1]=a[1];
	len=1;
	for (long long i=2;i<=n;i++){
		if (a[i]>c[len]){
			len++,c[len]=a[i];
		}else{
			iter=lower_bound(c+1,c+len,a[i])-c,c[iter]=a[i];
		}
	}
	if (n==0){
		len=0;
	}
	double pre=1.00*(abs(X2-X1)+abs(Y2-Y1));
	double stp=20-pi*5; 
	if(len==min(abs(X2-X1)+1,abs(Y2-Y1)+1)){
		printf("%.13lf\n",pre*100*1.00-len*1.00*stp+pi*5);
	}else{
		printf("%.13lf\n",pre*100*1.00-len*1.00*stp);
	}
	return 0;
}

Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		String op = scan.next();
		int b = scan.nextInt();
		if (op.equals("+")) {
			System.out.println(a + b);
		} else {
			System.out.println(a - b);
		}
	}

}


Measured memory_bytes: 22868
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  string str; cin >> str;
  vector<char> ss;
  string ans = "yes";
  for (int i = 0; i != str.size(); ++i) {
    auto result = find(ss.begin(), ss.end(), str[i]);
    if (result == ss.end()) {
      ss.push_back(str[i]);
    } else {
      ans = "no";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
  if((double)a.first/(double)a.second!=(double)b.first/(double)b.second){
    return (double)a.first/(double)a.second < (double)b.first/(double)b.second;
  }else{
    if(a.first!=b.first){
      return a.first>b.first;
    }
    else return a.second > b.second;
  }
}
signed main(){
  int x=0,y=0,z=0,w=0,n=0,m=0;
  string s,t,u;
  std::cin >> s;
  rep(i,s.size())std::cout << "x";
  std::cout << '\n';
}


Measured memory_bytes: 256
import sys
from collections import Counter
from operator import itemgetter
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    S=[input()for _ in range(n)]
    s_cnt=Counter(S)
    s_list=sorted(list(s_cnt.items()),key=itemgetter(1),reverse=True)
    s_list=[s[0] for s in s_list if s[1]==s_list[0][1]]
    s_list.sort()
    for s in s_list:
        print(s)
if __name__=='__main__':
    main()

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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(s) s.begin(),s.end()
#define vll vector<ll>
#define vi vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define vd vector<double>
#define vull vector<ull>
#define vc vector<char>
#define vs vector<string>
#define fi first
#define se second
#define sz(x) x.size()
#define cinarr(n,a) for(int i = 0; i < n; i++) cin >> a[i];
#define coutarr(n,a) for(int i = 0; i < n; i++) cout << a[i] << (i+1==n?'\n':' ');
#define fori(i,a,b,x) for(int i = a; i <= b; i+=x)
#define ford(i,a,b,x) for(int i = a; i >= b; i-=x)
#define tc int t; cin >> t; for(int cs = 1; cs <= t; cs++)
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define ld long double
#define reset(x,y) memset(x,y,sizeof x);
#define sqr(x) 1LL*(x)*(x)
#define cube(x) 1LL*(x)*(x)*(x)
#define ub(v, a) upper_bound(all(v), a)
#define lb(v, a) lower_bound(all(v), a)
#define EPS 1e-10
#define INF 2000000000
#define mod 1000000007
#define minof(a) min_element(all(a))
#define maxof(a) max_element(all(a))
#define debug(val) cerr << "The value of " << #val << " is = " << val << endl;
#define testing cerr << "--------------------------\n";

//input space ---> scanf("%[^\n]%*c",s);

vll dp(100005,0),pre(100005,1),a(105);
ll n,k;

int main() {
	IOS
	cin >> n >> k;
	fori(i,1,n,1) {
		cin >> a[i];
	}
	dp[0] = 1;
	fori(i,1,n,1) {
		ford(j,k,0,1) {
			if(j > a[i]) {
				dp[j] = pre[j]-pre[j-a[i]-1];
			} else {
				dp[j] = pre[j];
			}
			if(dp[j] < 0) {
				dp[j] += mod;
			}
		}
		pre[0] = dp[0];
		fori(i,1,k,1) {
			pre[i] = (pre[i-1]+dp[i])%mod;
		}
	}
	cout << dp[k] << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
   string s;
   cin>>s;
   int q;
   cin>>q;
   int current = 0;
   deque<char>dq;
   for(int i=0;i<s.size();i++)
    dq.push_back(s[i]);
   while(q--)
   {
       int t,f;
       char c;
       cin>>t;
       if(t==1)
            current++;
      else
      {
          cin>>f>>c;
          if(f==1)
          {
              if(current&1)
              {
                  dq.push_back(c);
              }
              else
                dq.push_front(c);
          }
          else
          {
              if(current&1)
              {
                  dq.push_front(c);
              }
              else
                dq.push_back(c);
          }
      }
   }
   if(current&1)
   {while(!dq.empty())
   {
       cout<<dq.back();
       dq.pop_back();
   }
   }
   else
   {
       while(!dq.empty())
     {
       cout<<dq.front();
       dq.pop_front();
    }
   }

}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    cout << (M1 != M2 ? 1 : 0) << "\n";
}

Measured memory_bytes: 764
n = int(input())
pl = list(map(int, input().split()))

count = 0
for i in range(1, n - 1):
    all = []
    all.append(pl[i - 1])
    all.append(pl[i])
    all.append(pl[i+1])
    all.sort()
    if all[1] == pl[i]:
        count += 1

print(count)


Measured memory_bytes: 3060
import math
N,M = map(int,input().split())

if(abs(N-M)<2):
    if(N==M):
        print((math.factorial(N)*math.factorial(M)*2)%(10**9+7))
    else:
        print(math.factorial(M)*math.factorial(N)%(10**9+7))
else:
    print(0)

Measured memory_bytes: 11028
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
                int N = sc.nextInt();
            String S = sc.next();

            StringBuilder copy = new StringBuilder(S);

            int flag=0;

            while(flag==0){
                flag=1;
                for(int i=0; i+1<copy.length(); i++){
                if(copy.charAt(i)=='('&&copy.charAt(i+1)==')'){
                    copy.delete(i,i+2);
                    flag=0;
                    break;
                }
            }
        }

        int res=0;
        int res1 = 0;

        for(int i=0; i<copy.length(); i++){
            if(copy.charAt(i)=='(') res1++;
            if(copy.charAt(i)==')') res++;
        }

        for(int i=0; i<res; i++) System.out.print('(');
        System.out.print(S);
        for(int i=0; i<res1; i++) System.out.print(')');

        }
    }
    

Measured memory_bytes: 21844
N = int(input())
total = [int(input()) for i in range(N)]
non = []
for i in range(N):
  if total[i] % 10 != 0:
    non.append(total[i])
if len(non):
  if sum(total) %10 != 0:
    ans = sum(total)
  else:
    ans = sum(total)-min(non)
else:
  ans = 0
print(ans)

    


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define ll long long
#define ss second
#define ff first
#define w(x) ll x; cin>>x; while(x--)
#define pi acos(-1)
#define all(cont) cont.begin(), cont.end()
#define countbit(x) __builtin_popcount(x)
#define mod 1000000007
#define re(i,n) for(ll i=0;i<n;i++)
#define re1(i,n) for(ll i=1;i<n+1;i++)
#define de(n) ll n;cin>>n;
#define def(a,n) ll n;cin>>n;ll a[n];re(i,n){cin>>a[i];}
#define defi(a,n,k) ll n;cin>>n; ll k;cin>>k;ll a[n];re(i,n){cin>>a[i];}
#define deb(x) cout<<#x<<"="<<x<<endl;
#define tr(it,a) for(auto it=a.begin();it!=a.end();it++)
#define nl cout<<endl;
using namespace std;
//18-1326D1 1208B 845C 912B 1009B 1350C 20C 1333C 1234D 1327C 1305B 1304B (or in matrix) 1216-C(26) 21
void cp()
{
    ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); 
    #ifndef ONLINE_JUDGE  
    freopen("input.txt", "r", stdin);  
    freopen("output.txt", "w", stdout);
#endif
}
int main()
{
  cp();
  //w(x)
  {
    de(n);
    ll ans=0;
    for(ll i=1;i<n;i++)
    {
      if(n%i==0)
      {
        ans+=(n/i -1);
      }
      else
      {
        ans+=(n/i); 
      }
    }
    cout<<ans;
  }
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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; }



int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<int> d1(n),d2(n);
  rep(i,n) cin >> d1[i] >> d2[i];
  bool f = false;
  rep(i,n-2){
    if(d1[i]==d2[i] && d1[i+1]==d2[i+1] && d1[i+2]==d2[i+2])
      f = true;
  }
  if (f) puts("Yes");
  else
    puts("No");
  return 0;
}

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

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

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

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using DoP = pair<double, double>;
using edge = struct { int to; double cost;}; // edge x = {to, cost}

const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1<<29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main(){
  int n, m;
  cin >> n >> m;
  vector<ll> h(n+1);
  for(int i = 1; i <= n; ++i) cin >> h[i];
  vector<vector<int>> e(n+1);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  vector<bool> used(n+1, false);
  int ans = 0;
  for(int i = 1; i <= n; ++i) {
    if(used[i]) continue;
    bool ok = true;
    for(auto next : e[i]) {
      if(h[next] >= h[i]) ok = false;
    }
    if(ok) {
      ++ans;
      used[i] = true;
      for(auto next : e[i]) {
        used[next] = true;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 9072
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 1e6+5;
const int mod = 1e9+7;
using namespace std;

int f[maxn],a[maxn],b[maxn];

void solve() {
	ll n,cnt=0; cin >> n;
	rep(i,0,n) {
		cin >> a[i];
		f[a[i]]++;
	}
	rep(i,0,n) {
		//ll tmp = a[i];
		int flag=1;
		if (f[a[i]]-1 > 0) continue; 
		int z=0;
		for (int j=1; j*j <= a[i]; j++) {
			if(a[i]%j==0) {
    			b[z++]=j;  
    			if(j!=a[i]/j)
    				b[z++]=a[i]/j;   
   			}    
		}
		rep(k,0,z) if (b[k] != a[i] && f[b[k]]) flag=0;
		if (flag) cnt++;
	}
	cout << cnt;
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:\\Users\\Fish_Brother\\Desktop\\in", "r", stdin);
	//freopen("C:\\Users\\Fish_Brother\\Desktop\\out", "w", stdout);
#endif
	//int t; cin >> t; while(t--)
	solve();

	return 0;
}

Measured memory_bytes: 8168
S=input()
K=int(input())
a=[]
x=0
for i in range(2,10):
    x=S.find(str(i))
    if x!=-1:
        a.append(x)
    else:
        a.append(K)
m=min(a)
if m>K-1:
    print(1)
else:
    print(a.index(m)+2)


Measured memory_bytes: 3060
while True:
    m = int(input())
    if not m:
        break
    target = [tuple(map(int, input().split())) for _ in range(m)]
    bx, by = min(target)
    target = {(x - bx, y - by) for x, y in target}

    n = int(input())
    sky = {tuple(map(int, input().split())) for _ in range(n)}
    sky_s = sorted(sky)

    for x, y in sky_s:
        for tx, ty in target:
            if (x + tx, y + ty) not in sky:
                break
        else:
            print(x - bx, y - by)
            break

Measured memory_bytes: 8112
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define rep(i,a,b) for(ll (i)=a;(i)<(ll)(b);(i)++)
#define INF 100000000

int main(){
    int N,K,d,tmp;
    cin >> N >> K;
    vector<int> cnt(N,0);
    for(int i=0;i<K;i++){
        cin >> d;
        rep(i,0,d){
            cin >> tmp;
            cnt[tmp-1] ++;
        }
    }
    int ans =0;
    cout << count(cnt.begin(),cnt.end(),0) << endl;

}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define fo(i,a) for(ll i=0;i<a;i++)
#define Fo(i,a,n) for(ll i=a; i<n; i++)

using namespace std;

void solve(){
    int n;
    cin>>n;
    int ans;
    if(n%1000 == 0) cout<<0;
    else cout<<1000- (n%1000);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
 //   cin >> t;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 3652
x1, y1, x2, y2 = gets.split.map(&:to_i)
dx = x2 - x1
dy = y2 - y1
x3 = x2 - dy
y3 = y2 + dx
x4 = x3 - dx
y4 = y3 - dy

puts "#{x3} #{y3} #{x4} #{y4}"

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define ll long long
using namespace std;
    ll ar[100001][4];
    ll dp[100001][4];
int32_t main()
{
    int n;
    cin>>n;


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

        for(int j=1;j<=3;j++)
        {
            cin>>ar[i][j];
            dp[i][j]=0;
        }

    }
    dp[1][1]=ar[1][1];
    dp[1][2]=ar[1][2];
    dp[1][3]=ar[1][3];

      for(int i=2;i<=n;i++)
    {
           dp[i][1]=max(dp[i-1][2],dp[i-1][3])+ar[i][1];
           dp[i][2]=max(dp[i-1][1],dp[i-1][3])+ar[i][2];
           dp[i][3]=max(dp[i-1][2],dp[i-1][1])+ar[i][3];
    }
    ll ans=0;
    for(int i=1;i<=3;i++)
    {
        ans=max(ans,dp[n][i]);
    }

    cout<<ans;


}


Measured memory_bytes: 6528
#include <stdio.h>

int main(void)
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a+b==c+d)
		{printf("Balanced");}
	else if(a+b>c+d)
		{printf("Left");}
	else
		{printf("Right");}
	return 0;
}


Measured memory_bytes: 128