akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
	int i;
	char A[1200];
	
	//fgets("%s", A, stdin);
	fgets(A, 1200, stdin);
	for(i = 0; i < 1200; i++){
		if(A[i] == 'a'){A[i] = 'A';}else if(A[i] == 'A'){A[i] = 'a';}else{}
		if(A[i] == 'b'){A[i] = 'B';}else if(A[i] == 'B'){A[i] = 'b';}else{}
		if(A[i] == 'c'){A[i] = 'C';}else if(A[i] == 'C'){A[i] = 'c';}else{}
		if(A[i] == 'd'){A[i] = 'D';}else if(A[i] == 'D'){A[i] = 'd';}else{}
		if(A[i] == 'e'){A[i] = 'E';}else if(A[i] == 'E'){A[i] = 'e';}else{}
		if(A[i] == 'f'){A[i] = 'F';}else if(A[i] == 'F'){A[i] = 'f';}else{}
		if(A[i] == 'g'){A[i] = 'G';}else if(A[i] == 'G'){A[i] = 'g';}else{}
		if(A[i] == 'h'){A[i] = 'H';}else if(A[i] == 'H'){A[i] = 'h';}else{}
		if(A[i] == 'i'){A[i] = 'I';}else if(A[i] == 'I'){A[i] = 'i';}else{}
		if(A[i] == 'j'){A[i] = 'J';}else if(A[i] == 'J'){A[i] = 'j';}else{}
		if(A[i] == 'k'){A[i] = 'K';}else if(A[i] == 'K'){A[i] = 'k';}else{}
		if(A[i] == 'l'){A[i] = 'L';}else if(A[i] == 'L'){A[i] = 'l';}else{}
		if(A[i] == 'm'){A[i] = 'M';}else if(A[i] == 'M'){A[i] = 'm';}else{}
		if(A[i] == 'n'){A[i] = 'N';}else if(A[i] == 'N'){A[i] = 'n';}else{}
		if(A[i] == 'o'){A[i] = 'O';}else if(A[i] == 'O'){A[i] = 'o';}else{}
		if(A[i] == 'p'){A[i] = 'P';}else if(A[i] == 'P'){A[i] = 'p';}else{}
		if(A[i] == 'q'){A[i] = 'Q';}else if(A[i] == 'Q'){A[i] = 'q';}else{}
		if(A[i] == 'r'){A[i] = 'R';}else if(A[i] == 'R'){A[i] = 'r';}else{}
		if(A[i] == 's'){A[i] = 'S';}else if(A[i] == 'S'){A[i] = 's';}else{}
		if(A[i] == 't'){A[i] = 'T';}else if(A[i] == 'T'){A[i] = 't';}else{}
		if(A[i] == 'u'){A[i] = 'U';}else if(A[i] == 'U'){A[i] = 'u';}else{}
		if(A[i] == 'v'){A[i] = 'V';}else if(A[i] == 'V'){A[i] = 'v';}else{}
		if(A[i] == 'w'){A[i] = 'W';}else if(A[i] == 'W'){A[i] = 'w';}else{}
		if(A[i] == 'x'){A[i] = 'X';}else if(A[i] == 'X'){A[i] = 'x';}else{}
		if(A[i] == 'y'){A[i] = 'Y';}else if(A[i] == 'Y'){A[i] = 'y';}else{}
		if(A[i] == 'z'){A[i] = 'Z';}else if(A[i] == 'Z'){A[i] = 'z';}else{}
	}
	
	printf("%s",A);
	
	return 0;
}


Measured memory_bytes: 2044
#include<stdio.h>
int main()
  { 
    int K,A,B,count=0,i;
    scanf("%d %d %d",&K,&A,&B);
    for(i=A;i<=B;i++)
     { 
       if(i%K==0)
        { 
         count++;
        }
       }
  if(count>0)
    printf("OK");
  else
    printf("NG");
  return 0;
 }


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


def main():
    N = int(input())
    d = len(str(N))
    ansL = [[0 for _ in range(9)] for _ in range(9)]
    for i in range(1,10):
        for j in range(1,10):
            tmp = 0
            # A(1桁)
            if i == j and i <= N:
                tmp += 1
            # AB(2桁)
            if i*10+j <= N:
                tmp += 1
            # A*B(3桁以上d桁未満)
            if d > 2:
                for k in range(3,d):
                    tmp += 10**(k-2)

                # d桁はN以下
                if int(str(N)[0]) > i:
                    tmp += 10**(d-2)
                elif int(str(N)[0]) == i:
                    tmp += int(str(N)[1:-1])
                    if int(str(N)[-1]) >= j:
                        tmp += 1
            ansL[i-1][j-1] = tmp
    
    ans = 0
    for i in range(9):
        for j in range(9):
            ans += ansL[i][j] * ansL[j][i]
    print(ans)
                

if __name__ == "__main__":
    main()


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

