akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int a[510][510];
int main()
{
	int h,w,H,W,i,j,ans=0;
	scanf("%d%d%d%d",&H,&W,&h,&w);
	if(H%h==0&&W%w==0)
	{
		printf("No\n");
		return 0;
	}
	for(i=h;i<=H;i+=h)
		for(j=w;j<=W;j+=w)
			a[i][j]=-w*h*1000+999;
	for(i=1;i<=H;i++)
		for(j=1;j<=W;j++)
		{
			if(!a[i][j])	a[i][j]=1000;
			ans+=a[i][j];
		}
	if(ans<0)
	{
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	for(i=1;i<=H;i++)
	{
		for(j=1;j<=W;j++)
			printf("%d ",a[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define sort(v) sort(v.begin(),v.end());
const ll mod = 1E9 + 7;

int main()
{
    ll a;
    cin>>a;
    cout<<a*(1+a*(1+a));
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        vector<int> A(N), B(N), C(N);
        rep(i, N) cin >> A[i] >> B[i] >> C[i];

        int not_a[2] = {};
        int not_b[2] = {};
        int not_c[2] = {};

        rep(i, N) {
            not_a[(i+1)%2] = max(not_b[i%2] + B[i], not_c[i%2] + C[i]);
            not_b[(i+1)%2] = max(not_a[i%2] + A[i], not_c[i%2] + C[i]);
            not_c[(i+1)%2] = max(not_a[i%2] + A[i], not_b[i%2] + B[i]);
        }
        cout << max({not_a[N%2], not_b[N%2], not_c[N%2]}) << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


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

int main(){
  int n, k;
  int p[200001];
  long long max=0;
  long long tmp=0;
  double ans=0;

  cin >> n >> k;
  for(int i=0;i<n;i++)cin >> p[i];
  
  for(int i=0;i<k;i++){
    tmp+=p[i];
  }
  //cout << "[" << tmp << "]";
  max = tmp;
  
  for(int i=0;i<n-k;i++){
    tmp-=p[i];
    tmp+=p[i+k];
    //cout << "[" << tmp << "]";
    if(max<tmp)max = tmp;
  }

  ans = (double)(max+k)/2;
  
  
  printf("%.12f", ans);
  return 0;
}


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


int main() {
  string S, s="Sunny", c="Cloudy", r="Rainy";
  cin >> S;
  
  if (S == s){
    cout << c << endl;
  }
  if(S == c){
    cout << r << endl;
  }
  if(S == r){
    cout << s << endl;
  }
  return 0;
  
  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <vector>
#include <iostream>
#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++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

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

int main(){
	vector<int> a(2);
	REP(i, 2) cin >> a[i];
	if (a[0] <= 8 && a[1] <= 8){
		printf("%s\n", "Yay!");
	}else{
		printf("%s\n", ":(");
	}
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) ((int)a.size())
#define pow2(n) (n * n)
#define int ll
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-8;
ll mod = static_cast<ll>(1e9 + 7);
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, std::forward<Args>(args)...); }
};
template <class F>
constexpr decltype(auto) funcs(F &&f) { return FixPoint<F>{std::forward<F>(f)}; }
template <class T>
std::vector<T> vecs(int n, T &&val) { return std::vector<T>(std::forward<int>(n), std::forward<T>(val)); }
template <class... Args>
decltype(auto) vecs(int n, Args &&... args) { return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...)); }
template <class V, class T>
void fill(V &x, const T &val) { x = val; }
template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    auto sum = accumulate(all(a), 0LL);
    reps(i, n - 1) maxs(a[i], a[i - 1]);
    cout << accumulate(all(a), 0LL) - sum << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}

Measured memory_bytes: 4780
hoge = input().split()
hoge[0] = int(hoge[0])
hoge[1] = int(hoge[1])
hoge[2] = int(hoge[2])
if hoge[0] * hoge[1] < hoge[2]:
  print(hoge[0] * hoge[1])
else:
  print(hoge[2])

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
int main()
{
int i,s=0,j,t,a[1001000];
int k,n;
scanf("%d%d",&n,&k);
for(i=0;i<n;i++)scanf("%d",&a[i]);
for(i=0;i<n;i++)
for(j=i;j<n;j++)
if(a[i]>a[j])
{
t=a[i];a[i]=a[j];a[j]=t;
}
for(i=0;i<k;i++)s=s+a[i];
printf("%d",s);
return 0;
}

Measured memory_bytes: 1736
#include "bits/stdc++.h"

using namespace std;
//vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x0f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//

int main() {

    int m, d;
    cin >> m >> d;
    ll ans = 0;
    for (int i = 1; i <= m; ++i) {
        for (int j = 1; j <= d; ++j) {
            if (((j % 10) * (j / 10) == (i)) && (j % 10 >= 2) && (j / 10 >= 2))
                ++ans;
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var array = Console.ReadLine().Split();
            var set = new HashSet<string>();
            for (var i = 0; i < N; i++) set.Add(array[i]);

            Console.WriteLine(set.Count == 4 ? "Four" : "Three");
        }
    }
}


Measured memory_bytes: 13280
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#define int long long
using namespace std;
const int maxn = 2e3+10;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int a[maxn],num[maxn];
signed main(){
	n=read();
	for(register int i=1;i<=n;i++){		
		a[i]=read();
		num[a[i]]++;
	}
	sort(a+1,a+n+1);
	int ans=0;
	for(register int i=1;i<=2000;i++)num[i]+=num[i-1];
	for(register int i=1;i<=n;i++){
		for(register int j=i+1;j<=n;j++){
			int x=a[i],y=a[j],zmin,zmax;
			if(x<y)swap(x,y);
			zmin=x-y+1;
			zmax=x+y-1;
			if(zmax<zmin)continue;
			int sum=num[zmax]-num[zmin-1];
			if(zmin<=x && x<=zmax)sum--;
			if(zmin<=y && y<=zmax)sum--;
			ans+=sum;
		}
	}
	printf("%lld\n",ans/3);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>
#include <cstdint>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long ll;

const ll INF = 1LL << 62;
const int MOD = 1e9 + 7;


int main() {
    int n, W; cin >> n >> W;
    vector<ll> w(n), v(n); rep(i, n) cin >> w[i] >> v[i];

    vector<vector<ll>> dp(n+1, vector<ll>(1e5+1, INF));
    dp[0][0] = 0;

    rep(i, n) rep(j, 1e5+1) {
        if (j+v[i] <= 1e5) dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]], dp[i][j] + w[i]);
        dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
    }


    for (int j = 1e5; j >= 0; j--) {
        if (dp[n][j] <= W) {
            cout << j << endl;
            break;
        }
    }


    return 0;
}

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

