akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define aint(v) v.begin(),v.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define ump gp_hash_table<int,int,custom_hash>
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
/*int **dp,in main function,int row,col;dp=new int*[n];rep(i,n)dp[i]=new int[m]*/
//**** Maths Section*******/
int power(int x,int y);
bool isPrime(int n);
int modInv(int a,int b);
int gcdExtended(int a,int b,int *x,int* y);
int mpower(int a,int b,int p);
/***************************/
int32_t main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  fastio
  int a;
  cin>>a;
  if(a>=30)
    cout<<"Yes\n";
  else cout<<"No\n";

  return 0;
}

int modInv(int a, int m)
{
int x, y;
int g = gcdExtended(a, m, &x, &y);
int res = (x%m + m) % m;
return res;
}

int gcdExtended(int a, int b, int *x, int *y)
{
if (a == 0){
    *x = 0, *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtended(b%a, a, &x1, &y1);
  *x = y1 - (b/a) * x1;
  *y = x1;
  return gcd;
}

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

bool isPrime(int n)
{
if (n <= 1)  return false;
  if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
      int p=sqrt(n);
      for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
          return false;
      return true;
}


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

int main()
{
  int a,b,sum,digit;
  while(cin >> a >> b){
    digit = 0;
    sum = a + b;
    while(sum > 0){
      sum /= 10;
      digit += 1;
    }
    cout << digit << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359
/*
int main(){
    iostream::sync_with_stdio(false);
    
    int D;
    cin >> D;
    if(D == 22) cout << "Christmas Eve Eve Eve" << endl;
    if(D == 23) cout << "Christmas Eve Eve" << endl;
    if(D == 24) cout << "Christmas Eve" << endl;
    if(D == 25) cout << "Christmas" << endl;
    
    return 0;
}*/

/*
int main(){
    iostream::sync_with_stdio(false);
    
    int N;
    cin >> N;
    int sum = 0;
    int m = 0;
    for(int i=0; i<N; i++){
        int tmp;
        cin >> tmp;
        sum += tmp;
        m = max(m, tmp);
    }
    cout << sum - m/2 << endl;
    
    return 0;
}*/

/*
int main(){
    iostream::sync_with_stdio(false);
    
    int N,K;
    cin >> N >> K;
    int p[100000];
    for(int i=0; i<N; i++) cin >> p[i];
    sort(p, p+N);
    int ans = INT_MAX;
    for(int i=0; i+K-1<N; i++){
        ans = min(ans, p[i+K-1]-p[i]);
    }
    cout << ans << endl;
    return 0;
}
*/

LL s[51],p[51];
LL solve(int now, LL place){
    if(place < 1) return 0;
    if(place >= s[now]) return p[now];
    return solve(now-1, place-1) + solve(0, place-1-s[now-1]) + solve(now-1, place-1-s[now-1]-s[0]);
}

int main(){
    iostream::sync_with_stdio(false);
    
    LL N,X;
    cin >> N >> X;
    s[0] = 1;
    p[0] = 1;
    for(int i=1; i<=N; i++){
        s[i] = 2*s[i-1] + 3;
        p[i] = 2*p[i-1] + 1;
    }
    cout << solve(N,X) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <set>
#include <cstdlib>
#include <vector>
#include <map>
#include <cstring>
using namespace std;
const int maxn=2e6+100;
const long long mod=1e12+7;
long long ans,l1,l2,len1,len2,ty,z,n,m,k,t,x,y;
set<long long>s;char c[maxn];bool le;char tt;
long long h[maxn];
int main()
{
  //  freopen("x.in","r",stdin);
  //  freopen("x.out","w",stdout);
  scanf("%s",c);
  k=strlen(c);
  ans=k;
  for(long long i=1;i<k;++i)
  {
      if(c[i]!=c[i-1])
      ans=min(ans,max(i,k-i));
  }
  printf("%d\n",ans);
  //  fclose(stdin);
   // fclose(stdout);
    return 0;
}


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

int main() {
	int n;

	while (cin >> n) {
		if (n == 0) break;
		vector<int> array(n);
		for (int i = 0; i < n; i++) {
			cin >> array.at(i);
		}

		long max = array.at(0);
		for (int j = 0; j < n; j++) {
			long total = 0;
			for (int k = 0; k < n - j; k++) {
				total += array.at(j + k);
				if (total > max) max = total;
			}
		}

		cout << max << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
import java.util.LinkedList;
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int N=in.nextInt();
			int A=in.nextInt(),B=in.nextInt(),C=in.nextInt();
			int X=in.nextInt();
			int f=0;
			if((N|A|B|C|X)==0)
				return;
			LinkedList<Integer> Li=new LinkedList<Integer>();
			for(int i=0;i<N;i++)
				Li.add(in.nextInt());
			for(;;)
			{
				if(Li.get(0)==X)
					Li.remove(0);
				if(Li.isEmpty())
					break;
				X=(A*X+B)%C;
				f++;
				if(f>10000)
					break;
			}
			System.out.println(f>10000 ? -1:f);
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
    int a,s=100000;
    cin>>a;
    for(int i=0;i<a;i++){
        s=s*1.05;
        if(s%1000!=0){
            s=1000*(s/1000+1);
        }
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 2976
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a+1):
  for j in range(b+1):
    d = x - 500 * i - 100 * j
    if 0 <= d <= c * 50:
      ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 100002;

int n, fact[N], inv[N], mod = 1e9 + 7;
vector <int> a;

int powlog(int a, int b){
    if(b == 0) return 1;
    int ret = powlog(a, b / 2);
    if(b % 2) return 1LL * ret * ret % mod * a % mod;
    return 1LL * ret * ret % mod;
}
int C(int n, int r){
    if(r > n) return 0;
    return 1LL * fact[n] * inv[n - r] % mod * inv[r] % mod;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    fact[0] = 1;
    for(int i = 1 ; i < N ; i++){
        fact[i] = 1LL * i * fact[i - 1] % mod;
    }
    inv[N - 1] = powlog(fact[N - 1], mod - 2);
    for(int i = N - 2 ; i >= 0 ; i--){
        inv[i] = 1LL * (i + 1) * inv[i + 1] % mod;
    }
    cin >> n;
    n++;
    a.resize(n);
    for(auto &i : a){
        cin >> i;
        i--;
    }
    vector <int> las(n, -1);
    int f = -1;
    for(int i = 0 ; i < n ; i++){
        if(las[a[i]] != -1){
            f = n - i - 1;
            f += las[a[i]];
            break;
        }
        las[a[i]] = i;
    }
    for(int k = 1 ; k <= n ; k++){
        cout << (C(n, k) - C(f, k - 1) + mod) % mod << "\n";
    }
}


Measured memory_bytes: 4704
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

void _main() {
  ll N, P;
  cin >> N >> P;

  unordered_map<ll,ll> mp;
  for (ll i=2; i*i<=P; i++) {
    while (0==P%i) {
      mp[i]++;
      P /= i;
    }
  }
  if (1!=P) mp[P]++;

  ll ans=1;
  fore(i, mp) {
    ll a=i.second/N;
    for (ll j=0; j<a; j++) ans*=i.first;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void fl()
{
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
int main()
{
//    fl();
	long long n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	long long cha=b-a;
	if(cha%2==0)
		printf("%lld\n",cha/2);
	else if(cha%2==1)
		printf("%lld\n",min(n-b+1+(cha-1)/2,a+(cha-1)/2));
	return 0;
}


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

typedef long long ll;

int main() {

    string s;
    long long a, b;
    cin >> a >> s;

    ll x = (ll)(s[0]-'0');
    ll y = (ll)(s[2]-'0');
    ll z = (ll)(s[3]-'0');

    b = 100*x + 10*y + z;

    cout << (a*b)/100;

    return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int h, w;
        h = sc.nextInt();
        w = sc.nextInt();
        char mass[][] = new char[h][w];
        for(int i = 0; i < h; i++){
            mass[i] = sc.next().toCharArray();
        }
        
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(mass[i][j] == '.'){
                    mass[i][j] = '0';
                }
            }
        }
        
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if( mass[i][j] == '#'){
                    for(int k = i - 1; k < i + 2; k++){
                        for(int l = j - 1; l < j + 2; l++){
                            if( k != -1 && k != h && l != -1 && l != w){
                                if(mass[k][l] != '#'){
                                    int num = (int) mass[k][l];
                                    mass[k][l] = (char) (num + 1);
                                }
                            }
                        }
                    }
                }
                
            }
        }
        
        for(int i = 0; i < h; i++){
            System.out.println(mass[i]);
        }
    }
    
}


Measured memory_bytes: 22612
/*
█████████████.....██████....██.........█....██████████....██.........██.
██.........██.......██......█.█........█....██......██.....██.......██..
██.........██.......██......█..█.......█....██......██......██.....██...
██.........██.......██......█...█......█....██......██.......██...██....
██.........██.......██......█....█.....█....██......██........██.██.....
██.........██.......██......█.....█....█....██......██.........███......
█████████████.......██......█.....█....█....██████████.........███......
██..................██......█......█...█....██......██.........███......
██..................██......█......█...█....██......██.........███......
██..................██......█.......█..█....██......██.........███......
██..................██......█.......█..█....██......██.........███......
██..................██......█........█.█....██......██.........███......
██..................██......█........█.█....██......██.........███......
██................██████....█.........██....██......██.........███......
ЗАПУСКАЕМ
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░
 */

#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <map>
#include <queue>
#include <random>
#define DEBUG
#define pqueue priority_queue
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define int long long
#define  mk(a, b) make_pair(a, b)
//#define x first;
//#define y second;

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
typedef tuple<int, int, int> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<int> > vvi;
typedef vector<char> vc;

const int INF = 1e9;
const ll INFLL = 1e12;
const int MOD = 1000000007;
const ld eps = 1e-6;
const int MOD2 = (1<<30)+1;
const int dosz = 5e5;

void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef DEBUG
//    freopen("a.in", "r", stdin);
#else
    //    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif
}

//map<int, int> kek;

void solve(){
    string s, t;
    cin >> s >> t;
    cout << t+s;
}

signed main() {
    int q = 1;
//    cin >> q;
    while(q--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int i,k,x;
  cin >> k >> x;
  for(i=x-k+1;i<=k+x-1;i++){
    if(i==x-k+1){
      printf("%d",i);
    }
    else{
      printf(" %d",i);
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;

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

  ll a, b, x;
  cin >> a >> b >> x;

  cout << (b / x) - (a + x - 1) / x + 1 << "\n";
}


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

int main()
{
    int n;
    int v[20], c[20];
    cin >> n;
    rep(i, n) {
        cin >> v[i];
    }
    rep(i, n) {
        cin >> c[i];
    }

    int res = 0;
    for (int bit = 0; bit < (1 << n); ++bit) {
        int x = 0, y = 0;
        for (int i = 0; i < n; i++) {
            if (bit & (1 << i)) {
                x += v[i];
                y += c[i];
            }
        }
        res = max(res, x - y);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(std::string b){
    if(b == "A"){
        cout << "T" << endl;
    }
    if(b == "T"){
        cout << "A" << endl;
    }
    if(b == "G"){
        cout << "C" << endl;
    }
    if(b == "C"){
        cout << "G" << endl;
    }
}

int main(){
    std::string b;
    std::cin >> b;
    solve(b);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <string>
#include <set>
#define MOD 1000000007

using namespace std;

int main() {
	int N, D, X; cin >> N >> D >> X;
	for (int i = 0; i < N; i++) {
		int x; cin >> x;
		int d = 1;
		while (d <= D) {
			X += 1;
			d += x;
		}
	}
	cout << X << endl;
}

Measured memory_bytes: 256
from math import ceil
def numdiv(n):
    c=0
    k=int((n)**0.5)
    for i in range(1,k+1):
        if n%i==0:
            c+=2
    if k==ceil(n**0.5):
        return c-1
    return c

c=0
n=int(input())
for i in range(3,n+1,2):
    if numdiv(i)==8:
        c+=1


print(c)

Measured memory_bytes: 62756
#include<stdio.h>

int main(){
  int N;
  int PAY;
  int count = 0;

  scanf("%d",&N);
  PAY = N;

  while( N >= 15){
      count++;
      N = N - 15;
  }
  //printf(" %d",N);
  //printf(" %d",count);
  printf("%d",((PAY*800)-(count*200)));
  return 0;
}


Measured memory_bytes: 128
h,w = [int(i) for i in input().split()]
s = []
for i in range(h):
  array = list(input())
  s.append(array)
d = [[float("inf")] * (w) for i in range(h)]
d[0][0]=0
if s[0][0]=='#':
  d[0][0]=1
for i in range(1,w):
  if s[0][i]!=s[0][i-1] and s[0][i]!=s[0][0]:
    d[0][i]=d[0][i-1]+1
  else:
    d[0][i]=d[0][i-1]
for i in range(1,h):
  for j in range(w):
    k=0
    u=0
    if j != 0 :
      if s[i][j]=="#" and s[i][j]!=s[i-1][j]:
        k=1
      if s[i][j]=="#" and s[i][j]!=s[i][j-1]:
        u=1
      d[i][j] = min(d[i-1][j]+k,d[i][j-1]+u)
    elif j == 0 :
      if s[i][0]=="#" and s[i][0]!=s[i-1][0]:
        k=1
      d[i][0] = d[i-1][0]+k

print(d[h-1][w-1])

Measured memory_bytes: 43120
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,i,j;
    while(~scanf("%d",&a))
    {
        if(a%2==0)
        {
            printf("%d\n",a);
        }
        else
        {
            printf("%d\n",2*a);
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
const int N = 1e6 + 10;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
     int n,k;cin >> n >> k;
     vector<int>a(n);
     int cnt = 0;
     int sum = 0;
     for(int i = 0;i<n;i++){
        cin >> a[i];
        if(a[i]>0) sum += a[i];
        if(a[i]<0) cnt++;
     }
    if(k>=n+cnt){
        cout << sum;
        return;
    }
    vector<int>l(220,0);
    multiset<int>ms;
    l[0] = 0;int now = 0;
    for(int i = 0;i<k;i++){
        int cnt = 0;sum = 0;
        now += a[i];
        ms.insert(a[i]);
        l[i+1] = max(l[i+1],max(l[i],now));
        for(auto it : ms){
            if(it<0) {cnt++;sum += it;l[i+cnt+1] = max(now-sum,l[i+cnt+1]);}
            else break;
        }
       // cout << l[i+1] <<endl;
    }
    ms.clear();
    vector<int>r(220,0);
    r[0] = 0;
    reverse(a.begin(),a.end());
    now = 0;
    for(int i = 0;i<k;i++){
        int cnt = 0;sum = 0;
        now += a[i];
        ms.insert(a[i]);
        r[i+1] = max(r[i+1],max(r[i],now));
        for(auto it : ms){
            if(it<0) {cnt++;sum += it;r[i+cnt+1] = max(r[i+cnt+1],now-sum);}
            else break;
        }
    }
    int ans = 0;
    for(int i = 0;i<=k;i++){
        ans = max(ans,r[i]+l[k-i]);
    }
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int X;cin>>X;
  cout<<X + X*X + X*X*X<<endl;
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3692
import java.util.Scanner;

public class Main {

	public static int cnt;

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int[] A = new int[n];

		for (int i = 0; i < n; i++) {
			A[i] = sc.nextInt();
		}

		mergeSort(A, 0, n);

		for (int i = 0; i < n - 1; i++) {
			System.out.print(A[i]);
			System.out.print(" ");
		}
		System.out.println(A[n - 1]);
		System.out.println(cnt);

	}

	public static void marge(int[] A, int left, int mid, int right) {
		int n1 = mid - left;
		int n2 = right - mid;

		int[] L = new int[n1 + 1];
		int[] R = new int[n2 + 1];

		for (int i = 0; i < n1; i++) {
			L[i] = A[left + i];
		}
		for (int i = 0; i < n2; i++) {
			R[i] = A[mid + i];
		}

		L[n1] = Integer.MAX_VALUE;
		R[n2] = Integer.MAX_VALUE;

		int i = 0;
		int j = 0;
		for (int k = left; k < right; k++) {
			cnt++;
			if (L[i] <= R[j]) {
				A[k] = L[i];
				i++;
			} else {
				A[k] = R[j];
				j++;
			}

		}
	}

	public static void mergeSort(int[] A, int left, int right) {
		if (left + 1 < right) {
			int mid = (left + right) / 2;
			mergeSort(A, left, mid);
			mergeSort(A, mid, right);
			marge(A, left, mid, right);
		}
	}

}

Measured memory_bytes: 170216
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < b; ++i)

main() {
	int n;
	cin >> n;
	set <string> s;
	rep(i, 0, n) {
		string t;
		cin >> t;
		s.insert(t);
	}
	cout << s.size() << endl;
}

Measured memory_bytes: 19096
n = int(input())
h = list(map(int, input().split()))
dp = [0]*n
dp[1] = abs(h[1]-h[0])
for i in range(2, n):
    dp[i] = min((dp[i-1] + abs(h[i]-h[i-1])), (dp[i-2] + abs(h[i]-h[i-2])))
print(dp[n-1])

Measured memory_bytes: 13908
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define coutif(a,b,c) cout<<(a?b:c)
#define all(x) (x).begin(), (x).end()
#define uint usigned int
typedef vector <ll> vi;
ll MOD = 1e9+7;
ll l[1000111];
//vi v1[200005],v2;
//bool visit[200005]={false};
/*void bfs(ll n){
    queue<ll> q;
    q.push(n);
    visit[n]=true;
    while(!q.empty()){
        ll t=q.front();
        q.pop();
        v2.pb(t);
        for(ll i=0;i<v1[t].size();i++){
            if(visit[v1[t][i]]==false){
                q.push(v1[t][i]);
                visit[v1[t][i]]=true;
            }
        }
    }
}*/
/*void dfs(ll n){
    for(ll i=0;i<v1[n].size();i++)
    {
        ll y=v1[n][i];
        if(visit[y]==0)
        {
            v2.pb(y);
            visit[y]=1;
            dfs(y);
        }
    }
}*/
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
    ll n,m,x=0,y=0,i,ans=0;
    string s;
    cin>>s;
    x=10*(s[0]-'0')+(s[1]-'0');
    y=10*(s[2]-'0')+(s[3]-'0');
	if(x<=12 && y<=12 &&x>0 && y>0){
	    cout<<"AMBIGUOUS";
	    return 0;
	}
	if(x<=12 && x>0 ){
	    cout<<"MMYY";
	    return 0;
	}
	if(y<=12 && y>0 ){
	    cout<<"YYMM";
	    return 0;
	}
	cout<<"NA";
	return 0;
}

Measured memory_bytes: 256
// I look at my watch
// it say nine twenty-five
// And I think oh God
// I'm still alive
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) int((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(int i = int(a); i < int(b); ++i)
#define roF(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
typedef long double ld;




int main(){	
	int n,m;cin>>n>>m;
	vector<int>vec(n);
	int sum=0;
	For(i,0,n){
		cin>>vec[i];
		sum+=vec[i];
	}
	sort(vec.rbegin(),vec.rend());
	ll val=(sum+4*m-1)/(4*m);
	For(i,0,m){
		if(vec[i]<val){
			cout<<"No"<<endl;
			return 0;
		}
	}	
	cout<<"Yes"<<endl;
	return 0;
}


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

int main() {
  long long n, a, b;
  cin >> n >> a >> b;
  long long A = (n - 1) * a + b;
  long long B = (n - 1) * b + a;
  cout << max((long long) 0, B - A + 1) << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int const mxn = 1e5+10;
long long dp1[mxn],dp2[mxn], mark[mxn];
vector <long long > adj[mxn];
int const mod=1e9+7;


void dfs(int v,int p){
	mark[v] = 1;
	for (auto u : adj[v]){
		if (!mark[u])
			dfs(u,v);
	}
	for (auto u : adj[v]){
		if (u!=p){
			dp1[v] *= ((dp2[u]+dp1[u]));
			dp1[v]%=mod;
			dp2[v] *= ((dp1[u]));
			dp2[v]%=mod;
		}
			
		
	}
}



int main(){
	int n;
	cin>>n;
	for (int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	fill(dp1,dp1+mxn,1);
	fill(dp2,dp2+mxn,1);
	dfs(1,0);
	cout<<(dp1[1]+dp2[1])%mod;
	
}

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

/**
 * Created by Ayushi on 11 Jul 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        StringTokenizer st;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        st = new StringTokenizer(br.readLine(), " ");
        int n = Integer.parseInt(st.nextToken());
        st = new StringTokenizer(br.readLine(), " ");
        int[] a = new int[n];
        int j = 0;
        int ans = 0;
        while (st.hasMoreTokens()) {
            a[j] = Integer.parseInt(st.nextToken());
            if (j % 2 == 0 && a[j] % 2 == 1) {
                ans++;
            }
            j++;
        }
        System.out.println(ans);
        br.close();
    }
}


Measured memory_bytes: 32660
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include<cstdio>
#define MOD 1000000007
#define MOD2 1000000014000000049LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long long ll;

template<int N, int M>
struct ModFact {
    int inv[N+1];
    int fact[N+1];
    int ifact[N+1];
    constexpr ModFact() : fact(), ifact() {
        ll f = 1;
        fact[0] = f;
        for (int i = 0; i < N; i++) {
            f = f*(i+1)%M;
            fact[i+1] = f;
        }
        f = power(f, M-2);
        ifact[N] = f;
        for (int i = N-1; i >= 0; i--) {
            f = f*(i+1)%M;
            ifact[i] = f;
        }
        for (int i = 0; i < N; i++) {
            f = ll(fact[i])*ll(ifact[i+1])%M;
            inv[i] = f;
        }
    }
    constexpr ll power(ll a, ll b) {
        ll r = 1;
        while (b>0) {
            if((b&1)!=0) r = (r*a)%M;
            a = (a*a)%M;
            b >>= 1;
        }
        return r;
    }
	int operator[](int n) {
		return inv[n];
	}
};

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}

inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

ModFact<100000, MOD> fact;

int main() {
    ll ans = 0, d;
    int a, N, prev, now;
    N = getint();
    prev = getint();
    REP(i, N-1) {
        now = getint();
        d = now - prev;
        prev = now;
        a = (a + fact[i]) % MOD;
        ans += a * d % MOD;
        // a += fact.inv[i+1];
        // if(a > MOD) a -= MOD;
        // ans += a * d;
        // if(ans > MOD2) ans -= MOD2;
    }
    printf("%lld\n", ((ans%MOD)*fact.fact[N-1])%MOD);
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
using namespace std;
typedef long long ll;
ll n,a,b,ans;
int main(void){
    cin>>n>>a>>b;
    ans=min(max(n-a,n-b),max(a-1,b-1));
    if(abs(a-b)%2==0){
        ans=min(ans,abs(a-b)/2);
    }
    else{
        ans=min(a+(b-a)/2,ans);
        ans=min(ans,n-b+1+(b-a)/2);
    }
    cout<<ans<<endl;
}


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

int main() {
	int n, y;
	cin >> n >> y;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n - i; j++) {
			int k = n - i - j;
			if (i * 10000 + j * 5000 + k * 1000 == y) {
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}

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

int main() {
    int n, p[10010];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> p[i];

    sort(p, p + n, greater<int>());

    int sum = p[0] / 2;
    for (int i = 1; i < n; i++) sum += p[i];

    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
 
 
int N, M, Q;
int cnt[505][505];

void _main() {
    cin >> N >> M >> Q;
    rep(i, 0, M) {
        int L, R; cin >> L >> R;
        cnt[L][R]++;
    }
    rep(L, 1, N + 1) rep(R, 2, N + 1) cnt[L][R] += cnt[L][R - 1];
    rep(_, 0, Q) {
        int p, q; cin >> p >> q;
        int ans = 0;
        rep(L, p, q + 1) ans += cnt[L][q];
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {

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

        long x = k[0];
        long ans = Math.abs(x - y);
        for (int i = 1; i < n - 1; i++) {
            x += k[i];
            y -= k[i];
            ans = Math.min(ans, Math.abs(x - y));
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 64460
#include<bits/stdc++.h>
using namespace std;
#define cs const 
//#define int long long
#define low(i) (i&(-i))
#define mid ((l+r)>>1)
#define ls (now<<1)
#define rs (now<<1|1)
#define par pair<int,int>
#define mp make_pair
#define fr first 
#define se second
#define rep(i, x, y) for(int i=x; i<=y; ++i)
#define drep(i, x, y) for(int i=x; i>=y; --i)
#define fore(i, x) for(int i=fir[x]; i; i=nex[i])
cs int base = 233;
cs int ff = 2e6+1;
cs int mod = 998244353;
cs int inf = 1e9+1;
int n, k, a[ff]; 
int read(){
	int f=1,re=0;char ch;
	for(ch=getchar();!isdigit(ch)&&ch!='-';ch=getchar());
	if(ch=='-'){f=-1,ch=getchar();}
	for(;isdigit(ch);ch=getchar()) re=(re<<3)+(re<<1)+ch-'0';
	return re*f; 
}
int xs(int d) { return min(abs(d), abs(k - d)); }
void init()
{
	k=read(),n=read();
	rep(i, 1, n) a[i]=read();
	rep(i, 1, n) a[i+n] = a[i] + k;
	int ans = k;
	ans++,ans--;
//	rep(i, 1, n+n) cout << a[i] << " ";
	rep(i, 1, n)
		ans = min(ans, abs(a[i+n-1] - a[i])); cout << ans;
}
signed main()
{
	init();
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>

using namespace std;

const int INF=10000000;
int map[21][21];

int main(void){
	int a,b,c;
	int d[4];
	int ans;
	int n,m;
	for(a=0;a<=20;a++){
		for(b=0;b<=20;b++){
			map[b][a]=INF;
			if(b==a)map[b][a]=0;
		}
	}
	cin >> n;
	cin >> m;
	for(a=0;a<m;a++){
		scanf("%d,%d,%d,%d",&d[0],&d[1],&d[2],&d[3]);
		map[d[0]][d[1]]=d[2];
		map[d[1]][d[0]]=d[3];
	}
	for(a=1;a<=n;a++){
		for(b=1;b<=n;b++){
			for(c=1;c<=n;c++){
				map[c][b]=min(map[c][b],map[c][a]+map[a][b]);
			}
		}
	}
	scanf("%d,%d,%d,%d",&d[0],&d[1],&d[2],&d[3]);
	ans=d[2]-d[3]-map[d[0]][d[1]]-map[d[1]][d[0]];
	cout << ans <<endl;
	return 0;
}

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

// int minHori()

int solve(vector<vector<int>> field, int tate, int yoko) {
    int ret = 0;
    for (int i = 0; i <= field.size() - tate; i++) {
        for (int j = 0; j <= field[i].size() - yoko; j++) {
            // 堀の最小
            int minHori = 1000000007;
            for (int k = i; k < i + tate; k++) {
                minHori = min(field[k][j], minHori);
            }
            for (int k = i; k < i + tate; k++) {
                minHori = min(field[k][j + yoko - 1], minHori);
            }
            for (int l = j; l < j + yoko; l++) {
                minHori = min(field[i][l], minHori);
            }
            for (int l = j; l < j + yoko; l++) {
                minHori = min(field[i + tate - 1][l], minHori);
            }
            int poolWater = 0;
            // 内部の最大
            for (int k = i + 1; k < i + tate - 1; k++) {
                for (int l = j + 1; l < j + yoko - 1; l++) {
                    if (field[k][l] >= minHori) goto fackin;
                    // cout << "minHori" << minHori << "tate" << tate << "yoko" << yoko << "field"
                    //      << field[k][l] << endl;
                    poolWater += minHori - field[k][l];
                    // cout << poolWater << endl;
                }
            }
            ret = max(poolWater, ret);
        fackin:;
        }
    }
    return ret;
}

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

    int D, W;
    while (1) {
        cin >> D >> W;
        if (!D & !W) break;
        vector<vector<int>> field(D, vector<int>(W));
        for (int i = 0; i < D; i++) {
            for (int j = 0; j < W; j++) {
                cin >> field[i][j];
            }
        }
        int ans = 0;
        for (int i = 3; i <= D; i++) {
            for (int j = 3; j <= W; j++) {
                ans = max(solve(field, i, j), ans);
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3220
use proconio::*;

fn main() {
    input! {
        n: i32,
    }

    let mut v = vec![];
    for _ in 0..n {
        input! {
            x: i32,
        }

        v.push(x);
    }

    let mut p = vec![];
    for _ in 0..1000001 {
        p.push(0);
    }
    for i in 0..n as usize {
        p[v[i] as usize] += 1;
    }

    for i in 0..1000001 {
        if p[i] == 0 {
            continue;
        }

        for j in 2..1000001 {
            if i * j > 1000000 {
                break;
            }
            p[i * j] = 0;
        }
    }

    let ans: i32 = p.iter().map(|&x| if x == 1 {1} else {0}).sum();
    println!("{}", ans);
}

Measured memory_bytes: 8364
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (n, x, t) = (v[0], v[1], v[2]);
    let ans = ((n + x - 1) / x) * t;
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

using namespace std;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef pair<int,int> pii;
typedef long long ll;
#define debug(x) cout << #x << "=" << x << endl;
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); cout << (i>0 ? " ":"") << v[i++]); cout << "\n"; return os;}



int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi v(3);
    cin >> v;
    

    vector<string> cmd(n);
    cin  >> cmd;
    
    vector<char> ans;
    int i;
    for(i=0;i<n;i++){
        int ia = cmd[i][0] - 'A';
        int ib = cmd[i][1] - 'A';
        char ch;
        if(v[ia] > v[ib]){
            v[ib]++;
            v[ia]--;
            ch = cmd[i][1];
        }else if(v[ib] > v[ia]){
            v[ia]++;
            v[ib]--;
            ch = cmd[i][0];
        }else{
            if(i+1 < n && cmd[i+1].find(cmd[i][0]) != string::npos){
                v[ia]++;
                v[ib]--;
                ch = cmd[i][0];
            }else{
                v[ib]++;
                v[ia]--;
                ch = cmd[i][1];
            }
        }
        ans.push_back(ch);
        if((*min_element(all(v))) < 0) break;
    }
    
    if(i < n){
        cout << "No\n";
    }else{
        cout <<"Yes\n";
        for(i=0;i<n;i++) cout << ans[i] << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 6648
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST

main :: IO ()
main = do
  s <- getLine :: IO String
  t <- getLine :: IO String
  print $ solve s t

solve :: String -> String -> Int
solve s t = length . filter id . zipWith (==) s $ t

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

int main()
{
  int ans=0;
  string a,b;
  cin >> a >> b;
  if(a.at(0)==b.at(0)){++ans;}
  if(a.at(1)==b.at(1)){++ans;}
  if(a.at(2)==b.at(2)){++ans;}
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
from collections import deque

def process_command(dll, commands):
    # line_count = 1
    for cmd in commands:
        # print('processing line: {0}'.format(line_count))
        # line_count += 1
        # print(cmd)
        try:
            cmd, num_str = cmd.split()
        except ValueError:
            pass
        # if cmd.startswith('insert') or cmd.startswith('delete '):
        #     t = cmd.split(' ')
        #     cmd = t[0]
        #     num_str = t[1]
        if cmd == 'insert':
            dll.appendleft(int(num_str))
        elif cmd == 'delete':
            # deque.index() ????????¨??§???????????? python3.5??\???????????§???????????§??¢???
            if int(num_str) in dll:  # ?????????????????????????????¨???????????´?????????????????????????????????
                temp = []
                result = dll.popleft()
                while result != int(num_str):
                    temp.append(result)
                    result = dll.popleft()
                temp = temp[::-1]
                dll.extendleft(temp)
        elif cmd == 'deleteFirst':
            dll.popleft()
        elif cmd == 'deleteLast':
            dll.pop()
        # print(dll)
        # print('=' * 64)


if __name__ == '__main__':
    # ??????????????\???
    commands = []
    num = int(input())
    commands = [input() for i in range(num)]

    # ??????
    dll = deque()
    process_command(dll, commands)

    # ???????????????
    print('{0}'.format(' '.join(map(str, dll))))

Measured memory_bytes: 190680
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: i64,
        m: i64,
        a: [String; m],
    }
    let mut ans = n;
    for ai in a.iter() {
        ans = ans - ai.parse::<i64>().unwrap();
    }
    if ans < 0 {
        println!("-1")
    } else {
        println!("{:?}", ans)
    }
}


Measured memory_bytes: 2464
# include <cstdio>
# include <cstring>
# include <algorithm>
# include <string>
# include <iostream>
using namespace std;
int main()
{
	string a;
	cin>>a;
	string a1=a;
	reverse(a.begin(),a.end());
	for(int i=0;i<a.size();i++)
	{
		if(a[i]=='q') a[i]='p';
		else if(a[i]=='p') a[i]='q';
		else if(a[i]=='b') a[i]='d';
		else if(a[i]=='d') a[i]='b';
	}
	if(a==a1) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

using namespace std;

int main() {
  int N, X;
  cin >> N >> X;
  int minv = 1e9;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    X -= a;
    minv = min(minv, a);
  }
  cout << N + X / minv << endl;

  return 0;
}

Measured memory_bytes: 256
from collections import Counter
n, m = map(int, input().split())
x = list(map(int, input().split()))
mods = [0 for _ in range(m)]
pairs = [0 for _ in range(m)]
c = Counter()
for y in x:
	mods[y%m] += 1
	c[y] += 1
	if c[y]%2 == 0:
		pairs[y%m] += 1
#print(mods, pairs)
ans = 0
ans += mods[0]//2
if m%2 == 0:
	ans += mods[m//2]//2
for i in range(1, (m+1)//2):
	mi = min(mods[i], mods[m-i])
	ans += mi
	mods[i] -= mi
	mods[m-i] -= mi

for i in range(m):
	if i == 0 or 2*i == m:
		continue
	else:
		ans += min(pairs[i], mods[i]//2)

print(ans)

Measured memory_bytes: 21216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
#define mod 1000000007
vector<pair<int,int>> vp;
pair<int,int> pp;
vector<int> vv,vv1;
map<int,int> mp;
int mat[502][502];
ll dp[1003][1003];
bool visited[1000];
int main()
{
    ll row,col;
    cin>>row>>col;
    char x;
    memset(dp,-1,sizeof dp);
    for(int i=0; i<=row; i++){
        for(int j=0; j<=col; j++){
            if(i==0 || j==0) dp[i][j] = 0;
        }
    }
    dp[1][1] = 1;
    for(int i=1; i<=row; i++){
        for(int j=1; j<=col; j++){
           cin>>x;
           if(x=='#') dp[i][j] = 0;
        }
    }
    for(int i=1; i<=row; i++){
        for(int j=1; j<=col; j++){
                if(i== 1 and j==1) continue;
            if(dp[i][j]==-1 ){
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
            //cout<<dp[i-1][j]<<" "<<dp[i][j-1]<<" "<<i<<" "<<j<<" "<<dp[i][j]<<"\n";
            }
        }
    }
    cout<<dp[row][col]<<"\n";
}


Measured memory_bytes: 8448
#include <stdio.h>
#include <stdlib.h>

#define N	100000
#define MD	1000000007

int vv[N * 2 + 1], ff[N * 2 + 1];

void init() {
	int i;

	ff[0] = 1;
	for (i = 1; i <= N * 2; i++) {
		vv[i] = i == 1 ? 1 : (long long) vv[i - MD % i] * (MD / i + 1) % MD;
		ff[i] = (long long) ff[i - 1] * i % MD;
	}
}

int *oj[N * 2], oo[N * 2];

void link(int i, int j) {
	int o = oo[i]++;

	if (o >= 2 && (o & o - 1) == 0)
		oj[i] = (int *) realloc(oj[i], o * 2 * sizeof *oj[i]);
	oj[i][o] = j;
}

int ta[N * 2], pp[N * 2], qu[N * 2], cnt, qu_[N * 2], cnt_;

int dfs1(int p, int i) {
	static int time;
	int o;

	ta[i] = ++time, pp[i] = p, qu[cnt++] = i;
	for (o = 0; o < oo[i]; o++) {
		int j = oj[i][o];

		if (j != p) {
			if (!ta[j]) {
				if (!dfs1(i, j))
					return 0;
			} else if (ta[j] < ta[i]) {
				int i_;

				if (cnt_ != 0)
					return 0;
				cnt_ = 0;
				for (i_ = j; i_ != -1; i_ = pp[i_])
					qu_[cnt_++] = i_;
				while (--cnt_)
					pp[qu_[cnt_]] = qu_[cnt_ - 1];
				pp[j] = i;
				for (i_ = i; i_ != j; i_ = pp[i_])
					qu_[cnt_++] = i_;
				qu_[cnt_++] = j;
			}
		}
	}
	return 1;
}

char visited[N * 2]; int sz[N * 2];

void dfs2(int i) {
	int o;

	if (visited[i])
		return;
	visited[i] = 1;
	sz[i] = 1;
	for (o = 0; o < oo[i]; o++) {
		int j = oj[i][o];

		if (j < pp[i]) {
			dfs2(j);
			sz[i] += sz[j];
		}
	}
}

int solve() {
	int h, x;

	for (h = 0; h < cnt; h++)
		visited[qu[h]] = 0;
	for (h = 0; h < cnt; h++)
		if (!visited[qu[h]])
			dfs2(qu[h]);
	x = 1;
	for (h = 0; h < cnt; h++)
		x = (long long) x * vv[sz[qu[h]]] % MD;
	return x;
}

int main() {
	int n, h, i, j, ans;

	init();
	scanf("%d", &n);
	for (i = 0; i < n * 2; i++)
		oj[i] = (int *) malloc(2 * sizeof *oj[i]);
	for (h = 0; h < n * 2; h++) {
		scanf("%d%d", &i, &j), i--, j--;
		link(i, n + j), link(n + j, i);
	}
	ans = ff[n * 2];
	for (i = 0; i < n * 2; i++)
		if (!ta[i]) {
			int x, y;

			cnt = 0, cnt_ = 0;
			if (!dfs1(-1, i) || cnt_ == 0) {
				printf("0\n");
				return 0;
			}
			x = solve();
			for (h = 0; h < cnt_; h++)
				pp[qu_[h]] = qu_[(h - 1 + cnt_) % cnt_];
			y = solve();
			ans = (long long) ans * (x + y) % MD;
		}
	printf("%d\n", ans);
	return 0;
}


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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
 
const ll MAX = 1e6 + 3;
const ll inf = 1e18;
const ll mod = 1e9 + 7;


vii c;

ll bp(ll a,ll e){
    if(e == 0) return 1;
    if(e&1) return (a*bp(a,e-1))%mod;
    ll x = bp(a,e>>1);
    return (x*x)%mod;
}

ll inv(ll a){
    return bp(a,mod-2);
}

ll mul(ll a,ll b){
    return (a*b)%mod;
}
int main(){
    fastio;
    ll n,x,y;
    string s;
    cin >> x >> y;
    ll a = x -(x+y)/3, b = y - (x+y) /3;
    if( (x+y)%3 != 0 || a<0 || b<0) cout << "0\n";
    else{
        ll ans = 1;
        f(i,1,a+1) ans = mul(ans,mul(a+b+1-i,inv(i)));
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3664