akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN

#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)

/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}

void print(vector<vector<int> >& b, string s, int i, int j)
{
	if(i==0 or j==0)
	{
		return;
	}
	if(b[i][j]==1)
	{
		print(b, s, i-1, j-1);
		cout<<s[i-1];
	}
	else if(b[i][j]==3)
		print(b, s, i, j-1);
	else print(b, s, i-1, j);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s, t, ans="";
	cin>>s>>t;

	int m = s.size(), n = t.size();

	vector<vector<int> > a(m+1, vector<int> (n+1)), b(m+1, vector<int> (n+1));
	for(int i = 0; i <= m; i++)
	{
		a[i][0]=0;
	} 
	for(int i = 0; i <= n; i++)
	{
		a[0][i]=0;
	}
	for(int i = 1; i <= m; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			if(s[i-1]==t[j-1])
			{
				a[i][j]=1+a[i-1][j-1];
				b[i][j]=1;
			}
			else
			{
				if(a[i-1][j]>=a[i][j-1])
				{
					a[i][j]=a[i-1][j];
					b[i][j]=2;
				}
				else
				{
					a[i][j]=a[i][j-1];
					b[i][j]=3;
				}
				// a[i][j]=max(a[i-1][j], a[i][j-1]);
			}
		}
	}
	int i = m, j = n;
	while(i > 0 and j > 0)
	{
		if(s[i-1]==t[j-1])
		{
			ans+=s[i-1];
			i--;
			j--;
		}
		else
		{
			if(a[i][j]==a[i-1][j])
			{
				i--;
			}
			else if(a[i][j]==a[i][j-1]) j--;
		}
	}
	// cout<<i<<" "<<j<<endl;
	reverse(ans.begin(), ans.end());
	cout<<ans<<endl;
	// print(b, s, m, n);
}

Measured memory_bytes: 73936
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

// ---------------------
// repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// ---------------------
#define INF 922337203685477580
typedef long long ll;

int H;

void maxHeapify(ll *A, int i) {
  int l = 2 * i;
  int r = 2 * i + 1;
  // ????????????????????????????????§???????????§????????????????????¶
  int largest = -11111;
  if (l <= H && A[l] > A[i]) {
    largest = l;
  } else {
    largest = i;
  }
  if (r <= H && A[r] > A[largest]) {
    largest = r;
  }

  if (largest != i) {// i ???????????????????????§????????´???
    ll t = A[i];
    A[i] = A[largest];
    A[largest] = t;

    maxHeapify(A, largest); // ?????°??????????????????
  }
}

void buildMaxHeap(ll *A) {
  for (int i = H / 2; i >= 1; i--) {
    maxHeapify(A, i);
  }
}

void insert(ll *S, ll k) {
  H++;
  S[H] = k;

  int i = H;
  int parent = i / 2;
  while (i > 1 && S[parent] < S[i]) {
    swap(S[parent], S[i]);
    i = parent;
    parent = i / 2;
  }
}

ll extractMax(ll *S) {
  ll m = S[1];
  S[1] = S[H];
  H--;
  maxHeapify(S, 1);

  return m;
}

int main() {
  H = 0;
  ll A[2000000];

  while(1) {
    char cmd[20];
    // cin >> cmd;
    scanf("%s", cmd);

    if (cmd[0] == 'i') {  // insert
      ll key;
      // cin >> key;
      scanf("%lld", &key);

      insert(A, key);
    // } else if (cmd == "extract") {
    } else if (cmd[0] == 'e' && cmd[1] == 'x') {
      ll key = extractMax(A);
      // cout << key << endl;
      printf("%lld\n", key);
    } else {
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 11028
package main

import "fmt"

func main() {
  var X,Y int
  fmt.Scan(&X,&Y)
  
  if Y % 2 == 0 && Y/2 >= X && 2*X >= Y/2 {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
}

Measured memory_bytes: 1752
#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>;
#define INF 100000000



int main()
{
    /*
    int a[5];
    int ans=0;
    for(int i=0;i<5;i++)
    {
        cin>>a[i];
        if(a[i]==0)
        {
            ans = ++i;
        }
    }

    cout<<ans<<endl;
    */
    /*
    int x,y;
    cin>>x>>y;
    for(int i=0;i<=x;i++)
    {
        if(4*i+2*(x-i)==y)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    */
    int x,n;
    cin>>x>>n;
    vector <int>a(n);
    vector <pair<int,bool>> b(110);
    for(int i=0;i<110;i++)
    {
        b[i].first=i+1;
    }
   for(int i=0;i<n;i++)
    {
        cin>>a[i];
        b[a[i]-1].first=INF;
    }
    int minV = 10010;
    int ans = 0;
    for(int i=-1;i<110;i++)
    {
        if(i==-1)
        {
            minV = abs(x-0);
            ans = 0;
            continue;
        }
        if(abs(x-b[i].first)<minV)
        {
            minV = abs(x-b[i].first);
            ans = i+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] x = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }

        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += Math.min(x[i]*2, Math.abs(k-x[i])*2);
        }

        System.out.println(sum);
    }

}

Measured memory_bytes: 21076
# input
N, M = map(int, input().split())
W = []
V = []
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)

dp = [[None for __ in range(M+1)] for _ in range(N+1)]
dp[0] = [0 for _ in range(M+1)]
for i in range(1, N+1):
    for w in range(M+1):
        if W[i-1] <= w:
            dp[i][w] = max(dp[i-1][w], dp[i-1][w-W[i-1]] + V[i-1])
        else:
            dp[i][w] = dp[i-1][w]


print(max(dp[-1]))


Measured memory_bytes: 270752
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = input()
    n_len = len(N)

    def dfs(val, is357):
        c = 0

        if (not is357
            and val.count('3') > 0
            and val.count('5') > 0
            and val.count('7') > 0):
            is357 = True

        if len(val) == n_len:
            if is357 and int(val) <= int(N):
                return 1
            else:
                return 0

        if is357:
            c+= 1

        c += dfs(val + '3', is357)
        c += dfs(val + '5', is357)
        c += dfs(val + '7', is357)
        return c

    print(dfs('', False))

if __name__ == '__main__':
    main()


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

int main() {
  int N;
  long int x;
  int tmp, count = 100;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> x;
    tmp = 0;
      while(x%2 == 0){
		x /= 2;
        tmp++;
      }
    if(count > tmp){
    count = tmp;
    }
  }
    cout << count << endl;
  
}

