akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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 gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	bool dotti = false;
	while (a > 0 && c > 0) {
		if (!dotti) {
			c -= b;
		}
		else {
			a -= d;
		}
		dotti ^= true;
	}
	puts((a > 0) ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    int sum = m,ans = m;
    bool flg = 0;
    for(int i = 0; i < n; i++){
        int a,b;
        cin >> a >> b;
        sum = sum + a - b;
        if(sum < 0){
            flg = 1;
        }
        ans = max(ans,sum);
    }
    if(flg)cout << 0 << endl;
    else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

ll x[20],y[20];
ll xx[20],yy[20];

void oresen(ll m,ll*x,ll*y){
	ll prex,prey;
	rep(i,0,m){
		ll tx,ty;
		scanf("%lld%lld",&tx,&ty);
		if(i){
			x[i]=tx-prex;
			y[i]=ty-prey;
		}
		prex=tx;
		prey=ty;
	}
}

int main(){
	ll n;
	while(scanf("%lld",&n),n){
		ll m;
		scanf("%lld",&m);
		oresen(m,x,y);
		rep(i,0,n){
			ll mm;
			scanf("%lld",&mm);
			oresen(mm,xx,yy);
			//(x,y),(-y,x),(-x,-y),(y,-x)
			ll ans=0;
			if(m==mm){
				ll flag;
				flag=1;rep(i,1,m)flag&=(x[i]==xx[i])&&(y[i]==yy[i]);ans|=flag;
				flag=1;rep(i,1,m)flag&=(x[i]==-yy[i])&&(y[i]==xx[i]);ans|=flag;
				flag=1;rep(i,1,m)flag&=(x[i]==-xx[i])&&(y[i]==-yy[i]);ans|=flag;
				flag=1;rep(i,1,m)flag&=(x[i]==yy[i])&&(y[i]==-xx[i]);ans|=flag;
				flag=1;rep(i,1,m)flag&=(-x[i]==xx[m-i])&&(-y[i]==yy[m-i]);ans|=flag;
				flag=1;rep(i,1,m)flag&=(-x[i]==-yy[m-i])&&(-y[i]==xx[m-i]);ans|=flag;
				flag=1;rep(i,1,m)flag&=(-x[i]==-xx[m-i])&&(-y[i]==-yy[m-i]);ans|=flag;
				flag=1;rep(i,1,m)flag&=(-x[i]==yy[m-i])&&(-y[i]==-xx[m-i]);ans|=flag;
				//rep(i,1,m)printf("%lld %lld %lld %lld\n",x[i],y[i],xx[i],yy[i]);
			}
			if(ans)printf("%lld\n",i+1);
		}
		puts("+++++");
	}
	return 0;
}


Measured memory_bytes: 2032
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	static int time;

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s[] = br.readLine().split(" ");
		int w = Integer.parseInt(s[0]);
		int h = Integer.parseInt(s[1]);
		int x = Integer.parseInt(s[2]);
		int y = Integer.parseInt(s[3]);
		int r = Integer.parseInt(s[4]);
		if (x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 24440
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    double A[n];
    REP(i,n) cin >> A[i];
    sort(A,A+n);
    double ans = 0.0;
    double tmp = 1.0;
    REPR(i,n-1){
        if(i == 0) break;
        tmp *= 2.0;
        ans += A[i] / tmp;
    }
    ans += A[0] / tmp;
    cout << fixed << setprecision(10) << ans << endl;

}

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

int main() {
  long x1,x2,x3,x4,x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
  if(x1==0) cout << 1 << endl;
  if(x2==0) cout << 2 << endl;
  if(x3==0) cout << 3 << endl;
  if(x4==0) cout << 4 << endl;
  if(x5==0) cout << 5 << endl;
}

Measured memory_bytes: 3620
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    vvint s(h,vint(w));
    REP(i,h){
        string si;
        cin >> si;
        REP(j,w){
            if(si[j]=='#'){
                s[i][j]=1;
            }else{
                s[i][j]=0;
            }
        }
    }
    
    int n = h*w;
    vvint d(n,vint(n,INF));
    vint field(n);
    REP(i,n){
        int y = i/w;
        int x = i%w;
        if(s[y][x]==1){
            field[i]=1;
            continue;
        }
        d[i][i]=0;
        field[i]=0;
        REP(j,4){
            if(x+dx[j]>=0&&x+dx[j]<w&&y+dy[j]>=0&&y+dy[j]<h){
                if(s[y+dy[j]][x+dx[j]]==0){
                    int next = w*(y+dy[j])+x+dx[j];
                    d[i][next]=1;
                    d[next][i]=1;
                }
            }
        }
    }
    REP(k,n){
        REP(i,n){
            REP(j,n){
                d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    int ans = 0;
    REP(i,n){
        REP(j,n){
            if(field[i]==0&&field[j]==0){
                ans = max(ans,d[i][j]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const ll MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;




int main(void){

    int ans=0;
    string s;
    cin>>s;
    rep(i,s.size()/2)if(s[i]!=s[s.size()-1-i])ans++;
    fin(ans);
}

Measured memory_bytes: 256
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        s: Chars
    };
    let l = s.iter().position(|&c| c == 'A').unwrap();
    let r = s.iter().rposition(|&c| c == 'Z').unwrap();
    println!("{}", 1 + r - l);
}


Measured memory_bytes: 3056
N, Ma, Mb = map(int, input().split())
dp = [[[10**18]*401 for _ in range(401)] for _ in range(N+1)]
dp[0][0][0] = 0

for i in range(N):
    a, b, c = map(int, input().split())
    
    for j in range(401):
        for k in range(401):
            dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k])
            
            if j+a<=400 and k+b<=400:
                dp[i+1][j+a][k+b] = min(dp[i+1][j+a][k+b], dp[i][j][k]+c)

ans = 10**18

for i in range(401):
    for j in range(401):
        if i>0 and j>0 and i*Mb==j*Ma:
            ans = min(ans, dp[N][i][j])

if ans==10**18:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 127268
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  for(int i=1;i<=n;i++){
    int x=i;
    if(x%3==0){
    cout << " " << i;
    }else{
      while(x!=0){
        if(x%10==3){
          cout << " " << i;
          break;
        }else{
          x=x/10;
        }
      }
    }
  }
  cout << endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long int
#define phi 1.6180339
#define rep(i,n) for(auto i=0;i<(n);i++)
#define endl "\n"
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define op1 cin.tie(NULL)
#define op2 cout.tie(NULL)
#define op3 std::ios_base::sync_with_stdio(false)
#define MAXX 1000001
using namespace std;
vector<int> arr(MAXX);
void trozen()
{
    int n;cin>>n;
    vector<int> v1(n);
    for(auto &i:v1) cin>>i;
    int j=1;
    int cnt=0;
    bool flag=false;
    for(int i=0;i<n;i++)
    {
        if(j==v1[i])
        {
            flag=true;
            cnt++;
            j++;
        }
    }
    int ans=n-cnt;
    if(flag)
        cout<<ans<<endl;
    else
        cout<<-1<<endl;
}
int32_t main()
{
    op1;op2;op3;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    trozen();
    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

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 (b<a) { a=b; return 1; } return 0; }

const ll INF=(ll)1e19;
//const int INF=(1<<30);

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

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

  VI a(n);
  REP(i,n)a[i]=i+1;

  int cnt=1;
  int ai,bi;
  do{
    bool ok=true;
    REP(i,n){
      if(a[i]!=p[i])ok=false;
    }
    if(ok)ai=cnt;

    ok = true;
    REP(i,n){
      if(a[i]!=q[i])ok=false;
    }
    if(ok)bi=cnt;
    cnt++;
  }while(next_permutation(ALL(a)));
  cout << abs(ai-bi) << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int H, W;
	int i,j;
    scanf("%d %d",&H,&W);
    (((H>=3)&&(H<=300))&&((W>=3)&&(W>=300)));
    while(!((H==0)&&(W==0)))
	{
		for (i = 1; i <= H; i++)
		{
			for ( j = 1; j <=W ; j++)
			{
				
					printf("#");
				
			}
			printf("\n");
		}
		printf("\n");
		scanf("%d %d",&H,&W);
	}	
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

#define EPS 1e-10
#define PB push_back

typedef double Type;

int sign(Type x)
{
    return x<-EPS?-1:(x>EPS?1:0);
}

struct Point
{
    Type x,y;
    Point(Type x,Type y):x(x),y(y) {}
    Point() {}
    void read()
    {
        scanf("%lf %lf",&x,&y);
    }
    bool operator==(const Point& p) const
    {
        return sign(x-p.x)==0&&sign(y-p.y)==0;
    }
    Point operator-(const Point& p) const
    {
        return Point(x-p.x,y-p.y);
    }
    Point operator*(const Type t) const
    {
        return Point(t*x,t*y);
    }
    Point operator+(const Point & p) const
    {
        return Point(x+p.x,y+p.y);
    }
    bool operator<(const Point& p) const
    {
        return sign(x-p.x)==0?sign(y-p.y)<0:sign(x-p.x)<0;
    }
};

ostream& operator<<(ostream& out,Point p)
{
    out<<p.x<<" "<<p.y;
    return out;
}

typedef Point Vector;

struct Line
{
    Point a,b;
    Line() {}
    Line(Point a,Point b):a(a),b(b) {}
};

typedef Line SegMent;

struct Polygon
{
    vector<Point> v;
};

//叉?
Type Cross(Vector a,Vector b)
{
    return a.x*b.y-a.y*b.x;
}

//点?
Type Dot(Vector a,Vector b)
{
    return a.x*b.x+a.y*b.y;
}

int contains(Polygon g, Point p)
{
    int sz=g.v.size();
    bool flag=false;
    for(int i=0; i<sz; i++)
    {
        Vector a=g.v[i]-p;
        Vector b=g.v[(i+1)%sz]-p;
        if(fabs(Cross(a,b))==0 && Dot(a,b)<EPS)
            return 1;   //点在多?形?上
        if(a.y>b.y)
            swap(a,b);
        if(a.y<EPS && b.y>EPS && Cross(a,b)>EPS)
            flag=!flag;
    }
    return flag?2:0;   //点在多?形内/点在多?形外
}

int main()
{
    int n;
    scanf("%d",&n);
    Polygon poly;
    for(int i=1; i<=n; i++)
    {
        Point temp;
        temp.read();
        poly.v.PB(temp);
    }
    int q;
    scanf("%d",&q);
    while(q--)
    {
        Point p;
        p.read();
        int ans=contains(poly,p);
        printf("%d\n",ans);
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    
    int maxv = -1e9;
    int minv;
    cin >> minv;
    
    for(int i = 1;i < n;i++){
        int r;
        cin >> r;
        maxv = max(maxv, r - minv);
        minv = min(minv, r);
    }
    cout << maxv << endl;
}


Measured memory_bytes: 3108
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <functional>
#include <iomanip>
using namespace std;

#define ll long long int

#define rep(p,q) for(int i = p; i < q;i++)


int main(void) {
	int week;
	cin >> week;
	int debt = 100000;
	rep(0, week) {
		debt = debt*1.05;
		if ((int)debt % 1000 != 0) {
			debt += 1000 - debt % 1000;
		}
		
	}
	cout << debt << endl;
}



Measured memory_bytes: 3104
def resolve():
    '''
    code here
    '''

    N = int(input())
    A_list = [int(item) for item in input().split()]

    if N >=2:
        prev_num = A_list[0]
        new_list = []
        prev_direction = 0
        cnt = 1
        for item in A_list[1:]:
            # print(item - prev_num)
            if item != prev_num:
                if prev_direction == 1:
                    if item - prev_num >= 0:
                        pass
                    else:
                        cnt += 1
                        prev_direction = 0
                elif prev_direction == -1:
                    if item - prev_num <= 0:
                        pass
                    else:
                        cnt += 1
                        prev_direction = 0
                else:
                    if item - prev_num > 0:
                        prev_direction = 1
                    elif item - prev_num < 0:
                        prev_direction = -1
    
            prev_num = item
    else:
        cnt = 1

    print(cnt)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 14436
#include <iostream>
using namespace std;
int main(){
	int i,l,H,W;
	for(;;){
		cin >> H >> W;
		if(H==0 && W ==0)return 0;
		for(i=0; i<H; i++){
				for(l=0; l<W; l++){
					//???????????????????????????????????????
					if(i==0 || i==H-1)
					{
						cout << "#";
					}
					//
					else if (i!=0 || i!=H-1)
					{
						if(l==0 || l==W-1){
							cout << "#";
						}
						else if(l!=0|| l!=W-1){
							cout << ".";
					}
				}		
			}	
			cout << endl;
		}
	cout << endl;
	}
	return 0;

}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int t = 1; 
    // cin >> t; 
    while (t--) {
        int n;
        cin >> n;
        int a[n], b[n];
        for(int i = 0; i < n; i++)
            cin >> a[i] >> b[i];
 
        sort(a, a + n);
        sort(b, b + n);
 
        int ma, mb;
        if(n % 2) {
            ma = a[n / 2];
            mb = b[n / 2];
        }
        else {
            ma = a[n / 2] + a[(n - 1) / 2];
            mb = b[n / 2] + b[(n - 1) / 2];
        }
 
        cout << mb - ma + 1 << '\n';
    }
    return 0;
}

Measured memory_bytes: 6756
//chiragjn
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define gibe_de_fast_io_b0ss ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const ll mod = 1e9 + 7;
const ll INF = 0x7FFFFFFFFFFFFFFF/2;
int main(){
    gibe_de_fast_io_b0ss;
    unsigned int n, m;
    cin>>n>>m;
    vector<string> arr(n);
    for(int i = 0; i < n; i++) {
    	cin>>arr[i];
    }
    
    ll cache[n][m] = {};
    cache[0][0] = 1LL;
    for(int i = 0; i < n; i++) {
    	for(int j = 0; j < m; j++) {
    		if(arr[i][j] == '#') continue;
    		if(i > 0) cache[i][j] = (cache[i][j] + cache[i - 1][j]) % mod;
    		if(j > 0) cache[i][j] = (cache[i][j] + cache[i][j - 1]) % mod;
    		
    	}
    }
    cout<<cache[n - 1][m - 1];
    return 0;
}


Measured memory_bytes: 9088
#include <iostream>
#include <vector>

using namespace std;

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

Measured memory_bytes: 256
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan =new Scanner(System.in);
    		
    		char[] s=scan.next().toCharArray();
    		int ans =700;
    		for (char i:s) {
    			if (i=='o') {
    				ans+=100;
    			}
    		}
    		System.out.print(ans);


    		
     
    }
    }
// end 

Measured memory_bytes: 22228
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements < num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define int long long int
//Binary_Search->dp->greedy
//auto check = [&](ll x){};
void solve(){
	string s;
	cin>>s;
	if(s[0]=='7' || s[1]=='7' || s[2]=='7') cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
 
}
int main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
return 0;
}    
 

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

typedef long long ll;
vector<bool> prime(1000005,true);
vector<ll> primes;
vector<ll> lcm(1000005,0);
ll mod=1e9+7;

ll power(ll n, ll k)
{
	if(k==0)
		return 1LL;
	if(k==1)
		return n;
// 	cout<<"n^k = "<<n<<" "<<k<<endl;
	ll ans=power(n,k/2);
	if(k&1)
		return (((ans*ans)%mod)*n)%mod;
	return (ans*ans)%mod;
}
void seive()
{
	prime[0]=prime[1]=false;
	for(int i=2;i*i<=1000005;i++)
	{
		if(prime[i])
			for(int j=i*2;j<=1000005;j+=i)
				prime[j]=false;
	}
	for(int i=2;i<=1000005;i++)
		if(prime[i])
			primes.push_back(i);
}

void factorize(ll n)
{
// 	cout<<n<<endl;
	unordered_map<ll,ll> m;
	while(n%2==0)
	{
		m[2]++;
		n/=2;
	}
	for(ll i=3;i*i<=n;i+=2)
	{
		if(n%i==0)
		{
			while(n%i==0)
			{
				m[i]++;
				n/=i;
			}
		}
	}
	if(n>2)
		m[n]++;
	for(auto i:m)
	{
		lcm[i.first]=max(lcm[i.first],i.second);
// 		cout<<i.first<<" "<<lcm[i.first]<<endl;
	}
}

int main()
{
	seive();
	ll n;
	cin>>n;
// 	cout<<n<<endl;
	ll a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
// 		cout<<a[i]<<endl;
		factorize(a[i]);
	}
// 	for(int i=0;i<10;i++)
// 		cout<<primes[i]<<" ";
// 	cout<<endl;
// 	for(int i=2;i<=5;i++)
// 		cout<<lcm[i]<<" ";
// 	cout<<endl;
	ll ans=0,l=1;
	for(ll i=2;i<=1000000;i++)
	    if(lcm[i]>0)
		    l=(l*power(i,lcm[i]))%mod;
// 	cout<<l<<endl;
	for(ll i=0;i<n;i++)
	{
	   // cout<<power(a[i],1000000005)<<endl;
	   // cout<<a[i]<<" "<<mod-2<<endl;
	    ans=(ans+(l*power(a[i],mod-2))%mod)%mod;
	   // cout<<ans<<endl;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 9336
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
const double eps=1e-10;
using namespace std;
const int MOD=1000000007;
const int INF=9000000009;

signed main(){
  int n;
  cin>>n;
  while(n--){
    double x1,y1,x2,y2,x3,y3,x4,y4;
    cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
    cout<<(abs((y2-y1)*(x4-x3)-(y4-y3)*(x2-x1))<eps?"YES":"NO")<<endl;
  }
  return 0;
}



Measured memory_bytes: 3112
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String n = sc.next();
    int d = sc.nextInt();
    long MOD = (long)Math.pow(10, 9) + 7;
    int len = n.length();
    long[][][] dp = new long[len][2][d];
    int first = Integer.parseInt(String.valueOf(n.charAt(0)));
    for(int i = 0; i < first; i++) {
      dp[0][1][(i % d)]++; 
    }
    first %= d;
    dp[0][0][first]++;
    int sum = first;
    for(int i = 1; i < len; i++) {
      int k = Integer.parseInt(String.valueOf(n.charAt(i)));
      int s = sum;
      sum = (sum + k) % d;
      dp[i][0][sum] = 1;
      for(int j = 0; j < k; j++) {
        dp[i][1][(s + j) % d] = (dp[i][1][(s + j) % d] + dp[i - 1][0][s]) % MOD;
      }
      for(int j = 0; j < 10; j++) {
        for(int l = 0; l < d; l++) {
          dp[i][1][(l + j) % d] = (dp[i][1][(l + j) % d] + dp[i - 1][1][l]) % MOD;
        }
      }
    }
    System.out.println((dp[len - 1][0][0] + dp[len - 1][1][0] + MOD - 1) % MOD);
  }
}