int main() {

  int N;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
  int k = 0;
  for (int i = 0; i < N; i++) {
    if (p.at(i) != (i + 1)) {
      k++;
    }
  }
  if (k == 0 || k == 2) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define prDouble(x) cout << fixed << setprecision(10) << x

double dp[3005][3005];

double probability(vector<double>& ar, int n, int x)
{

	if (x == 0)
		return 1;	//We will always get min 0 Heads
	if (n == 0)
		return 0;	//No coins to flip

	if (dp[n][x] > -0.9)
		return dp[n][x];

	return dp[n][x] = (ar[n] * probability(ar, n - 1, x - 1)) + ((1 - ar[n]) * probability(ar, n - 1, x));
}

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

	memset(dp, -1, sizeof(dp));

	vector<double> ar(n + 1);
	for (int i = 1; i <= n; i++)
		cin >> ar[i];

	prDouble(probability(ar, n, (n + 1) / 2));
}

Measured memory_bytes: 74532
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            int m=sc.nextInt();
            int f=sc.nextInt();
            int r=sc.nextInt();
            if(m==-1&&f==-1&&r==-1)
            break;
            if(m==-1||f==-1){
            System.out.print("F");
            }else if(m+f>=80){
                System.out.printf("A");
            }else if(m+f>=65){
                System.out.printf("B");
            }else if(m+f>=50||r>=50){
                System.out.printf("C");
            }else if(m+f>=30){
                System.out.printf("D");
            }else{
                System.out.printf("F");
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
const int NN = 1e6+10;
typedef long long ll;

int N,M;
vector<int> ve[NN];
priority_queue<int> q;
int main(){
//	freopen("input.txt","r",stdin); 
	cin>>N>>M; //输入N个工作，可工作天数M天 
	for(int i = 1;i<=N;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		if(a>M) continue; //如果，这项工作的时间大于自己所能付出的总时间，直接抛弃 
		ve[M-a+1].push_back(b); //表示M-a+1天之后不能做此份工作(也就是做了赚不到钱) 
	}
	ll earn = 0; //定义earn作为总钱数 
	for(int i = M;i>=1;i--){
		for(int m:ve[i]){
			q.push(m);
		}
		while(!q.empty()){
			earn += q.top();
			q.pop();
			break;
		}
	}
	cout<<earn<<endl;
	
	return 0;
}

Measured memory_bytes: 26752
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true)
        {
            int x = sc.nextInt();
            String op = sc.next();
            int y = sc.nextInt();
            int ans = 0;
            if(op.charAt(0) == '?')
                break;
            switch(op.charAt(0)){
                case '+' : ans = x + y; break;
                case '-' : ans = x - y; break;
                case '*' : ans = x * y; break;
                case '/' : ans = x / y; break;
            }
            System.out.println(ans);
        }
    }
}


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

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

	auto f = []( string s, string t )
	{
		int N = s.size();
		for( int i = 0; i < N; i++ ) {
			if( s[i] != '?' && s[i] != t[i] ) return false;
		}
		return true;
	};
	int N = S.size();
	int NT = T.size();
	if( NT > N ) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	string ans;
	for( int i = N - NT; i >= 0; i-- ) {
		if( f( S.substr( i, NT ) , T ) ) {
			ans = S;
			ans.replace( i, NT, T );
			for( int i = 0; i < N; i++ ) if( ans[i] == '?' ) ans[i] = 'a';
			break;
		}
	}
	if( ans.size() == 0 ) cout << "UNRESTORABLE" << endl;
	else cout << ans << endl;
}