Measured memory_bytes: 256
#!venv/bin/python

import math
import numpy as np
import random
import copy
import statistics 

N,M = [int(x) for x in input().split()]
likes = []
for i in range(N):
    likes.append([int(x) for x in input().split()][1:])

count = [0 for i in range(M)]
for like in likes:
    for a in like:
        count[a-1] += 1

ans = 0
for c in count:
    if c == N:
        ans += 1
print(ans)

Measured memory_bytes: 15420
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>


     
#define INF 1e9
#define LINF 1e19
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define pb push_back
#define sz size()
     
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

     
const ll MOD = 1e9 + 7;
const ll ZER = 0;


int main(){
    string s, t;
    cin >> s >> t;
    s += t;
    ll res = 0;
    rep(i, s.sz){
        res = 10 * res + (s[i] - '0');
    }
    rep(i, pow(res, 0.5) + 1){
        if(i * i == res){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}





Measured memory_bytes: 4100
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define mod       1000000007
#define double    long double
#define ull       unsigned long long
#define vi        vector<ll>
#define ppi       pair<int,int>
#define pii       pair<pair<int,int>,int>
#define pb        push_back
#define pi        2*acos(0.0)
#define rev       greater<int>()
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"This is test"<<endl;
#define str       string
#define endl      '\n'
#define e         cout<<'\n';
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll x;cin>>x;
	if(x%2==0){cout<<-1;}
	else{
		ll a=7,b=1;
		while(1){
			if(a%x==0){cout<<b;break;}
			b++;
			a=(a%x)*10+7;
			if(b>x){cout<<-1;return;}
		}
	}
}
int32_t main(){
	kehsihba();
	//init();
	ll t=1;
	//cin>>t;
	for(int k=1;k<=t;k++){
		//cout<<"Case "<<k<<": ";
		solve();
		//e;
	}
}


Measured memory_bytes: 3612
def check():
    N, M = map(int, input().split())
    keta = ['?']*N
    
    for _ in range(M):
        s, c = map(int, input().split())      
        if keta[s-1] == '?' or keta[s-1] == c:
            keta[s-1] = c
        else:
            return -1
    if keta[0] == 0 and N !=1:
        return -1
    
    keta = [0 if num == '?' else num for num in keta]
    
    if N == 1:
        return keta[0]
    
    keta = [1 if i==0 and num==0 else num for i,num in enumerate(keta)]
    
    return ''.join(map(str, keta))
  
print(check())

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

//top,frontからrightを決定
int ident(int a, int b) {
	int c;
	if (a == 1) {
		if (b == 2)c = 3;
		else if (b == 3)c = 5;
		else if (b == 5)c = 4;
		else c = 2;
	}
	else if (a == 2) {
		if (b == 1)c = 4;
		else if (b == 4)c = 6;
		else if (b == 6)c = 3;
		else c = 1;
	}
	else if (a == 3) {
		if (b == 1)c = 2;
		else if (b == 2)c = 6;
		else if (b == 5)c = 1;
		else c = 5;
	}
	else if (a == 4) {
		if (b == 1)c = 5;
		else if (b == 5)c = 6;
		else if (b == 6)c = 2;
		else c = 1;
	}
	else if (a == 5) {
		if (b == 1)c = 3;
		else if (b == 3)c = 6;
		else if (b == 6)c = 4;
		else c = 1;
	}
	else {
		if (b == 2)c = 4;
		else if (b == 3)c = 2;
		else if (b == 5)c = 3;
		else c = 5;
	}
	return c;
}
int calc(int x) {
	int ret = 0;
	rep (i,9) {
		ret += x % 6 + 1;
		x /= 6;
	}
	return ret;
}
//46656=6^6
int t[3][3], f[3][3];
int t3[9];
void solve() {
	t3[0] = 1;
	rep(i, 8)t3[i + 1] = t3[i] * 6;
	int n; cin >> n; 
	rep(aa, n) {
		map<int, bool> mp[3];
		vector<int> c;
		rep(i, 3) {
			rep(j, 3) {
				cin >> t[i][j];
			}
		}
		rep(i, 3) {
			rep(j, 3) {
				cin >> f[i][j];
			}
		}
		rep(i, 3) {
			rep(j, 46656) {
				vector<int> v;
				int cop = j;
				
				rep (k,6) {
					v.push_back(cop % 6 + 1); cop /= 6;
				}
				bool valid = true;
				rep(k, 3) {
					if (t[k][i] > 0 && t[k][i] != v[k])valid = false;
				}
				rep(k, 3) {
					if (f[k][i] > 0 && f[k][i] != v[3 + k])valid = false;
				}
				if (!valid)continue;
				int sum = 0;
				rep(k, 3) {
					rep(l, 3) {
						if (v[k]+v[3+l]==7||v[k]==v[3+l]) {
							valid = false; break;
						}
						int u = ident(v[k], v[3 + l]);
						u--;
						sum += t3[3*k + l] * u;
					}
				}
				if (!valid)continue;
				mp[i][sum] = true;
				if (i == 0)c.push_back(sum);
			}
		}
		sort(c.begin(), c.end());
		c.erase(unique(c.begin(), c.end()), c.end());
		vector<int> ans;
		rep(i, c.size()) {
			if (mp[1][c[i]] && mp[2][c[i]]) {
				ans.push_back(calc(c[i]));
			}
		}
		sort(ans.begin(), ans.end());
		ans.erase(unique(ans.begin(), ans.end()), ans.end());
		rep(i, ans.size()) {
			if (i > 0)cout << " ";
			cout << ans[i];
		}
		if (ans.size() == 0)cout << 0;
		cout << endl;
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 3312
#include <stdio.h>
#include <string.h>

#define M 1046527

char H[M][14];

int h1(int key) {
  return key % M;
}

int h2(int key) {
  return 1 + key % (M - 1);
}

int getChar(char ch) {
  if (ch == 'A') {
    return 1;
  } else if (ch == 'C') {
    return 2;
  } else if (ch == 'G') {
    return 3;
  } else if (ch == 'T'){
    return 4;
  } else {
    return 0;
  }
}

long long getkey(char str[]) {
  long long sum = 0, n = 1, i;
  for (i = 0; i < strlen(str); i++) {
    sum += n * (getChar(str[i]));
    n *= 5;
  }
  return sum;
}

int find(char str[]) {
  long long key, i, h;
  key = getkey(str);
  for (i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0) {
      return 1;
    } else if (strlen(H[h]) == 0) {
      return 0;
    }
  }
  return 0;
}

int insert(char str[]) {
  long long key, i ,h;
  key = getkey(str);
  for (i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0) {
      return 1;
    } else if (strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main() {
  int i, n, h;
  char command[9], s[14];
  for (i = 0; i < M; i++) {
    H[i][0] = '\0';
  }
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s %s", command, s);
    if (command[0] == 'i') {
      insert(s);
    } else {
      if (find(s)) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }

  return 0;
}



Measured memory_bytes: 16096
n=int(input())
if n<=10 : 
  print(n)
  exit()
  
ans=[0 for i in range(10**5+21)]
Q=[0,1,2,3]
def li(x):
  if x==0 : return [0,1]
  if x==9 : return [8,9]
  return [x-1,x,x+1]

now=0
for q in Q:
  W=[i for i in range(10)] if q==0 else li(q)
  for w in W:
    E=[i for i in range(10)] if [q,w]==[0,0] else li(w)
    for e in E:
      R=[i for i in range(10)] if [q,w,e]==[0,0,0] else li(e)
      for r in R:
        T=[i for i in range(10)] if [q,w,r,e]==[0,0,0,0] else li(r)
        for t in T:
          Y=[i for i in range(10)] if [q,w,e,r,t]==[0,0,0,0,0] else li(t)
          for y in Y:
            U=[i for i in range(10)] if [q,w,e,r,t,y]==[0,0,0,0,0,0] else li(y)
            for u in U:
              I=[i for i in range(10)] if [q,w,e,r,t,y,u]==[0,0,0,0,0,0,0] else li(u)
              for i in I:
                O=[i for i in range(10)] if [q,w,e,r,t,y,u,i]==[0,0,0,0,0,0,0,0] else li(i)
                for o in O:
                  P=[i for i in range(10)] if [q,w,e,r,t,y,u,i,o]==[0,0,0,0,0,0,0,0,0,0] else li(o)
                  for p in P:
                    
                    ans[now]= 10**9*q + 10**8*w + 10**7*e + 10**6*r + 10**5*t + 10**4*y + 1000*u + 100*i + 10*o + p
                    
                    if now>=10**5+2 : break
                    now+=1

ans=list(set(ans))
n-=8
ans.sort()
print(ans[n])

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

int main()
{
	int ret = 0;
	int m = 10;
	for (int i = 0; i < 5; ++i) {
		if (ret % 10 != 0) {
			m = min(ret % 10, m);
			ret += 10 - (ret % 10);
		}
		int t;
		cin >> t;
		ret += t;
	}

	if(m != 10 && (ret % 10) != m){
		int t = (ret % 10) == 0 ? 10 : (ret % 10);
		ret -= t - m;
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
const solve = (hs) => {
  // ...
  let currMax = 0
  let result = 0
  hs.map((h) => {
    if (h >= currMax) {
      result++
    }
    currMax = Math.max(h, currMax)
  })
  return result
}
const main = (input) => {
  const [n, hs] = input.split("\n")
  return solve(hs.split(" ").map(Number))
}

if (process.env.NODE_ENV !== "test") {
  const input = require("fs").readFileSync("/dev/stdin", "utf8")
  console.log(main(input.trim()))
}


Measured memory_bytes: 7500
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;

int n, k, x[100000], d1[100000], mid;

int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", &x[i]);
  mid = 0;
  for (int i = 0; i < n - 1; i++) if (x[i] < 0 && x[i+1] >= 0) mid = i + 1;
  if (x[n-1] < 0) mid = n;
  int ans = 1000000000;
  if (mid - k >= 0) ans = -x[mid - k];
  if (mid + k <= n) ans = min(ans, x[mid + k - 1]);
  for (int i = mid; i < n; i++) {
    int p1 = x[i];
    if (i - k + 1 < 0) continue;
    if (i - k + 1 >= mid) continue;
    int p2 = -x[i - k + 1];
    ans = min(ans, p1 + p2 + min(p1, p2));
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        int read = rint();
        WriteLine((double)((read/2)+(read%2))/read);
    
    
    }
    //各種読取
    static string rstr(){
        return ReadLine();
    }
    static int rint(){
        return int.Parse(ReadLine());
    }
    static long rlong(){
        return long.Parse(ReadLine());
    }
    static string[] stra(){
        return ReadLine().Split(' ');
    }
    static int[] inta(){
        string[] read_str_array = ReadLine().Split(' ');
        int[] return_int_array = new int[read_str_array.Length];
        for(int countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
        }
        return return_int_array;
    }
    static int[,] inta2(int num_array,int in_array){
        int[,] int_array2 = new int[num_array,in_array];
        for(int i=0;i<num_array;i++){
            int[] temp_array = inta();
            for(int j=0;j<in_array;j++){
                int_array2[i,j] = temp_array[j];
            }
        }
        return int_array2;
    }
    static long[] longa(){
        string[] read_str_array = ReadLine().Split(' ');
        long[] return_long_array = new long[read_str_array.Length];
        for(long countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
        }
        return return_long_array;
    }
    static double[] doublea(){
        string[] read_str_array = ReadLine().Split(' ');
        double[] return_double_array = new double[read_str_array.Length];
        for(long countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_double_array[countup_i] = long.Parse(read_str_array[countup_i]);
        }
        return return_double_array;
    }
    // A/B小数点以下切上
    static long divideup(long divided,long divid){
        long temp_divide = divided/divid;
        if(divided % divid > 0){
            temp_divide++;
        }
        return temp_divide;
    }
    static long GCD(long a,long b){
        if(a < b){
            long temp = a;
            a = b;
            b = temp;
        }
        if(a % b == 0){ return b; }
        else{
            long temp = b;
            b = a%b;
            a = temp;
            return GCD(a,b);
        }
    }
    static long LCM(long a,long b){
        return a * b / GCD(a,b);
    }
}
//知見
// (string) hogestr -> (char[]) hoge
    // char hoge = hogestr.ToCharArray();
// (char[]) hoge -> (string) hogestr
    // string hoge = new string(hoge);
// Hashtable ×  Dictionary ○
// Dictionary hoge<string,int>
    // hoge.ContainsKey(string) -> return boolean
    // hoge[string] -> return int
    // hoge[int] -> CE
// Dictionary hoge<int1,int2>
    // hoge<int1,int2>: hoge[int1] -> return int2
    // KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2
// SortedDictionary() > SortedList() ???
// キュー　-> 幅優先 ???
// スタック -> 深さ優先 ???


Measured memory_bytes: 11092
import sys
input = sys.stdin.readline

n,m,q = map(int,input().split())
c=[[0 for i in range(n+1)] for j in range(n+1)]
x=[[0 for i in range(n+1)] for j in range(n+1)]
for i in range(m):
    l,r = map(int,input().split())
    x[l][r] += 1
for i in range(1,n+1):
    for j in range(1,n+1):
        c[i][j] = c[i][j-1] + x[i][j]
for i in range(q):
    p,q = map(int,input().split())
    sum = 0
    for j in range(p,q+1):
         sum+= c[j][q] - c[j][p-1]
    print(sum)

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

using namespace std;

int main() {
    size_t n;
    cin >> n;
    vector<size_t> l(n, 0);
    for (size_t i = 0; i < n; ++i)
        cin >> l[i];
    sort(begin(l), end(l), greater<size_t>());
    size_t d = 0;
    for (size_t i = 0; i < l.size(); ++i) {
        auto a = l[i];
        for (size_t j = i + 1; j < l.size(); ++j) {
            auto b = l[j];
            for (size_t k = j + 1; k < l.size(); ++k) {
                auto c = l[k];
                if (a < b + c && b < a + c && c < a + b)
                    ++d;
            }
        }
    }
    cout << d << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,m=mii()

arr=limii()

mat=[[0] for _ in range(n)]
for i in range(m):
    a,b=mii()
    mat[a-1].append(arr[b-1])
    mat[b-1].append(arr[a-1])
chk=0
for i in range(n):
    if arr[i]>max(mat[i]):
        chk+=1

print(chk)






Measured memory_bytes: 96180
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    unsigned long long n,k,a[200005],i,j,l;
    cin>>n>>k;
    for(i=1;i<=k;i++)
    {
        cin>>a[i];    
    }
    for(j=k+1;j<=n;j++)
    {
        cin>>a[j];
        if(a[j]>a[j-k])
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5136
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll a,b,k;
    cin>>a>>b>>k;
    vector<ll> A;
    for(ll i=1;i<=a;i++){
        if(a%i==0 && b%i==0){A.push_back(i);}
    }
    sort(A.begin(),A.end(),greater<ll>());
    assert(A.size()>=k);
    cout<<A[k-1]<<endl;
    
    
    return 0;
}


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

int main()
{
  int n,s,i,sum;
  multiset<int> ms;
  multiset<int>::iterator it,ite;
  while(cin>>n,n){
    ms.clear();
    for(i=0;i<n;i++){
      cin>>s;
      ms.insert(s);
    }
    sum=0;
    ite=ms.end();
    ite--;
    it=ms.begin();
    for(it++;it!=ite;it++)sum+=*it;
    cout<<sum/(n-2)<<endl;
  }
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<functional>
#include<vector>
#include<queue>
using namespace std;
#define f(i,n) for(int i=0;i<(int)n;i++)
#define MOD 1000000009

int main(void){
	int a[100000];
	f(i, 100000)a[i] = 0;
	int k, s;
	int n, m;
	int x, y, z;
	int ans = 0;

	scanf("%d %d %d", &n,&x,&y);
	f(i, n){
		scanf("%d", &a[i]);
	}
	k = a[n - 1] - a[n - 2];
	if (k < 0)k = -k;
	s = a[n - 1] - y;
	if (s < 0)s = -s;
	ans = max(k, s);
	printf("%d\n", ans);


	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<tuple>
#include<sstream>
#include<functional>
#include<list>
#include<queue>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
typedef pair<ll, ll> p;
typedef vector<int> vec;
using Graph = vector<vector<int>>;
using graph = vector<vector<ll>>;

const ll inf = (1LL<<31)-1;
const long long MOD = 1000000007;



int main() {
    int t;
    cin >> t;
    rep(j, t) {
        ll ans = 0;
        ll n;
        cin >> n;
        vector<p> v1, v2;
        vector<p> v3;
        rep(i, n) {
            ll k, l, r;
            cin >> k >> l >> r;
            k--;
            if (l > r) {
                v1.push_back(p(l-r, i));
                v3.push_back(p(k, r));
            }
            else {
                v2.push_back(p(r-l, i));
                v3.push_back(p(k, l));
            }
        }
        set<ll> s1,s2;
        s1.insert(-1);
        s2.insert(-1);
        sort(all(v1),greater<p>()); sort(all(v2),greater<p>());
        rep(i, v1.size())s1.insert(i);
        if (!v1.empty()) {
            rep(i, v1.size()) {
                auto itr = s1.upper_bound(v3[v1[i].second].first);
                itr--;
                if (*itr == -1) {
                    ans += v3[v1[i].second].second;
                }
                else {
                    s1.erase(itr);
                    ans += v3[v1[i].second].second + v1[i].first;
                }
            }
        }
        if (!v2.empty()) {
            rep(i, v2.size())s2.insert(i);
            rep(i, v2.size()) {
                auto itr = s2.upper_bound(n - 2 - v3[v2[i].second].first);
                itr--;
                if (*itr == -1) {
                    ans += v3[v2[i].second].second;
                }
                else {
                    s2.erase(itr);
                    ans += v3[v2[i].second].second + v2[i].first;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 14596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;

string N;

int main() {
    cin >> N;

    int sum = 0;
    for (int i = 0; i < N.size(); i++) {
        string s{N[i]};
        sum += stoi(s);
    }

    if (stoi(N) % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
n, k, l = map(int, input().split())
pq = [list(map(int, input().split())) for _ in range(k)]
rs = [list(map(int, input().split())) for _ in range(l)]
INF = 10 ** 6


class UnionFind:
    def __init__(self, x):
        self.p = [e for e in range(x)]
        self.rank = [0] * x

    def same(self, u, v):
        return self.find_set(u) == self.find_set(v)

    def unite(self, u, v):
        self.link(self.find_set(u), self.find_set(v))

    def find_set(self, u):
        if u != self.p[u]:
            self.p[u] = self.find_set(self.p[u])

        return self.p[u]

    def link(self, u, v):
        if self.rank[u] > self.rank[v]:
            self.p[v] = u
        else:
            self.p[u] = v
            if self.rank[u] == self.rank[v]:
                self.rank[v] += 1


road_uf = UnionFind(n)
train_uf = UnionFind(n)

for p, q in pq:
    p -= 1
    q -= 1
    road_uf.unite(p, q)

for r, s in rs:
    r -= 1
    s -= 1
    train_uf.unite(r, s)

group = [(road_uf.find_set(i), train_uf.find_set(i)) for i in range(n)]

srt = sorted(group, key=lambda x: x[1])
srt.append((INF, INF))
srt.sort()

prev = (-1, -1)
cnt = 0
d = {}
for e in srt:
    if e == prev:
        cnt += 1
    else:
        d[prev] = cnt
        cnt = 1
        prev = e

ans = [d[e] for e in group]
print(*ans)


Measured memory_bytes: 100880
//2018-6-4
//miaowey
//
#include <bits/stdc++.h>
using namespace std;

#define LL long long
#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define Forr(i, a, b) for(int i = (a); i >= (int)(b); --i)

#define N (600000 + 5)
const int P = 998244353;

inline int Mul(int a, int b){
	return (LL)a * b % P;
}
inline int Mod(int a){
	if(a < 0) return a + P;
	return a >= P? a - P: a;
}
inline int Pow(int a, int anum){
	int ret = 1;
	while(anum){
		if(anum & 1) ret = Mul(ret, a);
		a = Mul(a, a); anum >>= 1;
	}
	return ret;
}

int fac[N], rfac[N];

inline int C(int a, int b){
	return Mul(fac[a], Mul(rfac[b], rfac[a - b]));
}

int main(){
	int n, a, b;
	LL k;
	
	fac[0] = rfac[0] = 1;
	For(i, 1, N - 5) fac[i] = Mul(fac[i - 1], i);
	rfac[N - 5] = Pow(fac[N - 5], P - 2);
	Forr(i, N - 6, 1) rfac[i] = Mul(rfac[i + 1], i + 1);

	scanf("%d%d%d%lld", &n, &a, &b, &k);
	
	int ta = 0, tb;
	LL rem, ans = 0, sa = 0;

	while(sa <= k && ta <= n){
		rem = k - sa;

		if(rem % b == 0){
			tb = rem / b; 
			if(tb <= n) ans = Mod(ans + Mul(C(n, ta), C(n, tb)));
		}

		sa += a; ++ta;
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 4992
O = input()
E = input()
n = len(E)
m = len(O)
L = []
if m== n:
    for i in range(n):
        L.append(O[i]+E[i])
else:
    for i in range(n):
        L.append(O[i]+E[i])
    L.append(O[m-1])
ans = ''.join(L)
print(ans)

Measured memory_bytes: 3064
# 0 originのインデックスで偶数降順+奇数昇順の配列
odd_arr = []
even_arr = []
n = gets.chomp.to_i
gets.chomp.split.each.with_index do |a, idx|
  if idx.odd?
    even_arr << a
  else
    odd_arr << a
  end
end
# １回ごとに逆順にする考慮を忘れていて1WA
if n.even?
  puts [even_arr.reverse + odd_arr].join(" ")
else
  puts [odd_arr.reverse + even_arr].join(" ")
end

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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int n = in();
  int k = in();
  int psts[n];
  REP(i,n) {
    cin >> psts[i];
  }
  int ans = 1000000000;
  REP(i,n-k+1) {
    int left = psts[i];
    int right = psts[i+k-1];
    int right_first = abs(right) + abs(right - left);
    int left_first = abs(left) + abs(right - left);
    ans = min(ans, min(right_first, left_first));
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 1024
import java.util.*;

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

    Map<Integer, List<Integer>> graph = new HashMap<>();
    for (int i = 1; i <= N; i++)
      graph.put(i, new LinkedList<Integer>());

    for (int i = 0; i < M; i++)
      graph.get(scan.nextInt()).add(scan.nextInt());

    scan.close();

    System.out.println(longestPath(graph, N));
  }

  private static int longestPath(Map<Integer, List<Integer>> graph, int n) {
    if (n == 0) return 0;

    int[] cache = new int[n + 1];
    Arrays.fill(cache, -1);
    int max = 0;
    for (int i = 1; i <= n; i++)
      max = Math.max(max, dfs(graph, i, cache));
    return max;
  }

  private static int dfs(Map<Integer, List<Integer>> graph, int idx, int[] cache) {
    if (cache[idx] >= 0) return cache[idx];

    int maxPath = 0;
    for (int con : graph.get(idx))
      maxPath = Math.max(maxPath, dfs(graph, con, cache) + 1);

    return cache[idx] = maxPath;
  }

}

Measured memory_bytes: 109688
n, a, b = map(int, input().split())
MOD = 10 ** 9 + 7

# でっかい数の n C a
def comb(n, a):
	ret = 1
	# 分子部分の計算
	for i in range(n - a + 1, n + 1):
		ret *= i
		ret %= MOD
	# 分母部分の計算
	for i in range(1, a + 1):
		ret *= pow(i, MOD - 2, MOD)
		ret %= MOD
	return ret
	
ans = pow(2, n, MOD) - 1
ans -= comb(n, a)
ans -= comb(n, b)
print(ans % MOD)

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

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()
#define what_is(x) #x << " is " << (x)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = (int)1e6 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

void megaRandom() {
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  srand(FOR);
}

ll n, a[N], b[N];

int main() {
	megaRandom();
	cin >> n;		
	for(int i = 1; i <= n; i ++)
		cin >> a[i] >> b[i];
	ll add = 0;
	for(int i = n; i >= 1; i --) {
		if((a[i] + add) % b[i] == 0)
			continue;
		ll tmp = (a[i] + add) / b[i];
		tmp ++;
		add += b[i] * tmp - (a[i] + add);
	}
	cout << add << "\n";
	return 0;  
}


Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
int ans = 0;
int main(){
    cin >> N;
    int X[N], Y[N];
    rep(i, N){
        cin >> X[i];
        Y[i] = X[i];
    }
    sort(Y, Y + N);
    rep(i, N){
        if(X[i] < Y[N / 2])
            cout << Y[N / 2] << endl;
        else
            cout << Y[N/2 - 1] << endl;
    }
    return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n, m;
string s[1010];
bool used[1010][1010];
void solve(){
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> s[i];
	}
	
	queue<tuple<int,int,int>> q;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(s[i][j] == '#'){
				q.push(make_tuple(0,i,j));
				used[i][j] = 1;
			}
		}
	}
	
	int ans = 0;
	int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
	while(!q.empty()){
		tuple<int,int,int> p = q.front(); q.pop();
		int c = get<0>(p);
		int x = get<1>(p);
		int y = get<2>(p);
		ans = c;
		for(int i = 0; i < 4; i++){
			int nx = x+dx[i], ny = y+dy[i];
			if(nx<0 || nx>=n || ny<0 || ny>=m) continue;
			if(used[nx][ny]) continue;
			used[nx][ny] = 1;
			q.push(make_tuple(c+1,nx,ny));
		}
	}
	cout << ans << endl;
}

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


Measured memory_bytes: 14352
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>
#include <functional>

using namespace std;
using ll = long long;
using ld = double;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>; //(x, y, dx, dy)
const ll INF = 1e17;
const ld eps = 1e-10;
const ll MOD = 1e9 + 7;

const double pi = acos(-1.0);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll H, W, N;
	cin >> H >> W >> N;
	ll sy, sx;
	cin >> sy >> sx;
	sx--; sy--;
	string s1, s2;
	cin >> s1 >> s2;
	ll ngl = -1, ngr = W, ngu = -1, ngd = H;
	bool flag = false;
	for (int i = N - 1;i >= 0;i--) {
		if (s2[i] == 'U' && ngd < H)
			ngd++;
		if (s2[i] == 'D' && ngu >= 0)
			ngu--;
		if (s2[i] == 'L' && ngr < W)
			ngr++;
		if (s2[i] == 'R' && ngl >= 0)
			ngl--;
		if (s1[i] == 'U' && ngu < H)
			ngu++;
		if (s1[i] == 'D' && ngd >= 0)
			ngd--;
		if (s1[i] == 'L' && ngl < W)
			ngl++;
		if (s1[i] == 'R' && ngr >= 0)
			ngr--;
		if (ngl >= ngr - 1 || ngu >= ngd - 1)
			flag = true;
	}
	if (sx <= ngl || ngr <= sx || sy <= ngu || ngd <= sy || flag)
		cout << "NO" << endl;
	else
		cout << "YES" << endl;
	return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, ans = 0;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; ++i) cin >> d.at(i);
    for (int i = 0; i < n; ++i) for (int j = i + 1; j < n; ++j) ans += d.at(i) * d.at(j);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
string s;
int k;
int main()
{
	cin>>k>>s;
	if(s.size()<=k)
	{
		cout<<s;
	}
	else
	{
		for(int i=0;i<=k-1;i++)
		{
			cout<<s[i];
		}
		cout<<"...";
	}
	return 0;
}

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

int main(){
    string s,t = "";
    cin >> s;
    string u = s;
    s += "        ";
    int i = 0;
    //cout << "01234567890123456789" << endl;
    //cout << s << ":" << endl;
    while(1){
        if(s.substr(i,5) == "dream"){
            i += 5;
            if(s.substr(i,2) == "er"){
                if(s.substr(i+2,1) == "d"){
                    i += 2;
                    t += "dreamer";
                }else if(s.substr(i+2,1) == "e"){
                    i += 2;
                    t += "dreamer";
                }else if(s.substr(i+2,1) == "a"){
                    t += "dream";
                }else if(s.substr(i+2,1) == " "){
                    i += 2;
                    t += "dreamer";
                }
            }else if(s.substr(i,1) == "d"){
                t += "dream";
            }else if(s.substr(i,1) == " "){
                t += "dream";
            }
        }

        else if(s.substr(i,5) == "erase"){
            i += 5;
            if(s.substr(i,1) == "r"){
                i += 1;
                t += "eraser";
            }else if(s.substr(i,1) == "e"){
                t += "erase";
            }else if(s.substr(i,1) == "d"){
                t += "erase";
            }else if(s.substr(i,1) == " "){
                t += "erase";
            }
        }
        else break;
        if(s.substr(i,1) == " ")break;
    }
    //cout << t << ":" << endl;
    //cout << u << ":" << endl;

    if(u == t)cout << "YES" <<endl;
    else cout << "NO" << endl;
}

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

int list[100];

int main(void){
	int a, b;
	bool flag = false;
	while(cin >> a >> b){
		memset(list, 0, 100);
		list[a-1]++;
		list[b-1]++;
		while(true){
			cin >> a >> b;
			if(!a && !b)	break;
			list[a-1]++;
			list[b-1]++;
		}
		flag = false;
		if(list[0] % 2 == 0 || list[1] % 2 == 0)	flag = true;
		for(int i = 2; i < 100; i++){
			if(list[i] % 2)	flag = true;
		}
		if(!flag) cout << "OK" << endl;
		else cout << "NG" << endl;
	}
  return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <inttypes.h>

int horieyui(int mikakosi) {
	int le, greater;
	if (mikakosi <= 1) return mikakosi;
	le = 0;
	greater = mikakosi;
	while (le + 1 < greater) {
		int mid = le + (greater - le) / 2;
		if ((int64_t)mid * mid <= mikakosi) le = mid; else greater = mid;
	}
	return le;
}

int main(void) {
	int a, b;
	char asumisu[32];
	int morikubosyoutarou;
	int amamiyasora;
	if (scanf("%d%d", &a, &b) != 2) return 1;
	snprintf(asumisu, sizeof(asumisu), "%d%d", a, b);
	if (sscanf(asumisu, "%d", &morikubosyoutarou) != 1) return 1;
	amamiyasora = horieyui(morikubosyoutarou);
	puts(amamiyasora * amamiyasora == morikubosyoutarou ? "Yes" : "No");
	return 0;
}


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

int main(){
  int N, M;
  cin>>N>>M;
  priority_queue<int> gateL;
  priority_queue<int, vector<int>, greater<int>> gateR;
  for(int i=0; i<M; i++){
    int L,R;
    cin>>L>>R;
    gateL.push(L);
    gateR.push(R);
  }
  int min=gateL.top(); //Lで最大
  int max=gateR.top(); //Rで最少
  if(min>max) cout<<0<<endl;
  else cout<<max-min+1<<endl;
}


Measured memory_bytes: 1276
#include<stdio.h>

int main(){

long ans=0;
int N;
scanf("%d",&N);

int A[N+1];
int B[N];

for (int i = 0; i < N+1; i++){scanf("%d",&A[i]);}
for (int i = 0; i < N; i++){scanf("%d",&B[i]);}

for (int i = N; i > 0; i--)
{
  if (B[i-1]-A[i]<=0)
  {
    ans += B[i-1];
  }else{
    ans += A[i];
    B[i-1] = B[i-1] - A[i];
    if (B[i-1]-A[i-1]<=0)
    {
      ans += B[i-1];
      A[i-1] = A[i-1]-B[i-1];
    }else{
      ans += A[i-1];
      A[i-1] = 0;
    } 
  }
}

printf("%ld",ans);

return 0;

}

Measured memory_bytes: 2512
n=int(input())

a=n//100
b=(n-a*100)//10
c=n-a*100-b*10

if a==b:
    if a<c:
        print((a+1)*100+(a+1)*10+a+1)
    elif c<a:
        print(a*100+a*10+a)
    elif a==c:
        print(n)
elif a<b:
    print((a+1)*100+(a+1)*10+a+1)
elif a>b:
    print(a*100+a*10+a)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int N = 300+5;
char s[N];
int f[N][N][N];
bool v[N][N][N];
inline int q(int l,int r,int k){
	if(r-l+1<=1)return r-l+1>=1;
	if(v[l][r][k])return f[l][r][k];
	v[l][r][k]=1;
	int diff = s[l]!=s[r];
	f[l][r][k]=max(q(l+1,r,k), q(l,r-1,k));
	if(k - diff>=0)f[l][r][k]=max(f[l][r][k],q(l+1,r-1,k-diff)+2);
	return f[l][r][k];
}

int main(){
	scanf("%s",s+1);
	int k;cin >> k;
	cout << q(1,strlen(s+1),k) << endl;
}


Measured memory_bytes: 137344
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define ll long long
int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//ll tt;	cin>>tt;	while(tt--)
	{
		ll n,m,i,sum;
		cin>>n>>m;
		ll arr[m+1];
			sum=0;
		for(i=0;i<m;i++)	{cin>>arr[i];sum+=arr[i];}

		cout<<max(-1LL,n-sum);
 	
 	}
	cerr<<" Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s \n";
		
		
return 0;
}

Measured memory_bytes: 3868
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
char charin() {char c; cin>>c; return c;}
string strin() {string s; cin>>s; return s;}
int main(){
    int n=in();
    vec h(n);
    rep(i,n)h[i]=in();
    int ans=0,tmp=0;
    rep(i,n-1){
        if(h[i]>=h[i+1])tmp++;
        else tmp=0;
        ans=max(tmp,ans);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    constexpr auto kMealPrice = 800;
    constexpr auto kPayback = 200;
    constexpr auto kPaybackMeals = 15;

    int meals;
    cin >> meals;

    auto res = meals * kMealPrice - (meals / kPaybackMeals) * kPayback;
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256