akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
 
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}
 
#define MAX_N 200002
#define INF   0x7f7f7f7f
 
int a[MAX_N];
int w[MAX_N/2+2];
 
long long number_of_inversions(int low, int high) 
{ 
    int i, j, k, p, mid;
    long long ans = 0;
 
    if (low < high) {
        mid = (low + high) >> 1;
        ans += number_of_inversions(low,   mid);
        ans += number_of_inversions(mid+1, high);
 
        p = mid-low+1;
        memcpy(w, a+low, p << 2);
        i = mid+1, j = 0; k = low;
 
        w[p] = INF;
        while (i <= high) {
            if (w[j] <= a[i]) a[k++] = w[j++];
            else              a[k++] = a[i++], ans += i-k;
        }
        memcpy(a+k, w+j, (p-j) << 2);
    }
    return ans;
}
 
int main()
{
    int n, i;
     
    n = in(); for (i = 0; i < n; i++) a[i] = in();
    printf("%lld\n", number_of_inversions(0, n-1));
    return 0;
}



Measured memory_bytes: 2884
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;
typedef long long ll;

int main(){
	ll N,A,B;
	vector<ll> ve;
	cin>>N>>A>>B;
	ll a;
	for(ll i=1;i<=N;i++){
		cin>>a;
		ve.push_back(a);
	}
	sort(ve.begin(),ve.end(),greater<ll>());

	ll vl=-1,vr=1000000001;
	while(vr-vl>1){
		ll mid=(vl+vr)/2;
		ll cnt=0;
		for(vector<ll>::iterator it=ve.begin();it!=ve.end();it++){
			cnt+=(((*it)-mid*B<=0) ? 0 : (((*it)-mid*B-1)/(A-B)+1));
		}
		if(cnt<=mid){
			vr=mid;
		}
		else{
			vl=mid;
		}
	}
	cout<<vr<<endl;
	return 0;
}


Measured memory_bytes: 1400
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;



void main() {
    int N, p;
    scan(N, p);
    string s;
    scan(s);
    auto a = s.map!(ch => ch - '0').array;

    long ans;

    if (p == 2) {
        foreach (i ; 0 .. N) {
            if (a[i] % 2 == 0) {
                ans += i + 1;
            }
        }
    }
    else if (p == 5) {
        foreach (i ; 0 .. N) {
            if (a[i] == 0 || a[i] == 5) {
                ans += i + 1;
            }
        }
    }
    else {
        auto r = new int[](N + 1);
        foreach (i ; 1 .. N + 1) {
            r[i] = r[i - 1] * 10 % p + a[i - 1] % p;
            r[i] %= p;
        }

        auto rt = powmod(10, p - 2, p);

        foreach (i ; 0 .. N + 1) {
            r[i] = r[i] * powmod(rt, i, p) % p;
        }

        auto cnt = new long[](p);
        foreach (i ; 0 .. N + 1) {
            ans += cnt[r[i]];
            cnt[r[i]]++;
            debug {
                writeln(cnt);
            }
        }
    }

    writeln(ans);
}

long powmod(long x, long y, long p) {
    return y > 0 ? powmod(x, y >> 1, p)^^2 % p * x^^(y & 1) % p : 1L;
}


void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}





Measured memory_bytes: 4092
#include <iostream>
using namespace std;
int main(void){
    int floor[4][3][10]={{{}}},n,b,f,r,v;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>b>>f>>r>>v;
        floor[b-1][f-1][r-1]+=v;
    }
    for(int i=0; i<4; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<10; k++){
              cout<<" "<<floor[i][j][k];
            }
            cout<<endl;
        }
        if(i!=3)
        cout<<"####################"<<endl;
    }
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
#include<numeric>
using namespace std;
// #define ll  long long
#define mp make_pair
#define fi first
#define se second
#define pii pair<ll,ll>
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using ll = long long;
int main()
{
    int n,m;string temp;
    cin >> n >> m;
    vector<string>str(n) ;
    for(int i=0;i<n;i++)
    {
        cin >> str[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(str[i]>str[j])
            {
                temp = str[i];
                str[i] = str[j];
                str[j] = temp;
            }
        }
    }
    for(int i=0;i<n;i++)
    cout << str[i];
}

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

int main() {
  int N,K;
  cin >> N >> K;
  map<int,int> mp;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    mp[a]++;
  }
  vector<int> vec;
  int val=0;
  for(auto p:mp){
    val++;
    vec.push_back(p.second);
  }
  sort(vec.begin(),vec.end());
  int sum=0;
  for(int i=0;i<val-K;i++){
    sum+=vec[i];
  }
  cout << sum;
}





Measured memory_bytes: 10748
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    S = list(input())

    if S == S[::-1]:
        # 回文
        i = (len(S) - 1) // 2
        ss = S[:i]
        if ss == ss[::-1]:
            print('Yes')
            return

    print('No')


if __name__ == '__main__':
    solve()


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

using namespace std;

#define FOR(i,k,n) for(int i=k;i<n;i++)
#define FORR(i,k,n) for(int i=k;i<=n;i++)
#define scan(a) scanf("%d",&a)
#define scann(a,b) scanf("%d%d",&a,&b)
#define scannn(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define mst(a,n)  memset(a,n,sizeof(a))
#define ll long long
#define N 50
#define mod 1000000007
#define INF 0x3f3f3f3f

