akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	D = inputInt()
	C = inputList()
	S = []
	ans = []
	for i in range(D):
		s = inputList()
		S.append(s)

	minC = min(C)
	minCn = 0
	for i,val in enumerate(C):
		if val == minC:
			minCn = i

	for i,val in enumerate(S):
		tmp = max(val)
		for j,vol in enumerate(val):
			if tmp == vol:
				ans.append(minCn+1)
				break

	for i in range(D):
		print(ans[i])

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


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

using namespace std;
#define int long long
#define N 666666
#define mod 1000000007
map<int,int> mp;
set<int> s; 
int arr[N];
signed main(){
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		cin>>arr[i];
		mp[arr[i]]++;s.insert(arr[i]);
	}
	if(s.size()>3) cout<<"No";
	else{
		int f=1;map<int,int> vis;
		if(s.size()==3){
			for(int i=1;i<=n;i++){
				if(!vis[arr[i]]){
					if(mp[arr[i]]!=n/3){
						f=0;
						break;
					}
				}
				vis[arr[i]]=1;
			}
			set<int> ::iterator it;int sum=0;
			for(it=s.begin();it!=s.end();it++){
				sum=sum^*it;
			}
			if(sum) f=0;
		}else if(s.size()==2){
			if(mp[0]!=n/3) f=0;
			for(int i=1;i<=n;i++){
				if(!vis[arr[i]]&&arr[i]){
					if(mp[arr[i]]!=2*n/3){
						f=0;
						break;
					}
				}
				vis[arr[i]]=1;
			}	
		}else if(s.size()==1){
			if(mp[0]!=n) f=0;
		}
		if(f) cout<<"Yes";else cout<<"No";
	}
	return 0;
}

/*

2
BWWB

4
BWBBWWWB

5
WWWWWWWWWW

BWBW
*/

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    
    int n; cin >> n;
    vi a(n); REP(i, n) cin >> a[i];

    int mn = 2e9, ans = -1e9;
    REP(i, n) {
        ans = max(ans, a[i] - mn);
        mn = min(mn, a[i]);
    }
    cout << ans << endl;


    

    return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>
int main(void){
    int k,i, n = 0, f;
    char s[12];
    char c[100];
    scanf("%s", s);
for(k=0;k<12;k++){
if('a'<=s[k]&&s[k]<='z'){s[k]=s[k]-'a'+'A';}
}
    while (1){
        scanf("%s", c);
f = strcmp(c, "END_OF_TEXT");
        if (f == 0){ break; }
for(k=0;k<100;k++){
if('a'<=c[k]&&c[k]<='z'){c[k]=c[k]-'a'+'A';}else if(c[k]=='\0'){break;}
}
        i = strcmp(c, s);
         
        if (i ==0){ n += 1; i = '\0'; }
    }
    printf("%d\n", n);
    return 0;
}


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


def main():
    N = int(input())
    nums = range(1, N + 1)
    while True:
        nums = [i // 2 if i % 2 == 0 else 0 for i in nums]
        if sum(nums) == 1:
            print([i + 1 for i in range(N) if nums[i] == 1][-1])
            break
        elif sum(nums) == 0:
            print(len(nums))
            break


main()


Measured memory_bytes: 9184
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {

        FastReader fs = new FastReader();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        long n = fs.nextLong();
        long k = fs.nextLong();
        long mod = 1000000007;
        long ans = 0 ;

        long first = ((n)*(n+1))/2;




        for(long i=k ; i<=(n+1) ; i++){
            long term1 = first - (i*(i-1))/2;
            long term2 = ((n-i)*(n-i+1))/2;
            
            long fin = term1 - term2 + 1 ;
            ans = (ans%mod+fin%mod)%mod;
        }

        out.println(ans);

        out.close();

    }

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
    //--------------------------------------------------------
}


Measured memory_bytes: 32904
#include <stdio.h>
int main(void)
{
    int sx,sy,tx,ty;
    scanf("%d%d%d%d", &sx,&sy,&tx,&ty);
    int i;
    for(i=0; i<tx-sx; i++) printf("R");
    for(i=0; i<ty-sy; i++) printf("U");
    for(i=0; i<tx-sx; i++) printf("L");
    for(i=0; i<ty-sy; i++) printf("D");
    //1往復
    printf("L");
    for(i=0; i<ty-sy+1; i++) printf("U");
    for(i=0; i<tx-sx+1; i++) printf("R");
    printf("D");
    printf("R");
    for(i=0; i<ty-sy+1; i++) printf("D");
    for(i=0; i<tx-sx+1; i++) printf("L");
    printf("U");

    return 0;
}

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