signed main(){
  int N;
  cin>>N;
  string ans="NO";
  int co=0;
  vector<int> A(N);
  rep(i,N){
    cin>>A[i];
    if(A[i]%2==1){
      co+=1;
    }
  }
  if(co%2==0)ans="YES";
  cout<<ans<<endl;
}

Measured memory_bytes: 4032
#include<queue>
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
#define Spa putchar(32)
const int maxn=111111;
int fa[maxn],siz[maxn];
LL Ans[maxn];
struct hhh
{
	int a,b;
}h[maxn];
int getf(int x)
{
	if(fa[x]==x) return x;
	return fa[x]=getf(fa[x]);
}
int read()
{
	int s=0,c=getchar(),f=1;
	while(c<48||c>57)
	{
		if(c==45) f=-1;
		c=getchar();
	}
	while(c>=48&&c<=57) s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return s*f;
} 
void write(LL x)
{
	if(x>=10) write(x/10);
	putchar(x%10+48);
}
void W(int x)
{
	if(x<0) x=-x,putchar(45);
	write(x);
}
int main()
{
	int N=read(),M=read();
	for(int i=1;i<=N;++i) fa[i]=i,siz[i]=1;
	for(int i=1;i<=M;++i)
	{
		h[i].a=read();h[i].b=read();
	}
	for(int i=M;i;--i)
	{
		int X=getf(h[i].a),Y=getf(h[i].b);
		if(X==Y)
		{
			Ans[i]=Ans[i+1];
			continue;
		}
		fa[X]=Y;
		Ans[i]=Ans[i+1]+(LL)siz[X]*siz[Y];
		siz[Y]+=siz[X];
//		for(int i=1;i<=N;++i) printf("----%d %d %d\n",i,fa[i],siz[i]);puts("");
	}
	for(int i=2;i<=M;++i)
	{
		write((LL)N*(N-1)/2-Ans[i]);puts("");
	}write((LL)N*(N-1)/2);
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  string J;
	cin >> A >> B;
  	if((A*B)%2 == 0){
      J = "Even";}
    else{
      J = "Odd";
    }
  cout << J << endl;
}

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