Measured memory_bytes: 3604
h,w=map(int,input().split())
l=[list(input()) for i in range(h)]
for x in range(h):
 for y in range(w):
  if l[x][y]=='.':
   c=0
   if x>0 and y>0:
    if l[x-1][y-1]=='#':c+=1
   if x>0:
    if l[x-1][y]=='#':c+=1
   if x>0 and y+1<w:
    if l[x-1][y+1]=='#':c+=1
   if y>0:
    if l[x][y-1]=='#':c+=1
   if y+1<w:
    if l[x][y+1]=='#':c+=1
   if x+1<h and y>0:
    if l[x+1][y-1]=='#':c+=1
   if x+1<h:
    if l[x+1][y]=='#':c+=1
   if x+1<h and y+1<w:
    if l[x+1][y+1]=='#':c+=1
   l[x][y]=str(c)
for j in range(h):
  l[j]=''.join(l[j])
  print(l[j])

Measured memory_bytes: 3188
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

int n, m, k;

int main()
{
	scanf("%d %d %d", &n, &m, &k);
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= m; j++)
			if (i * (m - j) + j * (n - i) == k) { printf("Yes\n"); return 0; }
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)


int main(){
    ll n, k;
    cin >> n >> k;
    vector<pll> dt(n);
    for(int i = 0; i < n; i++){
        cin >> dt[i].second >> dt[i].first;
    }

    sort(dt.begin(),dt.end());
    reverse(dt.begin(),dt.end());

    map<ll,ll> eat;
    ll val = 0;
    for(int i = 0; i < k; i++){
        eat[dt[i].second]++;
        val += dt[i].first;
    }
    ll pd = k;
    ll pu = k-1;
    ll diverse = ll(eat.size());

    ll ans = val + diverse*diverse;
    while(pu!=-1 && pd!=n){
        while(eat[dt[pd].second] > 0){
            pd++;
            if(pu==-1 || pd==n){break;}
        }
        while(eat[dt[pu].second] == 1){
            pu--;
            if(pu==-1 || pd==n){break;}
        }
        if(pu==-1 || pd==n){break;}
        val += dt[pd].first;
        eat[dt[pd].second]++;
        val -= dt[pu].first;
        eat[dt[pu].second]--;
        diverse++;

        ans = max(ans, val + diverse*diverse);
        pu--;pd++;
    }
    cout << ans << endl;


    return 0;

}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int gcd(int x,int y){
    if(x<y) swap(x,y); //常にx>=y
    //ユークリッドの互除法
    if(!(x%y)) return y;
    else return gcd(y,x%y);
}

int main(){
    long long n,m; cin>>n>>m;
    string s,t; cin>>s>>t;
    // if(max(n,m)%min(n,m)==0){
    //     cout<<-1<<endl;
    //     return 0;
    // }
    long long cnt=0;
    for(long long i=n*m/gcd(n,m);;i+=n*m/gcd(n,m),cnt++){
        if(i<0||i>LINF||cnt>1e3) break;
        // cout<<i<<endl;
        long long ss=0,tt=0;
        bool flg=1;
        while(ss<n&&tt<m){
            // cout<<ss<<" "<<tt<<endl;
            if(ss*i/n==tt*i/m){
                if(s[ss]!=t[tt]){
                    flg=0;
                    break;
                }
            }
            if(ss*i/n>tt*i/m) tt++;
            else ss++;
        }
        if(flg){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

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

        int n_row = sc.nextInt();
        int n = n_row % 10;

        if(n == 0 || n == 1 || n == 6 || n == 8){
            System.out.println("pon");
        }else if(n == 3){
            System.out.println("bon");
        }else{
            System.out.println("hon");
        }
    }
}

Measured memory_bytes: 35740
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n,c;
ll K;
int D[32][32];
int S[3][32];

int main()
{
	scanf("%d %d",&n,&c);
	for(int i=1;i<=c;i++){
		for(int j=1;j<=c;j++){
			scanf("%d",&D[i][j]);
		}
	}
	int v,id;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			scanf("%d",&v);
			id = (i+j)%3;
			S[id][v]++;
		}
	}
	int minv = 999999999;
	int cost;
	bool f=false;
	for(int p=1;p<=c;p++){
		for(int q=1;q<=c;q++){
			if(p==q)continue;
			for(int r=1;r<=c;r++){
				if(p==r || q==r)continue;
				cost=0;
				for(int i=1;i<=c;i++){
					cost += D[i][p]*S[0][i] + D[i][q]*S[1][i] + D[i][r]*S[2][i];
				}
				minv = min(minv,cost);
			}
		}
	}
	printf("%d\n",minv);

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
int gcd(int x,int y){ 
  if(y==0){
    return x;
  }else{
   return gcd(y,x%y);
  }
}

bool next(string &s){
  if(s[0]=='h'){
    s=s.substr(5);
    return 1;
  }
  s=s.substr(4);
  return 0;
}