const double eps=1e-8;
const double pi=acos(-1.0);

int a[N],b[N],c[N];
int dp[50][500][500];

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    int n,ma,mb;
    scanf("%d%d%d",&n,&ma,&mb);
    for(int i=1;i<=n;i++)
        scanf("%d%d%d",&a[i],&b[i],&c[i]);

    for(int i=0;i<=40;i++)
        for(int aa=0;aa<=400;aa++)
            for(int bb=0;bb<=400;bb++)
                dp[i][aa][bb]=INF;

    dp[0][0][0]=0;
    for(int i=1;i<=n;i++)
    {
        for(int aa=0;aa<=400;aa++)
        {
            for(int bb=0;bb<=400;bb++)
            {
                if(dp[i-1][aa][bb]==INF) continue;
                dp[i][aa][bb]=min(dp[i][aa][bb],dp[i-1][aa][bb]);
                dp[i][aa+a[i]][bb+b[i]]=min(dp[i][aa+a[i]][bb+b[i]],dp[i-1][aa][bb]+c[i]);
                //printf("dp[%d][%d][%d]=%d   dp[%d][%d][%d]=%d\n",i,aa,bb,dp[i][aa][bb],i,aa+a[i],bb+b[i],dp[i][aa+a[i]][bb+b[i]]);
            }
        }
    }

    int ans=INF;
    for(int aa=1;aa<=400;aa++)
    {
        for(int bb=1;bb<=400;bb++)
        {
            if(aa*mb==bb*ma) ans=min(ans,dp[n][aa][bb]);
        }
    }
    if(ans==INF) ans=-1;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 40832
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,math,classes;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k:Integer;
  l:array of Integer;
  s,s123,s1,s2,s3:string;
  al:string = 'abcdefghijklmnopqrstuvwxyz';
  tf,tfl,tfr,owari:Boolean;
  nyu:TStringList;
begin
  try
    { TODO -oUser -cConsole メイン : ここにコードを記述してください }
    nyu := TStringList.Create;
    Readln(a);
    Readln(s);
    nyu.CommaText := s;
    count:=0;
    owari:=true;
    j:=0;

    while owari do begin
      for i:=j to a-1 do begin
        if strtoint(nyu[i])mod 268435456 = 0 then begin
          nyu[i]:=inttostr(strtoint(nyu[i])div 268435456);
          count:=count+28;
          j:=i;
          break
        end;
        if strtoint(nyu[i])mod 16384 = 0 then begin
          nyu[i]:=inttostr(strtoint(nyu[i])div 16384);
          count:=count+14;
          j:=i;
          break
        end;
        if strtoint(nyu[i])mod 64 = 0 then begin
          nyu[i]:=inttostr(strtoint(nyu[i])div 64);
          count:=count+6;
          j:=i;
          break
        end;
        if strtoint(nyu[i])mod 2 = 0 then begin
          nyu[i]:=inttostr(strtoint(nyu[i])div 2);
          inc(count);
          j:=i;
          break
        end;

        if i=a-1 then
          owari:=false;
      end;
    end;

    Writeln(count);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Measured memory_bytes: 1760
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 3e18+7
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    int ans = 0;
    for(int i=1;i<=N;i++){
        if(i<10) ans++;
        else if(100<=i &&i<1000) ans++;
        else if(10000<=i && i<100000) ans++;
    }
    cout<<ans<<endl;
}


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

#define int long long
#define MOD 1000000007

int pow_mod(int a, int b){
	int ans = 1;
	while(b > 0){
		if(b & 1) ans = (ans * a) % MOD;
		a = (a * a) % MOD;
		b >>= 1;
	}
	return ans;
}

int kai[1000010];
int rkai[1000010];

int ncr(int n, int r){
	return kai[n] * rkai[r] % MOD * rkai[n-r] % MOD; 
}

signed main(){
	int n, k;
	cin >> n >> k;

	kai[0] = 1;
	rkai[0] = 1;
	for(int i = 1;i < 500010;i++){
		kai[i] = (kai[i-1]) * i % MOD;
		rkai[i] = rkai[i-1] * pow_mod(i, MOD-2) % MOD;
	}


	int ka = min(n, k);
	int fuka = n-ka;

	int tn = n;
	//int tmp = ncr(n, fuka) * ncr(n-fuka + n -1, n);

	int tmp = ncr(n*2-1, n-1);

	for(int i = 1;i < fuka;i++){
		int tt = ncr(n-i+i-1, i-1);
		tt = (tt*ncr(n, i)) %MOD;
		tmp = (MOD+tmp-tt) % MOD;
	}

	cout << tmp << endl;


	return 0;
}


Measured memory_bytes: 10496
def power(x, n, mod):
    ans = 1
    while n > 0:
        if n % 2 == 1:
            ans = ans * x % mod
        n //= 2
        x = x * x % mod
    return ans

n, k = map(int, input().split())

mod = 10 ** 9 + 7

