akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <map>
#include <unordered_set>
#include <tuple>
#include <queue>
#include <set>
#include <cstring>
#include <functional>
#include <random>
#include <chrono>

#define ar array
#define all(arr) (arr).begin(), (arr).end()
#define range(i, n) for (int i=0; i < n; ++i)
#define rall(arr) (arr).rbegin(), (arr).rend()

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

const ll INF = 1e18;
const int INFi = 2e9;
const int maxN = 1e6 + 5;
const int md = 998244353;
const int md2 = 1e9 + 7;

double getTime() { return clock() / (double) CLOCKS_PER_SEC; };

struct dsu {
    vector<int> dsu{};

    void build(int k) {
        dsu.resize(k+1);
        range(i, k + 1) dsu[i] = i;
    }

    int get_dsu(int a) {
        if (dsu[a] == a) return a;
        return dsu[a] = get_dsu(dsu[a]);
    }

    void unio(int a, int b) {
        a = get_dsu(a), b = get_dsu(b);
        if (rand() % 2) swap(a, b);
        dsu[a] = b;
    }
};

void solve() {
    int n; cin >> n;
    vector<pair<pair<int, int>, int>> xy(n);
    range(i, n) cin >> xy[i].first.first >> xy[i].first.second;
    range(i, n) xy[i].second = i;
    sort(all(xy));
    vector<int> ind(n+1);
    range(i, n) ind[xy[i].first.second] = xy[i].second;
    set<int> s;
    dsu d; d.build(n);
    range(i, n) {
        vector<int> todel;
        for(auto &e: s) {
            if (e > xy[i].first.second) break;
            todel.push_back(e);
            d.unio(ind[e], xy[i].second);
        }
        for(int j = 1; j < (int)todel.size(); ++j){
            s.erase(todel[j]);
        }
        if (todel.empty()) {
            s.insert(xy[i].first.second);
        }
    }
    vector<int> cnt(n);
    range(i, n) cnt[d.get_dsu(i)]++;
    range(i, n) cout << cnt[d.get_dsu(i)] << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //cout << setprecision(15) << fixed;
    int tests = 1;
    //cin >> tests;
    range(_, tests) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 12836
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n;
    cin >> n;
    int a,b,c;
    cin >> a >> b >> c;
    vi d(n);
    rep(i,n)cin >> d[i];
    sort(all(d));
    reverse(all(d));
    rep(i,n){
        if(c*(a+b) < a*(c+d[i])){
            a += b;
            c += d[i];
        }
    }
    cout << c/a << endl;

}



Measured memory_bytes: 3148
#include<stdio.h>

int main(void){
  int a;
  scanf("%d", &a);
  
  int b[a];
  int i;
  for(i=0; i<a; i++){
  scanf("%d", &b[i]);
  }
  b[a] = 0;

  i = 0;
  int count =0;
  int count2 = 0;
  
  while(i<a){  
  for(; i<a; i++){
    if(b[i]>=b[i+1]||b[i+1]==0){
      break;
    }
  }
  
     count =0;
    
  for(; i<a; i++){
    if(b[i]<b[i+1] || b[i+1] == 0){
      if(count > count2){
      count2 = count;
      }
      break;
    }
       count++;
  }
     
    if(b[i+1] == 0){
      break;
    }
  }
  
  printf("%d\n", count2);
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if (a > b){
        puts("a > b");
    }else if (a == b){
        puts("a == b");
    }else {
        puts("a < b");
    }
    return 0;
}


Measured memory_bytes: 2124
#include <stdio.h>
int main(void){
  int a,b,i;
  if(scanf("%d%d",&a,&b)<2) return 1;
  if(a<b){
    for(i=0;i<b;i++){
      printf("%d",a);
    }
  }
  else{
    for(i=0;i<a;i++){
      printf("%d",b);
    }
  }
  printf("\n");
  return 0;
}

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

using namespace std;

int main()
{
    long N;
    cin >> N;
    string A;
    vector<string> v;

    for (long i = 0; i < N; i++)
    {
        cin >> A;
        v.push_back(A);
    }

    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    if (N - v.size() == 0)
    {
        cout << "YES";
    }

    else
    {
        cout << "NO";
    }
}

Measured memory_bytes: 13936
N = int(input())
A = input()
B = input()
C = input()
counter = 0
for i in range(N):
    if(A[i]==B[i]):
        if(B[i]==C[i]):
            continue
        else:
            counter+=1
    elif(A[i]==C[i]):
        if(B[i]==C[i]):
            continue
        else:
            counter+=1
    elif(B[i]==C[i]):
        if(A[i]==B[i]):
            continue
        else:
            counter+=1
    else:
        counter+=2

