akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#define  go return 0
#define pb push_back
#include<utility>
#include <algorithm>
#include<iterator>
typedef long long ll;
typedef double db;
#define lp1(i, n)  for(int i=0; i<(int)(n); ++i)
#define lp2(i, n)  for(int i=1; i<=(int)(n); ++i)
#define lp3(j, m)  for(int j=0; j<(int)(m); ++j)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
typedef vector<int> vi;
const int N=1e5+5;
int arr[N];
int main(){

    int n,arr[N];
    db sum=0;
    cin>>n;
    lp1(i,n){
    cin>>arr[i];
   // arr[i]=1.0/arr[i];
    sum+=(1./arr[i]);
    }
    cout<<1/sum;
go;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  int l, r, L = 1, R = n, a;
  for (a = 0; a < m; a++) {
    cin >> l >> r;
    if (L < l) {
      L = l;
    }
    if (r < R) {
      R = r;
    }
  }
  if (R < L) {
    cout << 0 << endl;
  } else {
    cout << R - L + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[8005];
int a[2][8005],o[2];
bool ok[8005];
inline int read()
{int x=0;
char c=getchar();
while (c<'0'||c>'9') c=getchar();
while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
return x;
}
int main (){
	scanf ("%s",s+1);
	int len=strlen(s+1),i,j,las=0,now=0,x,y,pos=len+1;
	scanf ("%d%d",&x,&y);
	for (i=1;i<=len;i++)
	{if (s[i]=='T') {pos=i;break;}
	}
	x-=(pos-1);las=pos;now^=1;
	if (pos==len+1)
	{if (x==0&&y==0) {puts("Yes");}
	else {puts("No");}
	return 0;
	}
	for (i=pos+1;i<=len;i++)
	{if (s[i]=='T') 
	{a[now][++a[now][0]]=i-las-1;
	o[now]+=i-las-1;las=i;now^=1;
	}
	}
	a[now][++a[now][0]]=len-las;
	o[now]+=len-las;
	if ((o[0]-x)&1) {puts("No");return 0;}
	if ((o[1]-y)&1) {puts("No");return 0;}
	x=o[0]-x;x>>=1;
	y=o[1]-y;y>>=1;
	if (x>8000||x<0||y>8000||y<0) {puts("No");return 0;}
	ok[0]=1;
	for (i=1;i<=a[0][0];i++)
	{for (j=8000;j>=a[0][i];j--)
	{ok[j]|=ok[j-a[0][i]];}
	}
	if (!ok[x]) {puts("No");return 0;}
	memset (ok,0,sizeof(ok));
	ok[0]=1;
	for (i=1;i<=a[1][0];i++)
	{for (j=8000;j>=a[1][i];j--)
	{ok[j]|=ok[j-a[1][i]];}
	}
	if (!ok[y]) {puts("No");return 0;}
	puts("Yes");
	return 0;
}
	

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();    
        long N = r.l();
        int root = (int)Math.sqrt(N)+1;
        int factor = 1;
        for(int i = 2; i <= root; i++){
            if(N%i == 0)
                factor = i;
        }
        println(Math.max(String.valueOf(factor).length(), String.valueOf(N/factor).length()));
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 23252
#include<set>
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  set<int> s;
  int n; cin >>n;
  rep(i,n){
    int a; cin >>a;
    s.insert(a);
  }
  printf("%s",s.size()==n?"YES":"NO");
}

/// confirm df==0 ///


Measured memory_bytes: 9600
#include<iostream>
using namespace std;
int n;
int main(){
    cin >> n;
    int a[n];
    int b[n];
    for(int i = 0;i<n;i++){
        cin >> a[i];
    }
    for(int i = 0;i < n;i++){
        b[a[i]-1] = i + 1;
    }
    for(int i = 0;i<n;i++){
        cout << b[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>
#include<string.h>
int main(){
  int unused __attribute__((unused));
  int i, j, N, C[4]={0};
  char S[4], arr[][4] = {"AC", "WA", "TLE", "RE"};

  unused = scanf("%d", &N);
  for(i=0; i<N; i++){
    unused = scanf("%s", S);
    for(j=0; j<4; j++){
      if(strcmp(S, arr[j])==0) C[j]++;
    }
  }

  for(j=0; j<4; j++) printf("%s x %d\n", arr[j], C[j]);

  return 0;
}

Measured memory_bytes: 1732
import numpy as np
H,W = map(int, input().split())
a = [list(input()) for i in range(H)]
sub = {".": 0, "#": 1}
a = [[sub.get(x,x) for x in ai] for ai in a]
tmp = np.array(a)
tmp = tmp[:, ~(np.sum(tmp, 0) == 0)] # delete all 0 column
tmp = tmp[~(np.sum(tmp, 1) == 0), :] # delete all 0 row
sub2 = {0: ".", 1:"#"}
ans = [[sub2.get(x,x) for x in tmpi] for tmpi in tmp]
for ansi in ans:
    print("{}".format("".join(ansi)))

Measured memory_bytes: 12632
H,W=[int(i) for i in input().split(" ")]
S=[input() for i in range(H)]


for k,v in enumerate(S):
  for kk,vv in enumerate(list(v)):
    checkTarget = []
    if vv == "#":
      print("#", end="" )
    else:
      if H==1 and W==1:
        print("0" , end="")
        break
      if k == 0 and kk == 0:
        checkTarget = [                         
                                                   S[k][kk+1],
                                     S[k+1][kk], S[k+1][kk+1]]

      elif k == 0 and kk > 0 and kk < len(v)-1 and H==1:
        checkTarget = [ 
                        S[k][kk-1],             S[k][kk+1],
                        ]

      elif k == 0 and kk > 0 and kk < len(v)-1:
        checkTarget = [ 
                        S[k][kk-1],             S[k][kk+1],
                        S[k+1][kk-1], S[k+1][kk], S[k+1][kk+1]]
      elif k == 0 and kk == len(v)-1 and H==1:
        checkTarget = [ 
                        S[k][kk-1],             
                        ]

      elif k == 0 and kk == len(v)-1:
        checkTarget = [ 
                        S[k][kk-1],             
                        S[k+1][kk-1], S[k+1][kk]]
      elif k > 0 and k < len(S) -1 and kk==0 and W==1:
        checkTarget = [       S[k-1][kk],
                                         
                              S[k+1][kk]]

      elif k > 0 and k < len(S) -1 and kk==0:
        checkTarget = [       S[k-1][kk], S[k-1][kk+1],
                                         S[k][kk+1],
                              S[k+1][kk], S[k+1][kk+1]]

      elif k > 0 and k < len(S) -1 and kk==len(v)-1:
        checkTarget = [ S[k-1][kk-1],  S[k-1][kk],
                        S[k][kk-1],             
                        S[k+1][kk-1], S[k+1][kk]]

      elif k == len(S) -1 and kk == 0 and W==1:
        checkTarget = [   S[k-1][kk]
                                     ]
      elif k == len(S) -1 and kk == 0:
        checkTarget = [   S[k-1][kk], S[k-1][kk+1],
                                        S[k][kk+1]
                                                  ]
      elif k == len(S) -1 and kk> 0 and  kk < len(v)-1:
        checkTarget = [ S[k-1][kk-1],  S[k-1][kk], S[k-1][kk+1],
                        S[k][kk-1],                S[k][kk+1]
                                                                ]

      elif k == len(S) -1 and kk == len(v)-1:
        checkTarget = [ S[k-1][kk-1],  S[k-1][kk], 
                        S[k][kk-1]            
                                                               ]

      else:
        checkTarget = [ S[k-1][kk-1],  S[k-1][kk], S[k-1][kk+1],
                        S[k][kk-1],             S[k][kk+1],
                        S[k+1][kk-1], S[k+1][kk], S[k+1][kk+1]]

      print(len( [ i for i in checkTarget if i == "#"]  ), end="")
  print("", end="\n" if k != len(S)-1 else "" )


Measured memory_bytes: 3644
n = int(input())
schedule = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] * 3 for _ in range(n)]
dp[0][0] = schedule[0][0]
dp[0][1] = schedule[0][1]
dp[0][2] = schedule[0][2]

for i in range(1, n):
    dp[i][0] = max(dp[i-1][1] + schedule[i][0], dp[i-1][2] + schedule[i][0])
    dp[i][1] = max(dp[i-1][0] + schedule[i][1], dp[i-1][2] + schedule[i][1])
    dp[i][2] = max(dp[i-1][0] + schedule[i][2], dp[i-1][1] + schedule[i][2])

print(max(dp[n-1]))


Measured memory_bytes: 47344
import java.util.*;
 
public class Main{

       public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        int K = sc.nextInt();
        sc.close();
        Map<String, Integer> sub = new HashMap<>();
        int count = 0;

        for(int i = 0; i < s.length(); i++){
            for(int j = i+1; j <= i+K ; j++){
                if(j > s.length()){
                    continue;
                }
                if(!(sub.containsKey(s.substring(i, j)))){
                    count++;
                    sub.put(s.substring(i, j), count);
                }
            }
        }
        String[] subst = new String[count];
        for (String key : sub.keySet()) {
            subst[sub.get(key)-1] = key;
        }
        Arrays.sort(subst);
        System.out.println(subst[K-1]);
    }
}

Measured memory_bytes: 26324
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N,T;
	cin>>N>>T;
	vector<int> ts(N);
	rep(i,N)cin>>ts[i];
	ll bf = T;
	ll ans = T;
	REP(i,N-1){
		if(ts[i]<bf){
			ans -= bf-ts[i];
		}
		bf = ts[i] + T;
		ans += T;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	LL N, M;
	cin >> N >> M;

	vector<vector<LL> > students(N,vector<LL>(2));
	rep(i, N) cin >> students[i][0] >> students[i][1];

	vector<vector<LL> > checkpoints(M, vector<LL>(2));
	rep(i, M) cin >> checkpoints[i][0] >> checkpoints[i][1];

	for (int i = 0; i < N; i++) {
		int point_of_shortest_manhattan_distance = -1;
		int shortest_manhattan_distance = INF;
		for (int j = 0; j < M; j++) {
			int manhattan_distance = abs(students[i][0] - checkpoints[j][0]) + abs(students[i][1] - checkpoints[j][1]);
			if (manhattan_distance < shortest_manhattan_distance) {
				shortest_manhattan_distance = manhattan_distance;
				point_of_shortest_manhattan_distance = j + 1;
			}
		}
		cout << point_of_shortest_manhattan_distance << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b)
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

struct p
{
	ll a;
	int b;
	int c;
};

int main()
{
	ll n;
	int k;
	cin >> n >> k;
	int r = 1;
	for (ll i = k; n >= i; i *= k, r++);

	printf("%d", r);

	return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define pcnt(n) __builtin_popcount(n)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const double PI = acos(-1);

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k;
    string s;
    cin>>k>>s;
    if(s.length()>k){cout<<s.substr(0,k)<<"..."<<endl;}
    else{cout<<s<<endl;}
}

Measured memory_bytes: 3644
import math

def f(a, b):
  return len(list(str(max(a, b))))

N = int(input())

ans = len(str(N))
for i in range(1, int(math.sqrt(N)) + 1):
  if N % i == 0:
    ans = min(ans, f(i, N // i))
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.Arrays;

class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] S = IntStream.range(0, n).map(i -> sc.nextInt()).toArray();
		int q = sc.nextInt();
		int[] T = IntStream.range(0, q).map(i -> sc.nextInt()).toArray();
		System.out.println(IntStream.range(0, q).filter(i -> S[Math.max(0, Math.min(n, Arrays.binarySearch(S, T[i])))] == T[i]).count());
	}
}


Measured memory_bytes: 70988
N = int(input())
A = list(map(int,input().split()))
if N == 0:
    if A[0] == 1:
        print(1)
    else:
        print(-1)
else:
    saidaiA =[]
    oya = 1
    flag = True
    for i in range(len(A)):
        if oya >= 5*10**13:
            ko = 10**14
        else:
            ko = oya *2
        if i == 0:
            ko = 1
        oya = ko - A[i]
        saidaiA.append(ko)
        if oya < 0:
            flag = False
    ans = 0
    # print(saidaiA)
    motikosi = 0
    for i in range(len(A)):
        if A[-i] + motikosi >= saidaiA[-i]:
            ans += saidaiA[-i]
            motikosi = saidaiA[-i]
        else:
            ans += A[-i] + motikosi
            motikosi = A[-i] + motikosi
    if flag == True:
        print(ans+1)
    else:
        print(-1)

Measured memory_bytes: 645524
# 完全グラフを考える。
# 隣接する頂点の番号の値は、1〜Nの和から自分自身を引いたもの。

# →奇数の場合は、7ならば1-6, 2-5, 3-4の辺を削除する
# →偶数の場合は、6ならば同上

n = int(input())
if n % 2 == 0:
    excluded_sum = n+1
else:
    excluded_sum = n

print(n*(n-1) // 2 - (excluded_sum-1) // 2)

for i in range(1, n+1):
    for j in range(i+1, n+1):
        if i+j == excluded_sum:
            continue
        else:
            print('{} {}'.format(i, j))


Measured memory_bytes: 3336
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define IOS {ios :: sync_with_stdio(false); cin.tie(0);cout.tie(0); }
#define F first
#define S second
#define pb push_back
typedef long double ld;
#define deci(n) cout << fixed << setprecision(n);
typedef long long ll;

#define mem0(x)  memset(x,0,sizeof(x));
#define memm1(x) memset(x,-1,sizeof(x));
#define all(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define fori2(n) for(ll i=1;i<=n;i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define forj2(n) for(ll j=1;j<=n;j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define fork2(n) for(ll k=1;k<=n;k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
const ll md = 1e9 + 7;

#define BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) ((a) & (1ll << (p)))
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))
// const ll N = 100005;
// ll fac[N] = {1};
// #define calfac for(ll i=1  ;i<N;i++) fac[i] = (fac[i-1]*i)%md;
// ll C[N+1][M+1]; 
// void  ncr(){
//     ll n = N,k = M; 
//     for (ll i = 0; i <= n; i++) { 
//         for (ll j = 0; j <= min(i, k); j++) { 
//             if (j == 0 || j == i)  C[i][j] = 1; 
//             else C[i][j] = C[i - 1][j - 1] +  C[i - 1][j]; 
//         } 
//     } 
// } 


