akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main() {
    int H,W;
    cin >> H >> W;
    vector<vector<string>>S(H,vector<string>(W));
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> S[i][j];
            if(S[i][j] == "snuke") {
                cout << (char)(j+'A') << i+1 << endl;
            }
        }
    }
}




Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))


maxA = max(a)
dp = [0]*(maxA+1)
count = 0

for e in a:
    for i in range(e,maxA+1,e):
        dp[i] += 1

for e in a:
    if dp[e] == 1:
        count += 1

print(count)


Measured memory_bytes: 121976
#include <bits/stdc++.h>
#include<unordered_map>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll ans = 0;

int main() {
	cin >> N >> M;
	vector<ll>x(N), y(N), z(N);
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i] >> z[i];
	}
	for (int i = 0; i < (1 << 3); i++) {
		ll a, b, c;
		if (i&(1 << 2))a = 1;
		else a = -1;
		if (i&(1 << 1))b = 1;
		else b = -1;
		if (i&(1 << 0))c = 1;
		else c = -1;
		vector<ll>sum(N);
		for (int j = 0; j < N; j++) {
			sum[j] = a * x[j] + b * y[j] + c * z[j];
		}
		sort(sum.rbegin(), sum.rend());
		ll tmp = 0;
		for (int j = 0; j < M; j++)tmp += sum[j];
		ans = max(tmp, ans);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(n); ++i)
#define REPR(i,n,m) for (int i=(n); i>=(m); --i)
using namespace std;
using LL = long long;
using LD = long double;
using PLL = pair<long long, long long>;
using PLD = pair<long double, long double>;
using VLL = vector<long long>;
using VLD = vector<long double>;
using VPLL = vector<PLL>;
using VPLD = vector<PLD>;