Measured memory_bytes: 56532
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
	int i,j;
	int k,a,b;
	cin>>k;
	a=k/2;
	b=(k+1)/2;
	cout<<a*b<<endl;
	return 0;
}

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

int main(){
  string a;
  cin >> a;
  
  if(a.at(0) == a.at(1) && a.at(1) == a.at(2) || a.at(1) == a.at(2) && a.at(2) == a.at(3)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a==b && a!=c){
        printf("Yes");

    }
    else if(b==c && c!=a){
        printf("Yes");

    }
    else if(a==c && c!=b){
        printf("Yes");
    }
    else{
        printf("No");
    }

}

Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
    int i, j, H, W;
    
    while (1) {
        scanf("%d %d", &H, &W);
        
        if ( H == 0 && W == 0)
            break;
        for ( i=0; i<H; ++i) {
            for ( j=0; j<W; ++j) {
                if ( (i+j)%2 == 0)
                    putchar('#');
                else
                    putchar('.');
            }
            putchar('\n');
        }
        putchar('\n');
    }
}


Measured memory_bytes: 2052
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

ll N;
ll A[100000];

template <typename T>
T gcd(T a, T b){
    if(a < b) swap(a, b);
    while(b != 0){
        T tmp = b;
        b = a%b;
        a = tmp;
    }
    return a;
}

