akhauriyash/Code-Regression huggingface dataset:
a=int(input())
b=int(input())
if a==1:
    if b==2:
        print(3)
    if b==3:
        print(2)
if a==2:
    if b==1:
        print(3)
    if b==3:
        print(1)
if a==3:
    if b==1:
        print(2)
    if b==2:
        print(1)


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  vector<int> q;
  unordered_set<int> visited;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      char c;
      cin >> c;
      if(c == '#'){
        int coord = i*W+j;
        q.push_back(coord);
        visited.insert(coord);
      }
    }
  }
  const int total = H*W;
  int count = 0;
  while(visited.size() != total){
    vector<int> new_q;
    for(auto coord:q){
       vector<int> new_coord;
       int i = coord / W;
       int j = coord % W;
       new_coord.push_back((i-1 < 0?0:i-1)*W+j);
       new_coord.push_back(i*W+(j-1<0?0:j-1));
       new_coord.push_back(i*W+(j+1>=W?W-1:j+1));
       new_coord.push_back((i+1>=H?H-1:i+1)*W+j);
       for(auto e:new_coord){
         if(visited.find(e) == end(visited)){
           visited.insert(e);
           new_q.push_back(e);
         }
       }
      
    }
	q = new_q;
    //cout << "visited " << visited.size() << endl;
    count += 1;
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 43644
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        L: i32,
        R: i32,
        d: i32,
    }

    let m: Vec<i32> = (L..=R).filter(|n| n % d == 0).collect();
    println!("{}", m.iter().count());
}


Measured memory_bytes: 2100
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>

typedef int32_t i32;

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

#define POS(i, j) (((i) & 1) * d + (j) % d)

void run (void) {
  char *s = ALLOC (10000 + 1, char);
  i32 d;
  scanf ("%s%" SCNi32, s, &d);
  const i32 n = strlen (s);
  const i32 mod = 1000000007;
  i32 *dp = ALLOC (2 * d, i32);
  i32 sup = 0;
  for (i32 i = 0; i < n; ++i) {
    memset (dp + POS(i + 1, 0), 0, sizeof (i32) * d);
    for (i32 j = 0; j < d; ++j) {
      for (i32 k = 0; k < 10; ++k) {
        i32 x = POS(i + 1, j + k);
        dp[x] = (dp[x] + dp[POS(i, j)]) % mod;
      }
    }
    for (i32 j = 0; j < s[i] - '0'; ++j) {
      i32 x = POS(i + 1, sup + j);
      dp[x] = (dp[x] + 1) % mod;
    }
    sup = (sup + s[i] - '0') % d;
  }
  i32 ans = (dp[POS(n, 0)] + (sup == 0 ? 1 : 0) + mod - 1) % mod;
  printf ("%" PRIi32 "\n", ans);
}

int main (void) {
  run();
  return 0;
}


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

int main(){
  int n;
  cin >> n;

  vector<long long> a(n),rui(n);
  long long sum = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    sum += a[i];
    if(i!=0) rui[i] = rui[i-1] + a[i];
    else rui[i] = a[i];
  }

  long long ans = 10000000000;
  for (int i = 0; i < n; i++)
  {
    ans = min(ans,abs(rui[i]-(sum-rui[i])));
  }
  cout << ans << endl;
}

Measured memory_bytes: 3328
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

s=int(input())
count3 = s//3

count=0
for i in range(count3):
    n = s-3*(i+1)+i
    try:
        count += combinations_count(n,i)
    except:
        count += 1        

print(count%(10**9+7))


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

