akhauriyash/Code-Regression huggingface dataset:
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9 + 7;
const int maxn = 300005;
#define endl '\n'
#define ld long double
#define int ll
#define all(x) (x).begin(),(x).end()
const ll md = (ll) 1e9 + 7;
 
inline ll add(ll a, ll b) {
  a += b;
  if (a >= md) a -= md;
  return a;
}
 
inline ll sub(ll a, ll b) {
  a -= b;
  if (a < 0) a += md;
  return a;
}
 
inline ll mul(ll a, ll b) {
  return (ll) ((long long)((a%md) * (b%md)) % md);
}
 
inline ll power(ll a, long long b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
 
inline ll inv(ll a) {
  a %= md;
  if (a < 0) a += md;
  ll b = md, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

vector<int> fact(maxn+5);
void init (int n)
{
  fact[0] = 1;
  for(int i = 1;i<=n;i++)
  {
    fact[i] = mul(i,fact[i-1]);
  }
}
int nck(int n,int k)
{
  return mul(fact[n],mul(inv(fact[k]),inv(fact[n-k])));
}

int32_t main()
{ 
  IOS

  int s;
  cin >> s;
  int ans = 0;
  init(10000);
  for(int n = 1;n<=(s/3);n++){
    int rem = s - n*3;
    ans = add(ans,nck(rem + n  - 1, n  - 1));
  }
  cout <<  ans << endl;
  
    
    
} 



Measured memory_bytes: 5500
#include <cstdio>
#include <cstring>


int n,A[50];


int solve(int i,int m){
  int res;

  if(m==0) return 1;
  if(i>=n) return 0;
  res = solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}

int main(){

  //int top = 0;
  int M,q;

  scanf("%d",&n);

  for(int i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);

  for(int i=0;i<q ;i++){
    scanf("%d",&M);
    if(solve(0,M)){
      printf("yes\n");
    }
    else{
      printf("no\n");
    }
  }




return 0;
}

Measured memory_bytes: 2664
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>

using namespace std;

int main() {
  int N, T;
  cin >> N >> T;

  vector<int> c(N);
  vector<int> t(N);

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

  int res = -1;
  int cost = 10001;
  
  for (int i=0; i<N; i++) {
    if (t[i] <= T && cost > c[i]) {
      cost = c[i];
      res = i + 1;
    }
  }

  if (res == -1) {
    cout << "TLE" << endl;
  } else {
    cout << cost << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<int,int> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
int f[110];



int main(){
	while(1){
		int l=0,r=0;
		int la=0;
		cin>>n;
		if(n==0)break;
		int ans=0;
		REP(i,n){
			string s;
			cin>>s;
			if(s=="lu"){
				l=1;
			}else if(s=="ru"){
				r=1;
			}else if(s=="ld"){
				l=0;
			}else{
				r=0;
			}
			if(la==0&&l==1&&r==1){
				ans++;
				la=1;
			}
			if(la==1&&l==0&&r==0){
				ans++;
				la=0;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
using P = pair<int,int>;
const int INF = 1001001001;


int main(){
    int X,Y,Z;
    cin >> X >> Y >> Z;

    cout << Z << " " << X << " " << Y<< endl;
    
}

Measured memory_bytes: 3588
#include<stdio.h>
int main(void){
  char s[22];
  char s1[6],s2[8],s3[6];
  int i;
  for(i=0;i<20;i++){
    scanf("%c",&s[i]);
  }
  for(i=0;i<5;i++){
    s1[i]=s[i];
  }
  for(i=0;i<7;i++){
    s2[i]=s[i+6];
  }
  for(i=0;i<5;i++){
    s3[i]=s[i+14];
  }
  
  for(i=0;i<5;i++){
    printf("%c",s1[i]);
  }
  printf(" ");
  for(i=0;i<7;i++){
    printf("%c",s2[i]);
  }
  printf(" ");
  for(i=0;i<5;i++){
    printf("%c",s3[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
n,Y=map(int,input().split())

ans=0
for x in range(0,n+1):
  if ans>0:
    break
  for y in range(0,n+1-x):
    z=n-x-y
    if 10000*x+5000*y+1000*z==Y:
      ans+=1
      print(str(x)+' '+str(y)+' '+str(z))
      
    if ans>0:
      break
      
if ans==0:
  print(str(-1)+' '+str(-1)+' '+str(-1))

Measured memory_bytes: 9228
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  cout << n * (n + 1) / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
int main(){
  int a, b, sum, mul, sub, max;
  scanf("%d%d", &a, &b);
  sum = a + b; mul = a * b; sub = a - b;
  max = (sum > mul) ? sum : mul;
  max = (max > sub) ? max : sub;
  printf("%d", max);
  return 0;
}


Measured memory_bytes: 128
def stupid(a):
    from itertools import permutations
    ret = float('inf')
    for p in permutations(a):
        time = 0
        for dish in p:
            time += (10 - (time % 10)) % 10
            time += dish
        ret = min(ret, time)
    return ret

def fast(a):
    temp = a[::]
    temp.sort(key=lambda x: (10 - (x % 10)) % 10)
    ret = 0
    for dish in temp:
        ret += (10 - (ret % 10)) % 10
        ret += dish
    return ret

def stress(n):
    from random import randint
    for _ in range(n):
        a = [randint(1, 123) for _ in range(5)]
        expected = stupid(a)
        got = fast(a)
        if got != expected:
            raise Exception('%s -> expected:%d, got:%d' % (' '.join(map(str, a)), expected, got))

test = False
if test:
    stress(1000)
else:
    a = [int(input()) for _ in range(5)]
    print(fast(a))

Measured memory_bytes: 3064
using System;

class Program {
  public static void Main() {
    string[] input = Console.ReadLine().Split(' ');
    string[] input2 = Console.ReadLine().Split(' ');
    
    int total = 0;
    foreach (string n in input2) {
      total += int.Parse(n);
    }

    if (int.Parse(input[0]) <= total)
      Console.WriteLine("Yes");
    else
      Console.WriteLine("No");
  }
}

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

int main () {
  int N , t ;
  cin >> N >> t ;
  int ans = 1100 ;
  
  for(int i = 0 ; i < N ;i++) {
    int a , b ;
    cin >> a >> b ;
    if(b<=t) ans = min(ans,a) ;
  }
  if(ans != 1100) cout << ans << endl ; 
  else cout << "TLE" << endl ;
}

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

int main()
{
	long long n;
	vector<long long> a(5);
	cin >> n >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	sort(a.begin(), a.end());
	cout << ((n + a[0] - 1) / a[0]) + 4;
}

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

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define endl '\n'
#define ff first
#define ss second
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=100,mod=1e9+7,bit=61;
const ld PI=acos(-1.00);

ll n,m,ans=0,qq;
pair<pll,pll> q[N];
vector<ll> v;

void solve(ll prev)
{
    if((int)v.size()==n+1)
    {
        ll c=0;
        f(i,1,qq)
        {
            if(v[q[i].ff.ss]-v[q[i].ff.ff]==q[i].ss.ff)
            {
                c+=q[i].ss.ss;
            }
        }
        ans=max(ans,c);
        return;
    }
    f(i,prev,m)
    {
        v.pb(i);
        solve(i);
        v.pop_back();
    }
}

signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        cin>>n>>m>>qq;
        f(i,1,qq)
        {
            cin>>q[i].ff.ff>>q[i].ff.ss>>q[i].ss.ff>>q[i].ss.ss;
        }
        v.pb(1);
        solve(1);
        cout<<ans<<endl;
    }
    return 0;
}


















Measured memory_bytes: 3652
use std::collections::*;
use std::*;
macro_rules! get {
    ($($t:tt),*; $n:expr) => {
        {
            let stdin = std::io::stdin();
            ret = std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
                let line = line.unwrap();
                let mut it = line.split_whitespace();
                _get!(it; $($t),*)
            }).collect::<Vec<_>>()
        }
    };
    ($($t:tt),*) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut it = line.split_whitespace();
            _get!(it; $($t),*)
        }
    };
}
macro_rules! _get {
    ($it:ident; [char]) => {
        _get!($it; String).chars().collect::<Vec<_>>()
    };
    ($it:ident; usize1) => {
        $it.next().unwrap().parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
    };
    ($it:ident; [usize1]) => {
        $it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
    };
    ($it:ident; [$t:ty]) => {
        $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
    };
    ($it:ident; $t:ty) => {
        $it.next().unwrap().parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
    };
    ($it:ident; $($t:ty),+) => {
        ($(_get!($it; $t)),*)
    };
}
fn main() {
    let n = get!(i32);
    println!("{}", (n + 1000 - 1) / 1000 * 1000 - n);
}


Measured memory_bytes: 2128
import sys
li = [list(map(int,input().split())) for i in range(3)]
n = int(input())
k = [int(input()) for i in range(n)]
cnt = 0
for i in range(3):
    for j in range(3):
        if li[i][j] in k:
            li[i][j] = -1
        else:
            pass
for a in range(3):
    if li[a][0] == li[a][1] == li[a][2] == -1:
        print("Yes")
        exit()
    else:
        pass
for b in range(3):
    if li[0][b] == li[1][b] == li[2][b] == -1:
        print("Yes")
        exit()
    else:
        pass
if li[0][0] == li[1][1] == li[2][2] == -1:
    print("Yes")
    exit()

elif li[0][2] == li[1][1] == li[2][0] == -1:
    print("Yes")
    exit()
else:
    print("No")

Measured memory_bytes: 3192
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vi a(n);
	int mn = 1e9, mx = 0;
	rep(i, n) cin >> a[i], mn = min(a[i], mn), mx = max(mx, a[i]);
	if((mx - mn) > 1){
		cout << "No" << endl;
		return 0;
	}
	if((mx - mn) == 0){
		if(mn == (n - 1)){ //everyone is unique
			cout << "Yes" << endl;
			return 0;
		}
		cout << (((n / mn) > 1) ? "Yes" : "No") << endl;
		return 0;
	}
	int un = 0; //number of unique colors
	rep(i, n) if(a[i] == mn) un++;
	cout << ((mx >= un + 1 && mx <= (un + (n - un) / 2)) ? "Yes" : "No") << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int bigint;

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;


int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,m;
	cin >>n >>m;
	VI cn(n+2);
	rep(i,m){
		int a,b;
		cin >>a >>b;
		if(a==1) cn[b] |= 1;
		if(b==n) cn[a] |= 2;
	}
	rep(i,n+1) if(cn[i]==3){puts("POSSIBLE");return 0;};
	//for(auto x :cn) printf("%d, ",x); puts("");
	puts("IMPOSSIBLE");
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int p[1001];
int main()
{
    int n,k;
    cin>>n>>k;
    int ans=0;
    for(int i=1;i<=n;i++)
        cin>>p[i];
    sort(p,p+n+1);
    for(int i=1;i<=k;i++)
        ans+=p[i];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3560
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  vector<bool> prime(40000,true);

  for(i=2;i<40000;i++)
    if(prime[i])
      for(j=2;i*j<40000;j++)
        prime[i*j]=false;

  vi ans(40000,0);

  for(i=2;i<40000;i++)
    if(prime[i])
      for(j=i;j<40000;j++)
        if(prime[j] && i+j<40000)
          ans[i+j]++;

  while(1){
    cin>>n;
    if(n==0)break;
    cout<<ans[n]<<endl;
  }
}

Measured memory_bytes: 2988
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K,S;
  cin >> K >> S;
  int x,y,z,a;
  a=0;
  for(x=0;x<=K;x++){
    for(y=0;y<=K;y++){
      z=S-x-y;
      if(0<=z && z<=K){
        a++;
      }
    }
  }
  cout << a << endl;}
 


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
    template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
    template<typename T> void chadd(T& a, T b) { a = a + b; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t sz;
        inp(std::size_t _sz = 1) : sz(_sz) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
        template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
    };

    inp inp1; // input one

    ll gcd(ll a, ll b) {
        if (b == 0) return a;
        return gcd(b, a % b);
    }
    ll lcm(ll a, ll b) {
        return a / gcd(a, b) * b;
    }
}

int main() {

    int k = inp1;

    ll ans = 0;

    Rep(a, 1, k + 1) {
        Rep(b, 1, k + 1) {
            Rep(c, 1, k + 1) {
                ans += gcd(gcd(a, b), c);
            }
        }
    }

    Cout(ans);

    return 0;
}


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

int main(){
    int N, ans=0, M, D;
    cin >> M >> D;
    for(int i=2; i<=M; i++){
	for(int j=22; j<=D; j++){
	    if(i == (j/10)*(j%10) && (j%10)>=2)
		ans++;
	}
    }

    cout << ans << endl;    
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/dp/tasks/dp_d
//https://atcoder.jp/contests/dp/tasks/dp_e

#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x << "  = " << x << endl
typedef long long int ll;
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

#define dbg2(x, y)                                                       \
    {                                                                    \
        cout << #x << ": " << (x) << " , " << #y << ": " << (y) << endl; \
    }
#define fo(i, n) for (int i = 0; i < n; i++)
#define fok(i, k, n) for (int i = k; i < n; i++)
#define foA(i, A) for (auto i : A)
const int mxN=105;

string lcs(string a, string b){
    int n=a.length(), m=b.length();string r="";
    int dp[n+1][m+1];
    fo(i, n+1){
        fo(j, m+1){
            if(i==0 or j==0){dp[i][j]=0;continue;}
            if(a[i-1]==b[j-1]){
                dp[i][j]=1+dp[i-1][j-1];
            }
            else{
                dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    // fo(i, n+1){fo(j, m+1)cout<<dp[i][j]<<" ";cout<<endl;}
    int i=n, j=m;
    while(i>0 and j>0){
        if((dp[i][j]==1+dp[i-1][j-1]) and (a[i-1]==b[j-1])){
            // dbg2(i, j);dbg2(a[i-1], b[j-1]);deb(r);
            r=a[i-1]+r;
            i--;j--;
        }
        else if(dp[i][j]==dp[i-1][j]){i--;}
        else if(dp[i][j]==dp[i][j-1]){j--;}
    }
    return r;
}

int main(){
    fast;
    string a, b;
    cin>>a>>b;
    cout<<lcs(a,b);
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;



int main() {
//    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int x, y;
    cin >> x >> y;
    int ans = 0;
    if (x < 4) ans += (x == 1 ? 300000 : (x == 2 ? 200000 : 100000));
    if (y < 4) ans += (y == 1 ? 300000 : (y == 2 ? 200000 : 100000));
    if (x == 1 && y == 1) ans += 400000;
    cout << ans;

}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> pa;

#define fst first
#define snd second
#define pb push_back

const int maxn=500005,maxm=512;
const double pi=acos(-1.0);
//const ll mod=1000000007;
const ll mod=998244353;
const double eps=1e-8;

int n;

int a[maxn];

ll ans=0;

int main()
{
	int i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",a+i);
	sort(a,a+n);ans=a[n-1];
	for(j=2,i=n-2;i>=0&&j<n;i--)
    {
        if(j+1<=n) ans+=a[i],++j;
        if(j+1<=n) ans+=a[i],++j;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4596
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>

void solve() {
    int k, x, y;
    std::cin >> k >> x >> y;

    if (k % 2 == 0 && (x + y) % 2 != 0) {
        std::cout << -1 << std::endl;
        return;
    }

    bool xneg = false, yneg = false;
    if (x < 0) {
        xneg = true;
        x = -x;
    }
    if (y < 0) {
        yneg = true;
        y = -y;
    }

    std::vector<std::pair<int, int>> ans{{x, y}};
    while (x >= k) {
        x -= k;
        ans.emplace_back(x, y);
    }
    while (y >= k) {
        y -= k;
        ans.emplace_back(x, y);
    }
    if (ans.size() > 1 && x + y < k) {
        ans.pop_back();
        std::tie(x, y) = ans.back();
    }

    if (x + y != k) {
        bool iyneg = false;
        if ((x + y) % 2 == 1) {
            y -= k;
            ans.emplace_back(x, y);

            if (y < 0) {
                iyneg = true;
                y = -y;
            }
        }

        int nx, ny;
        ny = -(k - (x + y) / 2);
        nx = k + ny;
        if (x < y) std::swap(nx, ny);

        if (iyneg) ny = -ny;
        ans.emplace_back(nx, ny);
    }

    std::reverse(ans.begin(), ans.end());
    std::cout << ans.size() << std::endl;
    for (auto p : ans) {
        std::cout << p.first * (xneg ? -1 : 1) << " "
                  << p.second * (yneg ? -1 : 1) << std::endl;
    }
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}


Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
#define M 998244353

const int mod=M;
struct mint{
    long long x;
    mint(long long x=0):x((x%mod+mod)%mod){}
    mint operator-()const{
        return mint(-x);
    }
    mint &operator+=(const mint &a){
        if((x+=a.x)>=mod) x-=mod;
        return *this;        
    }
    mint &operator-=(const mint &a){
        if((x+=mod-a.x)>=mod) x-=mod;
        return *this;        
    }
    mint &operator*=(const mint &a){
        (x*=a.x)%=mod;
        return *this;        
    }
    mint operator+(const mint &a)const{
        return mint(*this)+=a;        
    }
    mint operator-(const mint &a)const{
        return mint(*this)-=a;        
    }
    mint operator*(const mint &a)const{
        return mint(*this)*=a;        
    }
    mint pow(long long t)const{
        if(!t){
            return 1;
        }
        mint a=pow(t>>1);
        a*=a;
        if(t&1){
            a*=*this;
        }
        return a;
    }
    mint inv()const{
        return pow(mod-2);
    }
    mint &operator/=(const mint &a){
        return (*this)*=a.inv();
    }
    mint operator/(const mint &a)const{
        return mint(*this)/=a;
    }
};
istream &operator>>(istream &is,const mint &a){
    return is>>a.x;
}
ostream &operator<<(ostream &os,const mint &a){
    return os<<a.x;
}

struct combination{
    vector<mint> fact,ifact;
    combination(int n):fact(n+1),ifact(n+1){
        assert(n<mod);
        fact[0]=1;
        for(int i=1;i<=n;i++){
            fact[i]=fact[i-1]*i;
        }
        ifact[n]=fact[n].inv();
        for(int i=n;i>=1;i--){
            ifact[i-1]=ifact[i]*i;
        }
    }
    mint operator()(int n,int k){
        if(k<0||n<k){
            return 0;
        }
        return fact[n]*ifact[k]*ifact[n-k];
    }
}c(200005);

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    
    mint ans=0;
    mint col=m;
    for(int x=n-1;x>=0;x--){
        mint y=col*c(n-1,x);
        if(x<=k){
            ans+=y;
        }
        col*=m-1;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 6240
#include<iostream>
#include<algorithm>
using namespace std;
bool t[5001][5];
int u[5];
void init();
void make_table();
void move(int);
int n;
int d,p,q,cnt;
int main(){

  while(cin>>n&&n!=0){
    init();
    for(int i=0;i<n;i++){
      cin>>d>>p>>q;
      q--;
      make_table();
    }
    cnt=0;
    for(int i=0;i<5000;i++)for(int j=0;j<5;j++)if(t[i][j])cnt++;
    cout<<cnt<<endl;
  }  
  return 0;
}

void init(){
  for(int i=0;i<=5000;i++){
    for(int j=0;j<5;j++){
      t[i][j]=false;
    }
  }
  for(int i=0;i<5;i++)u[i]=0;
}

void make_table(){
  int h;
  if(d==1){
    h=0;
    for(int j=q;j<q+p;j++)h=max(h,u[j]);
    for(int j=q;j<q+p;j++){t[h][j]=true;u[j]=h+1;}
  }else{
    h=u[q];
    for(int i=h;i<h+p;i++)t[i][q]=true;
    u[q]+=p;
  }





  /*
  h=0;
  for(int j=0;j<5;j++)h=max(h,u[j]);

  for(int i=0;i<h+1;i++){
    if(t[i][0]&&t[i][1]&&t[i][2]&&t[i][3]&&t[i][4]){
      for(int j=0;j<5;j++){
	t[i][j]=false;
      }
    }
  }
 
  


      
  int H=0;
  for(int i=0;i<=5000;i++){
    if(t[i][0]||t[i][1]||t[i][2]||t[i][3]||t[i][4]){
      for(int j=0;j<5;j++){
	t[H][j]=t[i][j];
	if(H!=i)t[i][j]=false;
      }
      H++;
    }
  }
  */
  /*
  for(int I=7;I>=0;I--){
    for(int j=0;j<5;j++){
      cout<<(int)t[I][j];
    }
    cout<<endl;
  }
  cout<<endl;
  */
  
  for(int i=0;i<5000;i++){
    while(1){
      if(t[i][0]&&t[i][1]&&t[i][1]&&t[i][2]&&t[i][3]&&t[i][4]){
	move(i);
	//cout<<i<<endl;
	/*
	for(int I=7;I>=0;I--){
	  for(int j=0;j<5;j++){
	    cout<<(int)t[I][j];
	  }
	  cout<<endl;
	}
	cout<<endl;
	*/


	
      }else{
	break;
      }
    }
  }



  

  for(int j=0;j<5;j++){
    u[j]=0;
    for(int i=4999;i>=0;i--){
      if(t[i][j]){
	u[j]=i+1;
	break;
      }
    }
  }

  //for(int i=0;i<5;i++)cout<<u[i]<<' ';cout<<endl;

}

void move(int x){
  for(int j=0;j<5;j++){
    for(int i=x;i<5000;i++){
      t[i][j]=t[i+1][j];
    }
  }
  for(int j=0;j<5;j++)t[5000][j]=false;
}

Measured memory_bytes: 1180
#include <stdio.h>

int main(){
  int x,y,key,d;
  scanf("%d %d",&x,&y);
  if(x<y){
    key=x;
    x=y;
    y=key;
  }
  while(y>0){
  d=x%y;
  x=y;
  y=d;
  }
  printf("%d\n",x);

  return 0;
}



Measured memory_bytes: 2144
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define tm1 ff
#define tm2 ss.ff
#define tm3 ss.ss
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define fill(x,v) memset(x,v,sizeof(x))
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;




int main(){
	fastio;	
	int n;cin>>n;
	int A,B;cin>>A>>B;
	int c0=0,c1=0,c2=0;
	FER(i,0,n){
		int k;cin>>k;
		if(k<=A)c0++;
		else if(k<=B)c1++;
		else c2++;
	}
	int ans=min(c1,min(c2,c0));
	cout<<ans<<endl;

	return 0;
}



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

int main() {
  int a, b, n;
  while (cin >> a >> b >> n) {
    int s = 0;
    for (int i = 0; i < n; ++i) {
      a = (a % b) * 10;
      s += a / b;
    }
    cout << s << endl;
  }
  return 0;
}



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

int main(){
  int n,k;
  int count=0;
  cin >> n >> k;
  vector<int> vec(n);
  for(int i=0; i<n; i++){
    cin >> vec.at(i);
  }
  
  vector<int> map(200000);
  
  for(int i=0; i<n; i++){
    map.at(vec.at(i)-1)++;
  }
  
  sort(map.begin(),map.end());
  reverse(map.begin(),map.end());
  
  for(int i=k; i<200000; i++){
    count += map.at(i);
  }
  
  cout << count << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const ll oo = 1e9 + 10;
const ll mod = 998244353,maxn = 110;
const double PI = acos(-1); 

ll solve(string a, string b){
    if (a.size() < b.size()) swap(a, b);
    int n = a.size(), m = b.size(), tmp = 0, ans = 100000;
    for (int i=0; i<=n-m; i++){
        for (int j=0; j<m; j++){
            if (a[i+j] != b[j]) tmp++;
        }
        ans = min(ans, tmp);
        tmp = 0;
    }
    return ans;
}

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string a, b;
    cin >> a >> b;

    cout << solve(a, b) << endl;
    return 0; 
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n,k;cin>>n>>k;
  vector<ll> h(n);
  rep(i,n){
    cin>>h[i];
  }
  vector<ll> dp(n,LLONG_MAX);
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  fori(i,2,n){
    ll minstep=LLONG_MAX;
    int limit=min(i,k);
    fori(j,1,limit+1){
      minstep=min(minstep,dp[i-j]+abs(h[i]-h[i-j]));
    }
    dp[i]=minstep;
  }
  cout<<dp[n-1]<<endl;
  return 0;
}


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

int main(){
  int x=0,max=0,N;
  string S;
  cin >> N >> S;
  for(int i=0;i<N;i++){
    if(S[i]=='I'){
      x++;
      if(max<x) max = x;
    }else x--;
  }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
 
using mint = static_modint<998244353>;
int main(){
    int n, m; cin >> n >> m;
    vector<mint>  a(n), b(m);
    for (int i = 0; i < n; i++) { int x; cin >> x; a[i] = x; }
    for (int i = 0; i < m; i++) { int x; cin >> x; b[i] = x; }
 
    auto ans = convolution(a, b);
    for (auto p : ans) cout << p.val() << " ";
    cout << "\n";
    return 0;
}

Measured memory_bytes: 19008
///
// File:  b.go
// Author: ymiyamoto
//
// Created on Sat Mar 24 02:09:26 2018
//
package main

import (
	"fmt"
)

var N, M int

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

func main() {
	fmt.Scan(&N)

	blues := map[string]int{}
	for i := 0; i < N; i++ {
		var s string
		fmt.Scan(&s)
		blues[s]++
	}
	fmt.Scan(&M)

	reds := map[string]int{}
	for i := 0; i < M; i++ {
		var s string
		fmt.Scan(&s)
		reds[s]++
	}

	m := 0
	for k, v := range blues {
		m = max(m, v-reds[k])
	}
	fmt.Println(max(0, m))
}


Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n;
    vi s(n);
    rep(i, n) {
        cin >> s[i];
    }
    cin >> q;
    vi t(q);
    rep(i, q) {
        cin >> t[i];
    }

    sort(all(s));
    sort(all(t));
    int ans = 0;
    rep(i, q) {
        if(binary_search(all(s), t[i])) {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3176
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; 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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int N;
int M;
struct edge {
  int to, cost;
};
vector<edge> Graph[101010];
ll pos[101010];

bool traverse(int s) {
  for (auto e : Graph[s]) {
    if (pos[e.to] == INF) {
      pos[e.to] = pos[s] + e.cost;
      if (!traverse(e.to)) {
        return false;
      }
    } else {
      if (pos[e.to] != pos[s] + e.cost) {
        return false;
      }
    }
  }
  return true;
}

int main() {
  cin >> N >> M;
  rep(i, 0, M) {
    int l, r, d;
    cin >> l >> r >> d;
    Graph[l].push_back(edge{r, d});
    Graph[r].push_back(edge{l, -d});
  }
  rep(i, 0, 101010) { pos[i] = INF; }

  repe(i, 1, N) {
    if (i == 1 || pos[i] == INF) {
      pos[i] = 0;
      if (!traverse(i)) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 12416
#include <stdio.h>
int ten[5] = {10000, 1000, 100, 10, 1};
char sb[2] = " *";
void solve(int N) {
	int i, j;
	for(i = 0; i < 8; ++ i) {
		for(j = 0; j < 5; ++ j) {
			switch(i) {
				case 0:
					printf("%c", sb[N / ten[j] % 10 / 5 != 1]);
					break;
				case 1:
					printf("%c", sb[N / ten[j] % 10 / 5 != 0]);
					break;
				case 2:
					printf("=");
					break;
				case 3:
					printf("%c", sb[N / ten[j] % 10 % 5 != 0]);
					break;
				case 4:
					printf("%c", sb[N / ten[j] % 10 % 5 != 1]);
					break;
				case 5:
					printf("%c", sb[N / ten[j] % 10 % 5 != 2]);
					break;
				case 6:
					printf("%c", sb[N / ten[j] % 10 % 5 != 3]);
					break;
				default:
					printf("%c", sb[N / ten[j] % 10 % 5 != 4]);
			}
		}
		printf("\n");
	}
}
int main() {
	int N;
	scanf("%d", &N);
	solve(N);
	while(scanf("%d", &N) != EOF) {
		printf("\n");
		solve(N);
	}
	return 0;
}

Measured memory_bytes: 568
#include <stdio.h>
int main (void){
	int a,b,t,i;
	for(i=0;i<10000;i++){
		scanf("%d%d",&a,&b);
		if(a==0 && b==0){
			break;
		}
		if(a>b){
			t=a;
			a=b;
			b=t;
		}
		printf("%d %d\n",a,b);
		}
	return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int main()
{
    int N;
    string s;
    int c[4] = {0};
    
    cin >> N;
    for (int i = 0;i < N;i++){
        cin >> s;
        if (s[0] == 'A'){
            c[0]++;
        }
        else if (s[0] == 'W'){
            c[1]++;
        }
        else if (s[0] == 'T'){
            c[2]++;
        }
        else{
            c[3]++;
        }
    }
    
    cout << "AC" << " " << "x" << " " << c[0] << endl;
    cout << "WA" << " " <<  "x" << " " << c[1] << endl;
    cout << "TLE" << " " <<  "x" << " " << c[2] << endl;
    cout << "RE" << " " <<  "x" << " " << c[3] << endl;
    
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;


int N;

void calc_sum(int n, ll sum, vector<vector<int>> &tree, vector<ll> &cnt, vector<ll> &ans, vector<bool> &seen) {
    seen.at(n) = true;
    ans.at(n) = sum + cnt.at(n);
    for (auto x : tree.at(n)) {
        if (!seen.at(x)) calc_sum(x, ans.at(n), tree, cnt, ans, seen);
    }
}

int main() {
    int Q, a, b, p, x;
    cin >> N >> Q;
    vector<vector<int>> tree(N);
    vector<bool> seen(N);
    vector<ll> cnt(N), ans(N);
    rep(i,N-1) {
        cin >> a >> b;
        --a;
        --b;
        tree.at(a).push_back(b);
        tree.at(b).push_back(a);
    }
    rep(i,Q) {
        cin >> p >> x;
        --p;
        cnt.at(p) += x;
    }
    calc_sum(0, 0, tree, cnt, ans, seen);
    rep(i,N) cout << ans.at(i) << " ";
}


Measured memory_bytes: 35864
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N; cin >> N;
    int S = 0, mi = INF, ans = 0;
    rep(i,0,N) {
        int x, s; cin >> x >> s;
        int prev = S, cur = S + s;
        prev -= x; cur -= x;
        mi = min(mi, prev);
        ans = max(ans, cur - mi);
        S += s;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll n;
  cin >>n;
  ll a[5];
  for(ll i=0;i<5;i++) cin >>a[i];
  sort(a,a+5);
  ll mi=a[0];
  ll k=n/mi;
  if(n%mi!=0) k++;
  if(k>=1) cout <<5+(k-1)<<endl;
  else cout <<5<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string S;
  cin>>S;
  int a=S.size();
  bool ans=true;
  if(S[0]!='A'){
      ans=false;
  }
  int cnt=0;
    for(int i=2; i<a-1; i++){
        if(S[i]=='C'){
            cnt++;
        }
    }
  	if(S[S.size()-1]=='C'){
		ans=false;
      	
    }
    if(cnt!=1){
        ans=false;      
    }
  int g=0;
  rep(i,a){
    if (isupper(S[i])){
      g++;
    }
  }
  if(g!=2){
  ans=false;}
  if(ans==true){
      cout<<"AC"<<endl;
  }
  else{
      cout<<"WA"<<endl;
  }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define il inline
#define vd void
typedef long long ll;
il ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi(),a=gi(),b=gi();
	printf("%d\n",std::min(n*a,b));
	return 0;
}



Measured memory_bytes: 764
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a // gcd(a, b) * b

def isPrime(x):
    if x < 2 or x % 2 == 0:
        return False
    if x == 2:
        return True
    i = 3
    while i * i <= x:
        if x % i == 0:
            return False
        i += 2
    return True

def divisor(x):
    res = []
    i = 1
    while i * i <= x:
        if x % i == 0:
            res.append(i)
            if i * i != x:
                res.append(x // i)
        i += 1
    res = sorted(res)
    return res

def factor(x):
    res = []
    if x == 1:
        res.push_back(1)
        return res
    i = 2
    while i * i <= x:
        while x % i == 0:
            res.append(i)
            x //= i
    if x != 1:
        res.append(x)
    res = sorted(res)
    return res

        


if __name__ == "__main__":
    N,K = map(int, input().split())
    A = list(map(int, input().split()))
    A = sorted(A)
    sum_v = sum(A)
    div = divisor(sum_v)
    div = sorted(div, reverse=True)
    for e in div:
        ok = True
        b = [int(a % e) for a in A]
        b = sorted(b)
        v = sum(b)
        v //= e
        ans = 0
        for i in range(N-v):
            ans += b[i]
        
        if ans <= K:
            print(e)
            exit()


Measured memory_bytes: 3444
<?php
fscanf(STDIN,"%d %d",$n,$k);
fscanf(STDIN,"%s",$str);

for($i=0;$i<$n;$i++){
	$moji=substr($str,$i,1);
	if($i==$k-1){
		$out.=strtolower($moji);
	}else{
		$out.=$moji;
	}
}

echo $out;
?>

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

int f[100010];
int r[100010];

int main(){
	int a, b, m;
	scanf("%d%d%d", &a, &b, &m);
	for(int i = 0; i < a; i++)
		scanf("%d", f + i);
	for(int i = 0; i < b; i++)
		scanf("%d", r + i);
	long ans = *min_element(f, f + a) + *min_element(r, r + b);
	for(int i = 0; i < m; i++) {
		int x, y, c;
		scanf("%d%d%d", &x, &y, &c);
		ans = min(ans, (long)f[x-1] + r[y-1] - c);
	}
	printf("%ld\n", ans);
}


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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 4000000000; //4*10^9;
constexpr auto MOD = 1000000007; //10^9+7;

int main(){
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	if (a[0] + a[1] + a[2] >= 22) cout << "bust" << endl;
	else cout << "win" << endl;
}

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

#define MAX_H 50
#define MAX_W 50

int H,W;
char c[MAX_H][MAX_W];

bool check(int x,int y){
  bool flag=false;
  if(c[x][y]=='#'){
    if(x+1<H){
      if(c[x+1][y]=='#') flag=true;
    }if(y+1<W){
      if(c[x][y+1]=='#') flag=true;
    }if(y-1>=0){
      if(c[x][y-1]=='#') flag=true;
    }if(x-1>=0){
      if(c[x-1][y]=='#') flag=true;
    }
  }else{
    flag=true;
  }return flag;
}
        
int main(){
  cin>>H>>W;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>c[i][j];
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(!check(i,j)){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
  
N = int(input())

P = factorization(N)

flag = 0

for i in range(len(P)):
  for j in range(40):
    P[i][1] = P[i][1] - (j + 1)
    if P[i][1] >= 0:
      flag += 1
    else:
      break
if N == 1:
  print(0)
else:
  print(flag)

Measured memory_bytes: 9500
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long int
#define mp make_pair
#define PI 3.14159265358979

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    int a,b;
  cin>>a>>b;
  cout<<a*b<<endl;
}

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

int sum = 0,ans = 0;
map<int,int> mp;

signed main(){

  int n,m; cin >> n >> m;
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    sum += a;
    mp[sum%m]++;
    if(sum%m == 0) ans++;
  }

  for(auto p = mp.begin(); p != mp.end(); p++){
    ans += (p->second-1) * p->second / 2; // nC2
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4224
c = str(input())
list_a = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

count = 0
for i in list_a:
    if i == c:
        count += 1
        break
    count += 1

print(list_a[count])

Measured memory_bytes: 3060
def comb(n, r, p):
    return fac[n] * facinv[r] * facinv[n - r] % p


def comb_pre(N_UNTIL, p):
    for i in range(2, N_UNTIL + 1):
        fac.append(fac[i - 1] * i % p)
        inv.append(-inv[p % i] * (p // i) % p)
        facinv.append(facinv[-1] * inv[-1] % p)


fac = [1, 1]
facinv = [1, 1]
inv = [0, 1]

K = int(input())
S = input()
N = len(S)
MOD = 1_000_000_007
comb_pre(N + K - 1, MOD)
ans = 0
for i in range(K + 1):
    tmp = pow(25, K - i, MOD)
    tmp *= comb(N + K - i - 1, K - i, MOD)
    tmp %= MOD
    tmp *= pow(26, i, MOD)
    tmp %= MOD
    ans += tmp
    ans %= MOD
print(ans)


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

using namespace std;
typedef long long ll;
char p[1500][1500];
ll n[1500][1500];
ll o[1500],q[1500];
ll z[4]={0,0,1,-1},l[4]={1,-1,0,0};
ll a,b;
struct cha
{
     ll x;
     ll y;
};
queue <cha> m;
void bfs()
{
    while(!m.empty())
    {
       cha top =m.front();
         m.pop();

for(ll i=0;i<4;i++)
{
    if(top.x+z[i]>=1&&top.x+z[i]<=a&&top.y+l[i]>=1&&top.y+l[i]<=b&&n[top.x+z[i]][top.y+l[i]]==0)
    {
        n[top.x+z[i]][top.y+l[i]]=n[top.x][top.y]+1;

        cha next ;
        next.x=top.x+z[i];
        next.y=top.y+l[i];
        m.push(next);

    }

}

    }



}
int main()
{
   ll c,d,e=0,f=0;
   cin>>a>>b;
   for(c=1;c<=a;c++)
   {
       scanf("%s",p[c]+1);
   }
   for(c=1;c<=a;c++)
   {

       for(d=1;d<=b;d++)
       {


           if(p[c][d]=='#'){

             cha t;
             t.x=c;
             t.y=d;
             m.push(t);
             n[c][d]=1;




           }

       }

   }


   bfs();
ll flag =-999999;
      for(c=1;c<=a;c++)
   {

       for(d=1;d<=b;d++)
       {

flag=max(flag,n[c][d]);


       }


   }


cout<<flag-1;
    return 0;
}


Measured memory_bytes: 31540