akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
// #define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vpiipi vector<piipi>
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
#define mod 1000000007
// #define mod 1000000009
// #define mod 163577857 
// #define mod 998244353
#define rep(i,n) for (int i = 0; i < n; i++)
#define repp(i,a,b) for(int i = a ; i<b ; i++)
#define reppr(i,a,b) for(int i = a-1 ; i>=b ; i--)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()
 
//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    int fact[500010], factinv[500010] , coefficientflag = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,500010)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!coefficientflag) coefficientflag = 1 , Util_nCr();             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

void solve();
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t; 
    rep(i,t)
    {
        // cout << "Case #" << i+1 << ": ";
        solve();
    }
}

int grid[20][20] = {};

void solve() 
{
    int n , m;
    cin >> n >> m;
    int hell[n] = {} , qty[n] = {};
    rep(i,n)
        qty[i] = 1;
    hell[0] = 1;
    rep(i,m)
    {
        int u , v;
        cin >> u >> v;
        u--,v--;
        if(qty[u]==1)
        {
            if(hell[u])
                hell[v] = 1 , hell[u] = 0;
            qty[u] = 0;
            qty[v]++;
        }
        else if(hell[u])
        {
            hell[v] = 1;
            qty[u]--;
            qty[v]++;
        }
        else
        {
            qty[u]--;
            qty[v]++;
        }
    }
    int ans = 0;
    rep(i,n) if(hell[i]) ans++;
    cout << ans << endl;
}  

Measured memory_bytes: 5152
import java.util.Scanner;

public class Main {

	
	
	public static void main(String args[]){
		
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		
		if(a < b && b < c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		
	}
}



Measured memory_bytes: 26152
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a=Integer.parseInt(sc.next());
int b=Integer.parseInt(sc.next());
int c=Integer.parseInt(sc.next());
   int[] vec=new int[3];
   vec[0]=a;vec[1]=b;vec[2]=c;
   Arrays.sort(vec);
   System.out.println(vec[0]+" "+vec[1]+" "+vec[2]);
           }
}




Measured memory_bytes: 26140
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
# define mp make_pair
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n;
    ll ans = 0;
    fi>>n;
    static int s[1 << 20];
    for (int i = 1;i <= n;++i)
        fi>>s[i];
    int k = 1;
    for (int i = 1;i <= n;++i)
    {
        if (s[i] < k) continue;
        if (s[i] == k) ++k;
        ans += (s[i] - 1) / k;
        if (k == 1) ++k;
    }
    fo << ans << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}

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

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

const long long INF = 1LL << 60;

int main(){
  ll a, b, x;
  cin >> a >> b >> x;
  
  if(a == 0){
    cout << b/x + 1 << endl;
  }else{
    cout << b/x - (a-1)/x << endl;
  }

  return 0;
}


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

#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

int k[11];
int s[11][11]; // s[i][j]
int p[11];
bool sw[11];
int n, m;

bool all_ok() {
    REPE(i, 1, m) {
        int on_count = 0;
        REPE(j, 1, k[i]) {
            if (sw[s[i][j]])
                on_count++;
        }
        if ((on_count % 2) != p[i])
            return false;
    }
    return true;
}

lli rec(int done_count) {
    // 最後まで行ったら判定
    if (done_count == n) {
        if (all_ok())
            return 1;
        else
            return 0;
    }
    lli ans = 0;
    int ind = done_count+1;

    // スイッチ use_index を on にする
    sw[ind] = true;
    ans += rec(ind);

    // スイッチ use_index を off にする
    sw[ind] = false;
    ans += rec(ind);

    return ans;
}

int main() {
    cin >> n >> m;
    REPE(i, 1, m) {
        cin >> k[i];
        REPE(j, 1, k[i]) {
            cin >> s[i][j];
        }
    }
    REPE(i, 1, m) {
        cin >> p[i];
    }


    lli ans = 0;
    ans = rec(0);
    cout << ans << endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2e5+5;
const int mod=1e9+7;
ll n,x,y,a[maxn],s;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>x>>y;
    for(int i=1;i<n;i++)
        for(int j=i+1;j<=n;j++){
            s=min((ll)(j-i),abs(x-i)+abs(y-j)+(ll)1);
            a[s]++;
        }
    for(int i=1;i<n;i++) cout<<a[i]<<endl;
    return 0;
}

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

#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

typedef long long ll;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;

