akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type pair struct{ v,fa int }

	var n, m int
	Fscan(in, &n, &m)
	g := make([][]int, n+1)
	for i := 0; i < m; i++ {
		var v, w int
		Fscan(in, &v, &w)
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	vis := make([]bool,n+1)
	ans := make([]int, n+1)
	q := []pair{{1,-1}}
	vis[1]=true
	cnt :=1
	for len(q) >0 {
		p := q[0]
		q=q[1:]
		v,fa := p.v,p.fa
		for _, w := range g[v] {
			if w != fa && !vis[w] {
				vis[w]=true
				cnt++
				ans[w]=v
				q = append(q, pair{w,v})
			}
		}
	}
	if cnt < n {
		Fprintln(out, "No")
		return
	}
	Fprintln(out, "Yes")
	for _, v := range ans[2:] {
		Fprintln(out, v)
	}
}

func main() { run(os.Stdin, os.Stdout) }


Measured memory_bytes: 24424
#include<bits/stdc++.h>
using namespace std;
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL); \
    cout.tie(NULL)
#define inc(x, y, i) for (int i = x; i <= y; i++)
#define dec(x, y, i) for (int i = x; i >= y; i--)
#define repeat(n) for (int i = 0; i<n;i++)

#define ll long long
#define ld long double
#define ull unsigned long long
#define infl LONG_MAX
#define infi INT_MAX
#define nl cout<<'\n'

#define all(v) v.begin(),v.end()
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define mkpr make_pair
#define pq priority_queue
/*void show(auto v){
    for(auto t : v)cout << t <<" ";cout <<endl;
}

void printAr(int a[],int n)  // print the array
{
    for(int *i = a; i!=a+n; ++i)cout << *i << " ";
    cout << endl;
}*/
const int N = 3000+6;
int a[N];
vector<int> v[N];
int dp[N];
int main()
{
    fastio;
    int n;
    cin >> n;
    cout << 1-n<<endl;

}


Measured memory_bytes: 3716
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999



int main() {
	bool flg = true;
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (i % 2 && S[i] == 'R') {
			flg = false;
			break;
		}
		if (i % 2 == 0 && S[i] == 'L') {
			flg = false;
			break;
		}
	}
	if (flg)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

int main(){
  int k, n;
  cin >> k >> n;
  vector<int> vec(n+1);
  for(int i=0; i<n; ++i){
    cin >> vec.at(i);
  }
  vec.at(n) = k;
  int x = vec.at(0);
  for(int i=0; i<n; ++i){
    vec.at(i) -= x;
  }
  int mxdis=0;
  for(int i=0; i<n; ++i){
    mxdis = max(mxdis, vec.at(i+1)-vec.at(i));
  }
  cout << k-mxdis << endl;
}

Measured memory_bytes: 1024
/*
Look at the star
Look at the shine for U
*/
#include<bits/stdc++.h>
#define ll long long
#define PII pair<int,int>
#define sl(x) scanf("%lld",&x)
using namespace std;
const int N = 1e6+5;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
ll inv(ll b){if(b==1)return 1; return (mod-mod/b)*inv(mod%b)%mod;}
ll fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n%mod;n=n*n%mod;}return r;}
char s[N];
int main()
{
	scanf("%s",s);
	for(int i = 0;s[i];i++)
		if(s[i] == '9') s[i] = '1';
		else s[i] = '9';
	puts(s);

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a;
	int b;
	int c;
	cin >> a >> b;
	if (a == 2) {
		cout << "No" << "\n";
	}
	else if (b == 2) {
		cout << "No" << "\n";
	}
	else {
		cout << "Yes" << "\n";
	}
	cin >> c;
}

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

int ans = 20;

void trim(vector<int>& grid)
{
  for (vector<int>::iterator it(grid.begin()); it != grid.end(); ) {
    if (*it == 0) {
      it = grid.erase(it);
    } else {
      ++it;
    }
  }
}

void dfs(const vector<int>& grid)
{
  int N = grid.size();
  ans = min(ans, N);
  if (ans == 0) {
    return;
  }
  for (int i = 0; i < N; i++) {
    // left
    if (i%4 != 0 && grid[i-1] == grid[i]) {
      vector<int> v(grid);
      v[i-1] = v[i] = 0;
      trim(v);
      dfs(v);
      if (ans == 0) {
        return;
      }
    }
    // left-down
    if (i%4 != 0 && i+3 < N && grid[i] == grid[i+3]) {
      vector<int> v(grid);
      v[i+3] = v[i] = 0;
      trim(v);
      dfs(v);
      if (ans == 0) {
        return;
      }
    }
    // down
    if (i+4 < N && grid[i] == grid[i+4]) {
      vector<int> v(grid);
      v[i+4] = v[i] = 0;
      trim(v);
      dfs(v);
      if (ans == 0) {
        return;
      }
    }
    // right-down
    if (i%4 != 3 && i+5 < N && grid[i] == grid[i+5]) {
      vector<int> v(grid);
      v[i+5] = v[i] = 0;
      trim(v);
      dfs(v);
      if (ans == 0) {
        return;
      }
    }
  }
}