int main()
{
    int i, j, k, n, a, b, c, ans;

    cin >> n;

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

    ans=0;
    for(i=0; i<n; i+=1)
    {
        for(j=i+1; j<n; j+=1)
        {
            for(k=j+1; k<n; k+=1)
            {
                a=t[i];
                b=t[j];
                c=t[k];
                if(a!=b && b!=c && a!=c)
                {
                    if(a+b>c && b+c>a && c+a>b)
                        ans+=1;
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3600
def main():
    s=input()
    n = len(s)
    dp = [[0]*(13) for _ in range(100005)]
    MOD = 10**9 + 7
    dp[0][0]=1

    for i in range(n):
        c=0
        if(s[i]=="?"):c=-1
        else:c = int(s[i])

        for j in range(10):
            if(c!=-1 and c!=j):
                continue
            for ki in range(13):
                dp[i+1][(ki*10+j)%13] += dp[i][ki]

        for j in range(13):
            dp[i+1][j]%=MOD
    res = dp[n][5]

    print(res)





if __name__ == '__main__':
    main()


Measured memory_bytes: 61916
#include <iostream>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <vector>
#include <cmath>
#include <cstdint>
#include <string>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  
  std::vector<std::vector<int>> a;
  for (int i = 0; i < n; ++i) {
    std::vector<int> row;
    for (int j = 0; j < m; ++j) {
      int x;
      cin >> x;
      row.push_back(x);
    }
    a.push_back(row);
  }

  std::vector<int> b;
  for (int j = 0; j < m; ++j) {
    int x;
    cin >> x;
    b.push_back(x);
  }

  for (int i = 0; i < n; ++i) {
    int sum = 0;
    for (int j = 0; j < m; ++j) {
      sum += a[i][j] * b[j];
    }
    cout << sum << endl;
  }
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

main(){
  int h,w,k;
  cin>>h>>w>>k;
  vector<string> s(h);
  cin>>s;
  auto sum = vec<ll>(h+1,w+1);
  rep(i,h)rep(j,w){
    sum[i+1][j+1] = (s[i][j]=='1');
  }
  rep(i,h)rep(j,w){
    sum[i + 1][j + 1] += sum[i + 1][j] + sum[i][j + 1] - sum[i][j];
  }

  auto get = [&](int sy, int sx, int ty, int tx) {
   return sum[ty][tx] - sum[ty][sx] - sum[sy][tx] + sum[sy][sx];
  };
  auto chk = [&](auto const& div,int px,int x){
    int n = div.size();
    ll tmp = 0;
    rep(i,n-1){
      chmax(tmp,get(div[i],px,div[i+1],x));
    }
    return tmp;
  };
  ll ans = INF;
  for(int i=0;i<(1<<(h-1));++i){
    bitset<11> b(i);
    vector<ll> div;
    div.emplace_back(0);
    rep(j,10)if(b[j])div.emplace_back(j+1);
    div.emplace_back(h);
    int px=0;
    ll tmp=b.count();
    for(int x=1;x<=w;++x){
      auto v = chk(div,px,x);
      if(v>k){
        if(abs(x-px)==1){
          tmp = INF;
          break;
        }
        tmp++;
        px = x-1;
      }
    }
    chmin(ans,tmp);
  }
  cout<<(ans)<<endl;
}


Measured memory_bytes: 384
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    Tuple!(int, int)[] A;
    foreach (i; 0..N) {
        s = readln.split.map!(to!int);
        A ~= tuple(s[0], s[1]);
    }

    int solve() {
        auto B = A.dup;
        Tuple!(int, int)[] C;
        B.sort!"a[0] == b[0] ? a[1] > b[1] : a[0] < b[0]";
        
        int left = 1;
        foreach (b; B) {
            if (b[0] == 0) {
                C ~= b;
            } else if (b[0] >= left) {
                left += 1;
            } else {
                C ~= b;
            }
        }

        int right = M;
        C.sort!"a[1] > b[1]";
        foreach (c; C) {
            if (right < left) {
                break;
            }
            if (c[1] <= right) {
                right -= 1;
            }
        }

        return (left - 1) + (M - right);
    }

    int ans = solve;
    //foreach (i; 0..N) {
    //    A[i] = tuple(M - A[i][1] + 1, M - A[i][0] + 1);
    //}
    ans = max(ans, solve);

    writeln(N - ans);
}


Measured memory_bytes: 12412
#include "bits/stdc++.h"

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

int n, k;
vector<int> a, nxt, pa;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k;
    a.assign(n, 0);
    pa.assign(n + 1, 0);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    for(int i = 0; i < k; ++i){
        pa.assign(n + 1, 0);
        nxt.assign(n, 0);
        for(int j = 0; j < n; ++j){
            pa[max(j - a[j], 0)]++;
            pa[min(j + a[j] + 1, n)]--;
        }
        // for(auto i : pa) cout << i << " ";
        // cout << "\n";
        int cur = 0;
        for(int j = 0; j < n; ++j){
            cur += pa[j];
            nxt[j] = cur;
        }
        a = nxt;
        bool done = true;
        for(int j = 0; j < n; ++j){
            if(a[j] != n) done = false;
            // cout << a[j] << " ";
        }
        // cout << "\n";
        if(done){
            break;
        }
    }
    for(auto i : a) cout << i << " ";
    return 0;
}

Measured memory_bytes: 5552
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
ll m;
ll modpow(ll a, ll b){
    ll res = 1;
    while(b > 0){
        if(b & 1){
            res *= a;
            res %= m;
        }
        a *= a;
        a %= m;
        b >>= 1;
    }
    return res;
}
int main(void){
    ll n;
    cin >> n;
    string s;
    cin >> s;

    reverse(all(s));

    ll originalPop = 0;
    rep(i, n){
        if(s[i] == '1'){
            originalPop++;
        }
    }
    m = originalPop;

    ll totalp = 0;
    ll totalm = 0;
    m = originalPop + 1;
    for(ll i = 0; i < n; i++){
        if(s[i] == '1'){
            totalp += modpow(2LL, i);
            totalp %= m;
        }
    }
    m = originalPop - 1;
    bool f = false;
    if(m == 0){
        f = true;
    } else {
        for(ll i = 0; i < n; i++){
            if(s[i] == '1'){
                totalm += modpow(2LL, i);
                totalm %= m;
            }
        }
    }

    vector<ll> ans;
    for(ll i = 0; i < n; i++){
        ll now;
        if(s[i] == '1'){
            m = originalPop - 1;
            if(f){
                ans.push_back(0);
                continue;
            }
            now = totalm - modpow(2LL, i);
            while(now < 0) now += m;
        } else {
            m = originalPop + 1;
            now = totalp + modpow(2LL, i);
            now %= m;
        }
        ll cnt = 1;
        while(now != 0){
            now %= __builtin_popcountll(now);
            cnt++;
        }

        ans.push_back(cnt);
    }

    reverse(all(ans));
    rep(i, n) cout << ans[i] << endl;

}


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

int main() {
  int n, ans = 0;
  cin >> n;
  cout << ((n % 1000) == 0 ? 0 : 1000 - (n % 1000)) << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>

int main(int argc, char *argv[]) {
    int n;
    scanf("%d", &n);
    int adj_mat[n+1][n+1];

    // init
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            adj_mat[i][j] = 0;
        }
    }

    // read
    for (int i = 1; i <= n; i++) {
        int node_id, adj_num;
        scanf("%d", &node_id);
        scanf("%d", &adj_num);
        for (int j = 1; j <= adj_num; j++) {
            int adj_id;
            scanf("%d", &adj_id);
            adj_mat[node_id][adj_id] = 1;
        }
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (j != n) {
                fprintf(stdout, "%d ", adj_mat[i][j]);
            } else {
                fprintf(stdout, "%d\n", adj_mat[i][j]);
            }
        }
    }

    return 0;
}


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

using namespace std ;

const int MAX = 1e6 + 10 ;

int arr[MAX] , Plus[MAX] , Minus[MAX] ;
int n ;

bool cmp(int &i , int &j)
{
	if(Minus[i] == 0 && Minus[j] == 0)
		return Plus[i] > Plus[j] ;
	else if(Minus[i] == 0 || Minus[j] == 0)
		return Minus[i] < Minus[j] ;
	else
	{
		if(Plus[i] - Minus[i] > 0 && Plus[j] - Minus[j] > 0)
			return Minus[i] < Minus[j] ;
		else if(Plus[i] - Minus[i] > 0 || Plus[j] - Minus[j] > 0)
			return Plus[i] - Minus[i] > Plus[j] - Minus[j] ;
		else
		{
			if(Plus[i] > 0 && Plus[j] > 0)
            	return Minus[i] > Minus[j] ;
			else if(Plus[i] > 0 || Plus[j] > 0)
				return Plus[i] > Plus[j] ;
			else
				return Minus[i] < Minus[j] ;
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	string s ;
	vector<int>perm ;
	for(int i = 0 ; i < n ; ++i)
	{
		cin>>s ;
		int cnt = 0 ;
		for(auto &c : s)
		{
			if(c == '(')
				cnt++ ;
			else
			{
				if(cnt == 0)
					Minus[i]++ ;
				cnt-- ;
				cnt = max(cnt , 0) ;
			}
		}
		Plus[i] = cnt ;
		perm.push_back(i) ;
	}
	sort(perm.begin() , perm.end() , cmp) ;
	int cnt = 0 ;
	for(auto &i : perm)
	{
		cnt -= Minus[i] ;
		if(cnt < 0)
			return cout<<"No\n" , 0 ;
		cnt += Plus[i] ;
	}
	if(cnt == 0)
		cout<<"Yes\n" ;
	else
		cout<<"No\n" ;
	return 0 ;
}		


Measured memory_bytes: 15108
n = int(input())
ans = [0 for _ in range(10**4+1)]
for x in range(1, 101): #x
    for y in range(1, 101): #y
        for z in range(1,101): #z
            if (m:=x*x+y*y+z*z+x*y+y*z+z*x) <= n:
                # print(m)
                ans[m] += 1

for i in range(n):
    print(ans[i+1])

Measured memory_bytes: 9300
#include <cstdio>

int a[10][10],ans,t,x[65],y[65],e[5][3],h,w,c;

int bfs(){
	int h=0,nx,ny;
	bool bj[10][10]={false};
	x[1]=1;
	y[1]=1;
	bj[1][1]=true;
	t=1;
	while (h<t){
		h++;
		for (int i=1;i<=4;i++){
			nx=x[h]+e[i][1];
			ny=y[h]+e[i][2];
			if (a[nx][ny]==a[1][1]&&!bj[nx][ny]){
				bj[nx][ny]=true;
				t++;
				x[t]=nx;
				y[t]=ny;
			}
		}
	}
	return 0;
}

int dfs(int k){
	if (k==6){
		if (a[1][1]!=c) return 0;
		bfs();
		if (t>ans) ans=t;
		return 0;
	}
	bfs();
	int nt,nx[65],ny[65],nc;
	nc=a[1][1];
	nt=t;
	for (int i=1;i<=t;i++){
		nx[i]=x[i];
		ny[i]=y[i];
	}
	for (int i=1;i<=6;i++)if (i!=nc){
		for (int j=1;j<=nt;j++) a[nx[j]][ny[j]]=i;
		dfs(k+1);
	}
	for (int j=1;j<=nt;j++) a[nx[j]][ny[j]]=nc;
	return 0;
}

int main(){
	e[1][1]=1;e[2][1]=-1;e[3][2]=1;e[4][2]=-1;
	scanf("%d%d%d",&h,&w,&c);
	while (h!=0){
		for (int i=0;i<=9;i++) for (int j=0;j<=9;j++)a[i][j]=0;
		for (int i=1;i<=h;i++)
			for (int j=1;j<=w;j++)scanf("%d",&a[i][j]);
		ans=0;	
		dfs(1);	
		printf("%d\n",ans);
		scanf("%d%d%d",&h,&w,&c);
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    map<int,int> mp[n];
    int b[n];
    int mx=0,cnt=0;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        for(int j=0; j<a; j++){
            int x,y;
            cin >> x >> y;
            mp[i][x]=y;
        }
    }
    for(int bit=0; bit<(1<<n); bit++){
        cnt=0;
        for(int i=0; i<n; i++){
            b[i]=0;
        }
        for(int i=0; i<n; i++){
            if(bit&(1<<i)){
                b[i]=1;
                cnt++;
            }
        }
        for(int i=0; i<n; i++){
            if(b[i]==1){
                for(auto p:mp[i]){
                    if(b[p.first-1]!=p.second)cnt=0;
                }
            }
        }
        mx=max(mx,cnt);
    }
    cout << mx << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=1,_n=n;i<=n;i++)
#define ll long long
#define pii pair<int,int>
#define vector<pii> vpii
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
bool ok(string s)
{
	rep(i,s.size()/2)
		if(s[i]!=s[s.size()-i-1])return 0;
	return 1;
}
map<int,ll>mp;
bool used[200100];
int main()
{
	ios::sync_with_stdio(0);
	int n;
	cin>>n;
	int a[200100];
	rep(i,n)
	{
		cin>>a[i];
		mp[a[i]]++;
	}
	ll cnt=0;
	rep(i,n)
	{
		if(!used[a[i]])
		{
		cnt+=mp[a[i]]*(mp[a[i]]-1)/2;
		used[a[i]]=1;}
	}
//	cout<<cnt<<endl;
	rep(i,n)
	{
		ll ans=cnt;
		ans-=mp[a[i]]*(mp[a[i]]-1)/2;
		ans+=(mp[a[i]]-1)*(mp[a[i]]-2)/2;
		cout<<ans<<endl;
	}
	return 0;
}



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

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A + B + C == 17) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

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

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, K;
  cin >> N >> K;
  vl D(N + 1, 0);
  vl A;
  REP(i, N) {
    ll a;
    cin >> a;
    D[i + 1] = a + D[i];
  }
  REP(i, N) FOR(j, i + 1, N + 1) { A.push_back(D[j] - D[i]); }

  for (ll i = 43; i >= 0; i--) {
    vl B;
    ll po = 1LL << i;
    AUTO(a, A) {
      if ((a & po) == po)
        B.push_back(a);
    }
    if (B.size() >= K) {
      A = B;
    }
  }
  ll ans = A[0];
  REP(i, K - 1) { ans &= A[i + 1]; }
  cout << ans << endl;
  return 0;
}


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

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

    if(n < 600){
        cout << 8 << endl;
    }else if(n < 800){
        cout << 7 << endl;
    }else if(n < 1000){
        cout << 6 << endl;
    }else if(n < 1200){
        cout << 5 << endl;
    }else if(n < 1400){
        cout << 4 << endl;
    }else if(n < 1600){
        cout << 3 << endl;
    }else if(n < 1800){
        cout << 2 << endl;
    }else{
        cout << 1 << endl;
    }
}