print(counter)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int N;
	cin >> N;

	vector<int> a_list(3 * N, 0);
	for (int i = 0; i < 3 * N; i++)
	{
		cin >> a_list[i];
	}

	sort(a_list.begin(), a_list.end());
	reverse(a_list.begin(), a_list.end());

	long long result = 0;
	for (int i = 1; i <= 2 * N; i += 2)
	{
		result += a_list[i];
	}

	cout << result;

	return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    int n,ma,mb;
    cin>>n>>ma>>mb;
    vvi cost(201,vi(201,100000));
    //後半のグループでAをiグラムBをjグラム買うときのコストの最小
    vector<pair<pair<int,int>,int>> vec;
    rep(i,n){
        int a,b,c;
        cin>>a>>b>>c;
        vec.push_back({{a,b},c});
    }
    if (n==1){
        if (vec[0].first.first*mb==vec[0].first.second*ma) cout<<vec[0].second<<endl;
        else cout<<-1<<endl;
        return 0;
    }
    int num=n/2;
    vector<pair<pair<int,int>,int>> vec1;
    for (int i=0;i<(1<<num);i++){
        int sa=0,sb=0,sc=0;
        bitset<20> s(i);
        rep(j,num){
            if (s.test(j)){
                sa+=vec[j].first.first;
                sb+=vec[j].first.second;
                sc+=vec[j].second;
            }
        }
        vec1.push_back({{sa,sb},sc});
    }
    int num2=n-num;
    for (int i=0;i<(1<<num2);i++){
        int sa=0,sb=0,sc=0;
        bitset<20> s(i);
        rep(j,num2){
            if (s.test(j)){
                sa+=vec[num+j].first.first;
                sb+=vec[num+j].first.second;
                sc+=vec[num+j].second;
            }
        }
        cost[sa][sb]=min(cost[sa][sb],sc);
    }
    int ans=1e9;
    for (auto p:vec1){
        int a=p.first.first;
        int c=p.first.second;
        int r=c%mb;
        int d;
        if (r==0)d=-mb;
        else d=-r;
        //cout<<(c+d)%mb<<endl;
        while (1){
            d+=mb;
            if (d>200)break;
            int b=ma*((c+d)/mb)-a;
            if (a==0 && c==0 && b==0 && d==0)continue;
            if (b<0)continue;
            else if (b>200)break;
            else{
                if (cost[b][d]>=10000)continue;
                else {
                    //cout<<b<<" "<<d<<" "<<cost[b][d]<<endl;
                    ans=min(cost[b][d]+p.second,ans);
                }
            }
        }
    }
    if (ans==1e9)cout<<-1<<endl;
    else cout<<ans<<endl;



    return 0;
}

Measured memory_bytes: 14700
import java.util.Scanner;

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

        int x = sc.nextInt();
        int y = sc.nextInt();

        System.out.println(whichGroup(x) == whichGroup(y) ? "Yes" : "No");
    }

    private static int whichGroup(int n) {
        int group = 0 ;
        switch (n) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                group = 1;
            break;
            case 4:
            case 6:
            case 9:
            case 11:
                group =  2;
            break;
            case 2:
                group =  3;
            break;
        }
        return group;
    }
}


Measured memory_bytes: 21844
#coding:utf-8

wh = 1
wh2 = 2
L = []
while wh < wh2:
    x, y = map(int, raw_input(). split())
    if x == 0 and y == 0:
        break
    else:
        L.append(x)
        L.append(y)


i = 0
while i < len(L):
    a = L[i]
    b = L[i + 1]
    if a < b:
        print(str(a) + " " + str(b))
    else:
        print(str(b) + " " + str(a))
    i += 2

Measured memory_bytes: 6556
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n, k) for (int i = n; i < k; i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v)                      \
    for (int i = 0; i < v.size(); i++) \
        P(v[i]);
#define printt(a, b) cout << a << " " << b << endl;
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dx8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int MOD = 1e9 + 7;

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> v, c;
    vi ans(100, 0);
    rep(i, n)
    {
        ll a, b;
        cin >> a >> b;
        v.push_back(make_pair(a, b));
    }
    rep(i, m)
    {
        ll a, b;
        cin >> a >> b;
        c.push_back(make_pair(a, b));
    }
    rep(i, n)
    {
        ll mini = 1e18;
        rep(j, m)
        {
            ll dist = abs(v[i].first - c[j].first) + abs(v[i].second - c[j].second);
            if (mini > dist)
            {
                ans[i] = j + 1;
                mini = dist;
            }
        }
    }
    rep(i, n)
    {
        P(ans[i]);
    }
}

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


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

using namespace std;

typedef long long int ll;
typedef vector<ll> V;
typedef vector<V> VV;

