akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 30000;
const int K = 100000;
const int mod = 1e9 + 7;
int dp[N], f[N], invf[N], n;
vector <int> a;
int binpow(int x, int y){
    int res = 1;
    while(y){
        if (y % 2) res = res * x % mod;
        y /= 2;
        x = x * x % mod;
    }
    return res;
}
int c(int n){
    return f[n + n] * invf[n + 1] % mod * invf[n] % mod;
}
vector <int> bp(vector <int> b, int x){
    if (x == 1) return b;
    vector <int> res(n);
    if (x % 2 == 1){
        vector <int> c = bp(b, x - 1);
        for (int i = 0; i < n; i++){
            for (int j = 0; j <= i; j++){
                res[i] = (res[i] + c[j] * b[i - j]) % mod;
            }
        }
        return res;
    } else{
        for (int i = 0; i < n; i++){
            for (int j = 0; j <= i; j++){
                res[i] = (res[i] + b[j] * b[i - j]) % mod;
            }
        }
        return bp(res, x / 2);
    }
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    string s;
    cin >> s;
    int m = s.length();
    f[0] = invf[0] = 1;
    for (int i = 1; i <= 2 * n; i++) f[i] = f[i - 1] * i % mod;
    for (int i = 1; i <= 2 * n; i++) invf[i] = binpow(f[i], mod - 2);
    dp[0] = 1;
    for (int i = 1; i <= n; i++){
        dp[i] = dp[i - 1];
        for (int j = 1; 2 * j <= i; j++){
            dp[i] = (dp[i] + dp[i - 2 * j] * binpow(2, j) % mod * c(j - 1)) % mod;
        }
    }
 //   for (int i = 0; i <= n + m; i++) cout << dp[i] << " ";
 //   cout << endl;
    for (int i = 0; i < n; i++) a.pb(binpow(2, i) * c(i) % mod);
    a = bp(a, m);
  //  for (int i = 0; i < n; i++) cout << a[i] << " ";
    int ans = 0;
    for (int i = 0; i <= n - m; i++){
        if ((n - i - m) % 2) continue;
        ans = (ans + dp[i] * a[(n - i - m) / 2]) % mod;
    }
    cout << ans;
}


Measured memory_bytes: 5036
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    int n,p;cin >> n;cin >> p;
    string s;cin >> s;
    LL ans = 0;
    if(p == 2 || p == 5){
        int dp[n+1][p];
        memset(dp,0,sizeof(dp));
        for (int i = 0; i < n; i++) {
            dp[i+1][(s[i]-'0')%p]++;
            for (int k = 0; k < p; k++) {
                int nx=(p + 10 * k + s[i]-'0')%p;
                dp[i+1][nx]+=dp[i][k];
            }
            ans+=dp[i+1][0];
        }
    }
    else{
        map<LL,LL> ma;
        int now = 0;
        ma[0]++;
        vector<LL> t(n+1,1);
        for (int i = 0; i < n; i++) {
            t[i+1] = t[i] * 10 % p;
        }
        for (int i = n-1; i >= 0; i--) {
            now = (now + t[n-1-i] * (s[i] - '0'))%p;
            ans += ma[now]++;
        }
    }
    cout<< ans << endl;
    return 0;
}


Measured memory_bytes: 4484
#include <stdio.h>
int main(void){
    // Your code here!
    int n;
    scanf("%d",&n);
    
    int s1=0;
    int s2=0;
    int now=0;
    int nut=1;
    int count=0;
    
    for(int i=0;i<n;i++){
        scanf("%d",&s1);
        
        if(i==0){
            
        }else if(nut==1){
            if(s1==s2){
                
            }else if(s1>s2){
                nut=0;
                now=1;
            }else if(s1<s2){
                nut=0;
                now=-1;
            }
        }else{
            if((s1-s2)*now>=0){
                
            }else if((s1-s2)*now<0){
                count++;
                nut=1;
            }
        }
        s2=s1;
    }
    printf("%d\n",count+1);
}

Measured memory_bytes: 1704
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>

using namespace std;

void countdown(vector<int> &r, int k, int n, int &z) {
    if(r[z] > 0){
        --r[z];
    } else {
        --r[z-1];
        r[z] = k;
        if(r[z-1]==0) --z;
        else z = n-1;
    }
    //if (r[z] == 0) {
    //    r[z] = k;
    //    z--;
    //    r[z]--;
    //    if (r[z] != 0) {
    //        z = n-1;
    //    }
    //} else {
    //    r[z]--;
    //}
    return;
}