int main(){
    int k,x;
    cin >> k >> x;
    cout <<(k*500>=x ? "Yes" : "No")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 1000000000

int main(){
    int n; cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a,a+n);

    for(int i = 0; i < n-1; i++){
        if(a[i] == a[i+1]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String next = sc.nextLine();
            int w=0,e=0,n=0,s=0;
            int i=1;
            for (char c : next.toCharArray()) {
                if (c == 'W')
                    w=1;
                else if (c == 'E')
                    e=1;
                else if (c == 'N')
                    n=1;
                else
                    s=1;
            }
            if ((w^e)==1 || (n^s)==1)
                System.out.println("No");
            else
                System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 9428
#include <iostream>

using namespace std;

int n, k, m, s, ac[1000005],sub[100005],cor,pen;
int main()
{
    cin >> n >> m;
    for(int i = 1; i <= m; ++i)
    {
        int x;
        char y[5];
        cin >> x >> y;
        if(y[0] == 'A')
        {
            ac[x] = true;
        }
        else if(ac[x] == false)
        {
            ++sub[x];
        }
    }
    for(int i = 1; i <= n; ++i)
    {
        if(ac[i] == true)
            ++cor, pen += sub[i];
    }
    cout << cor << ' ' << pen;
    return 0;
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  string s;
  cin >> s;

  int cnt = 0;
  string jud = "000";

  rep(i, 0, 1000) {
    bool b = false, c = false, wa = false;
    rep(j, 0, s.size()) {
      if (c && s[j] == jud[0]) wa = true;
      if (b && s[j] == jud[1]) c = true;
      if (s[j] == jud[2]) b = true;
    }
    if (wa) ++cnt;
    // cout << jud << ' ' << cnt << '\n';
    if (jud[2] == '9') {
      jud[2] = '0';
      if (jud[1] == '9') {
        jud[1] = '0';
        jud[0] += 1;
      } else
        jud[1] += 1;
    } else
      jud[2] += 1;
  }

  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  string s;
  cin>>n>>s;
  int max=0;
  int now=0;
  rep(i,n){
    if(s[i]=='I'){
      now++;
    }
    else{
      now--;
    }
    chmax(max,now);
  }
  cout<<max<<'\n';
  return(0);
}


Measured memory_bytes: 256
import sys

A=raw_input()
B=raw_input()
G="GREATER"
L="LESS"
E="EQUAL"

if len(A) > len(B):
    print G
    sys.exit()
if len(A) < len(B):
    print L
    sys.exit()

for i in range(len(A)):
    a = int(A[i])
    b = int(B[i])
    if a > b:
        print G
        sys.exit()
    if a < b:
        print L
        sys.exit()

print E

Measured memory_bytes: 2568
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,m=mii()
arr=[]
for i in range(m):
    a,b=mii()
    arr.append([a,b,i])

arr.sort(key=lambda x:(x[0],x[1]))
ans=[]
cnt=1
for i in range(m):

    c= str(arr[i][0]).zfill(6)+str(cnt).zfill(6)
    ans.append([c,arr[i][2]])
    if i+1<m:
        if arr[i][0]==arr[i+1][0]:
            cnt+=1
        else:
            cnt=1

ans.sort(key=lambda x:x[1])
for i in range(m):
    print(ans[i][0])

Measured memory_bytes: 116312
import java.util.*;
import java.io.*;
class Main {
    
    public static void solve(long[] arr){
        PriorityQueue<Long> p = new PriorityQueue<>();
        for(long i : arr){
            p.add(i);
        }
        int mod = 1000000009;
        long sum= 0;

        while(p.size() > 1){
           long first = p.poll();
           long second = p.poll();

            sum += first+second;
            
            p.add(first+second);
        }

        System.out.println(sum);

    }

    public static long frog(long[] arr){
        long[] dp = new long[arr.length];
        
        // dp[0] = arr[0];
        for(int i = 1; i < arr.length; i++){
            long option1 = Long.MAX_VALUE;
            long option2 = Long.MAX_VALUE;
            option1 = dp[i-1] + Math.abs(arr[i] - arr[i-1]);
            if(i-2 >= 0){
                option2 = dp[i-2] + Math.abs(arr[i] - arr[i-2]);
            }

            dp[i] = Math.min(option1,option2);
        
        }

        return (dp[dp.length-1]);
    }
    
    public static void main(String[] args) throws Exception{
        StringTokenizer str;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine().trim());
        long[] arr = new long[n];
        int i = 0;
           str = new StringTokenizer(br.readLine().trim()," ");   
            while(str.hasMoreTokens()){
                arr[i]=Long.parseLong(str.nextToken());
                i++;
            }
       
         System.out.println(frog(arr));
     
    }
}

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

int main(){
    int64_t X;
    cin>>X;
    int64_t m=100;
    int year=0;
    while(1){
        m*=1.01;
        year++;
        if (m>=X){
            break;
        }
    }
    cout<<year<<endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
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; }



void solve(){
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    while(n/k>0){
        n/=k;
        ans++;
    }
    cout<<ans+1<<endl;

}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    
     

    solve(); 


    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define debug printf("-----debug-----\n");
typedef long long ll;
const int MAXN=1005;
vector<int>edges[MAXN];
int cnt[MAXN];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int u,v;
        cin>>u>>v;
        edges[u].push_back(v);
        cnt[v]++;
    }
    queue<int>que;
    for(int i=1;i<=n;i++)
    {
        if(cnt[i]==0)que.push(i);
    }
    int num=0;
    while(!que.empty())
    {
        int u=que.front();que.pop();
        num++;
        for(auto v:edges[u])
        {
            if(--cnt[v]==0)que.push(v);
        }
    }
    cout<<-(num==n)<<endl;
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> d(N);
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}
	sort(d.begin(), d.end());
	auto itr = unique(d.begin(), d.end());
	d.erase(itr, d.end());
	d.resize(itr - d.begin());
	size_t size = d.size();
	cout << size << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <time.h>

