akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<bitset> 
#include<unordered_map> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include "boost/algorithm/string.hpp"
// RAJJI KI MEHER 
#define fio ios_base::sync_with_stdio(false)
//#define mod 1000000007
#define mod1 mod
#define mod2 100000009
#define li long long int
#define ll int
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define readi(x) scanf("%d",&x)
#define  reads(x)  scanf("%s", x)
#define readl(x) scanf("%lld",&x)
#define rep(i,n) for(i=0;i<n;i++)
#define revp(i,n) for(i=(n-1);i>=0;i--)
#define myrep1(i,a,b) for(i=a;i<=b;i++)
#define myrep2(i,a,b) for(i=b;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define MAXN 100000000000000005
#define MINN -10000000000000000
#define INTMAX 1000001000
#define pii pair<li,li>
#define pdd pair<double,double>
#define pic pair<int,char>
//#define N 5005
#define lgn 20
#define ddouble long double
#define minus minu
#define PI 3.1415926535
#define lgn 20
using namespace std;
vector<double>a(3005);li n;
double A[3005][2005];
li AA[3005][2005];
double ff(li i,li Hn){double z=1;
    if(i>=n){if(Hn>(n-Hn)) return(z);
    z=0;return(z);}
    if(AA[i][Hn]!=-1) return(A[i][Hn]);
if(Hn>(n-Hn)){AA[i][Hn]=0;A[i][Hn]=1;return(A[i][Hn]);}
else if((i-Hn)>(n-i+Hn)){AA[i][Hn]=0;A[i][Hn]=0;return(A[i][Hn]);} 
double ans=a[i]*ff(i+1,Hn+1)+(z-a[i])*ff(i+1,Hn);
AA[i][Hn]=0;A[i][Hn]=ans;return(ans);   
}
int main(){readl(n);memset(AA,-1,sizeof(AA));li i;
for(i=0;i<n;i++) cin>>a[i];
double ans=ff(0,0);
printf("%.10lf",ans);    
}

Measured memory_bytes: 93056
def main():
    temp=input().split(" ")
    n=int(temp[0])
    a=int(temp[1])
    b=int(temp[2])
    sa=abs(a-b)
    if sa%2==1:
        print("Borys")
    else:
        print("Alice")
if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
using namespace std;
inline int read(){
	int v=0,f=1;
	char c=getchar();
	while (c<'0' || c>'9'){
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9'){
		v=v*10+c-'0';
		c=getchar();
	}
	return v*f;
}
const int Maxn=105;
int n,m;
char c[Maxn][Maxn];
int dp[Maxn][Maxn];
int main(){
	scanf("%d %d",&n,&m);
	for (int i=1;i<=n;i++){
		scanf("%s",c[i]+1);
	}
	for (int i=0;i<Maxn;i++) for (int j=0;j<Maxn;j++) dp[i][j]=1e9;
	dp[1][1]=(c[1][1]=='.')?0:1;
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			if (i+j==2) continue;
			dp[i][j]=min(dp[i][j],dp[i-1][j]+(c[i-1][j]!=c[i][j]));
			dp[i][j]=min(dp[i][j],dp[i][j-1]+(c[i][j-1]!=c[i][j]));
		}
	}
	int ans=(dp[n][m]+1)/2;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<locale>