void solve(int k, int n) {
    if (k%2 == 0) {
        std::cout << k/2;
        for (int i = 0; i < n-1; i++) {
            std::cout << " " << k;
        }
        std::cout << std::endl;
        return;
    }
    vector<int> ret(n, (k+1)/2);
    int z = n-1;
    for (int i = 0; i < n/2; i++) {
        countdown(ret, k, n, z);
    }
    std::cout << ret[0];
    for (int i = 1; i < ret.size(); i++) {
        if (ret[i] == 0) {
            break;
        }
        std::cout << " " << ret[i];
    }
    std::cout << std::endl;
}

int main() {
    struct timeval start,end;
    long long span;
    int k, n;

    gettimeofday(&start,NULL);

    std::cin >> k >> n;
    solve(k, n);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 3456
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		long m = 1000000007L;

		long answer = 0L;
		for (int i = 0; i < 61; i++) {
			long d = (1L << i);
			long count = 0;
			for (int j = 0; j < a.length; j++) {
				if ((d & a[j]) > 0L) {
					count++;
				}
			}
			long t = (count * (n - count)) % m;
			answer += ((d % m) * t % m);
			answer %= m;
		}

		System.out.println(answer);
	}
}


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

int n;
vector<vector<int>> g;

vector<int> now, sz;

bool findta(int v, int u, int p = -1) {
    now.push_back(v);
    if (v == u) return true;
    for (int to : g[v]) {
        if (to == p) continue;
        if (findta(to, u, v)) return true;
    }
    now.pop_back();
    return false;
}