int main() {
  // Happy hacking!
  string s;

  cin >> s;

  ll first = stoi(s.substr(0, 2));
  ll second = stoi(s.substr(2, 2));

  if(1 <= first && first <= 12 && 1 <= second && second <= 12) {
    cout << "AMBIGUOUS" << endl;
    return 0;
  }

  if((first < 1 || 12 < first) && (second < 1 || 12 < second)) {
    cout << "NA" << endl;
    return 0;
  }

  if(first < 1 || 12 < first) {
    cout << "YYMM" << endl;
    return 0;
  }

  cout << "MMYY" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const int INF = INT_MAX / 2;

int N; 

ll dfs(ll num){
    if(num>N){
        return 0;
    }

    bool has_three, has_five, has_seven;
    has_three = has_five = has_seven = false;

    ll t = num;
    while(t!=0)    
    {
        if(t%10==3) has_three = true;
        else if(t%10==5) has_five = true;
        else if(t%10==7) has_seven = true;
        t/=10;
    }
    ll cnt = 0;
    if(has_three&&has_five&&has_seven) cnt++;
    cnt += dfs(num*10+3) + dfs(num*10+5) + dfs(num*10+7);
    return cnt;
}


int main(){
    cin >> N;
    ll ans = 0;
    ans += dfs(3);
    ans += dfs(5);
    ans += dfs(7);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

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

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
string s, t;

int match() {
  int ans = -1;
  REP(i, s.length() - t.length() + 1) {
    bool f = true;
    REP(j, t.length()) {
      if(t[j] != s[i + j] && s[i + j] != '?') f = false;
    }
    if(f) ans = i;
  }
  return ans;
}

string getstr(int sl) {
  string ss = s;
  REP(i, t.length()) {
    ss[sl + i] = t[i];
  }

  REP(i, ss.length()) {
    if(ss[i] == '?') {
      ss[i] = 'a';
    }
  }

  return ss;
}

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

  cin >> s >> t;
  int m = match();
  if(m != -1)  {
    cout << getstr(m) << endl;
  } else {
    cout << "UNRESTORABLE" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  int N;
  cin >> N;
  double ans = 0.0;
  for (int i = 0; i < N; i++) {
	  double A;
	  cin >> A;
	  ans += 1.0 / A;
	}
  cout << 1.0 / ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}

void mainsolve(){

	ll n;
	cin >> n;
	vector<ll> p(n), q(n), aa(n);
	rep(i,n) cin >> p[i];
	rep(i,n) cin >> q[i];
	rep(i,n) aa[i] = i+1;

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

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

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<long long> > vvll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define INF 100000000000000LL
#define MOD 1000000007
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define p_q priority_queue

#define FOR(i, a, b) for (int i=(a); i<=(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 5005
int n;
ll a, b;
int p[MN];
int inv[MN];
ll dp[MN][MN]; //cost to get the first i to be in order and less than the jth thing

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    memset(dp, 0x3f, sizeof dp);

    cin >> n >> a >> b;
    FOR(i, 1, n){
        cin >> p[i];
        inv[p[i]] = i;
    }

    dp[0][1] = 0;
    F0R(i, n){
        FOR(j, 1, n+1){
            //cout << "best ans at " << i << " " << j << " is " << dp[i][j] << "\n";
            int loc = inv[i+1];
            //cout << "loc is " << loc << "\n";
            if(j <= loc){
                dp[i+1][loc+1] = min(dp[i+1][loc+1], dp[i][j]);
            }

            ll val = j <= loc ? b : a;

            dp[i+1][j] = min(dp[i+1][j], dp[i][j] + val);
        }
    }
    ll mnv = INF;
    FOR(i, 1, n+1){
        mnv = min(mnv, dp[n][i]);
    }

    cout << mnv << "\n";

    return 0;
}


Measured memory_bytes: 195968
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


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

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> s(n);
  rep(i, n){
    cin >> a[i];
    if(i==0){
      s[i]=a[i];
    } else {
      s[i]=a[i]+s[i-1];
      s[i]%=mod;
    }
  }
  mint ans=0;
  repo(i, n-1){
    ans+=a[i]*s[i-1];
  }
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 6420
#include<stdio.h>

int main()
{
	int n, i;
	scanf("%d", &n);
	for (i = 0; i <= 25; i ++) {
		if (n - (4 * i) >= 0) {
			if ((n - (4 * i)) % 7 == 0) {
				printf("Yes");
				return 0;
			}
		}
	}
	printf("No");
	return 0;
}


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

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

    bool flg = true;
    ll i = 1;

    ll ans = N;
    for (ll i = 1; i * i <= N; i++)
    {
        ll j;
        if (N % i == 0)
        {
            j = N / i;
            if (ans < i + j - 2)
            {
                break;
            }
            ans = i + j - 2;
        }
        
    }
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <memory.h>
#include <vector>
using namespace std;
const int MAXN=1e5+5;
int n,k,t1,t2,p[MAXN],ans;
char s[MAXN];
int main(){
	//freopen("p6.in","r",stdin);
	//freopen("p6.out","w",stdout);
	scanf("%d %d\n",&n,&k);
	//gets(s);
	scanf("%s",s);
	int i,j=0,len=strlen(s);
	for(i=1;i<len;i++){
		if(s[i]==s[i-1])ans++;
		//else p[++p[0]]=i;
		else j++;
	}
	/*i=1;j=p[0];
	while(i<j){
		
	}*/
	j=(j+1)/2;
	if(j<=k)cout<<n-1;
	else cout<<ans+2*k;
	return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const int N = 110;
bool black[N][N];
int best[N][N];

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n, m; cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    string s; cin >> s;
    for (int j = 1; j <= m; j++) {
      black[i][j] = s[j - 1] == '#';
    }
  }

  memset(best, 64, sizeof best);
  best[1][0] = best[0][1] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      best[i][j] = min(
        best[i - 1][j] + (black[i][j] && !black[i - 1][j]),
        best[i][j - 1] + (black[i][j] && !black[i][j - 1])
      );
    }
  }
  cout << best[n][m] << endl;

  return 0;
}


Measured memory_bytes: 384
//Single Source Shortest Path I
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