int main(){
    
    int n, k;
    std::string s;

    std::cin >> n >> k >> s;

    s.at(k - 1) = std::tolower(s.at(k - 1));

    std::cout << s << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
n=int(input())
s=list(input())
dic={"A":0,"B":1,"C":2,"D":3,"E":4,"F":5,"G":6,"H":7,"I":8,"J":9,"K":10,"L":11,"M":12,"N":13,"O":14,"P":15,"Q":16,"R":17,"S":18,"T":19,"U":20,"V":21,"W":22,"X":23,"Y":24,"Z":25}
di={1:"A",2:"B",3:"C",4:"D",5:"E",6:"F",7:"G",8:"H",9:"I",10:"J",11:"K",12:"L",13:"M",14:"N",15:"O",16:"P",17:"Q",18:"R",19:"S",20:"T",21:"U",22:"V",23:"W",24:"X",25:"Y",26:"Z"}
li=[]
t=len(s)
for i in range(0,t):
  k=s[i]
  m=dic[k]
  a=(m+n)%26+1
  b=di[a]
  li.append(b)
print("".join(li))

Measured memory_bytes: 3316
using System;

class Program
{
    static void Main(string[] args)
    {
        //変数定義
        string[] input0;
          int n;
        int m;

        //Inputします
        input0 = Console.ReadLine().Split(' ');
        n = int.Parse(input0[0]);
        m = int.Parse(input0[1]);
        bool[] kind = new bool[m];
        for(int a = 0; a < m; a++)
        {
            kind[a] = true;
        }

        for (int i = 0; i < n; i++)
        {
            string[] input1= Console.ReadLine().Split(' ');
            int k = int.Parse(input1[0]);
            int[] like = new int[k];
            for(int b=0;b<k;b++)
            {
                like[b]=int.Parse(input1[b + 1]) - 1;
            }
            Array.Sort(like);
            for(int c = 0; c < m; c++)
            {
                int d = Array.IndexOf(like, c);
                if (d == -1)
                    kind[c] = false;
            }
        }

        Array.Sort(kind);
        Array.Reverse(kind);
        


        //Outputします
        Console.WriteLine(Array.LastIndexOf(kind,true) + 1);
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int n,w,a[1000],b[1000];
long long f[102][100002];
int main(){
	int s=0;
	cin>>n>>w;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
		s+=b[i];
	}
	for(int i=0;i<=n;i++){
		for(int j=1;j<=s;j++)
			f[i][j]=10000000001;
	}
	for(int i=0;i<=n;i++){
		f[i][0]=0;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=s;j++){
			f[i][j]=f[i-1][j];
			if((j>=b[i])&&(f[i-1][j-b[i]]!=10000000001)){
				f[i][j]=min(f[i][j],f[i-1][j-b[i]]+a[i]);
			}
			
		}
	}
	//cout<<f[n][17]<<endl;
	
		for(int j=s;j>=1;j--){
			if(f[n][j]<=w){
				cout<<j;
				return 0;
			}
		}
	cout<<0;
}

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


int main(){
	int N, R;
	cin >> N >> R;
	if(N>=10) {
		cout << R << endl;
		return 0;
	}
	else {
		cout << R + 100 * (10 - N) << endl;
		return 0;
	}
}












Measured memory_bytes: 3596
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<pair<int, int>> train(M), query(Q);
    for (int i = 0; i < M; i++) {
        int l, r;
        cin >> l >> r;
        train[i] = make_pair(l-1, r-1);
    }
    for (int i = 0; i < Q; i++) {
        int p, q;
        cin >> p >> q;
        query[i] = make_pair(p-1, q-1);
    }
    int d1[500][500] = {};
    int d2[500][500] = {};
    for (auto p : train) {
        d1[p.first][p.second]++;
    }
    for (int i = 0; i < 500; i++) {
        int sum = 0;
        for (int j = 0; j < 500; j++) {
            sum += d1[i][j];
            d2[i][j] = sum;
        }
    }
    for (auto p : query) {
        int sum = 0;
        for (int i = p.first; i <= p.second; i++) {
            sum += d2[i][p.second] - d2[i][p.first] + d1[i][p.first];
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <string>
#include <vector>
#include <queue>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto&& i : a){
        cin >> i;
    }
    priority_queue<int> b;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            b.push(a[i] * a[j]);
        }
    }
    while(b.size()){
        int num = b.top();
        b.pop();
        string str = to_string(num);
        bool check = true;
        for(int i = 1; i < str.size(); i++){
            if(str[i] - str[i - 1] != 1){
                check = false;
                break;
            }
        }
        if(check){
            cout << str << "\n";
            return 0;
        }
    }
    cout << "-1\n";
}


Measured memory_bytes: 4984
from collections import deque
from sys import maxint
dist = [maxint]*100005
K = int(raw_input())
Q = deque()
dist[1] = 0
Q.append(1)
while Q :
    cur = Q.popleft()
    n1 = (cur + 1)%K
    n2 = (cur * 10)%K
    if dist[cur] + 1 < dist[n1] :
        dist[n1] = dist[cur] + 1
        Q.append(n1)
    if dist[cur] < dist[n2]:
        dist[n2] = dist[cur]
        Q.appendleft(n2)

print dist[0] + 1

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

