akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define debug(n1) cout<<"debug... "<<n1<<"\n"
#define PI 3.141592653589793238462643383279502
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
class abc
{
    public:
    ll x;
    string s;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n,m;
    cin>>n>>m;
    abc arr[m];
    rep(i,0,m)
    {
        cin>>arr[i].x>>arr[i].s;
    }
    ve <ll> cor(n,0),wa(n,0);
    ll p=0;
    rep (i,0,m)
    {
        if (arr[i].s=="AC")
        {
            cor[arr[i].x-1]++;
        }
        else if (cor[arr[i].x-1]==0)
        {
            wa[arr[i].x-1]++;
        }
    }
    ll a1=0;
    rep (i,0,n)
    {
        if (cor[i]!=0)
        {
            a1++;
            p+=wa[i];
        }
    }
    cout<<a1<<" "<<p<<"\n";

}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#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
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9;
const ll mod=998244353;
vector<ll>bit(1000010);
ll n;
ll sum(ll i){
    ll s=0;
    while(i>0){
        s+=bit[i];
        i=i&(i-1);
    }
    return s;
}
void add(ll i,ll a){
    while(i<=n){
        bit[i]+=a;
        i+=i&-i;
    }
}
signed main(){
    ll n_,k;cin>>n_>>k;
    vector<ll>a(n_+1);
    set<ll>st;
    ll ans=0;
    rep(i,n_){
        cin>>a[i+1];
        a[i+1]+=a[i];
        st.insert(a[i+1]-i*k-k);
    }
    st.insert(0);
    n=st.size();
    ll cnt=1;
    map<ll,ll>m;
    for(auto e:st){
        m[e]=cnt;
        cnt++;
    }
    add(m[0],1);
    rep(i,n_){
        ll d=m[a[i+1]-i*k-k];
        ans+=sum(d);
        //cout<<i<<' '<<sum(d)<<endl;
        add(d,1);
    }
    cout<<ans<<endl;
}

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

int main(){
	char a;
    char ans;
    string alp = "abcdefghijklmnopqrstuvwxyz";
	cin >> a;
    rep(i, 25){
      if(alp.at(i) == a) ans = alp.at(i+1);
    }
	cout << ans << endl;
}

Measured memory_bytes: 256
# URL : https://atcoder.jp/contests/abl/tasks/abl_a

from itertools import *
def Yes(f): print('Yes' if f else 'No')
def YES(f): print('YES' if f else 'NO')
def ispow(x): return int(x ** 0.5) ** 2 == x


res = 0
M = 10 ** 9 + 7
# s = input()
# a, b, c, d = map(int, input().split())
# a, b, c = map(int, input().split())
# a, b = map(int, input().split())
n = int(input())

# res = pow()
# print(res)
print('ACL' * n)


Measured memory_bytes: 9160
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    string s;
    cin >> s;
    cout << "2018" + s.substr(4, 6) << endl;
}

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