ll cntOdd(){
    ll ans  = 0;
    for(ll i = 0; i < N; i++){
        if(A[i]%2 == 1) ans++;
    }
    return ans;
}

ll cntRem(){
    ll ans  = 0;
    for(ll i = 0; i < N; i++){
        ans += (A[i]-1);
    }
    return ans;
}

ll gcd_all(){
    ll ans = gcd<ll>(A[0], A[1]);
    for(ll i = 2; i < N; i++){
        ans = gcd<ll>(ans, A[i]);
    }
    return ans;
}

ll oddIdx(){
    for(ll i = 0; i < N; i++){
        if(A[i]%2 == 1)return i;
    }
}

void process(){
    ll g = gcd_all();
    for(ll i = 0; i < N; i++) A[i] /= g;
}

bool oneExists(){
    for(ll i = 0; i < N; i++){
        if(A[i] == 1) return true;
    }
    return false;
}

string ans;

void judge(ll cur){
    // cout << "judge()" << endl;
    // for(ll i = 0; i < N; i++) cout << A[i] << ' ';
    // cout << endl;
    ll rem = cntRem();
    if(oneExists()){
        if(rem%2 == 1){
            ans = cur == 0 ? "First" : "Second";
        }else{
            ans = cur == 0 ? "Second" : "First";
            return;
        }
    }
    if(rem%2 == 1){
        ans = cur == 0 ? "First" : "Second";
        return;
    }
    if(cntOdd() >= 2){
        ans = cur == 0 ? "Second" : "First";
        return;
    }
    ll idx = oddIdx();
    A[idx]--;
    process();
    judge(cur^1);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(ll i = 0; i < N; i++) cin >> A[i];
    if(N == 1) {
        if(A[0] == 1){
            cout << "Second" << endl;
        }else{
            cout << "First" << endl;
        }
        return 0;
    }
    judge(0);
    cout << ans << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int x; cin >> x;
	if(x == 0) cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}


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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