const int INF = numeric_limits<int>::max();
const unsigned long long int ULLINF = numeric_limits<unsigned long long int>::max();

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

    LL n; cin >> n;
    VLL v;
    map<string, LL> mp;
    REP(i,n) {
        LL tmp;
        cin >> tmp;
        if (mp[to_string(tmp)]==0) {
            v.push_back(tmp);
            mp[to_string(tmp)] = 1;
        }
        else mp[to_string(tmp)]++;
    }
    
    //sort(v.begin(), v.end());
    if (v.size()<3) { cout << 0 << endl; return 0;}
    
    LL ans = 0;
    LL tmp = 0;
    for (LL i=0; i<(v.size()-2); i++)
    {
        for (LL j=i+1; j<(v.size()-1); j++)
        {
            for (LL k=j+1; k<(v.size()); k++)
            {
                if (((v[i]+v[j]>v[k])&&(v[j]+v[k]>v[i]))&&(v[k]+v[i]>v[j]))
                    ans += mp[to_string(v[i])]*mp[to_string(v[j])]*mp[to_string(v[k])];
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3716
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	ll N, A, B;
	cin >> N >> A >> B;
	ll  ans = (N / (A + B)) * A;
	N = N % (A + B);
	ans += min(A, N);
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;


int twice = 1, n;
int a[1100000];
int cnt[3];


int main(){
    cin >> n;
    for(int i = 0;i < n;i++){
        scanf("%1d", a + i);
        a[i]--;
        cnt[a[i]]++;
    }

    if(cnt[1] == 0){
        twice = 2;
        for(int i = 0;i < n;i++)a[i] /= 2;
    }         
    Int ans = 0;
    int n_1Ck = 0;
    for(int i = 0;i < n;i++){
        if(n_1Ck == 0)ans += a[i];
        int a = n-1-i;
        int b = i+1;
        if(i ==n-1)continue;
        while(a % 2 == 0){
            n_1Ck++;
            a /= 2;
        }
        while(b % 2 == 0){
            n_1Ck--;
            b /= 2;
        }
    }
    ans %= 2;
    ans *= twice;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4352
import sys
import numpy as np

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, M, Q = map(int, readline().split())
    LR = [[0] * (N + 1) for _ in range(N + 1)]

    for _ in range(M):
        L, R = map(int, readline().split())
        LR[L][R] += 1

    LR = np.array(LR)
    LR = LR.cumsum(axis=0).cumsum(axis=1)

    for _ in range(Q):
        p, q = map(int, readline().split())
        ans = LR[q][q] - LR[q][p - 1] - LR[p - 1][q] + LR[p - 1][p - 1]
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 33192
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <ctime>
#include <set>
#include <map>
#include <vector>
using namespace std;

template <typename T>
T next_int() {
	T x = 0, p = 1;
	char ch;
	do { ch = getchar(); } while(ch <= ' ');
	if(ch == '-') {
		p = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		x = x * 10 + (ch - '0');
		ch = getchar();
	}
	return p * x;
}

const int max_int = (int)1e9 + 228;
const int max_n = (int)1e5 + 228;
const int mod = (int)1e9 + 7;

int main() {
//	freopen(".in", "r", stdin);

	int n = next_int<int>();
	int m = next_int<int>();

	vector<int> a(n);

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

	for(int i = 1; i <= n - 1; i++) {
		if(a[i] + a[i - 1] >= m) {
			puts("Possible");
		
		        for(int j = 1; j < i; j++) cout << j << "\n";

		        for(int j = n - 1; j >= i + 1; j--) cout << j << "\n";

		        cout << i << "\n";
		
			return 0;
		}
	}

	puts("Impossible");
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    string s[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> s[i][j];
        }
    }
    char q='A';
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=="snuke"){
                cout << q << i+1 << endl;
                return 0;
            }
            q++;
        }
        q='A';
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
Alice = 0
Bob = 0
tf = 0
for i in l:
    if tf == 0:
        Alice += i
        tf = 1
    else:
        Bob += i
        tf = 0
ans = Alice - Bob
print(ans)

Measured memory_bytes: 3060
// Course＞Introduction to Programming I ＞ ITP1_1_B:   X Cubic
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_B&lang=jp

// 以下のソースコードには(複数の？)誤りがあるので、このまま提出しても「誤り」と判定されます。
// ソースコード中の誤りを修正し、「正解」（Accepted）を出してください。

// 適宜、paiza.io (https://paiza.io/ja/projects/new) などのC++実行環境を、確認に用いることを推奨します。

#include <iostream>
using namespace std;

int main(){
	int x;
	cin >> x;
	cout << ( x * x * x ) << endl;
	return 0;
	}


Measured memory_bytes: 3088
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

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

int main(){
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1;
    cin >> s2;
    bool yoko_flg = false;
    ll ans = 1;
    rep(i, n) {
        if ( i < n - 1 && s1[i] == s1[i+1] ) {
            if ( i == 0 ) {
                ans = ans * 6 % mod;
            }
            else if ( yoko_flg ) {
                ans = ans * 3 % mod;
            }
            else {
                ans = ans * 2 % mod;
            }
            yoko_flg = true;
            ++i;
        }
        else {
            if ( i == 0 ) {
                ans = ans * 3 % mod;
            }
            else if ( yoko_flg ) {
                ans = ans * 1 % mod;
            }
            else {
                ans = ans * 2 % mod;
            }
            yoko_flg = false;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A=sc.nextInt(),B=sc.nextInt(),C=sc.nextInt(),D=sc.nextInt();
		if(Math.ceil((double)A/D) >=Math.ceil((double)C/B)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 35732
#include <bits/stdc++.h>
#define int long long 
 
using namespace std;
 
const int maxn = 1e6+10;
int n, W;
int w[maxn], v[maxn];
int dp[maxn];
 
int32_t main(){
	scanf("%lld%lld", &n, &W);
 
	for(int i=0; i<n; i++){
		scanf("%lld%lld", &w[i], &v[i]);
	}
 
	for(int i=1; i<maxn; i++){
		dp[i] = 1e10;
	}
 
	for(int i=0; i<n; i++){		
		for(int j=maxn; j>=1; j--){
			if(j-v[i] < 0){
				continue;
			}
				dp[j] = min(dp[j-v[i]] + w[i], dp[j]);	
		}
	}
	
 
	int ans=-1e9;
	for(int i=0; i<maxn; i++){
		if(dp[i] <= W){
			ans = max(ans, i);
		}
	}
 
	printf("%lld\n", ans);
}


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

int main(void)
{
	int h, w;
	int i, j;
	while (true){
		cin >> h >> w;
		if (h == 0 && w == 0) break;
		for (i = 0;i < h; i++){
			for (j = 0; j < w; j++)
				cout << "#";
			cout << "\n";
		}
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 1120
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

n,c,k = list(map(int, input().split()))
ts = [None]*n
for i in range(n):
    ts[i] = int(input())
ts.sort()
ans = 0
last = -float("inf")
num = 0
for t in ts:
    if last<t or num==c:
        last = t+k
        num = 1
        ans += 1
    else:
        num += 1
print(ans)

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

int main(){
    int N;
    string A,B,C;
    cin>>N>>A>>B>>C;
    int cnt=0;
    for(int i=0;i<N;i++){
        if(A[i]!=B[i]){
            if(B[i]!=C[i]){
                if(C[i]!=A[i]){
                    cnt+=2;
                }else cnt++;
            }else cnt++;
        }else if(B[i]==C[i]){
        }else cnt++;
    }

    cout<<cnt<<endl;


}

Measured memory_bytes: 384
// finish date: 2018/2/09

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>>
        vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    int K, A, B;
    cin >> K >> A >> B;
    ll ans = 1;
    if (1 + K <= A || B - A <= 2) {
        cout << 1 + K << endl;
        return 0;
    }
    //前処理
    int T = K;
    int last_add = 0;
    T -= A - 1;
    ans = A;
    if (T % 2) last_add = 1;

    T /= 2;
    ans+= (ll) T * (B - A);

    ans += last_add;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace _4_A {
    class Program {
        static void Main (string[] args) {
                var input = Console.ReadLine ().Split ();
                var a = Convert.ToInt32 (input[0]);
                var b = Convert.ToInt32 (input[1]);

                var d = a / b;
                var r = a % b;
                var f = (double) a / (double) b;

                Console.WriteLine ($"{d} {r} {f:f5}");
        }
    }
}


Measured memory_bytes: 18096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<ll> A(N);
    ll ans = 0;
    rep(i,N){
        cin>>A[i];
        while(A[i] % 2 == 0){
            A[i] /= 2;
            ans++;
        }
    }
    cout << ans <<endl;  
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    ll n;
    string s;
    cin >> n >> s;
    vector<int> red;
    vector<int> gr;
    set<int> bl;
    //vector<int> bl;
    ll cnt=0;
    rep(i,0,n){
        
        if(s.at(i)=='R'){
            red.push_back(i);
        }
        if(s.at(i)=='G'){
            gr.push_back(i);
        }
        if(s.at(i)=='B'){
            bl.insert(i);
            //bl.push_back(i);
            cnt++;
        }
        
    }
    //cout << cnt << endl;
    ll sum =0;
    for(int i:red){
         for(int j:gr){
                sum += cnt;
                if((i+j)%2==0&&bl.count((i+j)/2)) sum--;
                if(bl.count(2*i-j)) sum--;
                if(bl.count(2*j-i)) sum--;

            
        }
    }
    cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3708
def main():
    import sys
    from heapq import heappop, heappush
    from collections import deque

    def input(): return sys.stdin.readline().rstrip()

    def check(k):
        tmp = str(k)
        flag = 1
        if len(tmp) > 2:
            for s in nums:
                flag &= (s in tmp)
            if flag: 
                return True
        return False

    n = int(input())
    num = [3, 5, 7]
    nums = ['3', '5', '7']
    que = deque([3, 5, 7])
    cnt = 0
    while que:
        x = que.popleft()
        if x > n:
            break
        if check(x):
            cnt += 1
        for i in num:
            que.append(10*x+i)
    print(cnt)


    
if __name__ == '__main__':
    main()

Measured memory_bytes: 12296
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  int n;
  cin >> n;
  const int mx = 1000005;
  vi a(mx,0);
  vi hurui(mx,0);
  rep(i,n) {
    int in;
    cin >> in;
    a.at(in)++;
  }

  rep(i,mx) {
    if(a.at(i) == 0) continue;
    int ai = i;
    while(ai<mx) {
      hurui[ai]++;
      ai+=i;
    }
  }
  int ans = 0;
  rep(i,mx) {
    if(a.at(i) != 1) continue;
    if(hurui.at(i) == 1) {
      ans++;
    }
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 11180
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

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

	if (n < 1000) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ABD" << endl;
	}

	return 0;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	int a[n];
	for (int i = 0; i < n; i++) cin >> a[i];
	bool dp[100010] = { false };
	for (int i = 1; i <= k; i++) {
		for (int j = 0; j < n; j++) {
			if (i - a[j] >= 0) {
				if (dp[i - a[j]] == false) {
					dp[i] = true;
				}
			}
		}
	}
	if (dp[k]) {
		cout << "First" << endl;
	}
	else {
		cout << "Second" << endl;
	}
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int gcd(int a, int b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}

int main() {
  int a, b, c, d, ans = 0;
  cin >> a >> b >> c >> d;
  ans = abs(a - c) + abs(b - d);
  ans -= gcd(abs(a - c), abs(b - d));
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll mod = 1000000007;
ll ans[100005];
ll L[100005];
ll R[100005];
int main() {
	string s;
	cin >> s;
	ll lcount = 0;
	ll rcount = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'L') {
			L[lcount] = i;
			lcount++;
		}
		else {
			R[rcount] = i;
			rcount++;
		}
		ans[i] = 0;
	}

	

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'R') {
			for (int j = 0; j <lcount; j++) {
				if (i < L[j]) {
					if ((L[j] - i) % 2 == 0) {
						ans[L[j]]++;
					}
					else {
					ans[L[j]-1]++;
					}
				break;
				}
			}
		}
		else {
			for (int k = rcount-1; k >= 0; k--) {
				if (i > R[k]) {
					if ((i - R[k]) % 2 == 0) {
						ans[R[k]]++;
					}
					else {
						ans[R[k]+1]++;
					}
					break;
				}
				
			}
		}
	}
	for (int i = 0; i < s.size(); i++) {
		cout << ans[i] << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 5300
#include<iostream>
#include<string>
#include<vector>

int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::string s, t;
  std::cin >> s >> t;
  
  int s_len = s.size();
  int t_len = t.size();
  
  int lcs[s_len + 1][t_len + 1];
  for(int i = 0; i <= s_len; ++i) lcs[i][0] = 0;
  for(int j = 1; j <= t_len; ++j) lcs[0][j] = 0;
  
  for(int i = 0; i < s_len; ++i){
    for(int j = 0; j < t_len; ++j){
      if(s[i] == t[j]) lcs[i + 1][j + 1] = lcs[i][j] + 1;
      else lcs[i + 1][j + 1] = std::max(lcs[i + 1][j], lcs[i][j + 1]);
    }
  }
  
  std::vector<char> c;
  
  int i = s_len;
  int j = t_len;
  while(lcs[i][j] > 0){
    if(s[i - 1] == t[j - 1]){
      --i;
      --j;
      c.push_back(s[i]);
    }else if(lcs[i - 1][j] == lcs[i][j]){
      --i;
    }else{
      --j;
    }
  }
  
  for(i = c.size() - 1; i >= 0; --i) std::cout << c[i];
  std::cout << std::endl;
  
  return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
#define fastio std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pii pair<int, int>
#define mpi make_pair
#define F first
#define S second
#define pb push_back
#define INF 1e15

const int nax = 405;
ll dp[405][405];


int main()
{   
    fastio

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

    for(int i = 0 ; i<n;i++)
        for(int j = 0 ; j<n;j++)
                dp[i][j] = INF;
    
    for(int i = 0 ; i<n;i++)
    {
        dp[i][i] = 0;
    }

    vector<ll> psum(n+1 , 0);

    for(int i= 1;i<=n;i++)
        psum[i] = psum[i-1] + arr[i-1];

    for(int k = 2 ;k<=n;k++)
    {
        for(int i = 0;i+k-1<n;i++)
        {
            int j = i+k-1;

            for(int mid = i+1;mid<=j;mid++)
            {
                dp[i][j] = min(dp[i][j] , dp[i][mid-1]+dp[mid][j]);
            }
            dp[i][j] += psum[j+1]-psum[i];
        }
        
    }

    cout<<dp[0][n-1]<<endl;
    return 0;
} 


Measured memory_bytes: 1536
//Have a nice day:)
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2147483647;
#define LL long long

inline int read();

const int N=9e5+2;
int n, m, k, c, p;
LL cnt[10];

struct Node 
{ 
    int x, y;
    bool operator < (const Node&b) { return x==b.x ? y<b.y : x<b.x; }
}add[N];

void Work()
{
    n=read(), m=read(), k=read();
    for(int i=1; i<=k; ++i)
    {
        int x=read(), y=read();
        for(int j=-1; j<=1; ++j)
            for(int u=-1; u<=1; ++u)
                if(x+j>1 && x+j<n && y+u>1 && y+u<m) 
                    ++c, add[c]=(Node){ x+j, y+u } ;
    }

    sort(add+1, add+c+1);

    for(int i=1; i<=c; ++i)
    {
        if(add[i].x==add[i-1].x && add[i].y==add[i-1].y) ++p;
        else p=1;
        --cnt[p-1], ++cnt[p];
    }
    
    cnt[0]+=1ll*(n-2)*(m-2);

    for(int i=0; i<=9; ++i) printf("%lld\n", cnt[i]);
}

int main()
{
    #ifdef gc
    freopen("61b.in","r",stdin);
    freopen("61b.out","w",stdout);
    #endif

    Work();

    return 0;
}

inline int read()
{
    char c; bool type=1;
    while((c=getchar())<'0' || c>'9')
        if(c=='-') type=0;
    int ans=c^48;
    while((c=getchar())>='0' && c<='9')
        ans=(ans<<3)+(ans<<1)+(c^48);
    return type?ans:-ans;
}


Measured memory_bytes: 7296
using System;

namespace _0501
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0)
                {
                    break;
                }
                string[] s = new string[n];
                for (int i = 0; i < n; i++)
                {
                    s[i] = Console.ReadLine();
                }
                int a = int.Parse(Console.ReadLine());
                for (int i = 0; i < a; i++)
                {
                    char now = char.Parse(Console.ReadLine());
                    bool b = true;
                    for (int j = 0; j < n; j++)
                    {
                        if (now == s[j][0])
                        {
                            Console.Write(s[j][2]);
                            b = false;
                        }
                    }
                    if (b)
                    {
                        Console.Write(now);
                    }
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 8900
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i
k = gets.to_i
array = a,b,c,d,e
array.sort #配列を昇順に整列


if k < (array.last - array.first)
    print ":("
else
    print "Yay!"
end



Measured memory_bytes: 1788
#include <iostream>
#define int long long int
using namespace std;
signed main(){
  int a,b,k;
  cin >> a >> b >> k;
  if(a<k){
    if(b<(k-a)){
      cout << 0 << " " << 0 << endl;
    }else{
      cout << 0 << " " << b-(k-a) << endl;
    }
  }else{
    cout << a-k << " " << b << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		
		Scanner sc= new Scanner(System.in);
		int n = sc.nextInt();
		int cost[] = new int[n];
		for(int i=0;i<n;i++){
		    cost[i] = sc.nextInt();
		}
		int dp[]=new int[n];
		for(int i=1;i<n;i++){
		    dp[i] = dp[i-1]+Math.abs(cost[i]-cost[i-1]);
		    if (i-2>=0){
		        dp[i] = Math.min((dp[i-2]+Math.abs(cost[i-2]-cost[i])), dp[i]);
		    }
		}
	    System.out.println(dp[n-1]);
		
	}
}

Measured memory_bytes: 50492
#include<bits/stdc++.h>
using namespace std;
int main(){
  double N,K,a,n,sum=0;cin>>N>>K;
  if(N<K){
    for(int i=1;i<=N;i++){
      a=0;n=i;
      for(int j=0;n<K;j++){
        n*=2;
        a++;
      }
      sum+=1/(N*pow(2,a));
    }
  }
  else{
    for(int i=1;i<K;i++){
      a=0;n=i;
      for(int j=0;n<K;j++){
        n*=2;
        a++;
      }
      sum+=1/pow(2,a);
    }
    sum=(sum+N-K+1)/N;
  }
  cout << fixed << setprecision(10) << sum << endl;
}

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

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;
 
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;

int main() {

  string s;
  cin >> s;
  
  vector<int> a(s.size(),0);
  
  for ( int i = 0; i < s.size(); i++){
    for ( int j = 0; j < s.size(); j++){
      if ( s[i] == s[j] ){
        a[i]++;
        if ( a[i] == 2 ){
          cout << "no" << endl;
          return 0;
        }
      }
    }
  }
  
  cout << "yes" << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 10000000001
#define DIM 200001
#define mod 1000000007
#define PI 3.1415926535897932384626433
#define se second
#define fi first
#define pb push_back
#define T true
#define F false
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define endl "\n"
typedef char ch;
typedef bool boll;
typedef string st;
typedef long long ll;
typedef long double ld;
typedef set <string>sst;
typedef set <long long>sl;
typedef queue <long long>que;
typedef vector <long long>vec;
typedef unsigned long long ull;
typedef map <long long,long long>mll;
typedef pair <long long,long long>pll;
typedef vector <pair<long long,long long> >vpl;
typedef pair <long long, unsigned long long > pul;
ll n,z,x,c;
st s,t;
int main()
{
    cin>>n;
    cin>>s;
    cin>>t;
    for(int i=0;i<n;i++)cout<<s[i]<<t[i];
    cout<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main() {
    double mov, dir;
    double x, y, d;
    
    while (scanf("%lf,%lf",&mov,&dir),mov != 0 || dir != 0) {
        x += sin(d*M_PI/180)*mov;
        y += cos(d*M_PI/180)*mov;
        
        d += dir;
    }
    
    printf("%d\n%d\n", (int)x, (int)y);
    
    return 0;
}

Measured memory_bytes: 632
// AtCoder Regular Contest 073
// D - Simple Knapsack

#include <cstdio>
#include <vector>
#include <algorithm>
#define MAX_WD 3
using namespace std;
typedef long long int ll;


int N;
ll W, W1;
vector<int> vs[MAX_WD + 1];
ll ans;

void sel(int *cnt, int wd, ll w_sum) {
  ll v_sum;
  if (w_sum > W) {
    return;
  }
  if (wd > MAX_WD) {
    v_sum = 0;
    for (int j = 0; j <= MAX_WD; j++) {
      if (cnt[j] == 0) {
        continue;
      }
      v_sum += vs[j][cnt[j] - 1];
    }
    ans = max(ans, v_sum);
    return;
  }

  for (int i = 0; i <= (int)vs[wd].size(); i++) {
    cnt[wd] = i;
    sel(cnt, wd + 1, w_sum + (W1 + wd) * cnt[wd]);
  }
  return;
}

int main() {

  ll w;
  int v;
  int cnt[MAX_WD + 1];

  scanf("%d%lld", &N, &W);
  for (int i = 0; i < N; i++) {
    scanf("%lld%d", &w, &v);
    if (i == 0) {
      W1 = w;
    }
    vs[w - W1].push_back(v);
  }
  for (int j = 0; j <= MAX_WD; j++) {
    sort(vs[j].rbegin(), vs[j].rend());
    for (int i = 1; i < (int)vs[j].size(); i++) {
      vs[j][i] += vs[j][i - 1];
    }
  }

  ans = 0;
  sel(cnt, 0, 0);

  printf("%lld\n", ans);

  return 0;

}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,t;
	cin>>n>>t;
	int a[n];
	ll ans = 0;
	ll j = 0;
	for(int i = 0 ;i<n; i++) cin>>a[i];
	for(int i = 0;i <n;i++)
	{
		if(j>a[i])
		{
			ans += t-(j-a[i]);
			j = a[i]+t;
		}
		else
		{
			ans += t;
			j = a[i]+t;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    ll N; cin>>N;
    vector<vector<ll>>a(N,vector<ll>(2));
    rep(i,N)cin>>a[i][0]>>a[i][1];
    ll ans =0;
    rep(i,N){
        a[N-1-i][0]+=ans;
        if(a[N-1-i][0]%a[N-1-i][1]==0)continue;
        else {
        ans+=(a[N-1-i][0]/a[N-1-i][1]+1)*a[N-1-i][1]-a[N-1-i][0];
        //cout<<ans<<" ";
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const LL mod = 1e9 + 7;

#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed << setprecision(10);
}

inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_array(const int A[], int n) {
    REP(i, n) {
        if (i < n - 1) {
            cout << A[i] << " ";
        } else {
            cout << A[i] << endl;
        }
    }
}

struct uf {
    int count;
    vector<int> id;
    vector<int> size;
    int max_size = 1;

    void init(int n) {
        count = n;
        id.assign(n, 0);
        size.assign(n, 0);

        REP(i, n) {
            id[i] = i;
            size[i] = 1;
        }
    }

    int find(int x) {
        while (x != id[x]) x = id[x];
        return x;
    }

    bool connected(int p, int q) {
        return find(p) == find(q);
    }

    void united(int p, int q) {
        p = find(p);
        q = find(q);

        if (!connected(p, q)) {
            count--;
            if (size[p] < size[q]) {
                id[p] = q;
                size[q] += size[p];
            } else {
                id[q] = p;
                size[p] += size[q];
            }
        }

        max_size = max(max_size, size[p]);
        max_size = max(max_size, size[q]);
    }
};

inline void solve() {
    int n, m;
    cin >> n >> m;

    uf uf;
    uf.init(n);

    int a, b;

    REP(i, m) {
        cin >> a >> b;
        uf.united(a-1, b-1);
    }

    cout << uf.count - 1 << endl;
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    int t = 1;
    // cin >> t;

    for (int _ = 0; _ < t; _++) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3936
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
#include<math.h>
//#include "Ants.h"
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef pair < int, int> P;
/****Union-Ford-Tree***/
int par[int(0x7ffffff)];//Parent
int Rank[int(0x7ffffff)];//Deep_of_the_Tree

//int a[100] = { 4,2,3,1,5 }, m[100] ={3,2,2};
//int n = 0;
//const ll mod = 1000000007;


//n要素で初期化
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		Rank[i] = 0;
	}
}
//木の根探し
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}
//xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (Rank[x] < Rank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (Rank[x] == Rank[y])Rank[x]++;
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}
/************************************************************************************/
int dx[4] = { 1,0/*,-1,0*/ }, dy[4] = { 0,1/*,0,-1*/ };
/**************/
int n, m;
int dp[3001][3001];
//string d[3001][3001];

int main()
{

	string s, t;
	cin >> s >> t;
	n = s.size(), m = t.size();
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (s[i] == t[j]) {
				dp[i + 1][j + 1] = dp[i][j] + 1;
				//d[i + 1][j + 1] = d[i][j]+s[i];
				//cout << d[i + 1][j + 1] << endl;
			}
			else {
				dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
				/*if (dp[i + 1][j + 1] == dp[i][j + 1]) {
					d[i + 1][j + 1] = d[i][j + 1];
				}
				else {
					d[i + 1][j + 1] = d[i + 1][j];
				}*/
				//cout << d[i + 1][j + 1] << endl;
			}
		}
	}
	string d;
	int x = n,y=m;

	while (x > 0 && y > 0) {
		/*if (s[x] == t[y]) {
			d += s[x-1];
			x--;
			y--;
		}
		else*/ if (dp[x][y] == dp[x - 1][y]) {
			x--;
		}
		else if(dp[x][y]==dp[x][y-1]){
			y--;
			}
		else {
			d += s[x - 1];
				x--;
				y--;
		}
	}
	reverse(d.begin(), d.end());
	cout << d << endl;
	//cout << dp[n][m] << endl;
}


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

int main() {
	int n;
	cin>>n;
	long long int a[n+1];
	for(int i=0;i<n+1;i++)
		a[i]=1;
		
	a[0] = 0;
	
	for(int i=2;i<n+1;i++) {
		for(int j=i;j<n+1;j+=i) {
			a[j]+=1;
		}
	}
	
	long long int res=0;
	
	for(int i=1;i<n+1;i++) {
		res+= i*a[i];
	}
	
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 81760
#include <iostream>
#include<cstdio>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<cstring>

using namespace std;

int a[100005],fa[100005],vis[100005],mi[100005];
priority_queue<pair<int,int>, vector<pair<int,int> >, greater<pair<int,int> > >q;

int _find(int x)
{
    return fa[x]==x?x:fa[x]=_find(fa[x]);
}

void _merge(int x,int y)
{
    int fx=_find(x),fy=_find(y);
    if(fx!=fy)
    {
        fa[fx]=fy;
    }
}
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++)
	{
	    scanf("%d",&a[i]);
	    fa[i]=i;
	    mi[i]=1e9+9;
	}
	int x,y;
	for(int i=0;i<m;i++)
    {
        scanf("%d %d",&x,&y);
        _merge(x,y);
    }
	for(int i=0;i<n;i++)
        _find(i);
    pair<int,int>tt;
	for(int i=0;i<n;i++)
	{
	    mi[fa[i]]=min(a[i],mi[fa[i]]);

	    tt.first=a[i];
	    tt.second=fa[i];
	    q.push(tt);
	}
	sort(fa,fa+n);
	int cnt=unique(fa,fa+n)-fa;
	if(cnt==1)
        printf("0\n");
    else
    {
        long long ans=0;
        for(int i=0;i<cnt;i++)
            ans+=mi[fa[i]];
        while(!q.empty())
        {
            if(cnt==2)
                break;
            pair<int,int>tmp;
            tmp=q.top();
            q.pop();
            if(vis[tmp.second]==0)
            {
                vis[tmp.second]=1;
                continue;
            }
            ans+=tmp.first;
            cnt--;
        }
        if(cnt==2)
            printf("%lld\n",ans);
        else
            printf("Impossible\n");
    }
    return 0;
}


Measured memory_bytes: 2680
#include <bits/stdc++.h>
using namespace std;
#define ll	    long long
#define vi      vector <ll>
#define vii     vector <pair<int,int>>
#define ii      pair<int,int>
#define loop(n)	for(int i=0;i<n;i++)
#define pb      push_back
const ll mod=1e9+7;
void fast();

int main()
{
    string s;
    cin>>s;
    int n=s.size(),z=1;
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n-i-1])
            z=0;
    }
    for(int i=0;i<((n-1)/2)/2;i++){
        if(s[i]!=s[(n-1)/2-i-1])
            z=0;
    }
    for(int i=(n+3)/2-1;i<n/2;i++)
        if(s[i]!=s[(n-i-1)])
            z=0;
    if(z)
        cout<<"Yes";
    else
        cout<<"No";
}

void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
/*

*/


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
using namespace std;
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
 
int main() {
    ll N,M;
    cin >> N >> M;
    ll time = 1;
    ll one = M * 1900 + (N - M) * 100;
    rep(i,M)time *= 2;
    cout << time * one << endl;
}
    
  

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

int main() {
    int h,w; cin >> h >> w;
    vector<string> c(h+2);
    string s = "";
    for(int i = 0; i < w+2; i ++) s += '.';
    c[0] = s;
    c[h+1] = s;
    for(int i = 1; i <= h; i ++) {
        string S; cin >> S;
        c[i] = '.' + S + '.';
    }
    for(int i = 1; i <= h; i ++) {
        for(int j = 1; j <= w; j ++) {
            int count = 0;
            if(c[i][j]=='.') {
                if(c[i-1][j-1]=='#') count++;
                if(c[i-1][j]=='#') count++;
                if(c[i-1][j+1]=='#') count++;
                if(c[i][j-1]=='#') count++;
                if(c[i][j+1]=='#') count++;
                if(c[i+1][j-1]=='#') count++;
                if(c[i+1][j]=='#') count++;
                if(c[i+1][j+1]=='#') count++;
                cout << count;
            }
            else cout << c[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  char b;
  cin >> b;
  if(b == 'A') cout << 'T';

  if(b == 'T') cout << 'A';

  if(b == 'G') cout << 'C';

  if(b == 'C') cout << 'G';
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[])
{
	long int sum = 0;
	int cnt, a;

	scanf("%d", &cnt);
	int max = -1000000, min = 1000000;
	for (int i = 0; i < cnt; i++)
	{
		if(i == cnt-1){
			scanf("%d", &a);
		}else{
		scanf("%d ", &a);
		}
		if(max <= a){
			max = a;
		}
		if(min >= a){
			min = a;
		}
		sum += a;
	}
	printf("%d %d %ld\n",min,max,sum);
	return 0;
}



Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt(),temp=0;
		for(int i=1;i<=n;i+=2)
		{
			temp++;
		}
		System.out.printf("%.10f",(double)temp/n);
	}

}


Measured memory_bytes: 23764
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int n, m, a[100005];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	int mn = 1e9 + 7;
	int mx = 0, cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (mn < a[i]) {
			int t = a[i] - mn;
			if (t > mx) {
				mx = t;
				cnt = 1;	
			} else if (t == mx) cnt++;
		}
		mn = min(mn, a[i]);
	}
	printf("%d\n", cnt);
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> b(n, 0);
    for ( ll i = a.size(); i >= 1; --i ) {
        ll tmp_num = i;
        int sum = 0;
        while(1) {
            if ( tmp_num > n ) {
                break;
            }
            sum += b[tmp_num-1];
            if ( i == 1 ) {
                tmp_num += 1LL;
            }
            else {
                tmp_num += i;
            }
        }
        if ( ( sum & 1 ) ^ ( a[i-1] ) ) {
            b[i-1] = 1;
        }
        else {
            b[i-1] = 0;
        }
    }
    int num = 0;
    rep(i, b.size()) {
        if ( b[i] == 1 ) ++num;
    }
    cout << num << endl;
    if ( num == 0 ) {
        return 0;
    }
    rep(i, n) {
        if ( b[i] ) {
            if ( i != 0 ) {
                cout << " ";
            }
            cout << i + 1;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2432
/*
 * b.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++) {
    if (i) putchar(' ');
    printf("%d", (i < n / 2 + 1) ? 0 : m);
  }
  putchar('\n');
  return 0;
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() 
{
  string N;
  cin >>N;
  string y="Yes";
  string n="No";
  
  rep(i, N.size()){
    
  if(i%2==0){
  if(N[i]!='L')
  {}
    else{
    cout << n << endl;
      return 0;
    }
  }
    
  else{
  if(N[i]!='R')
  {}
    else{
    cout << n << endl;
      return 0;
    }
  }
  }
    cout << y << endl;
}

Measured memory_bytes: 256
n,m,x = map(int,input().split())
ca = [list(map(int,input().split())) for i in range(n)]
ans = 100000000
for bit in range(1 << n):
    tmp_ca = [0] * (m+1)
    for j in range(n):
        if bit & (1 << j):
            for k in range(m+1):
                tmp_ca[k] += ca[j][k]
        tmp = 0
        for k in range(1,m+1):
            if tmp_ca[k] < x:
                tmp += 1
        if tmp == 0:
            ans = min(ans,tmp_ca[0])
if ans == 100000000:
    print(-1)
else:
    print(ans)


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int main() {
    int M, N;
    int A[100005];
    int cnt = 0;
    cin >> M >> N;
    for (int i = 0; i < N; i++) { cin >> A[i]; A[i]--; }

    if (M == 2) {
        for (int i = 0; i < N; i++) {
            if (i % 2 == A[i]) cnt++;
        }
        cout << min(cnt, N - cnt) << endl;
        return (0);
    }

    for (int i = 0; i < N; i++) {
        if (i > 0 && A[i] == A[i - 1]) {
            A[i] = N;
            cnt++;
        }
    }
    cout << cnt << endl;

    return (0);
}



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

int main(){
    int N,M,X;
    cin>>N>>M>>X;
    int A[100];
    int r=0,l=0;
    for(int i=0;i<M;i++){
        cin>>A[i];
        if(X>A[i]) r++;
        else l++;
    }
    cout<<static_cast<int>(min(r,l))<<endl;
    return 0;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    int n;
    cin >> n;
    int a[n];
    for (i = 0; i < n; i++) cin >> a[i];
    int x = 0;
    for (i = 0; i < n; i++) x ^= a[i];
    for (i = 0; i < n; i++) {
        cout << (x ^ a[i]) << " ";
    }
    cout << endl;
}

Measured memory_bytes: 4384
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

vector<bool> used(50,false);
mat G(50,vec(0));
void bridge(ll a, ll b, ll to){
    if(a < b) swap(a,b);
    used[to] = true;
    for(ll next : G[to]){
        if((a != max(to,next)) || (b != min(to,next))){
            if(!used[next]) bridge(a,b,next);
        }
    }
}

int main() {
    cin>>N>>M;
    rep(i,M){
        cin>>A>>B;
        --A; --B;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    ll ans = 0;
    rep(i,N){
        for(ll j : G[i]){
            bridge(i,j,i);
            ans += 1 - used[j];
            rep(k,50) used[k] = false;
        }
    }
    ans /= 2;
    cout<<ans<<endl;
}

Measured memory_bytes: 256