count = [0] * k
for i in range(k, 0, -1):
    count[i-1] = power(k // i, n, mod)
    j = i * 2
    while j <= k:
        count[i-1] -= count[j-1]
        j += i

ans = 0
for i in range(1, k+1):
    ans = (ans + count[i-1] * i) % mod
print(ans)


Measured memory_bytes: 74288
#include<bits/stdc++.h>
#define inf (int)1e9+7

using namespace std;

const int mx = 1e5+123;

int hight[mx];

int dp[mx];

int n , k;
int solve(int i){

if(i == n)  return 0;

if(dp[i]!=-1) return dp[i];

int ret = inf;

for(int j = 1;j<=k;j++){
     if(i+j<=n)
    ret = min(ret,abs(hight[i]-hight[i+j])+solve(i+j));
}
return dp[i] = ret;

}
int main(){

    cin>>n>>k;

    for(int i = 1;i<=n;i++){
         cin>>hight[i];
    }
    memset(dp,-1,sizeof(dp));

    cout<<solve(1)<<endl;


  return 0;
}


Measured memory_bytes: 12140
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define RFOR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))

using namespace std;

static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> paii;

int main()
{
	string str;
	cin >> str;
	
	FOR(i, 0, (int)str.size())
	{
		str[i] = (char)('A' + (26+(str[i]-'A')-3)%26);
	}
	
	cout << str << endl;
	
	return 0;
}

