akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        String s = fs.next();
        long k = fs.nextLong();
        for (char c : s.toCharArray()) {
            if (c == '1') {
                if (k == 1) {
                    System.out.println(1);
                    return;
                }
                k--;
            } else {
                System.out.println(c);
                return;
            }
        }
    }

    static final class Util {
        public static void shuffleSort(int[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffleSort(long[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffle(int[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void shuffle(long[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void swap(int[] x, int i, int j) {
            final int t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        public static void swap(long[] x, int i, int j) {
            final long t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        private Util() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        int[] nextIntArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}


Measured memory_bytes: 32516
import java.util.*;

public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    
    String ans = "No";
    int a = sc.nextInt();
    
    String as = String.valueOf(a);
    String x = as.substring(0, 1);
    String y = as.substring(1, 2);
    String z = as.substring(2, 3);
 
    if ("7".equals(x) || "7".equals(y) || "7".equals(z)) {
      ans = "Yes";
    }
 
    System.out.println(ans);
  }
}

Measured memory_bytes: 27032
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(N);
    int sum = 0;
    REP(i, N){
        cin >> a[i];
        sum += a[i];
    }
    int cnt = 0;
    REP(i, N) if (a[i] * 4 * M >= sum) cnt++;
    string ans = (cnt >= M) ? "Yes" :"No";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <list>
#include <map> //連想配列
#include <queue>
#include <set> //
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector> //動的配列

using namespace std;

int main() {
  char *s1 = (char *)malloc(11);
  char *s2 = (char *)malloc(11);
  char *s3 = (char *)malloc(11);
  cin >> s1 >> s2 >> s3;
  char S1 = *s1 - 32;
  char S2 = *s2 - 32;
  char S3 = *s3 - 32;
  cout << S1 << S2 << S3 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(a) cout << #a << ": " << a << endl
int main(){
	//freopen("input.txt", "r",stdin);
	int n, k; cin>>n>>k;
	vector<int> a(n);
	for(int i =0; i<n; i++){
		cin>>a[i];
	}
	sort(a.begin(), a.end());
	long long ans = 0;
	for(int i =0; i < n - k; i++){
			ans += a[i];
			//debug(a[i]);
	}
	cout<<ans<<endl;
	return 0;
}
	


Measured memory_bytes: 1024
a,b=map(int,input().split())
#print(ab)
x=input()
#print(x)
x1=x[:a]
x2=x[a]
x3=x[a+1:a+b+1]
#print(x1)
#print(x2)
#print(x3)


if x2=="-" and  (all(x1[i] in ["0","1","2","3","4","5","6","7","8","9"] for i in range(a))) and (all(x3[j] in ["0","1","2","3","4","5","6","7","8","9"]   for j in range(b))):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)


int main(){
	int n;
	cin>>n;
	vector<string> v(n);
	rep(i,n){
		cin>>v[i];
	}
	
	
	int p = 0;
	
	rep(i,v.size()){
		if(v[i]=="A")p++;
		else p--;
		if(p<0){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	if(p==0)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 3124
N=int(input())
H=list(map(int,input().split()))
if N==1:
    print("Yes")
    exit()
for i,h in enumerate(H):
    if i==N-1:continue
    if i==0:
        if H[0]-H[1]<=1:
            H[0]-=1
        else:
            print("No")
            exit()
        continue
    if (H[i-1]==H[i] and H[i]-H[i+1]>0) or H[i]-H[i+1]>1:
        print("No")
        exit()
    elif H[i-1]<H[i]:
        H[i]-=1
print("Yes")

Measured memory_bytes: 14396
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

using namespace std;

int main() {
  string p[3];
  char men[3] = {'A', 'B', 'C'};
  int idx[3] = {};
  for (int i=0; i<3; i++) cin >> p[i];
  int who = 0;
  while(1) {
    if ((int)p[who].length() == idx[who]) {cout << men[who] << endl; return 0;}
    idx[who]++;
    who = p[who][idx[who]-1] - 'a';
    //while(p[i].length() > idx[i] && p[i][idx[i]-1] == men[i]+32) idx[i]++;
    //cout << men[i] << " " << idx[i] << endl;
    //if ((int)p[i].length() == idx[i]) {cout << men[i] << endl; return 0;}
  }
  return 0;
}


Measured memory_bytes: 3600
#include<stdio.h>
#include<math.h>
int main()
{
	int a,b,c[12][12],i,j,k,m,d=0;
	scanf("%d%d",&a,&b);
	for(i=0;i<a;i++)
	{
		for(j=0;j<b;j++)
		scanf("%d",&c[i][j]);
	}
	for(k=0;k<a-1;k++)
	{
		for(i=k+1;i<a;i++)
		{   float t=0;
			for(j=0;j<b;j++)
			{t=t+(c[k][j]-c[i][j])*(c[k][j]-c[i][j]);
			
			}
			m=sqrt(t);
		if(m-sqrt(t)==0)
			{
			d++;	
			}
		}
	}
	printf("%d",d);
 } 

Measured memory_bytes: 128
#include <stdio.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n)  FOR(i,0,n)

int main(){
	int n, f[100][10], p[100][11];
	int max, dup, tmp;
	scanf("%d",&n);
	REP(i,n)
		REP(j,10)
			scanf("%d",&f[i][j]);
	REP(i,n)
		REP(j,11)
			scanf("%d",&p[i][j]);

	max = -2e9;
	//営業時間の組み合わせを10桁の2進数で表す
	FOR(i,1,1<<10) {
		tmp = 0;
		FOR(j,0,n) {
			dup = 0;
			FOR(k,0,10) {
				if((i>>k & 1) & f[j][k]) dup++;
			}
			tmp += p[j][dup];
		}
		if(max < tmp) max = tmp;
	}
	printf("%d\n",max);
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    for (int i = 0; i<N; i++)
    {
        cin >> S.at(i);
    }
    /*
    int count = N;
    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            if (i != j && S.at(i) == S.at(j))
            {
                count--;
                S.at(i) = "aaaaaaaaaaaaaahkrstomnjaibgdfnabdi";
                break;
            }
        }
    }
    cout << count << endl;
    */
   sort(S.begin(), S.end());
   S.erase(unique(S.begin(), S.end()), S.end());
   cout << S.size() << endl;
}

Measured memory_bytes: 9596
import java.util.Scanner;
import java.util.Arrays;
public class Main {

	
	public static void main(String[] args) {
		// Write your code here
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int n = sc.nextInt();
        int a[] = new int[n+1];
        long b[] = new long[n+1];
        for(int i=1;i<=n;i++) {
            a[i]=sc.nextInt();
            b[i]=sc.nextLong();
        }
        int max=(int)Math.pow(10,4);
        long dp[][] = new long[n+1][max+1];
        for(long row[]:dp)
        {
            Arrays.fill(row,Long.MAX_VALUE);
        }
        for(int i=0;i<=n;i++)
        {
            dp[i][0]=0;
        }
        for(int i=1;i<=max;i++) dp[0][i]=Long.MAX_VALUE;
        long min=Long.MAX_VALUE;
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=max;j++)
            {
                if(a[i]>j){
                    dp[i][j]=dp[i-1][j];
                }
                else if(dp[i-1][j-a[i]]!=Long.MAX_VALUE && dp[i-1][j-a[i]]!=Long.MAX_VALUE)
                {
                    dp[i][j]=Math.min(dp[i-1][j-a[i]]+b[i],Math.min(dp[i-1][j],dp[i][j-a[i]]+b[i]));
                }
                else if(dp[i-1][j-a[i]]!=Long.MAX_VALUE)
                {
                    dp[i][j]=Math.min(dp[i-1][j],dp[i-1][j-a[i]]+b[i]);
                }
                else if(dp[i][j-a[i]]!=Long.MAX_VALUE)
                {
                    dp[i][j]=Math.min(dp[i-1][j],dp[i][j-a[i]]+b[i]);
                }
                else dp[i][j]=dp[i-1][j];
                if(j>=h) min=Math.min(min,dp[i][j]);
                
                
            }
            
        }
        System.out.println(min);
	}
}

Measured memory_bytes: 129852
#include<stdio.h>
long int gcd(long int num1,long int num2)
{
	long int t,r=1;
	if(num1<num2)
	{
		t = num1;
		num1 = num2;
		num2 = t;
	}
	while(r != 0)
	{
		r = num1 % num2;
		num1 = num2;
		num2 = r;
	}
	return num1;
}

int main(void)
{
	long int num1,num2;
    long int ans;
	char str[64];
	
	fgets(str,sizeof(str),stdin);
	sscanf(str,"%ld %ld",&num1,&num2);
	
	ans = num1 * num2;
	ans /= gcd(num1,num2);
	
	printf("%ld",ans);
	
	return 0;
}


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

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    s = input()
    n = len(s)
    """
    s = d0d1...dn-1
    Tk = dk...dn-1 とする
    Tn = 0
    Tk = T(k+1) + dk * 10^(n-k-1) で計算可能
    s[i:j] = di...d(j-1)
           = (Ti - Tj) * 10^(n-j)
    s[i:j] ≡ 0 (mod 2019) <=> Ti ≡ Tj (mod 2019) で判定可能
    """

    dp = [0] * (n + 1)
    for i in range(n-1, -1, -1):
        dp[i] = (dp[i+1] + int(s[i]) * pow(10, n - i - 1, 2019)) % 2019
    # print(dp)
    prev_dict = defaultdict(int)
    cnt = 0
    for i in range(n, -1, -1):
        cnt += prev_dict[dp[i]]
        prev_dict[dp[i]] += 1
    print(cnt)


if __name__ == "__main__":
    main()

Measured memory_bytes: 16480
def nabeatsu(n):
    if(n % 3 == 0):
        return True
    temp = n
    while(temp > 0):
        if(temp % 10 == 3):
            return True
        temp = temp // 10
    return False

x = int(input())
for i in range(x):
    if(nabeatsu(i + 1)):
        print(' ', end = '')
        print(i + 1, end = '')
print()


Measured memory_bytes: 6248
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    bool ans = (abs(a - c) <= d) || (abs(a - b) <= d && abs(b - c) <= d);

    cout << (ans ? "Yes\n" : "No\n");
    return 0;
}



Measured memory_bytes: 256
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

string n;
int dp[1000003][2];
signed main(){
    cin >> n;
    n = '0' + n;
    int ind = 1;
    for (auto it = n.rbegin(); it != n.rend(); it++){
        char c = *it;
        int dig = c - '0';
        dp[ind][0] = dp[ind-1][0] + dig;
        if (dig != 9) dp[ind][0] = min(dp[ind][0], dp[ind-1][1] + (dig + 1) % 10);
        dp[ind][1] = dp[ind-1][0] + 10 - dig;
        if (ind > 1) dp[ind][1] = min(dp[ind][1], dp[ind-1][1] + 10 - dig - 1);
        
        ind++;
    }
    ind--;
    cout << min(dp[ind][0], dp[ind][1]) << endl;
}

Measured memory_bytes: 16944
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int NIL = -1;
const long long INF = 1LL << 60;
const long long MOD = 1e9+7;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main() {
  string S; cin >> S;
  int a = 10 * (S[0] - '0') + (S[1] - '0');
  int b = 10 * (S[2] - '0') + (S[3] - '0');
  if (a >= 1 && a <= 12) {
    if (b >= 1 && b <= 12) {
      cout << "AMBIGUOUS" << endl;
    }
    else {
      cout << "MMYY" << endl;
    }
  }
  else {
    if (b >= 1 && b <= 12) {
      cout << "YYMM" << endl;
    }
    else cout << "NA" << endl;
  }
}


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

const ll mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;
  rep(i, 60) {
    ll x = 0;
    rep(j, n) if (a[j]>>i&1) ++x;
    ll now = x*(n-x)%mod;
    rep(j, i) now = now * 2 %mod;
    ans += now;
    ans %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int c[20];
int d[50001] = { 0 };

int main()
{
	int n, m;

	cin >> n >> m;
	rep(i, m) cin >> c[i];
	sort(c, c + m);

	rep(i, m) {
		rep(j, n + 1) {

			if (i == 0 && j % c[i] == 0) {
				d[j] = j / c[i];
				continue;
			}

			if (j >= c[i]) d[j] = min(d[j], d[j - c[i]] + 1);
		}
	}

	cout << d[n] << endl;

	return 0;
}


Measured memory_bytes: 3360
#include <stdio.h>

int N;
long long x;


int main()
{

	long long Li = 0;
	long long Li1 = 1;
	long long Li2 = 2;
	
	

	scanf("%d", &N);

	

	for (int i = 2; i <= N;i++)
	{

		if (N <= 86) {
			Li = Li1 + Li2;
			x = Li1;
			Li1 = Li;
			Li2 = x;
		}
	}


	if (N == 1)
		printf("%d", Li1);

	else
		printf("%lld", Li);

	getchar(); getchar();
	return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,k;
  cin >> n >> k;
  vec a(n);
  for(ll i=0;i<n;i++) cin >> a[i],a[i]--;
  vec rep;
  rep.push_back(0);
  set<ll> al;
  al.insert(0);
  while(1) {
    ll nx=a[rep[rep.size()-1]];
    if(al.count(nx)) break;
    al.insert(nx);
    rep.push_back(nx);
    if(al.size()==n) break;
  }
  ll id;
  for(ll i=0;i<rep.size();i++) {
    ll nx=a[rep[rep.size()-1]];
    if(nx==rep[i]) {
      id=i;
      break;
    }
  }
  ll size=al.size()-id;
  if(k>=id) {
    k=((k-id)%size+id)%al.size();
  }
  cout << rep[k]+1 << endl;
}

Measured memory_bytes: 15508
#include<iostream>
#include<map>
#include<list>
#include<queue>
#include<vector>
#include<algorithm>
#include<climits>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define f   first
#define s   second
#define fastio ios_base::sync_with_stdio(0)\
               ;cin.tie(0)\
               ;cout.tie(0)    
#define forxN(x,n) for(int i=x;i<n;i++)
#define forNx(n,x) for(int i=n;i>=x;i--)  
#define vll    vector<ll> 
#define vpll   vector<pair<ll,ll> >
#define vill   vector<pair<int,int> >
#define wloop   int t\
               ;cin>>t\
               ;while(t--)



int main(){
    fastio;
    int n;cin>>n;
    int a[n];
    forxN(0,n){
        cin>>a[i];
    }
    int dp[n];
    dp[0]=0;
    ll sum=0;
    forxN(1,n){
    		if(i>1){
    			dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    		}
    		else dp[1]=abs(a[1]-a[0]);
    }
    // forxN(0,n){
    // 	cout<<dp[i]<<" ";
    // }
    cout<<dp[n-1];
    cout<<'\n';
    
    return 0;
}

Measured memory_bytes: 4436
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N, H, W;
  cin >> N >> H >> W;

  cout << (N-H+1)*(N-W+1) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int d[101];
  bool v[101];
  int map[101][101];
  int mx=99999999,mn,z,a,b,c,dd,e,hozon,k,n;
  while(1){
    for(int i=0;i<101;i++){
      for(int j=0;j<101;j++){
	map[i][j]=mx;
      }
      d[i]=mx;
    }
    cin>>n>>k;
    if(n==0&&k==0)break;
    for(int i=0;i<k;i++){
      cin>>z;
      if(z==1){
	cin>>c>>dd>>e;
	if(map[c][dd]>e){
	  map[c][dd]=e;
	  map[dd][c]=e;
	}
      }else{
	cin>>a>>b;
	for(int j=0;j<101;j++){
	  d[j]=mx;
	  v[j]=false;
	}
	d[a]=0;
	while(1){
	  mn=mx;
	  for(int j=0;j<=n;j++){
	    if(mn>d[j]&&v[j]==false){
	      mn=d[j];
	      hozon=j;
	    }
	  }
	  //cout<<hozon<<endl;
	  if(mn==mx)break;
	  v[hozon]=true;
	  for(int j=0;j<=n;j++){
	    if(d[j]>map[hozon][j]+d[hozon])d[j]=map[hozon][j]+d[hozon];
	  }
	}
	if(d[b]==mx){
	  cout<<-1<<endl;
	}else{
	  cout<<d[b]<<endl;
	}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1200
#include<cstdio>
#include<algorithm>
using namespace std;
void dfs(int j,int sum);
bool ans[2001];
int a[2001];
int n;
int main(){

  int m,b;
  scanf("%d",&n);
  for(int i = 1;i <= n;i++) scanf("%d",&a[i]);

  fill(ans,ans+2001,0);
  dfs(0,0);
  
  scanf("%d",&m);
  for(int i = 0;i < m;i++){
    scanf("%d",&b);
    if(ans[b] == 1) printf("yes\n");
    else printf("no\n");
  }
  return (0);
}

void dfs(int j,int sum){
  if(ans[sum] != 1) ans[sum]++;
  if(j <= n){
    dfs(j+1,sum+a[j]);
    dfs(j+1,sum);
  }
}

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	for (auto &x : a) {
		cin >> x;
	}
	sort(a.rbegin(), a.rend());

	int s[2] = { 0 };
	for (auto i = 0u; i < a.size(); ++i) {
		s[i % 2] += a[i];
	}
	cout << s[0] - s[1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
const int mod = 1000000007;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
int main(){
    int n;cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    mint ans=1;
    vector<int> pos(n);
    for(int i=0;i<n;i++){
        if(a[i]==0){
            ans*=3-pos[0];
            pos[0]++;
        }
        else{
            ans*=pos[a[i]-1]-pos[a[i]];
            pos[a[i]]++;
        }
    }
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 1408
#!ruby -p
exit if/\./=~a=$_
0 while a.gsub!(/[-+]*\?/,?A)||a.gsub!(/(\+|-)(\w)/){eval"(65+($2.ord-65#{$1}1)%26).chr"}||a.gsub!(/\[([-+\w]+?)\]/){$1.scan(/[-+]*\w/).reverse*''}

Measured memory_bytes: 9896
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int n,d;
    int count=0;
    float x,y;
    cin>>n>>d;
    for ( int i=0;i<n;++i)
    {
        cin>>x>>y;
        if (sqrt(pow(x,2)+pow(y,2))<= d)
        count++;
    }
    cout<<count;

    return 0;
}


Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,mod,div,i;
    string s;
    vector<char>v;
    cin>>n;
    while(n>0)
    {
        n--;
        mod=n%26;
        //div=n/26;
        n/=26;
        /*if(mod==0)
        {
            mod=26;
            n--;
        }*/
        char j='a'+mod;
        v.push_back(j);
        //cout<<mod<<endl;
    }
    reverse(v.begin(),v.end());
    for(i=0; i<v.size(); i++)
        cout<<v[i];
    v.clear();
    return 0;
}


Measured memory_bytes: 3632
N=gets.to_i
array=gets.chomp.split(" ").map(&:to_i)
MEMO={}
MEMO[0] = 1
now=0
array.each do |a|
    now += a
    MEMO[now] ||= 0
    MEMO[now] += 1
end
ret = 0
MEMO.each do |k,v|
    ret += (v-1)*v/2
end
puts ret


Measured memory_bytes: 39528
//test


#include<cstdio>
typedef long long ll;
const int MAXN = 500;
const int MAXM = 10000;
bool vis[MAXM + 5];
int prm[MAXM + 5], pcnt = 0;
ll GCD(ll x, ll y) {
	return y == 0 ? x : GCD(y, x%y);
}
ll LCM(ll x, ll y) {
	return x / GCD(x, y) * y;
}
void sieve() {
	for(int i=2;i<=MAXM;i++) {
		if( !vis[i] ) prm[++pcnt] = i;
		for(int j=1;i*prm[j]<=MAXM;j++) {
			vis[i*prm[j]] = true;
			if( i % prm[j] == 0 ) break;
		}
	}
}
ll Mat[MAXN + 5][MAXN + 5];
int main() {
	sieve(); int N;
	scanf("%d", &N);
	if( N == 2 ) {
		printf("4 7\n23 10\n");
		return 0;
	}
	for(int i=1;i<=N;i++)
		for(int j=1;j<=N;j++)
			Mat[i][j] = 1;
	for(int i=1;i<=N;i++)
		for(int j=1;j<=N;j++)
			if( (i & 1) == (j & 1) ) {
				Mat[i][j] = prm[(i + j) / 2] * prm[(i+N+1-j)/2 + N];
				Mat[i+1][j] = LCM(Mat[i+1][j], Mat[i][j]);
				Mat[i-1][j] = LCM(Mat[i-1][j], Mat[i][j]);
				Mat[i][j+1] = LCM(Mat[i][j+1], Mat[i][j]);
				Mat[i][j-1] = LCM(Mat[i][j-1], Mat[i][j]);
			}
	for(int i=1;i<=N;i++)
		for(int j=1;j<=N;j++)
			if( (i & 1) != (j & 1) )
				Mat[i][j]++;
	for(int i=1;i<=N;i++) {
		for(int j=1;j<N;j++)
			printf("%lld ", Mat[i][j]);
		printf("%lld\n", Mat[i][N]);
	}
}

Measured memory_bytes: 5120
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007

int main(){
    int x,ans=0,max=0,mod=0,cur=5;
    scanf("%d",&x);
  	max=x/100;mod=x%100;
  	while(mod!=0){
      if(cur<=mod){
        mod-=cur;ans++;
      }else cur--;
    }
  	if(max>=ans) printf("%d",1);
  	else printf("%d",0);
    return 0;
}



Measured memory_bytes: 1712
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

int SURP = 1000000007;

long long int fact(int N){
	long long int ret = 1;
	FOR(i,1,N+1){
		ret = (ret * i)% SURP;
	}
	return ret;
}

int main(){
	int N,T;
	cin >> N >> T;
	int time[N];
	FOR (i,0,N) cin >> time[i];

	int ret = 0;
	if (N > 1){
		FOR(i,1,N){
			int d = time[i] - time[i-1];
			ret += min(d,T);
		}
		ret += T;
	}else{
		ret = T;
	}

	cout << ret << endl;
	return 0;
}


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

int main() {
  int N ;
  cin >> N ;
  
  
  vector<int> vec(N);
  for(int i=0; i<N;i++){
    cin >> vec.at(i);
    int c=0;
    while(vec.at(i)>0){
      if(vec.at(i)%2!=0){
        break;
      }
      else{
        vec.at(i)=vec.at(i)/2;
      c++;
      }
    }
    vec.at(i)=c;
  }
  
    sort(vec.begin(),vec.end());
    
    cout << vec.at(0) << endl;
}

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

#define mp make_pair
#define pb push_back

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef vector<int> vi;

string s;
int k;

int main()
{
  cin >> s >> k;
  vector<string> sub;
  for (int i = 0; i < (int)s.length(); i++) {
    for (int c = 1; c <= k && i+c <= (int)s.length(); c++) {
      sub.pb(s.substr(i,c));
    }
  }

  sort(sub.begin(), sub.end());

  auto last = unique(sub.begin(), sub.end());
  sub.erase(last, sub.end());

  cout << sub[k-1] << endl;

  return 0;
}


Measured memory_bytes: 1660
N, M = map(int, input().split())  # 品物の数、割引券の枚数
A = list(map(int, input().split()))  # 品物の値段
A.sort(reverse=True)
i = 0
for _ in range(M):
    A[i] = A[i] // 2
    if i <= N - 2 and A[i] < A[i + 1] and A[0] < A[i+1]:
        i += 1
    else:
        A.sort(reverse=True)
        i = 0
print(str(sum(A)))

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    double k;
    int n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    int maxDiff = -1;
    sort(a.begin(), a.end());
    int tmp, ans = 0;
    rep(i, n) {
        if (i + 1 < n) tmp = a[i + 1] - a[i];
        else {
            tmp = a[i] - a[0];
            if (tmp > k / 2) tmp = (int) a[0] - (a[i] - k);

        }
        maxDiff = max(maxDiff, tmp);
        ans += tmp;
    }
    ans -= maxDiff;

    cout << ans << endl;

    return 0;
}

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

using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    string s;
    cin>>s;
    ll k;
    cin>>k;
    
    for(int i=0;i<k;i++){
         if(s[i]!='1'){
               cout<<s[i]<<endl;
               return 0;
         }
        if(i+1==s.size()){
            break;
        }
    }
    cout<<1<<endl;
     
    return 0;
}


Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;
const long long INF = 1e15;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N;
	cin >> N;
	int pay = 1000 * (N / 1000);
	if (pay < N)pay += 1000;
	cout << pay - N << "\n";
	return 0;
}

Measured memory_bytes: 3184
# -*- coding: utf-8 -*-
from collections import deque
d = deque() # 初期化

H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
Shw = [input() for _ in range(H)]

d.appendleft((Ch-1, Cw-1, 0))
score = [[-1] * W for _ in range(H)]
score[Ch-1][Cw-1] = 0

walk = [(-1, 0), (1, 0), (0, -1), (0, 1)]
warp = list()
for i in range(-2, 3):
  for j in range(-2, 3):
    if (i, j) != (0, 0) and (i, j) not in walk:
      warp.append((i, j))

while len(d) > 0:
  
  y, x, s = d.popleft()
  
  # walk
  for i in range(len(walk)):
    dy, dx = walk[i]
    if 0 <= y+dy < H and 0 <= x+dx < W: 
      if score[y+dy][x+dx] == -1 or score[y+dy][x+dx] > s:
        if Shw[y+dy][x+dx] == ".":
          d.appendleft((y+dy, x+dx, s))
          score[y+dy][x+dx] = s
          
  # warp
  for i in range(len(warp)):
    dy, dx = warp[i]
    if 0 <= y+dy < H and 0 <= x+dx < W:
      if score[y+dy][x+dx] == -1 or score[y+dy][x+dx] > s+1:
        if Shw[y+dy][x+dx] == ".":
          d.append((y+dy, x+dx, s+1))
          score[y+dy][x+dx] = s+1

print(score[Dh-1][Dw-1])

Measured memory_bytes: 97412
#include<cstdio>
#include<iostream>
#include<string.h>
using namespace std;

main(){
  int nosense;
  char type[3];
  int A=0,B=0,AB=0,O=0;
  while(scanf("%d,%2s",&nosense,type)!=EOF){
    
    if(strcmp(type,"A")==0)A++;//'A'ツづつオツづ按つ「ツづヲツつ、ツづ可陳債暗督！ツ！ツ！
    else if(strcmp(type,"B")==0)B++;
    else if(strcmp(type,"O")==0)O++;
    else AB++;
  } 
  cout << A << endl<<B<<endl<<AB<<endl<<O<<endl;

  return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, M: int):
    if N==M:
        print(YES)
    else:
        print(NO)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()


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

int main(int argc, char *argv[])
{
    vector<char> record;
    int m, f, r;

    while (true)
    {
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1)
            break;

        if (m == -1 || f == -1)
        {
            record.push_back('F');
            continue;
        }
        else if (m + f >= 80)
        {
            record.push_back('A');
            continue;
        }
        else if (m + f < 80 && m + f >= 65)
        {
            record.push_back('B');
            continue;
        }
        else if (m + f < 65 && m + f >= 50)
        {
            record.push_back('C');
            continue;
        }
        else if (m + f < 50 && m + f >= 30)
        {
            if (r >= 50)
                record.push_back('C');
            else
                record.push_back('D');
            continue;
        }
        else
        {
            record.push_back('F');
        }
    }

    for (char c : record)
    {
        cout << c << endl;
    }

    return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<59;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

bool f(vb a){
	int n=a.size();
	for(int i=0;i<n;i++) if(!a[i]) return 0;
	return 1;
}

int n;
string s;

int main(){
	cin>>s;
	n=s.size();
	int res=inf;
	for(int i=0;i<26;i++){
		vb a(n,0);
		bool flag=0;
		for(int j=0;j<n;j++) if((s[j]-'a')==i){
			a[j]=1;
			flag=1;
		}
		if(!flag) continue;
		int tmp=0;
		while(!f(a)){
			vb b(n-tmp-1,0);
			for(int j=0;j<n-tmp-1;j++){
				b[j]=a[j]|a[j+1];
			}
			a=b;
			tmp++;
		}
		res=min(res,tmp);
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const MAXN=550;
int N,M,Q;
int a[MAXN][MAXN];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);

  cin>>N>>M>>Q;
  rep(i,0,M) {
    int l,r;
    cin>>l>>r;
    a[l][r]++;
  }
  rep(i,1,N+1) rep(j,1,N+1) a[i][j]+=a[i][j-1];

  rep(i,0,Q) {
    int p,q;
    cin>>p>>q;
    int res=0;
    rep(j,p,q+1) res+=a[j][q];
    cout<<res<<"\n";
  }
}


Measured memory_bytes: 2048
#include <cstdio>
#include <cstdlib>
#include <stack>
using namespace std;

bool isOperator(char c){
    if((c == '+') || (c == '-') || (c == '*')) return true;
    else return false;
}

int operation(char ope, int x, int y){
    switch (ope) {
        case '+': return x + y;
        case '-': return x - y;
        case '*': return x * y;
        // dafault???
    }
}

int main(int argc, char const *argv[]) {
    char str[8];
    char delimiter;
    stack<int> operand; // ??????????????????????´???????????????????

    while(delimiter != '\n'){
        scanf("%s", str);
        // ??????????????\?????´???
        if(isOperator(str[0])){
            int y = operand.top();
            operand.pop();
            int x = operand.top();
            operand.pop();
            operand.push(operation(str[0], x, y));
        }
        // ????????\?????´???
        else{
            operand.push(atoi(str));
        }
        scanf("%c", &delimiter); // ???????????????????????????
    }
    printf("%d\n", operand.top());

    return 0;
}

Measured memory_bytes: 2764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define int long long

typedef long long ll;


const ll mod = 998244353;


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    map<int, int> m;
    vector<int> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        m[a[i]]++;
    }
    ll ans = 0;
    for(pair<int, int> t : m){
        ans += t.second * (t.second - 1) / 2;
    }
    for(int i = 0; i < n; ++i){
        ll res = ans;
        res -= (m[a[i]] - 1) * m[a[i]] / 2;
        m[a[i]]--;
        res += (m[a[i]] - 1) * m[a[i]] / 2;
        cout << res << endl;
        m[a[i]]++;
    }
}


Measured memory_bytes: 11904
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

for i in range(N):
    A[i] -=1

sum = B[A[0]]

for i in range(1,N): # 1,,,N-1
    if A[i]-A[i-1] ==1:
        sum += B[A[i]] + C[A[i-1]]
    else:
        sum += B[A[i]]

print(sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

int N=1<<18;
class StarrySkyTree{
public:
  ll Ma[555555],A[555555];
  void init(){memset(Ma,0,sizeof(Ma)),memset(A,0,sizeof(A));}
  void add(int a,int b,ll x,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      A[k]+=x;
      while(k){
        k=(k-1)/2;
        Ma[k]=max(Ma[k*2+1]+A[k*2+1],Ma[k*2+2]+A[k*2+2]);
      }
      return;
    }
    add(a,b,x,k*2+1,l,(l+r)/2);
    add(a,b,x,k*2+2,(l+r)/2,r);
  }
  ll getMax(int a,int b,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l)return -LLONG_MAX;if(a<=l&&r<=b)return Ma[k]+A[k];
    ll left=getMax(a,b,k*2+1,l,(l+r)/2),right=getMax(a,b,k*2+2,(l+r)/2,r);
    return max(left,right)+A[k];
  }
};

StarrySkyTree t;

int p[200001],r[200001];
void init(){rep(i,200001)p[i]=i,r[i]=0;}
int find(int x){return (p[x]==x)?x:(p[x]=find(p[x]));}
void unite(int x,int y) {
  x=find(x),y=find(y);
  if(x==y)return;
  if(r[x]<r[y])p[x]=y;
  else{p[y]=x;if(r[x]==r[y])r[x]++;}
}
bool same(int x,int y){return find(x)==find(y);}

void Main() {
  init();
  t.init();
  ll n;
  R n;
  P a[n];
  rep(i,n) R a[i].F;
  rep(i,n) R a[i].S;
  ll c[n],d[n];
  rep(i,n) {
    c[i]=a[i].F;
    d[i]=a[i].S;
  }
  sort(c,c+n);
  sort(d,d+n);
  rep(i,n) {
    if(c[i]>d[i]) {
      pr("No");
      return;
    }
  }
  set<ll> s;
  map<ll,ll> m;
  rep(i,n) {
    s.in(a[i].F);
    s.in(a[i].S);
  }
  tr(it,s) {
    ll k=m.size();
    m[*it]=k;
  }
  rep(i,n) {
    t.add(0,m[a[i].F]+1,1);
    t.add(0,m[a[i].S]+1,-1);
  }
  rep(i,n) {
    t.add(0,m[a[i].F]+1,-1);
    t.add(0,m[a[i].S]+1,1);
    if(a[i].F<=a[i].S&&t.getMax(0,m.size())<=0) {
      pr("Yes");
      return;
    }
    t.add(0,m[a[i].F]+1,1);
    t.add(0,m[a[i].S]+1,-1);
  }
  if(n>=4) {
    sort(a,a+n);
    rep(i,n) a[i].F=i;
    rep(i,n) swap(a[i].F,a[i].S);
    sort(a,a+n);
    rep(i,n) a[i].F=i;
    rep(i,n) unite(a[i].F,a[i].S);
    int cnt=0;
    rep(i,n) {
      if(find(i)==i) cnt++;
    }
    if(cnt!=1) {
      pr("Yes");
      return;
    }
  }
  pr("No");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

#define ff first
#define ss second
#define pb push_back

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 100005;
const int mod = 1e9 + 7;

ll expr(ll b, ll e){
	ll ans = 1;
	while(e){
		if(e & 1){
			ans = (ans * b) % mod;
		}
		e >>= 1;
		b = (b * b) % mod;
	}
	return ans;
}

ll C(ll k, ll n){
	ll ret = 1;
	for(int i = 1; i <= k; i++){
		ret *= ((n - (k - i)) * expr(i, mod-2)) % mod;
		ret %= mod;
	}
	return ret;
}

int main() {
	ll n, a, b;
	scanf("%lld %lld %lld", &n, &a, &b);
	ll ans = expr(2, n);
	ans -= C(a, n);
	ans += mod;
	ans %= mod;
	ans -= C(b, n);
	ans += mod;
	ans %= mod;
	ans = ((ans - 1) + mod) % mod;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "algorithm"
#include "map"
typedef long long i64;

i64 n;
i64 MODULO = (i64)(1e9 + 7);

std::map<i64, std::map<i64, i64>> map;

i64 f(i64 x, i64 y) {
	if (x == 0 && y == 0)
		return 1;
	if (x < 0 || y < 0)
		return 0;
	i64& ret = map[x][y];
	if (ret != 0)return ret;
	ret += f(x >> 1, y >> 1);
	ret += f((x - 1) >> 1, (y - 1) >> 1);
	ret += f((x - 2) >> 1, y >> 1);
	ret %= MODULO;
	return ret%MODULO;
}

int main() {
	std::cin >> n;
	std::cout << f(n, n);
	return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int a = in.nextInt();
            int b = in.nextInt();
            in.close();
            System.out.println(Function(a, b));
            
            
            
	}
	public static int Function(int a, int b) {
		if(b != 0)
			return Function(b, a % b);
		else
			return a;
	}
}
	


Measured memory_bytes: 26232
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b=mod-2,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;




int n, m, x[2020], y[2020], dp[2020][2020];

signed main() {
    cin >> n >> m;
    rep(i,n) cin >> x[i];
    rep(i,m) cin >> y[i];
    reps(i,1,n+1) reps(j,1,m+1) {
        if (x[i-1]==y[j-1]) dp[i][j] = (dp[i][j-1] + dp[i-1][j] + 1) %mod;
        else dp[i][j] = (dp[i][j-1] + dp[i-1][j] +mod - dp[i-1][j-1]) %mod;
    }
    cout << (dp[n][m] + 1)%mod << endl;
}

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

int main(){
    ll N,K;
    cin >> N >> K;
    char S[N];
    rep(i,N){
        cin >> S[i];
        if(i==K-1) S[i] += 32;
    }
    rep(i,N) cout << S[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
//AtCoder ABC111 A - AtCoder Beginner Contest 999
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
int main() {
    string n; cin>>n;
    for(auto&& c:n){
        if(c=='9') c='1';
        else if(c=='1') c='9';
    }
    cout<<n<<endl;
    return 0;
}

Measured memory_bytes: 256