int main(){

  int n, k, a;
  int d[11] = {};

  cin >> n >> k;
  for(int i = 0; i < k; i++){
    cin >> a;
    d[a]++;
  }
  while(1){
    int num = n;
    bool flag = true;
    while(num){
      if(d[num%10]){
        flag = false;
        break;
      }
      num /= 10;
    }
    if(flag){
      cout << n << endl;
      return 0;
    }
    n++;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
using namespace std;
#define l long long
#define pb push_back
#define mem(a,n) memset(a,n,sizeof(a))
#define find(v,n) find(v.begin(),v.end(),n)
#define sort1(v) sort(v.begin(),v.end())
#define lb(v,n) lower_bound(v.begin(),v.end(),n)-v.begin()
#define ub(v,n) upper_bound(v.begin(),v.end(),n)-v.begin()
#define mod 1000000007
#define reverse(s) reverse(s.begin(),s.end())
//#define pi pair<l,l> 
const double pi=3.141592653589793;
bool isprime(l n)
{
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
			return false;
	}
	return true;
}
/*bool fact(l n)
{
	vector<l> v;
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			if(i%2==1||(n/i)%2==1)
			{
				return true;
			}
		}
	}
	return false;
}*/
l power(l a,l b)
{
	l ans=1;
	while(b>0)
	{
		if(b&1)
		{
			ans=(ans*a);
		}
		b>>=1;
		a=(a*a);
	}
	return ans;
}//prefixsums
void frooty()
{
	l n,k;
	cin>>n>>k;
	vector<l> v;
	for(l i=0;i<n;i++)
	{
		l a;
		cin>>a;
		v.pb(a);
	}
	for(l i=k;i<n;i++)
	{
		if(v[i]>v[i-k])
		{
			cout<<"Yes"<<"\n";
		}
		else
			cout<<"No"<<"\n";
		//pro=((pro/v[i-k])*v[i])%mod;
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int q=1;
	//cin>>q;
	while(q--)
	{
		frooty();
	}
}

Measured memory_bytes: 5324
# -*- coding: utf-8 -*-
import sys
from operator import itemgetter
from fractions import gcd
from math import ceil, floor, sqrt
from copy import deepcopy
from collections import Counter, deque
import heapq
from functools import reduce
sys.setrecursionlimit(200000)
# local only
# if not __debug__:
#     fin = open('in_1.txt', 'r')
#     sys.stdin = fin
# local only
# input = sys.stdin.readline
# def ii(): return int(input())
# def mi(): return map(int, input().rstrip().split())
# def lmi(): return list(map(int, input().rstrip().split()))
# def fi(): return float(input())
# def mfi(): return map(float, input().rstrip().split())
# def lmfi(): return list(map(float, input().rstrip().split()))
# def li(): return list(input().rstrip())
# def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
# def exit(*arg): print(*arg); sys.exit()
# template


def main():
    a = ["Sunny", "Cloudy", "Rainy"]
    S = input()
    if S == a[0]:
        print(a[1])
    elif S == a[1]:
        print(a[2])
    else:
        print(a[0])
    return


if __name__ == '__main__':
    if not __debug__:
        import doctest
        doctest.testmod()
    main()


Measured memory_bytes: 5364
#include <cstdio>
#include <iostream>
using namespace std;
const int N = 2e5 + 2;

int n, k, c, l[N], r[N], p;
char s[N];
bool ans[N], flag;

int main(){
	scanf("%d%d%d%s", &n, &k, &c, s + 1);
	++c;
	l[0] = 1 - c;
	for(int i = 1; i <= k; i++){
		l[i] = l[i - 1] + c;
		while(s[l[i]] == 'x') l[i]++;
	}
	r[k + 1] = n + c;
	for(int i = k; i; i--){
		r[i] = r[i + 1] - c;
		while(s[r[i]] == 'x') r[i]--;
	}
	for(int i = 1; i <= k; i++){
		if(l[i] == r[i]) flag = ans[l[i]];
		p = max(p, l[i] - c);
		while(p + 1 < r[i] + c) ans[++p] = 1;
		if(l[i] == r[i]) ans[l[i]] = flag;
	}
	for(int i = 1; i <= n; i++)
		if(!ans[i] && s[i] == 'o') printf("%d\n", i);
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define lowbit(x) ((x)&(-(x)))
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 0x3f3f3f3f;
const LL LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
const int maxn = 1e5 + 10;
int N;
int main()
{
    scanf("%d", &N);
    printf("%d", (1000 - N % 1000) % 1000);
    return 0;
}

Measured memory_bytes: 3812
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vstr=vector<string>;

vll total_layer,p_layer;

ll func(ll n, ll x){
    if(n == 0) return x>0;

    if(x <= 1+total_layer[n-1]) return func(n-1,x-1);
    else return p_layer[n-1] + 1 + func(n-1, x-2-total_layer[n-1]);
}

void solve() {
    ll N,X;
    cin >> N >> X;
    ll layer = 1, p = 1;;
    rep(i,N+1){
        total_layer.pb(layer);
        layer = 2*layer+3;
        p_layer.pb(p);
        p = 2*p+1;
    }
    print(func(N,X));
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

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

const long long INF = 1LL << 60;
vector<ll> h(100010), dp(100010);

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

int main(){
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> h.at(i);
  }

  //初期化
  for(int i = 0; i < 100010; i++){
    dp.at(i) = INF;
  }

  //初期条件
  dp.at(0) = 0;

  //ループ
  for(int i = 1; i < N; i++){
    chmin(dp.at(i), dp.at(i-1) + abs(h.at(i) - h.at(i-1)));
    if(i > 1) chmin(dp.at(i) , dp.at(i-2) + abs(h.at(i) - h.at(i-2)));
  }

  cout << dp.at(N-1) << endl;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(const T x,const T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}

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

const ll MOD=1e9+7;
const int MAX=1e5+100;

int main() {
  // 偶数->奇数で1になる
  ll A,B;cin>>A>>B;

  if (A==B) {
    OUT(A);
    return 0;
  }

  // 要素が奇数個
  if ((B-A)%2==0) {
    if (A%2==0) {
      bitset<60> a((B-A)/2%2);
      bitset<60> b(B);
      OUT((a^b).to_ullong());
    } else {
      bitset<60> a(A);
      bitset<60> b((B-A)/2%2);
      OUT((a^b).to_ullong());
    }
  // 要素が偶数個
  } else {
    if (A%2==0) {
      if ((B-A+1)/2%2==0) {
        OUT(0);
      } else {
        OUT(1);
      }
    } else {
      bitset<60> a(A);
      bitset<60> b(B);
      if ((B-A-1)/2%2==0) {
        OUT((a^b).to_ullong());
      } else {
        bitset<60> c(1);
        OUT(((a^b)^c).to_ullong());
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int a[4][3][10]={0},n,x,y,z,temp;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d%d%d%d",&x,&y,&z,&temp);
        a[x-1][y-1][z-1]+=temp;
    }
    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                printf(" %d",a[i][j][k]);
            }
            printf("\n");
        }
        if(i<3){
            for(int j=0;j<20;j++){
            printf("#");
            }
            printf("\n");
        }
    }
}

Measured memory_bytes: 2684
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

bool calc(string s, string t) {
    int[] freq(string s) {
        int[char] d;
        foreach (c; s) d[c]++;
        auto v = d.values;
        v.sort();
        return v;
    }

    return freq(s) == freq(t);
}

void main() {
    auto s = read!string;
    auto t = read!string;
    writeln(calc(s, t) ? "Yes" : "No");
}


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

int main() {
  for(int H, W; cin >> H >> W, H || W; ) {
    int A[H], B[W];
    for(int i = 0; i < H; i++) cin >> A[i];
    for(int i = 0; i < W; i++) cin >> B[i];

    int ans = 0;
    for(int i = 0; i < H; i++) {
      for(int j = 0; j < W; j++) {
        if(A[i] == B[j]) {
          ans += A[i];
          A[i] = 0;
          B[j] = 0;
        }
      }
    }
    for(int i = 0; i < H; i++) ans += A[i];
    for(int i = 0; i < W; i++) ans += B[i];
    cout << ans << endl;
  }
}

Measured memory_bytes: 1160
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY


A,B=get_i
puts A*B

Measured memory_bytes: 14320
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
typedef pair<int, vector<P>> S;
void output(int time, S s){
    printf("time %d, inv %d\n", time, s.first);
    for(auto vi : s.second) printf("(%d, %d) ", vi.first, vi.second);
    cout << endl;
}
int main(){
    int n;
    while(cin >> n && n){
        vector<P> v(n);
        for(auto& vi : v) cin >> vi.first >> vi.second;
        for(auto& vi : v) if(vi.first < vi.second) swap(vi.first, vi.second);
        int inv = 0;
        for(int i = 0; i < n; i++){
            for(int j = i + 1; j < n; j++){
                if(v[i].first > v[j].first) inv++;
                if(v[i].first > v[j].second) inv++;
                if(v[i].second > v[j].first) inv++;
                if(v[i].second > v[j].second) inv++;
            }
        }
        priority_queue<S, vector<S>, greater<S>> que;
        set<vector<P>> used;
        que.push(S(inv, v));
        used.insert(v);
        const int BEAM = 1 << 10;
        for(int iter = 0; ; iter++){
            priority_queue<S, vector<S>, greater<S>> nque;
            if(que.top().first == 0){
                cout << iter << endl;
                break;
            }
            for(int i = 0; i < BEAM && !que.empty(); i++){
                S s = que.top(); que.pop();
                int inv = s.first;
                vector<P>& v = s.second;
                for(int i = 0; i < n - 1; i++){
                    if(v[i].first > v[i + 1].second){
                        vector<P> nv = v;
                        int ninv = inv - 1;
                        swap(nv[i].first, nv[i + 1].second);
                        if(nv[i].first < nv[i].second){
                            swap(nv[i].first, nv[i].second);
                            ninv--;
                        }
                        if(nv[i + 1].first < nv[i + 1].second){
                            swap(nv[i + 1].first, nv[i + 1].second);
                            ninv--;
                        }
                        if(!used.count(nv)){
                            used.insert(nv);
                            nque.push(S(ninv, nv));
                        }
                    }
                }
            }
            que.swap(nque);
        }
    }
    return 0;
}

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

long long gcd(long long a, long long b) {
    if(a < b) swap(a, b);
    long long r = a % b;

    while(r > 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

long long lcm(long long a, long long b) {
    long long g = gcd(a, b);
    long long l = a / g * b;
    return l;
}


int main() {
    cin >> n;
    vector<long long> t(n, 0);
    for(int i = 0; i < n; ++i) cin >> t.at(i);
    sort(t.begin(), t.end());
    t.erase(unique(t.begin(), t.end()), t.end());

    int tlen = t.size();
    long long lc = 1;
    for(int i = 0; i < tlen; ++i) {
        lc = lcm(lc, t.at(i));
    }

    cout << lc << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
	char c[3][3];
	for (int i = 0; i < 3; i++) {
		scanf("%s", c[i]);
	}
	for (int i = 0; i < 3; i++) {
		printf("%c", c[i][i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main (String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			int x = in.nextInt();
			int y = in.nextInt();
			if(x==0 && y==0){
				break;
			}else{
				if(x<y){
					System.out.println(x+" "+y);
				}else{
					System.out.println(y+" "+x);
				}
			}
		}
	}
}

Measured memory_bytes: 27380
#include <stdio.h>
  
int gcd(int x,int y){
  if(x<y){
    int tmp = x; x = y; y = tmp;
  }
  while(y>0){
    int r=x%y;
    x=y;
    y=r;
  }
  return x;
}
  
int main(){
  int x,y,z;
  scanf("%d%d",&x,&y);
  printf("%d\n",gcd(x,y));
  
  return 0;
}


Measured memory_bytes: 2728
#include <bits/stdc++.h>
using namespace std;
inline int read() {
    int X=0,w=0;
    char ch=0;
    while(!isdigit(ch)) {
        w|=ch=='-';
        ch=getchar();
    }
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}
inline double dbread() {
    double X=0,Y=1.0;
    int w=0;
    char ch=0;
    while(!isdigit(ch)) {
        w|=ch=='-';
        ch=getchar();
    }
    while(isdigit(ch)) X=X*10+(ch^48),ch=getchar();
    ch=getchar();
    while(isdigit(ch)) X+=(Y/=10)*(ch^48),ch=getchar();
    return w?-X:X;
}
inline void write(int x) {
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
int main()
{
    int a,b,c;
    a=read();
    b=read();
    c=read();
    if(b-a==c-b)
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>

int n; 

int main() {
    int l; 
    scanf("%d", &l); 
    
    while ((1 << n) <= l) n++; 
    
    std::vector<std::pair<std::pair<int, int>, int> > v;
    std::vector<std::pair<std::pair<int, int>, int> >::iterator it; 
    for (int i = 0; i < n - 1; i++) {
        v.push_back({{i, i + 1}, 0});
        v.push_back({{i, i + 1}, 1 << i}); 
    }

    for (int i = n - 2; i >= 0; i--) {
        if (1 << (n - 1) <= l - (1 << i)) {
            v.push_back({{i, n - 1}, l - (1 << i)}); 
            l -= (1 << i); 
        }
    }

    printf("%d %d\n", n, v.size()); 

    for (it = v.begin(); it != v.end(); it++) {
        printf("%d %d %d\n", it->first.first + 1, it->first.second + 1, it->second); 
    }

    return 0; 
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

ll aa[252525];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a;
	cin>>n;
	REP(i, n){
		cin>>a;
		aa[i]=a-i-1;
	}
	sort(aa, aa+n);
	ll b=aa[n/2];
	ll ans=0;
	REP(i, n){
		ans+=abs(aa[i]-b);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1792
import { readFileSync } from 'fs'
export function greenBin(file: string) {
  const input = readFileSync(file, 'utf8')

  const [n, ...words] = input.split('\n').map(w => w.trim())
  let result = 0
  const entity: { [key: string]: number } = {}
  words.forEach(word => {
    const key = word
      .split('')
      .sort()
      .join('')
    if (!entity[key]) {
      entity[key] = 1
    } else {
      result += entity[key]
      entity[key] += 1
    }
  })

  console.log(result)
  // return(result)
}
const input = '/dev/stdin'
greenBin(input)

Measured memory_bytes: 45880
class Cmb:
    def __init__(self, m=10**5, p=10**9+7):
        fct, inv = [1], [1]
        a, b = 1, 1
        for i in range(1, m+1):
            a = (a * i) % p
            b = (b * pow(i, p - 2, p)) % p
            fct.append(a)
            inv.append(b)
        self.fct = fct
        self.inv = inv
        self.p = p

    def calc(self, n, r):
        fct, inv = self.fct, self.inv
        if r < 0 or n < r:
            return 0
        return (fct[n] * inv[r] * inv[n - r]) % self.p


n, k = map(int, input().split())
*A, = map(int, input().split())
A.sort()
s = 0
p = 10**9+7
cmb = Cmb()
for i in range(n):
    s += (A[n-1-i]-A[i])*cmb.calc(n-1-i, k-1)
    s %= p
print(s)


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

int main() {
  int n;
  cin >> n;
  int x[105], y[105], h[105];
  for (int i = 0; i < n; i ++) {
    cin >> x[i] >> y[i] >> h[i];
  }

  for (int cx = 0; cx <= 100; cx ++) {
    for (int cy = 0; cy <= 100; cy ++) {
      bool ok = true;
      int ans = 0, max = INT32_MAX;
      for (int i = 0; i < n; i ++) {
        int tmp = abs(x[i] - cx) + abs(y[i] - cy);
        if (h[i] == 0) {
          max = min(max, tmp);
        } else {
          if (ans == 0) {
            ans = tmp + h[i];
          } else if (ans != tmp + h[i]) {
            ok = false;
            break;
          }
        }
        if (ans > max) {
          ok = false;
          break;
        }
      }
      if (ok) {
        cout << cx << " " << cy << " " << ans << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    private final static Scanner sc = new Scanner(System.in);

    /**
     * 本処理を実行します。
     */
    public static void execute() {
        int n = nextInt();
        int k = nextInt();
        Integer[] l = nextInts(n);

        Arrays.sort(l, Comparator.reverseOrder());

        int length = 0;
        for (int i = 0;i < k; i++) {
            length += l[i];
        }

        out(length);
    }

    /**
     * 次の標準入力をintで受け取ります。
     * @return 標準入力値(int)
     */
    public static int nextInt() {
        return sc.nextInt();
    }

    /**
     * 次の標準入力をStringで受け取ります。
     * @return 標準入力値(String)
     */
    public static String nextString() {
        return sc.next();
    }

    /**
     * 次の標準入力を指定回数分intで受け取ります。
     * @param n 取得回数
     * @return 取得した標準入力値の配列(int)
     */
    public static Integer[] nextInts(int n) {
        Integer[] arr = new Integer[n];

        for (int i = 0; i < n; i++) {
            arr[i] = nextInt();
        }

        return arr;
    }

    /**
     * 標準出力にオブジェクトを出力します。
     * @param o 出力対象
     */
    public static void out(Object o) {
        System.out.println(o);
    }

    public static void main(String[] args) {
        execute();
    }
}

Measured memory_bytes: 21076
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;

int n;
vector<int> adj[MAXN];

int dp[MAXN][2]; // dp[i][j] is the minimum cost of the subtree at i (at least one) (when j==1 there is an antenna in the parent subtree)
bool canempty[MAXN];

void dfs(int at,int par) {
	int nchild=0;
	canempty[at]=true;
	REPSZ(i,adj[at]) {
		int to=adj[at][i]; if(to==par) continue;
		++nchild;
		dfs(to,at);
		if(!canempty[to]) canempty[at]=false;
	}
	if(nchild==0) {
		dp[at][0]=dp[at][1]=1;
	} else if(nchild==1) {
		REPSZ(i,adj[at]) {
			int to=adj[at][i]; if(to==par) continue;
			dp[at][0]=dp[to][0];
			dp[at][1]=canempty[to]?1:dp[to][1];
		}
	} else {
		canempty[at]=false;
		dp[at][0]; int mxspare=0;
		REPSZ(i,adj[at]) {
			int to=adj[at][i]; if(to==par) continue;
			dp[at][0]+=dp[to][1];
			if(canempty[to]) mxspare=max(mxspare,dp[to][1]);
		}
		dp[at][1]=dp[at][0]-mxspare;
	}
	//printf("%d: %d/%d canempty=%d (%d)\n",at,dp[at][0],dp[at][1],canempty[at]?1:0,nchild);
}

void run() {
	scanf("%d",&n); REP(i,n-1) { int a,b; scanf("%d%d",&a,&b); adj[a].PB(b); adj[b].PB(a); }
	int root=0; while(root<n&&SZ(adj[root])<3) ++root;
	if(root>=n) { printf("1\n"); return; }
	dfs(root,-1);
	printf("%d\n",dp[root][1]);
}

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


Measured memory_bytes: 11648
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fr(i,a,n) for(i=a;i<n;i++)
#define frn(i,a,n) for(i=a;i<=n;i++)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define ub upper_bound
#define lb lower_bound
//#define map map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define bs binary_search
#define qll queue<ll>
#define sll set<ll>
#define ma 500000
/*ll power(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return power(x*x,n/2);
    else                             //n is odd
        return x*power(x*x,(n-1)/2);
}*/

/*void decToBinary(ll n)
{
    string s;
int binaryNum[32];
int i = 0;
while (n > 0) {
binaryNum[i] = n % 2;
n = n / 2;
i++;
}
for (int j = i - 1; j >= 0; j--) {
 char c = binaryNum[j] +'0';
 s=s+c;
}
 
 //cout<<s<<endl;
 
 
 
 // for (int j = i - 1; j >= 0; j--)
 // cout<<s[j];
 
sort(s.begin(), s.end());
do {
cout << s << endl;
} while (next_permutation(s.begin(), s.end())); */
int highestPowerof2(int n)
{
   int p = (int)log2(n);
   return (int)pow(2, p);  
}
ll mindig(ll n){
ll x;
ll ans=mod;
 while(n>0)
        {
            x=n%10;
            ans=min(ans,x);
            n=n/10;
        }
        return ans;
}
ll maxdig(ll n)
{
    ll x;
    ll ans1=-1;
         while(n>0)
        {
            x=n%10;
            ans1=max(ans1,x);
            n=n/10;
        }
        return ans1;
}
 ll power(ll x, ll y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
 
int main()
{
    fastio;
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}


Measured memory_bytes: 3696
N,M= map(int,input().split())
N,M = max(N,M),min(N,M)
mod = 10**9+7

n = 100010
frac = [1]*(n+1)
for i in range(n):
    frac[i+1] = (i+1)*frac[i]%mod
if N==M+1:
    print(frac[N]*frac[M]%mod)
elif N==M:
    print(frac[N]*frac[M]*2%mod)
else:
    print(0)



Measured memory_bytes: 64300
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var b = Console.ReadLine().Trim()[0];
        var c = b == 'A'
            ? 'T'
            : b == 'T'
            ? 'A'
            : b == 'C'
            ? 'G'
            : 'C';
        Console.WriteLine(c);
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

int gcd(int a,int b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(a%b,b);
}


void solve(void)
{
  int N,M;
  cin>>N>>M;
  string S,T;
  cin>>S>>T;
  int G = gcd(N,M);
  int LCM = N*M/G;
  int P = LCM/N;
  int Q = LCM/M;
  if(G == 1)
  {
    if(S[0] == T[0])
    cout<<LCM<<endl;
    else
    {
      cout<<-1<<endl;
    }
    
    return;
  }
  for (int i = 1; i <= LCM; i++)
  {
    char X = 0; char Y = 0;
    if((i-1)%P == 0) X = S[(i-1)/P];
    if((i-1)%Q == 0) Y = T[(i-1)/Q];
    // DEBUG(X,Y);
    if(X != 0 && Y != 0)
    {
      if(X != Y)
      {
        cout<<-1<<endl;
        return;
      }
    }

  }
  cout<<LCM<<endl;
  
  
  return;
}




int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
 
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
#define ll long long
int main()
{
    int n,a[20],b[20],c[20];
    cin>>n;
    REP(i,n)cin>>a[i];
    REP(i,n)cin>>b[i];
    REP(i,n-1)cin>>c[i];
    int ans=0;
    REP(i,n){
        ans+=b[a[i]-1];
        if(i<n-1&&a[i+1]==a[i]+1)ans+=c[a[i]-1];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

money = 1000
mount = 0

f = -1
pre = a[0]
for i in range(1, len(a)):
    if f < 0:
        if a[i] <= pre:
            pre = a[i]
            continue
        mount += money // pre
        money %= pre
        f *= -1
    else:
        if a[i] >= pre:
            pre = a[i]
            continue
        money += mount * pre
        mount = 0
        f *= -1

    pre = a[i]

money += mount * a[-1]
print(money)


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

int main() 
{
    string s;
    int b_num=0, r_num=0;
    cin >> s;

    for (int i = 0; i < s.length(); i++) 
    {
        if (s[i] == '0') r_num++;
        else b_num++;
    }
    cout << min(b_num, r_num) * 2 << endl;
}

Measured memory_bytes: 512
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        x: isize, t: isize
    }

    let ans = if x - t > 0 { x-t } else { 0 };
    println!("{}", ans);
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 2084
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
//dijkstra(O(ElogV))
//0-indexed
ll n;
vector<vector<pll> >G(100010);
vector<ll> d(100010);
void dijkstra(ll s,vector<vector<pll> >&G,vector<ll> &d){
    priority_queue<pll,vector<pll>,greater<pll> >pq;
    rep(i,n){
        d[i]=inf*inf;
    }
    d[s]=0;
    pq.push(mp(0,s));
    while(!pq.empty()){
        pll k=pq.top();pq.pop();
        ll v=k.second;
        if(d[v]<k.first)continue;
        for(auto e:G[v]){
            if(d[e.first]>d[v]+e.second){
                d[e.first]=d[v]+e.second;
                pq.push(mp(d[e.first],e.first));
            }
        }
    }
}
int main(){
    ll m;cin>>n>>m;
    vector<vector<pll> >G(n);
    REP(i,1,n)G[i].pb(mp(i-1,0));
    rep(i,m){
        ll l,r,c;cin>>l>>r>>c;
        l--;r--;
        G[l].pb(mp(r,c));
    }
    vector<ll>d(n);
    dijkstra(0,G,d);
    if(d[n-1]==inf*inf)cout<<-1<<endl;
    else cout<<d[n-1]<<endl;
}

Measured memory_bytes: 13176
#include <iostream>
#include <stack>
#include <string>

int main() {
    std::string S;
    std::cin >> S;

    std::stack<int> s;                  // 下り坂の左縁
    std::stack<std::pair<int, int>> l;  // 池の左縁と面積

    for (int i = 0; i < S.length(); ++i) {
        if (S[i] == '\\') {
            s.push(i);
        } else if (S[i] == '/' && !s.empty()) {
            int a = i - s.top();
            // 他の池とマージする
            while (!l.empty() && l.top().first > s.top()) {
                a += l.top().second;
                l.pop();
            }
            l.emplace(s.top(), a);
            s.pop();
        }
    }

    int sum = 0;
    std::stack<int> ans;
    while (!l.empty()) {
        ans.push(l.top().second);
        sum += l.top().second;
        l.pop();
    }

    std::cout << sum << std::endl;
    std::cout << ans.size();
    while (!ans.empty()) {
        std::cout << " " << ans.top();
        ans.pop();
    }
    std::cout << std::endl;
    return 0;
}



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

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

int main(){
    string S;
    cin >> S;
    
    reverse(S.begin(), S.end());

    ll dp[S.length()+1][13];
    for(int i=0; i<=S.length(); i++){
        for(int j=0; j<13; j++){
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;
    
    ll dg = 1;
    for(int i=0; i<S.length(); i++){
        // cout << "------ " <<i << endl;
        // cout << dg << endl;
        for(int j=0; j<13; j++){
            if(S[i] != '?'){
                int d = S[i] - '0';
                int nd = (dg*d + j)%13;
                dp[i+1][nd] += dp[i][j];
                dp[i+1][nd] %= MOD;
                continue;
            }

            // cout << "---- " << j << endl;
            for(int k=0; k<10; k++){
                // int nd = (dg*k + j)%13;
                int nd = dg*k + j;
                nd %= 13;
                // cout << k << " " << dg << " " << nd << endl;
                dp[i+1][nd] += dp[i][j];
                dp[i+1][nd] %= MOD;
            }
        }
        dg = (dg * 10) %13;
    }

    cout << dp[S.length()][5] << endl;

    return 0;
}


Measured memory_bytes: 10624
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>

using namespace std;

int main(){
    vector<int> nums(4);
    string str;
    cin >> str;
    for(int i=0; i<(1<<4); i++){
        vector<bool> pm(3, true);
        int sum=str[0] - '0';

        for(int k=0; k<3; k++){
            if(i & (1<<k)) pm[k] = false;
        }

        for(int j=1; j<4; j++){
            if(pm[j-1]) sum += str[j] - '0';
            else sum -= str[j] - '0';
        }

        if(sum == 7){
          string ans;
           for(int k=0; k<3; k++){
              ans.push_back(str[k]);
              if(pm[k]) ans.push_back('+');
              else ans.push_back('-');
           }
           ans.push_back(str[3]);
           ans.push_back('=');
           ans.push_back('7');
           cout << ans << endl;
           return 0;
        }
    }
}


Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(string, S, N);
    vs J = {"AC", "WA", "TLE", "RE"};
    REP(k, 4)
    {
        ll sum = 0;
        FOR(s, S)
        {
            if (s == J[k])
            {
                ++sum;
            }
        }
        cout << J[k] << " x " << sum << endl;
    }
}

Measured memory_bytes: 6424
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
#include <sstream>
#include <bitset>

using namespace std;

typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef pair<int, int> P;

int main() {
    int n, tmp;

    cin >> n;
    vector<int> w;
    int sum = 0;

    REP(i,n) {
        cin >> tmp;
        sum += tmp;
        w.PB(tmp);
    }

    int tsum= 0;
    int m = 1000000;
    REP(i,n) {
        tsum += w[i];
        m = min(m, abs(tsum-(sum-tsum)));
    }

    cout << m << endl;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
  const newconst={
  ABC:'ARC',
  ARC:'ABC'  
  }
  console.log(newconst[input.trim()]);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29472
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getval(_T& a) {
	std::cin >> a;
}
template<class _T> static void getval(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getval(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}
template <class _T> static void tp_swap(_T& right, _T& left) {
	//	usage:  tp_swap<type name>(a, b);
	_T tmp = right;
	right = left;
	left = tmp;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	LLONG K;
	getval(K);

	int len = (K >= 50LL) ? 50 : K;
	if (len < 2) {
		len = 2;
	}
	printf("%d\n", len);

	std::vector<LLONG> ai(len, 0);
	for (int i = 0; i < len; i++) {
		ai[i] = i;
	}
	LLONG all = K / (LLONG)len;
	LLONG surp = K % (LLONG)len;
	for (int i = 0; i < len; i++) {
		std::sort(ai.begin(), ai.end());
		LLONG add = all * len;
		if (i < surp) {
			add += len;
		}
		ai[0] += add;
		for (int j = 1; j < len; j++) {
			ai[j] -= (add / len);
		}
	}


	for (int i = 0; i < len; i++) {
		printf("%lld ", ai[i]);
	}
	putchar('\n');
}


Measured memory_bytes: 3668