Measured memory_bytes: 1180
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-8
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long i=0; i<n; ++i) { cout<<a[i]; if(i!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> vl;
typedef vector<vector<long long> > vll;
typedef vector<P> vp;
typedef vector<vector<P> > vpp;
class RSQ {
public:
	RSQ(int n) {
		_n=1;
		while(_n<n) _n*=2;
		_dat.resize(2*_n-1);
		for(int i=0;i<2*_n-1;++i) _dat[i]=0;
	}
	int size() {
		return _n;
	}
	void update(int k,long long a) {
		k+=_n-1;
		_dat[k]+=a;
		while(k>0) {
			k=(k-1)/2;
			_dat[k]+=a;
		}
	}
	// return the minimum number in [a,b)
	// external call should be written like query(a,b,0,0,_n)
	ll query(int a,int b,int k=0,int l=0,int r=-1) {
		if(r==-1) r=_n;
		if(r<=a||b<=l) return 0;
		if(a<=l&&r<=b) return _dat[k];
		else {
			ll vl=query(a,b,k*2+1,l,(l+r)/2);
			ll vr=query(a,b,k*2+2,(l+r)/2,r);
			return vl+vr;
		}
	}
private:
	int _n;
	vector<ll> _dat;
};
int main() {
	ios::sync_with_stdio(false);
	int n,q;
	cin>>n>>q;
	RSQ rsq(n);
	REP(i,q) {
		int c,x,y;
		cin>>c>>x>>y;
		if(c==0) {
			--x;
			rsq.update(x,y);
		}
		if(c==1) {
			--x;
			--y;
			cout<<rsq.query(x,y+1)<<endl;
		}
	}
}

Measured memory_bytes: 4940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int a[11];
int main()
{
    int n;
    cin>>n;
    if(n == 1){
        cout<<"1"<<endl;
        return 0;
    }
    for(int i=1;i<=7;i++)
    {
        a[i] = 1<<i;
    }
    int ans;
    for(int i=1;i<=7;i++)
    {
        if(n < a[i]){
            ans = a[i-1];
            break;
        }
    }
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
 
using namespace std;
 
const int N=100005;
 
int n,s1[N],m1,s2[N],m2,vec[N];
int A[N],B[N],ans,fa[N],m,sz[N];
bool fl[N];
map<int,int> D;

inline int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
inline void link(int u,int v){if(find(u)!=find(v))sz[find(v)]+=sz[find(u)],fa[find(u)]=find(v);}
 
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&s1[i]),m1^=s1[i],D[s1[i]]++;
	D[m1]++;
	for(int i=1;i<=n;i++)scanf("%d",&s2[i]),m2^=s2[i],D[s2[i]]--;
	for(auto&i:D)if(i.se<0)puts("-1"),exit(0);
	s1[0]=m1;s2[0]=m2;
	memcpy(vec,s1,(n+1)<<2);
	sort(vec,vec+n+1);
	m=unique(vec,vec+n+1)-vec;
	for(int i=0;i<m;i++)fa[i]=i,sz[i]=1;
	for(int i=0;i<=n;i++){
		A[i]=lower_bound(vec,vec+m,s1[i])-vec;
		B[i]=lower_bound(vec,vec+m,s2[i])-vec;
		if(A[i]!=B[i])link(A[i],B[i]),ans++;
	}
	if(!ans)puts("0"),exit(0);
	if(A[0]!=B[0])ans--;
	for(int i=0;i<m;i++){
		if(fa[i]==i&&sz[i]>1){
			fl[find(i)]=true;
			if(find(i)!=find(A[0])&&find(i)!=find(B[0]))ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 8576
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 入力
		int n = sc.nextInt();
		String s = new String();
		HashMap<String, Integer> map = new HashMap<String, Integer>();
		long cnt= 0;
        for(int i = 0; i < n; i++){
            s = sc.next();
            char[] chars = s.toCharArray();
            Arrays.sort(chars);
            String s2 = new String(chars);
            if(map.containsKey(s2)){
                Integer j = map.get(s2);
                cnt = cnt + j;
                map.put(s2, j + 1);
            }else{
                map.put(s2, 1);
            }
        }        
		
		// 計算

		// 出力
        System.out.println(cnt);
		
	}
}


Measured memory_bytes: 52948
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
#define INT_MAX 1<<30
const ll mod = 1e9+7;

bool isPrime(ll x){
	if(x==1 || x==0) return false;
	else{
		for(ll i=2; i*i<=x; i++){
			if(x % i == 0) return false;
		}
		return true;
	}
}


int main(){
	ll x; cin >> x;
	while(!isPrime(x)){
		x++;
	}
	cout << x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int N, sum = 0;
    cin >> N;
    int p[10];
    for(int i=0;i<N;i++)
        cin >> p[i];
    // 降順ソート
    sort(p, p + N, greater<int>());
    
    sum += p[0]/2;

    for(int i=1;i<N;i++)
        sum += p[i];

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x,m;
  cin>>n>>x>>m;
  int l=m;
  x-=m;
  for(int i=1;i<n;i++){
    cin>>m;
    x-=m;
    l=min(l,m);
  }
  cout<<n+x/l<<endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<string>
using namespace std;
int max(int a, int b);
void findLCS(char *X, char *Y, int XLen, int YLen);

int max(int a, int b) {
  return (a > b)? a : b;
}

void findLCS(string X, string Y, int Len1, int Len2) {
  int L[Len1 + 1][Len2 + 1];
  int r, c, i;

  for(r = 0; r <= Len1; r++) {

    for(c = 0; c <= Len2; c++) {

      if(r == 0 || c == 0) {

        L[r][c] = 0;

      } else if(X[r - 1] == Y[c - 1]) {

        L[r][c] = L[r - 1][c - 1] + 1;

      } else {

        L[r][c] = max(L[r - 1][c], L[r][c - 1]);
      }
    }
  }

 
  r = Len1;
  c = Len2;
  i = L[r][c];

  char LCS[i+1];

  
  LCS[i] = '\0';

  while(r > 0 && c > 0) {

    if(X[r - 1] == Y[c - 1]) {

      LCS[i - 1] = X[r - 1];

      i--;
      r--;
      c--;

    } else if(L[r - 1][c] > L[r][c - 1]) {

      r--;

    } else {

      c--;

    }

  }

  
  
  cout<< LCS;
}

int main() {
 
  string X ;
  string Y ;
  cin>>X;
  cin>>Y;

  
  int Len1 = X.length();
  int Len2 = Y.length();

  findLCS(X, Y, Len1, Len2);

  return 0;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
using pll = pair<long, long>;
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007
#define INF 1e18

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<pll>> Graph(n);
  rep(i,n-1){
    Graph.at(i+1).push_back(pll(i,0));
  }
  rep(i,m){
    long l,r,c;
    //cin >> l >> r >> c;
    scanf("%ld%ld%ld",&l,&r,&c);
    Graph.at(l-1).push_back(pll(r-1,c));
  }
  priority_queue<pll,vector<pll>, greater<pll>> que;
  vector<long> dis(n,INF);
  dis.at(0) = 0;
  que.push(pll(0,0));
  while(que.size()){
    pll P = que.top();
    que.pop();
    long v = P.second;
    long d = P.first;
    if(d > dis.at(v)) continue;
    for(pll nP : Graph.at(v)){
      long nv = nP.first;
      long cost = nP.second;
      if(d + cost < dis.at(nv)){
        dis.at(nv) = d + cost;
        que.push(pll(dis.at(nv),nv));
      }
    }
  }
  //rep(i,n-1) cout << dis.at(i) << endl;
  if(dis.at(n-1) == INF) cout << -1 << endl;
  else cout << dis.at(n-1) << endl;
}


Measured memory_bytes: 10104
N,M=list(map(int,input().split()))
A=sorted(list(map(int,input().split())),reverse=True)
C=[-1,2,5,5,4,5,6,3,7,6]
DP=[[0 if j==0 else -1 for i in range(M)] for j in range(N+1)]
for i in range(N+1):
  for j in range(M):
    if(j>0):
      DP[i][j]=max(DP[i][j],DP[i][j-1]);
    if(i-C[A[j]]>=0 and DP[i-C[A[j]]][j]!=-1):
      DP[i][j]=max(DP[i][j],DP[i-C[A[j]]][j]*10+A[j]);
    if(j>0 and i-C[A[j]]>=0 and DP[i-C[A[j]]][j-1]!=-1):
      DP[i][j]=max(DP[i][j],DP[i-C[A[j]]][j-1]*10+A[j]);
print(DP[N][M-1])  

Measured memory_bytes: 36252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

int main() {
    int S,W;
    cin >> S >> W;
    if(S <= W) {
        cout << "unsafe" << endl;
    }
    else {
        cout << "safe" << endl;
    }
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<list>
#include<deque>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<numeric>
using namespace std;

using ll = int64_t;

/// <summary>
/// 単純なcoutの時に使う
/// </summary>
#define co(a) cout<<a<<endl


/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define rep(i,a) for(ll i=0; i<a; ++i)

/// <summary>
/// 迷路等で使う方向のベクトル
/// </summary>
const vector<ll> dx = { 0, 1, 0, -1 }, dy = { 1, 0, -1, 0 };

/// <summary>
/// デバッグ時に使う
/// </summary>
#define DEBUG(x)     std::cout << #x << " : " << x << "\n"


///////////////////////////////////////////////////////////////////////////

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

	ll N;
	cin >> N;

	vector<ll> d(N);
	rep(i, N) {
		cin >> d[i];
	}

	unordered_set<ll> ans;
	
	rep(i, N) {
		ans.insert(d[i]);
	}

	cout << ans.size() << endl;

}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var lr = Console.ReadLine().Split();
        var l = int.Parse(lr[0]);
        var r = int.Parse(lr[1]);

        var ans = m1(l, r);
        Console.WriteLine(ans);
    }

    static long m1(int l, int r)
    {
        var ans = long.MaxValue;

        for (long i = l; i < r; i++)
        {
            for (long j = i + 1; j <= r; j++)
            {
                ans = Math.Min(ans, i * j % 2019);
                if (ans == 0) return ans;
            }
        }

        return ans;
    }
}


Measured memory_bytes: 11092
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n],b[n];
   for(int i=0;i<n;i++)
    {
        cin>>a[i];int p=a[i];
        b[p-1]=i;}


    for(int i=0; i<n; i++)
    {
       cout<<b[i]+1<<" ";
    }
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    set<int> s;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (s.count(a) == 1) s.erase(a);
        else s.insert(a);
    }

    cout << s.size() << endl;
}