Measured memory_bytes: 3588
#include <iostream>

using namespace std;

int main(){
  int count=0;
  
  while(1){
    int book[10]={0};

    cin>>book[0];

    if(book[0]==0)
      break;
    
    for(int i=1;i<10;i++){
      cin>>book[i];
      book[0]-=book[i];
    }

    cout<<book[0]<<endl;

    count++;
    if(count==5)
      break;
  }

  return 0;
}



Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		sc.close();

		int ans = 0;

		int t = x / 100;
		t++;

		out: for(int i = 0; i < t; i++) {
			for(int j = 0; j < t - i; j++) {
				for(int k = 0; k < t - i -  j; k++) {
					for(int l = 0; l < t - i - j - k; l++) {
						for(int m = 0; m < t - i - j - k - l; m++) {
							for(int n = 0; n < t - i - j - k - l - m; n++) {
								int a = 100 * i + 101 * j + 102 * k + 103 * l + 104 * m + 105 * n;
								if( a == x) {
									ans = 1;
									break out;
								}
							}
						}
					}
				}
			}
		}

		System.out.println(ans);

	}

}


Measured memory_bytes: 21844
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define MOD 1000000007
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0);
template<typename T> inline T gcd(T&a,T&b){return b==0?a:gcd(b,a%b);}
template<typename T> inline T lcm(T&a,T&b){return a/gcd(a,b)*b;}
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
int main(){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if (b<=c) puts("0");
    else if (a<=c && c<b && b<=d) printf("%d\n",b-c);
    else if (c<=a && b<=d) printf("%d",b-a);
    else if (a<=c && d<=b) printf("%d\n",d-c);
    else if (c<=a && a<=d) printf("%d\n",d-a);
    else puts("0");
    return 0;
}


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