x = I()
ans = (x // 500) * 1000
x %= 500
ans += x // 5 * 5
print(ans)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
vector<int>a[100009];
bool cmp(vector<int>x,vector<int>y) {
	for(int i=0;i<26;i++)
		if(x[i]!=y[i])
			return x[i]<y[i];
	return 0;
}
bool deng(vector<int>x,vector<int>y) {
	for(int i=0;i<26;i++)
		if(x[i]!=y[i])
			return 0;
	return 1;
}
int main() {
	int n;
	cin>>n;
	string s;
	for(int i=0;i<n;i++) {
		cin>>s;
		a[i].resize(26);
		for(int j=0;j<10;j++) a[i][s[j]-'a']++;
	}
	sort(a,a+n,cmp);
	long long ans=0;
	for(int i=0;i<n;) {
		int j=i+1;
		while(j<n&&deng(a[i],a[j])) j++;
		ans+=1ll*(j-i)*(j-i-1)/2;
		i=j;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 13568
/***** author :  C0d1ngPhenomena *****/

#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define TestCases int T; cin>>T; while(T--)
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define revrep(i,a,b) for(ll i = b-1; i >= a; i--)
#define vll vector<ll>
#define vvll vector < vll >
#define pll pair<ll, ll>
#define vpll vector <pll>
#define mp(x,y) make_pair(x,y)
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define alld(c) c.begin(),c.end(),greater<int>()
#define mem(a,val) memset(a,val,sizeof(a))
#define f first
#define s second
#define pb push_back
using namespace std;

bool poss(ll T, ll N, ll K, vll A, vll F)
{
	ll sum = 0;

	rep(i, 0, N)
	{
		if (A[i] * F[i] > T)
		{
			sum += A[i] - T / F[i];
		}
	}

	return sum <= K;
}

int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	ll n, k;
	cin >> n >> k;
	vll A(n), F(n);

	rep(i, 0, n)
		cin >> A[i];

	rep(i, 0, n)
		cin >> F[i];

	sort(all(A));
	sort(all(F));
	reverse(all(F));

	ll lo = 0, hi = 1000000000010;

	rep(i, 0, 50)
	{

		ll mid = (lo + hi) / 2;
		if (poss(mid, n, k , A, F))
		{
			hi = mid;
		}
		else
		{
			lo = mid + 1;
		}
	}

	if (poss(min(hi, lo), n , k, A, F))
	{
		cout << min(hi, lo) << endl;
	}
	else
	{
		cout << max(hi, lo) << endl;
	}

	return 0;
}




Measured memory_bytes: 9532
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC042_D
{
    class Program
    {      
        static void Main(string[] args)
        {
            var a = scan();
            maketable(a[0], a[1]);
            long ans = 0;
            for (long i =a[3]; i < a[1]; i++)
            {
                long ue = getC(a[0] - a[2] - 1, i);
                long shita = getC(a[2]-1,a[1]-i-1);             
                ans += ue * shita;
                ans %= q;
            }
            Console.WriteLine(ans);
        }

        const int q = 1000000007;
        static long[] t = new long[200000];
        static long[] s = new long[200000];

        
        //(a+b)!/a!b!｛a+bCa｝を計算
        static long getC(long a,long b)
        {
            return(((t[a+b]*s[a])% q)*s[b])%q;           
        }
        
        // x! と(x!)^-1をtableにしたいです。
        static void maketable(long H,long W)
        {
            t[0] = 1;
            s[0] = 1;
            t[1] = 1;
            s[1] = 1;
            for (long i = 2; i < H+W-1; i++)
            {
                t[i] = i*t[i - 1];
                t[i] %= q;         
            }
            s[H + W - 2] = powmod(t[H + W - 2],q-2, q);
            for (long i = H+W-2 ; i > 2; i--)
            {
                s[i-1] = (s[i] * (i)) % q;
            }
        }
       
        //a^b(modq)
        static long powmod(long a, long b, long p)
        {
            if (b == 0) return 1;
            if (b % 2 == 0)
            {
                long d = powmod(a, b / 2, p);
                return (d * d) % p;
            }
            else return (a * powmod(a, b - 1, p)) % p;         
        }

        static long[] scan()
        {
            return
               Console.ReadLine().Split(' ')
               .Select(i => long.Parse(i)).ToArray();
        }
    }

}


Measured memory_bytes: 5976
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,s=0;
  cin>>n;
  vector<int> l(n);
  for(i=0;i<n;i++) cin>>l.at(i);
  sort(l.begin(),l.end());
  for(i=0;i<n-1;i++) s+=l.at(i);
  if(l.at(n-1)<s) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3568
n,m,l = gets.split(" ").map(&:to_i)
b = readlines.map{|i| i.chomp.split.map(&:to_i)}
a = b.slice!(0,n)
n.times do |i|
  l.times do |j|
    c = 0
    m.times do |k|
      c += a[i][k]*b[k][j]
    end
    print c
    print ' ' if (j < (l-1))
  end
  puts
end

Measured memory_bytes: 9140
m,d=map(int,input().split())
count=0
for i in range(1,m+1,1):
  for j in range(22,d+1,1):
    j10=j//10
    j1=j%10
    if j1<2:
      continue
    if j10*j1 == i:
      count=count+1
print(count)

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

int main()
{
int H,N;
cin >> H >> N;
vector<int> A(N);
for(int i=0; i<N; i++)
{
  cin >> A.at(i);
}
int sum=0;
for(int i=0; i<N; i++)
{
  sum+=A.at(i);
}
if(sum>=H)
{
  cout << "Yes" <<endl;
}
else
{
  cout << "No" <<endl;
}
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>

#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif

#define pb push_back
#define mp make_pair
#define FOR(i, A, N) for(int (i) = (A); (i) < (N); (i)++)
#define REP(i, N) for(int (i) = 0; (i) < (N); (i)++)

using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

int n,m;
ll X[111], Y[111];

int main() {
	scanf("%d", &n);
	REP(i, n) {
		scanf("%lld %lld", X+i, Y+i);
	}
	long double best = 0;
	int steps = 100000;
	for(int ang = 0; ang < steps; ang++) {
		long double piang = 2*M_PI*ang/steps;
		long double XA = cosl(piang);
		long double XB = sinl(piang);
		long double sumx = 0, sumy = 0;
		REP(j, n) {
			if(XA*X[j]+XB*Y[j] > 0) {
				sumx += X[j];
				sumy += Y[j];
			}
		}
		best = max(best, sqrtl(sumx*sumx+sumy*sumy));
	}
	printf("%.12lf\n", (double)best);


	return 0;
}


Measured memory_bytes: 512
A, B = map(int, input().split())
def gcd(a,b):
    x = max(a, b)
    y = min(a, b)
    if x%y == 0:
        return y
    else:
        while x%y !=0:
            z =x%y
            x =y
            y =z
        else:
            return z

def lcm(a, b):
    return int((a * b) // gcd(a, b))

ans = lcm(A, B)
print(ans)


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

int main() {
  int64_t r,c,k;
  cin >> r >> c >> k;
  vector<vector<int64_t>> C(k, vector<int64_t>(3, 0));
  for (int i = 0; i < k; i++)
  {
    for (int j = 0; j < 3; j++){
      cin >> C[i][j];
    }
  }
  vector<vector<int64_t>> I(r, vector<int64_t>(c, 0));
  for (int i = 0; i < k; i++) {
      I[C[i][0]-1][C[i][1]-1] = C[i][2];
  }

  vector<vector<vector<int64_t>>> D(r, vector<vector<int64_t>>(c, vector<int64_t>(4, 0)));
  int64_t aa = 0;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      for (int l = 0; l < 4; l++) {
        aa = 0;
        if (l==0) {
          if (i-1 >= 0){
            aa = max(aa,max(D[i-1][j][0],max(D[i-1][j][1],max(D[i-1][j][2],D[i-1][j][3]))));
          }
          if (j-1 >= 0){
            aa = max(aa,D[i][j-1][0]);
          }
        }
        else {
          if (i-1 >= 0){
            aa = max(aa, max(D[i-1][j][0],max(D[i-1][j][1],max(D[i-1][j][2],D[i-1][j][3]))) + I[i][j]);
          } 
          else {
            aa = max(aa, I[i][j]);
          }
          if (j-1 >= 0){
            aa = max(aa,max(D[i][j-1][l-1] + I[i][j], D[i][j-1][l]));
          }
          else {
            aa = max(aa,0 + I[i][j]);
          }
          }
        D[i][j][l] = max(D[i][j][l],aa);
      }
    }
  }
  int64_t ans=0;
  for (int i = 0; i < 4; i++)
  {
  ans = max(D[r-1][c-1][i],ans);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1016740
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int a, b, t;
  cin >> a >> b >> t;
  cout << t/a * b << endl;

  return 0;
}



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

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

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const long long llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,m,x,y,c,i,nxt,cs,dist[nmax];
vector<pair<int,int> >a[nmax];
set<int>d[nmax];
priority_queue<pair<int,int> >s;
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>n>>m;
    for(i=2;i<=n;i++)dist[i]=inf;
    for(i=1;i<=m;i++)
	{
		cin>>x>>y>>c;
		a[x].pb(make_pair(y,c));
		a[y].pb(make_pair(x,c));
	}
	s.push({0,1});
	while(s.size())
	{
		nxt=s.top().sc;
		cs=-s.top().fr;
		s.pop();
		if(dist[nxt]<cs)continue;
		for(i=0;i<a[nxt].size();i++)
		{
			int tmp=dist[nxt];
			if(!d[nxt].count(a[nxt][i].sc))tmp++;
			if(tmp<dist[a[nxt][i].fr])
			{
				dist[a[nxt][i].fr]=tmp;
				d[a[nxt][i].fr].clear();
				d[a[nxt][i].fr].in(a[nxt][i].sc);
				s.push({-dist[a[nxt][i].fr],a[nxt][i].fr});
			}
			else if(tmp==dist[a[nxt][i].fr])d[a[nxt][i].fr].in(a[nxt][i].sc);
		}
	}
	if(dist[n]==inf)cout<<-1<<endl;
	else cout<<dist[n]<<endl;
	return 0;
}

Measured memory_bytes: 23412
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;

struct UnionFind{
    vector<int> parent;
    vector<int> rank; // tree's depth

    UnionFind(int n){
        parent.resize(n);
        rank.resize(n);
        init(n);
    }

    // initialize
    void init(int n){
        for(int i = 0; i < n; i++){
            parent[i] = i;
            rank[i] = 0;
        }
    }
    // find root
    int find(int x){
        if(parent[x] == x){
            return x;
        }else{
            return parent[x] = find(parent[x]);
        }
    }

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;

        if(rank[x] < rank[y]){
            parent[x] = y;
        }else{
            parent[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }
};

int main(){
    int n, m; cin >> n >> m;
    vector<int> p(n);
    rep(i, n){
        cin >> p[i];
        p[i]--;
    }
    UnionFind UF(n);
    rep(i, m){
        int x, y; cin >> x >> y;
        x--, y--;
        UF.unite(x, y);
    }
    int ans = 0;
    rep(i, n){
        if(UF.find(p[i]) == UF.find(i)) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4516
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
int a,b,c,x;
inline int read(){
	int x=0;bool f=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=!f;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return f?-x:x;
}

int main(){
	a=read(),b=read(),c=read(),x=read();
	int sum=0;
	for(int i=0;i<=a;++i){
		for(int j=0;j<=b;++j){
			for(int k=0;k<=c;++k){
				if(500*i+100*j+50*k==x) sum++;
			}
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(false);cin.tie(nullptr);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    in ans=0;
    REP(i,1,n+1){
        int x=n/i;
        if(n%i==0) x --;
        ans += x;
    }
    cout<<ans<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 3648
let N = Int(readLine()!)!
var ans = "Yes"
var preT = 0
var preX = 0
var preY = 0
for _ in 0..<N {
    let input = readLine()!.characters.split(" ").map{Int(String($0))!}
    let (t, x, y) = (input[0], input[1], input[2])
    let dist = abs(x - preX) + abs(y - preY)
    let time = t - preT
    let overTime = time - dist
    if overTime < 0 || overTime % 2 > 0 {
        ans = "No"
    }
    preT = t
    preX = x
    preY = y
}
print(ans)

Measured memory_bytes: 4080
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
// #define debug
// #define TRACE(x)

using namespace std;

typedef long long llint;

const int MAXN = 510;
const int INF = 1e9;

int n, cr[MAXN], cc[MAXN], tot, idx[MAXN];
char a[MAXN][MAXN], b[MAXN][MAXN], tmp[MAXN][MAXN];

void apply(int row, int col) {
  REP(i, n) b[row][i] = a[row][i];
  REP(i, n) a[i][col] = b[row][i];
}

bool full_col(int c) {
  REP(i, n) if (a[i][c] != '#') return false;
  return true;
}

int main(void) {
  scanf("%d",&n);
  REP(i, n) {
    scanf("%s",a[i]);
    REP(j, n) tmp[i][j] = a[i][j];
  }
 
  REP(i, n) REP(j, n) 
    if (a[i][j] == '#') 
      ++tot;

  if (tot == 0) {
    printf("-1\n");
    return 0;
  }

  int sol = INF;

  REP(i, n) {
    REP(r, n) REP(c, n) a[r][c] = tmp[r][c];
    
    int my = 0;
    bool imac = 0;
    REP(row, n)
      if (a[row][i] == '#')
	imac = true;

    if (!imac)
      ++my;

    REP(j, n)
      if (a[i][j] == '.') {
	++my;
	apply(i, j);
      }
    
    REP(col, n)
      if (!full_col(col))
	++my;

    sol = min(sol, my);
  }

  printf("%d\n",sol);
  
  return 0;
}


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

int main(void) {
    string q;
    int a, b;
    stack<int> s;
    
    while(cin >> q) {
        if (q[0] == '*') {
            a = s.top(); s.pop();
            b = s.top(); s.pop();
            s.push(a * b);
        }
        else if (q[0] == '+') {
            a = s.top(); s.pop();
            b = s.top(); s.pop();
            s.push(a + b);
        }
        else if (q[0] == '-') {
            a = s.top(); s.pop();
            b = s.top(); s.pop();
            s.push(b - a);
        }
        else {
            a = atoi(q.c_str());
            s.push(a);
        }
    }

    cout << s.top() << endl;

    return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    int n;
    cin >> n;
    vector<int> ans(n);
    rep(i,1,n+1){
        int a = i*2;
        int first,second,third;
        rep(j,2,sqrt(a)+1){
            int a = i*2;
            a -= j*j;
            first=j;
            rep(k,2,sqrt(a)+1){
                second=k;
                a-= k*k;               
                double left = sqrt(a);
                if(left/1==int(left)){
                    //cout<<a<<endl;
                    if(left<2){
                        continue;
                    }else{
                        third = left;
                        int x,y,z;
                        if((first+second+third)%2==1){
                            continue;
                        }else{
                            int s=(first+second+third)/2;
                            x = s-first;
                            y = s-second;
                            z = s-third;
                            if(x>0&&y>0&&z>0){
                                ans[i-1]++;
                            }
                        }
                        //cout<<i<<first<<second<<third<<endl;
                    }
                    
                }
                a+=k*k;
            }
            a+=j*j;
        }
    }
    rep(i,0,n){
        cout<<ans[i]<<endl;
    }
    
  return 0;
}

Measured memory_bytes: 3640