static const int N = 100;
static const int WHITE = 0;
static const int BLACK = 1;
//int colors[N], d[N];
//
//void dijkstra(vector<vector<int>> &W, int n) {
//    int u, mind;
//    for(int i = 0; i < n; i++) {
//        colors[i] = WHITE;
//        d[i] = INT_MAX;
//    }
//    d[0] = 0;
//    while(1) {
//        u = -1;
//        mind = INT_MAX;
//        for(int i = 0; i < n; i++) {
//            if(colors[i] == WHITE && d[i] < mind) {
//                u = i;
//                mind = d[i];
//            }
//        }
//        if(u == -1) break;
//        colors[u] = BLACK;
//        for(int i = 0; i < n; i++) {
//            if(W[u][i] != -1) {
//                d[i] = min(d[i], mind + W[u][i]);
//            }
//        }
//    }
//}
int d[N];

void dijkstra(vector<vector<int>> &W, int n) {
    int colors[n];
    for(int i=0; i<n; i++) {
        colors[i] = WHITE;
        d[i] = INT_MAX;
    }
    
    d[0] = 0;

    while(1) {
        int u = -1;
        int min_distance = INT_MAX;
        for(int i=0; i<n; i++) {
            if(colors[i] == BLACK) continue;
            if(d[i] < min_distance) {
                u = i;
                min_distance = d[i];
            }
        }
        if(u == -1) break;

        colors[u] = BLACK;
        for(int i=0; i<n; i++) {
            if(colors[i] == BLACK) continue;
            if(W[u][i] == -1) continue;
            d[i] = min(d[i], d[u] + W[u][i]);
        }
    }
}

int main() {
    int n;
    int u, k, v, c;
    cin >> n;
    vector<vector<int>> W(n, vector<int>(n));
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            W[i][j] = -1;
    for(int i = 0; i < n; i++) {
        cin >> u >> k;
        for(int j = 0; j < k; j++) {
            cin >> v >> c;
            W[u][v] = c;
        }
    }

    dijkstra(W, n);

    for(int i = 0; i < n; i++) {
        cout << i << " " << d[i] << endl;
    }
}


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

const int Maxn = 200005;
pair <int, int> P[Maxn];
int n, maxi_pos, mini_pos, mini1 = 0x3f3f3f3f, maxi1, maxi2, mini2 = 0x3f3f3f3f;
long long ans;
map <int, int> Ma;
int main()
{
	scanf("%d", &n);
	P[0].first = 0x3f3f3f3f;
	for (int i = 1; i <= n; i++)
	{
		scanf("%d%d", &P[i].first, &P[i].second);
		if (P[i].first > P[i].second) swap(P[i].first, P[i].second);
	}
	sort(P + 1, P + 1 + n, [](pair <int, int> x, pair <int, int> y){return x.second < y.second;});
	
	for (int i = 1; i <= n; i++)
	{
		mini1 = min(mini1, P[i].first);
		maxi1 = max(maxi1, P[i].first);
		mini2 = min(mini2, P[i].second);
		maxi2 = max(maxi2, P[i].second);
	}
	ans = (maxi1 - mini1) * (long long) (maxi2 - mini2);
	for (int i = 1; i <= n; i++)
		if (P[i].first < P[mini_pos].first) mini_pos = i;
	for (int i = 1; i <= n; i++)
		if (i != mini_pos && P[i].second > P[maxi_pos].second) maxi_pos = i;
	Ma[P[mini_pos].second]++, Ma[P[maxi_pos].first]++;
	for (int i = 1; i <= n; i++)
		if (i != maxi_pos && i != mini_pos)
			Ma[P[i].first]++;
	ans = min(ans, (long long) (P[maxi_pos].second - P[mini_pos].first) * (Ma.rbegin() -> first - Ma.begin() -> first));
	for (int i = 1; i <= n; i++)
		if (i != maxi_pos && i != mini_pos)
		{
			Ma[P[i].first]--;
			if (!Ma[P[i].first]) Ma.erase(P[i].first);
			Ma[P[i].second]++;
			ans = min(ans, (long long) (P[maxi_pos].second - P[mini_pos].first) * (Ma.rbegin() -> first - Ma.begin() -> first));
		}
	mini_pos = maxi_pos = 0;
	Ma.clear();
	for (int i = 1; i <= n; i++)
		if (P[i].second > P[maxi_pos].second) maxi_pos = i;
	for (int i = 1; i <= n; i++)
		if (i != maxi_pos && P[i].first < P[mini_pos].first) mini_pos = i;
	Ma[P[mini_pos].second]++, Ma[P[maxi_pos].first]++;
	for (int i = 1; i <= n; i++)
		if (i != maxi_pos && i != mini_pos)
			Ma[P[i].first]++;
	ans = min(ans, (long long) (P[maxi_pos].second - P[mini_pos].first) * (Ma.rbegin() -> first - Ma.begin() -> first));
	for (int i = 1; i <= n; i++)
		if (i != maxi_pos && i != mini_pos)
		{
			Ma[P[i].first]--;
			if (!Ma[P[i].first]) Ma.erase(P[i].first);
			Ma[P[i].second]++;
			ans = min(ans, (long long) (P[maxi_pos].second - P[mini_pos].first) * (Ma.rbegin() -> first - Ma.begin() -> first));
		}
	printf("%lld", ans);
	return 0;
}

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