using namespace std;
typedef long long int ll;

int main()
{
	int n;
	ll a[10000], b[10000];
	scanf("%d", &n);
	ll as=0, bs=0;
	for(int i=0; i<n; i++){
		scanf("%lld", &a[i]);
		as+=a[i];
	}
	for(int i=0; i<n; i++){
		scanf("%lld", &b[i]);
		bs+=b[i];
	}
	if(as>bs){
		printf("No\n");
		return 0;
	}
	ll count1=0, count2=0;
	for(int i=0; i<n; i++){
		if(a[i]>b[i]) count2+=(a[i]-b[i]);
		if(a[i]<b[i]){
			if(a[i]%2==b[i]%2){
				count1+=((b[i]-a[i])/2);
			}else{
				count1+=((b[i]-a[i]+1)/2);
				count2++;
			}
		}
	}
	if(count1>bs-as || count2>bs-as){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for( int i=a; i<n; i++)
#define loop(i,a,n)	for( int i=a; i>=n; i--)

int main() 
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	int a,b;
	cin>>a>>b;
	int c[b];
	map<int,int> m;
	if(b==0){
		cout<<a;
		return 0;}
	forr(i,0,b)
	{
		cin>>c[i];
		m[c[i]]++;
	}
	int e=-1,f=-1,i=a;
	while(1)
	{
		if(!m.count(i))
		{
			e=i;
			break;
		}
		i++;
	}
	i=a;
	while(1)
	{
		if(!m.count(i))
		{
			f=i;
			break;
		}
		i--;
	}
	if(abs(a-f)<abs(a-e))
		cout<<f;
	else if(abs(a-f)>abs(a-e))
		cout<<e;
	else
		cout<<min(f,e);
	
	return 0; 	
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var < (end); var++)
#define RFOR(var, begin, end) for (int var = (begin) - 1; var >= (end); var--)
#define REP(var, length) FOR(var, 0, length)
#define RREP(var, length) RFOR(var, length, 0)
#define SORT(vector) sort(vector.begin(), vector.end())

const ll MOD = 1e9 + 7;

int a, b, c;
vector<int> l;

int func(int rest, int as, int bs, int cs) {
  int ret1, ret2, ret3, ret4, ret;
  if (rest < 0) {
    return as && bs && cs ? abs(as - a) + abs(bs - b) + abs(cs - c) - 30 : MOD;
  }
  ret1 = func(rest - 1, as, bs, cs);
  ret2 = func(rest - 1, as + l[rest], bs, cs) + 10;
  ret3 = func(rest - 1, as, bs + l[rest], cs) + 10;
  ret4 = func(rest - 1, as, bs, cs + l[rest]) + 10;
  ret = min(ret1, ret2);
  ret = min(ret, ret3);
  ret = min(ret, ret4);
  return ret;
}

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n >> a >> b >> c;
  l = vector<int>(n);
  REP(i, n) {
    cin >> l[i];
  }
  cout << func(n - 1, 0, 0, 0);
}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <set>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> ab(n);

	for (int i = 0; i < n; i++) {
		cin >> ab[i].first >> ab[i].second;
	}

	sort(ab.begin(), ab.end(),
		[](const pair<int, int>& x, const pair<int, int>& y) {return x.second < y.second; });

	int cTime = 0;
	for (int i = 0; i < n; i++) {
		cTime += ab[i].first;
		if (cTime > ab[i].second) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";

	return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
const ll MOD = 998244353;
const ll INF = 1e18;
using namespace std;


main(){    
    #ifdef XOX
        freopen("D:\\V S Code\\cpp\\competitiveProgramming\\Input.txt", "r", stdin);
        freopen("D:\\V S Code\\cpp\\competitiveProgramming\\OPT.txt", "w", stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll a, b, n;
    cin >> a >> b >> n;
    ll x = min(b-1, n);
    cout << (a * x) / b; 
}

Measured memory_bytes: 3608
#include <iostream>
#include <stdio.h>

#define lo long long
using namespace std;

lo n,m,k;
int main()
{
    cin>>n>>m>>k;

    if (k==0 || k==n*m) {cout<<"Yes\n"; return 0;}

    for (lo x=0;x<=n;x++)
    {
        for (lo y=0;y<=m;y++)
        {
            if ((x==0 && n*y==k) || (y==0 && m*x==k))
            {
                cout<<"Yes\n";
                return 0;
            }
            else if (m*x + n*y - 2*x*y == k)
            {
                cout<<"Yes\n";
                return 0;
            }
        }
    }

    printf("No\n");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;
 
int N;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int dp[100000 + 5];
  cin >> N;
  dp[0] = 0;
  for(int i = 1; i<=N; ++i){
    dp[i] = dp[i-1] + 1;
   for(int j=6; j<=i; j*=6) dp[i] = min(dp[i], dp[i-j] + 1);
   for(int j=9; j<=i; j*=9) dp[i] = min(dp[i], dp[i-j] + 1);
  }
  cout << dp[N] << "\n";
  return 0;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# 一番小さい数はかならず条件を満たす(同じ数があるときはだめ)
# i!=j の任意のjで割り切れない → N-i!=jで一つでも割り切れるものがある数

'''
エラトステネスの篩の数列版じゃない？
1  2  3  4  5  6  7  8  9  10
11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30

小さい方から倍数を取ってけば良いかな
'''


N = read_a_int()
A = read_ints()


cnt = Counter(A)
A = []
B = []
for k, v in cnt.items():
    if v == 1:
        A.append(k)
        # ただ消すだけじゃだめなんだ
    else:
        B.append(k)


A.sort()
AMAX = 10**6 + 10
is_first = [True] * (AMAX + 1)
for a in B:
    if is_first[a]:
        for j in range(a, AMAX + 1, a):
            is_first[j] = False

cnt = 0  # なにでも割り切れないときのcnt
for a in A:
    if is_first[a]:
        cnt += 1
        for j in range(a, AMAX + 1, a):
            # print(j)
            is_first[j] = False
print(cnt)


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

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

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

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

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

template<typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	ll N, M;
	cin >> N >> M;
	vll A(N);
	cin >> A;

	vll B(N + 1, 0);
	for (int i = 0; i < N; i++)
		B[i + 1] = A[i] + B[i];

	map<ll, ll> m;
	for (int i = 0; i <= N; i++) {
		m[B[i] % M]++;
	}

	ll ans = 0;
	for (auto mm : m)
		if (mm.second >= 1) {
			ans += mm.second * (mm.second - 1) / 2;
		}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5760
n,m=map(int,input().split())
L=[0 for j in range(30)]
for i in range(n):
  l=list(map(int,input().split()))
  l.pop(0)
  for k in range(1,31):
    if k in l:
      L[k-1]+=1
ct=0
for p in range(len(L)):
  if L[p]==n:ct+=1
print(ct)

Measured memory_bytes: 3064
"use strict";

// read lines from stdin
const input = require("fs")
  .readFileSync("/dev/stdin", "utf8").trim();

let win = 0;

for (let i = 0; i < input.length; i++) {
  if (input.charAt(i) === "o") {
    win++;
  }
}

console.log(win + (15 - input.length) >= 8 ? "YES" : "NO");


Measured memory_bytes: 21064
#include<iostream>
#include<cstdio>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
	int sum,m;
	while(1)
	{
		cin>>m;
		if(m==0)
		{
			break;
		}
		m=1000-m;
		sum=m/500+(m%500)/100+(m%500%100)/50+(m%500%100%50)/10+(m%500%100%50%10)/5+(m%500%100%50%10%5);
		cout<<sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 3124
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
clm = [0]
tot = 0
for a in A:
    tot += a
    clm.append(tot)

def cmb(a):
    return a * (a - 1) // 2 

ans = 0

for a in Counter(clm).values():
    ans += cmb(a)

print(ans)

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,mod=1e9+7;
	cin>>n;
	vector<int>cnt(26,0);
	char c;
	for(int i=0;i<n;++i){
		cin>>c;
		++cnt.at(c-'a');
	}
	int64_t ans=1;
	for(auto&i:cnt){
		ans*=(i+1);
		ans%=mod;
	}
	cout<<ans-1<<"\n"s;
}

Measured memory_bytes: 256
from heapq import heappush,heappop
inf=100000
h,w=map(int,input().split())
cost=[]
for i in range(10):
    lst=list(map(int,input().split()))
    cost.append(lst)

def dijkstra(start):
    min_cost=[inf]*10
    min_cost[start]=0
    q=[]
    heappush(q,(0,start))
    while q:
        c,v=heappop(q)
        if v==1:
            return c
        if c>min_cost[v]:
            continue
        for i,nc in enumerate(cost[v]):
            if c+nc<min_cost[i]:
                min_cost[i]=c+nc
                heappush(q,(c+nc,i))

to_one=[None]*10
for i in range(10):
    to_one[i]=dijkstra(i)
ans=0
for i in range(h):
    lst=list(map(int,input().split()))
    for j in lst:
        if j!=-1:
            ans+=to_one[j]
print(ans)

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

long long int h[100005];

int main()
{
	int n,ans=0,c=0;
	cin >> n;
	h[0] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
	}
	for (int i = n ; i >= 1; i--) {
		if (h[i] <= h[i - 1]) c++;
		else {
			if (c > ans) ans = c;
			c = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int f[10][11],g[10];
void work(int pre,int d,int k){
	if(d==-1)return;
	for(int i=max(pre-1,0);i<=pre+1;i++){
		if(f[d][i]>=k){
			printf("%d",i);work(i,d-1,k);break;
		}
		k-=f[d][i];
	}
}
int main(){
	for(int i=0;i<10;i++)f[0][i]=1;
	g[0]=9;for(int i=1;i<10;i++){
		for(int j=0;j<10;j++){
			if(j)f[i][j]+=f[i-1][j-1];
			f[i][j]+=f[i-1][j]+f[i-1][j+1];
		}
		g[i]=g[i-1];
		for(int j=1;j<10;j++)g[i]+=f[i][j];
	}
	int n;scanf("%d",&n);
	for(int i=0;i<10;i++){
		if(g[i]>=n){
			if(i)n-=g[i-1];
			for(int j=1;j<10;j++)if(f[i][j]>=n){printf("%d",j);work(j,i-1,n);break;}
			else n-=f[i][j];
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll k=0;

    rep(i,n){cin>>a[i];}
   ll dp[n+1][2];
    dp[0][0]=0;
    dp[0][1]=-INF;
    for(int i=0;i<n;i++){
        dp[i+1][0]=max(dp[i][0]+a[i],dp[i][1]-a[i]);
        dp[i+1][1]=max(dp[i][0]-a[i],dp[i][1]+a[i]);
    }

   // cout<<dp[n][1];
   // cout<<dp[n][0];
    cout<<dp[n][0]<<endl;

    return 0;
}


Measured memory_bytes: 2560
import fractions

n = int(input())
A_list = list(map(int, input().split()))
Left = [0]*(n+1)
Right = [0]*(n+1)
for i in range(n):
    Left[i+1] = fractions.gcd(Left[i], A_list[i])
    Right[n-i-1] = fractions.gcd(Right[n-i], A_list[n-i-1])
gcd_max = 0
for del_pos in range(n):
    gcd_ = fractions.gcd(Left[del_pos], Right[del_pos+1])
    if gcd_max < gcd_:
        gcd_max = gcd_
print(gcd_max)

Measured memory_bytes: 89580
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
#define _cTime (chrono::system_clock::now())
#define progress (chrono::duration_cast<chrono::milliseconds>(_cTime-_sTime).count())
#define reset _sTime=_cTime
auto reset;

struct UnionFind{
    vl par,dist;
    UnionFind(int x){par.assign(x,-1); dist.assign(x,0);}
    ll find(ll x){return par[x]<0?x:find(par[x]);}
    ll depth(ll x){return par[x]<0?0:depth(par[x])+dist[x];}
    bool same(ll x,ll y){return find(x)==find(y);}
    ll size(ll x){return -par[find(x)];}
    ll diff(ll x,ll y){return same(x,y)?depth(x)-depth(y):LINF;}
    void unite(ll x,ll y,ll k=0){
        k+=depth(y); k-=depth(x); k=-k;
        x=find(x); y=find(y);
        if(x==y)return;
        if(size(x)<size(y)){swap(x,y);k=-k;}
        par[x]+=par[y]; par[y]=x; dist[y]=k;
    }
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	vl a(m),b(m),c;
	rrep(i,m){
		cin>>a[i]>>b[i];
		a[i]--;b[i]--;
	}
	ll ans=n*(n-1)/2;
	UnionFind u(n);
	rep(i,m){
		c.push_back(ans);
		if(!u.same(a[i],b[i]))ans-=u.size(a[i])*u.size(b[i]);

		u.unite(a[i],b[i]);

	}
	rrep(i,m){
		cout<<c[i]<<"\n";
	}
}


Measured memory_bytes: 5364
N,M,X,Y = map(int,input().split())
x_list = list(map(int,input().split()))
y_list = list(map(int,input().split()))

war_flag = 0
for i in range(X+1,Y+1):

    for j in range(N):
        if i <= x_list[j]:
            war_flag = 1
            break
        else:
            war_flag = 0
    if war_flag == 1:
        continue
    
    for k in range(M):
        if i > y_list[k]:
            war_flag = 1
            break
        else:
            war_flag = 0

    if war_flag == 0:
        print('No War')
        exit()

print('War')


Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
        int a = sc.nextInt();
        int b = sc.nextInt();
		for(int i = 1;i <= 1000;i++){
          if(a == (int)(i * 0.08) && b == (int)(i * 0.1)){
            System.out.println(i);
            return;
          }
        }
      System.out.println(-1);
    }
}

Measured memory_bytes: 35876
#include <bits/stdc++.h>
#define pb push_back
#define Int long long
using namespace std;

const int MAXN=500005;
const long MOD=(long)(1e9+7);
vector<int> adj[MAXN];
vector<pair<int,int>> G[MAXN];

Int N,M,K;
Int B,C,H,W;
Int X,Y,Z;
vector<Int> A;

Int ceilS(Int x,Int y){
    return (x+y-1)/y;
}
using D=long double;

Int perform(Int x){
    return (x*(x+1))/2LL;
}
vector<Int> dp;
bool VIS[MAXN];

void dfs(int u){
    VIS[u]=true;
        for(auto &v:adj[u]){
            if(!VIS[v])
                dfs(v);
            dp[u]=max(dp[u],1+dp[v]);
        }
}

int main()
{
     
     cin>>N;
     A.resize(N);
     for(auto &x:A) cin>>x;
     vector<vector<Int>> dp(N,vector<Int>(N,1e13)) ;
     for(int i=0;i<N;++i) dp[i][i]=0;
     
     vector<Int> pref(N);
     pref[0]=A[0];
     
     for(int i=1;i<N;++i){
         pref[i]=pref[i-1]+A[i];
     }
    
     for(int length=1;length<=N;++length){
         for(int i=0;i<N-length+1;++i){
             int j=i+length-1;
                for(int k=i;k<j;++k){
                    Int sum=pref[j]-(i ? pref[i-1]:0);
                    dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+sum);
                }
         }
     }
     cout<<dp[0][N-1]<<"\n";
    
}


Measured memory_bytes: 28340
#include<bits/stdc++.h>
using namespace std;
char s[300][300];
int nm[300];
int n;
int d[300][300];
int main() {
    scanf("%d",&n);
    for(int i=0;i<n;i++) {
        scanf("%s",s[i]);
        for(int j=0;j<n;j++) {
            if(s[i][j]=='1') d[i][j]=1;
            else d[i][j]=n;
        }
        d[i][i]=0;
    }
    for(int k=0;k<n;k++) {
        for(int i=0;i<n;i++) {
            for(int j=0;j<n;j++) {
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    int u=0;
    int v=0;
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
            if(d[i][j]>d[u][v]) {
                u=i;
                v=j;
            }
        }
    }
    for(int i=0;i<n;i++) nm[i]=d[u][i]+1;
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
            if(s[i][j]=='1' && abs(nm[i]-nm[j])!=1) {
                printf("-1");
                return 0;
            }
        }
    }
    printf("%d",d[u][v]+1);
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int count_sw = 0;

void sort(int A[],int N){
    for (int i = 0; i < N; i++) {
        for (int j = N-1; j > i; j--) {
            if (A[j] < A[j-1]) {
                swap(A[j],A[j-1]);
                count_sw++;
            }
        }
    }
}


int main(){
    int N,*A;
    cin >> N;
    
    A = (int *)malloc(sizeof(int)*N);
    
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    sort(A,N);
    
    for (int i = 0; i < N; i++) {
        cout << A[i];
        if (i != N-1) cout << " ";
    }
    cout << endl;
    
    cout << count_sw << endl;
    
    
    return 0;
}

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

int main() {
  string O, E;
  cin >> O >> E;
  for (int i = 0; i < O.size(); i++) {
    cout << O[i];
    if (i < E.size()) {
      cout << E[i];
    }
  }
  cout << endl;
}

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

int main() {
  int H, W;
  scanf("%d%d", &H, &W);

  vector<string> grid(H);
  for (int i = 0; i < H; i++) {
    cin >> grid.at(i);
  }

  vector<bool> row(H, false);
  vector<bool> col(W, false);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (grid.at(i).at(j) == '#') {
        row.at(i) = true;
        col.at(j) = true;
      }
    }
  }

  for (int i = 0; i < H; i++) {
    if (row.at(i)) {
      for (int j = 0; j < W; j++) {
        if (col.at(j)) {
          cout << grid.at(i).at(j);
        }
      }
      cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

from collections import defaultdict
from heapq import heappush, heappop
import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
# INF = sys.maxsize
INF = 10 ** 10
# INF = float("inf")

count = [0] * (10 ** 5 + 10)


def dp(*x):  # debugprint
    print(*x)


def main():
    N = int(input())
    AS = map(int, input().split())
    sum = 0
    for a in AS:
        count[a] += 1
        sum += a
    Q = int(input())
    for q in range(Q):
        B, C = map(int, input().split())
        sum += (C - B) * count[B]
        count[C] += count[B]
        count[B] = 0
        print(sum)


def _test():
    import doctest
    doctest.testmod()


if __name__ == "__main__":
    import sys
    argv = sys.argv
    if len(sys.argv) == 1:
        # no option
        main()
    elif sys.argv[1] == "-t":
        _test()
    else:
        input = open(sys.argv[1]).buffer.readline


Measured memory_bytes: 16332
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            } else {
                for (int h = 0; h < H; h++) {
                    for (int w = 0; w < W; w++) {
                        System.out.print("#");
                    }
                    System.out.println();
                }
                System.out.println();
            }
        }
    }
}


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

const int N = 2e5+5;
int n, m;
vector<int> adj[N];

bool a[N], b[N];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int x, y; cin >> x >> y;
        if (y == n) b[x] = true;
        if (x == 1) a[y] = true;
    }
    for (int i = 1; i <= n; i++) {
        if (a[i] && b[i]) {
            cout << "POSSIBLE\n";
            return 0;
        }
    }
    cout << "IMPOSSIBLE\n";
}



Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
struct point
{
    ll x, y;
};
ll dist(ll x,ll y)
{
    return x*x+y*y;
}
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    int cnt=0;
    ll n,d;
    cin>>n>>d;
    d*=d;
    rep (i,0,n)
    {
        ll x,y;
        cin>>x>>y;
        ll val=dist(x,y);
        if (val<=d)
        {
            cnt++;
        }
    }
    cout<<cnt<<"\n";
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
      using namespace std;
      #include <ext/pb_ds/assoc_container.hpp>
      #include <ext/pb_ds/tree_policy.hpp>
      using namespace __gnu_pbds;
      #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
      #define ll long long
      #define int long long
      #define ld long double
      #define pb push_back
      #define f(i,a,b) for(int i=a;i<b;i++)
      #define fd(i,a,b) for(int i=a-1;i>=b;i--)
      #define pf push_front
      #define ppf pop_front
      #define ppb pop_back
      #define fi first
      #define se second
      #define take(a,n) f(i,0,n)cin>>a[i];
      #define show(a,n) f(i,0,n){cout<<a[i]<<" ";}
      #define ashow(a)  for(auto i:a)cout<<i<<" ";
      #define khtm     cout<<endl;
      #define all(s) s.begin(),s.end()
      #define len(a) a.length()
      #define INF 1e18
      #define MAXN 2000009
      #define PMOD 998244353
      const double pi=3.14159265358979323;
      const int mod=1e9+7;
      void btao(int n){
        if(n)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
      }
      bool isPrime(int n) 
  { 
      // Corner cases 
      if (n <= 1) 
          return false; 
      if (n <= 3) 
          return true; 
    
      // This is checked so that we can skip 
      // middle five numbers in below loop 
      if (n % 2 == 0 || n % 3 == 0) 
          return false; 
    
      for (int i = 5; i * i <= n; i = i + 6) 
          if (n % i == 0 || n % (i + 2) == 0) 
              return false; 
    
      return true; 
  } 
  int spf[MAXN];
  void sieve()
        {
            spf[1] = 1;
            for (int i=2; i<MAXN; i++)
                spf[i] = i;
            for (int i=4; i<MAXN; i+=2)
                spf[i] = 2;
            for (int i=3; i*i<MAXN; i++)
            {
                if (spf[i] == i)
                {
                    for (int j=i*i; j<MAXN; j+=i)
                        if (spf[j]==j)
                            spf[j] = i;
                }
            }
        }
 
  int lcm(int a,int b){
      return a*b/__gcd(a,b);
  }
  
  // string s;
       signed main() {

          ios_base::sync_with_stdio(false);
          cin.tie(NULL);  
          cout.tie(0);  
       // -------------------------------------Code starts here--------------------------------------------------------------------- 
      int t=1;
      // cin>>t;
      while(t--)
      {
        

            int x=0,y=0;
          int mx=0,mi=INF,mn=INF;
            int tb,ta,tm=0;
            int n,m;
            // int a,b;
            cin>>n;
           int a[n];
           take(a,n);
           sort(a,a+n);
           y+=a[n-1];
           x=1;
           for(int i=n-2;i>=0;i--){
            if(x==n-1)break;
            y+=a[i];
            x++;
             if(x==n-1)break;
            y+=a[i];
            x++;
        }
        
        cout<<y<<endl;


                    }
   }