int main(){
  string n;
  while(cin>>n){
    int above=0;
    int under=1;
    if(n=="#")break;
    reverse(n.begin(), n.end());
    if(!next(n))above=90;
    while(!n.empty()){
      under=under<<1;
      if(!next(n)){
	above=2*above + 90;
      }else{
	above=2*above - 90;
      }
    }
    int g=gcd(above,under);
    cout << above/g;
    if(under/g!=1){
      cout << "/" << under/g << endl;
    }else{
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1204
def resolve():
    s = str(input())
    t = str(input())
    ans = 1000
    tmp = 1000
    for pos in range(len(s)-len(t)+1):
        tmp = 0
        for i in range(len(t)):
            if s[pos+i] != t[i]:
                tmp += 1

        ans = min(ans, tmp)
    print(ans)
    
resolve()

Measured memory_bytes: 8984
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

const int MOD = 1000000007;
const ll INF = 1LL << 60;

int dp[3010][3010];

int main(){
  string s,t; cin >> s >> t;
  
  memset(dp,0,sizeof(dp));
  
  rep(i,s.size()){
    rep(j,t.size()){
      if(s[i] == t[j]) chmax(dp[i+1][j+1],dp[i][j]+1);
      chmax(dp[i+1][j+1],dp[i+1][j]);
      chmax(dp[i+1][j+1],dp[i][j+1]);
    }
  }
  
  string res = "";
  int i = s.size(), j = t.size();
  
  while(i > 0 && j > 0){
    if(dp[i][j] == dp[i-1][j]){
      i--;
    }else if(dp[i][j] == dp[i][j-1]){
      j--;
    }else{
      res = s[i-1]+res;
      i--,j--;
    }
  } 
  
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 35712
using System;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadLineInt();
            var list = new List<string> { "AC", "WA", "TLE", "RE" };

            var judge = new Dictionary<string, int>();
            list.ForEach(l => judge.Add(l, 0));

            for(var i = 0; i < N; i++)
            {
                var S = ReadLineStr();
                judge[S]++;
            }

            list.ForEach(l => Console.WriteLine($"{l} x {judge[l]}"));
        }

        #region 使いまわし
        static string ReadLineStr() { return Console.ReadLine(); }

        static int ReadLineInt() { return Convert.ToInt32(Console.ReadLine()); }
        static (int, int) ReadLineInt2()
        {
            var temp = Console.ReadLine().Split(' ');
            return (Convert.ToInt32(temp[0]), Convert.ToInt32(temp[1]));
        }
        static (int, int, int) ReadLineInt3()
        {
            var temp = Console.ReadLine().Split(' ');
            return (Convert.ToInt32(temp[0]), Convert.ToInt32(temp[1]), Convert.ToInt32(temp[2]));
        }
        static List<int> ReadLineIntList()
        {
            var data = new List<int>();
            foreach (var temp in Console.ReadLine().Split(' '))
            {
                data.Add(Convert.ToInt32(temp));
            }

            return data;
        }

        static long ReadLineLong() { return Convert.ToInt64(Console.ReadLine()); }
        static (long, long, long) ReadLineLong3()
        {
            var temp = Console.ReadLine().Split(' ');
            return (Convert.ToInt64(temp[0]), Convert.ToInt64(temp[1]), Convert.ToInt64(temp[2]));
        }
        static List<long> ReadLineLongList()
        {
            var data = new List<long>();
            foreach (var temp in Console.ReadLine().Split(' '))
            {
                data.Add(Convert.ToInt64(temp));
            }

            return data;
        }
        #endregion
    }
}


Measured memory_bytes: 30988
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long int
bool prep(string s1, string s2, int n1){
    for (int i = 0; i< n1; i++){
        if(s1[i]!=s2[i]){
            return false;
        }
    }
    return true;
}
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    int n1 = s1.length();
    int n2 = s2.length();
    if(n2==n1+1 && prep(s1, s2, n1)){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 3600
#include<iostream>
using namespace std;
int main() {
    int h, w; cin >> h >> w;
    char s[h + 2][w + 2];
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            cin >> s[i][j];
        }
    }
    for (int i = 0; i <= h; ++i) {
        s[i][0] = '0';
        s[i][w + 1] = '0';
    }
    for (int j = 0; j <= w; ++j) {
        s[0][j] = '0';
        s[h + 1][j] = '0';
    }
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            int cnt = 0;
            if (s[i][j] == '.') {
                if (s[i - 1][j] == '#') {
                    cnt++;
                }
                if (s[i + 1][j] == '#') {
                    cnt++;
                }
                if (s[i][j - 1] == '#') {
                    cnt++;
                }
                if (s[i][j + 1] == '#') {
                    cnt++;
                }
                if (s[i - 1][j - 1] == '#') {
                    cnt++;
                }
                if (s[i - 1][j + 1] == '#') {
                    cnt++;
                }
                if (s[i + 1][j + 1] == '#') {
                    cnt++;
                }
                if (s[i + 1][j - 1] == '#') {
                    cnt++;
                }
                s[i][j] = cnt + '0';
            }
        }
    }
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            cout << s[i][j];
            if (j == w) {
                cout << endl;
            }
        }
    }
    return 0;
}





Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String[] o = scanner.next().split("");
		String[] e = scanner.next().split("");
		String[] i = scanner.next().split("");

		System.out.print(o[0].toUpperCase() + e[0].toUpperCase() + i[0].toUpperCase());
	}
}