#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 
// Ordered set docs:
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
ll modInv(ll a)
{
    return pow(a,md-2);
}
 
// ll nCr(ll n,ll r)
// {
//     return (fac[n]*modInv((fac[r]*fac[n-r])%md))%md;
// }

 
ll po(ll x,ll n){
    if(n==0) return 1;
    if(n%2==1) return (x*po(x,n-1));
    else {
        ll k=po(x,n/2);
        return (k*k);
    }
}
 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
}
 
int32_t main(){
    IOS;
    ll d,t,s;
    cin >> d >> t >> s;
    if(s*t >=d ) cout <<"Yes\n";
    else cout <<"No\n";
} 

Measured memory_bytes: 3660
n = int(input())
d, x = map(int, input().split())
a = [int(input()) for i in range(n)]
count = 0
for i in a:
    dd = d
    n = 0
    while True:
        if dd < n*i + 1:
            break
        n += 1
        count += 1

ans = count + x
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#define MAX 10000
#define NIL -1

struct Node{int p,l,r;};
struct Node T[MAX];
int n;

void preParse(int u){
  if(u==NIL)return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u==NIL)return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u==NIL)return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main() {
  int i,v,l,r,root;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NIL)T[l].p=v;
    if(r!=NIL)T[r].p=v;
  }
  for(i=0;i<n;i++)if(T[i].p==NIL)root=i;

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2004
/*ABC174-D*/
#include<stdio.h>
#define reg register
#define ri reg int
#define rep(i, x, y) for(ri i = x; i <= y; ++i)
#define nrep(i, x, y) for(ri i = x; i >= y; --i)
#define DEBUG 1
#define ll long long
#define max(i, j) (i) > (j) ? (i) : (j)
#define min(i, j) (i) < (j) ? (i) : (j)
struct IO {
	#define MAXSIZE (1 << 20)
	#define isdigit(x) (x >= '0' && x <= '9')
	char buf[MAXSIZE], *p1, *p2;
	char pbuf[MAXSIZE], *pp;
	#if DEBUG
	#else
		IO() : p1(buf), p2(buf), pp(pbuf) {}
		~IO() {
			fwrite(pbuf, 1, pp - pbuf, stdout);
		}
	#endif
	inline char gc() {
		#if DEBUG
    		return getchar();
		#endif
    	if(p1 == p2)
			p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin);
    	return p1 == p2 ? ' ' : *p1++;
	}
	inline bool blank(char ch) {
    	return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
	}
	template <class T>
	inline void read(T &x) {
    	register double tmp = 1;
    	register bool sign = 0;
    	x = 0;
    	register char ch = gc();
    	for(; !isdigit(ch); ch = gc())
    		if(ch == '-') sign = 1;
    	for(; isdigit(ch); ch = gc())
			x = x * 10 + (ch - '0');
    	if(ch == '.')
			for(ch = gc(); isdigit(ch); ch = gc())
        		tmp /= 10.0, x += tmp * (ch - '0');
    	if(sign) x = -x;
	}
	inline void read(char *s) {
		register char ch = gc();
		for(; blank(ch); ch = gc());
		for(; !blank(ch); ch = gc())
			*s++ = ch;
    	*s = 0;
	}
	inline void read(char &c) {
    	for(c = gc(); blank(c); c = gc());
	}
	inline void push(const char &c) {
		#if DEBUG
    		putchar(c);
		#else
    		if(pp - pbuf == MAXSIZE) {
				fwrite(pbuf, 1, MAXSIZE, stdout);
				pp = pbuf;
			}
    		*pp++ = c;
		#endif
	}
	template <class T>
	inline void write(T x) {
    	if(x < 0) {
			x = -x;
			push('-');
		}
    	static T sta[35];
    	T top = 0;
    	do{
			sta[top++] = x % 10;
			x /= 10;
    	}while(x);
    	while(top)
			push(sta[--top] + '0');
	}
	template <class T>
	inline void write(T x, char lastChar) {
    	write(x);
		push(lastChar);
	}
} io;
char st[200010];
int n, cr, ans;
int main() {
	io.read(n);
	rep(i, 1, n) {
		io.read(st[i]);
		if(st[i] == 'R') ++cr;
	}
	rep(i, 1, cr) if(st[i] == 'W') ++ans;
	io.write(ans);
}