using namespace std;

int T , N , D;

int main(){
	scanf("%d" , &T);
	for(int i = 0 ; i < T ; ++i){
		scanf("%d%d" , &N , &D);
		if(N % 2 == 0) D = (D ^ 127);
		printf("%d\n" , 127 * (N - 1) + D);
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int k,x; cin>>k>>x;
	k--;
	for (int i=x-k; i<=x+k; i++) {
	cout<<i<<" ";
	}
	cout<<"\n";
}


Measured memory_bytes: 256
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

int a[200005];

void Main() {
  int n, k; cin >> n >> k;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  reverse(a, a + n);
  long long ans = 0;
  for(int i = k; i < n; i++) {
    ans += a[i];
  }
  cout << ans << "\n";
}


Measured memory_bytes: 1024
n = int(input())
x = input()
ans = [0]*(n+1)

for i in range(1,n+1):
    s = format(i, 'b')
    c = s.count('1')
    a = i%c
    ans[i] += 1
    ans[i] += ans[a] 

one_cnt = x.count('1')
numx = int(x,2)

for i in range(n):
    temp = one_cnt
    if x[i]=='0':
        temp += 1
        num = numx%temp + pow(2,n-1-i,temp)
    else:
        if temp>1:
            temp -= 1
            num = numx%temp - pow(2,n-1-i,temp)
        else:
            print(0)
            continue
    print(ans[num%temp]+1)


Measured memory_bytes: 76500
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)


int h,w,n;
int winf;
int calc(int x,int y){
	int ans;
	if(y%2==0){
		if(x%2==0){
			ans = (winf+x-y)%(2*w);
			if(ans>=w){
				ans = 2*w-1-ans;
			}
		}else{
			ans = (winf+x+y)%(2*w);
			if(ans>=w){
				ans = 2*w-1-ans;
			}
		}
	}else{
		if(x%2==0){
			ans = (winf+x+y)%(2*w);
			if(ans>=w){
				ans = 2*w-1-ans;
			}
		}else{
			ans = (winf+x-y)%(2*w);
			if(ans>=w){
				ans = 2*w-1-ans;
			}
		}
	}
	return ans;
}

int main(){
	cin >> h >> w >> n;
	vector<int>v(w),s(w);
	winf = (10000000/(2*w))*2*w;
	rep(i,w){
		v[i] = calc(i,h);
	}
	rep(i,w){
		s[v[i]] = i;
	}
	vector<pair<int,int> > pa(n);
	rep(i,n){
		cin >> pa[i].first >> pa[i].second;
	}
	sort(pa.begin(),pa.end());
	rep(i,n){
		int p,q;
		p = calc(pa[i].second-1,pa[i].first);
		q = calc(pa[i].second,pa[i].first);
		swap(v[s[p]],v[s[q]]);
	}
	rep(i,w){
		s[v[i]] = i;
	}
	rep(i,w){
		cout << s[i]+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 5864
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int C = 30000;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int n;
	scanf("%d", &n);
	if (n == 3) {
		printf("2 5 63\n");
		return 0;
	}
	for (int x = 3; x + 6 < C && n >= 4; x += 12, n -= 2) {
		printf("%d %d ", x, x + 6);
	}
	int x = 2;
	for (; n >= 3; x += 6, n -= 3) {
		printf("%d %d %d ", x, x + 2, x + 4);
	}
	if (n == 1) {
		printf("%d ", x + 4);
	} else if (n == 2) {
		printf("%d %d ", x, x + 2);
	}

	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
typedef long long int ll;
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))



typedef struct
{
	int No,order,p;
	ll y;
} DETA;

int cmp_year( const void *p, const void *q ) {
    return ((DETA*)p)->y - ((DETA*)q)->y;
}
int cmp_no( const void *p, const void *q ) {
    return ((DETA*)p)->No - ((DETA*)q)->No;
}


int main(void){
	int n,m;
	scanf("%d %d",&n,&m);
	DETA id[m];
	rep(i,m){
		scanf("%d %lld",&id[i].p,&id[i].y);
		id[i].No = i;
	}
	qsort(id,m,sizeof(DETA),cmp_year);
	int count[n+1];
	m0(count);
	rep(i,m){
		count[id[i].p]++;
		id[i].order=count[id[i].p];
	}
	qsort(id,m,sizeof(DETA),cmp_no);
	rep(i,m){
		printf("%06d%06d\n",id[i].p,id[i].order);
	}

	return 0;

}

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

ll pow_mod(int n, int m, int mod) {
  if (m == 0) return 1;
  if (m % 2 == 0) {
    ll tmp = pow_mod(n, m / 2, mod);
    return (tmp * tmp) % mod;
  } else {
    return (n * pow_mod(n, m - 1, mod)) % mod;
  }
}

void init_factorials_mod(ll arr[], int n, int mod) {
  arr[0] = 1;
  for (int i = 1; i < n + 1; i++) {
    arr[i] = arr[i-1] * i % mod;
  }
}

ll combination_mod(int n, int r, int mod, ll fact[]) {
  if (n <= 0 || r <= 0) return 1;
  return fact[n] * pow_mod(fact[n - r], mod - 2, mod) % mod
                 * pow_mod(fact[r], mod - 2, mod) % mod;
}