Measured memory_bytes: 22740
def print_component(a, b, n):
    for _ in range(25):
        print(a * 100)
        if n:
            x = min(n, 50)
            n -= x
            print((a+b)*x + a*2*(50-x))
        else:
            print(a * 100)


A, B = map(int, input().split())

print('100 100')
print_component('#', '.', A - 1)
print_component('.', '#', B - 1)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int ans = 1000 - (x % 1000);
    if (ans == 1000) {
      ans = 0;
    }
    System.out.println(ans);
    sc.close();
  }
}


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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int x,y;
  cin>>x>>y;

  if(x+y==4)
    cout<<2;
  else if(x+y==3)
    cout<<3;
  else
    cout<<1;



  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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++)
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
typedef long long ll;

using namespace std;

int main() {
  int n;
  cin >> n;
  int dp[4][13];
  REP(i, 4)
  {
    REP(j, 13)
    {
      dp[i][j] = 0;
    }
  }

  REP(i, n)
  {
    string s;
    int num;
    cin >> s >> num;
    if (s == "S")
    {
      dp[0][num - 1] = 1;
    }
    else if (s == "H")
    {
      dp[1][num - 1] = 1;
    }
    else if (s == "C")
    {
      dp[2][num - 1] = 1;
    } else if (s == "D")
    {
      dp[3][num - 1] = 1;
    }
  }

  string ans;
  REP(i, 4)
  {
    REP(j, 13)
    {
      if (dp[i][j] == 0) {
        if (i == 0) {
          ans = "S";
        } else if (i == 1) {
          ans = "H";
        } else if (i == 2) {
          ans = "C";
        } else if (i == 3) {
          ans = "D";
        }

        cout << ans << " " << j+1 << "\n";
      }
    }
  }
}



Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	ll a, b, n;
	cin >> a >> b >> n;
	ll ans = floor((double) a / b * min(b - 1, n));
	cout << ans << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3760
//変数の数を減らす
//loopの上限は 1e8回/秒

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

int main()
{
    int K, S;
    cin >> K >> S;
    int counter = 0;
    for (int i = 0; i <= K; i++)
    {
        for (int j = 0; j <= K; j++)
        {
            int k = S - i - j;
            if (k >= 0 && k <= K)
            {
                counter++;
            }
        }
    }
    cout << counter << endl;
}


Measured memory_bytes: 256
// ABC143_C
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <cstring>  // std::memset 初期化
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N;
    cin >> N;
    string S;
    cin >> S;
    
    // calculation
    stack<char> stk;
    char ch;
    REP(i, S.length()) {
        ch = S[i];
        if (stk.empty()) {
            stk.push(ch);
        } else {
            if (stk.top() ==  ch) {
                continue;
            } else {
                stk.push(ch);
            }
        }
    }
    cout << stk.size() << "\n";
    
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <unordered_set>
#include <cstdint>
#include <vector>
#include <sstream>
#include <string>
#include <climits>
#include <set>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <numeric>
#include <map>
using namespace std;