void solve()
{
  string s;cin>>s;
  int k; cin>>k;
  int n = SZ(s);

  vector<string> d;
  for (int i=0; i<k; i++) {
    for (int j=0; j<n-i; j++) {
      d.push_back(s.substr(j, i+1));
    }
  }
  SORT(d);
  UNIQUE(d);
  cout << d[k-1] << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <map>
#define rep(i, n) for(int i=0; i<n; i++)

#define MAX 100000

using namespace std;

int main(void){
  int N;
  cin >> N;
  int A[N];
  rep(i, N)
    cin >> A[i];
  //入力終わり

  //各数字が何回出てきたか
  int count[MAX+1];
  rep(i, MAX+1)
    count[i] = 0;

  //数字のカウント
  rep(i, N)
    count[ A[i] ]++;

  //2回以上出てくる数字を左と右から内側に向かって見ていく
  int l = 1, r = 100000;
  //0回または1回登場する数字を飛ばす
  while(count[l]<2){
    l++;
    //無限ループ回避
    if(l > MAX){
      //全部同じ数字なので1種類
      cout << N << endl;
      return 0;
    }
  }
  while(count[r]<2)
    r--;
  
  //登場回数が1になるまで左右から消していく
  while(l < r){
    
    while(count[l]<2)
      l++;
    while(count[r]<2)
      r--;

    //問題の操作を実行
    count[l]--; count[r]--;

    //登場回数が1か0なら1つ右にずらす
    if(count[l] < 2)
      l++;
    //登場回数が1か0なら1つ左にずらす
    if(count[r] < 2)
      r--;
  }

  //最後に残った場所は登場回数が2以上の可能性がある
  //同じ数字を選べば2つずつ消していけることを利用
  //偶数のときもこれで処理できる(厳密には違う)
  count[l] = count[l]%2;
  
  //登場回数の和をとっていく
  int ans = 0;
  rep(i, MAX+1)
    if(count[i] == 1)
      ans += 1;

  //解答
  cout << ans << endl;
  
  return 0;
}


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

#define pb push_back
#define se second
#define fi first

using namespace std;

typedef long long ll;

ll n, ans, a[(int)3e5];

int main(){
    cin >> n;
    for(ll i = 1; i <= n; i++)
        ans += i;
    cout << ans - n;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)

	dp := make([][]int, n+1)
	for i := 0; i < n+1; i++ {
		dp[i] = make([]int, n+1)
	}

	ans := 0
	for i := n - 1; i >= 0; i-- {
		for j := n - 1; j >= 0; j-- {
			if s[i] == s[j] {
				l := dp[i+1][j+1] + 1
				dp[i][j] = l
				ans = max(ans, min(l, j-i))
			}
		}
	}

	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


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

int main() {
    int W, H, N;
    cin >> W >> H >> N;

    vector<int> x(N), y(N), a(N);
    rep(i, N) {
        cin >> x.at(i);
        cin >> y.at(i);
        cin >> a.at(i);
    }

    // メモ
    // 最終な、左下(b, c), 右上(d, f)が分かればよい
    // a=1 -> minXを更新 a=2 -> maxXを更新
    // a=3 -> minYを更新 a=4 -> maxYを更新

    int minX = 0, minY = 0, maxX = W, maxY = H;

    rep(i, N) {
        switch (a.at(i)) {
            case 1:
                minX = max(minX, x.at(i));
                break;

            case 2:
                maxX = min(maxX, x.at(i));
                break;

            case 3:
                minY = max(minY, y.at(i));
                break;

            case 4:
                maxY = min(maxY, y.at(i));
                break;
        }
    }

    if ((maxX - minX) > 0 && (maxY - minY) > 0) {
        cout << (maxX - minX) * (maxY - minY) << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n;
	cin>>n;
	deque<int>ans;
	for(int i=1,tmp;i<=n;++i){
		cin>>tmp;
		if(i&1)ans.emplace_back(tmp);
		else ans.emplace_front(tmp);
	}
	if(n&1)reverse(ans.begin(),ans.end());
	for(auto i=ans.begin();i!=ans.end();++i){
		cout<<*i;
		if(i+1!=ans.end())cout<<" "s;
		else cout<<"\n"s;
	}
}

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

using namespace std;

int main(){
  int n; cin >> n;
  vector<tuple<string,int,int>> a;
  for(int i=0;i<n;i++){
    string s;
    int p;
    cin >> s >> p;
    a.push_back(make_tuple(s,100-p,i+1));
  }
  sort(a.begin(),a.end());
  for(tuple<string,int,int> t :a){
    string x;
    int y,z;
    tie(x,y,z)=t;
    cout << z << endl;
  }
}


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

int main(){
    int h,n; cin>>h>>n;
    int at = 0;
    for(int i=0; i<n; i++){
        int a; cin >> a;
        at += a;
    }
    cout << (at>=h?"Yes":"No") << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		sc.close();
		long yono = 1;
		for(int i = 2 ; i <= n ; i++){
			yono *= i;
			yono %= (int)Math.pow(10 , 9) + 7;
		}
		ou.println(yono);
		ou.flush();
	}
}

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

int main() {
    int n;
    pair<int,int> a[100001];
    cin >> n;
    for(int i = 1; i <= n; i++){
        a[i].first = i;
        cin >> a[i].second;
    }
    int now = 1;
    int count = 0;
    while(count < n){
        count++;
        if(a[now].second == 2){
            cout << count << endl;
            return 0;
        }
        now = a[now].second;
    }
    cout << -1 << endl;
}

Measured memory_bytes: 1024
#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;
typedef pair<int,int> P;
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);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){


    ll n,m;
    cin>>n>>m;
    vector<ll> v[n+1];
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }

    vector<bool> f(n+1,false);
    vector<ll> ans(n+1,0);
    f[0]=true;
    queue<ll> q;
    q.push(0);

    while(!q.empty()){
        int qsize = q.size();

        rep(i,qsize){
            ll t = q.front();q.pop();
            for(int j=0;j<v[t].size();j++){
                ll vt=v[t][j];
                if(!f[vt]){
                    q.push(vt);
                    f[vt] = true;
                    ans[vt] = t;
                }
            }
        }

    }

    rep(i,n){
        if(!f[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    rep(i,n-1){
        cout<<ans[i+1]+1<<endl;
    }







return 0;
}


Measured memory_bytes: 12904
#include<cstdio>
#include<algorithm>

using namespace std;

typedef long long ll;

int n;
ll a, b, h[100000];

int check(ll c){
	ll res = 0;
	for(int i = 0; i < n; i++){
		ll x = h[i] - b * c, y = a - b;
		res += max(0LL, (x + y - 1) / y);
	}
	return res <= c;
}

int main(){
	scanf("%d %lld %lld", &n, &a, &b);
	for(int i = 0; i < n; i++) scanf("%lld", &h[i]);
	ll l = 0, r = 1000000000;
	while(r - l > 1){
		ll c = (l + r) / 2;
		if(check(c)) r = c;
		else l = c;
	}
	printf("%lld\n", r);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  string S;
  cin >> N >> S;
  int cnt = 0;
  ll ans = 1;
  rep(i, 2*N) {
    if(S[i] == 'B') {
      if(cnt%2) {
        if(cnt == 0) {
          ans = 0;
          break;
        }
        (ans *= cnt) %= mod;
        cnt--;
      } else {
        ans *= 1;
        cnt++;
      }
    } else {
      if(cnt%2) {
        ans *= 1;
        cnt++;
      } else {
        if(cnt == 0) {
          ans = 0;
          break;
        }
        (ans *= cnt) %= mod;
        cnt--;
      }
    }
  }
  function<ll(ll)> fact = [&](ll n) {
    if(n == 0) return 1LL;
    else return (n * fact(n-1)) % mod;
  };
  if(cnt) cout << 0 << endl;
  else cout << (ans * fact(N)) % mod << endl;
  return 0;
}


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

int main(){
    int ans = 0, n;
    cin >> n;
    map<string, int> mp;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        mp[s]++;
    }
    for(auto p = mp.begin(); p != mp.end(); p++){
        if(p->second > 0){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 19256
#ABC086-C
n = int(input())
grid = []
for _ in range(n):
    t,x,y = map(int,input().split())
    grid.append([t,x,y])

def distance(x1,y1,x2,y2):
    return (abs(x2 - x1) + abs(y2 - y1))

now = [0,0,0]
flg = True
for i in range(n):
    next = grid[i]
    time = next[0] - now[0]
    if time >= distance(now[1],now[2],next[1],next[2]) and (time - distance(now[1],now[2],next[1],next[2])) % 2 == 0:
        now = next
    else:
        flg = False
        break
        
if flg:
    print('Yes')
else:
    print('No')
            


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

#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i,a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

template<class T>
struct ModInt {
    T x;
    ModInt(T x = 0) :x((x + mod) % mod) {}
    ModInt& operator+=(const ModInt a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(const ModInt a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator*=(const ModInt a) {
        (x *= a.x) %= mod;
        return *this;
    }
    ModInt operator+(const ModInt a) const {
        ModInt res(*this);
        return res += a;
    }
    ModInt operator-(const ModInt a) const {
        ModInt res(*this);
        return res -= a;
    }
    ModInt operator*(const ModInt a) const {
        ModInt res(*this);
        return res *= a;
    }
    ModInt pow(T t) const {
        if (!t) return 1;
        ModInt a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    ModInt inv() const {
        return pow(mod - 2);
    }
    ModInt& operator/=(const ModInt a) {
        return (*this) *= a.inv();
    }
    ModInt operator/(const ModInt a) const {
        ModInt res(*this);
        return res /= a;
    }
};
using mint = ModInt<long long>;

int n;
int a[23][23];
mint dp[23][(1 << 21) + 3];
void solve() {
    cin >> n;
    rep(i, n) rep(j, n) cin >> a[i][j];

    dp[0][0] = 1;
    rep(i, n) rep(s, 1 << n) {
        if (dp[i][s].x == 0) continue;
        rep(j, n) {
            if (((s >> j) & 1) == 0 && a[i][j] == 1) {
                dp[i + 1][s | 1 << j] += dp[i][s];
            }
        }
    }
    cout << dp[n][(1 << n) - 1].x << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 377088
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-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; }

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll cur = 1000;
    rep(i, n-1) {
        ll t = 0;
        if (a[i] < a[i+1]) t = cur / a[i];
        cur += (a[i+1] - a[i]) * t;
    }
    cout << cur << endl;
}


Measured memory_bytes: 3580
// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
typedef vector<int> vi;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int maxn=1111;
const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};
const char dir[]="LRDU";

int n;
LL x[maxn],y[maxn];

void construct(int lvl,LL x,LL y)
{
	if(lvl<0)return;
	LL len=1ll<<lvl;
	for(int d=0;d<4;d++)
	{
		LL nx=x+dx[d]*len,ny=y+dy[d]*len;
		if(abs(nx)+abs(ny)<len)
		{
			construct(lvl-1,nx,ny);
			putchar(dir[d]);
			return;
		}
	}
}

int main()
{
	get1(n);for(int i=1;i<=n;i++)get2(x[i],y[i]);
	for(int i=1;i<=n;i++)if((x[i]+y[i]-x[1]-y[1])%2)
	{
		puts("-1");
		return 0;
	}
	
	if((x[1]+y[1])%2!=0)
	{
		puts("40");
		for(int i=0;i<40;i++)printf("%lld ",1ll<<i);puts("");
		for(int i=1;i<=n;i++)
		{
			construct(39,x[i],y[i]);
			puts("");
		}
	}
	else
	{
		puts("40");
		printf("1 ");for(int i=0;i<39;i++)printf("%lld ",1ll<<i);puts("");
		for(int i=1;i<=n;i++)
		{
			putchar('L');construct(38,x[i]+1,y[i]);
			puts("");
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF=1LL<<60;
const int MAXN=1005;
int n, m, S1, S2, T;
char s[100];
struct edge{
    int to;
    long long w;
    bool type;
    edge(int to=0, long long w=0, bool type=false):to(to),w(w),type(type) {}
};
vector<edge> G[MAXN];
long long dist[MAXN][MAXN];
priority_queue< pair<long long, pair<int, int> > > q;
pair<long long, pair<int, int> > now;
vector<long long> ans;
long long cross(long long a1, long long b1, long long a2, long long b2){
    if(a1==INF||a2==INF) return 0;
    return floor((a1-a2+1.0)/(b2-b1));
}
long long calc(long long dp[MAXN], int k, long long x){
    long long ret=INF;
    for(int i=0; i<=k; i++){
        ret=min(ret,dp[i]+x*i);
    }
    return ret;
}
int main(){
    while(~scanf("%d%d%d%d%d",&n,&m,&S1,&S2,&T)&&n){
        for(int i=1; i<=n; i++){
            G[i].clear();
        }
        int k=0;
        for(int i=0, x, y, z; i<m; i++){
            scanf("%d%d%s",&x,&y,s);
            if(s[0]=='x'){
                G[x].push_back(edge(y,0,1));
                G[y].push_back(edge(x,0,1));
                k++;
            }
            else{
                sscanf(s,"%d",&z);
                G[x].push_back(edge(y,z,0));
                G[y].push_back(edge(x,z,0));
            }
        }
        for(int i=1; i<=n; i++){
            for(int j=0; j<=k; j++){
                dist[i][j]=INF;
            }
        }
        dist[T][0]=0;
        while(!q.empty()) q.pop();
        q.push(make_pair(0LL,make_pair(T,0)));
        while(!q.empty()){
            now=q.top(); q.pop();
            int u=now.second.first, cnt=now.second.second;
            long long d=dist[u][cnt];
            if(-now.first>d) continue;
            for(auto p: G[u]){
                int ncnt=cnt+p.type, nidx=p.to;
                long long ndist=d+p.w;
                if(ncnt<=k&&ndist<dist[nidx][ncnt]){
                    dist[nidx][ncnt]=ndist;
                    q.push(make_pair(-ndist,make_pair(nidx,ncnt)));
                }
            }
        }
        ans.clear();
        ans.push_back(0LL);
        for(int i=0; i<=k; i++){
            for(int j=0; j<=k; j++) if(i!=j){
                long long x1, x2, x3;
                x1=cross(dist[S1][i],i,dist[S2][j],j);
                x2=cross(dist[S1][i],i,dist[S1][j],j);
                x3=cross(dist[S2][i],i,dist[S2][j],j);
                for(int d=-1; d<=1; d++){
                    ans.push_back(x1+d);
                    ans.push_back(x2+d);
                    ans.push_back(x3+d);
                }
            }
        }
        sort(ans.begin(),ans.end());
        ans.erase(unique(ans.begin(),ans.end()),ans.end());
        long long ret=INF;
        for(auto p: ans){
            if(p>=0){
                ret=min(ret,abs(calc(dist[S1],k,p)-calc(dist[S2],k,p)));
            }
        }
        printf("%lld\n",ret);
    }
    return 0;
}

Measured memory_bytes: 10236
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

const double PI = acos(-1);
constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class Task{
public:
    void solve(istream& in, ostream& out){
        lint A;
        string B;
        in>>A>>B;
        lint BB = (B[0]-'0') * 100 + (B[2]-'0') * 10 + (B[3]-'0');
        out<<A*BB/100<<'\n';
    }
};

int main(){
    istream& in(cin);
    ostream& out(cout);
    ios_base::sync_with_stdio(false);
    in.tie(nullptr), out.tie(nullptr);
    Task solver;
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = k; i < n; i++)
    {
        if(a[i-k] < a[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 4052
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    int n;
    cin>>n;
    vector<int> a(int(1e6)+10,0);
    vector<bool> b(a.size(),true);
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        a[x]++;
    }
    for(int i=1;i<b.size();i++){
        if(a[i]>0){
            int j=2;
            while(1ll*j*i<b.size()){
                b[i*j]=false;
                j++;
            }
        }
    }
    int ans=0;
    for(int i=1;i<a.size();i++){
        if(a[i]==1 && b[i]){
            ans++;
        }
    }
    cout<<ans<<"\n";
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS(N) resize(N)
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

int N;
vector<int> v;

void init()
{
	cin >> N;
	string s;
	cin >> s;
	cin >> s;
	v.PB(1);
	reps(i, 1, N) {
		if (s[i] != s[i-1]) v.PB(1);
		else v.back()++;
	}
}

int culc(int pos)
{
	if (v[pos-1] == 1) {
		return 2;
	} else {
		if (v[pos] == 1) return 1;
		else return 3;
	}
}

void solve()
{
	ll res = 3 * v[0];
	reps(i, 1, v.size()) {
		res *= culc(i);
		res %= MOD;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
h = []
for i in range(n):
    a = int(input())
    h.append(a)
h.sort()
ans=10**10
for i in range(n-k+1):
    dif = abs(h[i]-h[i+k-1])
    if dif<ans: ans=dif
print(ans)


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

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

	long N;
	cin >> N;

	long A[N];
	long long t = 0;;
	for (long i = 0; i < N; i++) {
		cin >> A[i];
		t += A[i];
	}

	long long a2 = 0;
	for (long long i = 1; i < N; i+=2)
		a2 += A[i];

	long ans[N];
	ans[0] = t - 2 * a2;

	for (long long i = 1; i < N; i++)
		ans[i] = 2 * A[i-1] - ans[i-1];

	for (long i = 0; i < N-1; i++)
		cout << ans[i] << " ";

	cout << ans[N-1] << endl;

	return 0;
}


Measured memory_bytes: 2944
import string

dic = {i: c for i, c in enumerate(string.ascii_uppercase)}
dic_inv = {c: i for i, c in enumerate(string.ascii_uppercase)}
length = len(string.ascii_uppercase)

n = int(input())
s = input()

s_new = [dic[(dic_inv[c] + n) % length] for c in s]
print(''.join(s_new))


Measured memory_bytes: 3956
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Solve is
   A : Integer;
   B : Integer;
begin
   Get (A);
   Get (B);
   if A = B then
      Put_Line ("Draw");
   elsif A = 1 then
      Put_Line ("Alice");
   elsif B = 1 then
      Put_Line ("Bob");
   elsif A > B then
      Put_Line ("Alice");
   else
      Put_Line ("Bob");
   end if;
end Solve;

Measured memory_bytes: 3676
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int a[3],k;
	cin >> a[0] >> a[1] >> a[2] >> k;
	int max=0,maxarr;
	for(int i=0;i<3;i++)
	{
		if(max <= a[i])
		{
			max = a[i];
			maxarr = i;
		}
	}
	int sum = 0;
	for(int j = 0;j<3;j++)
	{
		if(j == maxarr)
		{
			sum = sum + a[j]*pow(2,k);
		}
		
		else
		{
			sum = sum + a[j];
		}	
	}
	
	cout << sum;
	return 0;
}


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

int main(){
  string s;cin>>s;
  int n=s.size();
  bool vary=true;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(s[i]==s[j])vary=false;
    }
  }
  cout<<(vary?"yes":"no")<<endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
musics = []
for _ in range(N):
  s, t = input().split()
  musics.append([s, int(t)])
x = input()
passed = False
ans = 0
for i in range(N):
  if passed: ans += musics[i][1]
  if x == musics[i][0]: passed = True
print(ans)

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

typedef long long ll;

ll N, K;
ll a[(int)1e5], b[(int)1e5];

int main() {
    cin >> N >> K;
    rep(i, N) cin >> a[i] >> b[i];

    map<ll, ll> mp;
    rep(i, N) {
        mp[a[i]] += b[i];
    }

    ll tmp = 0;
    // for (auto iter = mp.begin(); iter != mp.end(); iter++) {
    //     tmp += iter->second;
    //     if (tmp >= K) {
    //         // cout << iter->first << endl;
    //         printf("%lld\n", iter->first);
    //         break;
    //     }
    //     // printf("%lld %lld\n", iter->first, iter->second);
    // }

    for (ll i = 1; i <= 1e5; i++) {
        tmp += mp[i];
        if (tmp >= K) {
            printf("%lld\n", i);
            return 0;
        }
    }
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
//#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll a[2];rep(i,0,1)cin>>a[i];
    ll b[2];rep(i,0,1)cin>>b[i];
    ll t;cin>>t;
    if(abs(a[0]-b[0])>(a[1]-b[1])*t){
        cout<<"NO"<<endl;
    }else{
        cout<<"YES"<<endl;
    }
    
    return 0;
}





Measured memory_bytes: 3652
# include <bits/stdc++.h>
using namespace std ;
bool is_war ( const vector <int >& x , const vector <int >& y ) {
for ( int Z = -100; Z <= 100; ++ Z ) {
bool is_ok = true ;
for ( int i = 0; i < x . size (); ++ i ) {
if ( x [ i ] >= Z ) is_ok = false ;
}
for ( int i = 0; i < y . size (); ++ i ) {
if ( y [ i ] < Z ) is_ok = false ;
}
if ( is_ok ) return false ;
}
return true ;
}
int main () {
int N , M ; cin >> N >> M ;
vector <int > x ( N +1) , y ( M +1);
cin >> x [0] >> y [0];
for ( int i = 0; i < N ; ++ i ) {
cin >> x [ i +1];
}
for ( int i = 0; i < M ; ++ i ) {
cin >> y [ i +1];
}
if ( is_war (x , y )) {
cout << " War " << endl ;
}
else {
cout << "No War " << endl ;
}
}


Measured memory_bytes: 3592
S = input()
lenS = len(S)
count = [0] * 2019
count[0] = 1
num = 0
d = 1
for i in range(lenS):
    num += int(S[lenS - i - 1]) * d
    count[num%2019] += 1
    d *= 10
    d %= 2019
ans = 0
for i in count:
    ans += i*(i-1)//2
print(ans)


Measured memory_bytes: 9128
#include <stdio.h>
#include<algorithm>
using namespace std;
int main(){
int N,s=0,i,a[100000],j=0;
scanf("%d",&N);
for(i=0;i<N;i++){
scanf("%d",&a[i]);}
sort(a,a+i);
i=0;

while(i<N){
while(a[i]==a[i+1]){i++,j++;}
if(j%2==0){s++;}
j=0;
i++;}
printf("%d",s);

return 0;}

Measured memory_bytes: 512
#include <iostream>
#include <cstdint>
using namespace std;
int main() {
  uint64_t n, a, b;
  cin >> n >> a >> b;
  uint64_t ans = (n/(a+b))*a + ((n % (a+b) >= a) ? a : n%(a+b));
  cout << ans << endl;
  return 0;
}

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

int digits(int N, int X){
    int digit_cnt=0;
    while(N>0){
        int Y=N/X;
        if(Y>=0){
            digit_cnt+=1;
            N=Y;
        }
    }
    return digit_cnt;
}

int main(){
    int n,k; cin >> n >> k;
    cout << digits(n,k) << endl;
}

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

const int MAX = 100010;
int n, m;
int a1[MAX];
int a2[MAX];

bool binSearch(int a[], int lo, int hi, int x) {
    while (lo < hi) {
        int mi = (lo + hi) >> 1;
        if (a[mi] == x) {
            return true;
        } else if (a[mi] < x) {
            lo = mi + 1;
        } else {
            hi = mi;
        }
    }
    return false;
}

int main() {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &a1[i]);
    scanf("%d", &m);
    for (int i = 0; i < m; i++) scanf("%d", &a2[i]);
    int ans = 0;
    for (int i = 0; i < m; i++) {
        if (binSearch(a1, 0, n, a2[i])) {
            ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3704
tate, yoko = map(int, input().split())
main = [input() for i in range(tate)] 

ans = []

for row in main: # rowの中身は文字列
    ans.append(list(row)) # listを使えば文字列を一文字づつ分けてlistにできる
    
dxy = [(-1,-1), (-1,0), (-1,1), (0,-1), (0,1), (1,-1), (1,0), (1,1)]

for y in range(tate):
    for x in range(yoko):
        if main[y][x] == "#": continue # 満たすときだけ次に進む、満たさない場合飛ばされて次のループに行く
        c = 0
        for dx,dy in dxy:
            if x + dx < 0 or x + dx > yoko - 1 or y + dy < 0 or y + dy > tate - 1: continue
            if main[y + dy][x + dx] == "#":
                    c += 1
        ans[y][x] = c
for row in ans:
    print("".join(list(map(str, row))))

Measured memory_bytes: 3064
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	static int w;
	static int h;
	static int[][] side_wall;
	static int[][] under_wall;
	static int[][] flag;
	static int[][] map;
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(true){
			w = scan.nextInt();
			h = scan.nextInt();
			if (w==0 && h==0) break;
			side_wall = new int[h][w];
			under_wall = new int[h][w];
			for(int j=0;j<h;++j){
				for(int i=0;i<w-1;++i){
					side_wall[j][i]=scan.nextInt();
				}
				side_wall[j][w-1]=1;
				if(j==h-1){
					for(int i=0;i<w-1;++i){
						under_wall[j][i]=1;
					}
					under_wall[j][w-1]=0;
				} else {
					for(int i=0;i<w;++i){
						under_wall[j][i]=scan.nextInt();
					}
				}
			}
			map = new int[h][w];
			Queue<Node> qu = new LinkedList<Node>();
			Node node = new Node(0,0);
			qu.add(node);
			map[0][0]=1;
			while(qu.isEmpty()!=true){
				Node cur = qu.poll();
				int x=cur.getx(),y=cur.gety();
				if(x==w-1&&y==h-1){
					break;
				}
				if(y-1>=0){
					if(under_wall[y-1][x]==0&&map[y-1][x]==0){
						qu.add(new Node(x,y-1));
						map[y-1][x]=map[y][x]+1;
					}
				}
				if(x-1>=0){
					if(side_wall[y][x-1]==0&&map[y][x-1]==0){
						qu.add(new Node(x-1,y));
						map[y][x-1]=map[y][x]+1;
					}
				}
				if(x+1<w){
					if(side_wall[y][x]==0&&map[y][x+1]==0){
						qu.add(new Node(x+1,y));
						map[y][x+1]=map[y][x]+1;
					}
				}
				if(y+1<h){
					if(under_wall[y][x]==0&&map[y+1][x]==0){
						qu.add(new Node(x,y+1));
						map[y+1][x]=map[y][x]+1;
					}
				}
			}
			System.out.println(map[h-1][w-1]);
		}
	}
}

class Node{
	private int x;
	private int y;
	Node(int x, int y){
		this.x=x;
		this.y=y;
	}
	public int getx(){
		return x;
	}
	public int gety(){
		return y;
	}
}



Measured memory_bytes: 69408
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        
        int N=sc.nextInt();
        int[] d=new int[N];
        for(int i=0;i<N;i++){
            d[i]=sc.nextInt();
        }
        Arrays.sort(d);
        int ans=1;
        for(int i=0;i<N-1;i++){
            if(d[i]<d[i+1]){
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 22740
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<map>
using namespace std;

typedef long long ll;
typedef short int sh;

const int inf=0x3f3f3f3f;
const int MAX=1<<20;
const int mod=1e9+7;
const int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{1,1},{1,-1},{-1,-1},{-1,1}};

ll n,m,k;

void Scan(map<pair<int,int>,ll>&mp)
{
    int xx,yy;
    pair<int,int>p;
    while(k--)
    {
        scanf("%d%d",&p.first,&p.second);
        mp[p]++;
        for(int i=0;i<8;i++)
        {
            xx=p.first+dir[i][0];
            yy=p.second+dir[i][1];
            if(xx>0&&xx<=n&&yy>0&&yy<=m)
            {
                pair<int,int> pp(xx,yy);
                mp[pp]++;
            }
        }
    }
}

void Get_Answer(map<pair<int,int>,ll>mp)
{
    ll sum=(n-2)*(m-2);
    ll ans[10]={0},t=0;
    map<pair<int,int>,ll>::iterator it;
    for(it=mp.begin();it!=mp.end();it++)
    {
        int x,y;
        x=it->first.first;
        y=it->first.second;
        if(x>1&&x<n&&y>1&&y<m)
        {
            ll v=it->second;
            ans[v]++;
            t++;
        }
    }
    ans[0]=sum-t;
    for(int i=0;i<10;i++)
        printf("%lld\n",ans[i]);
}

int main()
{
    while(scanf("%lld%lld%lld",&n,&m,&k)!=EOF)
    {
        map<pair<int,int>,ll>mp;
        Scan(mp);
        Get_Answer(mp);
    }
    return 0;
}


Measured memory_bytes: 115688
#include<bits/stdc++.h>
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const ll mod= 1e9+7;
const ll mod2=1271309838631957LL;
long double PI = acosl(-1);
const ll inf = 1e15;
const int nmax = 1e5+10;
const int MAXLG = log2(nmax)+1;


vector<int>g[nmax];
ll m;
ll dp[nmax];
ll dp2[nmax];

void dfs(int u, int p=0){
    dp[u]=1;
    for(int v: g[u]){
        if(p==v) continue;
        dfs(v, u);
        dp[u]*=((dp[v]+1)%m);
        dp[u]%=m;
    }
//    cout<<dp[u]<<" ++++++++++++ "<<u<<endl;
}

void dfs2(int u, int p=0){
    vector<ll>pre, suf;
    pre.push_back(1), suf.push_back(1);
    for(int v: g[u])
        if(v!=p) pre.push_back((dp[v]+1)%m ), suf.push_back((dp[v]+1)%m);

    pre.push_back(1), suf.push_back(1);

    for(int i=1; i<pre.size(); i++)
        pre[i]=(pre[i]*pre[i-1])%m;

    for(int i=suf.size()-2; i>=0; i--)
        suf[i]=(suf[i]*suf[i+1])%m;

//    if(p==0){
//        for(int v : pre) cout<<v<<" ";
//            cout<<endl;
//        for(int v : suf) cout<<v<<" ";
//            cout<<endl;
//    }

    for(int i=0, idx=0; i<g[u].size(); i++, idx++){
        int v=g[u][i];
        if(v==p){
            idx--;
            continue;
        }
        dp2[v] = (1 + (dp2[u]*( (pre[idx]*suf[idx+2])%m))%m )%m;
//        cout<<(pre[i]*suf[i+2])<<endl;
//        cout<<dp2[v]<<" == dp2 "<<v<<endl;
        dfs2(v, u);
    }
}



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

    int n;
    cin>>n>>m;

    for(int i=1; i<n; i++){
        int u,v;
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1);
    dp2[1]=1;
    dfs2(1);

    for(int i=1; i<=n; i++) cout<<(dp[i]*dp2[i])%m<<"\n";
}





Measured memory_bytes: 26368
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.nextInt();
            var b = cin.nextInt();
            var x = cin.nextInt();

            Console.WriteLine((a <= x && x <=a+b)? "YES":"NO");
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13140
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	mp := map[int]bool{}
	for i := 0; i < n; i++ {
		var v int
		fmt.Scan(&v)
		mp[v] = !mp[v]
	}
	sum := 0
	for _, v := range mp {
		if v {
			sum++
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 6912
#include<iostream>
using namespace std;
int data[20],n;

bool solve(int i,int m)
{
  if(i>n)
    return false;
  if(m-data[i]==0)
    return true;
  if(solve(i+1,m-data[i]))
    return true;
  if(solve(i+1,m))
    return true;
  
  return false;
}

int main()
{
  for(;cin>>n;)
    {
      for(int i=0;i<n;i++)
	  cin>>data[i];
      int q;
      cin>>q;
      for(int i=0;i<q;i++)
	{
	  int tmp;
	  cin>>tmp;
	  if(solve(0,tmp))
	    cout<<"yes"<<endl;
	  else
	    cout<<"no"<<endl;    
	}
    }
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int i,p[n],ans=0;
    for(i=0;i<n;i++) cin>>p[i];
    for(i=1;i<(n-1);i++){
            if(((p[i+1]>p[i]) && p[i-1]<p[i])||((p[i-1]>p[i])&&(p[i+1]<p[i]))) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define range(X) (1 <= X && X <=10000)

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

Measured memory_bytes: 596