Measured memory_bytes: 1684
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define ld long double
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007
const int N = 25;
char a[N][N];
int vis[N][N];
int h, w;
int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};
int dist[N][N];
bool isValid(int x , int y){
    if(x < 1 || x > h || y < 1 || y > w){
        return false;
    }
    if(a[x][y] == '#'){
        return false;
    }
    return true;
}
int bfs(int x , int y){
    queue<pair<int,int>> q;
    memset(vis,0,sizeof(vis));
    q.push({x,y});
    vis[x][y] = 1;
    dist[x][y] = 0;
    while(!q.empty()){
        int cx = q.front().fi;
        int cy = q.front().se;
        q.pop();
        for(int k = 0; k<4; k++){
            if(isValid(cx + dx[k] , cy + dy[k]) && !vis[cx + dx[k]][cy + dy[k]]){
                int nx = cx + dx[k];
                int ny = cy + dy[k];
                dist[nx][ny] = dist[cx][cy] + 1;
                vis[nx][ny] = 1;
                q.push({nx , ny});
            }
        }
    }
    int res = 0;
    for(int i = 1; i<=h; i++){
        for(int j = 1; j<=w; j++){
            res = max(res , dist[i][j]);
        }
    }
    return res;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>h>>w;
    for(int i = 1; i<=h; i++){
        for(int j = 1; j<=w; j++){
            cin>>a[i][j];
        }
    }
    int ans = 0;
    for(int i = 1; i<=h; i++){
        for(int j = 1; j<=w; j++){
            if(a[i][j] == '.' && isValid(i,j)){
                int c = bfs(i,j);
                ans = max(c , ans);
            }
        }
    }
    cout<<ans;
    
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{

	cin.tie(0); ios_base::sync_with_stdio(false);
	int m, d;
	cin >>m  >>d;
	
	int ans = 0;
	rep2(i, 1, d+1){
		int d1= i%10;
		int d2= i/10;
		if(d1 * d2 <= m && d1*d2>0){
		if(d1>1 && d2>1){
			ans++;
			//dbg(d1,d2,d1*d2);
		}}
	}
	
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
   CCC
   CAtD
   CABD
   CsBD
    DDD

    UUR
    DDL
    LUUURRD
    RDDDLLU

    """
    sx, sy, tx, ty = read_ints()
    return 'U'*(ty-sy)+'R'*(tx-sx)+'D'*(ty-sy)+'L'*(tx-sx)+'L'+'U'*(ty-sy+1)+'R'*(tx-sx+1)+'D'+'R'+'D'*(ty-sy+1)+'L'*(tx-sx+1)+'U'


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


Measured memory_bytes: 62108
N = int(input())

ans = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
L = 1


def f(i, j):
    global L
    if i == j:
        return
    mid = (i + j) // 2
    for k in range(i, mid + 1):
        for r in range(mid + 1, j + 1):
            ans[k][r] = L
            ans[r][k] = L
    L += 1
    f(i, mid)
    f(mid + 1, j)
    L -= 1


f(1, N)
for i in range(1, N):
    print(' '.join(
        str(ans[i][j])
        for j in range(i + 1, N + 1)
    ))


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

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

    vector<pair<int,int>> xidx(n);
    for(int i=0;i<n;i++){
        xidx[i]=make_pair(x[i],i+1);
    }
    sort(xidx.begin(),xidx.end());

    vector<int> a(n*n,0);
    for(int i=0;i<n;i++){
        a[x[i]]=i+1;
    }

    int pos=0;
    for(int loop=0;loop<2;loop++){
        for(int idx=0;idx<n;idx++){
            int cnt=(loop==0 ? xidx[idx].second-1 : n-xidx[idx].second);
            for(int i=0;i<cnt;i++){
                if(a[pos]==0) a[pos]=xidx[idx].second;
                else i--;
                pos++;
            }
        }
    }
    
    vector<int> cnt(n*n,0);
    for(int i=0;i<n*n;i++){
        cnt[a[i]-1]++;
        if(cnt[a[i]-1]==a[i] && x[a[i]-1]!=i){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    for(int i=0;i<n*n;i++){
        cout<<a[i]<<(i+1==n*n ? "\n" : " ");
    }
    
    return 0;
}

Measured memory_bytes: 3072
// package other2017.tenka2017;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        long n = in.nextLong();

        sch: for (long a = 1 ; a <= 3500 ; a++) {
            for (long b = 1 ; b <= 3500 ; b++) {
                long up = n * a * b;
                long dw = 4 * a * b - n * b - n * a;
                if (dw >= 1 && up % dw == 0) {
                    out.println(String.format("%d %d %d", a, b, up / dw));
                    break sch;
                }
            }
        }
        out.flush();
    }

    public static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }

    public static class InputReader {
        private static final int BUFFER_LENGTH = 1 << 12;
        private InputStream stream;
        private byte[] buf = new byte[BUFFER_LENGTH];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int next() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public char nextChar() {
            return (char) skipWhileSpace();
        }

        public String nextToken() {
            int c = skipWhileSpace();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public long nextLong() {
            int c = skipWhileSpace();
            long sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public double nextDouble() {
            return Double.valueOf(nextToken());
        }

        int skipWhileSpace() {
            int c = next();
            while (isSpaceChar(c)) {
                c = next();
            }
            return c;
        }

        boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
	double R, pi = acos(-1);
	cin >> R;
	
	cout << fixed << setprecision(6) << pi * R * R << " " << setprecision(6) << 2 * pi * R << endl;

    return 0;
}



Measured memory_bytes: 3276
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

ll pow2(ll n, ll k) {
    ll ret = 1;
    REP(i, k) ret *= n;
    return ret;
}

int check_k(const vector<int>& shff, int num_kind) {

	vector<int> all_xor;
	REP(n, num_kind) {
		bool is_first = true;
		int xor_res = 0;
		for (auto s : shff) {
			if (s == n) {
				if (is_first) {
					is_first = false;
				}
				else {
					break;
				}
			}
			else if (!is_first) {
				xor_res ^= s;
			}
		}
		all_xor.pb(xor_res);
	}

	if (*min_element(ALL(all_xor)) ==
		*max_element(ALL(all_xor))) {
		return *min_element(ALL(all_xor));
	} else {
		return -1;
	}
}

void experiment(int M) {
    vector<int> shff;
    auto num_kind = pow2(2, M);
    REP(m, num_kind) {
        shff.pb(m);
        shff.pb(m);
    }

	set<int> seen;

    do {
		auto K = check_k(shff, num_kind);
		if (seen.count(K)) continue;
		seen.insert(K);

        cout << "K = " << K << endl;
        for(auto s: shff) cout << s << " ";
        cout << endl;
    } while(next_permutation(ALL(shff)));
}

int main(void)
{
    cin.sync_with_stdio(false);
    ll M, K;
    cin >> M >> K;

    if (M == 0) {
        if (K == 0) {
            cout << "0 0" << endl;
        } else {
            cout << -1 << endl;
        }
    }
    else if (M == 1) {
        if (K == 0) {
            cout << "0 0 1 1" << endl;
        } else {
            cout << -1 << endl;
        }
    }
    else {
        auto mx = pow2(2, M);
        if (K >= mx) {
            cout << -1 << endl;
        } else {
            vector<int> ans;
            if (K == 0) {
                REP(i, mx) {
                    ans.pb(i);
                    ans.pb(i);
                }
            } else {
                REP(k, K) ans.pb(k);
                for(int k = K; k >= 0; --k) ans.pb(k);
                FOR(k, K + 1, mx) ans.pb(k);
                ans.pb(K);
                for(int k = mx - 1; k >= K + 1; --k) ans.pb(k);
            }
            REP(k, SIZE(ans)) {
                if (k == 0) cout << ans[k];
                else cout << " " << ans[k];
            }
            cout << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 2932
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const pii dam = pii(-1, -1);
int h, w, s;
int u[32][32], cu[32][32];
int all;
pii dp[32][32][32][32];

int sum(int i, int j, int k, int l) {
  int res = cu[k][l];
  if (i) res -= cu[i-1][l];
  if (j) res -= cu[k][j-1];
  if (i && j) res += cu[i-1][j-1];
  return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> h >> w >> s, h) {
    all = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> u[i][j];
        cu[i][j] = u[i][j];
        all += u[i][j];
      }
    }
    for (int i = 0; i < h; i++) {
      for (int j = 1; j < w; j++) {
        cu[i][j] += cu[i][j-1];
      }
    }
    for (int j = 0; j < w; j++) {
      for (int i = 1; i < h; i++) {
        cu[i][j] += cu[i-1][j];
      }
    }
    
    for (int dy = 0; dy < h; dy++) {
      for (int dx = 0; dx < w; dx++) {
        for (int i = 0; i+dy < h; i++) {
          for (int j = 0; j+dx < w; j++) {
            int k = i+dy, l = j+dx;
            pii tmp = dam;
            if (s - (all - sum(i, j, k, l)) >= 0) {
              tmp = pii(1, s - (all - sum(i, j, k, l)));
            }
            for (int m = i; m < k; m++) {
              pii U = dp[i][j][m][l], D = dp[m+1][j][k][l];
              if (U == dam || D == dam) continue;
              if (U.first + D.first == tmp.first) {
                tmp = pii(tmp.first, max(tmp.second, min(U.second, D.second)));
              } else if (U.first + D.first > tmp.first) {
                tmp = pii(U.first + D.first, min(U.second, D.second));
              }
            }
            for (int m = j; m < l; m++) {
              pii L = dp[i][j][k][m], R = dp[i][m+1][k][l];
              if (L == dam || R == dam) continue;
              if (L.first + R.first == tmp.first) {
                tmp = pii(tmp.first, max(tmp.second, min(L.second, R.second)));
              } else if (L.first + R.first > tmp.first) {
                tmp = pii(L.first + R.first, min(L.second, R.second));
              }
            }
            dp[i][j][k][l] = tmp;
          }
        }
      }
    }
    cout << dp[0][0][h-1][w-1].first << " " << dp[0][0][h-1][w-1].second  << endl;
  }

  return 0;
}


Measured memory_bytes: 10992
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/

int main(void){
  int x, a, b;
  cin >> x >> a >> b;
  if (abs(x-a)>abs(x-b)) cout << "B" << endl;
  else cout << "A" << endl;

  
}


Measured memory_bytes: 256
class Dice(object):
	def __init__(self,List):
		self.face=List
	
	def n_spin(self,List):
		temp=List[0]
		List[0]=List[1]
		List[1]=List[5]
		List[5]=List[4]
		List[4]=temp

	def s_spin(self,List):
		temp=List[0]
		List[0]=List[4]
		List[4]=List[5]
		List[5]=List[1]
		List[1]=temp

	def e_spin(self,List):
		temp=List[0]
		List[0]=List[3]
		List[3]=List[5]
		List[5]=List[2]
		List[2]=temp

	def w_spin(self,List):
		temp=List[0]
		List[0]=List[2]
		List[2]=List[5]
		List[5]=List[3]
		List[3]=temp

dice = Dice(map(int,raw_input().split()))
command = list(raw_input())
for k in command:
	if k=='N':
		dice.n_spin(dice.face)
	elif k=='S':
		dice.s_spin(dice.face)
	elif k=='E':
		dice.e_spin(dice.face)
	else:
		dice.w_spin(dice.face)
print dice.face[0]

Measured memory_bytes: 6448
#include<bits/stdc++.h>
using namespace std;
long long ans;
int main() {
    int N, smlr;
    scanf("%d", &N);
    vector<int> A(N+1), B(N);
    for (auto& a:A) scanf("%d", &a);
    for (auto& b:B) scanf("%d", &b);
    for (int i = 0; i<N; i++) {
        A[i] -= smlr = min(A[i], B[i]);
        B[i] -= smlr;
        ans += smlr;
        A[i+1] -= smlr = min(A[i+1], B[i]);
        ans += smlr;
    }
    printf("%lld\n", ans);
    return 0;
}

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

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define INF 1000000007
#define LLINF 2696969696969696969ll
#define MAXN 100013

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

int N, W;
ll dp[MAXN];
int ans;

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N >> W;
	FOR(i, 1, MAXN) dp[i] = LLINF;
	FOR(i, 0, N)
	{
		ll x, y; cin >> x >> y;
		FORD(j, MAXN - y, 0)
		{
			ckmin(dp[j + y], dp[j] + x);
		}
	}
	FOR(i, 1, MAXN)
	{
		if (dp[i] <= W) ans = i;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int T = reader.nextInt();
		int min = 1000;
		String result = "TLE";
		for (int i = 0; i < N; i++) {
			int A = reader.nextInt();
			int B = reader.nextInt();
			if (B <= T && A <= min) {
				min = A;
				result = Integer.toString(min);
			}
		}

		reader.close();
		System.out.print(result);
	}
}



Measured memory_bytes: 23892
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>
#include <vector>


using namespace std;

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


	return 0;
}


Measured memory_bytes: 256
//abc170_c.cpp
//Sun Jun 14 20:56:14 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

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

int main(){
	int x,n;
	cin >> x >> n;

	map<int,int> mp;
	for (int i=0;i<n;i++){
		int tmp;
		cin >> tmp;
		mp[tmp] = 1;
	}

	int tmp1 = x;
	int tmp2 = x;
	while(1){
		auto itr1 = mp.find(tmp1);
		auto itr2 = mp.find(tmp2);
		if (itr1 != mp.end() && itr2 != mp.end()){
			tmp1++;
			tmp2--;
		}else {
			if (itr1 == mp.end() && itr2 == mp.end()){
				cout << tmp2 << endl;
			}else if (itr1 == mp.end()){
				cout << tmp1 << endl;
			}else {
				cout << tmp2 << endl;
			}
			return 0;
		}
	}
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
typedef long long ll;
using namespace std;

int main() {
	ll N,K; cin >> N >> K;
	ll ans = 0;
	ans = pow(K - 1, N - 1) * K;
	cout << ans << endl;
}


Measured memory_bytes: 512
#include <stdio.h>

int main()
{
  long long n,b,r,re;

  scanf("%lld %lld %lld",&n,&b,&r);

  re = n / (b+r);

  if( n%(b+r) >= b )
    printf("%lld",b*re + b);
  else
    printf("%lld", b*re + n%(b+r));

  return 0;
}


Measured memory_bytes: 1708
n, m= map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
r = range(n-m+1)
 
for i in r:
    for j in r:
        for k in range(m):
            if a[i+k][j:j+m] != b[k]:
                break
        else:
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 63052
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, x;
int ans[4];
int y;
int cnt;

signed main() {
	cin >> n >> x;
	if (x == 1 || x == 2 * n - 1) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	if (n == 2) {
		cout << 1 << endl << 2 << endl << 3 << endl;
		return 0;
	}
	ans[1] = x;
	if (x < 2 * (n - 1)) {
		ans[0] = 2 * n - 1;
		ans[2] = 1;
		ans[3] = 2 * (n - 1);
		y = x;
	}
	else {
		ans[0] = 1;
		ans[2] = 2 * n - 1;
		ans[3] = 2;
		y = 2;
	}
	int j = 1;
	while (cnt < n - 2) {
		j++;
		if (j != y) {
			cout << j << endl;
			cnt++;
		}
	}
	for (int i = 0; i < 4; i++)cout << ans[i] << endl;
	cnt += 4;
	while (cnt < 2 * n - 1) {
		j++;
		if (j != y) {
			cout << j << endl;
			cnt++;
		}
	}
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int partition(int a[],int l,int r);
int quicksort(int a[],int l,int r);

int main(void){
  int N,d[100005],K,i;
  char str[1000000],*p;
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  d[0]=atoi(p);
  
  for(i=1;i<N;i++){
    p=strtok(NULL," \n");
    d[i]=atoi(p);
  }
  
  quicksort(d,0,N-1);
  
  
  K=d[(N-1)/2+1]-d[(N-1)/2];
  
  printf("%d\n",K);
  
  
  return 0;
}

int partition(int a[],int l,int r){
    int i,j,bbuff;
    long abuff,pivot;
    
    i=l-1,j=r;
    pivot=a[r];
    for(;;){
        while(a[++i]<pivot);
        
        while(i<=--j && a[j]>=pivot);
        
        if(i>=j){
            abuff=a[r],a[r]=a[i],a[i]=abuff;
            break;
        }
        
        abuff=a[i],a[i]=a[j],a[j]=abuff;
        
    }
    
    return i;
}

int quicksort(int a[],int l,int r){
    int v;
    
    if(l>=r){
        return 0;
    }
    
    v=partition(a,l,r);
    
    quicksort(a,l,v-1);
    quicksort(a,v+1,r);
    
    return 0;
    
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,i,j,h,w;
    cin>>n>>h>>w;
    ll tot=0;
    for(i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        if(x>=h && y>=w)
            tot++;
    }
    cout<<tot<<endl;
}


Measured memory_bytes: 256
N,Q=map(int,input().split())
S=input()
LR=[list(map(int,input().split())) for i in range(Q)]
I = [0 for i in range(N)]
for i in range(N-1):
  if S[i]=="A" and S[i+1]=="C":
    I[i+1]=I[i]+1
  else:
    I[i+1]=I[i]
      
for i in range(Q):
  l=LR[i][0]-1
  r=LR[i][1]-1
  print(I[r]-I[l])

Measured memory_bytes: 69208
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int s1 = sc.nextInt();
   int s2 = sc.nextInt();
   int s3 = sc.nextInt();
   
   int[] aaa = {s1,s2,s3};
   Arrays.sort(aaa);
   System.out.println(aaa[1]+aaa[0]);
 }
}

Measured memory_bytes: 21844
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;

int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination

int main(){
    int n;
    cin >>n;
    int a[n+2];
    a[0]=0;
    a[n+1]=0;
    rep2(i,n){
        cin >> a[i];
    }
    int b[n+1];
    int k=0;
    rep2(i,n){
        if(i%2==0){
            k-=a[i];
        }else{
            k+=a[i];
        }
    }
    b[n]=k/2;
    for(int i=n-1;i>1;i--){
        b[i]=a[i+1]-b[i+1];
    }
    b[1]=a[1]-b[n];
    cout<<2*b[n]<<" ";
    for(int i=1;i<n-1;i++){
        cout<<2*b[i]<<" ";
    }
    cout<<2*b[n-1]<<endl;
    return 0;
}

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

using namespace std;

int main() {
    int n;
    int cnt =0;
    cin >> n;

    int a_cnt=0;
    int b_cnt=0;
    int ba_cnt=0;
    string s;
    size_t found;

    for(int i=0;i<n;i++) {
        cin >> s;

        found = s.find("AB");
        while(found != string::npos){
            cnt++;
            found = s.find("AB", found+1);
        }

        if(s.front() == 'B') {
            if(s.back() == 'A') ba_cnt++; 
            else b_cnt++;
        } else {
            if(s.back() == 'A') a_cnt++; 
        }
    }

    if(ba_cnt > 0) {
        cnt += ba_cnt-1; 
        if(a_cnt > 0) {
            cnt++;
            a_cnt--;
        }
        if(b_cnt > 0) {
            cnt++;
            b_cnt--;
        }
    }

    if(a_cnt > 0 & b_cnt > 0) cnt += min(a_cnt,b_cnt);

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;
typedef long long ll;
map<int,int> mp;
int n,a[200005];
ll ans=0;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		ans+=mp[a[i]-i];
		mp[-a[i]-i]++;
	}
	cout<<ans;
}


Measured memory_bytes: 21476