int main() {
  ll n, k;
  cin >> n >> k;

  vector<ll> a(n);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }

  sort(a.begin(), a.end());
  
  const ll mod = 1000000007;
  ll cnt = 0;

  ll fact[100000];
  init_factorials_mod(fact, n, mod);

  for (ll i = k - 1; i < n; i++) {
    // cout << combination_mod(i, k - 1, mod, fact) << endl;
    cnt += (a[i] * combination_mod(i, k - 1, mod, fact)) % mod;
    cnt %= mod;
    // cout << (a[i] * combination_mod(i, k - 1, mod, fact)) % mod << endl;
  }

  for (ll i = 0; i < n - k + 1; i++) {
    // cout << n - i - 1 << " C " << k - 1 << " = " << combination_mod(n - i - 1, k - 1, mod, fact) << endl;
    cnt -= (a[i] * combination_mod(n - i - 1, k - 1, mod, fact)) % mod;
    cnt %= mod;
    if (cnt < 0) cnt += mod;
    // cout << (a[i] * combination_mod(i, k - 1, mod, fact)) % mod << endl;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,a;
    cin>>n;
    while(cin>>a)
        if(a%2==0&&a%3!=0&&a%5!=0)
            cout<<"DENIED"<<endl,exit(0);
    cout<<"APPROVED"<<endl;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;
 
 
public class Main {
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
	
		int N = Integer.parseInt(sc.next());
		
		int[][] phrase = new int[N][3];
		for(int i=0;i<N;i++){
			phrase[i][0] = Integer.parseInt(sc.next());
			phrase[i][1] = Integer.parseInt(sc.next());
			phrase[i][2] = Integer.parseInt(sc.next());
		}
		
		int M = Integer.parseInt(sc.next());
		int[] ans = new int[M];
		int[] W = new int[M];
		for(int i=0;i<M;i++){
			W[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		
		for(int i=0;i<M;i++){
			int w=W[i];
			int[][] dp = new int[N+1][w+1];
			
			for(int j=0; j<N;j++){
				for(int k=0; k<=w;k++){
					int tmp=dp[j][k];
					for(int l=phrase[j][0];l<=Math.min(phrase[j][0]*2, phrase[j][1]);l++){
						if(k-l>=0){
							tmp = Math.max(tmp,dp[j+1][k-l]+phrase[j][2]);
						}else{
							break;
						}
					}
					dp[j+1][k] = tmp;
				}
			}
			
			if(dp[N][w] == 0){
				System.out.println("-1");
				return;
			}else{
				ans[i] = dp[N][w];
			}
			
		}
		
		for(int ans_ : ans){
			System.out.println(ans_);
		}
		
		
	}
	
	
	
}


Measured memory_bytes: 98784
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <list>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

#define N_MAX (1<<12)
#define INF 1000000000000000LL

ll nn_mn;
ll dat_mn[(2 * N_MAX) - 1];

void init_mn(ll n1){
  nn_mn = 1;

  while(nn_mn < n1)nn_mn *= 2;

  for(ll i = 0; i < 2 * nn_mn - 1; i++){
    dat_mn[i] = INF;
  }
}

void update_mn(ll k, ll a){
  k += nn_mn - 1;
  dat_mn[k] = a;
  while(k > 0){
    k = (k - 1) / 2;
    dat_mn[k] = min(dat_mn[k * 2 + 1], dat_mn[k * 2 + 2]);
  }
}

ll query_mn(ll a, ll b, ll k, ll l, ll r){
  if(r <= a || b <= l)return INF;

  if(a <= l && r <= b){
    return dat_mn[k];
  }
  else{
    ll vl = query_mn(a, b, k * 2 + 1, l, (l + r) / 2);
    ll vr = query_mn(a, b, k * 2 + 2, (l + r) / 2, r);
    return min(vl, vr);
  }
}

int main() {
  ll n,x;
  cin>>n>>x;
  init_mn(n*2+1);
  vector<ll> v;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
  }
  rep(i,0,n){
    update_mn(i,v[i]);
    update_mn(i+n,v[i]);
  }
  ll ans = INF;
  rep(i,0,n){
    ll d = i*x;
    rep(j,0,n){
      ll a = query_mn(n+j-i,n+j+1,0,0,nn_mn);
      d += a;
    }
    ans = min(ans,d);
  }
  printf("%lld\n",ans);
  return 0;
}




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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    vector<pair<int, int>> v;
    for(int i=1;i<=n;++i){
        int a;
        cin >> a;
        v.emplace_back(a, i);
    }
    sort(v.begin(), v.end());
    for(int i=0;i<n;++i){
        if(i)cout << " ";
        cout << v[i].second;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> b(n);
    rep(i, n) cin >> b[i];
    vector<int> ans;
    
    rep(i, n) {
        int cnt = 0, mv = 0, mi = -1;
        
        rep(ii, n) {
            if (b[ii] == -1) {
                continue;
            }
            
            cnt++;
            
            if (cnt != b[ii]) {
                continue;
            }
            
            if (mv < b[ii]) {
                mv = b[ii];
                mi = ii;
            }
        }
        
        if (mi == -1) {
            cout << -1 << endl;
            return 0;
        }
        
        ans.push_back(b[mi]);
        b[mi] = -1;
    }
    
    reverse(all(ans));
    
    rep(i, sz(ans)) {
        cout << ans[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[]num=new int[n];
        for(int i=0;i<n;){
            num[i++]=sc.nextInt();
        }
        	
        Arrays.sort(num);
        int sum=1000000000;
        for(int i=0;i+m-1<n;i++){
            int nsum=0;
            nsum+=num[i+m-1]-num[i];
            sum=Math.min(sum,nsum);
        }
        System.out.print(sum);
    }
}


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

using namespace std;

int k,i,num[100005];
char s[100005];

int main(){
	scanf("%s", s);
	scanf("%d", &k);
	
	int l = strlen(s);
	
	for(i = 0; i < l; i++){
		if(s[i] == 'a')
		num[i] = 0;
		else
		num[i] = 'z' - s[i] + 1;
	}
	
	for(i = 0; i < l; i++){
		if(k >= num[i]){
			k -= num[i];
			s[i] = 'a';
		}
	}
	
	s[l - 1] = s[l - 1] + (k % 26);
	
	printf("%s\n", s);
}


Measured memory_bytes: 768
h1, m1, h2, m2, k = gets.split.map(&:to_i)
if (h2 * 60 + m2) - (h1 * 60 + m1) > k
 puts (h2 * 60 + m2) - (h1 * 60 + m1) - k
else
  puts "0"
end

Measured memory_bytes: 14436
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int,P> PP;
typedef pair<int,PP> PPP;
struct edge { int to;  int cost; };

signed main() {
	string s;
	cin >> s;

	int ans = 0;
	int counter = 0;

	rep(i, s.size()){
		if(s[i] == 'A' ||
		s[i]=='T'||
		s[i] =='G'||
		s[i]=='C')
		{
			counter++;
		}
		else{
			ans = max(ans, counter);
			counter = 0;
		}
	}
	ans = max(counter, ans);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int h,w;
vector<string>g;

struct Ptr{
    int x;
    int y;
    int cost;
    Ptr(){
        x = 0;
        y = 0;
        cost = 0;
    }
    Ptr(int x, int y, int cost){
        this->x = x;
        this->y = y;
        this->cost = cost;
    }
    bool operator < (const Ptr &a) const{
        return this->cost < a.cost;
    }
    bool operator > (const Ptr &a) const{
        return this->cost > a.cost;
    }
    void print(){
        printf("x:%3d y:%3d cost:%3d\n", x, y, cost);
    }
};

int Dij(){
    priority_queue<Ptr, vector<Ptr>, greater<Ptr>>que;
    vector<vector<bool>>visited(h+1, vector<bool>(w+1, false));
    if(g[0][0] == '#'){
        que.push(Ptr(0, 0, 1));
    }else{
        que.push(Ptr());
    }
    int dx[2] = {0, 1};
    int dy[2] = {1, 0};
    while(!que.empty()){
        Ptr now = que.top();
        que.pop();
        if(visited[now.y][now.x])   continue;
        visited[now.y][now.x] = true;
        if(now.x == w && now.y == h)    return now.cost;
        rep(i, 2){
            Ptr next = now;
            next.x += dx[i];
            next.y += dy[i];
            if(next.x > w || next.y > h)    continue;
            if(g[now.y][now.x] == '.'){
                if(g[next.y][next.x] == '#'){
                    next.cost++;
                }
            }
            que.push(next);
        }
    }
    return 0;
}

int main(){
    cin >> h >> w;
    g.resize(h);
    rep(i, h)   cin >> g[i];
    --h;    --w;
    cout << Dij() << endl;
}



Measured memory_bytes: 3612
import sys
n=int(input())
t,b=map(int,input().split())
h= [int(x) for x in input().split()]
temp=sys.maxsize
i=0
for a in h:
    val=t-(a*0.006)
    if (abs)(val-b) <temp :
        temp=(abs)(val-b)
        ans=i+1
    i+=1
print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt(),b=scan.nextInt(),c=scan.nextInt();
		if(a==b&&b==c) {
			System.out.println(1);
		}
		if(a!=b&&b!=c&&c==a) {
			System.out.println(2);
		}
		if(a!=b&&b!=c&&c!=a) {
			System.out.println(3);
		}
		if(a!=b&&b==c&&c!=a) {
			System.out.println(2);
		}
		if(a==b&&b!=c&&c!=a) {
			System.out.println(2);
		}
		
	}
	}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	string s;
	cin >> s;
	int n = s.length();
	if(n & 1) {
		cout << "No";
	}
	else {
		bool ok = 1;
		for(int i = 0; i < n; i += 2) {
			if(s[i] == 'h' && s[i + 1] == 'i') {

			}
			else {
				ok = 0;
			}
		}
		if(ok) {
			cout << "Yes";
		}
		else {
			cout << "No";
		}
	}

	return 0;
}

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

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

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