int main(){
int N;
   cin>>N;
  vector<int>h(N+1);
  h[0]=0;
  int sum=0;
  for(int i=1; i<=N; i++){
   cin>>h[i];
   if(h[i]>h[i-1]){sum+=h[i]-h[i-1];}// 全てのh[i]は1以上であり、
  }// a[i-1]より大きなa[i]が現れるたびに差を加算していけば、
  // a[i]を0にするのに必要な数値は既に加算されている事になる。
  // a[i]<a[i-1]となる区間が現れるごとに(l, r)の区間がリセットされ、
  // 上記の作業を繰り返せば必要な操作回数が算出される
  cout<<sum;
}

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

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

	int tmp;
	cin >> tmp;

	int result = 0;

	for (int i = 0; i < N-1; i++)
	{
		int tmp2;
		cin >> tmp2;
		if (tmp == tmp2)
		{
			result++;
			tmp = -1;
		}
		else
			tmp = tmp2;
		
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 256
from math import *
import sys,bisect,copyreg,copy,statistics,os
def inp(): return sys.stdin.readline().strip()
def IIX(): return (int(x) for x in sys.stdin.readline().split())
def II(): return (int(inp()))
def LI(): return list(map(int, inp().split()))
def LS(): return list(map(str, inp().split()))
def L(x):return list(x)
def out(var): return sys.stdout.write(str(var))
def binary_search(arr, x): 
    left = 0
    right = len(arr) - 1
    mid = 0
    while left <= right:   
        mid = (left + left) // 2
        if arr[mid] < x: 
            left = mid + 1
        elif arr[mid] > x: 
            right = mid - 1
        else: 
            return mid
    return -1
 
s=inp()
c=0
if s.count("R")==1:
    out(1)
else:
    for i in range(3):
        if s[i]=='R':
            c+=1
        elif s[i]=='S' and i!=2:
            c= 0
    out(c)

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

int main()
{
	int y, m, d;
	char c1, c2;
	cin >> y >> c1 >> m >> c2 >> d;
	
	if (y <= 2019 and m <= 4 and d <= 30)
	{
		cout << "Heisei" << endl;
	}
	else
	{
		cout << "TBD" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
struct node {
    node() : value {}, left {nullptr}, right {nullptr} {};
    node(int v) : value {v}, left {nullptr}, right {nullptr} {};
    int value;
    node* left;
    node* right;
};

struct bst {
    bst() : root {nullptr} {};
    node* root;
    void insert(int v){
        node** ptr = &root;
        while(*ptr){
            if(v < (*ptr)->value){
                ptr = &((*ptr)->left);
            } else {
                ptr = &((*ptr)->right);
            }
        }
        *ptr = new node(v);
    };
    void inorder_print(node* ptr){
        if(!ptr){
            return;
        }
        inorder_print(ptr->left);
        cout << ' ' << ptr->value;
        inorder_print(ptr->right);
    };
    void preorder_print(node* ptr){
        if(!ptr){
            return;
        }
        cout << ' ' << ptr->value;
        preorder_print(ptr->left);
        preorder_print(ptr->right);
    };
    void print(){
        inorder_print(root);
        cout << endl;
        preorder_print(root);
        cout << endl;
    };
};


int main(){
    int n;
    cin >> n;
    char com[10];
    int v;
    auto tree = bst();
    for(int i = 0; i < n; ++i){
        scanf("%s", com);
        if(com[0] == 'i'){
            scanf("%d", &v);
            tree.insert(v);
        } else {
            tree.print();
        }
    }
}

Measured memory_bytes: 16872
/*Program from Luvwgyx*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#define int long long
using namespace std;
const int maxn=1e3+10;
int ans[maxn][maxn];
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void print(int x){
    if(x<0)putchar('-'),x=-x;
    if(x>9)print(x/10);
    putchar(x%10+'0');
}
void write(int x){print(x);puts("");}
signed main(){
    int n=read(),m=read(),a=read(),b=read();
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            if(j<=a&&i<=b)ans[i][j]=1;
            else if(j>a&&i>b)ans[i][j]=1;
            else ans[i][j]=0;
        }
    for(int i=1;i<=n;i++){for(int j=1;j<=m;j++)print(ans[i][j]);puts("");}
    return 0;
}


Measured memory_bytes: 9088
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int a, b, c;

int main() {
	cin >> a >> b >> c;
	if (a == b)cout << c << endl;
	else {
		if (a == c)cout << b << endl;
		else  cout << a << endl;
	}
}

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

#define int long long
#define pb push_back
#define mp make_pair

const int MOD = 1000000007;

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

	string s;
	cin>>s;

	int n=s.length();
	vector<int> arr(n,0);
	int st=0;
	int kek=0;
	int nexl[n];
	int prevr[n];
	int i=0;
	prevr[0]=-1;
	nexl[n-1]=-1;
	if(s[0]=='R')
		prevr[0]=0;
	for(int i=1;i<n;i++)
	{
		if(s[i]=='R')
			prevr[i]=i;
		else
			prevr[i]=prevr[i-1];
	}

	if(s[n-1]=='L')
		nexl[n-1]=n-1;
	for(int i=n-2;i>=0;i--)
	{
		if(s[i]=='L')
			nexl[i]=i;
		else
			nexl[i]=nexl[i+1];
	}

	for(int i=0;i<n;i++)
	{
		if(s[i]=='R')
		{
			if(nexl[i]!=-1)
			{
				if((nexl[i]-i)%2==1)
					arr[nexl[i]-1]++;
				else
					arr[nexl[i]]++;
			}
			else
			{
				arr[n-1]++;
			}
		}
		if(s[i]=='L')
		{
			if(prevr[i]!=-1)
			{
				if((i-prevr[i])%2==1)
					arr[prevr[i]+1]++;
				else
					arr[prevr[i]]++;
			}
			else
			{
				arr[0]++;
			}
		}
	}

	for(int i=0;i<n;i++)
		cout<<arr[i]<<" ";

    return 0;
}

Measured memory_bytes: 3024
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

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

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

    for(int i = 1; i< n; ++i)
    {
        for(int j =i+1; j<=n; ++j)
        {
            sum+= v[i]*v[j];
        }
    }
    cout << sum;

    return 0;
}

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

bool drop(vector< vector<int> > &v_v);
int caluculate_score_of_line(vector<int> &v, int bidx, int eidx);
int apply_to_line(vector<int> &v);
int apply_to_lines(vector< vector<int> > &v_v);
void disp_v(vector<int> &v);
void disp_v_v(vector< vector<int> > &v_v);

bool drop(vector< vector<int> > &v_v) {
    int drop_count = 0;
    for (int j=0; j<5; j++) {
        for (int i=v_v.size()-1; i>-1; i--) {
            if (v_v[i][j] == 0) {
                int above_idx = i - 1;
                while (above_idx>=0) {
                    if (v_v[above_idx][j] > 0) {
                        v_v[i][j] = v_v[above_idx][j];
                        v_v[above_idx][j] = 0;
                        drop_count ++;
                        break;
                    }
                    above_idx--;
                }
            }
        }
    }

    if (drop_count > 0) {
        // cout << "DROP" << endl;
        // disp_v_v(v_v);
        return true;
    } else {
        return false;
    }
}

int caluculate_score_of_line(vector<int> &v, int bidx, int eidx) {
    int score_of_element = v[bidx];
    for (int i=bidx; i<=eidx; i++) {
        v[i] = 0;
    }
    return score_of_element * (eidx-bidx+1);
}

int apply_to_line(vector<int> &v) {
    int bef = 0, bef_count = 0, bidx = 0;
    for (int i=0; i<v.size(); i++) {
        if ((bef!=0)&&((bef!=v[i])||(v[i]==0))) {
            // ?????¶??????????????£?¶????????°???§????????´????????????
            if (bef_count>=3) {
                return caluculate_score_of_line(v, bidx, i-1);
            }
            bef_count = 0;
            bidx = i;
        }
        bef_count++;
        bef = v[i];
    }
    // ????°??????£?¶??????\???????????´????????????
    if (bef_count>=3) {
        return caluculate_score_of_line(v, bidx, v.size()-1);
    }
    return 0;
}

int apply_to_lines(vector< vector<int> > &v_v) {
    int score_of_lines = 0;
    for (int i=0; i<v_v.size(); i++) {
        score_of_lines += apply_to_line(v_v[i]);
    }
    return score_of_lines;
}

void disp_v(vector<int> &v) {
    for (int i=0; i<v.size(); i++) {
        cout << v[i] << " ";
    }
    cout << endl;
}

void disp_v_v(vector< vector<int> > &v_v) {
    for (int i=0; i<v_v.size(); i++) {
        disp_v(v_v[i]);
    }
}

int main() {
    int i, j, n, tmp;
    string s;
    while ((cin >> n) && (n != 0)) {
        int ans = 0;
        vector< vector<int> > v_v;
        for (i=0; i<n; i++) {
            vector<int> v;
            for (j=0; j<5; j++) {
                cin >> tmp;
                v.push_back(tmp);
            }
            v_v.push_back(v);
        }
        // disp_v_v(v_v);
        ans += apply_to_lines(v_v);
        // disp_v_v(v_v);
        // ?????¨???????????????????????°?¶???????
        // drop(v_v)???false????????£?????¨??????????????\???????????§?????????
        while (drop(v_v)) {
            ans += apply_to_lines(v_v);
            // disp_v_v(v_v);
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1216
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		// 計算
		String result = "No";
		int c = Integer.valueOf(Integer.toString(a) + Integer.toString(b));
		for(int i = 0; i < c; i++){
		    if(i*i == c) result = "Yes";
		}
		
		// 出力
		System.out.println(result);
	}
}



Measured memory_bytes: 23124
# -*- coding: utf-8 -*-
n = int(input())
s1 = input()
s2 = input()

mod = 1000000007

if s1[0]==s2[0]:
    i = 1
    ret = 3
else:
    i=2
    ret = 6

while i<n:
    if s1[i-1]==s2[i-1]:
        if s1[i]==s2[i]:
            ret *= 2
            i += 1
        else:
            ret *= 2
            i += 2
    else:
        if s1[i]==s2[i]:
            ret *= 1
            i += 1
        else:
            ret *= 3
            i += 2
print(ret%mod)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define M 1000000007

using namespace std;

// Solve function here


// End Solve function

int main(){
	//ios::sync_with_stdio(0);
	//cin.tie(0);
    //ifstream cin1("input.in");
	//clock_t start, finish;
	char temp = 'a'-1;
	long long n; cin >> n;
	
	string res = "";
	long long mod;
	while(n > 0){
			mod = n%26;
			n /= 26;
			if(mod == 0){
				res += 'z';
				n--;
			}
			else res += (temp+mod);
			
		}
		
		reverse(res.begin(), res.end());
		cout << res << endl;
	return 0;
}


Measured memory_bytes: 3512
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int solve(void);

int main(void)
{
	while (solve())
	{
	}

	return 0;
}

int solve(void)
{
	ll N, M;
	cin >> N >> M;
	if(!(N|M)) { return 0; }

	// v[i][0] = min, v[i][1] = max
	vector<vector<ll>> v(N, vector<ll>(2, 0));
	for (ll i = 0; i < M; i++)
	{
		ll S, k;
		cin >> S >> k;
		for (ll j = 0; j < k; j++)
		{
			ll c;
			cin >> c;
			// update min
			if (k == 1) {
				v[c-1][0] += S;
			}
			// update max
			v[c-1][1] += S;
		}
	}

	ll ans = 0;
	for (ll i = 0; i < N; i++)
	{
		for (ll j = 0; j < N; j++) {
			if(i == j) continue;
			ans = max(ans, v[i][1] - v[j][0] + 1);
		}
	}

	cout << ans << endl;

	return 1;
}


Measured memory_bytes: 3432
#include<bits/stdc++.h>
//#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main(){
    int n; cin >> n;
    vector<int> h(n);
    for(int i=0;i<n;i++) cin >> h[i];
    int count=0;
    int MaX=h[0];
    for(int i=1;i<n;i++){
        if(MaX>h[i]) continue;
        count++;
        MaX=max(MaX,h[i]);
    }
    cout << count+1<< endl;
    return 0;
}

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


int main()
{
    int64_t n, k, tmp;
    cin >> n >> k;

    auto h = std::multiset<int64_t>();

    for (int i=0; i<n; ++i) {
        cin >> tmp;
        h.insert(tmp);
    }


    if (n <= k) {
        cout << 0 << endl;
        return 0;
    }

    int64_t t = 0;
    for (auto it = next(h.rbegin(), k); it != h.rend(); it++) {
        t += *it;
    }


    cout << t << endl;


    return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

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

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

const string YES = "Yes";
const string NO = "No";

void solve(std::string S, std::string T){
    bool flag = true;
    REP(i, S.size()) {
        if(S[i] != T[i]) {
            flag = false;
        }
    }

    cout << (flag ? YES : NO) << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 3628
// 1_agc034_a
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    a--; b--; c--; d--;

    string s;
    cin >> s;
    int flag = 1;

    for(int i = a; i < c; i++){
        if(s[i] == '#' && s[i + 1] == '#'){
            flag = 0;
            break;
        }
    }
    for(int i = b; i < d; i++){
        if(s[i] == '#' && s[i + 1] == '#'){
            flag = 0;
            break;
        }
    }

    if(c > d){
        int tmp = 0;
        for(int i = b; i <= d ; i++){
            if(s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.'){
                tmp = 1;
                break;
            }
        }
        if(tmp == 0) flag = 0;
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 592
import static java.lang.Math.*;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        double[] p1 = {0, 0};
        double[] p2 = {100, 0};
        
        System.out.println(p1[0] + " " + p1[1]);
        kock(n, p1, p2);
        System.out.println(p2[0] + " " + p2[1]);
    }
    
    static void kock(int n, double[] p1, double[] p2){
        
        if(n == 0) return;
        
        double[] s = new double[2];
        s[0] = (2*p1[0] + p2[0])/3;
        s[1] = (2*p1[1] + p2[1])/3;
        
        double[] t = new double[2];
        t[0] = (p1[0] + 2*p2[0])/3;
        t[1] = (p1[1] + 2*p2[1])/3;
        
        double[] u = new double[2];
        u[0] = (t[0]-s[0]) * cos(toRadians(60)) - (t[1]-s[1]) * sin(toRadians(60)) + s[0];
        u[1] = (t[0]-s[0]) * sin(toRadians(60)) + (t[1]-s[1]) * cos(toRadians(60)) + s[1];
        
        kock(n-1, p1, s);
        System.out.println(s[0] + " " + s[1]);
        kock(n-1, s, u);
        System.out.println(u[0] + " " + u[1]);
        kock(n-1, u, t);
        System.out.println(t[0] + " " + t[1]);
        kock(n-1, t, p2);
    }
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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;
}

signed main() {
  string S;
  cin >> S;
  bool lastStateDown = true;
  vector<int> StateCount;
  int nowValue = 0;
  int ans = 0;
  int downCount = 0, upCount = 0;
  int lastUpVal = 0;
  rep(i, S.length()) {
    if (S[i] == '<') {
      if (lastStateDown) {
        lastStateDown = false;
        ans += max(nowValue, lastUpVal);
        nowValue = 0;
      }
      ans += nowValue;
      nowValue++;
    } else {
      if (!lastStateDown) {
        lastStateDown = true;
        lastUpVal = nowValue;
        nowValue = 0;
      }
      ans += nowValue;
      nowValue++;
    }

  }
  ans += nowValue;

  cout << ans << endl;

}


Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define hii cout << "hii" << endl
#define int long long
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int N = 5e5 + 5;
const int MAX = 250000 + 5;
const int M = 5e6 + 5;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int INF = 1e15;
const int LG = 21;

int col[N];
vector<int> row[N];

void solve()
{
	int h, w, m;
	cin >> h >> w >> m;
	set<pair<int, int>> s;
	for(int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		row[a].push_back(b);
		col[b]++;
	}
	for(int i = 1; i < N; i++)
	{
		if(col[i])
		{
			s.insert({col[i], i});
		}
	}
	int ret = 0;
	for(int i = 1; i < N; i++)
	{
		for(auto x : row[i])
		{
			s.erase({col[x], x});
			col[x]--;
			s.insert({col[x], x});
		}
		auto it = s.end();
		it--;
		int temp = row[i].size() + it -> first;
		ret = max(ret, temp);
		for(auto x : row[i])
		{
			s.erase({col[x], x});
			col[x]++;
			s.insert({col[x], x});
		}
	}
	cout << ret << endl;
}
 
int32_t main() 
{	
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

Measured memory_bytes: 45772
S = input()
n = len(S)
def kei(i,f):
    if i == n - 1:
        return sum(list(map(int,f.split("+"))))
    return kei(i+1,f+S[i+1])+\
           kei(i+1,f+"+"+S[i+1])
               
print(kei(0,S[0]))

Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys
from itertools import chain

# from itertools import combinations as comb
# form bisect import bisect_left, bisect_right, insort_left, insort_right
# from collections import Counter
# import numpy as np

YES = "Yes"  # type: str


def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    routes = [set() for _ in range(N)]
    marks = [None for _ in range(N)]
    for a, b in zip(A, B):
        a = a - 1
        b = b - 1
        routes[a].add(b)
        routes[b].add(a)

    marks[0] = -1
    cur_rooms = [0]
    count = 1
    while count < N:
        new_cur_rooms = []
        for cur_room in cur_rooms:
            next_rooms = list(routes[cur_room])
            for next_room in next_rooms:
                if marks[next_room] is None:
                    marks[next_room] = cur_room
                    new_cur_rooms.append(next_room)
                    count += 1
        cur_rooms = new_cur_rooms

    answer = "Yes\n" + "\n".join((str(n + 1) for n in marks[1:]))

    return answer


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # N, M, A, B = map(int, line.split())
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    answer = solve(N, M, A, B)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 141008
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int INF = 1e9 + 5;

void solve()
{
	ll n,w;cin >> n >> w;
	vector<vector<ll>> hash(n+1,vector<ll> (w+1,0));
	vector <ll> weights(n),values(n);
	for(ll i = 0; i<n; ++i)
	{
		cin >> weights[i] >> values[i];
	}
	
	for(ll i = 1; i<n+1;++i){
		for(ll j = 1;j<w+1;++j)
		{
			if(j<weights[i-1])
				hash[i][j] = hash[i-1][j];
			else
			{
				hash[i][j] = max(hash[i-1][j],values[i-1]+hash[i-1][j-weights[i-1]]);
			}
		}
	}
	cout << hash[n][w];
		
}

int main() {
    int t=1;
    while(t--)
		solve();
	
}


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

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

    string ans = "None";
    for (char i = 'a'; i <= 'z'; i++){

        if(S.find(i) == string::npos){
            ans = i;
            break ;
        }
            

        
    }

    cout << ans << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(in) in.begin(), in.end()
#define FIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int, int> PII;

vector<ll> adj[100005];
vector<pair<ll, ll> > ans;
ll dp[100005];

ll dfs(ll x, ll parent){
    dp[x] = 1;
    ll cnt = 0;
    for(ll i = 0 ; i < adj[x].size() ; i++){
        ll y = adj[x][i];
        if(y == parent){
            continue;
        }
        if(dp[y] == 1){
            cnt++;
            ans.push_back({x, y});
        }else if(dp[y] == 0){
            cnt += dfs(y, x);
        }
    }
    dp[x] = -1;
    if(parent == -1){
        return (ll)0;
    }
    if(cnt%2){
        ans.push_back({x, parent});
        cnt = 0;
    }else{
        ans.push_back({parent, x});
        cnt = 1;
    }
    return cnt;
}

int main(){
    FIO;
    ll n, m;
    cin >> n >> m;

    for(ll i = 0 ; i <= n ; i++){
        dp[i] = 0;
    }
    for(ll i = 0 ; i < m ; i++){
        ll x, y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    if(m%2){
        cout << "-1" << endl;
        return 0;
    }
    dfs((ll)1, -1);
    for(ll i = 0 ; i < m ; i++){
        cout << ans[i].first << " " << ans[i].second << endl;
    }
    return 0;
}


Measured memory_bytes: 17136
#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() {
	int k;
	string s;
  	cin >> k >> s;
  	if (s.size() <= k) cout << s << "\n";
  	else {
    	string ans = s.substr(0,k);
      	ans += "...";
      	cout << ans << "\n";
    }
  	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int sum=0;
  for (int i=0;i<N;i++){
    int x;
    cin >> x;
    if (x<=K-x){
      sum+=x;
    }
    if (x>K-x){
      sum+=(K-x);
    }
  }
  cout << sum*2 << endl;
}


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

public class Main {
	Scanner sc = new Scanner(System.in);
	int cnt[];
	int ans[];
	int info[][];
	boolean judge;
	int n, x, m;
	int max = 0;

	void run() {
		n = sc.nextInt();
		x = sc.nextInt();
		m = sc.nextInt();
		cnt = new int[n + 1];
		ans = new int[n + 1];
		info = new int[m][3];
		judge = false;
		for (int i = 0; i < m; i++) {
			info[i][0] = sc.nextInt();
			info[i][1] = sc.nextInt();
			info[i][2] = sc.nextInt();
		}
		Arrays.fill(ans, -1);
		dfs(0);
		if (ans[1] == -1) {
			System.out.println(-1);
		} else {
			for (int j = 1; j < n; j++) {
				System.out.print(ans[j] + " ");
			}
			System.out.println(ans[n]);
		}
	}

	void dfs(int oriCnt) {
		if (oriCnt == n + 1) {
			judge = false;
			for (int i = 0; i < m; i++) {
				int sum = 0;
				for (int j = info[i][0]; j <= info[i][1]; j++) {
					sum += cnt[j];
				}
				if (sum == info[i][2]) {
					judge = true;
				} else {
					judge = false;
				}
				if (!judge) {
					return;
				}
			}
			if (judge) {
				int sum = 0;
				for (int j = 1; j <= n; j++) {
					sum += cnt[j];
				}
				if (sum >= max) {
					max = sum;
					for (int k = 1; k <= n; k++) {
						ans[k] = cnt[k];
					}
				}
			}
			return;
		} else {
			for (int i = 0; i <= x; i++) {
				cnt[oriCnt] = i;
				dfs(oriCnt + 1);
			}
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 23900
#include <iostream>
#include <cstring>
#include <string>
using namespace std;

string x;
string y;

int lcs(string x, string y){

  int c[1024][1024] = {{}};
  string nul = "0";
  x = nul + x;
  y = nul + y;


  /*
  for(int i = 0;i < x.size();i++) cout << " " << x[i];
  cout << endl;
  for(int i = 0;i < y.size();i++) cout << " " << y[i];
  cout << endl;
*/
  for(int i = 1;i < x.size();i++){
    for(int j = 1;j < y.size();j++){
      if(x[i] == y[j] ) c[i][j] = c[i - 1][j - 1] + 1;
      else  c[i][j] = max(c[i - 1][j],c[i][j - 1]);

/*
      for(int k = 1;k < x.size();k++){
        for(int l = 1;l < y.size();l++){
          cout << c[k][l] << ' ';
        }
        cout << endl;
      }
*/

    }
  }

  return c[x.size() - 1][y.size() - 1];
}



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

  for(int i = 0;i < q;i++){
    cin >> x;
    cin >> y;
    cout << lcs(x,y) << endl;
  }
}

Measured memory_bytes: 7276
# -*- coding: utf-8 -*-
def input_str(row):
    res = []
    for _ in range(row):
        res.append(raw_input().split())
    return res

N = int(raw_input())
balls = input_str(N)
balls = sorted([sorted([int(x), int(y)]) for x, y in balls], key=lambda x: x[0])
#rmin == min, bmax == max
xmax = max(balls, key=lambda x: x[0])[0]
xmin = min(balls, key=lambda x: x[0])[0]
ymax = max(balls, key=lambda x: x[1])[1]
ymin = min(balls, key=lambda x: x[1])[1]
res1 = (xmax - xmin) * (ymax - ymin)

maxdiff = max(xmax, ymax) - min(xmin, ymin)
#rmin == min, rmax == max
diff = xmax - xmin
mina = xmax

for i in range(N)[:-1]:
    mina = min(balls[i][1], mina)
    xmax = max(balls[i][1], xmax)
    xmin = min(balls[i+1][0], mina)
    diff = min(diff, xmax - xmin)

res2 = maxdiff * diff

print min(res1, res2)


Measured memory_bytes: 104552
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
using Int = long long;
int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    int result = 0;
    for (int i = 1; i < N; i++) {
        unsigned int bits = 0;
        for (int j = 0; j < i; j++) {
            bits |= (1 << (S[j] - 'a'));
        }
        int count = 0;
        for (int j = i; j < N; j++) {
            unsigned int bit = 1 << (S[j] - 'a');
            if (bits & bit) {
                count++;
                bits &= ~bit;
            }
        }
        result = max(result, count);
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
    int main(){
        char s[4];
        char sun[4] = "SUN";
        char mon[4] = "MON";
        char tue[4] = "TUE";
        char wed[4] = "WED";
        char thu[4] = "THU";
        char fri[4] = "FRI";
        char sat[4] = "SAT";
        while(~scanf("%s",s)){
            if(strcmp(s,sun) == 0){
                printf("7\n");
            }else if(strcmp(s,mon) == 0){
                printf("6\n");
            }else if(strcmp(s,tue) == 0){
                printf("5\n");
            }else if(strcmp(s,wed) == 0){
                printf("4\n");
            }else if(strcmp(s,thu) == 0){
                printf("3\n");
            }else if(strcmp(s,fri) == 0){
                printf("2\n");
            }else if(strcmp(s,sat) == 0){
                printf("1\n");
            }
        }
    }


Measured memory_bytes: 128
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-11 16:52:38
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++)
        cin >> d[i];

    sort(all(d), rev(int));

    int prev = INF;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int r = d[i];
        if (r < prev) {
            ans++;
            prev = r;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 510;
int n, m, q;

int f[N][N], tmp[N][N];

int main() {
	scanf("%d%d%d", &n, &m, &q);
	for(int i = 1 ; i <= m ; ++ i) {
		int l, r;
		scanf("%d%d", &l, &r);
		tmp[l][r] ++;
	}
	for(int i = 1 ; i <= n ; ++ i) f[i][i] = tmp[i][i];
	for(int len = 2 ; len <= n ; ++ len) {
		for(int i = 1 ; i + len - 1 <= n ; ++ i) {
			int j = i + len - 1;
			f[i][j] = f[i][j - 1];
			for(int k = i ; k <= j ; ++ k) f[i][j] += tmp[k][j];
//			printf("f[%d][%d] = %d\n", i, j, f[i][j]);
		}
	}
	for(int i = 1 ; i <= q ; ++ i) {
		int l, r;
		scanf("%d%d", &l, &r);
		printf("%d\n", f[l][r]);
	}
}

Measured memory_bytes: 2944
#include <bits/stdtr1c++.h>
using namespace std;
#define INP "solve"
#define OUT "solve"
const int QQ = 3e5 + 10;
const int maxN = 3e5 + 10;
const int maxM = 3e5 + 10;
const int oo = 1e9;
const int module = 1e9 + 7;
const long double du = 1e-9;

void doc() {
    freopen(INP ".inp","r",stdin);
    freopen(OUT ".out","w",stdout);
}

long long D[maxN];
vector <int> a[maxN];
void DFS(int u) {
    for (int v : a[u]) {
        D[v] += D[u];
        DFS(v);
    }
}
void solve() {
    int n, Q;
    cin >> n >> Q;
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        a[u].push_back(v);
    }
    for (int i = 1; i <= Q; i++) {
        int p, x;
        cin >> p >> x;
        D[p] += x;
    }
    DFS(1);
    for (int i = 1; i <= n; i++) cout << D[i] << ' ';
}
int main(int argc,char *argv[]) {
    //srand(time(nullptr));
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //doc();
    solve();
}


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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define azazax x1
#define azazay y1
#define azazaz prev

using namespace std;

typedef long long ll;
typedef long double ld;

const int max_n = 2e9, inf = 1000111222;

int main() {
    string s;
    int w;
    cin >> s;
    cin >> w;
    for (int i = 0; i < s.size(); i += w) {
        cout << s[i];
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<cstring>
using namespace std;
int main()
{
	string a;
	cin>>a;
	int x,y;
	x=((int)a[0]-48)*10+(int)a[1]-48;
	y=((int)a[2]-48)*10+(int)a[3]-48;
	if(x>0&&x<13)
	{
		if(y>0&&y<13)
		{
			cout<<"AMBIGUOUS";
			return 0;
		}
		cout<<"MMYY";
		return 0;
	}
	else
	{
		if(y>0&&y<13)
		{
			cout<<"YYMM";
			return 0;
		}
		cout<<"NA";
		return 0;
	}
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {

	static ArrayList<ArrayList<Edge>> edge;
	static long dist[];

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);

		edge = new ArrayList<>();
		dist = new long[n];

		for (int i = 0; i < n; i++) {
			edge.add(new ArrayList<>());
		}

		for (int i = 0; i < n - 1; i++) {
			str = br.readLine().split(" ");
			int a = Integer.parseInt(str[0]) - 1;
			int b = Integer.parseInt(str[1]) - 1;
			int c = Integer.parseInt(str[2]);

			edge.get(a).add(new Edge(b, c));
			edge.get(b).add(new Edge(a, c));
		}

		str = br.readLine().split(" ");
		int q = Integer.parseInt(str[0]);
		int k = Integer.parseInt(str[1]) - 1;

		dfs(k, -1, 0);

		for (int i = 0; i < q; i++) {
			str = br.readLine().split(" ");
			int x = Integer.parseInt(str[0]) - 1;
			int y = Integer.parseInt(str[1]) - 1;

			System.out.println(dist[x] + dist[y]);
		}
	}

	static void dfs(int s, int p, long add) {
		dist[s] = add;

		for (int i = 0; i < edge.get(s).size(); i++) {
			if (edge.get(s).get(i).to == p) {
				continue;
			}
			dfs(edge.get(s).get(i).to, s, add + edge.get(s).get(i).cost);
		}
	}
}

class Edge implements Comparable<Edge> {
	int to;
	int cost;

	public Edge(int to, int cost) {
		this.to = to;
		this.cost = cost;
	}

	public int compareTo(Edge e) {
		return this.cost - e.cost;
	}
}

Measured memory_bytes: 106944
import java.util.*;

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

		while(true)
		{
			int x = scan.nextInt();
			int y = scan.nextInt();

			if (x == 0 && y == 0)
			{
				break;
			}

			if (x >= y)
			{
				System.out.println(y + " " + x);
			}
			else if (x < y)
			{
				System.out.println(x + " " + y);
			}
		}
	}
}