using namespace std;

long long inf=1000000007;

long long modpow(long long n,long long p,long long mod);

int main(){
	long long n,m,r;
	cin>>n>>m>>r;
	vector<vector<pair<long long,long long>>> kankei(n);
	vector<bool> done(n,false);
	vector<long long> dis(n,inf*100);

	for(long long i=0;i<m;i++){
		long long a,b,c;
		cin>>a>>b>>c;
		kankei.at(a).push_back(make_pair(b,c));
	}

	priority_queue<pair<long long,long long>,vector<pair<long long,long long>>,greater<pair<long long,long long>>> que;
	que.push(make_pair(0,r));
	while(!que.empty()){
		long long nowpos=que.top().second;
		long long nowdis=que.top().first;
		que.pop();
		if(done.at(nowpos)) continue;
		done.at(nowpos)=true;
		dis.at(nowpos)=nowdis;

		for(auto next:kankei.at(nowpos)){
			que.push(make_pair(nowdis+next.second,next.first));
		}
	}

	for(long long i=0;i<n;i++){
		if(done.at(i)){
			cout<<dis.at(i)<<endl;
		}else{
			cout<<"INF"<<endl;
		}
	}

	return 0;
}

long long modpow(long long n,long long p,long long mod){
	if(p==0) return 1;
	if(p%2==0) return (modpow(n,p/2,mod)*modpow(n,p/2,mod))%mod;
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}