int main() {
	ios_base::sync_with_stdio(false);

	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	vector<ll> dp(n, 0);
	for (int i = 1; i < n; i++) {
		dp[i] = 1e18;
		for (int j = max(0, i - k); j < i; j++) {
			dp[i] = min(dp[i], abs(h[i] - h[j]) + dp[j]);
		}
	}
	cout << dp[n - 1];

	return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#define Mod 1000000007
using namespace std ;

int H , W , K , D ; 
int F[105][135][9] ; // ÁÐÊý¡¢¸ÃÁÐ×´Ì¬¡¢Ð¡ÇòÐÐÊý 

inline bool Judge( int i ) { // ÅÐ¶ÏÒ»¸ö×´Ì¬ÊÇ·ñºÏ·¨ 
	
	for(register int j = 1 ; j < W - 1 ; ++j ) 
		if( ( i & ( 1 << j ) ) and ( i & ( 1 << j - 1 ) ) )
			return false ;
	return true ;
	
}
inline void Update( int &A , int B ) {
	A = ( A + B ) % Mod ;
}

int main() {
	
	scanf( "%d%d%d" , &H , &W , &K ) ;
	D = 1 << W - 1 ;
	for(register int i = 0 ; i < D ; ++i ) { // Ã¶¾ÙµÚÒ»ÁÐµÄ×´Ì¬ 
		if( not Judge( i ) ) continue ;
		if( i & 1 ) F[1][i][2] = 1 ;
			else F[1][i][1] = 1 ;
	}
	for(register int i = 1 ; i < H ; ++i ) { // Ïòºó×ªÒÆ  
		for(register int j = 0 ; j < D ; ++j ) { // Ã¶¾Ù×´Ì¬ 
			if( not Judge( j ) ) continue ;
			for(register int k = 1 ; k <= W ; ++k ) { // Ã¶¾ÙÐ¡ÇòËùÔÚµÄÐÐ 
				for(register int tj = 0 ; tj < D ; ++tj ) { // Ã¶¾Ù×ªÒÆºóµÄ×´Ì¬ 
					if( not Judge( tj ) ) continue ;
					if( k != 1 )
						if( tj & ( 1 << k - 2 ) ) {
							Update( F[i+1][tj][k-1] , F[i][j][k] ) ;
							continue ;
						}
					if( k != W )
						if( tj & ( 1 << k - 1 ) ) {
							Update( F[i+1][tj][k+1] , F[i][j][k] ) ;
							continue ;
						}
					Update( F[i+1][tj][k] , F[i][j][k] ) ;
				}
			}
		}
	}
	int Ans = 0 ;
	for(register int i = 0 ; i < D ; ++i )
		if( Judge( i ) ) Update( Ans , F[H][i][K] ) ;
	return not printf( "%d\n" , Ans ) ;
	
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a;
	int count = 0;
	for (int i = 0; i < n; ++i)
	{
		int tmp;
		cin >> tmp;
		a.push_back(tmp - 1);
	}

	int i =0;
	for(auto f : a)
	{
		if(a[f] == i)
			count++;

		i++;
	}
	count /= 2;

	cout << count;

	return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
const int N=2e5+10;
int n,A[N],suma[N],sumb[N],sumc[N],L[N],R[N];
int ss[N],sumL[N],Ans=1e18;
void Get(int *sa,int *sb,int *val)
{
	int p=0;
	for(int i=1;i<=n;i++)
	{
		ss[i]=sa[i]-sb[i];
		if(ss[i]<ss[p]) p=i;
		val[i]=sb[i]+ss[p];
	}
}
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>A[i];
	//Get L
	for(int i=1;i<=n;i++)
	{
		suma[i]=suma[i-1]+A[i];
		sumb[i]=sumb[i-1]+(A[i]==0?2:(A[i]&1));
	}
	Get(suma,sumb,L);
/*	printf("suma:");
	for(int i=1;i<=n;i++)
		printf("%lld ",suma[i]);puts("");
	printf("sumb:");
	for(int i=1;i<=n;i++)
		printf("%lld ",sumb[i]);puts("");
	printf("L:");
	for(int i=1;i<=n;i++)
		printf("%lld ",L[i]);puts("");
*/
	//Get R
	reverse(A+1,A+n+1);	
	for(int i=1;i<=n;i++)
	{
		suma[i]=suma[i-1]+A[i];
		sumb[i]=sumb[i-1]+(A[i]==0?2:(A[i]&1));
	}
	Get(suma,sumb,R);
	reverse(R+1,R+n+1);
	reverse(A+1,A+n+1);
/*	printf("R:");
	for(int i=1;i<=n;i++)
		printf("%lld ",R[i]);puts("");
*/
	//Get Ans
	for(int i=1;i<=n;i++)
		sumc[i]=sumc[i-1]+1-(A[i]&1);
	Get(L,sumc,sumL);
/*	printf("sumc:");
	for(int i=1;i<=n;i++)
		printf("%lld ",sumc[i]);puts("");
	printf("sumL:");
	for(int i=1;i<=n;i++)
		printf("%lld ",sumL[i]);puts("");
*/	for(int i=0;i<=n;i++)
		Ans=min(Ans,sumL[i]+R[i+1]);
	cout<<Ans<<endl;
}


Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL; 

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const int INF = 1e9+7;
const int MAX_N = 1e5+10;
int dp[MAX_N];

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N,K;
    cin >> N >> K;
    VI h(N);
    REP(i,N)
    {
        cin >> h[i];
    }

    memset(dp, 0, sizeof(dp));

    for(int i=N-1; i>0; i--)
    {
        int tmp=INF;
        FOR(j,1,K+1)
        {
            dump(i)
            dump(j)
            if(i+j > N) break;
            int kouho = dp[i+j] + abs(h[i-1] - h[i-1+j]);
            dump(kouho)
            if(kouho < tmp) tmp = kouho;
        }
        dp[i] = tmp;
        dump(i)
        dump(dp[i])
    }

    cout << dp[1] << endl;



}


Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main()
{
  int n, m;
  int a[100010], b[100010];
  int ans = 0, lim = 0;
  
  cin >> n >> m;
  
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
  }
  
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      if (n == 1) {
        ans = 0;
      }
      else {
        ans = 1;
      }
    }
    else {
      ans *= 10;
    }
    lim = lim * 10 + 9;
  }
  
  for (int i = ans; i <= lim; i++) {
    string s = to_string(i);
    bool flg = true;
    for (int j = 0; j < m; j++) {
      if (s[a[j]-1] != (b[j] + '0')) {
        flg = false;
      }
    }
    if (flg) {
      cout << i << endl;
      return (0);
    }
  }
  
  cout << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const ll N=1e5+5;
const ll mod=1e9+7;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    vector< pair<string , ll > >a(n);
    for(ll i=0;i<n;i++)cin>>a[i].first>>a[i].second;
    string x;cin>>x;
    ll flg=0,ans=0;
    for(ll i=0;i<n;i++){
        if(flg)ans+=a[i].second;
        if(a[i].first==x)flg=1;
    }
    cout<<ans;
}


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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;

//DONT WASTE YOUR TIME
//prove yourself
//remember....fuck ps&&as hard....show them your are better then them
//Be confident.....dont lose hope.......You can do it.....
//dimaag  khoob h tere meh ....bas concentration ki kami h
//CONCENTRATE
//A,B,C dimaag nhi ...observation h .....zyaada mat sochna unme.....bas observe karna dhyaan se aur implement kar daal jitni jaldi ho sake