Measured memory_bytes: 34632
#include <iostream>
#include <cstdio>
#include <cmath>
 
using namespace std;
 
int main(int argc, char *argv[])
{
  double x,y;
  double sumE = 0;
  double sumN = 0;
  double rad = M_PI/2.0;
  while(scanf("%lf,%lf",&x,&y) !=EOF ){
    getchar();
    if(x ==0&& y== 0)
      break;
    sumE += x*cos(rad);
    sumN += x*sin(rad);
    rad  -= y*M_PI/180;
  }
  cout <<(int)sumE <<endl<<(int)sumN <<endl;
  return 0;
}


Measured memory_bytes: 1236
from collections import defaultdict
import math


def main():
    n = int(input())
    mod = 1000000007
    zeroes = 0
    counter1 = defaultdict(int)
    counter2 = defaultdict(int)
    for _ in range(n):
        x, y = [int(x) for x in input().split()]

        if x == y == 0:
            zeroes += 1
            continue

        denominator = math.gcd(x, y)
        x, y = x // denominator, y // denominator

        if y < 0:
            # quadrant III, IV -> I, II
            x, y = -x, -y

        if x <= 0:
            # round 90° from quadrant II to I
            x, y = y, -x
            counter2[(x, y)] += 1
            counter1[(x, y)] += 0
        else:
            counter1[(x, y)] += 1
            counter2[(x, y)] += 0

    ans = 1
    for k, v in counter1.items():
        now = 1
        now += pow(2, v, mod) - 1
        now += pow(2, counter2[k], mod) - 1
        ans = ans * now % mod
    ans += zeroes
    ans -= 1  # choose no fish
    return ans % mod


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 68176
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
ans = 0

x,y = map(int,input().split())

if x == y:
  print('Yes')
elif x in a and y in a:
  print('Yes')
elif x in b and y in b:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064