Measured memory_bytes: 5224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define repd(i,a,b) for(ll i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int>
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
#define INF 1e18
#define NINF -1e16

#define nax 200005
bool isPrime(ll n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
} 
bool isPowerOfTwo (unsigned int x) 
{ 
  return (!(x&(x-1))); 
}
vll prime;
signed main() {
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	srand (static_cast <unsigned> (time(0)));
	int t=1;
	//cin >> t;
	while (t--) 
	{
		int a,b,c;
      cin >>a>>b>>c;
      int k;
      cin>>k;
      if (b>a && c>b)
        cout <<"Yes";
      else
      {
        while(k>0)
        {
          if (b<=a)
            b*=2;
          else if (c<=b)
            c*=2;
          else
            break;
          k--;
        }
        if (b>a && c>b)
          cout <<"Yes";
        else
          cout <<"No";
	}
	}
	return 0;
}


Measured memory_bytes: 3688
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false)

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

const int N = 1e5 + 5;

vector <int> g[N];
bool seen[N];

int dfs(int cur);

int main()
{
	int n;
	cin >> n;
	for (int i = 1; i < n; ++i)
	{
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}

	if (dfs(1))
		cout << "Alice\n";
	else
		cout << "Bob\n";
}

int dfs(int cur)
{
	seen[cur] = true;
	int ans = 0;
	for (auto &i : g[cur])
		if (!seen[i])
			ans ^= (1 + dfs(i));

	return ans;
}