int main()
{
	string str;
	cin >> str;
	int n = str.length();

	int cnt = 0;

	for (int i = 0; i < n / 2; i++)
	{
		if (str[i] != str[n - i - 1])
			cnt++;
	}

	cout << cnt;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
 
typedef long long lld;
typedef vector<lld> vlld;
typedef pair<lld,lld> pi;
typedef tuple<lld,lld,lld> tup;
const lld mod=(lld)1e9+7;
struct Node{
      lld w,v;
};
lld dp[101][100001];

lld solve(Node a[],lld n,lld W)
{
      if(W<0 || n==0)
      return 0;
      if(dp[n][W]!=-1)
      return dp[n][W];
      if(W-a[n-1].w<0)
      {
      dp[n][W]=solve(a,n-1,W);
      return dp[n][W];
      }
      
       dp[n][W]=max(a[n-1].v+solve(a,n-1,W-a[n-1].w),solve(a,n-1,W));
       return dp[n][W];
}

int main() {
      
      lld n,W;
      cin>>n>>W;
      Node a[n];
      forn(i,n)
      {
            cin>>a[i].w>>a[i].v;
      }
      
      memset(dp,-1,sizeof(dp));
      cout<<solve(a,n,W);
      
 
  return 0;
}

Measured memory_bytes: 82536
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test1 cout << "test1" << endl;
#define test2 cout << "test2" << endl;
#define fixprecision(n) fixed; cout << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define iikae auto&
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

int main(){
  kyopro;
  ll N, K;
  cin >> N >> K;
  //n=2 0 n=3 1 n=4 3
  ll saidai{1};
  rep(i, N-2, N){
    saidai *= i;
  }
  saidai /= 2;
  if(saidai < K){
    cout << "-1" << rt;
    return 0;
  }
  ll sen = saidai - K;
  cout << sen + N - 1 << rt;
  rep(i, 2, N + 1){
    cout << 1 << sp << i << rt;
  }
  ll kara{2};
  ll made{3};
  rep(i, 0, sen){
    cout << kara << sp << made << rt;
    if(made == N){
      kara++;
      made = kara + 1;
    }
    else{
      made++;
    }
  }
}

Measured memory_bytes: 256
import sys
from collections import deque
n = int(sys.stdin.readline())
lines = sys.stdin.readlines()

Q = deque()
for i in range(n):
    command = lines[i].split()
    if command[0] == "insert":
        Q.appendleft(command[1])
    elif command[0] == "deleteFirst":
        Q.popleft()
    elif command[0] == "deleteLast":
        Q.pop()
    elif command[0] == "delete":
        try:
            Q.remove(command[1])
        except:
            pass
print(" ".join(Q))

Measured memory_bytes: 214284
import sys

lines = sys.stdin.readlines()
N, M, X = map(int, lines[0].split())
A = []
C = []

for i in range(N):
    line = list(map(int, lines[i+1].split()))
    A.append(line[1:])
    C.append(line[0])

# return []
def full_search():
    costs = []
    for i in range(2**N):
        vals = [0] * M
        cost = 0

        # iを二進数に直して扱う。それぞれのビットがn冊目の本を買うかどうかに匹敵。
        for j in range(N):
            # ビットを移動しながらn冊目の本を買う際のコストと経験値を計算する
            if ((i >> j) & 1):
                # 現在の組み合わせに対して
                # 全てのアルゴリズム分を計算
                cost += C[j]

                # 全てのアルゴリズム(m)に対して経験値を求める
                for m in range(M):
                    vals[m] += A[j][m]

        combination_ok = True
        for m in range(M):
            if vals[m] >= X:
                continue
            else:
                combination_ok = False
                break

        if combination_ok:
            costs.append(cost)
    return costs

costs = full_search()
if len(costs) == 0:
    print(-1)
else:
    print(min(costs))


Measured memory_bytes: 9236
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

string S;
int goal[2];
vector<int> v[2];

unordered_map<int,bool> dp[2][4000];
bool solve(int turn, int n, int x){
	if(v[turn].size() == n){
		return (x == goal[turn]);
	}
	if(dp[turn][n].count(x)) return dp[turn][n][x];
	return dp[turn][n][x] = solve(turn, n+1, x+v[turn][n]) | solve(turn, n+1, x-v[turn][n]);
}

signed main(){
	cin >> S >> goal[0] >> goal[1];
	S += 'T';

	int cnt = 0;
	int turn = 0;
	rep(i, S.size()){
		if(S[i] == 'F') cnt++;
		else{
			v[turn].pb(cnt);
			cnt = 0;
			turn ^= 1;
		}
	}
	goal[0] -= v[0].front();
	v[0].erase(v[0].begin());

	if(solve(0, 0, 0) && solve(1, 0, 0)){
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}

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

int main(void){
	int N;
	cin >> N;
	
	if((N%4==0) || (N%7==0)){
		cout << "Yes" << endl;
	}else if(N >=4 || N >= 7){
		bool yes = false;
		for(int i=N;i>=0;i-=4){
			if(i%7==0){
				cout << "Yes" << endl;
				yes = true;
				break;
			}
		}
		if(!yes)  cout << "No" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include<stdio.h>
using namespace std;
typedef long long ll;
int main() {
    int A;
    int B;
    cin >> A >> B ;
    int ans;
    if (A>=13){
        ans=B;}
    else if(13>A && 6<=A){
        ans=B/2;
    }
    else{
        ans=0;
    }


    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	if (N%2==0){
		printf("%.10lf\n",(double)(N/2)/N);
	}else{
		printf("%.10lf\n",(double)(N/2+1)/N);
	}
	return 0;
}

Measured memory_bytes: 256
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
const int siz = 1e5 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;

void solve(){
  ll n;
  cin >> n;
  ll a[n];
  ll sum = 0;
  ll freq[siz] = {0};
  for(ll &i : a) cin >> i, sum += i, freq[i]++;
  ll q;
  cin >> q;
  while(q--) {
    ll b, c;
    cin >> b >> c;
    ll minus = b*freq[b];
    sum -= minus;
    sum += freq[b]*c;
    freq[c] += freq[b];
    freq[b] = 0;
    cout << sum << endl;
  }

}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  // cin >> t;
  while(t--){
    //tt++;
    //cout << "Case #" << tt << ": ";
    solve();
  }
  return 0;
}  

Measured memory_bytes: 5216
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)

	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	ss := make([]Station, n-1)
	for i := 0; i < n-1; i++ {
		ss[i].c = getNextInt(scanner)
		ss[i].s = getNextInt(scanner)
		ss[i].f = getNextInt(scanner)
	}

	for i := 0; i < n-1; i++ {
		s := ss[i].s + ss[i].c
		for ii := i + 1; ii < n-1; ii++ {
			if s <= ss[ii].s {
				s = ss[ii].s + ss[ii].c
				continue
			}
			s = ss[ii].s + ((s-ss[ii].s-1)/ss[ii].f+1)*ss[ii].f + ss[ii].c
		}
		fmt.Fprintln(writer, s)
	}
	fmt.Fprintln(writer, 0)

	writer.Flush()
}

type Station struct {
	c, s, f int
}


Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> v;
int main(void){
    ll n,ans=0,rans=0;
    cin>>n;
    ll s[n],t[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
     for(int i=0;i<n;i++){
        cin>>t[i];
    }
    for(int i=0;i<30;i++){
        v.clear();
        ll T=pow(2,i);
        for(int j=0;j<n;j++){
            v.push_back(t[j]%(2*T));
        }
        sort(v.begin(),v.end());
        ans=0;
        for(int j=0;j<n;j++){
            ll l1=lower_bound(v.begin(),v.end(),T-s[j]%(2*T))-v.begin();
            ll l2=lower_bound(v.begin(),v.end(),2*T-s[j]%(2*T))-v.begin();
            ll l3=lower_bound(v.begin(),v.end(),3*T-s[j]%(2*T))-v.begin();
            ll l4=lower_bound(v.begin(),v.end(),4*T-s[j]%(2*T))-v.begin();
            ans+=l2-l1+l4-l3;
            
        }
        //cout<<ans<<endl;
        if(ans%2==1)rans+=pow(2,i);
    }
    cout<<rans<<endl;
}


Measured memory_bytes: 5492
#include <stdio.h>

int judge(int num) {
	if (num >= 0 && num <= 100) {
		return 1;
	} else {
		return 0;
	}
}

int main () {
	int inNum1, inNum2, inNum3;
	
	scanf("%d %d %d", &inNum1, &inNum2, &inNum3);
	
	if (judge(inNum1)*judge(inNum2)*judge(inNum3) == 0) {
		printf("error\n");
		return 0;
	}
	
	if (inNum1 < inNum2 && inNum2 < inNum3) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	
}




Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
	cin >> s;
	vector<long long> prev(2019, 0);
	long long ans = 0;
	prev[s[0] - '0'] = 1;
	for(int pos = 1; pos < s.size(); ++pos){
		vector<long long> now(2019);
		for(int res = 0; res < 2019; ++res)
			now[(res*10 + s[pos] - '0')%2019] = prev[res]; 
		ans+= now[0];
		prev = now;
		prev[s[pos] - '0']++; // como empezar de nuevo
	}
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 3752
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(void){
	int i,n,p;
	double b,sum,max;

	int x[100];
	int y[100];
	double wa[100]={0};
	double d[4]={0};

	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%d",&x[i]);
	}
	for(i=0;i<n;i++){
		scanf("%d",&y[i]);
	}
	for(p=1;p<4;p++){
		sum=0;
		for(i=0;i<n;i++){
			wa[i]=abs(x[i]-y[i]);
			b=pow(wa[i],p);
			sum=b+sum;
		}
		d[p]=pow(sum,(1/(double)p));
		printf("%lf\n",d[p]);
	}
	max=0;
	for(i=0;i<n;i++){
		if(max<wa[i]){
			max=wa[i];
		}
	}
	printf("%lf\n",max);

	return 0;
}

Measured memory_bytes: 700
from collections import deque


N,M = map(int,input().split())

dic = {}

for i in range(M):

    a,b,c = map(int,input().split())

    a -= 1
    b -= 1

    if a not in dic:
        dic[a] = []

    dic[a].append([b,c])

lis = [[0] * N for j in range(N)]
lis[0][0] = 1
lmax = [0] * N
lmax[0] = 1

mcost = [-1 * float("inf")] * N
mcost[0] = 0

q = deque([])
q.append(0)
cnt = 0

while len(q) > 0:

    now = q.pop()

    if now not in dic or lmax[now] > N:
        continue

    for npath in dic[now]:

        b = npath[0]
        c = npath[1]

        if mcost[now] + c > mcost[b]:
            mcost[b] = mcost[now] + c
            lis[b] = lis[now].copy()
            lmax[b] = lmax[now]
            lis[b][b] += 1
            lmax[b] = max(lmax[b],lis[b][b])

            if lmax[b] >= 2:
                mcost[b] = float("inf")
            q.append(b)

    if lis[N-1][N-1] != -1 * float("inf") and lmax[N-1] >= 2:
        mcost[N-1] = float("inf")
        break

    elif mcost[N-1] == float("inf"):
        break

print (mcost[N-1])


Measured memory_bytes: 11756
#include<bits/stdc++.h>
using namespace std;
int main(void) {
long long X;
cin >> X;
long long ans = 1;
for (int i = 1; i < X; ++i) {
    for (int j = 2; j < X; ++j) {
   	    long long beki = pow(i, j);
        if (beki <= X) {
        ans = max(ans, beki);
        }
    }
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std ; 
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define pii pair<int,int> 
long long MOD  = 1e9+7;


signed main(){
    fast;
    int a,b; cin >> a >> b;
    cout << max(a+b, max(a-b , a*b)) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int height[10];
	int i;
	for(i=0;i<10;i++){
		scanf("%d",&height[i]);
	}
	int j,temp;
	for(j=0;j<9;j++){
		for(i=j+1;i<10;i++){
			if(height[j]<height[i]){
				temp=height[j];
				height[j]=height[i];
				height[i]=temp;
			}
		}
	}
	for(j=0;j<3;j++){
		printf("%d\n",height[j]);
	}
	return 0;
}

Measured memory_bytes: 600
n = int(input())
w = [input() for _ in range(n)]

flg = True
for i in range(n - 1):       
    if w[i][-1] != w[i + 1][0]:
        flg = False
        break
for i in range(n):
    for j in range(i):
        if w[i] == w[j]:
            flg = False
            break
    if not flg:
        break
    
print('Yes' if flg else 'No')

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

int main()
{
	long long int n,i, j,k, res, r = 0, g = 0, b = 0;
	cin >> n;
	string s;
	cin >> s;
	for (i = 0; i < n; i++)
	{
		if (s[i] == 'R')
			r++;
		else if (s[i] =='G') g++;
		else b++;
	}
	res = r*b*g;
	int x=(int)'R' + (int)'G' + (int)'B';
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			k = 2*j - i;
			if(k<n&&((int)s[i] + (int)s[j]+(int)s[k])== x)
			      res--;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
typedef struct
{
    char suit;
    int value;
} card;

void cardChecker(card allcard[], card Card, int Check[])
{
    int j;
    for (j = 0; j < 52;j++){
        if (allcard[j].suit == Card.suit && allcard[j].value == Card.value){
            //printf("check\n");
            Check[j] = 1;
            break;
        }
    }
}

void noCardPrint(int Check[],card allcard[]){
    int i;
    for (i = 0; i < 52; i++)
    {
        if(Check[i] == 0){
            printf("%c %d\n", allcard[i].suit, allcard[i].value);
        }
    }
}

int main(void){
    int N;
    card allcard[53];
    int i;
    card Card;
    int Check[53];
    char a;
    int b;
    for (i = 0; i < 52; i++)
    {
        Check[i] = 0;
    }
    for (i = 0; i < 13; i++){
        allcard[i].suit = 'S';
        allcard[i].value = i + 1;
        allcard[i + 13].suit = 'H';
        allcard[i + 13].value = i + 1;
        allcard[i + 26].suit = 'C';
        allcard[i + 26].value = i + 1;
        allcard[i + 39].suit = 'D';
        allcard[i + 39].value = i + 1;
    }
    scanf("%d", &N);
    for (i = 0; i < 2 * N;i++)
    {
        scanf("%c", &a);
        scanf("%d", &b);
        Card.suit = a;
        Card.value = b;
        //printf("k=%d", k);
        cardChecker(allcard, Card, Check);
    }
    noCardPrint(Check, allcard);
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <queue>
using namespace std;

int main(){
  queue<int> qi;
  queue<string> qs;
  int n,q,t;
  string s;
  cin >> n >> q;
  for(int i=0;i<n;i++){
    cin>>s>>t;
    qs.push(s);
    qi.push(t);
  }
  t=0;
  while(qi.size()){
    if(qi.front()>q){
      qi.push(qi.front()-q);qi.pop();
      qs.push(qs.front());qs.pop();
      t+=q;
    }else {
      t+=qi.front();qi.pop();
      cout<<qs.front()<<" "<<t<<endl;qs.pop();    
    }
  }
  return 0;
}
  

Measured memory_bytes: 4176
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
long long dp[100001][4];
int main()
{
    //freopen("FORM.inp", "r", stdin);
    //freopen("FORM.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    long long n, f = LONG_MIN; long long ans = 0;
    cin >> n;
    int a[n+1][4];
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= 3; j++) cin >> a[i][j];
    dp[1][1] = a[1][1]; dp[1][2] = a[1][2]; dp[1][3] = a[1][3];
    for(int i = 1; i <= n; i++)
    {
        dp[i][1] = max(dp[i-1][2] + a[i][1], dp[i-1][3] + a[i][1]);
        dp[i][2] = max(dp[i-1][1] + a[i][2], dp[i-1][3] + a[i][2]);
        dp[i][3] = max(dp[i-1][1] + a[i][3], dp[i-1][2] + a[i][3]);
    }
    for(int i = 1; i <= 3; i++) f = max(f, dp[n][i]);
    cout << f;

}


Measured memory_bytes: 4992
#include<stdio.h>
int main(void)
{
int a ,b ,c;
scanf("%d%d%d" ,&a ,&b ,&c);
if(a < b&&b < c)printf("Yes\n");
if(a > b||b > c||a == b||c == b||a == c)printf("No\n");
return 0;
}

Measured memory_bytes: 1816