Measured memory_bytes: 4864
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String args[]){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		try{
			String[] strA = insBR.readLine().split(" ");
			int[] intA = new int[strA.length];
			String strMessage = "";
			for(int i = 0;i < strA.length ;i++){
				intA[i] = Integer.parseInt(strA[i]);
			}
			if(intA[0] < intA[1] && intA[1] < intA[2]){
				strMessage = "Yes";
			}else{
				strMessage = "No";
			}
			System.out.println(strMessage);

		}catch(IOException e){
			System.out.println("入力が無効です。");
		}catch(NumberFormatException e){
			System.out.println("数値を入力してください。");
		}
	}

}



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


void is (int *A, int N) {
    for (int i = 0; i < N-1; i++) {
        cout << A[i] << ' ';
    }
    cout << A[N-1] << '\n';
    for (int i = 1; i <= N-1; i++) {
        int v = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
            A[j+1] = v;
        }
        cout << A[0];
        for (int i = 1; A[i] != 0 ; i++) {
            cout << ' ' << A[i];
        }
        cout << '\n';
    }
}

int main () {
    int N;
    cin >> N;
    int A[1001] = {};
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    is(A, N);
}

Measured memory_bytes: 3060
from itertools import accumulate


def solve(string):
    n, m, k, *ab = map(int, string.split())
    a, b = [0] + ab[:n], [0] + ab[n:]
    a, b = list(accumulate(a)), list(accumulate(b))
    i, j, ans = n, 0, 0
    while a[i] > k:
        i -= 1
    while j <= m and a[i] + b[j] <= k:
        j += 1
    ans = i + j - 1
    while i > 0:
        i -= 1
        while j <= m and a[i] + b[j] <= k:
            j += 1
        ans = max(ans, i + j - 1)
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 59604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll cnt[10][10];

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

    for(int i=1;i<=n;i++){
        string s=to_string(i);
        int x=s[0]-'0';
        int y=s.back()-'0';
        cnt[x][y]++;
    }

    ll ans=0;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            ans+=cnt[i][j]*cnt[j][i];
        }
    }

    cout<<ans<<endl;
}




Measured memory_bytes: 256
import java.io.*;
public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line;
        int a,b;
        int s,l;
        try{
        line = reader.readLine();
        String[] x = line.split(" ");
        a = Integer.parseInt(x[0]);
        b = Integer.parseInt(x[1]);
        s=a*b;
        l=2*a+2*b;
        System.out.println(s+" "+l);
        }catch (NumberFormatException e) {
            System.out.println(e);
        } catch (IOException e) {
            System.out.println(e);
        }

    
    }
}