int main()
{
  int N;
  cin >> N;
  while (N-- > 0) {
    ans = 20;
    vector<int> grid(20);
    for (int i = 0; i < 20; i++) {
      cin >> grid[i];
    }
    dfs(grid);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;

int main() {
  int a,b;
  cin >> a >> b;
  if(b==100)b++;
  if(a==0){
    cout << b << endl;
  }else if(a==1){
    cout << 100*b << endl;
  }else{
    cout << 10000*b << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

int main(){
    string S;
    cin >> S;
    int ans;
    ans = max((S.at(0) - '0')*100 + (S.at(1) - '0')*10 + (S.at(2) - '0') - 753,753-((S.at(0) - '0')*100 + (S.at(1) - '0')*10 + (S.at(2) - '0')));
    rep(i,S.len - 2){
        ans = min(ans,max((S.at(i) - '0')*100 + (S.at(i+1) - '0')*10 + (S.at(i+2) - '0')-753,753-((S.at(i) - '0')*100 + (S.at(i+1) - '0')*10 + (S.at(i+2) - '0'))));
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
    int N;
    string s;
    cin >> N, cin >> s;
    int r = 0, b = 0;
    for (int i = 0; i < N; ++i) {
        if (s[i] == 'R') ++r;
        else if (s[i] == 'B') ++b;
    }
    cout << ((r > b) ? "Yes" : "No") << endl;
    return 0;
}

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

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

int main() {
    int n, t1, t2;
    cin >> n;
    cin >> t1;
    for (int i = 1; i < n; i++) {
        cin >> t2;
        t1 = gcd(t1, t2);
    }
    cout << t1 << endl;
    return 0;
}

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

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

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=4e5+5;
int n,m,fa[N],tot,head[N],nex[N],to[N];
bool vis[N];
void add(int u,int v){to[++tot]=v;nex[tot]=head[u];head[u]=tot;}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int u,v;scanf("%d%d",&u,&v);add(u,v);add(v,u);
    }
    queue<int>q;
    q.push(1);vis[1]=true;
    while(!q.empty())
    {
        int u=q.front();q.pop();
        for(int i=head[u];i;i=nex[i])
        {
            int v=to[i];if(vis[v])continue;
            vis[v]=true;fa[v]=u;q.push(v);
        }
    }
    for(int i=2;i<=n;i++)
        if(!vis[i])
    {
        printf("No\n");return 0;
    }
    printf("Yes\n");
    for(int i=2;i<=n;i++) printf("%d\n",fa[i]);
}


Measured memory_bytes: 7704
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=1e9+7;
const long double PI = acos(-1),eps=1.0e-14;
void solve(){
    ll n;
    cin>>n;
    ll res=1e18;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            min_self(res,n/i+i-2);
        }
    }
    cout<<res<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3632
<?php

// $fp = fopen('xxx.txt','r');
$fp = STDIN;

while(($input = fgets($fp)) !== false){
  list($a, $b, $c, $d, $e, $f) = explode(' ', trim($input));

  $x = ($e*$c - $b*$f)/($a*$e - $b*$d);
  $y = ($a*$f - $d*$c)/($a*$e - $b*$d);
  
  $roundedX = round($x,3);
  $roundedY = round($y,3);

  printf( "%.3f %.3f\n", $roundedX, $roundedY);
}

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

int main(){
	string s;
	cin >> s;
	map<char, char>m;
	m['D'] = 'A';
	m['E'] = 'B';
	m['F'] = 'C';
	m['G'] = 'D';
	m['H'] = 'E';
	m['I'] = 'F';
	m['J'] = 'G';
	m['K'] = 'H';
	m['L'] = 'I';
	m['M'] = 'J';
	m['N'] = 'K';
	m['O'] = 'L';
	m['P'] = 'M';
	m['Q'] = 'N';
	m['R'] = 'O';
	m['S'] = 'P';
	m['T'] = 'Q';
	m['U'] = 'R';
	m['V'] = 'S';
	m['W'] = 'T';
	m['X'] = 'U';
	m['Y'] = 'V';
	m['Z'] = 'W';
	m['A'] = 'X';
	m['B'] = 'Y';
	m['C'] = 'Z';
	for (int i = 0; i < s.size(); i++) {
		cout << m[s[i]];
	}
	cout << "\n";
	return 0;
}

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

deque<int> q;
int dis[100005];

int main() {
	int n;
	scanf("%d",&n);
	memset(dis,0x7f,sizeof(dis));
	dis[1]=1;
	q.push_back(1);
	while(!q.empty()) {
		int u=q.front();
		q.pop_front();
		if(dis[(u*10)%n]>dis[u]) {
			dis[(u*10)%n]=dis[u];
			q.push_front((u*10)%n);
		}
		if(dis[(u+1)%n]>dis[u]+1) {
			dis[(u+1)%n]=dis[u]+1;
			q.push_back((u+1)%n);
		}
	}
	printf("%d\n",dis[0]);
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 1000005
ll arr[MAX+2];
bool check()
{
    for(int i=2;i<MAX;i++){
        if(arr[i]>1) return false;
    }
    for(int i=2;i<MAX;i++)
    {
        ll cnt=0;
        for(int j=i;j<MAX;j+=i){
            if(arr[j]==1) cnt++;
        }
        if(cnt>1) return false;
    }
    return true;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n; cin>>n;
    ll gcd=0;
    for(int i=1;i<=n;i++) {
        ll a; cin>>a;
        gcd=__gcd(gcd,a);
        arr[a]++;
    }
    if(check())
    {
        cout<<"pairwise coprime"<<endl;
        return 0;
    }
    if(gcd==1){
        cout<<"setwise coprime"<<endl;
        return 0;
    }
    cout<<"not coprime"<<endl;
    
    
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;
#define INF 1e9

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



int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n){
    cin >> a[i];
  }
 
  if(n % 2==0){
    for(int i = n-1; i >= 0; i-=2){
      cout << a[i] << " ";
    }
    for(int j = 0; j < n; j+=2){
      cout << a[j];
      if(j!= n-1)
        cout << " ";
    }
  }
  else{
    for(int i = n-1; i >= 0; i-=2){
      cout << a[i] << " ";
    }
    for(int i = 1; i < n; i+=2){
      cout << a[i];
      if(i!= n-1)
        cout << " ";
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 2944
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<climits>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll h,n; cin >> h >> n;
  ll sum = 0; 
  for(int i=0;i<n;i++){
    ll a; cin >> a;
    sum += a;
  }
  if(sum >= h) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

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


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<ll> primes;

// 正の整数n未満の素数を全て求める
vector<ll> sieve(ll n) {
  vector<bool> is_prime(n);
  rep(i, n) is_prime[i] = true;

  is_prime[1] = false;
  for (ll i = 4; i < n; i += 2) is_prime[i] = false;
  ll lim = ll(sqrt(n));
  for (ll i = 3; i <= lim; i += 2) {
    for (ll j = 3; i * j < n; j += 2) {
      is_prime[i * j] = false;
    }
  }

  vector<ll> ret;
  for (ll i = 1; i < n; i++) {
    if (is_prime[i]) ret.push_back(i);
  }
  return ret;
}

ll solve2(ll n) {
  ll ret = 0;

  ll len = primes.size();
  for (int i = 0; i < len; i++) {
    ll sum = primes[i];
    for (int j = i + 1; j < len; j++) {
      if (sum == n) ret++;
      if (sum >= n) break;
      sum += primes[j];
    }
  }

  return ret;
}

void solve() {
  primes = sieve(10000);

  while (true) {
    ll n; cin >> n;
    if (n == 0) break;
    outl(solve2(n));
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}



Measured memory_bytes: 3180
// --------------
// Tejas Pandey  |
// 24 - 08 - 19  |
// JSC 2019 QF   |
// --------------

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		int m,d;
		cin >> m >> d;
		int ans = 0;
		for(int i = 10;i <= d;i++){
			if(i%10 > 1 && (i/10)%10 > 1 && (i%10)*((i/10)%10) <= m)
			ans++;
		}
		cout << ans;
	}
	return 0;
}

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

using namespace std;

vector<int>v1('z'-'a'+1, 0);
vector<int>v2('z'-'a'+1, 0);

int count(string &s1, string &s2){
    v1 = vector<int>('z'-'a'+1, 0);
    v2 = vector<int>('z'-'a'+1, 0);

    for(int i = 0; i < s1.size(); i++)
        v1[s1[i]-'a']++;
    for(int i = 0; i < s2.size(); i++)
        v2[s2[i]-'a']++;
    
    int count = 0;
    for(int i = 0; i < v2.size(); i++)
        count += v1[i] != 0 and v2[i] != 0;
    return count;
}

int main(){

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout.precision(20);


    int n;
    cin >> n;
    string s, s1, s2;
    cin >> s;
    int ans = 0;
    for(int i = 1; i < n; i++){
        s1 = s.substr(0, i);
        s2 = s.substr(i, n-i);
        ans = max(ans, count(s1,s2));
    }
    cout << ans << endl;
}
    

Measured memory_bytes: 256
while 1:
 n=int(input())
 if n==0:break;
 a=[]
 for i in range(n):
  b=list(map(int,input().split()))
  a+=[b+[sum(b)]]
  for s in a[i]:print("%5d"%s,end='')
  print()
 for c in zip(*a):print("%5d"%sum(c),end='')
 print()


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define int long long
using namespace std;

struct edge { int from, to, cost; };

vector<vector<int>> Gf; // forward
vector<vector<int>> Gr; // reverse

void print(const vector<auto>& v) {
    for (auto e : v) {
        cerr << e << " ";
    }
    cerr << endl;
}

void dfs(int u, vector<bool>& vis) {
    vis[u] = true;
    for (int v : Gf[u]) {
        if (vis[v]) continue;
        dfs(v, vis);
    }
}

void dfsr(int u, vector<bool>& vis) {
    vis[u] = true;
    for (int v : Gr[u]) {
        if (vis[v]) continue;
        dfsr(v, vis);
    }
}

signed main() {
    int N, M, P;
    cin >> N >> M >> P;
    vector<edge> es(M);
    Gf.resize(N);
    Gr.resize(N);
    for (auto& e : es) {
        cin >> e.from >> e.to >> e.cost;
        e.cost -= P;
        e.cost *= -1;
        e.from--; e.to--;
        Gf[e.from].push_back(e.to);
        Gr[e.to].push_back(e.from);
    }

    vector<bool> ff(N);
    dfs(0, ff);
    vector<bool> fr(N);
    dfsr(N - 1, fr);

    vector<bool> f(N);
    for (int i = 0; i < N; i++) {
        f[i] = ff[i] & fr[i];
    }

    const int inf = 1e18;
    vector<int> d(N, inf);
    d.front() = 0;
    bool upd = false;
    int n = 2 * N;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < M; j++) {
            edge e = es[j];
            if (!f[e.from]) continue;
            if (!f[e.to]) continue;
            if (d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                if (i == n - 1) {
                    upd = true;
                }
            }
        }
    }
    cout << (upd ? -1 : max(0LL, -d[N - 1])) << endl;
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll a, b;
  cin >> a >> b;

  if (a == 1 && b != 1) {
    cout << "Alice" << endl;
    return 0;
  }
  if (a != 1 && b == 1) {
    cout << "Bob" << endl;
    return 0;
  }

  if (a > b) {
    cout << "Alice" << endl;
  } else if (a < b) {
    cout << "Bob" << endl;
  } else {
    cout << "Draw" << endl;
  }
  
  return 0;
}

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

typedef long long ll;

int main() {
	ll x, y;
	cin >> x >> y;
	
	set<ll> s;
	s.insert(x);
	while (x <= y) {
		for (auto i : s) {
			auto g = __gcd(x, i);
			x *= i / g;
		}

		if (s.find(x) != s.end()) {
			x *= 2LL;
		} else {
			s.insert(x);
		}
	}

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

	return 0;
}


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

int main()
{
    string S, T;
    cin >> S >> T;

    int count = 0;
    if (S[0] == T[0]) {
        count++;
    }
    if (S[1] == T[1]) {
        count++;
    }
    if (S[2] == T[2]) {
        count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int gcb(int a, int b){
	int temp;
	if(a < b){
		temp = a;
		a = b;
		b = temp;
	}
	if(a % b == 0)
		return b;
	else
		return gcb(b, a % b);

}

int main(void){

	long SUM;
	int K, i, j ,l, t;
	scanf("%d", &K);

	SUM = 0;

	for(i = 1; i <= K;i++){
			for(j = 1; j <= K;j++){
					for(l = 1; l <= K;l++){
						t = gcb(i,j);
						SUM = SUM + gcb(t,l);
						
					}
			}
	}

	printf("%ld", SUM);
	return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


struct edge{
    int to;
    int cost;
};

vector<edge> tree[100001];
ll cost[100001];

void dfs(int v, int p, ll c){
    cost[v] = c;
    for(auto &edge : tree[v]){
        if(edge.to == p) continue;
        dfs(edge.to, v, c + edge.cost);
    }
}


int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n;
    int q, k;
    cin >> n;
    REP(i, n - 1){
        int a, b, c;
        cin >> a >> b >> c;
        tree[a].push_back({b, c});
        tree[b].push_back({a, c});
    }
    cin >> q >> k;
    dfs(k, 0, 0);
    REP(i, q){
        int x, y;
        cin >> x >> y;
        cout << cost[x] + cost[y] << "\n";
    }

    return 0;
}



Measured memory_bytes: 12800
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10**6)
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A, B, C, S):
    D = [A, B, C]
    ans = []

    def f(s):
        t = []
        if 'A' in s:
            t.append(0)
        if 'B' in s:
            t.append(1)
        if 'C' in s:
            t.append(2)
        return t
    for i, s in enumerate(S):
        t = f(s)
        if D[t[0]] == 0 and D[t[1]] == 0:
            print('No')
            return
        else:
            if D[t[0]] == D[t[1]] == 1 and i != N-1:
                ns = S[i+1]
                if s == ns:
                    ans.append(t[1])
                    D[t[0]] -= 1
                    D[t[1]] += 1
                else:
                    n = set(t) & set(f(ns))
                    m = set(t) - n
                    n = n.pop()
                    m = m.pop()
                    ans.append(n)
                    D[n] += 1
                    D[m] -= 1


            elif D[t[0]] > D[t[1]]:
                ans.append(t[1])
                D[t[0]] -= 1
                D[t[1]] += 1
            else:
                ans.append(t[0])
                D[t[0]] += 1
                D[t[1]] -= 1

    print('Yes')
    for a in ans:
        if a == 0:
            print('A')
        elif a == 1:
            print('B')
        else:
            print('C')



def main():
    N, A, B, C = read_int_n()
    S = [read_str() for _ in range(N)]
    (slv(N, A, B, C, S))


    # N = 10**5
    # A = random.randint(1, 10**9)
    # B = random.randint(1, 10**9)
    # C = random.randint(1, 10**9)
    # S = random.choices(['AB', 'AC', 'BC'], k=N)
    # (slv(N, A, B, C, S))

if __name__ == '__main__':
    main()


Measured memory_bytes: 90616
#include <bits/stdc++.h>
using namespace std;
 
#define froop1(a,n) for(long long i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	long long N,dist;
  cin >> dist >> N;
  vector<long long> house(N);
  house.at(0) = 0;
  froop1(0,N){
    cin >> house.at(i);
  }
  vector<long long> a;
  a.push_back(dist - house.at(N - 1) + house.at(0));
  froop1(1,N){
    a.push_back(house.at(i) - house.at(i - 1));
  }
  long long maxd = 0;
  froop1(0,a.size()){
    maxd = max(maxd,a.at(i));
  }
  cout << dist - maxd << endl;
  
  
 }

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

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
  const long MOD = pow(10, 9) + 7;
  long N;
  long ans;
  long a = 1, b = 1, c = 1;
  cin >> N;
  a = modpow(10, N, MOD);
  b = 2 * modpow(9, N, MOD) % MOD;
  c = modpow(8, N, MOD);
  ans = a - b + c;
  if(ans < 0) ans += MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    transform(a.begin(), a.end(), a.begin(), ::toupper);
    transform(b.begin(), b.end(), b.begin(), ::toupper);
    transform(c.begin(), c.end(), c.begin(), ::toupper);

    cout << a[0] << b[0] << c[0] << endl;
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE OverloadedStrings #-}
import Control.Monad
import Data.Char
import Data.Maybe
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

main :: IO ()
main = do
  (n,m) <- getHogeVab readIntV
  h <- V.thaw =<< V.unfoldrN n readIntV <$> B.getLine
  -- h <- VM.new n
  ma <- VM.replicate (max m n) 0

  -- forM_ [0..(n-1)] $ \i -> do
  --   getInt >>= VM.write h i

  forM_ [0..(m-1)] $ \_ -> do
    (a,b) <- getHogeVab readIntV
    max <$> (VM.read ma (a-1)) <*> (VM.read h (b-1)) >>= VM.write ma (a-1)
    max <$> (VM.read ma (b-1)) <*> (VM.read h (a-1)) >>= VM.write ma (b-1)

  forM_ [0..(n-1)] $ \i -> do
    ma' <- VM.read ma i
    h'  <- VM.read h i
    if ma' < h'
      then VM.write ma i 1
      else VM.write ma i 0

  print =<< return . V.sum =<< V.freeze ma

----------------------------------------------------------------------

tupleToBString (m,n) = B.concat [m,n]

tuplify2 (x:y:_) = (x,y)
tuplify2 _ = undefined

readInt = fst . fromJust . B.readInt
readIntTuple = tuplify2 . map readInt . B.words
readIntList = map readInt . B.words

readIntV = B.readInt . B.dropWhile isSpace
getIntV n = getHogeV readIntV n
getHogeV f n = V.unfoldrN n f <$> B.getLine
getHogeVab f = (\vec -> (vec V.! 0, vec V.! 1)) <$> getHogeV f 2
getHogeVabs f n = V.replicateM n <$> getHogeVab f

getInt = fmap readInt B.getLine
getIntList = fmap readIntList B.getLine
getIntNList n = fmap (map readIntList) $ replicateM (fromIntegral n) B.getLine
getIntNtuple n = replicateM n $ tuplify2 . B.words <$> B.getLine
getIntVec n = V.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine

toDouble x = fromInteger x :: Double


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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

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

int main() {
	int n;
	cin >> n;
	vector<ll> a(n+1), b(n);
	rep(i,n+1) cin >> a[i];
	rep(i,n) cin >> b[i];
	ll ans=0;
	rep(i,n) {
			ll temp = min(a[i], b[i]);
			ans += temp;
			ans += min(a[i+1], (b[i] - temp));
			a[i+1] = max(a[i+1]-(b[i] - temp),(ll)0);
	}
	cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<deque>
using namespace std;

using ll = long long;

int main(void)
{
    string s;
    cin >> s;

    bool isOk = true;
    for (int i = 0; i < (s.size() - 1) / 2; i++) {
        if (s[i] == s[s.size() - 1 - i]) {
            continue;
        } else {
            isOk = false;
        }
    }

    for (int i = 0; i < (s.size() - 1) / 2 / 2; i++) {
        if (s[i] == s[(s.size() - 1) / 2 - 1 - i]) {
            continue;
        } else {
            isOk = false;
        }
    }

    for (int i = (s.size() - 1) / 2 + 1; i < s.size(); i++) {
        if (s[i] == s[s.size()- 1 - i]) {
            continue;
        } else {
            isOk = false;
        }
    }

    if (isOk) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
n, m = map(int, input().split())
xy = []
for i in range(m):
    xy.append(list(map(int, input().split())))

x = 0
y = 1

# 0-indexに揃える
for _xy in xy:
    _xy[x] -= 1
    _xy[y] -= 1

red = [False] * n
red[0] = True
ballCnt = [1] * n

for i in range(m):
    # ボール移動
    ballCnt[xy[i][x]] -= 1
    ballCnt[xy[i][y]] += 1

    if red[xy[i][x]]:
        red[xy[i][y]] = True

    if ballCnt[xy[i][x]] == 0:
        red[xy[i][x]] = False

# print(red)

ans = 0
for r in red:
    if r:
        ans += 1
print(ans)

Measured memory_bytes: 28964
MOD = int(1e9) + 7

def main():
    buf = input()
    buflist = buf.split()
    N = int(buflist[0])
    M = int(buflist[1])
    a = []
    for i in range(M):
        buf = input()
        a.append(int(buf))
    a.append(N+9999) # sentinel
    pattern = [1]
    for i in range(1, N+10):
        pattern.append(0)
    pointer = 0
    for i in range(0, N+2):
        if a[pointer] == i:
            pattern[i] = 0
            pointer += 1
        pattern[i+1] = (pattern[i+1] + pattern[i]) % MOD
        pattern[i+2] = (pattern[i+2] + pattern[i]) % MOD
    print(pattern[N])

if __name__ == '__main__':
    main()


Measured memory_bytes: 7852
#include <stdio.h>

int main(int argc, char *argv[])
{
	char buf[5];
	int i;
	int count = 0;

	scanf("%s", buf);
	for (i = 0; i < 4; i++) {
		if (buf[i] == '+') {
			count++;
		} else {
			count--;
		}
	}

	printf("%d\n", count);


	return 0;
}


Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BMultipleOf9 {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        string s;
        cin >> s;

        int res = 0;
        for (int i = s.size() - 1; i >= 0; i--) {
            res *= 10;
            res %= 9;
            res += s[i] - '0';
            res %= 9;
        }
        cout << (res == 0 ? "Yes" : "No") << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BMultipleOf9 solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,k,q;
cin>>n>>k>>q;
int a[100005];
  for(int i = 0; i<n; i++){
      a[i] = k;
  }
  int x[100005];
  
  for(int j = 0; j<q; j++){
      cin>>x[j];
      a[x[j]-1] = a[x[j]-1]+1;
      
  }
  
  for(int i = 0; i<n; i++){
      if(a[i]-q>0){
          cout<<"Yes"<<endl;
      }
      else{
          cout<<"No"<<endl;
      }
  }
  
  return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

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

 		int h = sc.nextInt();
 		int w = sc.nextInt();

 		System.out.println((H-h)*(W-w));
 	}
}


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

int main() {
  int A, B, C, X, Y;
  int x =0;
  cin >> A >> B >> C >> X >> Y;
  
  if (A+B<2*C) x=A*X+B*Y;
  else {
    x += min(X,Y)*2*C;
    if (X<Y) {
      if (B>2*C) x += (Y-X)*2*C;
      else x += (Y-X)*B;
    }
    else {
      if (A>2*C) x += (X-Y)*2*C;
      else x+= (X-Y)*A;
    }
  }

  cout << x << endl;

}



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

int top=0,S[1000];

void push(int x){
    S[++top]=x;
}

int pop(){
    top--;
    return S[top+1];
}

int main() {
    int a,b;
    char s[100];
    while(scanf("%s",s)!=EOF){
        if(s[0]=='+'){
            a=pop();
            b=pop();
            push(a+b);
        }
        else if(s[0]=='-'){
            b=pop();
            a=pop();
            push(a-b);
        }
        else if(s[0]=='*'){
            a=pop();
            b=pop();
            push(a*b);
        }
        else{
            push(atoi(s));
        }
    }
    printf("%d\n",pop());
	return 0;
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int l,r,d;
  cin>>l>>r>>d;
  int ans=0;
  rep2(i,l,r+1){
    if(i%d==0)ans++;
  }
  cout<<ans<<endl;
  return(0);
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> pii;
#define FOR(i, n) for(LL i = 1; i<=n; i++)
#define F0R(i, n) for(LL i = 0; i<n; i++)
#define mp make_pair
#define pb push_back
#define f first
#define s second


//var 
LL n, trr[400005], trc[400005], q, tt, gg;

void upr(LL l, LL r, LL g){
	for(l += n, r += n; l<r; l/=2, r/=2){
		if(l % 2){
			trr[l] = min(trr[l], g);
			l++;
		}
		if(r%2){
			r--;
			trr[r] = min(trr[r], g);
		}
	}
}

void upc(LL l, LL r, LL g){
	for(l += n, r += n; l<r; l/=2, r/=2){
		if(l % 2){
			trc[l] = min(trc[l], g);
			l++;
		}
		if(r%2){
			r--;
			trc[r] = min(trc[r], g);
		}
	}
}

LL ger(LL g){
	LL res = trr[g += n];
	for( ;g>1; g/=2)
		res = min(res, trr[g/2]);
	return res;
}

LL gec(LL g){
	LL res = trc[g += n];
	for(; g>1; g/=2)
		res = min(res, trc[g/2]);
	return res;
}


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

	cin >> n >> q; n -= 2;
	FOR(i, 2*n) trr[i] = n+1;
	FOR(i, 2*n) trc[i] = n+1;
	LL ans = n*n;
	while(q--){
		cin >> tt >> gg;
		tt--; gg--;
		if(tt){
			LL mn = ger(gg-1);
			ans -= mn-1;
			upc(0,mn-1, gg);
			upr(gg-1, gg-1, 1);
			continue;
		}
		LL mn = gec(gg-1);
		ans -= mn-1;
		upr(0, mn-1, gg);
		upc(gg-1, gg-1, 1);
	}

	cout << ans << endl;

	cout.flush();
	return 0;
}

Measured memory_bytes: 9836
///
// File:  alds1_10_b.cpp
// Author: ymiyamoto
//
// Created on Tue Oct 17 21:37:26 2017
//

#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

static vector<uint32_t> matrix(101, 0);
static uint64_t dp[101][101];

int32_t main()
{
  uint32_t n;
  cin >> n;

  for (uint32_t i = 1; i <= n; i++) {
    cin >> matrix[i - 1] >> matrix[i];
  }

  for (uint32_t l = 2; l <= n; l++) {
    for (uint32_t i = 1; i <= n - l + 1; i++) {
      uint32_t j = i + l - 1;
      uint64_t min_val = UINT64_MAX;
      for (uint32_t k = i; k <= j - 1; k++) {
        min_val = min(min_val, dp[i][k] + dp[k + 1][j] + matrix[i - 1] * matrix[k] * matrix[j]);
      }
      dp[i][j] = min_val;
    }
  }

  cout << dp[1][n] << endl;

  return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>

using namespace std;

int x[4], y[4];
bool used[4][4];

bool valid(int i, int j) {
    if (0 <= i && i < 4 && 0 <= j && j < 4) return true;
    return false;
}

int dfs(int i1, int j1) {
    int i2, j2;
    if (valid(i1, j1+1)) {
        i2 = i1;
        j2 = j1+1;
    } else if (valid(i1+1, 0)) {
        i2 = i1+1;
        j2 = 0;
    } else {
        i2 = j2 = -1;
    }

    if (used[i1][j1]) {
        if (i2 != -1) return dfs(i2, j2);
        return 1;
    }
    int ret = 0;
    for (int i=0; i<4; ++i) {
        if (valid(i1+y[i], j1+x[i]) && ! used[i1+y[i]][j1+x[i]]) {
            used[i1][j1] = used[i1+y[i]][j1+x[i]] = true;
            ret += dfs(i2, j2);
            used[i1][j1] = used[i1+y[i]][j1+x[i]] = false;
        }
    }
    return ret;
}

int main() {
    while (cin >> x[0], x[0] < 4) {
        cin >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3];
        cout << dfs(0, 0) << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;


vector<Int> factorize(Int N){
    vector<Int> res;
    for(Int i=1; i*i<=N; i++){
        if(N % i == 0){
            res.push_back(i);
            if(i*i != N) res.push_back(N/i);
        }
    }
    return res;
}


int main(){
   Int N; cin >> N;

   vector<Int> f1 = factorize(N);
   vector<Int> f2 = factorize(N-1);

   Int ans = f2.size()-1;

   rep(i, f1.size()){
       if(f1[i] == 1) continue;

       Int now = N;
       while(now % f1[i] == 0) now /= f1[i];

       if(now % f1[i] == 1){
           ans++;
       }
   }

   cout << ans << endl;

    
}

Measured memory_bytes: 384
L, R = map(int, input().split())

MOD = 2019

v = []
if R+1 - L < MOD:
    for i in range(L, R+1):
        v.append(i % MOD)
else:
    v = list(range(0, MOD))
v.sort()

ans = MOD+1
for i in range(len(v)):
    for j in range(i+1, len(v)):
        tmp = v[i] * v[j] % MOD
        if tmp < ans:
            ans = tmp

print(ans)


Measured memory_bytes: 40912
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
#define MOD 1000000007
using namespace std;

int main() {
	int n, m;
	cin >> n;
	vector<int>T(n);
	REP(i, n) {
		cin >> T[i];
	}
	cin >> m;
	int p, x;
	REP(i, m) {
		cin >> p >> x;
		int time = 0;
		REP(j, n) {
			if (j == p - 1) {
				time += x;
			}
			else {
				time += T[j];
			}
		}
		cout << time << endl;
	}
	return 0;
}

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


int getDigit(int a){
  return (int)log10(a)+1;
}


int main(){
  int n,k;
  bool jud1=false;
  bool jud2=true;
  int tl;
  int x;
  std::cin>>n>>k;
  int dig[k];
  for(int i=0;i<k;i++){
    std::cin>>dig[i];
  }
  
  tl=n-1;
  while(!jud1){
    tl++;
    x=tl;
    for(int i=0;i<getDigit(tl);i++){
      for(int j=0;j<k;j++){
        if((x%10)==dig[j]){
          jud2=false;
          break;
        }
      }
      if(jud2==false){
        break;
      }else{
        x=x/10;
      }
    }
    if(jud2==true){
      jud1=true;
    }
    jud2=true;
  }
  std::cout<<tl<<std::endl;

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    ll dp[N+1][2] = {};
    rep(i,0,N)cin >> A[i];
    dp[1][0] = dp[1][1] = A[0];
    dp[2][0] = A[0] + A[1];
    dp[2][1] = -A[0] - A[1];
    rep(i,2,N){
        dp[i+1][0] = max(dp[i][0] + A[i], dp[i][1] + A[i]);
        dp[i+1][1] = max(dp[i][0] - A[i-1] * 2 - A[i], dp[i][1] + A[i-1] * 2 - A[i]);
    }
    rep(i,0,N+1){
        //cout << dp[i][0] << " " << dp[i][1] << endl;
    }
    cout << max(dp[N][0],dp[N][1]) << endl;
}

Measured memory_bytes: 2560
# -*- coding:utf-8 -*-                                                                                     
import sys

def is_unbalanced(n, li_part):
    li_uniq = set(li_part)

    for c in li_uniq:
        if li_part.count(c) > n/2. :
            return 1

    return 0

li_c = list(input())
N = len(li_c)

for size_frame in range(2, 4):
    i = 0

    while(i + size_frame <= N):
        if(is_unbalanced(size_frame, li_c[i:i+size_frame]) == 1):
            print( i+1, i+1 + size_frame -1) # 自然な文字列の順番にする                                    
            sys.exit()

        i = i + 1

print(-1, -1)


Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

const int maxnum = 50;
int num = 0;

// グラフを 2 次元ベクトルで表示
bool graph[maxnum][maxnum];
bool besucht[maxnum];

void einstellen(){
	for( int i = 0; i < maxnum; ++i ){
		besucht[i] = false;
		for( int j = 0; j < maxnum; ++j ) graph[i][j] = false;
	}
}

void init(){
	for( int i = 0; i < num; ++i ) besucht[i] = false;
}

bool check(){
	for( int i = 0; i < num; ++i ){
		if( besucht[i] == false ){
			return true;
		}
	}
	return false;
}

void dfs( int n ){
	if( besucht[n] == false ){
		besucht[n] = true;
		for( int i = 0; i < num; ++i ){
			if( i != n && besucht[i] == false && graph[n][i] == true ) dfs(i); 
		}
	}
}

int main(){
	int m;
	cin >> num >> m;
	int ans = 0;
	vector<pair<int, int>> v;
	einstellen();
	for( int i = 0; i < m; ++i ){
		int x, y;
		cin >> x >> y;
		--x; --y;
		v.emplace_back(x, y);
		graph[x][y] = graph[y][x] = true;
	}
	for( int i = 0; i < m; ++i ){
		int x = v.at(i).first, y = v.at(i).second;
		graph[x][y] = graph[y][x] = false;
		init();
		// dfs でノードを探索していく
		// 0 からスタートして 1 箇所でも行けないところがあったら連結でない
		dfs(0);
		if( check() ) ++ans;
		graph[x][y] = graph[y][x] = true;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from itertools import product


def solve(string):
    n = int(string)
    ans = 0
    for i in range(3, len(str(n)) + 1):
        tmp = (int("".join(x))
               for x in product("753", repeat=i)
               if "7" in x and "5" in x and "3" in x)
        ans += len([x for x in tmp if x <= n])
    return str(ans)


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


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

int main()
{
  string s;
  cin >> s;

  int flag = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A') {
      if (s[i+1] == 'C') {
        flag = 1;
        break;
      }
    }
  }

  if (flag == 1) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,edge[3];
	cin >>n;
	for(int i=0; i<n; i++){
		cin >>edge[0] >>edge[1] >>edge[2];
		for(int l=0; l<3; l++){
			for(int m=0 ;m<2 ;m++){
				if(edge[m]<edge[m+1]){
					int c = edge[m];
					edge[m] = edge[m+1];
					edge[m+1] = c;
				}
			}
		}
		for(int l=0; l<3; l++){edge[l]=edge[l]*edge[l];}
		if(edge[0] == edge[1]+edge[2]){cout <<"YES"<<endl;}
		else{cout<<"NO"<<endl;}
	}
	return 0;
}

Measured memory_bytes: 0
import sys
from bisect import bisect_left
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def main():
    A, B, Q = map(int, readline().split())
    stx = list(map(int, read().split()))
    s = stx[:A]; t = stx[A:-Q]; x = stx[-Q:]
    s = [-10 ** 10] + s + [10 ** 11]
    t = [-10 ** 10] + t + [10 ** 11]

    for i in x:
        ax = bisect_left(s, i)
        bx = bisect_left(t, i)
        pp = max(s[ax], t[bx]) - i
        mm = i - min(s[ax - 1], t[bx - 1])
        pm = min(s[ax] * 2 - i - t[bx - 1], t[bx] * 2 - i - s[ax - 1])
        mp = min(i - s[ax - 1] * 2 + t[bx], i - t[bx - 1] * 2 + s[ax])
        print(min(pp, mm, pm, mp))


if __name__ == '__main__':
    main()

Measured memory_bytes: 36320
#include <stdio.h>
 
int main()
{
    int n,d,x,a,Ans=0,i;
 
    scanf("%d %d %d",&n,&d,&x);
    for(i=0; i<n; i++)
    {
        scanf("%d",&a);
       
        Ans+=(d-1)/a;
       
        Ans++;
       
    }
    printf("%d\n",Ans+x);
 
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int num = b / a;
        System.out.println(Math.min(c, num));
    }
}




Measured memory_bytes: 21716