Measured memory_bytes: 21448
import sys
from collections import Counter
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

N,K = na()
A=Counter(na())
c=0
ans=0
for i in A.most_common():
    ans+=i[1]
    c+=1
    if(c>=K):
        break
print(N-ans)

Measured memory_bytes: 39268
#include<iostream>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
using namespace std;
typedef long long llong;

int main()
{
	int a;
	cin >> a;
	if (a == 3 || a == 5 || a == 7) cout << "YES";
	else cout << "NO";
}

Measured memory_bytes: 256
"use strict";
function Main(input) {
    let S = input.split("\n")[0].split(/\s/)[0] + 'X';
    let ans = 0, l = 0;
    for (let n = 0; n < S.length; n++) {
        switch (S.charAt(n)) {
        case 'A': 
        case 'C': 
        case 'T': 
        case 'G': 
            l += 1; 
            break;
        default: 
            if (l > ans) ans = l;
            l = 0;
        }
    }
    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
long long fac[1010], finv[1010], inv[1010]; 
long long MOD = 1000000007; 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 1005; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long group(int k, int n, int r){
	long long num = COM(r, k*n) * fac[k*n] % MOD; 
	for(int i = 0; i < n; i++){
		num *= finv[k]; num %= MOD; 
	}
	num *= finv[n]; num %= MOD; 
	return num; // r人残っているときにk人のグループをn個作る方法
}
int main(){
	int N, A, B, C, D; 
	cin >> N >> A >> B >> C >> D; 
	COMinit(); 
	long long dp[1010][1010] = {}; // i人のグループまで見てj人使いきってる
	dp[A-1][0] = 1; 
	for(int i = A-1; i < B; i++){
		for(int j = 0; j <= N; j++){
			if(!dp[i][j]) continue; 
			dp[i+1][j] += dp[i][j]; 
			dp[i+1][j] %= MOD; 
			for(int k = C; k <= D; k++){
				if(j + (i+1)*k > N) break; 
				dp[i+1][j + (i+1)*k] += dp[i][j] * group(i+1, k, N-j); 
				dp[i+1][j + (i+1)*k] %= MOD; 
			}
		}
	}
	cout << dp[B][N] << endl; 
}

Measured memory_bytes: 8320
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;

#define getmid(l,r) ((l) + ((r) - (l)) / 2)
#define MEM(a,b) memset(a,b,sizeof(a))
#define MP(a,b) make_pair(a,b)
#define PB push_back

typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int INF = (1 << 30) - 1;

int N;
int A[110];

int main(){
	scanf("%d",&N);
	int sum = 0;
	for(int i = 1; i <= N; ++i) scanf("%d",&A[i]),sum += A[i];
	ll ans = 1LL << 60;
	for(int v = -100; v <= 100; ++v){
		ll res = 0;
		for(int i = 1; i <= N; ++i){
			res += 1ll * (A[i] - v) * (A[i] - v);
		}
		ans = min(ans,res);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set> 
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>
#include <complex>
#define assem99 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define ld long double
#define ii pair<int, int>
#define pll pair<ll, ll>
#define vii vector<ii>
#define point complex<double>
#define rep(i,a,b) for(int i=a; i<b; i++)
#define F first
#define S second
#define endline '\n'
#define sz(a) (int)(a).size()
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
int dx[] = { 0, -1, 0, 1, -1, 1, -1, 1 };
int dy[] = { -1, 0, 1, 0, 1, -1, -1, 1 };
const int MOD = 998244353, N = 2e5 + 5;
const double pi = acos(-1);
using namespace std;

// 0 -> BB
// 1 -> WW
// 2 -> BW
// 3 -> WB
int n, k, dp[1005][2005][5];
ll solve(int id, int cnt, int op)
{
	if (id == n - 1) return cnt == k;
	if (~dp[id][cnt][op]) return dp[id][cnt][op];
	ll ans = 0;
	if (op == 0)
	{
		ans += solve(id + 1, cnt, 0); ans %= MOD;
		ans += solve(id + 1, cnt + 1, 1); ans %= MOD;
		ans += solve(id + 1, cnt + 1, 2); ans %= MOD;
		ans += solve(id + 1, cnt + 1, 3); ans %= MOD;
	}
	if (op == 1)
	{
		ans += solve(id + 1, cnt + 1, 0); ans %= MOD;
		ans += solve(id + 1, cnt, 1); ans %= MOD;
		ans += solve(id + 1, cnt + 1, 2); ans %= MOD;
		ans += solve(id + 1, cnt + 1, 3); ans %= MOD;
	}
	if (op == 2)
	{
		ans += solve(id + 1, cnt, 0); ans %= MOD;
		ans += solve(id + 1, cnt, 1); ans %= MOD;
		ans += solve(id + 1, cnt, 2); ans %= MOD;
		ans += solve(id + 1, cnt + 2, 3); ans %= MOD;
	}
	if (op == 3)
	{
		ans += solve(id + 1, cnt, 0); ans %= MOD;
		ans += solve(id + 1, cnt, 1); ans %= MOD;
		ans += solve(id + 1, cnt + 2, 2); ans %= MOD;
		ans += solve(id + 1, cnt, 3); ans %= MOD;
	}
	return dp[id][cnt][op] = ans;
}

int main()
{
	assem99;
	int a; cin >> a;
	cout << a + a * a + a * a * a;

	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
constexpr int M = 1e9 + 7;
constexpr int INF = 1e9;

int main() {
    string s, check;
    cin >> s;
    for(int i = 0; i < s.size(); ++i) {
        if(s[i] != 'x') {
            check += s[i];
        }
    }
    auto check2 = check;
    reverse(check2.begin(), check2.end());
    if(check != check2) {
        cout << -1 << endl;
    } else {
        int l = 0, r = s.size() - 1;
        int res = 0;
        while(l < r) {
            //cout << l << ' ' << r << endl;
            if(s[l] != s[r]) {
                if(s[l] == 'x') {
                    l++;
                } else {
                    r--;
                }
                res++;
            } else {
                l++;
                r--;
            }
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
    int H, W; cin >> H >> W;
    vector<vector<int>> cost(10,vector<int>(10));
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> cost[i][j];
        }
    }

    for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }

    ll ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int num; cin >> num;
            if (num == -1) continue;
            ans += cost[num][1];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e18
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll n,X,tot,s[maxn];
struct node{ll b,l,r,val;}p[maxn];

inline bool cmp(node a,node b){return a.val>b.val;}

inline ll cal(ll a,ll b)
{
	if(a<=p[b].b) return a*p[b].l;
	return p[b].l*p[b].b+(a-p[b].b)*p[b].r;
}

inline bool jud(ll x)
{
	ll nw=x,tmp=0,t=x/X,t2=x%X;
	if(t>=n) return true;
	rep(i,1,n)
	{
		if(i<=t) tmp=max(tmp,cal(t2,i)+s[t+1]-p[i].val);
		else tmp=max(tmp,cal(t2,i)+s[t]);
	}
	if(tmp>=tot) return true; return false;
}

int main()
{
	n=read(); X=read();
	rep(i,1,n) p[i].b=read(),p[i].l=read(),p[i].r=read(),tot+=p[i].b*p[i].l;
	rep(i,1,n) p[i].val=p[i].b*p[i].l+(X-p[i].b)*p[i].r;
	sort(p+1,p+n+1,cmp);
	rep(i,1,n) s[i]=s[i-1]+p[i].val;
	ll l=0,r=inf,ans=inf;
	while(l<=r)
	{
		ll mid=(l+r)>>1;
		if(jud(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6400
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "unordered_set"
#include "stack"
#include "tuple"

#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n,i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<int,int>

typedef long long ll;
using namespace std;

int n, m, p, q, c;

namespace std {
	template<>
	class hash<P> {
	public:
		size_t operator()(const P&x)const {
			return hash<ll>()(x.first)*intmax + hash<ll>()(x.second);
		}
	};
}

map<P, vector<pair<P, int>>>v;
map<P, int>mp;
priority_queue<pair<int, P>, vector<pair<int, P>>, greater<pair<int, P>>>Q;

int main() {
	cin >> n >> m;
	rep(m) {
		cin >> p >> q >> c;
		v[mkp(p, c)].push_back(mkp(mkp(q, c), 0));
		v[mkp(q, c)].push_back(mkp(mkp(p, c), 0));
	}
	for (auto it = v.begin(); it != v.end(); ++it) {
		if (it->first.second != 0) {
			it->second.push_back(mkp(mkp(it->first.first, 0), 1));
			v[mkp(it->first.first, 0)].push_back(mkp(it->first, 0));
		}
	}
	mp[mkp(1, 0)] = 0;
	rep(v[mkp(1, 0)].size()) {
		Q.push(mkp(v[mkp(1, 0)][i].second, v[mkp(1, 0)][i].first));
	}
	while (!Q.empty()) {
		P Qsec = Q.top().second;
		int Qfst = Q.top().first;
		Q.pop();
		if (mp.find(Qsec)==mp.end()) {
			mp[Qsec] = Qfst;
			rep(v[Qsec].size()) {
				if (mp.find(v[Qsec][i].first)==mp.end()) {
					Q.push(mkp(Qfst + v[Qsec][i].second, v[Qsec][i].first));
				}
			}
		}
	}
	if (mp.find(mkp(n, 0)) == mp.end())cout << -1 << endl;
	else cout << mp[mkp(n, 0)] << endl;
	return 0;
}

Measured memory_bytes: 91192
N = int(input())
digits = ['3','5','7']
count = 0
ret = []
s = ''
def saiki(keta, moji):
    if keta == 0:
        return
    keta = keta - 1
    for d in digits:
        ret.append(moji+d)
        saiki(keta, moji+d)

saiki(11, s)
for i in ret:
    if '3' in i and '5' in i and '7' in i:
        if int(i) <= N:
            count += 1
print(count)


Measured memory_bytes: 22048
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
    string s;
    cin >> s;
    if (s == "Sunny") cout << "Cloudy" << endl;
    if (s == "Cloudy") cout << "Rainy" << endl;
    if (s == "Rainy") cout << "Sunny" << endl;
}


Measured memory_bytes: 256
A, B = map(int, input().split())

K = 50
G = [['#' if i < K else '.'] * (2 * K) for i in range(2 * K)]

A -= 1
for i in range(0, 2 * K, 2):
    for j in range(0, 2 * K, 2):
        if A > 0:
            G[i][j] = '.'
            A -= 1
        else:
            break

B -= 1
for i in range(2 * K - 1, -1, -2):
    for j in range(2 * K - 1, -1, -2):
        if B > 0:
            G[i][j] = '#'
            B -= 1
        else:
            break

print (2 * K, 2 * K)
for g in G:
    print (*g, sep = '')



Measured memory_bytes: 4468
import java.util.Scanner


object Main {
  val sc = new Scanner(System.in)

  def main(args: Array[String]): Unit = {
    val n = sc.nextInt
    val m = sc.nextInt

    val ab = Vector.fill(n)( (sc.nextLong, sc.nextLong) ).sorted
        .foldLeft(Vector.empty[(Long, Long, Long, Long)]){ case ( res, acc) =>
      val lo = res.lastOption.getOrElse((0L, 0L, 0L, 0L))
          res :+ (acc._1, acc._2, lo._3 + acc._2, lo._4 + acc._1 * acc._2)
        }

    val dataTuple = ab.find(_._3 >= m).get

    val result = dataTuple._4 - dataTuple._1 * ( dataTuple._3 - m)

//    println(ab)
//    println(dataTuple)
    println(result)
  }
}

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

int64_t gcd(int64_t a, int64_t m);
int main(void) {
    int64_t A, B, C;
    int64_t d;

    cin >> A >> B >> C;
    
    // Ax mod B = C
    d = gcd(A,B);
    if( d == 1) {
        cout << "YES\n";
    } else {
        if(C % d) {
            cout << "NO\n";
        } else {
            cout << "YES\n";
        }
    }

    return 0;
}
int64_t gcd(int64_t a, int64_t m) {
    int64_t tmp;
    int64_t r;

    if(a < m) {
        tmp = a;
        a = m;
        m = tmp;
    }

    r = a % m;
    while(r!=0) {
        a = m;
        m = r;
        r = a % m;
    }

    return m;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+100;
int n,k,q;
int a[maxn];
int main(){
	scanf("%d%d%d",&n,&k,&q);
	for(int i=1;i<=q;i++){
		int x;
		scanf("%d",&x);
		a[x]++;
	} 
	for(int i=1;i<=n;i++){
		int del=q-a[i];
		if(del>=k)puts("No");
		else puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
void Main()
{
    string S;
    cin >> S;

    vector<string> tokens = {
        "dream",
        "dreamer",
        "erase",
        "eraser",
    };

    while (S.size() > 0) {
        bool hit = false;
        rep(i, tokens.size()) {
            string t = tokens[i];
            if (S.size() >= t.size() && S.substr(S.size() - t.size(), t.size()) == t) {
                S = S.substr(0, S.size() - t.size());
                hit = true;
                break;
            }
        }
        if (!hit) {
            put("NO");
            return;
        }
    }

    put("YES")
}
signed main(){ Main();return 0;}

Measured memory_bytes: 3792
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int A,B;
    R(A,B);
    W(max(0,A-2*B));
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
using System.Threading;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		Console.WriteLine("{0}",sc.I^1);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 27332