Measured memory_bytes: 8960
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#include <iomanip>
#define For(i,j,k) for(int i=j;i<=k;i++)
#define Dow(i,j,k) for(int i=j;i>=k;i--)
#define LL long long
using namespace std ;

inline LL read() {
	LL x = 0 , f = 1 ;
	char ch = getchar() ;
	while(ch<'0'||ch>'9') { if(ch=='-') f = -1 ; ch = getchar() ; }
	while(ch>='0'&&ch<='9') { x = x * 10+ch-48 ; ch = getchar() ; }
	return x * f ;
}

const int N = 1e5+11;
int n,x,y,S;
int a,b,c,d;


int main() {
	n=read();
	For(i, 1, n) {
		x=read();
		if(x%4==0) a++;
		else if(x%2==0) b++;
		else c++;
	}
	if(b) c++;
	c--;
	if(a-c<0) puts("No");
	else puts("Yes");
}









Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){

    int n, h, w; cin >> n >> h >> w;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int a, b; cin >> a >> b;
        if(h <= a && w <= b) ans++;
    }

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



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;

int main() {
    int n, p, p_max;

    scanf("%d", &n);

    int ans = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &p);
        ans += p;
        p_max = max(p_max, p);
    }
    ans -= p_max / 2;

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

    return 0;
}


Measured memory_bytes: 128