akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int range = sc.nextInt();
        int atk = sc.nextInt();
        
        range = 2 * range;
        
        // 座標順に整列
        int[][] array = new int[n][2];
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            int hp = sc.nextInt();
            array[i][0] = x;
            array[i][1] = hp;
        }
        Arrays.sort(array, (az, bz) -> Integer.compare(az[0], bz[0]));
        
        // [{x, y}, ...] 座標xまでyのダメージを食らうというキュー
        Queue<int[]> que = new ArrayDeque<int[]>();
        
        long totalBombs = 0;
        long nowDamage = 0;
        for (int i = 0; i < n; i++) {
            int x = array[i][0];
            int hp = array[i][1];
            
            // xに当たらない爆風のデータは削除する
            while (!que.isEmpty()) {
                int[] ary = que.peek();
                
                if (x > ary[0]) {
                    // 現在受けるダメージからも引く
                    nowDamage -= ary[1];
                    
                    que.poll();
                } else {
                    break;
                }
            }
            
            // 現在キューに溜まったダメージを受ける
            hp -= nowDamage;
            
            // 当座標のHPが残っている場合、爆弾を使う
            if (hp > 0) {
                // 残HPを0にするのに必要な爆弾数を数える
                int needBombs = hp / atk;
                if (hp % atk != 0) {
                    needBombs++;
                }
                
                totalBombs += needBombs;
                
                // 現在受ける爆風ダメージを更新する
                int damage = atk * needBombs;
                nowDamage += damage;
                
                // 今回の爆風の範囲とダメージをキューに入れる
                que.add(new int[]{x + range, damage});
            }
        }
        
        
        System.out.println(totalBombs);
    }
}


Measured memory_bytes: 119676
#include <iostream>
#include <vector>
#include <algorithm>
long long sankaku[1000000];
void init(){
  sankaku[0] = 0;
  for(int i = 1; 1000000 > i; i++){
    sankaku[i] = sankaku[i-1]+i;
  }
}
using namespace std;
int main(){
  int n;cin>>n;
  vector<string> s(n);
  init();
  for(int i = 0; n > i; i++){
    cin>>s[i];
    sort(s[i].begin(),s[i].end());
  }
  sort(s.begin(),s.end());
  vector<int> ans;
  int tmp = 1;
  for(int i = 1; n > i; i++){
    if(s[i-1]!=s[i]){
      ans.push_back(tmp);
      tmp = 1;
    }else tmp++;
  }
  ans.push_back(tmp);
  long long ret = 0;
  for(int i = 0; ans.size() > i; i++){
    ret += sankaku[ans[i]-1];
  }
  cout << ret << endl;
  
}

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

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

int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

bool solve(vector<ll> &a, vector<ll> &b){
  bool ok = true;
  rep(i,a.size()){
      if(a[i]!=b[i]){
        ok = false;
        break;
      }
  }
  if(ok){
    return true;
  }else{
    return false;
  }
}

int main(){
  ll n;
  cin >> n;
  vector<ll> p(n);
  vector<ll> q(n);

  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];

  vector<ll> r(n);
  rep(i,n) r[i] = i+1;

  ll a,b;
  ll i = 0;
  do{
    i++;
    if(solve(r,p)){
      a = i;
    }
    if(solve(r,q)){
      b = i;
    }
  }while(next_permutation(r.begin(), r.end()));

  cout << abs(a-b) << endl;


  return 0;
}

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

const int MAX_N = 2e5 + 5;

vector< int > g[MAX_N];

int main() {
	int n, m;
	scanf(" %d %d", &n, &m);

	for(int i = 0; i < m; i++) {
		int u, v;
		scanf(" %d %d", &u, &v);

		g[u].pb(v);
		g[v].pb(u);
	}

	for(int nb1 : g[1]) {
		for(int nb2 : g[nb1]) {
			if(nb2 == n) {
				printf("POSSIBLE\n");
				return 0;
			}
		}
	}

	printf("IMPOSSIBLE\n");
	return 0;
}


Measured memory_bytes: 12016
#include <bits/stdc++.h>
#include <ctype.h>
using namespace std;
 
 
int main(){
  int A,B;
  cin>>A>>B;
  if(A==1&&A!=B||A>B&&B!=1)cout<<"Alice"<<endl;
  else if(A==B)cout<<"Draw"<<endl;
  else cout<<"Bob"<<endl;
}

Measured memory_bytes: 256
a=[list(map(int,input().split()))for i in range(3)]
n=int(input())
b=[int(input())for i in range(n)]
ans='No'
for i in range(3):
  for j in range(3):
    for k in range(n):
      if a[i][j]==b[k]:
         a[i][j]=0
      
for i in range(3):
    if a[i][0] + a[i][1] + a[i][2] == 0:
        ans = "Yes"
    if a[0][i] + a[1][i] + a[2][i] == 0:
        ans = "Yes"
if a[0][0] + a[1][1] + a[2][2] == 0:
    ans = "Yes"
if a[0][2] + a[1][1] + a[2][0] == 0:
    ans = "Yes"
print(ans)


Measured memory_bytes: 3064
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

lim = 10 ** 6 + 1
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, lim + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    # 累計
    factinv.append((factinv[-1] * inv[-1]) % mod)