Measured memory_bytes: 24196
/*
 _ _ _   _    _   _    _   _ _ _   _    _   _ __ _   __       __
|  _ _| | |  | | | |  | | |  _  | | |  | | |  __  | |   \   /   |
| |_ _  | |__| | | |  | | | |_| | | |__| | | |__| | | |\ \_/ /| |
|_ _  | |  __  | | |  | | |  _ <  |  __  | |  __  | | | \   / | |
 _ _| | | |  | | | |__| | | |_| | | |  | | | |  | | | |  \_/  | |  _   _   _
|_ _ _| |_|  |_| |_ __ _| |_ _ _| |_|  |_| |_|  |_| |_|       |_| |_| |_| |_|

*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << " ";
#define endl "\n"
const int  MOD=1000000007;
const int N=1000100;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){  
                                                        for (auto &v : vec) is >> v; return is; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve(){
    int n;
    cin>>n;
    vector<vector<int> > m(11,vector<int>(11,0));
    for(int i=1;i<=n;i++){
        m[to_string(i)[0]-'0'][i%10]++;
    }
    ll ans=0;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            ans+=m[i][j]*m[j][i]*1LL;
        }
    }
    cout<<ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t = 1;
    // cin>>t;
    for (long int tt = 1; tt <= t; tt++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3708
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

int trans[55][55];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  VI a(n), b(n);
  REP(i, n) cin >> a[i];
  REP(i, n) cin >> b[i];

  // -1の判定
  // グラフを構築
  // [1,l)とansのは使っていい辺
  REP(i, 55) REP(j, 55) trans[i][j] = (i==j?0:LLINF);
  REP(i, 51) FOR(j, 1, 51) trans[i][i%j] = 1;
  // WFをする
  REP(k, 51) REP(i, 51) REP(j, 51) chmin(trans[i][j], trans[i][k] + trans[k][j]);
  // 到達判定
  bool flag = true;
  REP(i, n) if(trans[a[i]][b[i]] == LLINF) flag = false;
  if(!flag) {
    cout << -1 << endl;
    return 0;
  }

  VI ans;
  for(int l=50; l>=1; --l) {
    // グラフを構築
    // [1,l)とansのは使っていい辺
    REP(i, 55) REP(j, 55) trans[i][j] = (i==j?0:LLINF);
    REP(i, 51) FOR(j, 1, l) trans[i][i%j] = 1;
    REP(i, 51) REP(j, ans.size()) trans[i][i%ans[j]] = 1;
    // WFをする
    REP(k, 51) REP(i, 51) REP(j, 51) chmin(trans[i][j], trans[i][k] + trans[k][j]);
    // 到達判定
    bool flag = true;
    REP(i, n) if(trans[a[i]][b[i]] == LLINF) flag = false;
    if(!flag) ans.PB(l);
  }

  // cout << ans << endl;
  int ret = 0;
  REP(i, ans.size()) ret += (1LL<<ans[i]);
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
s = list(input())

ops=['+', '-']
for o1 in ops:
   for o2 in ops:
       for o3 in ops:
           if eval(s[0] + o1 + s[1] + o2 + s[2] + o3 + s[3]) == 7:
                print(s[0] + o1 + s[1] + o2 + s[2] + o3 + s[3] + '=7')
                exit()


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
from collections import deque
def inpl(): return tuple(map(int, input().split()))

H, W = inpl()

S = [input() for _ in range(H)]
V = [[True if S[h][w]=="." else False for w in range(W)] for h in range(H)]
V[0][0] = True

Q = deque() #step, H, W
Q.append([1, 0, 0])

ok = False
while Q:
    s, h, w = Q.popleft()
    if h == H-1 and w == W-1:
        ok = True
        break
    
    if h > 0:
        if V[h-1][w]:
            V[h-1][w] = False
            Q.append([s+1, h-1, w])
    
    if h < H-1:
        if V[h+1][w]:
            V[h+1][w] = False
            Q.append([s+1, h+1, w])

    if w > 0:
        if V[h][w-1]:
            V[h][w-1] = False
            Q.append([s+1, h, w-1])
    
    if w < W-1:
        if V[h][w+1]:
            V[h][w+1] = False
            Q.append([s+1, h, w+1])

if ok:
    b = sum([s.count("#") for s in S])
    print(H*W - b - s)
else:
    print(-1)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
 int i,n;
  long long int s=0;
 cin >> n;
 for(i=1;i<=n;i++)
 {
  if(i%3!=0 && i%5!=0)
  s+=i;
 }
 cout << s;
 return 0;
}

Measured memory_bytes: 3636
import bisect,sys
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac =fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV
        
    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s+=a
        yield s


sys.setrecursionlimit(200005)


def main():
    N = iRaw()
    As = isRaw()
    ais = [(Aa+a,a) for a,Aa in enumerate(As)]
    ais.sort()
    ais0 = [ai[0] for ai in ais]
    ans = 0
    for b,Ab in enumerate(As):
        num = b-As[b]
        l = bisect.bisect_left(ais0, num)
        r = bisect.bisect_right(ais0, num)
        ans+=max(r-l,0)
    return ans

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 111888
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)

/*unsigned int xor128(void)
{
    static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned int t = (x ^ (x << 11));
    x = y;
    y = z;
    z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
unsigned int xor128rnd(unsigned int m)
{
    return xor128() % m;
}*/

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
bool graph[51][51];
int a[2510], b[2510];
int visited[51][51];
bool used[51];
int N, M;
void dfs(int v)
{
    used[v] = true;
    for (int i = 0; i < N; ++i)
    {
        if (!graph[v][i])
            continue;
        if (used[i])
            continue;

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

    //cout << fixed << setprecision(15);

    string s;
    cin >> s;
    int arr[4];
    arr[0] = s[0] - '0', arr[1] = s[1] - '0', arr[2] = s[2] - '0', arr[3] = s[3] - '0';

    for (int bit = 0; bit < (1 << 3); ++bit)
    {
        int sum = arr[0];
        for (int i = 0; i < 3; ++i)
        {
            if ((1 & (bit >> i)) == 1)
            {
                sum += arr[i + 1];
            }
            else
            {
                sum -= arr[i + 1];
            }
        }
        if (sum == 7)
        {
            for (int i = 0; i < 3; ++i)
            {
                cout << arr[i];

                if ((1 & (bit >> i)) == 1)
                {
                    cout << '+';
                }
                else
                {
                    cout << '-';
                }
            }
            cout << arr[3] << "=7" << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: i32,
        mut d: [i32; n],
    }

    d.sort();
    println!("{}", (d[(n / 2) as usize] - d[(n / 2 - 1) as usize]));


}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

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

    int a = min(A, K);
    K -= a;
    int b = min(B, K);
    K -= b;
    int c = K;

    int ans = a - c;
// cout<< a << " " <<b << " " << c << endl;
    cout << ans << endl;
}


Measured memory_bytes: 3624
import bisect
a=[3,5,7]
c=[3,5,7]
for i in range(8):
    b=[]
    for j in a:
        for k in range(3):
            b.append(int(str(j)+str(k*2+3)))
            c.append(int(str(j)+str(k*2+3)))
    a=b
n=int(input())
def is755(d):
    if len(set(list(str(d))))<3:
        return False
    else:
        return True
print(sum([i<=n and is755(i) for i in c]))

Measured memory_bytes: 11540
#include<stdio.h>

int main(){
  int length; //長さ
  int A[100]; //配列
  int i=0,j=0; //ループ
  int flag=0; //交換回数
  int key; // 回避変数
  int min; //最小値

  scanf("%d",&length); //長さ入力
  
  while(i < length){ //数の入力
    scanf("%d",&A[i]);
    i++;
  }
  
  for(i = 0;i <= length-1;i++){ //selectionSort(A, N)
    min = i;
    for(j = i;j <= length-1;j++){
      if(A[j] < A[min]){
	min = j;
      }
    }
    if(min!=i)flag++;
    key = A[i];
    A[i] = A[min];
    A[min] = key;
  }

  for(i = 0;i < length-1;i++){   //表示
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  printf("%d\n",flag);
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    vector<vector<int>> a(n,vector<int>(n));
    rep(i,n)rep(j,n-1){
        cin>>a[i][j];a[i][j]--;
    }
    vector<int> t(n,0);
    vector<bool> used(n,false);
    ll cou=0;
    queue<int> que1;
    rep(i,n) que1.push(i);
    while(true){
        cou++;
        //cout<<que1.size()<<endl;
        rep(i,n)used[i]=false;
        bool changed=false;
        queue<int> que2;
        while(que1.size()){
            int i=que1.front();que1.pop();
            if(used[i]||t[i]==n-1)continue;
            int b=a[i][t[i]];
            if(!used[b]&&a[b][t[b]]==i&&t[b]<n-1){
                used[i]=true;used[b]=true;changed=true;
                t[i]++;t[b]++;
                que2.push(i);que2.push(b);
            }
        }
        
        if(!changed){
            cout<<-1<<endl;
            return 0;
        }
        rep(i,n){
            if(t[i]!=n-1)changed=false;
        }
        if(changed){
            cout<<cou<<endl;
            return 0;
        }
        swap(que1,que2);
    }
}

Measured memory_bytes: 4352
#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <istream>
#define INF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
pair<int,int> a[100010];
int dp[200010];
int main(){
	int h,n;
	cin>>h>>n;
	for(int i=0;i<n;i++)cin>>a[i].first>>a[i].second;
	for(int i=0;i<=200000;i++)dp[i]=1000000000;
	dp[h]=0;
	for(int i=h;i>=1;i--){
		for(int j=0;j<n;j++){
			dp[(max(0,i-a[j].first))]=min(dp[max(0,i-a[j].first)],dp[i]+a[j].second);
		}
	}
	cout<<dp[0]<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b,m;
    cin>>a>>b>>m;
    ll arr[a],brr[b];
    for(int i=0;i<a;i++)cin>>arr[i];
    for(int i=0;i<b;i++)cin>>brr[i];
    ll m1=1e18,m2=1e18;
    for(int i=0;i<a;i++)m1=min(m1,arr[i]);
    for(int i=0;i<b;i++)m2=min(m2,brr[i]);
    ll ans=m1+m2;
    for(int i=0;i<m;i++)
    {
        ll x,y,c;
        cin>>x>>y>>c;
        x--;y--;
        ans=min(ans,max((ll)0,arr[x]+brr[y]-c));
    }
    cout<<ans;
}


Measured memory_bytes: 1792
#!/usr/bin/env/ python3
#S = input()
N = int(input())
#A, B, C = input().split()
#N, M = map(int, input().split())

#N = int(input())
#A = [int(x) for x in input().split()]

#H, W = map(int, input().split())
#S = [input() for _ in range(H)]
#print(S[0][1])

if N < 105: print("0")
elif N < 135: print("1")
elif N < 165: print("2")
elif N < 189: print("3")
elif N < 195: print("4")
else: print("5")

Measured memory_bytes: 3060
from collections import defaultdict

def main():
    n = int(input())
    a = list(map(int, input().split()))
    d = defaultdict(lambda: 0)
    ans = 0
    for i, ai in enumerate(a, 1):
        d[str(i+ai)] += 1
        ans += d[str(i-ai)]
    print(ans)
        

if __name__ == "__main__":
    main()

Measured memory_bytes: 72676
#include<iostream>
using namespace std;
int main(){
int x,y;
while(1){
cin>>x>>y;
if(x==0&&y==0) break;
if(x<=y) cout<<x<<" "<<y<<endl;
if(x>y)  cout<<y<<" "<<x<<endl;
}

return 0;
}

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

int main() {
    int l, r;
    std::cin >> l >> r;

    if (r - l >= 2019) {
        std::cout << 0 << std::endl;
    } else {
        int min = INT32_MAX;
        for (int i = l; i <= r; i++) {
            for (int j = i + 1; j <= r; j++) {
                min = std::min(min, ((i % 2019) * (j % 2019)) % 2019);
            }
        }

        std::cout << min << std::endl;
    }
}


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

int main(void){
  int w,h,x,y;
  cin >> w >> h >> x >> y;
  double answer = w * (double)h / 2;
  cout << answer << ' ';
  if((double)w / 2 == (double)x && (double)h / 2 == (double)y)cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const ll mod = 1e9+7;

//-------------------------<MATH>-------------------------------------------------------//
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
ll mult_mod(ll a , ll b){a = a%mod; b = b%mod;
ll c = (a * b)%mod;
//cout << a << " " << b << endl;
return c;}
ll add_mod(ll a , ll b){a = (a + mod)%mod;b = (b + mod)%mod;ll c = (a + b)%mod;return c;}
ll fac[(int)(5e5 + 5)] , inv_fac[(int)(5e5 + 5)];
void precomp_factorial(int M){fac[0] = 1;for(int i = 1 ; i <= M ; i++) fac[i] = mult_mod(i , fac[i - 1]);
    inv_fac[M] = inv(fac[M]);for(int i = M - 1 ; i >= 0 ; i--) inv_fac[i] = mult_mod(i + 1 , inv_fac[i + 1]);}
ll nCk(ll n , ll k){ll ans = fac[n];ans = mult_mod(ans , inv_fac[n - k]);ans = mult_mod(ans , inv_fac[k]);return ans;}
int lo[(int)(1e3 + 6)];
void sieve(int M){for(int i = 2 ; i < M ; i++){ if(lo[i]) continue; for(int j = i ; j < M ; j += i)lo[j] = i;}}
int max_expo_prime_n_fac(ll N , int prime){int ress = 0;while(N){ress += (N/prime);N /= prime;}return ress;}
//-------------------------</MATH>-------------------------------------------------------//

//-------------------------<STRING>-------------------------------------------------------//
string get_prefix(string x , int MAX){return x.substr(0 , min((int)x.size() , MAX));}
string get_suffix(string x,int MAX){int dn=1;for(int i=x.size()-1;i>=0;i--){if(dn==MAX)return x.substr(i);dn++;}return x;}
string convert_to_binary(int x,int len) {string ans=""; while(x){if(x&1){ans='1'+ans;}
    else{ans ='0'+ans;}x/=2;}int k = ans.size();while(k < len){ans = '0' + ans;k++;}return ans;}
//-------------------------</STRING>-------------------------------------------------------//

ull llrand() {ull r = 0;for(int i = 0; i < 5; ++i){r = (r << 15)|(rand() & 0x7FFF);}return r & 0xFFFFFFFFFFFFFFFFULL;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};
const int M = 60;

int arr[M][M];
bool vis[M][M];

int n, m;
int till = 0;

void reset(){
    till = 0;
    for(int i = 0 ; i <= n + 2 ; i++){
        for(int j = 0 ; j <= m + 2 ; j++){
            vis[i][j] = 0;
            arr[i][j] = 0;
        }
    }
}

bool inside(int x, int y){
    return (x >= 1 && x <= n && y >= 1 && y <= m);
}

void dfs(int x, int y){
    if(vis[x][y]) return;
    vis[x][y] = 1;
    if(arr[x][y] == 2) till++;
    for(int d = 0 ; d < 4 ; d++){
        int nx = x + dx[d];
        int ny = y + dy[d];
        if(inside(nx, ny) && (arr[nx][ny] == 0 || arr[nx][ny] == 2)){
            dfs(nx, ny);
        }
    }

}
int main(){

    int a;
    cin >> a;
    int sum = a+a*a+a*a*a;
    cout << sum;
}






Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main() {
     string S;
     cin >> S;
     int A = (S[0] - '0')*10 + S[1] - '0';
     int B = (S[2] - '0')*10 + S[3] - '0';

     if(1 <= A && A <= 12){
          if(1 <= B && B <= 12) cout << "AMBIGUOUS";
          else cout << "MMYY";
     }else{
          if(1 <= B && B <= 12) cout << "YYMM";
          else cout << "NA";
     }
}

Measured memory_bytes: 256