/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}

__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    int x;
    cin >> x;
    int ans = 0;
    ans += x / 500 * 1000;
    x %= 500;
    ans += x / 5 * 5;
    cout << ans << '\n';
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
#define popc __builtin_popcount
using std::cin; using std::cout;
const int maxn = 15;
typedef long long ll;
const int mod = 1e9 + 7;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
inline void reduce(int & x) {
	x += x >> 31 & mod;
}
int n, m;
int edge[maxn];
int f[1 << maxn];
int shift[maxn * maxn];
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	shift[0] = 1;
	rep(i, 1, maxn * maxn - 1) {
		reduce(shift[i] = shift[i - 1] + shift[i - 1] - mod);
	}
	rep(i, 1, m) {
		int x, y;
		cin >> x >> y;
		-- x, -- y;
		edge[x] |= 1 << y;
	}
	* f = 1;
	for(int i = 2;i < 1 << n;i += 2) {
		for(int j = i;j;j = j - 1 & i) {
			int s0 = i | (i >> 1 & 1);
			int s1 = j | (j >> 1 & 1);
			s0 ^= s1;
			int mul = f[i ^ j];
			rep(i, 0, n - 1){
				if(s1 >> i & 1) mul = (ll) mul * shift[popc(edge[i] & s0)] % mod;
				if(s0 >> i & 1) mul = (ll) mul * (shift[popc(edge[i] & s1)] - 1) % mod;
			}
			reduce(f[i] += mul - mod);
		}
	}
	int ans = shift[m] - f[(1 << n) - 2];
	cout << ans + (ans >> 31 & mod) << '\n';
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll mod = 1e9+7;