//capture it

const ll N= 1e6+55,mod = 1e9+7;

ll bob[N],a[N];
vl ans;
int main() {
 	//freopen("task.in","r",stdin);freopen("task.out","w",stdout);
	ll x,y,z,i,j,k,n;
	sc(n);sc(k);
	for(i=0;i<n;i++){
		sc(a[i]);
		bob[a[i]]++;
	}
	j=0;
	for(i=1;i<N;i++){
		if(bob[i]==0)continue;
		j++;
		ans.pb(bob[i]);
	}
	sort(ans.begin(),ans.end());
	x=0;
	for(i=0;i<ans.size();i++){
		if(j<=k){
			pr(x);
			return 0;
		}
		j--;
		x+=ans[i];
	}
	if(j<=k){
		pr(x);
		return 0;
	}

}

Measured memory_bytes: 8052
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for (int i = a; i <= b; ++i) {
      	cerr << i << ":" << i/10000 << i/1000%10 << i/10%10 << i%10 << endl;
        if (i/10000 == i%10 && i/1000%10 == i/10%10) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
function main(input){
    let field = new Array(4);
    for(let i=0;i<4;i++){
        field[i] = [new Array(10).fill(0),new Array(10).fill(0),new Array(10).fill(0)];
    }

    let lines = input.split("\n");
    let length = parseInt(lines.shift());
    for(let i=0;i<length;i++){
        let args = lines[i].split(" ");
        args = allParseInt(args);
        field[args[0]-1][args[1]-1][args[2]-1]+=args[3];
    }
    
    render(field);

    
}

function allParseInt(arr){
    return arr.map(x=>parseInt(x));
}

function render(field){
    for(let i=0;i<4;i++){
        for(let j=0;j<3;j++){
            let put = "";
            for(let k=0;k<10;k++){
                put+= " "+field[i][j][k];
            }
            console.log(put);
        }
        if(i!==3){
              console.log("####################");
        }
    }
}


main(require("fs").readFileSync("/dev/stdin","utf-8"));


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

const int MAX = 1000;

void PrintInfo(int R[], int n){
	for(int i = 0; i < n; i++){
		if(i > 0)
			cout << " ";
		cout << R[i];
	}
	cout << "\n";
}

void InsertionSort(int R[], int n){
	
	int v;
	int j;  // 作用就是把未排序序列的第一个元素插入到已排好序序列的合适的位置,从i-1开始 
	int i; // 指向未排序序列的第一个元素 
	for(i = 1; i < n; i++){
		v = R[i];
		j = i - 1;
		while( j >= 0 && R[j] > v){
			R[j+1] = R[j];  // 后移
			j--; 
		}
		R[j+1] = v;  // 把v插入到合适的位置 
		PrintInfo(R, n);
	}
}



int main()
{
	int n;
	cin >> n;
	int R[MAX];
	for(int i = 0; i < n; i++)
		cin >> R[i];
	PrintInfo(R, n);
	InsertionSort(R, n);
	return 0; 
}



Measured memory_bytes: 3116
def gcd(x, y):
	while y != 0:
		x, y = y, x % y
	return x

n = int(input())
A = list(map(int, input().split()))
L = [0]
R = [0]
for i in range(n):
	L.append(gcd(L[i], A[i]))
	R.append(gcd(R[i], A[-(i + 1)]))
R = R[::-1]

ans = []
for i in range(n):
	ans.append(gcd(L[i], R[i + 1]))
print(max(ans))

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

using namespace std;

const int MAX = 51;
 
int main(){
    int n,k,m,a,p,x,y;
    vector<bool> v(MAX);
    bool bu[MAX][MAX];
 
    fill(bu[0],bu[MAX],false);
 
    cin >> n >> k;
    for(int i = 0 ; i < k ; i++){
	cin >> m;
	for(int j = 0 ; j < m ; j++){
	    cin >> a;
	    bu[i][a] = true;
	}
    }
 
    cin >> p;
    for(int i = 0 ; i < p ; i++){
	cin >> x >> y;
	for(int j = 0 ; j < k ; j++){
	    if(bu[j][x] && bu[j][y]){
		v[x] = v[y] = true;
	    }
	}
    }
 
    int cnt = 0;
    for(int i = 0 ; i < MAX ; i++){
	if(v[i]) cnt++;
    }
 
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3088
#include <cstdio>
#include <utility>
#include <algorithm>

using namespace std;

using range=pair<int,int>;//right left

const int MAXN=5e5+7;
int N,Q;

int color[MAXN];
range query[MAXN];
int permu[MAXN];
int pos[MAXN];

int bit[MAXN];
int res[MAXN];

void update(int index,int diff){
    if (index==0) return ;

    for(int i=index;i<=N;i+=(i&-i)){
        bit[i]+=diff;
    }
}

int calc(int l,int r){
    int len=r&-r;
    int left=r-len+1;
    if (l==left) return bit[r];
    if (left>l) return bit[r]+calc(l,left-1);
    return bit[r]-calc(left,l-1);
}

int main(){
    scanf("%d%d",&N,&Q);

    for(int i=1;i<=N;i++) scanf("%d",color+i);
    for(int i=1;i<=Q;i++) scanf("%d%d",&query[i].second,&query[i].first),permu[i]=i;

    sort(permu+1,permu+Q+1,[](int a,int b){ return query[a]<query[b];});

    int left=1,right=1,index=1;

    while (left<=Q){
        auto &ql=query[permu[left]];
        while(right<=Q&&ql.first==query[permu[right]].first) right++;

        while(index<=ql.first) {
            int c=color[index];
            update(pos[c],-1);
            update(index,1);
            pos[c]=index;
            // for(int i=1;i<=N;i++) printf("%d ",bit[i]);
            // putchar('\n');
            index++;
        }
        
        
        for(int i=left;i<right;i++){
            auto &q=query[permu[i]];
            res[permu[i]]=calc(q.second,q.first);
        }

        left=right;
    }

    for(int i=1;i<=Q;i++) printf("%d\n",res[i]);

    return 0;
}

Measured memory_bytes: 17328
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);


int main() {
  FAST;
  int H, W;
  cin >> H >> W;
  vector<vector<char>> S(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j= 0; j < W; j++) {
    cin >> S.at(i).at(j);
    }
  }

  const int INF = 1000000;

  int result = 0;
  for (int sx = 0; sx < H; sx++) {
    for (int sy = 0; sy < W; sy++) {
      for (int gx = 0; gx < H; gx++) {
        for (int gy = 0; gy < W; gy++) {
          if (S.at(sx).at(sy) == '.') {
            if (S.at(gx).at(gy) == '.') {
              vector<vector<int>> d(H, vector<int>(W));
              vector<int> dx(4), dy(4);
              dx = {1, 0, -1, 0};
              dy = {0, 1, 0, -1};
              queue<pair<int, int>> que;
              for (int i = 0; i < H; i++) {
                for (int j= 0; j < W; j++) {
                  d.at(i).at(j) = INF;
                }
              }
              que.push(pair<int, int> (sx, sy));
              d.at(sx).at(sy) = 0;
              while (que.size()) {
                pair<int, int> p = que.front();
                que.pop();
                if (p.first == gx && p.second == gy) {
                  break;
                }
                for (int i = 0; i < 4; i++) {
                  int nx = p.first + dx.at(i);
                  int ny = p.second + dy.at(i);
                  if (0 <= nx && nx < H && 0 <= ny && ny < W && S.at(nx).at(ny) == '.' && d.at(nx).at(ny) == INF) {
                    que.push(pair<int, int> (nx, ny));
                    d.at(nx).at(ny) = d.at(p.first).at(p.second) + 1;
                  }
                }
              }
            result = max(result, d.at(gx).at(gy));
            }
          }
        }
      }
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
import heapq
n, m = map(int, input().split())

jobs = [[] for i in range(10**5+1)]

for i in range(n):
    a, b = map(int, input().split())
    jobs[a].append(b)

candidate = []
ans = 0
for i in range(m+1):
    for j in jobs[i]:
        heapq.heappush(candidate, -j)

    # print(i, candidate)
    if len(candidate) >= 1:
        ans += heapq.heappop(candidate) * -1


print(ans)

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

int main(){
	int n,m,x; cin>>n>>m>>x;
	int temp;
	int xl=0,xr=0;
	for(int i=0;i<m;i++) {
		cin >> temp;
		if(temp<x) xl++;
		else xr++;
	}
	if(xl>xr) cout << xr << endl;
	else cout << xl << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #pragma GCC optimization ("O3,unroll-loops")
// #pragma GCC target ("avx,avx2,fma")
using namespace std;

#define _ << ": " <<
#define watch1(var1) (cerr << (#var1) _ var1 << '\n')
#define watch2(var1, var2) cerr << (#var1) _ var1 << ", " << (#var2) _ var2 << '\n';
#define watch3(var1, var2, var3) cerr << (#var1) _ var1 << ", " << (#var2) _ var2 << ", " << (#var3) _ var3 << '\n';
#define wloop(size, arr) cerr << (#arr) << ": "; for (int i = 0; i < size; i++) cerr << arr[i] << " \n"[i+1 == size];

template<typename... Args>
void read(Args&... args) { ((cin >> args), ...); }

template<typename... Args>
void show(Args... args) { ((cout << args << " "), ...); }

#define ints(a...) int a; read(a)
#define longs(a...) int64_t a; read(a)

void solve() {
    char c; cin >> c;
    cout << (isupper(c) ? 'A' : 'a');
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1; 
    // cin >> T;
    while (T--) solve();
    return 0;
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var b = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var c = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

        for (int i = 0; i < n; i++)
        {
            a[i]--;
        }

        var ans = b[a[0]];
        for (int i = 1; i < n; i++)
        {
            ans += b[a[i]];
            if (a[i] == a[i - 1] + 1) ans += c[a[i - 1]];
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<cstring>
#include<map>
#include<sstream>
 
using namespace std;

int N,A,B;
string S;
vector<string> ans;

int main(){
  
  cin>>N>>A>>B>>S;
  
  int pass_national = 0;
  int pass_overseas = 0;
  int pass_all = 0;
    
  for(int i = 0; i < N; ++i){
    pass_all = pass_national + pass_overseas;    
    
    if(S[i] == 'a' && pass_all < (A+B)){
      ++pass_national;
      cout << "Yes" << endl;
    }else if(S[i] == 'b' && pass_all < (A+B) && pass_overseas < B){
      ++pass_overseas;
      cout << "Yes" << endl;
    }else{
    	cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 896
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<=(b);++(i))
#define rep(i, n)  FOR(i,0,n-1)
#define FFOR(i, a, b) for(int (i)=a;(i)>(b);--(i))
#define rrep(i,n) FFOR(i,0,n)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#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
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define ll long long
#define mod 1000000007LL
#define INF 123456789012345
typedef pair<ll, ll> P;
typedef pair<int, P> PP;

const int maxn =1e5 + 10;

vector<P> goen[maxn],gosn[maxn];
ll ryoen[maxn],ryosn[maxn];
ll dist[maxn];
ll ans[maxn];


void dik(ll start,ll n,vector<P> *go,ll *ryo)
{
	priority_queue< P,vector<P>,greater<P> > que;
	que.push(mp(0,start));
	rep(i,maxn-1) dist[i] = INF;
	dist[start] = 0;

	while(!que.empty())
	{
		ll nown = que.top().second;
		ll nowc = que.top().first;
		que.pop();

		rep(i,go[nown].size())
		{
			ll nxtn = go[nown][i].first;
			ll nxtc = nowc + go[nown][i].second;
			if(dist[nxtn] <= nxtc) continue;
			dist[nxtn] = nxtc;
			que.push(mp(nxtc,nxtn));
		}
	}
	
	rep(i,n) ryo[i] = dist[i];
}

int main() {
	
	ll n,m,s,t;cin>>n>>m>>s>>t;
	s--,t--;
	rep(i,m)
	{
		int u,v,a,b;cin>>u>>v>>a>>b;
		u--,v--;
		goen[u].pb(mp(v,a));
		goen[v].pb(mp(u,a));
		gosn[u].pb(mp(v,b));
		gosn[v].pb(mp(u,b));
	}

	dik(s,n,goen,ryoen);
	dik(t,n,gosn,ryosn);

	ans[n-1]=ryoen[n-1]+ryosn[n-1];
	for(int i=n-2;i>=0;i--)	ans[i] = min(ans[i+1],ryoen[i]+ryosn[i]);

	rep(i,n) cout << 1000000000000000 - ans[i] << endl;

	return 0;
}

Measured memory_bytes: 19964
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  char s[4];
  scanf("%s", s);
  bool a=true, b=true, c=true;
  for (int i=0; i<3; i++) {
    if (s[i]=='a') {
      a=false;
    } else if (s[i] == 'b') {
      b=false;
    } else {
      c=false;
    }
  }
  if (a||b||c) printf("No\n");
  else printf("Yes\n");
  return 0;
}


Measured memory_bytes: 128
# include <iostream>
using namespace std;
int main(){
  long long int n,i,x,k,temp; 
  cin>>n; 
  long long int ar[n];
  for(i=0;i<n;i++){
    cin>>ar[i];
  }
  k=ar[0];
  temp=1000;
  for(i=1;i<n;i++){
    if(k>=ar[i]){
      k=ar[i];
    }
    else{
      x=(temp/k);
      temp=temp-(k*x);
      temp=temp+(ar[i]*x);
      k=ar[i];
    }
  }
  cout<<temp; 
  return 0;
}

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

int main() {
  int X,N;
  cin >> X >> N;
  
  vector<int> Y(N);
  
  for(int i=0;i<N;i++) cin >> Y.at(i);
  
  int Z;
  //一旦入れておいて試す数
  bool M=false;
  //該当するか判定
  int A;
  //答え保存
  
  for(int i=0;i<100;i++){
    Z = X - i;
    for(int j=0;j<N;j++){
      if(Y.at(j) == Z) M = true;
    }
    if(M == false){
      A = Z;
      break;
    }
    
    M = false;
    
    Z = X + i;
    for(int j=0;j<N;j++){
      if(Y.at(j) == Z) M = true;
    }
    if(M == false){
      A = Z;
      break;
    }
    
    M = false;
  }
  
  cout << A << endl;
}


Measured memory_bytes: 3600
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,A,B,C=MI()
    D = { "A":A,"B":B,"C":C }
    ans = []
    S=[ST() for _ in range(N)]
    for i,s in enumerate(S):
        if(D[s[0]]==D[s[1]]==0):
            print("No")
            return
        if(D[s[0]]<D[s[1]]):
            ans.append(s[0])
            D[s[0]]+=1
            D[s[1]]-=1
        elif(D[s[0]]>D[s[1]] or i==N-1):
            ans.append(s[1])
            D[s[0]]-=1
            D[s[1]]+=1
        else:
            ns = S[i+1]
            if(s[0] in ns):
                ans.append(s[0])
                D[s[0]]+=1
                D[s[1]]-=1
            else:
                ans.append(s[1])
                D[s[0]]-=1
                D[s[1]]+=1
        # print(D)

    print("Yes")
    print(*ans,sep="\n")
if __name__ == '__main__':
    main()

Measured memory_bytes: 97324
#include <iostream>

using namespace std;

int n;
int cur, ans;

int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		char c;
		cin >> c;
		if (c == 'I') cur ++;
		else cur --;
		if (cur > ans) ans = cur;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import math
a, b, h, m = map(int, input().split())
c2 = m * 360 / 60
c1 = h * 360 / 12 + (1 * c2 / 12)
clis = [c1, c2]
C = max(clis) - min(clis)
# print(clis, type(C))
# C = max(clis) - min(clis) if max(clis) - \
#     min(clis) <= 180 else 360 - (max(clis) - min(clis))
# C = 360 - abs(c1 - c2) if abs(c1 - c2) > 180 else abs(c1 - c2)
# print(C, a**2, b**2, - (2 * a * b * math.cos(C)))
c = math.sqrt(a ** 2 + b ** 2 - (2 * a * b * math.cos(math.radians(C))))
print(c)


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

int main(){
    int a, b, c, cnt;
    cnt = 0;
    
    cin >> a >> b >> c;
    
    for(int i = a; i <= b; i++){
        if(c % i == 0){
            cnt++;
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}



Measured memory_bytes: 3128
#include<stdio.h>

int main(){
    int N,K,X,Y;
    scanf("%d%d%d%d",&N,&K,&X,&Y);
    if(N<= K){
    printf("%d\n",N*X);
    }
    else{   
    printf("%d\n",K*X+(N-K)*Y);
    }
    return 0;
}


Measured memory_bytes: 128
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
        return self.root[x]

    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if (x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        #rnkが大きい方に結合
        elif (self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
        # rnkが同じ（深さに差がない場合）は1増やす
        if(self.rnk[x] == self.rnk[y]):
            self.rnk[y] += 1

    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]


N, M=map(int, input().split())

uni=UnionFind(N)
for i in range(M):
    a,b=map(int, input().split())
    uni.Unite(a-1,b-1)
ans=0
for i in range(N):
    ans=max(ans, uni.Count(i))
print(ans)


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

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

int main(){

  int n;
  cin>>n;
  vector<double> x(n);
  cin>>x;

  double ans = (double)INF;
  for(double p = 0.0;p<=100.0;p+=1.0){
    double tmp = 0.0;
    rep(i,n){
      tmp += (x[i]-p)*(x[i]-p);
    }
    chmin(ans,tmp);
  }
  //cout<<fixed<<setprecision(10);
  cout<<(ans)<<endl;

}

Measured memory_bytes: 256
s = [int(i) for i in input().split()]
s.sort(reverse=True)
if s[0] == s[1] and s[1] == s[2]:
    print(0)
elif s[0] == s[1]:
    if (s[0] - s[2])%2 == 0:
        print((s[0]-s[2])//2)
    else:
        print(1+(s[0]+1-s[2])//2)
elif s[1] == s[2]:
    print(s[0]-s[2])
else:
    if (s[1] - s[2])%2 == 0:
        print(s[0]-s[1]+(s[1]-s[2])//2)
    else:
        print(s[0]-s[1]+1+(s[1]-s[2]+1)//2)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <math.h>
#include <vector>
#include <map>
using namespace std;
int main() {
  double a, b, x;
  double ans;
  cin >> a >> b >> x;
  if (2 * x >= a * a * b) {
	  ans = atan(2 * b / a - 2 * x / (a * a * a));
	}
  else {
	  ans = atan(a * b * b / (2 * x));
	}
  ans *= 180.0 / M_PI;
  cout << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<unordered_map>
#include<string>
#define LL long long
#define li i<<1
#define ri i<<1|1
using namespace std;
inline LL read()
{
    char c=getchar();LL x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
LL n; 
int main()
{
	n=read();
	LL ans=n%1000;
	ans=1000-ans;
	if(ans==1000)
		ans=0;
	printf("%lld\n",ans);
	return 0;
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> connect(m);
    vector<int> p(m);
    for (auto i = 0; i < m; i++)
    {
        int k;
        cin >> k;
        vector<int> connect_i(k);
        for (auto j = 0; j < k; j++)
        {
            int s;
            cin >> s;
            s -= 1;
            connect_i[j] = s;
        }
        connect[i] = connect_i;
    }
    for (auto i = 0; i < m; i++)
    {
        int p_i;
        cin >> p_i;
        p[i] = p_i;
    }

    int ans = 0;

    for (auto bit = 0; bit < pow(2, n); bit++)
    {
        vector<int> bits(n);
        for (auto i = 0; i < n; i++)
        {
            if(bit & (1 << i)){
                bits[i] = 1;
            }else{
                bits[i] = 0;
            }
        }
        bool is_all = true;
        for (auto i = 0; i < m; i++)
        {
            int sum = 0;
            for (auto j = 0; j < connect[i].size(); j++)
            {
                if(bits[connect[i][j]] == 1){
                    sum += 1;
                }
            }
            if(sum % 2 != p[i]){
                is_all = false;
                break;
            }
        }
        if(is_all){
            ans += 1;
        }
        
        
    }

    cout << ans << endl;

}

Measured memory_bytes: 384
n,quantum = gets.split(" ").map(&:to_i)
process = []
n.times{
    p,t = gets.split
    t = t.to_i
    process << [p,t]
}

total = 0

while !process.empty?

	p,t = process.shift

	if t <= quantum
		total += t
		puts "#{p} #{total}"
	else
		t -= quantum
		total += quantum
		process << [p,t]
	end
end

Measured memory_bytes: 19328
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  	int q, cc = 0;
  	string s;
  	bool re = false;
  	cin >> s >> q;
  	int que[q], f[q];
  	char c[q];
  	for (int i = 0; i < q; i ++) {
      	cin >> que[i];
      	if (que[i] == 2) {
          	cin >> f[i] >> c[i];
          	cc++;
        }
    }
  	s.reserve(s.size() + cc);
  	for (int i = 0; i < q; i ++) {
      	if (que[i] == 1) {
          	re = !re;
        } else {
      		if ((f[i] == 1) != re) {
              	s.insert(s.begin(), c[i]);
            } else {
              	s.insert(s.end(), c[i]);
            }
        }
    }
  	if (re) reverse(s.begin(), s.end());
  	cout << s << endl;
  
	return 0;
}


Measured memory_bytes: 2716
p = 2019
s = [int(i) for i in input()]
p_cnt = 0
 
s = s[::-1]
div_dic = dict(zip(range(p), [0] * p))
tmp = 0

for i in range(len(s)):
    tmp += s[i] * pow(10, i, p)
    tmp %= p
    div_dic[tmp] += 1

for v in div_dic.values():
    p_cnt += v * (v - 1)
p_cnt //= 2
p_cnt += div_dic.get(0)
 
print(p_cnt)


Measured memory_bytes: 12340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }

int main(){
    vector<ll> N(3);
    REP(i, 3) cin >> N[i];
    ll K;
    cin >> K;
    ll max = 0;
    REP(A, K+1) {
        REP(B, K+1) {
            REP(C, K+1) {
                if (A+B+C == K) {
                    ll a = N[0] * pow(2,A);
                    ll b = N[1] * pow(2,B);
                    ll c = N[2] * pow(2,C);
                    chmax(max, a+b+c);
                }
            }
        }
    }
    cout << max << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <complex>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
const double PI = acos(-1);
inline bool equals(double a, double b) { return abs(b - a) < EPS; }
using Point = complex<double>;
namespace std { bool operator < (const Point &a, const Point &b) { return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b); } }
struct Line
{
    Point a, b;
    Line(Point a, Point b) : a(a), b(b) {}
};
double dot(const Point &a, const Point &b) { return real(a) * real(b) + imag(a) * imag(b); }
double cross(const Point &a, const Point &b) { return real(a) * imag(b) - imag(a) * real(b); }
bool isParallel(const Line &a, const Line &b) { return equals(cross(a.b - a.a, b.b - b.a), 0.0); }
bool isOrthogonal(const Line &a, const Line &b) { return equals(dot(a.a - a.b, b.a - b.b), 0.0); }
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    while(n--)
    {
        double x0, y0, x1, y1, x2, y2, x3, y3; cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        Line s = Line(Point(x0, y0), Point(x1, y1));
        Line t = Line(Point(x2, y2), Point(x3, y3));
        if(isParallel(s, t)) cout << 2 << endl;
        else if(isOrthogonal(s, t)) cout << 1 << endl;
        else cout << 0 << endl;
    }
    return 0;
}




Measured memory_bytes: 3308
def BellmanFord(edges,num_v,source):
  dist=[float("inf") for i in range(num_v)]
  dist[source]=0
  
  for i in range(num_v):
    for edge in edges:
      if edge[0] != float("inf") and dist[edge[1]] > dist[edge[0]] + edge[2]:
        dist[edge[1]] = dist[edge[0]] + edge[2]
        if i==num_v-1 and edge[1] == N - 1:
            return -1
  
  return dist

N,M = map(int,input().split())
edges = []
for i in range(M):
    a,b,c = map(int,input().split())
    edges.append([a-1,b-1,-c])

d  = BellmanFord(edges,N,0)
if d==-1:
    print("inf")
    exit()

print(-d[N-1])



Measured memory_bytes: 45272
#include <iostream>
#include <vector>
#include <string>
using namespace std;

vector<vector<int> > table;
vector<int> record;
string s, t;

int MAX = 300;

/*
pair<int, string> lcs(int end_s, int end_t){

    if((end_s < 0) || (end_t < 0)){
       return make_pair(0, "");
    }

    if(table[end_s][end_t].first != -1){
        return table[end_s][end_t];
    }

    auto longest = lcs(end_s - 1, end_t);
    for(int j = 0; j <= end_t; j++){
        if(t[j] == s[end_s]){
            auto sub = lcs(end_s-1,j-1);
            int len = sub.first+1;
            if(len > longest.first){
                sub.first += 1;
                sub.second += s[end_s];
                longest = sub;
            }
        }
    }

    table[end_s][end_t] = longest;
    return longest;
}

*/


string lcs(int s_size, int t_size){

    string ans = "";

    for(int i = 1; i <= s_size; i++){
        for(int j = 1; j <= t_size; j++){
            if(s[i-1] == t[j-1]){
                table[i][j] = table[i-1][j-1] + 1;
            }
            else{
                table[i][j] = max(table[i-1][j], table[i][j-1]);
            }
        }
    }

    while(s_size > 0 && t_size > 0){
        if(s[s_size-1] == t[t_size-1]){
            ans = s[s_size-1] + ans; 
            s_size--;
            t_size--;
        }else{
            if(table[s_size-1][t_size] > table[s_size][t_size-1])
                s_size--;
            else
                t_size--;
        }
    }

    return ans; 
}


int main(){
    
    cin >> s >> t;

    table = vector<vector<int> >(s.size()+1, vector<int>(t.size()+1, 0));
    record = vector<int>();

    auto longest = lcs(s.size(), t.size());

    cout << longest << "\n";

    return 0;
}


Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main(){
	int i,j,n,d[30],s = 0,c[30]={0};
	cin >> n;
	if(n>23){
		cout << 0 << endl;
		return 0;
	}
	
	for(i=0;i<n;i++){
		cin >> d[i];
		c[d[i]]++;
		if(!d[i]){
			cout << 0 << endl;
			return 0;
		}
	}
	
	for(i=1;i<=11;i++){
		if(c[i]>=3 || c[12]>=2){
			cout << 0 << endl;
			return 0;
		}
	}
	
	if(n==23){
		cout << 1 << endl;
		return 0;
	}
	
	for(i=0;i<(1<<n);i++){
		vector<int> v;
		for(j=0;j<n;j++){
			if(i & 1<<j){
				v.push_back((d[j]+12)%24);
			}else{
				v.push_back(12-d[j]);
			}
		}
		v.push_back(12);
		sort(v.begin(),v.end());
		int x = (24 + v[0] - v.back())%24;
		for(j=0;j<v.size()-1;j++){
			x = min(x,v[j+1]-v[j]);
		}
		s = max(s,x);
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re          return
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for (__typeof(b) i=(a)-((a)>(b));i!=(b)-((a)>(b));i+=1-2*((a)>(b)))
#define PI            3.141592653589793l
#define fill(c,val) memset(c,val,sizeof(c))
#define LB lower_bound
#define UB upper_bound
#define inf 1e16
using namespace std;
typedef long long ll;
const ll INF=(1LL<<60)-1;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
  	     int n;
         cin >> n;
  map<long long, int> mp;
  mp[0] = 1;
  long long s = 0;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    s += x;
    ans += mp[s];
    mp[s]++;
   }
		 cout<<ans;
   cout<<endl;
 }
    return 0;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
#define INF 1e9+7
#define ll long long
#define f(x) for(ull i=0;i<x;i++)
#define F first
#define S second
#define N 1000000000
#define M 1000000009
#define mp make_pair
#define ull unsigned long long
#define sc(n) scanf("%d",&n)
#define gcd __gcd
using namespace std;

int main() {
	ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    if(n==k){
        cout<<0<<endl;
        return 0;
    }
    if(n<0&&k==0){
        cout<<-n<<endl;
        return 0;
    }
    if(n>0&&k==0){
        cout<<n+1<<endl;
        return 0;
    }
    int no=n-k;
    int sn=1,sk=1;
    if(n!=0)
        sn=n/abs(n);
    if(k!=0)
        sk=k/abs(k);
    if(sn== -sk){
        cout<<abs(abs(n)-abs(k))+1<<endl;
    }
    else if(no>0&&sn==sk){
            cout<<no+2<<endl;
    }
    else
        cout<<abs(abs(n)-abs(k))<<endl;
    return 0;
}


Measured memory_bytes: 256
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 1e6 + 6, mod = (int) 0;
int a[N];
int main() {
	int n;
	scanf("%d", &n);
	long long res = 0;
	for (int j = 0; j < 3 * n; ++j)
		scanf("%d", a + j);
	sort(a, a + 3 * n);
	for (int j = n; j < 3 * n; j += 2)
		res += a[j];
	cout << res << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

const ll MAX = 1000000;
ll fac[MAX], finv[MAX], inv[MAX];
// nCk初期化
void nCkInit(const ll MOD) {//O(max(n,r)logmax(n,r) mは素数)
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll nCk(ll n, ll k,const ll MOD){//init後,O(1)
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll N,M;
int main(){
    nCkInit(MOD);
    cin>>N>>M;
    ll ans=0;
    for(ll i=0;i<=N;i++){
        ans=(ans+((i%2==1)?(-1):1) * ( nCk(N,i,MOD)*fac[M]%MOD*finv[M-i]%MOD*fac[M-i]%MOD*finv[M-N]%MOD*fac[M-i]%MOD*finv[M-N]%MOD )+MOD )%MOD;
    }
    cout<<ans<<endl;
    return 0;
}

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

#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int r;
	cin>>r;
	
	r = 2*r;
	double ans = (double)3.1415*(double)r;
	cout<<ans;
}

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

int main() {
	string s, e;
	cin >> s >> e;
	bool chk = true;
	if (e.size() == s.size() + 1) {
		for (int i = 0; i < s.size(); ++i) {
			if (e[i] != s[i]) {
				chk = false;
				break;
			}
		}
	}
	else {
		chk = false;
	}

	if (chk) {
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 3724