def cmb(n, r):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % mod

H, W, A, B = getNM()

mother = cmb((H - 1) + (W - 1), (W - 1))

goban = cmb((H - A) + (B - 1), B - 1)
togoal = cmb((A - 1) + (W - B - 1), (W - B - 1))

for i in range(A):
    row = H - A + i
    col = B - 1
    row_left = A - 1 - i
    col_left = W - B - 1
    mother -= cmb(row + col, row) * cmb(row_left + col_left, row_left)
    mother %= mod
print(mother)

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

int main() {
  int n;
  cin >> n;
  vector<int> a;
  for (int i=0; i<n; i++) {
    int input;
    cin >> input;
    a.push_back(input);
  }

  sort(a.begin(), a.end());
  printf("%d\n", a[n-1] - a[0]);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int N,M,Q;
int a[50],b[50],c[50],d[50];
int ans;
int A[10];

void dfs(int id,int pre) {
	if (id==N) {
		int now=0;
		for (int i=0;i<Q;i++)
      if (A[b[i]-1]-A[a[i]-1]==c[i])
        now += d[i];
		if (ans<now) ans=now;
	} else {
		for (int i=pre; i<=M; i++) {
			A[id]=i;
			dfs(id+1,i);
		}
	}
}

int main() {
	cin>>N>>M>>Q;
	for(int i=0;i<Q;i++)
    cin>>a[i]>>b[i]>>c[i]>>d[i];
	dfs(0,1);
	cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3592
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	var M int
	fmt.Scan(&M)
	var X int
	fmt.Scan(&X)
	nums := scanNums(M)

	cntN := 0
	cnt0 := 0
	for _, num := range nums {
		if num > X {
			cntN++
		}
		if num < X {
			cnt0++
		}
	}
	fmt.Println(min(cntN, cnt0))
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func min(nums ...int) int {
	res := nums[0]
	for _, num := range nums {
		if res > num {
			res = num
		}
	}
	return res
}


Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    long long A, B;
    cin >> A >> B;

    long long i = 1;
    while (true) {
        if (A * i % B == 0) {
            cout << A * i << endl;
            return 0;
        }
        i++;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
 
#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238
 
typedef pair<int, int> P;
 
 
signed main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    int cnt = 0;
    REP(i,min(N/4,M)){
        cout<<i+1<<" "<<N/2-i<<endl;
        cnt++;
    }
    if(cnt<=M){
        if(((N/2)%2==0&&(N%2==0))||((N/2)%2==1&&(N%2==0))){
            REP(i,M-cnt){
                cout<<N/2+i+1<<" "<<N-i-1<<endl;
            }
        }else{
            REP(i,M-cnt){
                cout<<N/2+i+1<<" "<<N-i<<endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3772
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

//typedef __int64 ll;
typedef long long ll;
ll n;

int main(){
	while(cin>>n){
		if(!n)return 0;
		ll m=n,d=1,p;
		while(m>7){m/=8;d++;}
		for(int i=d-1;i>=0;i--){
			p=(n/(int)(pow(8,i)+0.1))%8;
			if(p<4)cout<<p;
			else if(p<5)cout<<p+1;
			else cout<<p+2;
		}
		cout<<endl;
	}
}

Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;

int main()
{
    int n, a[212345];

    cin >> n;
    REP(i, n)
    {
        cin >> a[i];
        a[i] -= i + 1;
    }

    sort(a, a + n);

    int b;

    if (n % 2)
        b = a[n / 2];
    else
        b = (a[n / 2 - 1] + a[n / 2]) / 2;

    ll res = 0;

    REP(i, n)
    res += abs(a[i] - b);

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define show(x) cout<<#x" = "<<x<<endl;
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<unsigned,unsigned> uupair;
typedef pair<int,int> iipair;
typedef vector<int> vec;
typedef vector<ll> llvec;
typedef vector<unsigned> uvec;
typedef vector<ull> ullvec;
typedef vector<uvec> grid;
typedef vector<vec> igrid;
typedef vector<string> svec;
typedef vector<bool> bvec;
typedef vector<bvec> bgrid;
typedef vector<char> cvec;
typedef vector<uupair> uupvec;
typedef vector<iipair> iipvec;
typedef unordered_map<unsigned,unsigned> uuhmap;
typedef unordered_map<ll,ll> llllhmap;
typedef map<unsigned,unsigned> uumap;
typedef map<int ,unsigned> iumap;
typedef map<int,int> iimap;
typedef unordered_map<int ,unsigned> iuhmap;
typedef unordered_map<int,int> iihmap;
typedef unordered_map<unsigned,uvec> uuvechmap;
typedef map<char,cvec> ccvecmap;
typedef unordered_set<unsigned> uhset;
typedef set<unsigned> uset;

const unsigned LIMIT=1e5;

int main()
{
    unsigned n;
    uvec a,b,c;
    unsigned dp[LIMIT+1][3];
    
    cin>>n;

    a.resize(n);
    b.resize(n);
    c.resize(n);

    for(unsigned i=0;i<n;++i)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    dp[0][0]=dp[0][1]=dp[0][2]=0;
    for(unsigned i=1;i<=n;++i)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i-1];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i-1];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i-1];
    }
    cout<<max({dp[n][0],dp[n][1],dp[n][2]});
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

string s;
int n;
ll dp[2011][2011];
ll pre[2011][27],nxt[2011][27];

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

  cin>>s;
  s=(char)('a'+26)+s+(char)('a'+26);
  n=s.size();

  rep(i,2001)rep(c,26)nxt[i][c]=INF;
  for(ll i=n-2;i>=0;i--){
    repl(c,'a','z'+1){
      if(s[i+1]==c)nxt[i][c-'a']=i+1;
      else nxt[i][c-'a']=nxt[i+1][c-'a'];
    }
  }

  memset(pre,-1,sizeof(pre));
  repl(i,1,n+1){
    repl(c,'a','z'+1){
      if(s[i-1]==c)pre[i][c-'a']=i-1;
      else pre[i][c-'a']=pre[i-1][c-'a'];
    }
  }

  rep(i,n)dp[i][i]=dp[i][i+1]=1;
  repl(len,2,n+1){
    rep(l,n){
      ll r=l+len;
      if(r>n)break;
      ll res=1;
      rep(c,26){
        if(nxt[l][c]<r&&pre[r][c]>l){
          res++;
          if(nxt[l][c]<pre[r][c])res+=dp[nxt[l][c]][pre[r][c]];
        }
      }
      dp[l][r]=res%mod;
    }
  }
  cout<<(dp[0][n]-1+mod)%mod<<endl;

  return 0;
}



Measured memory_bytes: 26736
#include <vector>
#include <fstream>
#include <iostream>
using namespace std;

int main() {
  int n, div, rem;
  cin >> n;

  div = n / 2;
  rem = n % 2;

  if (rem == 1) {
    div = div + 1;
  }
  cout << div;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;

int main()
{
    faster

    ll n,a,b;

    cin>>n>>a>>b;

    ll s=a+b;

    ll p=n/s , r=n%s;



    cout<<(p*a)+min(r,a)<<endl;


    return 0;
}



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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using vb = vector<bool> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

ll fast(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        y >>= 1;
    }
    return res;
}

ll inv(ll n){
    return fast(n,mod-2);
}


void pre(){



}


void solve(){

    int h,n;
    cin >> h >> n;
    vector<int> a(n+1),b(n+1);
    for(ll i=1;i<=n;i++){
        cin >> a[i] >> b[i];
    }
    vector<vector<int>> dp(2,vector<int>(h+1,oo));
    int prev=0 , cur = 1;
    dp[cur][0] = 0;
    for(int i=1;i<=h;i++){
        if(a[1] >= i){
            dp[cur][i] = b[1];
        }else{
            dp[cur][i] = dp[cur][i-a[1]] + b[1];
        }
    }
    //cout << dp[cur][9] << " ";
    for(int i=2;i<=n;i++){
        swap(prev,cur);
        dp[cur][0] = 0;
        for(ll j=1;j<=h;j++){
            if(a[i] >= j){
                dp[cur][j] = min(dp[prev][j],b[i]);
            }else{
                dp[cur][j] = min(dp[prev][j] ,  min(dp[cur][j-a[i]] , dp[prev][j-a[i]]) + b[i]);
            }
        }
    }

    cout << dp[cur][h];

}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
 
int main() {
  int a, b;
  std::cin >> a >> b;
  int max = 0;
  // aを２回押す
  max = a + a-1;
  // bを２回押す
  max = std::max(max, b + b-1);
  // aとbを押す
  max = std::max(max, a+b);
  // 出力
  std::cout << max << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll n, l;
  cin >> n >> l;
  vector<string> s(n);
  rep(i,n) cin >> s[i];
  Sort(s);
  rep(i,n) cout << s[i];
  cout << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RANGE(i,n) for(int i=0;i<n;i++)
typedef long long ll;
struct P{
    ll var1;
    ll var2;
};
bool operator< ( const P &one, const P &two){
    return one.var1 < two.var1;
};
bool operator> ( const P &one, const P &two){
    return one.var1 > two.var1;
};

using namespace std;

signed main() {
    double W,H,x,y;
    bool dup_flag = false;
    cin >> W >> H >> x >> y;
    if( x == W/2 && y == H/2)cout << H*W/2 << " " << 1;
    else cout << H*W/2 << " " << 0;
}


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

const int MN = 2222;
using namespace std;
vector<int> v[MN];
bool used[MN];
int dp[MN][MN];
int f(int x, int k, int d) {
    int ret = 0;
    if(d > k) ret = 1;
    used[x] = 1;
    for(int y: v[x]) {
        if(!used[y]) {
            ret += f(y, k, d+1);
        }
    }
    used[x] = 0;
    return ret;
}
int main() {
    int n;
    int k;
    cin>>n>>k;
    for(int i = 0; i < n-1; ++i) {
        int a,b;
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    int ans = 1e9;
    for(int i = 1; i <= n; ++i) {
        int q = 0;
        vector<int> t1(MN);
        vector<int> t2(MN);
        used[i] = 1;
        if(k%2 == 0) {
            for(int x: v[i]) {
                q += f(x, k/2, 1);
            }
            ans = min(ans, q);
        }
        else {
            for(int x: v[i]) {
                t1[x] += f(x, k/2, 1);
                q += t1[x];
                t2[x] += f(x, k/2+1, 1);
            }
            for(int x: v[i]) {
                ans = min(ans, q - t1[x] + t2[x]);
            }
        }
        used[i] = 0;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
#define N 25
char a[N][N];
bool vis[N][N];
int dep[N][N];
int dx[]={0,1,-1,0,0};
int dy[]={0,0,0,1,-1};
int n,m;
int sol(int sx,int sy,int ex,int ey)
{
	if(ex<sx) return 0;
	if(ex==sx&&ey<sy) return 0;
	queue<pii> q;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			dep[i][j]=1000;
			vis[i][j]=0;
		}
	}
	dep[sx][sy]=0;
	q.push(mp(sx,sy));
//	int cnt=0;
	while(!q.empty())
	{
		pii u=q.front();
		q.pop();
//		cnt++;
		if(u.fir==ex&&u.second==ey)
		{
			return dep[ex][ey];
		}
		for(int i=1;i<=4;i++)
		{
			int tx=u.first+dx[i],ty=u.second+dy[i];
			if(tx<1||ty<1||tx>n||ty>m) continue;
			if(a[tx][ty]=='#') continue;
			if(vis[tx][ty]) continue;
			vis[tx][ty]=1;
			dep[tx][ty]=dep[u.first][u.second]+1;
			q.push(mp(tx,ty));
		}
	}
}
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		scanf("%s",a[i]+1);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(a[i][j]=='#' ) continue;
			for(int c=1;c<=n;c++)
			{
				for(int d=1;d<=m;d++)
				{
					if(a[c][d]=='#') continue;
					if(c==i&&d==j) continue;
//					printf("%d %d %d %d\n",i,j,c,d);
					ans=max(ans,sol(i,j,c,d));
				}
			}
		}
	}
	cout<<ans<<endl;
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



Measured memory_bytes: 256
import sys
import heapq
sys.setrecursionlimit(2000000)
n,m = map(int,input().split())
g2 = [[] for i in range(n)]
g = [[] for i in range(n)]
for i in range(n-1+m):
        a,b = map(int,input().split())
        g2[b-1].append(a-1)
        g[a-1].append(b-1)
for j in range(n):
        if len(g2[j]) == 0:
                ne = j
                break
kazu = [0]*n
for i in range(n):
        kazu[i] = len(g2[i])
ans = [0] * n
def dfs(x):
        z = []
        for i in g[x]:
                kazu[i]-=1
                if kazu[i] == 0:
                        z.append(i)
                        ans[i] = x+1
        for i in z:
                dfs(i)
dfs(ne)
for i in ans:
        print(i)


Measured memory_bytes: 137108
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b, c) for (int i = (a); i <= (b); i += (c))
#define FORD(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define FORl(i, a, b, c) for (ll i = (a); i <= (b); i += (c))
#define FORDl(i, a, b, c) for (ll i = (a); i >= (b); i -= (c))
using namespace std;
int main () {
	int l;
	scanf("%d", &l);
	vector< pair<pii, int> > elist;
	int it = 20;
	while (l > 1) {
		if (l % 2 == 0) {
			elist.pb({{it - 1, it}, 0});
			elist.pb({{it - 1, it}, l >> 1});
			l >>= 1; it--;
		} else {
			elist.pb({{1, it}, l - 1});
			l--;
		}
	}
	printf("%d %d\n", 20 - it + 1, (int)elist.size());
	for (auto e : elist) {
		if (e.fi.fi != 1) e.fi.fi -= it - 1;
		e.fi.se -= it - 1;
		printf("%d %d %d\n", e.fi.fi, e.fi.se, e.se);
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())

dic = {}
ans = 1

def calc(N):
    n = N
    for i in range(2, N + 1):
        while n % i == 0:
            if i not in dic:
                dic[i] = 1
            else:
                dic[i] += 1
            n = int(n / i)

for i in range(2, N + 1):
    calc(i)

for v in dic.values():
    ans = (ans * (v + 1)) % (10 ** 9 + 7)

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long 
#define ull unsigned long long 
#define f(i,x,n) for(ll int i=x;i<n;i++) 
#define re(j,x,n) for(ll int j=x;j>=n;j--)
#define f1(k,x,n) for(ll int k=x;k<=n;k++)
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll int t,x;
    cin>>t>>x;
    float ans=(float)t/x;
    cout<<fixed<<setprecision(9)<<ans; 
   
}

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

using namespace std;
using LLONG = long long;

int main()
{
	LLONG X, Y; cin >> X >> Y;
	if (X % Y == 0)
	{
		cout << -1 << endl;
	}
	else
	{
		LLONG ans = X;
		while (ans <= 1e18)
		{
			if (ans % Y != 0) break;
			ans += X;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<algorithm>

using namespace std;
using ll = long long;

int main() {
	string A, B;
	cin >> A >> B;

	if (A.size() < B.size()) {
		cout << "LESS" << endl;
		return 0;
	}
	else if (A.size() > B.size()) {
		cout << "GREATER" << endl;
		return 0;
	}
	else {
		for (int i = 0; i < (int)A.size(); i++) {
			char& A_tmp = A[i];
			char& B_tmp = B[i];
			int Q = A_tmp - '0';
			int W = B_tmp - '0';

			if (Q < W) {
				cout << "LESS" << endl;
				return 0;
			}
			else if (Q > W) {
				cout << "GREATER" << endl;
				return 0;
			}
		}

		cout << "EQUAL" << endl;
		return 0;
	}
}

Measured memory_bytes: 3572
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> ADJ;
vector<int> dp;
vector<bool> visit; 
void dfs(int p)
{
	if(ADJ[p].size()==0)
	{
		dp[p]=0;
	}
	else
	{
		int m=-1;
		for (int i = 0; i < ADJ[p].size(); ++i)
		{
			if(visit[ADJ[p][i]]==false)
			{
				dfs(ADJ[p][i]);
			}
			m=max(dp[ADJ[p][i]],m);
		}
		dp[p]=m+1;
	}
	visit[p]=true;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// chrono::steady_clock sc;
 //  	auto start = sc.now();
 //  	ifstream cin;
 //  	cin.open("INPUT.txt");

	int N,M;
	cin>>N>>M;
	ADJ.resize(N);
	dp.resize(N);
	visit.resize(N);
	for (int i = 0; i < N; ++i)
	{
		visit[i]=false;
	}
	for (int i = 0; i < M; ++i)
	{
		int x,y;
		cin>>x>>y;
		x--;
		y--;
		ADJ[x].push_back(y);
	}
	for (int i = 0; i < N; ++i)
	{
		if(visit[i]==false)
		{
			dfs(i);
		}
	}
	int ans=0;
	for (int i = 0; i < N; ++i)
	{
		if(dp[i]>ans)
		{
			ans=dp[i];
		}
	}
	cout<<ans<<endl;
	
	// cin.close();
	// auto end = sc.now();
 //   	auto time_span = static_cast<chrono::duration<double>>(end - start);
 //   	cout<<"Operation took: "<<time_span.count()<<" seconds";

	return 0;
}

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

#include <math.h>
#include <stdlib.h>


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

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; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    if(N%2 == 0) cout << N << endl;
    else cout << 2 * N << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;

int main(){
    int all, choose, item, ans=0;
    vector<int> vec1;
    cin >> all >> choose;
    for (int i = 0; i < all;i++){
        cin >> item;
        vec1.push_back(item);
    }
    sort(vec1.begin(), vec1.end());
    for (int i = 0; i < choose;i++){
        ans += vec1[i];
    }

    cout << ans;
}

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

int main()
{
    int n , t = 0 , h = 0 ;
    cin >> n ;
    while(n--)
    {
        string T , H ;
        cin >> T >> H ;
        if(T > H) t += 3 ;
        else if(T == H)
        {
            t += 1 ;
            h += 1 ;
        }
        else h += 3 ;
    }
    cout << t << " " << h << endl ;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
int main(){
  char a, b;
  cin >> a >> b;
  if((a=='H'&&b=='H')||(a=='D'&&b=='D')){
    cout << 'H' << endl;
  }
  else {
    cout << 'D' << endl;
  }
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
typedef long long int ll;
#define pb         push_back
#define mp         make_pair
#define F          first
#define S          second
#define fl(i,a,b)  for(ll i=a;i<b;i++)
#define pll        pair<ll,ll>
#define pii        pair<int,int>
#define all(v)     v.begin(),v.end()
#define M          1000000321

using namespace std;
bool isPrime(ll n)
{
    if(n<=1)
        return false;
    if(n<=3)
        return true;
    if(n%2==0 || n%3==0)
        return false;

    for(ll i=5;i*i<=n;i=i+6)
        if(n%i==0|| n%(i+2)==0)
            return false;

    return true;
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b,a%b);

}

bool sortbydesc(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    if(a.S < b.S)
        return true;
    else
        return false;
}

vector<ll> gr[100005];
ll dp[100005];

ll dfs(ll x)
{
    if(dp[x]!=-1)
        return dp[x];
    if(gr[x].size()==0)
    {
        dp[x]=0;
        return dp[x];
    }
    ll temp=0;
    fl(i,0,gr[x].size())
        temp = max(temp,dfs(gr[x][i]));
    dp[x]=1+temp;
    return dp[x];
}

int main()
{
 ios::sync_with_stdio(0);
 cin.tie(0);
 cout.tie(0);
 ll n,m;
 cin>>n>>m;
 ll a,b;
 fl(i,0,m)
 {
    cin>>a>>b;
    gr[a].pb(b);
 }
 memset(dp,-1,sizeof(dp));
 ll ans=0;
 fl(i,1,n+1)
 ans=max(ans,dfs(i));
 cout << ans;
}

Measured memory_bytes: 8576
N,M= map(int,input().split())
H = list(map(int,input().split()))
K = [ [] for _ in range(N) ]
for i in range(M):
    a,b = map(int,input().split())
    K[a-1].append(b-1)
    K[b-1].append(a-1)

ans = 0
for i in range(N):
    m = H[i]
    judge = 0
    for j in K[i]:
        if H[j] >= m:
            judge = 1
            break
    if judge == 0:
        ans += 1
print(ans)

Measured memory_bytes: 94468
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
// #define mod  1000000007
#define N 100005
// #define MAX 200005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"
// const int inf = (int)1e18 + 10;
const int mod = 1e9 + 7;

const int inf = 1e15;

signed main(){
  fast;
   
   int a , b , n , ans , tl , tr , sl , sr , x;
   cin >> a >> b >> n;
   vec s(a);
   vec t(b);
   for(int i = 0 ; i < a ; i++)
       cin >> s[i];

   for(int i = 0 ; i < b ; i++)
        cin >> t[i];

   sort(s.begin() , s.end());
   sort(t.begin() , t.end());

   for(int i = 0 ; i < n ; i++){
       cin >> x;
       tl = lower_bound(t.begin() , t.end() , x) - t.begin();
       tr = upper_bound(t.begin() , t.end() , x) - t.begin();
       sl = lower_bound(s.begin() , s.end() , x) - s.begin();
       sr = upper_bound(s.begin() , s.end() , x) - s.begin();
       if(tr == b) tr = inf;
       else tr = t[tr];
       if(sr == a) sr = inf;
       else sr = s[sr];
       if(tl == 0 && t[tl] > x ) tl = -inf;
       else{
             
              tl = t[tl-1];
       }
       if(sl == 0 && s[sl] > x ) sl = -inf;
       else{
             
              sl = s[sl-1];
           
       }
       // cout << x<<endl;
       // cout << sl << " " << sr << endl;
       // cout << tl << " " << tr << endl;
      
       ans = min(abs(max(tr , sr) - x) , abs(x - min(tl , sl)));
       ans = min(ans , 2*(tr - x) + (x - sl));
       ans = min(ans , 2*(x - sl) + (tr - x));
       ans = min(ans , 2*(sr - x) + (x - tl));
       ans = min(ans , 2*(x - tl) + (sr - x));

      cout << ans << endl;
       // cout << endl;
   }
 }


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

#define INF 1e9
using namespace std;

int main() {

    string S, T; cin >> S >> T;

    int ok = false;
    string temp = S;
    for (int i = 0; i < S.size(); ++i) {
        temp = temp[temp.size()-1] + temp.substr(0, temp.size()-1);
        if (temp == T) {
            ok = true;
        }
    }

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		long x = scanner.nextLong();
		long a = scanner.nextLong();
		long b = scanner.nextLong();
		if (b <= a) {
			System.out.println("delicious");
		} else if (b -a <= x) {
			System.out.println("safe");
		} else {
			System.out.println("dangerous");
		}
		scanner.close();
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    
    if(a+b>=k){
        ll ans = min(a,k);
        cout<<ans<<endl;
        return 0;
        }
    else{
        ll ans = a;
        ans-=k-a-b;
        cout<<ans<<endl;
    }
    
    
}


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

int main(){
    ll n,a,b,c,d,e;
    cin>>n>>a>>b>>c>>d>>e;
    ll m=min(a,min(b,min(c,min(d,e))));
    cout<<5+n/m-(n%m==0)<<endl;
    return 0;
}

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

#define ll long long
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define forn(i,n) for(ll i=0; i<(n); i++)
#define fori(i,k,n) for(ll i=k; i<(n); i++) 
#define all(x) (x).begin(),(x).end()
#define en '\n'
#define FILL(x,v) memset(x,v,sizeof(x))
#define pb push_back

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
 
template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
 
template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}
const int INF = 1e9 + 5;

void solve(){
	int n;
	cin >> n;
	vi a(n);
	for(auto &it: a){
		cin >> it;
	}
	vi dp(n, INF);
	// min jumps
	dp[0] = 0;
	forn(i,n){
		for(int j: {i+1, i+2}){
			if(j < n){
				dp[j]=min(dp[j], dp[i]+abs(a[i] - a[j]));
			}
		}
	}
	cout << dp[n-1] << en;
	// int l = 0
	// while(l<n - 1){
	// 	// int k = min(a[l+1], a[l+2])
	// 	int j = abs(a[l+1] - a[l]);
	// 	int k = abs(a[l+2] - a[l]);
	// 	if(j<k) {

	// 	}else {

	// 	}
	// }
}

int main(){
    ios::sync_with_stdio(0);
	cin.tie(0);
    cout.tie(0);
 
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
    int t = 1;
	// cin >> t;
    while(t--)
        solve();
    return 0;
}

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

    int main(){
    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;
    if(e-a<=k){
    cout<<"Yay!";
}   else if(e-a>k){
    cout<<":(";
}  return 0 ;
    }

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,sum;
  cin >> n ;
  vector<int> v(n);
  vector<int> c(n);
  for(int i = 0; i < n ; i++){
    cin >> v.at(i);
  }
    for(int i = 0; i < n ; i++){
    cin >> c.at(i);
  }
  for(int i = 0 ; i< n ; i++){
    if( v.at(i) > c.at(i)){
      sum += v.at(i) - c.at(i);
    }
  }
  cout << sum << endl;
}

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

int main() {
    int A, B;
    cin >> A >> B;
    if (A%3 == 0 || B%3 == 0 || (A + B)%3 == 0){
        cout << "Possible" << endl;
    }
    else{
        cout << "Impossible" << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ff first
#define ss second
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  char s[100001];
  scanf("%s", s);
  int l = strlen(s);
  for (int i = 0; i < l; i += 2) {
    printf("%c", s[i]);
  }
  printf("\n");
}

int main() {
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

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

int main() {
    long long a, b, x;
    cin >> a >> b >> x;
    if (a!=0) {
      for (int i=1; i<=b/x; i++) {
          if (a<=i*x && i*x<=b) {
              a=i*x;
              break;
          }
      }
    }
    if (a%x!=0) {
        cout << "0\n";
        return 0;
    }
    cout << 1+(b-a)/x << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
#define NM 1000000
#define QM 50000
#define NOT_FOUND -1

int binarySearch(int *A,int key,int length){
  
  int mid,left = 0,right = length;
  
  while(left < right){
    mid = (left + right)/2;
    if(key == A[mid]) return mid;
    if(key > A[mid]) left = mid +1;
    else if(key < A[mid]) right = mid;
  }
  return NOT_FOUND;
}
  

int main(){

  int i,j,count=0,x,y,A[NM],B[QM],k;

  scanf("%d",&x);

  for(i=0;i<x;i++) scanf("%d",&A[i]);

  scanf("%d",&y);

  for(i=0;i<y;i++) scanf("%d",&B[i]);

  for(i=0;i<y;i++){

    k = binarySearch(A,B[i],x);
    if(k >= 0) count++;

  }
    

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

  return 0;
}



Measured memory_bytes: 2328
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    a, b, k = input_nums()
    cnt = 0
    for i in reversed(range(1, min(a, b)+1)):
        if a%i == 0 and b%i == 0:
            cnt += 1
        if cnt == k: break
    print(i)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v
#define NUM(x,v) (POSU(x,v)-POSL(x,v))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
const ll INF=1e9+7;
const ll N = 200003;
ll n,a;
set <ll> d;
int main(){
	cin>>n;
	FOR(i,0,n){
		cin>>a;
		d.insert(a);
	}
	cout<<d.size()<<endl;
	return 0;
}

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

int main(){
  int a, b, c, d; cin >> a >> b >> c >> d;
  if(abs(a-c)<=d || (abs(b-a)<=d && abs(c-b)<=d)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

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

a, b, c = map(int, input().split())
m = max(a, b, c)

if (3*m-(a+b+c))%2 == 0:
    print((3*m-(a+b+c))//2)
else:
    print((3*(m+1)-(a+b+c))//2)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <class T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

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

    string L;
    cin >> L;
    int len = L.length();

    vector<vector<ll>> dp(len + 2, vector<ll>(2));
    dp[0][1] = 1;
    for (int i = 0; i <= len; ++i) {
        bool n = L[i] - '0';
        dp[i + 1][1] = (dp[i][1] * (n + 1)) % MOD;
        dp[i + 1][0] = (dp[i][0] * 3 + dp[i][1] * n) % MOD;
    }

    cout << (dp[len][0] + dp[len][1]) % MOD << endl;
    return 0;
}


Measured memory_bytes: 5840
n,m = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
b = {}
b[0] = 1
sum=0
for i in range(0,n):
  sum += a[i]
  sum = sum%m
  if sum in b:
    ans += b[sum]
    b[sum] = b[sum]+1
  else:
    b[sum] = 1
print(ans)

Measured memory_bytes: 14228
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

const int mod = 1e+9 + 7;
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcd(long long a,long long b){return a*b / gcd(a,b) / gcd(a,b);}
int main()
{
	//ある箇所への最短経路を通るということは、その途中の経路もすべて最短距離で通過しなければならない
	int N,M;
	cin>>N>>M;
	vector<int> result(N,-1);
	vector<int> path(N);
	vector<vector<int>> way(N);
	for(int i=0; i<M; i++)
	{
		int _a,_b;
		cin>>_a>>_b;
		_a--;
		_b--;
		way[_a].push_back(_b);
		way[_b].push_back(_a);
	}
	queue<pair<int,int>> q;
	q.push(make_pair(0,0));
	result[0] = 0;
	while(!q.empty())
	{
		int pos = q.front().first;
		int depth = q.front().second;
		q.pop();
		for(int i=0; i<way[pos].size(); i++)
		{
			int next_pos = way[pos][i];
			int next_depth = depth + 1;

			if(result[next_pos] == -1 || result[next_pos] > next_depth)
			{
				q.push(make_pair(next_pos,next_depth));
				result[next_pos] = next_depth;
				path[next_pos] = pos + 1;
			}
		}
	}
	if(*min_element(path.begin(),path.end()))
	{
		cout<<"No"<<endl;
	}
	else
	{
		cout<<"Yes"<<endl;
		for(int i=1; i<path.size(); i++)
		{
			cout<<path[i]<<endl;
		}
	}

}

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

#define fio() ios_base::sync_with_stdio(false);\
cin.tie(NULL);
#define md 1000000007
#define mem(ar,avg) memset(ar,avg,sizeof(ar))
#define pb push_back

typedef long long int lli;
typedef float fl;


int main()
{
	fio();
	int t;
	//cin >> t;
	//while (t--)
	{
		lli n, d;
		cin >> n >> d;

		d *= d;

		pair<lli, lli> ar[n];

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

		lli ans = 0 ;
		lli dis ;

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

			dis = ( ar[i].first  ) * ( ar[i].first  ) +  ( ar[i].second ) * ( ar[i].second ) ;
			if (dis <= d ) ans ++;

		}
		cout << ans << endl;

	}

}

Measured memory_bytes: 6780
#include <iostream>
using namespace std;
int main() {
	int h, n;
	cin >> h >> n;
  	int con;
  	int a;
  	for(int i = 0; i<n ; i++){
		cin >> con;
      	a += con;
    }
  	if( a >= h ){
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
bool prime(ll n){
    if(n<=1) return false;
    else if(n==2 || n==3) return true;
    else if(n%2==0 || n%3==0) return false;
    for(ll i=5;i*i<=n;i+=6){
        if(n%i ==0 || n%(i+2)==0) return false;
    }
    return true;
}
int main() {
   ll n,a,b,k;
   cin>>n;
   for(ll i=n;i<=1000000;i++){
       if(prime(i)){ cout<<i;return 0;
       }
   }
    return 0;
    
}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, n, q, sn = 1, now, l, r, ans, t;
  scanf("%lld", &n);
  char s[n + 10], c;
  scanf("%s", s);
  scanf("%lld", &q);
  while(n > sn) sn <<= 1;
  bool seg[26][sn * 2], b;
  ll las[sn * 2];
  now = 1;
  for(i = 1; i < sn * 2; ++i) {
    if(i == now << 1) now = i;
    las[i] = sn / now * (i - now + 1) - 1;
  }
  for(i = 0; i < 26; ++i) for(j = 0; j < sn * 2; ++j) seg[i][j] = false;
  for(i = 0; i < n; ++i) seg[s[i] - 'a'][sn + i] = true;
  for(i = 0; i < 26; ++i) for(j = 0; j < sn; ++j) {
    now = sn + j;
    while(now & 1 && now != 1) now >>= 1, seg[i][now] = seg[i][now * 2] | seg[i][now * 2 + 1];
  }
  for(i = 0; i < q; ++i) {
    scanf("%lld", &t);
    if(t == 1) {
      scanf("%lld %c\n", &l, &c);
      l--;
      seg[s[l] - 'a'][sn + l] = false;
      now = (sn + l) >> 1;
      while(now) seg[s[l] - 'a'][now] = seg[s[l] - 'a'][now * 2] | seg[s[l] - 'a'][now * 2 + 1],  now >>= 1;
      s[l] = c;
      seg[s[l] - 'a'][sn + l] = true;
      now = (sn + l) >> 1;
      while(now) seg[s[l] - 'a'][now] = seg[s[l] - 'a'][now * 2] | seg[s[l] - 'a'][now * 2 + 1],  now >>= 1;
    } else {
      scanf("%lld%lld", &l, &r);
      l--, r--;
      ans = 0;
      for(j = 0; j < 26; ++j) {
        b = false;
        now = sn + l;
        while( 1 ) {
          while(!(now & 1)) now >>= 1;
          while(las[now]> r) now <<= 1;
          b = b | seg[j][now];
          if(las[now] == r) break;
          now++;
        }
        if(b) ans++;
      }
      printf("%lld\n", ans);
    }
  }
  return 0;
}

Measured memory_bytes: 35712
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
const int mod = 1000000007;
const int max_n = 200005;
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;
}

int main(){
    ll n;cin >> n;
    vpl v(n);
    rep(i,n){
        ll x,l;cin >> x >>l;
        v[i].fi=x+l;
        v[i].se=x-l;
    }
    sort(all(v));
    ll t=-INF;ll ans=0;
    rep(i,n){
        if(t<=v[i].se){
            ans++;
            t=v[i].fi;
        }
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 1792
#include<cstdio>

char str[100005];

int main(){
    bool flag = true;
    int r = 0;
    scanf("%s",str);
    for(int i=0;str[i];i++){
        if(str[i]=='d'){
            if(r)r=0;
            if(str[i+1]=='r'&&str[i+2]=='e'&&str[i+3]=='a'&&str[i+4]=='m'){
                r = 1;
                if(str[i+5]=='e'){
                    if(str[i+6]=='r'){
                        i+=4;
                    }else {
                        flag = false;break;
                    }
                }else {
                    i+=4;
                }
            }else {
                flag = false;
                break;
            }
        }else if(str[i]=='e'){
            if(str[i+1]=='r'){
                if(str[i+2]=='a'&&str[i+3]=='s'&&str[i+4]=='e'){
                    if(str[i+5]=='r'){
                        i += 5;
                    }else {
                        i += 4;
                    }
                }else if(r){
                    i += 1;
                }else {
                    flag = false;
                    break;
                }
            }else {
                flag = false;
                break;
            }
            r = 0;
        }else {
            flag = false;
            break;
        }
    }
    if(flag)
        puts("YES");
    else
        puts("NO");
    return 0;
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m, c;
    cin >> n >> m >> c;

    int b[1000];
    for (int i = 0; i < m; i++)
        cin >> b[i];
    
    int ans = 0;
    for (int i = 0; i < n; i++){
        int sum = 0;
        for (int j = 0; j < m; j++){
            int a;
            cin >> a;
            sum += a * b[j];
        }
        
        if (sum + c > 0)
            ans += 1;
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256