int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    bool po = false;
    int ans=0;
    int flag = 1;
    for(int i=0;i<n;i++){
        if(flag==a[i]){
            flag++;
            po = true;
        }else{
            ans++;
        }
    }
    if(po){
    cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
  unsigned long long N,M;
  cin >> N >> M;
  if (N>1 && M>1) {
    cout << (N-2) * (M-2);
  } else if (N>1) {
    cout << (N-2);
  } else if (M>1) {
    cout << (M-2);
  } else {
    cout << "1";
  }
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
A.sort()

C = Counter(A)
cannot = set()
L= max(A)
ans = 0
for a in A:
    if a in cannot: continue
    if C[a] == 1:
        ans += 1
    ind = 1
    while a*ind <= L:
        cannot.add(a*ind)
        ind += 1

print(ans)

Measured memory_bytes: 103468
#include<iostream>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstring>
#include<string>
#define ll long long
#define lson (rt<< 1)
#define rson (rt<< 1 | 1)
#define gmid ((l+r)>> 1 )
using namespace std;

const int maxn=20000050;
int main()
{
	string n;
	cin>>n;
	int s=0;
	int k=n.length();
	for(int i=k-1;i>=0;--i)
	  s=(s+n[i]-'0')%9;
	if(s==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;  
}


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

int main() {
	ll n;
	cin >> n;
	priority_queue<ll, vector<ll>, greater<ll>> pq;
	vector<ll>a;
	pq.push(3);
	pq.push(5);
	pq.push(7);
	while (pq.top() <= n) {
		a.push_back(pq.top());
		pq.push(pq.top() * 10 + 3);
		pq.push(pq.top() * 10 + 5);
		pq.push(pq.top() * 10 + 7);
		pq.pop();
	}
	int ans = 0;
	for (int i = 0; i < a.size(); i++) {
		int x = a.at(i);
		if (x <= 332)continue;
		string y = to_string(x);
		sort(y.begin(), y.end());
		int k = 1;
		for (int j = 0; j < y.length(); j++) {
			if (k == 1 && y.at(j) == '3')k *= 2;
			if (k == 2 && y.at(j) == '5')k *= 2;
			if (k == 4 && y.at(j) == '7')k *= 2;
		}
		if (k == 8)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1144
#include <stdio.h>

char s[4];

int main(void)
{
	scanf("%c%c%c%c%*c", &s[0], &s[1], &s[2], &s[3]);
	int a, b;
	a = ((s[0] == '0' && s[1] >= '1' && s[1] <= '9') ||
		(s[0] == '1' && s[1] >= '0' && s[1] <= '2'));
	b = ((s[2] == '0' && s[3] >= '1' && s[3] <= '9') ||
		(s[2] == '1' && s[3] >= '0' && s[3] <= '2'));

	if(!(a+b)) printf("NA");
	else if(a*b) printf("AMBIGUOUS");
	else if(a) printf("MMYY");
	else printf("YYMM");
	
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define M 1000000007

int main(void){
    int a,ans=0;cin>>a;
	for(int i=0;i<4;i++){
	    if(a%10==2)ans++;
	    a/=10;
	}
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    int h, w;
    string s[52] = {};
    cin >> h >> w;
    fr1(h) cin >> s[i], s[i] = '.' + s[i] + '.';
    fr(w + 2) s[0] += '.', s[h + 1] += '.';
    fr1(h) {
        for (int j = 1; j <= w; j++) {
            if (s[i][j] == '#') cout << '#';
            else {
                int z = 0;
                for (int k = -1; k <= 1; k++) for (int l = -1; l <= 1; l++) if (k || l) {
                    if (s[i + k][j + l] == '#') z++;
                }
                cout << z;
            }
        }
        cout << '\n';
    }
}


Measured memory_bytes: 256