int cntsz(int v, int p) {
    sz[v] = 1;
    for (int to : g[v]) {
        if (to != p) {
            sz[v] = max(sz[v], 1 + cntsz(to, v));
        }
    }
    return sz[v];
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    g.resize(n);
    sz.resize(n);
    int ao, ta;
    cin >> ta >> ao;
    if (ao == ta) {
        cout << 0 << endl;
        return 0;
    }
    --ao, --ta;
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    findta(ao, ta);
    ta = (now.size() + 1) / 2;
    cntsz(now[(now.size() + 1) / 2], now[(now.size() + 1) / 2 - 1]);
    if (now.size() % 2 == 0) {
        cout << sz[now[ta]] - 1 + now.size() / 2 - 1 << endl;
    }
    else {
        cout << sz[now[ta]] + now.size() / 2 - 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 10880
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

std::string S, T;

int main()
{
  std::cin >> S >> T;

  std::cout << T+S << std::endl;

  return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int a = 0, w = 0, t = 0, r = 0;
  while (n--) {
    string s;
    cin >> s;
    if (s == "AC")
      ++a;
    else if (s == "WA")
      ++w;
    else if (s == "TLE")
      ++t;
    else if (s == "RE")
      ++r;
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << w << endl;
  cout << "TLE x " << t << endl;
  cout << "RE x " << r << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

ll sx, sy, gx, gy;
ll INF = 1000000000, dp[200005];
int n;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> sx >> sy >> gx >> gy >> n;
	if (sx > gx) {
		swap(sx, gx);
		swap(sy, gy);
	}
	bool flag = true;
	if (sy > gy) {
		flag = false;
		swap(sy, gy);
	}

	vector<pair<ll, ll> > v;
	
	FOR(i, n) {
		ll x, y;
		cin >> x >> y;
		if (sx <= x && x <= gx && sy <= y && y <= gy) {
			if (flag) v.push_back(make_pair(x, y));
			else v.push_back(make_pair(x, -y));
		}
	}
	sort(ALL(v));
	fill(dp, dp+n, INF);
	FOR(i, v.size()) {
		*lower_bound(dp, dp+n, v[i].second) = v[i].second;
	}

	ll sz = lower_bound(dp, dp+n, INF) - dp;
	ll dis = (gx - sx) + (gy - sy);
	ll mi = min(gx - sx, gy - sy);
	double ans;
	if (mi >= sz) ans = dis * 100 - sz * (20.0 - 5 * M_PI);
	else ans = dis * 100 - (sz-1) * (20.0 - 5 * M_PI) + (10 * M_PI - 20.0);
	cout << setprecision(15) << ans << endl;
	return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    int n;
    cin>>n;
    double rate = 380000,ans=0;
    for(int i = 0; i < n; i++)
    {
        double x;
        string u;
        cin>>x>>u;
        if(u=="JPY")
        {
            ans+=x;
        }
        else
        {
            ans+=x*rate;
        }
        
    }
    
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s=br.readLine();
        String p=br.readLine();
        s=s+s;
        if(s.indexOf(p)!=-1){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
	}
}

Measured memory_bytes: 24472
def q2():
    N = int(input())
    S = input()
    ans = 'Yes'
    d, m = divmod(N, 2)

    if m == 1:
        ans = 'No'
    elif S[:d] != S[d:]:
        ans = 'No'

    print(ans)


if __name__ == '__main__':
    q2()


Measured memory_bytes: 2940
N = int(input())
A = list(map(int, input().split()))
ans="APPROVED"
for i in range(N):
    if (A[i]%2==0):
        if (A[i]%5 !=0 and A[i]%3 !=0):
            ans="DENIED"
            #print(i)
print(ans)


Measured memory_bytes: 2940
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();

        if(k % 2 == 0){
            System.out.println((k/2) * (k/2));
        }else{
            System.out.println((k/2)*((k/2)+1));
        }
    }

}


Measured memory_bytes: 22736
#include<iostream>


using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;

	if (A * C <= B) {
		cout << C << endl;
	}
	else {
		if (A > B) {
			cout << 0 << endl;
		}
		else {
			cout << B / A << endl;
		}
	}

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.Remoting.Channels;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private int[] A;

        public void Solve()
        {
            var sc = new Scanner();
            A = sc.IntArray();
            Array.Sort(A);
            int ans = 0;
            var bb = A[2] - A[1];
            A[0] += bb;
            A[1] = A[2];
            var aa = (A[2] - A[0]) / 2;
            A[0] += 2 * aa;
            ans = aa + bb;
            if (A[2] - A[0] == 1)
            {
                ans += 2;
            }
            Console.WriteLine(ans);
         
        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define gt(n) scanf("%d", &n)
#define gtll(n) scanf("%ld", &n)
#define out(n) printf("%d", n)
#define outll(n) printf("%ld", n)
#define loop(n) for(int i=0; i<n; i++)
#define MAXX 1001
#define mem(x, y) memset(x, y, sizeof(x))
#define loop1(n) for(int i=1; i<=n; i++)
#define ll long long
#define pb push_back
#define pi acos(-1)
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//(only in c)char[33];itoa(n,buffer,base);printf("%s",buffer);
#define dec_to_bin(n) std::string binary = std::bitset<64>(n).to_string();
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int main()
{
fast;
int n;
string s;
cin>>n>>s;
s+="ZZ";
int c=0;
for(int i=0;i<n;i++){
if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
        c++;
     i+=2;
}
}
cout<<c<<endl;
return 0;
}


Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <unordered_map>
#include <list>
using namespace std;
const long long int mod1=1000000007;
const long long int mod2 = 998244353;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define ll long long int
#define ull unsigned long long int
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define FOR(i, a, b) for (int i = (a), _##i = (b); i <= _##i; ++i)
#define FORD(i, a, b) for (int i = (a), _##i = (b); i >= _##i; --i)
#define REP(i, a) for (int i = 0, _##i = (a); i < _##i; ++i)
#define REPD(i,n) for(int i = (n)-1; i >= 0; --i)
#define pll pair<ll, ll>
#define ln endl
ll gcd(ll a, ll b){
    ll c;
     while(b){
        c = b;
        b = a % b;
        a = c;
     }
     return a;
}
ll lcm(ll a, ll b){
    return (a * b) / gcd(a, b);
 }
ll power1(ll a, ll b){
     ll out = 1;
     while(b){
        if(b & 1){
            out *= a;
        }
        b >>= 1;
        a *= a;
     }
     return out;
}
ll power2(ll a, ll b, ll m){
     a %= m;
     ll out = 1;
     while(b){
        if(b & 1){
            out *= a;
            out %= m;
        }
        b >>= 1;
        a = (a * a) % m;
     }
     return out;
}
ll modi(ll x, ll p){
    return power2(x, mod1 - 2, mod1);
}
int main(){
    fast;
    ll tt = 1;
    //cin >> tt;
    while(tt--){
        ll h1, m1, h2, m2, k;
        cin >> h1 >> m1 >> h2 >> m2 >> k;
        ll time = (h2 - h1) * 60 + m2 - m1;
        cout << time - k << endl;
    }
}

Measured memory_bytes: 3640
try:
    while 1:
        a = input().split()
        b = input().split()
        s = 0
        v = 0
        for i in range(len(a)):
            if a[i] == b[i]:
                s += 1
            elif a[i] in b:
                v += 1

        print(*(s, v))
except:
    pass

Measured memory_bytes: 7380
#include<iostream>
    #include<cstdlib>
    #include<math.h>
    #include<set>
    #include<string>
    #include<stdlib.h>
    using namespace std ;
    int main(){
      string ABC="ABC",N;
      cin>>N;
      ABC=ABC+N;
      cout<<ABC<<endl;
      return 0;
    }

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

int main()
{
    double x1, y1, x2, y2;
    scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);

    printf("%lf\n", (double)hypot(x1-x2, y1-y2));

    return 0;
}



Measured memory_bytes: 2112
N = gets.to_i
A = gets.split.map{|i|i.to_i}
H = Hash.new{0}
A.size.times{|i|
    H[A[i] - i] += 1
}
#warn H.inspect
count = 0
A.size.times{|i|
    h = -A[i] - i
    #warn h
    #warn H[h].inspect
    count += H[h]
}
puts count


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

int main()
{
    int n,i;
    cin>>n;
    int value;
    vector <int> v;
    for(i=0;i<n;i++)
    {
        cin>>value;
        v.push_back(value);
    }
    int arr[n];
    arr[0]=0;
    arr[1]=abs(v[1]-v[0]);
    for(i=2;i<n;i++)
    {
        arr[i]=min(arr[i-1]+abs(v[i-1]-v[i]),arr[i-2]+abs(v[i-2]-v[i]));
    }
    cout<<arr[n-1]<<endl;
    return 0;
}

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

using namespace std;

int main(void){
//string S;
int N;
cin >> N;
int M;
cin >> M;
/*long long mincost = 0;
//vector<int> H(N);

for(int i = 0; i < N; i++){
  cin >> H[i];
}

sort(H.begin(), H.end(), greater<int>());

for(int i = K; i < H.size(); i++){
  mincost += H[i];
}*/
if(M == N) cout << "Yes" << endl;
if(M < N) cout << "No" << endl;

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
 
const int MOD = 1000000007;
using mint = Fp<MOD>;
 
// 愚直計算による二項係数計算
mint com(long long n, long long r) {
    mint res = 1;
    for (long long i = 0; i < r; ++i) {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}
 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);

ll n,a,b;
cin >> n >> a >> b;

mint ans = modpow(mint(2), n);
ans -= com(n, a) + com(n, b) + 1;
cout << ans << endl;

return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, A, B, C;
string S[int(1e5 + 5)];
char ans[int(1e5 + 5)];

int main(){
  cin >> N >> A >> B >> C;
  for (int i = 0; i < N; i++) cin >> S[i];

  for (int i = 0; i < N; i++){
    if (S[i] == "AB"){
      if (A == 0 && B == 0){
        No(); return 0;
      }
      if (A == 1 && B == 1){
        if (S[i + 1] == "AB" || S[i + 1] == "AC") A++, B--, ans[i] = 'A';
        else A--, B++, ans[i] = 'B'; 
      }else{
        if (A < B) A++, B--, ans[i] = 'A';
        else A--, B++, ans[i] = 'B';
      }
    }else if (S[i] == "AC"){
      if (A == 0 && C == 0){
        No(); return 0;
      }
      if (A == 1 && C == 1){
        if (S[i + 1] == "AB" || S[i + 1] == "AC") A++, C--, ans[i] = 'A';
        else A--, C++, ans[i] = 'C';
      }else{
        if (A < C) A++, C--, ans[i] = 'A';
        else A--, C++, ans[i] = 'C';
      }
    }else{
      if (B == 0 && C == 0){
        No(); return 0;
      }
      if (B == 1 && C == 1){
        if (S[i + 1] == "BC" || S[i + 1] == "AB") B++, C--, ans[i] = 'B';
        else B--, C++, ans[i] = 'C';
      }else{
        if (B < C) B++, C--, ans[i] = 'B';
        else B--, C++, ans[i] = 'C';
      }
    }
  }

  Yes();
  for (int i = 0; i < N; i++){
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 6856
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll dp[100010][4];
int main(){
    string s;cin >> s;
    ll n=s.size();
    dp[0][0]=1;
    rep(i,n){
        rep(j,4){
            if(s[i]=='?'){
                dp[i+1][j]+=3*dp[i][j];       
            }
            else dp[i+1][j]+=dp[i][j];
        }
        if(s[i]=='A'||s[i]=='?'){
            dp[i+1][1]+=dp[i][0];
        }
        if(s[i]=='B'||s[i]=='?'){
            dp[i+1][2]+=dp[i][1];
        }
        if(s[i]=='C'||s[i]=='?'){
            dp[i+1][3]+=dp[i][2];
        }
        rep(j,4)dp[i+1][j]%=MOD;
    }
    cout << dp[n][3] <<endl;
}

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

int main()
{
    ios::sync_with_stdio(false);
    int a, b, k, aux = 0, i, ans;

    cin >> a >> b >> k;

    for (i = 100;; i--)
    {
        if (a % i == 0 and b % i == 0)
        {
            // cout<<i<<" ";
            aux++;
            if (aux == k)
            {
                ans = i;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;

void raushan_kumar(){
	int n;cin>>n;
	int q=n/500;
	int r=n%500;
	int q2=r/5;
	cout<<q*1000+q2*5;
}

int32_t main()
{
	fast;int t=1;
	//cin>>t;
	while(t--){
		raushan_kumar();
	}

}

Measured memory_bytes: 256
INF = float('inf')
import bisect
L = list()
n = int(input())
for i in range(n):
  L.append(int(input()))
LIS = [INF] * n
for i in range(n):
  LIS[bisect.bisect_left(LIS, L[i])] = L[i]
for i in range(n):
  if(LIS[i] == INF):
    print(i)
    exit()
print(n)


Measured memory_bytes: 10472
a,b,q=(input().split())
a,b,q=int(a),int(b),int(q)
s=[int(input()) for i in range(a)]
t=[int(input()) for i in range(b)]
x=[int(input()) for i in range(q)]
dist=['' for i in range(8)]
dist1=['' for i in range(2)]
dist2=['' for i in range(4)]
sp1=['' for i in range(2)]
tp1=['' for i in range(4)]

import bisect
for k in range(q):

    p1=bisect.bisect_left(s,x[k])

    if p1==0:
        dist1[0]=s[0]-x[k]
        dist1[1]=s[0]-x[k]
        sp1[0]=s[0]
        sp1[1]=s[0]        
    elif p1==a:
        dist1[0]=x[k]-s[a-1]
        dist1[1]=x[k]-s[a-1]
        sp1[0]=s[a-1]
        sp1[1]=s[a-1]
    else:
        dist1[0]=x[k]-s[p1-1]
        dist1[1]=s[p1]-x[k]
        sp1[0]=s[p1-1]
        sp1[1]=s[p1]
 
    p11=bisect.bisect_left(t,sp1[0])

    if p11==0:
        dist2[0]=t[0]-sp1[0]
        dist2[1]=t[0]-sp1[0]
    elif p11==b:
        dist2[0]=sp1[0]-t[b-1]
        dist2[1]=sp1[0]-t[b-1]
    else:
        dist2[0]=sp1[0]-t[p11-1]
        dist2[1]=t[p11]-sp1[0]
        
    p11=bisect.bisect_left(t,sp1[1])

    if p11==0:
        dist2[2]=t[0]-sp1[1]
        dist2[3]=t[0]-sp1[1]
    elif p11==b:
        dist2[2]=sp1[1]-t[b-1]
        dist2[3]=sp1[1]-t[b-1]
    else:
        dist2[2]=sp1[1]-t[p11-1]
        dist2[3]=t[p11]-sp1[1]
        
    dist[0]=dist1[0]+dist2[0]
    dist[1]=dist1[0]+dist2[1]
    dist[2]=dist1[1]+dist2[2]
    dist[3]=dist1[1]+dist2[3]
                

    p1=bisect.bisect_left(t,x[k])

    if p1==0:
        sp1[0]=t[0]
        sp1[1]=t[0]
        dist1[0]=t[0]-x[k]
        dist1[1]=t[0]-x[k]
    elif p1==b:
        sp1[0]=t[b-1]
        sp1[1]=t[b-1]
        dist1[0]=x[k]-t[b-1]
        dist1[1]=x[k]-t[b-1]
    else:
        sp1[0]=t[p1-1]
        sp1[1]=t[p1]
        dist1[0]=x[k]-t[p1-1]
        dist1[1]=t[p1]-x[k]
        
    p11=bisect.bisect_left(s,sp1[0])

    if p11==0:
        dist2[0]=s[0]-sp1[0]
        dist2[1]=s[0]-sp1[0]
    elif p11==a:
        dist2[0]=sp1[0]-s[a-1]
        dist2[1]=sp1[0]-s[a-1]
    else:
        dist2[0]=sp1[0]-s[p11-1]
        dist2[1]=s[p11]-sp1[0]
    
    p11=bisect.bisect_left(s,sp1[1])

    if p11==0:
        dist2[2]=s[0]-sp1[1]
        dist2[3]=s[0]-sp1[1]       
    elif p11==a:
        dist2[2]=sp1[1]-s[a-1]
        dist2[3]=sp1[1]-s[a-1]
    else:
        dist2[2]=sp1[1]-s[p11-1]
        dist2[3]=s[p11]-sp1[1]

    dist[4]=dist1[0]+dist2[0]
    dist[5]=dist1[0]+dist2[1]
    dist[6]=dist1[1]+dist2[2]
    dist[7]=dist1[1]+dist2[3]
    
    ans=min(dist[0],dist[1],dist[2],dist[3],dist[4],dist[5],dist[6],dist[7])

    print(ans)


Measured memory_bytes: 125528
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    var(string, s);
    int N = s.length();
    int c = count(all(s), '0');
    print(min(c, N-c) * 2);

    return 0;
}


Measured memory_bytes: 512
#!/usr/bin/env python3
import numpy as np

h, w = list(map(int, input().split()))

s = np.array([list(input()) for _ in range(h)]) == "."

ups = np.zeros((h, w), dtype=int)
downs = np.zeros((h, w), dtype=int)
rights = np.zeros((h, w), dtype=int)
lefts = np.zeros((h, w), dtype=int)

for i in range(1, h):
    ups[i, :] = (ups[i-1]+1)*s[i-1]

for i in reversed(range(h-1)):
    downs[i, :] = (downs[i+1]+1)*s[i+1]

for i in range(1, w):
    rights[:, i] = (rights[:, i-1]+1)*s[:, i-1]

for i in reversed(range(w-1)):
    lefts[:, i] = (lefts[:, i+1]+1)*s[:, i+1]

ans = (((ups+downs+lefts+rights)*s).max()+1)
print(ans)


# data_w = []
# data_w_index = []
# data_h = []
# data_h_index = []

# for i in range(h):
#     count = 0
#     index = 0
#     data_w_index_tmp = []
#     data_w_tmp = []
#     for j in range(len(s[i])):
#         # print(s[i][j][0])
#         # print(count)
#         # print(index)
#         if s[i][j] == ".":
#             count += 1
#             data_w_index_tmp.append(index)
#         else:
#             data_w_tmp.append(count)
#             data_w_index_tmp.append(-1)
#             count = 0
#             index += 1
#     data_w_tmp.append(count)
#     # data_w_index_tmp.append(index)

#     data_w_index.append(data_w_index_tmp)
#     data_w.append(data_w_tmp)

# print(data_w)
# print(data_w_index)

# for i in range(w):
#     count = 0
#     index = 0
#     data_h_index_tmp = []
#     data_h_tmp = []
#     for j in range(len(s)):
#         # print(s[i][j][0])
#         # print(count)
#         # print(index)
#         if s[j][i] == ".":
#             count += 1
#             data_h_index_tmp.append(index)
#         else:
#             data_h_tmp.append(count)
#             data_h_index_tmp.append(-1)
#             count = 0
#             index += 1
#     data_h_tmp.append(count)
#     # data_h_index_tmp.append(index)

#     data_h_index.append(data_h_index_tmp)
#     data_h.append(data_h_tmp)

# # print(data_h)
# # print(data_h_index)

# ans = 0
# for i in range(w):
#     for j in range(h):
#         index_h = data_h_index[i][j]
#         index_w = data_w_index[j][i]
#         if index_h != 1:
#             ans_tmp = data_h[i][index_h]+data_w[j][index_w]-1
#             ans = max(ans, ans_tmp)
# print(ans)


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

const std::string YES = "Yes";
const std::string NO = "No";

void solve(std::string s, long long x, long long y){
	const int Base = 8005;
	bitset<Base * 2> v, h;
	v.set(Base);
	h.set(Base);
	bool start = true, horizontal = true;
	int d = 0;
	for(int i = 0;i < s.size();i++){
		if(s[i]=='F'){
			d++;
		}else{
			if(horizontal){
				if(start){
					h = (h << d);
				}else{
					h = ((h << d)|(h >> d));
				}
			}else{
				v = ((v << d)|(v >> d));
			}
			start = false;
			horizontal = not horizontal;
			d = 0;
		}
	}
	if(horizontal){
		if(start){
			h = (h << d);
		}else{
			h = ((h << d)|(h >> d));
		}
	}else{
		v = ((v << d)|(v >> d));
	}

	if(abs(x) <= Base and abs(y) <= Base and h.test(Base + x) and v.test(Base + y)){
		cout << YES << endl;
	}else{
		cout << NO << endl;
	}
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
	std::string s;
	std::cin >> s;
	long long x;
	std::cin >> x;
	long long y;
	std::cin >> y;
	solve(s, x, y);
	return 0;
}


Measured memory_bytes: 256
let rec power ( * ) e m n =
  if n <= 0 then e
  else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)

let m = 1000000007
let ( +^ ) x y = (x + y) mod m
let ( -^ ) x y = x +^ (m - y)
let ( *^ ) x y = (x * y) mod m

let perm n k =
  Array.fold_left ( *^ ) 1 @@
  Array.init k @@ ( +^ ) (n - k + 1)
let comb n k = power ( *^ ) (perm n k) (perm k k) (m - 2)

let f r c = comb (r + c) (min r c) -^ 1

let () = Scanf.scanf "%d %d %d %d" @@ fun r1 c1 r2 c2 ->
  Printf.printf "%d\n" @@
  f (r2 + 1) (c2 + 1)
  -^ f (r2 + 1) c1
  -^ f r1 (c2 + 1)
  +^ f r1 c1


Measured memory_bytes: 52472
n,a,b = map(int, input().split())
a -= b
l = [int(input()) for _ in range(n)]
ok = 10**10
ng = 0
while ok-ng > 1:
  mid = (ok+ng)//2
  t = 0
  for x in l:
    t += (max(x-b*mid,0)-1)//a+1
  if t <= mid:
    ok = mid
  else:
    ng = mid
print(ok)

Measured memory_bytes: 7052
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		System.out.println(N*(N-1)/2 + M*(M-1)/2);
		
		sc.close();
	}
}


Measured memory_bytes: 22356
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var a, b, k int
	sc.nextInts(&a, &b, &k)
	a, b = max(a-k, 0), max(min(b-(k-a), b), 0)
	fmt.Printf("%d %d\n", a, b)
}

type scanner struct {
	sc *bufio.Scanner
}

var sc *scanner

func init() {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	sc = &scanner{sc: s}
}

func (s *scanner) nextInts(ints ...*int) {
	for i := range ints {
		s.sc.Scan()
		*ints[i], _ = strconv.Atoi(s.sc.Text())
	}
}

func (s *scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 640
import java.util.*;
//import static java.lang.Integer.*;
import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		long n = parseLong(sc.next());
		sc.close();
		StringBuilder sb = new StringBuilder();
		long sho = n;
		while(sho != 0) {
			long amari = sho % -2;
			sho /= -2;
			if(amari < 0) {
				amari=-amari;
				sho++;
			}
			sb.insert(0, (char)('0'+amari));
		}
		out.println(sb.length()==0?"0":sb.toString());
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include<vector>
#include <utility>
#include <string>

using namespace std;

int main(){
  int n,b,c,i,j,k;
  cin >> n;
  vector<long long> a(n);
  for(i=0;i<n;i++)cin >> a[i];
  sort(a.begin(),a.end());
  vector<long long>::iterator itr = lower_bound(a.begin(),a.end(),a[n-1]/2);
  if((double)a[n-1]/2-(double)*itr<=(double)*(itr-1)-(double)a[n-1]/2)itr--;
  cout << a[n-1] << " " << *itr << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
const int maxn = 2e5 + 10;
int a[maxn], cnt[maxn];
void solve(){
    memset(cnt, 0, sizeof cnt);
    int n; cin >> n;
    for(int i = 1; i < n; i++) cin >> a[i];

    for(int i = 1; i < n; i++) cnt[a[i]]++;

    for(int i = 1; i <= n; i++) cout << cnt[i] << endl;
}
int main(){
    IOS;
    int t = 1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 5180
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define ITR(i,x) for(auto i=(x).begin();i!=(x).end();++i)
using namespace std;

typedef pair<int, int> P;
typedef long long ll;
const int mod = 1000000007;

bool square(ll a){ll n=(ll)sqrt(a);return a==n*n;}
int digitsum(ll N,int a);//a進数におけるNの各桁の和、計算量はloga(N)
ll mpow(ll x, ll n);
ll inv_mod(ll a){return mpow(a,mod-2);}
int gcd(int x,int y){return y ? gcd(y,x%y) : x;};//xとyの最大公約数
int lcm(int x,int y){return x*y/gcd(x,y);}//xとyの最小公倍数

int main(){
    string s;
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2]) cout<<"Yes"<<endl;
    else if(s[1]==s[2]&&s[2]==s[3]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

int digitsum(ll N,int a){
    if(N==0) return 0;
    int ret=0;
    ret+=digitsum(N/a,a)+N%a;
    return ret;
}
ll mpow(ll x, ll n){ //x^n(mod division) ←普通にpow(x,n)では溢れてしまうため，随時mod計算 2分累乗法だから早い
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}
/*
class Factorial{//階乗とその逆元を求めて計算に利用するクラス
private:
    vector<ll> fac;
public:
    
    Factorial(ll N){
        fac.push_back(1);
        for(int i=0;i<N;i++) fac.push_back(fac[i]*(i+1)%mod);
    }

    ll fact(ll a){return fac[a];}
    ll ifact(ll a){return inv_mod(fac[a]);}

    ll cmb(ll a,ll b){
        if(a==0&&b==0) return 1;
        if(a<b||a<0) return 0;
        ll tmp =ifact(a-b)*ifact(b)%mod;
        return tmp*fac[a]%mod;
    }
};
*/

/*
class UnionFind{//UnionFind木
 private:
    vector<int> Parent;
 public:
    UnionFind(int N){
        for(int i=0;i<N;i++) Parent.push_back(-1);
    }

    int root(int A){
        if(Parent[A]<0) return A;
        return Parent[A]=root(Parent[A]);
    }

    int size(int A){
        return -Parent[root(A)];
    }

    bool connect(int A,int B){
        A=root(A);
        B=root(B);
        if(A==B) return false;
        if(size(A)<size(B)) swap(A,B);
        Parent[A]-=Parent[B];
        Parent[B]=A;
    }
};
*/

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#define _A_ true
using namespace std;

int main(){
  int n,AC=0;
  int dp[1010][1010];
  char A[1500],B[1500];
  scanf("%d",&n);
  while(_A_){
    if(AC == n)break;
    scanf("%s",A);
    scanf("%s",B);
    for(int i=0;i<1010;i++)for(int j=0;j<1010;j++)dp[i][j]=0;

    for(int i=0;i<strlen(A);i++){
      for(int j=0;j<strlen(B);j++){
	if(A[i] == B[j]){
	  dp[i+1][j+1]=dp[i][j]+1;
	}
	else{
	  if(dp[i+1][j] > dp[i][j+1]){
	    dp[i+1][j+1]=dp[i+1][j];
	  }
	  else {
	    dp[i+1][j+1] = dp[i][j+1];
	  }
	}
      }
    }
    printf("%d\n",dp[strlen(A)][strlen(B)]);
    AC++;
  }
  return 0;
}

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

b=[]
for i in range(1,30):
    b.append(2**i)
#print(b)
ans=0
u=len(b)
for i in range(n):
    for j in range(u):
        if a[i]%b[j]==0:
            ans+=1
print(ans)

Measured memory_bytes: 4148
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
typedef long long ll;
using namespace std;
long long n,m;
int main(){
	cin>>n>>m;
	if (n==1 && m==1){
		cout<<1;
	}else if (n==1){
		cout<<m-2;
	}else if (m==1){
		cout<<n-2;
	}else{
		cout<<(m-2)*(n-2);
	}
	return 0;
} 

Measured memory_bytes: 256
n,w = map(int, input().split())
high = [0] * (w + 1)
for i in range(n):
    weight, value = map(int, input().split())
    if weight <= w:
        renewal = high[:weight]
        renewal += [max([j+value, k]) for j,k in zip(high[:w-weight+1], high[weight:])]
        high = renewal
print(high[w])

Measured memory_bytes: 137748
#include <iostream>
#define NUM 10000


using namespace std;

int main(void){
	int times[NUM];
	int i, n;
	int max;

	for(i=0;i<NUM;i++){
		times[i] = 0;
	}

	while(cin >> n){
		times[n]++;
	}

	max = 0;
	for(i=0;i<NUM;i++){
		if(max < times[i]){
			max = times[i];
		}
	}

	for(i=0;i<NUM;i++){
		if(max == times[i]){
			cout << i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
n, m = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
ll = sorted(l)
count = 0
total = 0
for i in range(n):
    if count < m:
        count += ll[i][1]
        total += ll[i][0]*ll[i][1]
    else:
        c = count-m
        total -= ll[i-1][0]*c
        print(total)
        exit()
    if i == n-1:
        c = count-m
        total -= ll[i][0]*c
        print(total)
        exit()

Measured memory_bytes: 61528
using System;

class Program
{
    // 最小値保持
    private static int [] a = new int[50001];

    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int n = int.Parse(s[0]);
        int m = int.Parse(s[1]);

        s = Console.ReadLine().Split(' ');
        int[] g = new int[m];
        
        for (int i = 0; i < m; i++) g[i] = int.Parse(s[i]);

        Console.WriteLine(Coin(n, g, m));
    }

    static int Coin(int n, int[] g, int m)
    {
        int g_min = 10000; //額面最大値

        if (a[n] != 0) return a[n];
        if (n == 0)    return 0;

        for (int i = 0; i < m; i++)
        {
            if (n - g[i] >= 0)
            {
                int r = Coin(n - g[i], g, m) + 1;
                if (g_min > r) g_min = r;
            }
        }

        a[n] = g_min;
        return a[n];
    }
}


Measured memory_bytes: 12476
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define out(a) printf("%d ",a)
using namespace std;
int n,a,b,x,y;
int read()
{
	int s=0,t=1; char c;
	while (c<'0'||c>'9') {if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9') {s=s*10+c-'0'; c=getchar();}
	return s*t;
}
int main()
{
	n=read(); a=read(); b=read();
	if ((a+b)&1) puts("Borys");
	else puts("Alice");
	return 0;
}


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

int main(){
  string S; 
  cin>>S;
  
  if(S=="SUN"){
    cout<<7<<endl;
  }
  else if(S=="MON"){
    cout<<6<<endl;
  }
  else if(S=="TUE"){
    cout<<5<<endl;
  }
  else if(S=="WED"){
    cout<<4<<endl;
  }
  else if(S=="THU"){
    cout<<3<<endl;
  }
  else if(S=="FRI"){
    cout<<2<<endl;
  }
  else{
    cout<<1<<endl;
  }

}

Measured memory_bytes: 256
def resolve():
    h, w  = map(int, input().split())
    a = [list(map(int, input().split())) for _ in range(h)]
    ans = []
    for i in range(h):
        for j in range(w):
            if j != w-1 :
                if a[i][j] % 2 == 0:
                    continue
                else:
                    ans.append([i+1, j+1, i+1, j+2])
                    a[i][j+1] += 1
                    a[i][j] -= 1
    for i in range(h):
        if i != h-1:
            if a[i][w-1] % 2 == 0:
                continue
            else:
                ans.append([i+1, j+1, i+2, j+1])
                a[i+1][w-1] += 1
                a[i][w-1] -= 1
    print(len(ans))
    for i in range(len(ans)):
        print(*ans[i])
resolve()

Measured memory_bytes: 70748