akhauriyash/Code-Regression huggingface dataset:
// finish date: 2018/06/17
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <functional>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define pii pair<int,int>
const int bigmod = 998244353;
#define INF 1050000000

//足し算
int add(int a, int b) {
    return (a + b) % bigmod;
}

//掛け算
int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}

int N;
vi fact;

//割り算  -  逆元(求めたい数とbigmodを渡す)
int divine(int a, int p = bigmod, int b = -1) {
    if (b < 0) b = p - 2;  //int gyakugen(int a, int p, int b = p - 2とできなかったため。)
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        int d = divine(a, p, b / 2);
        return mul(d, d);
    } else {
        return mul(a, divine(a, p, b - 1));
    }
}

//nやkが大きな場合nCkをO(1)で求めるようにプログラムを適切に変更する。
int nCk_gyakugen(int n, int k, int p = bigmod) {
    if (k == 0) return 1;
    if (n == 0) return 0;
    if (n < k) return 0;
    int denominator = fact[n];
    int molecule1 = fact[k];
    int molecule2 = fact[n - k];
    return mul(denominator, mul(divine(molecule1), divine(molecule2)));
}

int main() {
    int N, A, B;
    ll K;
    cin >> N >> A >> B >> K;
    int ans = 0;

    fact = vi(N + 1, 0);
    fact[0] = 1;
    FOR(i, 1, N + 1) {
        fact[i] = mul(i, fact[i - 1]);
    }

    rep(n, N + 1) {
        ll res = K - (ll) A * n;
        if (res % B != 0) continue;
        ll m = res / B;
        if (!(0 <= m && m <= N)) continue;
        ans = add(ans, mul(nCk_gyakugen(N, n, bigmod), nCk_gyakugen(N, (int) m, bigmod)));
    }
    cout << ans << endl;

    return 0;
}






Measured memory_bytes: 1408
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
using std::ostream;

#include <cstring>

struct node {
    int data;
    node *prev;
    node *next;
};

struct DLL {
    node *N;

    DLL() : N(new node) {
        N->data = -1;
        N->prev = N;
        N->next = N;
    }

    ~DLL() {}

    node *_insert(int x) {
        node *tmp = new node;
        tmp->data = x;
        tmp->next = N->next;
        tmp->prev = N;

        N->next->prev = tmp;
        N->next = tmp;

        return N;
    }

    node *_delete(int x) {
        for (node *current = N->next; current->data != -1; current = current->next) {
            if (current->data == x) {
                current->prev->next = current->next;
                current->next->prev = current->prev;
                break;
            }
        }
        return N;
    }

    node *_deleteFirst() {
        N->next->next->prev = N;
        N->next = N->next->next;
        return N;
    }

    node *_deleteLast() {
        N->prev->prev->next = N;
        N->prev = N->prev->prev;
        return N;
    }

    void print() {
        bool flag=false;
        for (node *current = N->next; current->data != -1; current = current->next) {
            if(flag){
                cout << " ";
            }
            else{
                flag = true;
            }

            cout << current->data;
        }
        cout << endl;
    }
};

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

    DLL *list = new DLL;

    for (int i = 0; i < n; ++i) {
        char op[20];
        int x;

        cin >> op;

        if(op[0] == 'i'){
            cin >> x;
            list->_insert(x);
        }else if(op[0] =='d'){
            if (strlen(op) > 6){
                if (op[6] == 'F') list->_deleteFirst();
                else if (op[6] == 'L') list->_deleteLast();
            }
            else{
                cin >> x;
                list->_delete(x);
            }
        }
    }

    list->print();

}



Measured memory_bytes: 37416
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define mod 1000000007
#define pb push_back  
#define endl "\n"
#define fi first
#define se second 
#define ll long long
int power(int a,int b,int m=mod)
{
    if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
     
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	int c=(a%m+b%m);	if(c>=m)	c-=m;	return c;}
int sub(int a,int b,int m=mod){	int c=(a%m-b%m);	if(c<0)		c+=m;	return c;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}

int32_t main()
{
   IOS
   
   ll n;
   cin>>n;
   
   ll a[n],i,sum=0,ans=0;
   for(i=0;i<n;i++)
   {
   	cin>>a[i];
   	sum=add(sum,a[i]);
   }
   for(i=0;i<n;i++)
   {
   	sum=sub(sum,a[i]);
   	ans = add(ans,mul(sum,a[i]));
   }
   cout<<ans<<endl;
   
}

Measured memory_bytes: 5208
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        String T = sc.nextLine();
        char [] app = new char[S.length()];
        char [] down = new char[T.length()];
        int [] anc = new int[S.length()-T.length()];
        int Min = 0;
        
        
        for(int i = 0;i < S.length();i++){
            app[i] = S.charAt(i);
        }
        for(int i = 0;i < T.length();i++){
            down[i] = T.charAt(i);
        }
        if(S.length() == T.length()){
            int count = 0;
            for(int i = 0;i < T.length();i++){
                if(app[i] != down[i]){
                    count++;
                }
                Min = count;
            }
        System.out.println(Min);
        }else{
            for(int i = 0;i < S.length()-T.length();i++){
                int count = 0;
                for(int l = 0;l < T.length();l++){
                    if(app[i+l] != down[l]){
                        count++;
                    }  
                    anc[i] = count;
                }
            }
            Min = anc[0];
            for(int i = 1 ; i < anc.length; i++){
                if(Min > anc[i]){
                    Min = anc[i];
                    }
                }
                System.out.println(Min);
        }
    }
}


Measured memory_bytes: 36100
N = int(input())
L = list(map(int, input().split()))

def foo(i, j, k):
  if L[i] == L[j] or L[i] == L[k] or L[j] == L[k]:
    return 0
  if L[i] + L[j] - L[k] > 0 and L[i] + L[k] - L[j] > 0 and L[j] + L[k] - L[i] > 0:
    return 1
  else:
    return 0

ans = 0
for i in range(N):
  for j in range(i+1, N):
    for k in range(j+1,N):
      if foo(i, j, k):
        ans += 1
print(ans)

Measured memory_bytes: 9212
#include<bits/stdc++.h>
using namespace std;
#define T top()
#define E end()
#define PS push
#define Q queue
#define PP pop()
#define L0 (LL)0
#define V vector
#define ST stack
#define FI first
#define MAX 4e18
#define MIN -MAX
#define DQ deque
#define RE rend()
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define SE second
#define DL double
#define G getline
#define IN insert
#define endl "\n"
#define EM empty()
#define RB rbegin()
#define PSB push_back
#define PI acos(-1.00)
#define PPB pop_back()
#define PSF push_front
#define ub upper_bound
#define lb lower_bound
#define MD 1000000007
#define PPF pop_front()
#define LL long long int
#define PQ priority_queue
#define N cout<<"NO"<<endl
#define Y cout<<"YES"<<endl
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define UOSMOY v.C;w.C;ww.C;u.C;uu.C;uo.C;vo.C;vu.C;ab.C;bc.C;cc.C;uuu.C;a.C;b.C;c.C
V<LL>v;
V<LL>w,ab;
set<LL>uo;
map<LL,LL>u;
map<LL,LL>ww,cc,bc;
LL ar[500][500];
LL br[500][500];
LL cr[500][500];
V<pair<LL,LL> >uu;
map<LL,V<LL> >uuu;
map<pair<LL,LL>,LL> vo;
map<pair<LL,LL>,LL> vu;
int main()
{
//  BRR;
//  file;
    FAST;
    char ch;
    string a,b,c;
    DL x,y,d,e,f,g,h;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r=0;
//    cin>>tt;
    while(tt--)
    {
        UOSMOY;
        cin>>n>>m;
        if(n*4==m)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
        else if(n*2==m)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
        s=0;
        for(i=1; i<=n/2; i++)
        {
            l=n-i;
            if((i*2)+(l*4)==m)
            {
                cout<<"Yes"<<endl;
                s++;
                break;
            }
            else if((i*4)+(l*2)==m)
            {
                cout<<"Yes"<<endl;
                s++;
                break;
            }
        }
        if(s==0)
        {
            cout<<"No"<<endl;
        }

    }
    return 0;
    //IN
    //AL
}


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

using namespace std;

#define MAX 2010
typedef long long ll;
const ll MOD = (1e9) + 7;

ll dp[MAX][MAX];

ll extgcd(ll a, ll b, ll &x, ll &y)
{
    ll d = a;
    if (b != 0) {
	d = extgcd(b, a % b, y, x);
	y -= (a / b) * x;
    } else {
	x = 1; y = 0;
    }
    return d;
}

ll mod_inverse(ll a, ll m)
{
    ll x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}

int main()
{
    ll N, D, X;
    while (cin >> N >> D >> X, N) {
        ll res = 0, comb = 1;
        memset(dp, 0, sizeof(dp));
        dp[0][0] = 1;
        for (int i = 1; i <= min(N, D); i++) {                        
            comb *= (D - i + 1) % MOD;
            comb %= MOD;
            comb *= mod_inverse(i, MOD);
            comb %= MOD;

            ll sum[MAX] = {};
            for (int j = 0; j <= N; j++) {
                sum[j] += dp[i-1][j];                
                if (j > 0) sum[j] += sum[j-1];
                sum[j] %= MOD;
            }

            for (int j = 0; j <= N; j++) {
                if (j > 0) dp[i][j] = sum[j-1];
                if (j - X >= 0) {
                    dp[i][j] += (-sum[j-X] + MOD) % MOD;
                }
                dp[i][j] %= MOD;
            }                
            res += dp[i][N] * comb;
            res %= MOD;
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 34664
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest._300Problems_remain_
{
    class CF2016_B
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int bottom = 1;
            int top = n + 1;
            while (bottom + 1 < top)
            {
                long x = (bottom + top) / 2;

                if (n > x * (x + 1) / 2)
                {
                    bottom = (int)x;
                }
                else
                {
                    top = (int)x;
                }
            }
            bottom++;
            for(int i = bottom; i > 0; i--)
            {
                if (n >= i)
                {
                    Console.WriteLine(i);
                    n -= i;
                }
            }
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		String S=stdIn.next();
		long A[]=new long[S.length()+1];
		long ans=0;
		for(int i=0;i<S.length();i++){
			char c=S.charAt(i);
			if(c=='<'&&A[i+1]<=A[i])
				A[i+1]=A[i]+1;
		}
		for(int i=S.length()-1;i>=0;i--){
			char c=S.charAt(i);
			if(c=='>'&&A[i]<=A[i+1])
				A[i]=A[i+1]+1;
		}
		for(int i=0;i<S.length()+1;i++){
			ans+=A[i];
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 32732
from itertools import permutations
from scipy.sparse.csgraph import floyd_warshall
n,m,r=map(int,input().split())
R=list(map(int,input().split()))
l=[[float('inf')]*n for _ in range(n)]
for _ in range(m):
    a,b,c,=map(int,input().split())
    a-=1
    b-=1
    l[a][b]=c
    l[b][a]=c
for i in range(n):
    l[i][i] = 0 #自身のところに行くコストは０
def warshall_floyd(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j]=min(d[i][j],d[i][k]+d[k][j])
                
    return d
#F=warshall_floyd(l)
F1 = floyd_warshall(l)
ans=float('inf')
for v in permutations(R):
    temp=0
    for i in range(r-1):
        temp+=F1[v[i]-1][v[i+1]-1]
    ans=min(ans,temp)
print(int(ans))

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


void solve(long long N, long long M){
    if(M<=2*N){
        cout << M/2 << endl;
    }
    else{
        M -= 2*N;
        cout << N + M/4 << endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int x1, y1, x2, y2;
    io.read(x1, y1, x2, y2);
    int a = x2 - x1;
    int b = y2 - y1;

    int x3 = a - b + x1;
    int y3 = a + b + y1;
    int x4 = -b + x1;
    int y4 = a + y1;

    cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4;
    return 0;
}

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

using namespace std;
#define ll long long

int a[200010] = {};
int b[200010] = {};
int main() {
	int n;
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b, b + n);
	int l = b[n / 2 - 1], r = b[n / 2];
	for (int i = 0; i < n; i++) {
		if (a[i] <= l) cout << r << endl;
		else
			cout << l << endl;
	}
	return 0;
}

Measured memory_bytes: 3712
#define _USE_MATH_DEFINES
#include <iostream> 
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std; 
int main(){
	double a, b, c, d, e, f, x, y;
	while(cin >> a >> b >> c >> d >> e >> f){
		x = (c*e - f*b) / (a*e - d*b);
		y = (c*d - f*a) / (b*d - e*a);
		if (x==0){ x=0; }
		if (y==0){ y=0; } 
		std::cout << std::fixed;
		std::cout << std::setprecision(3) << x << " " << y << endl;
	}
	return 0;
}


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

using namespace std;

int main()
{
    int n, m;
    
    while (scanf("%d %d", &n, &m) && n){
        char s[128][9];
        int pr[128];
        
        for (int i = 0; i < n; i++){
            scanf("%s %d", s[i], pr + i);
        }
        
        int ret = 0;
        
        for (int i = 0; i < m; i++){
            char t[9];
            scanf("%s", t);
            for (int j = 0; j < n; j++){
                bool ok = true;
                for (int k = 0; k < 8; k++){
                    if (s[j][k] != '*' && s[j][k] != t[k]) ok = false;
                }
                ret += ok * pr[j];
            }
        }
        
        printf("%d\n", ret);
    }
    
    return (0);
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

typedef long long ll;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;

void solve()
{
  int n; cin >> n;
  int cnt1=0, cnt2=0;
  for (int i=0; i<n; i++) {
    int a;
    cin >> a;
    if (a%4==0) {
      cnt1++;
    } else if (a%2==0) {
      cnt2++;
    }
  }

  int tmp = n - cnt1*2;
  if (tmp <= 1 || tmp <= cnt2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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


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

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

	const long long numAlpha = 26;
	string out;
	while (N > 0) {
		out.insert(out.begin(), 'a' + (N - 1) % numAlpha);
		N = (N - 1) / numAlpha;
	}
	cout << out;

	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
const ll mod=1000000007;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  int n,k; cin>>n>>k;
  vector<double> p(n);
  rep(i,n) cin>>p[i];

  double ans=0;
  rep(i,k){
    ans+=p[i]*(p[i]+1.0)/2.0/p[i];
  }
  double ma=ans;
  for(int i=k;i<n;i++){
    ans-=p[i-k]*(p[i-k]+1.0)/2.0/p[i-k];
    ans+=p[i]*(p[i]+1.0)/2.0/p[i];
    ma=max(ma,ans);
  }
  cout<<fixed<<setprecision(10)<<ma<<endl;

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h> 
typedef long long ll;
using namespace std;
const ll mod =998244353; 
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int k;
int ans[100005],len=1;
void solve(){
	int i,now=1;
	bool flag=0;
	ans[now]++;
	while(ans[now]>=10||(now!=len&&abs(ans[now]-ans[now+1])>=2)) flag=1,ans[++now]++;
	if(now>len) len=now;
	if(!flag) return ;
	for(i=now-1;i>=1;i--) ans[i]=max(0,ans[i+1]-1);
	return ;
}
int main(){
	int i,j,now;
    //freopen("a.in","r",stdin);
    k=read();
	if(k<=9) {printf("%d\n",k);return 0;}
	k-=9;
	ans[1]=9;
	while(k){
		solve();
		k--;
	}
	for(i=len;i>=1;i--) printf("%d",ans[i]);
}

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

using namespace std;

const int MOD = 1e9 + 7;

struct mat {
	vector <vector<int> > num;
	
	mat() { }
	
	mat(int n, int m) {
		num = vector<vector<int>>(n, vector<int>(m));
	}
	
	mat operator * (const mat& T) const {
		mat res = mat(num.size(), T.num[0].size());
		
		for (int i = 0; i < num.size(); i++) {
			for (int j = 0; j < T.num[0].size(); j++) {
				for (int k = 0; k < num[0].size(); k++) {
					res.num[i][j] = (res.num[i][j] + 1LL * num[i][k] * T.num[k][j]) % MOD;
				}
			}
		}
		
		return res;
	}
}iden;

mat my_pow(mat a, long long lv) {
	if (lv == 0) return iden;
	mat tmp = my_pow(a, lv / 2);
	tmp = tmp * tmp;
	if (lv & 1) tmp = tmp * a;
	return tmp;
}

int main() {
	int n;
	long long k;
	scanf("%d%lld", &n, &k);
	
	iden = mat(n, n);
	
	for (int i = 0; i < n; i++) {
		iden.num[i][i] = 1;
	}
	
	mat a = mat(n, n);
	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			scanf("%d", &a.num[j][i]);
		}
	}
	
	a = my_pow(a, k);
	mat b = mat(1, n);
	
	for (int i = 0; i < n; i++) b.num[0][i] = 1;
	
	b = b * a;
	
	long long res = 0;
	
	for (int i = 0; i < n; i++) res = (res + b.num[0][i]) % MOD;
	
	printf("%lld\n", res);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int n, k;
ll ans = 0ll;

int main()
{
    cin>>n>>k;
    FOR(i,k,n+2) {
        ans += (n + 1 - i) * i + 1;
        ans %= MOD;
        //cout<<i<<": "<<(n + 1 - i) * i + 1<<endl;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
int main(){
	int n, ans=0;
	char a;
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%c", &a);
		if(a == 'Y') ans=1;
	}
	if(ans) printf("Four");
	else printf("Three");
}

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

int main(){
int N;  cin >> N;
vector<int> T(N);
int total_time = 0;
for (int i = 0; i < N; i++) {
    cin >> T[i];
    total_time += T[i];
}
int M; cin >> M;
vector<int> P(M), X(M);
for (int j = 0; j < M; j++) {
    cin >> P[j] >> X[j];    
}

for (int j = 0; j < M; j++) {
    cout << total_time - T[P[j] - 1] + X[j] << endl;
}

}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    pair<int, bool> card[3][3];
    int n;
    int a;
    int b;

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a;
            card[i][j] = make_pair(a, false);
        }
    }

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> b;
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (card[j][k].first == b) {
                    card[j][k].second = true;
                    break;
                }
            }
        }
    }

    if (card[0][0].second && card[1][1].second && card[2][2].second) {
        cout << "Yes" << endl;
        return 0;
    }

    if (card[0][2].second && card[1][1].second && card[2][0].second) {
        cout << "Yes" << endl;
        return 0;
    }

    for (int i = 0; i < 3; i++) {
        if (card[i][0].second && card[i][1].second && card[i][2].second) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    for (int i = 0; i < 3; i++) {
        if (card[0][i].second && card[1][i].second && card[2][i].second) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3648
/// In The Name Of God
/// I wish, that I could leave it all behind me / Go to my own world where no one can find me
#include<bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define pii pair <int , int>
#define ld long double
#define for2(a,b,c) for(int (a) = (b); (a) < (c); (a)++)
#define setp cout << fixed << setprecision(15)
#define endl "\n"
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define error(x) cerr << #x << " = " << (x) << endl;
#define all(x) (x).begin() , (x).end()


int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k; cin >> n >> k;
    int ans = 0;
    int cnt = 0;
    int l,r;
    for2(i,0,n){
        int x; cin >> x;
        if(x == 1){
            l = cnt;
            cnt = -1;

        }
        cnt++;
    }
    r = cnt;
    bool b = 0;
    for2(j,1,k){
        if(l%(k-1) != 0) l --,b=1;
        else if(r%(k-1) != 0) r--,b=1;
    }

    cout << (l+k-2)/(k-1) + (r+k-2)/(k-1) + b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define tt this->
#define ll long long
using namespace std;
int main ()
{
int x=0 , y;
cin>>x>>y;
if (x<10)x=100*(10-x);
else x=0;
cout<<x+y;

    return 0;
}

/*
▀█████████▄     ▄████████    ▄████████    ▄████████
  ███    ███   ███    ███   ███    ███   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
 ▄███▄▄▄██▀    ███    ███  ▄███▄▄▄▄██▀   ███    ███
▀▀███▀▀▀██▄  ▀███████████ ▀▀███▀▀▀▀▀   ▀███████████
  ███    ██▄   ███    ███ ▀███████████   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
▄█████████▀    ███    █▀    ███    ███   ███    █▀
                            ███    ███

*/


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K,Q;
    cin >> N >> K >> Q;
    ll A[100010];
    rep(i,0,Q) cin >> A[i];
    ll val[100010] = {};
    rep(i,0,Q){
        A[i]--;
        val[A[i]]++;
    }
    rep(i,0,N) val[i] += K-Q;
    rep(i,0,N){
        if(val[i] > 0){
            print("Yes");
        }else{
            print("No");
        }
    }

    
}


Measured memory_bytes: 2176
#include<iostream>
using namespace std;
long long n, k, now = 1, cnt, a[210000], pre[210000];

int main() {
	int i, j;
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (i = 1, j = 1; !pre[i] && k; i = a[i], j++, k--)
		pre[i] = j;
	k = k % (j - pre[i]);
	for (; k; i = a[i], k--);
	cout << i << endl;
	return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 100000
#define MAX_M 100000
typedef pair<i64, string> P;
i64 N, M;
P submission[MAX_M];
bool ac[MAX_N + 1];
i64 wa[MAX_N + 1];

void solve() {
  REPS(i, N) {
    ac[i] = false;
    wa[i] = 0;
  }
  i64 penalty = 0;

  i64 pi;
  string si;
  REP(i, M) {
    P p = submission[i];
    pi = p.F;
    si = p.S;
    if (ac[pi]) continue;

    if (si == "AC") {
      ac[pi] = true;
      penalty += wa[pi];
    } else if (si == "WA") {
      wa[pi]++;
    }
  }

  i64 cnt_ac = 0;
  REPS(i, N) {
    if (ac[i]) cnt_ac++;
  }
  cout << cnt_ac << " " << penalty << endl;
}

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

  i64 pi;
  string si;
  REP(i, M) {
    cin >> pi >> si;
    assert(si == "AC" || si == "WA");
    submission[i] = mp(pi, si);
  }

  solve();

  return 0;
}

Measured memory_bytes: 7424
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  cin >> n;
  while (n--) {
    string order, s;
    cin >> order >> s;
    reverse(all(order));
    for (auto &o : order) {
      if (o == 'J') s = string(1, s.back()) + s.substr(0, s.size() - 1);
      if (o == 'C') s = s.substr(1, s.size() - 1) + s.front();
      if (o == 'E') s = even(s.size()) ? s.substr(s.size() / 2, s.size() / 2) + s.substr(0, s.size() / 2) : s.substr(s.size() / 2 + 1, s.size() / 2) + string(1, s[s.size() / 2]) + s.substr(0, s.size() / 2);
      if (o == 'A') reverse(all(s));
      if (o == 'P') transform(all(s), s.begin(), [](char &c) {
        return isdigit(c) ? ((c - '0') + 9) % 10 + '0' : c;
      });
      if (o == 'M') transform(all(s), s.begin(), [](char &c) {
        return isdigit(c) ? ((c - '0') + 1) % 10 + '0' : c;
      });
    }
    cout << s << endl;
  }
}

Measured memory_bytes: 3196
N, K = map(int,input().split())
answer = 0
for i in range(N):
  dice = i + 1
  time = 0
  if dice >= K:
    answer += 1/N
    continue
  else:
    while (True):
      dice=dice*2
      time+= 1
      if dice >= K :
        answer += (1/N)*((1/2)**time)
        break
print(answer)

Measured memory_bytes: 3060
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

struct Run {
   char c;
   int start, end;
};

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   string S;
   cin >> S;

   int N = S.size();
   vector<Run> runs;

   char last = 0;
   for (int i = 0; i < N; ++i) {
      if (S[i] != last) {
         if (!runs.empty())
            runs.back().end = i-1;
         runs.push_back({S[i], i, i});
         last = S[i];
      }
   }
   runs.back().end = N-1;

// for (Run r : runs)
//    cerr << r.c << ' ' << r.start << ' ' << r.end << endl;
   
   VI A(N+1, 0);

   for (Run r : runs) {
      if (r.c == '>') {
         int len = r.end - r.start + 1;
         for (int i = r.start, v = len; i <= r.end+1; ++i) {
            A[i] = max(A[i], v--);
         }
      }
   }

   for (Run r : runs) {
      if (r.c == '<') {
         for (int i = r.start, v = 0; i <= r.end+1; ++i) {
            A[i] = max(A[i], v++);
         }
      }
   }

// for (int x : A)
//    cerr << x << ' ';
// cerr << endl;

   llong sum = 0;
   for (int x : A)
      sum += x;
   cout << sum << endl;

   return 0;
}


Measured memory_bytes: 5744
import sys
input = sys.stdin.readline

R, C, K = map(int, input().split())

items = [0] * R * C

for _ in range(K):
    r, c, v = map(int, input().split())
    items[C * (r-1) + c-1] = v

dp = [0] * 4 * R * C

dp[1] = items[0]

def ind(i,j,k):
    return 4 * C * i + 4 * j + k

for row in range(R):
    for col in range(C):
        for pick in range(4):
            curr = dp[ind(row,col,pick)]
            #Go Right
            if col + 1 < C:
                dp[ind(row,col+1,pick)] = max(curr, dp[ind(row,col+1,pick)])
                if pick < 3:
                    dp[ind(row,col+1,pick+1)] = max(curr + items[C * row + col+1], dp[ind(row,col+1,pick+1)])
            #Go Down
            if row + 1 < R:
                dp[ind(row+1,col,0)] = max(curr, dp[ind(row+1,col,0)])
                dp[ind(row+1,col,1)] = max(curr + items[C * (row+1) + col], dp[ind(row+1,col,1)])
                    

print(max(dp))
            


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	ll N=in<ll>();
	ll T=in<ll>(),A=in<ll>();
	vector<ll> H(N);
	REP(i,N){
		H[i]=abs((1000LL*T-6LL*in<ll>())-1000LL*A);
	}

	auto res = min_element(ALL(H));
	
	cout << distance(H.begin(),res)+1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n) - 1; i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

template<typename T>
inline void setmax(T& a, T b) {
    if (a < b) a = b;
}

template<typename T>
inline void setmin(T& a, T b) {
    if (a > b) a = b;
}

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 998244353;

inline void mod(ll& x) {
    if (x >= MOD) x -= MOD;
}

ll solve(string& s) {
    int n = s.length();
    if (n == 1) return s[0] - '0' + 1;
    if (n == 2) {
        if (s[0] == '0') return s[1] - '0' + 2;
        else return 3 * (s[1] - '0' + 1);
    }
    vector<ll> dp(n + 1);
    dp.back() = 1;
    for (int i = n - 1; i >= 0; --i) {
        dp[i] = dp[i + 1];
        if (s[i] == '1') {
            dp[i] += dp[i + 1];
            mod(dp[i]);
        }
        for (int len = 1; len <= n - i; ++len)
            for (int cnt = 2; cnt * len <= n - i; ++cnt) {
                string t(len, '1');
                for (int j = 0; j < len * cnt; ++j)
                    if (s[j + i] == '0')
                        t[j % len] = '0';
                dp[i] += solve(t) * dp[i + len * cnt];
                dp[i] %= MOD;
            }
    }
    //cerr << s << '\n';
    //trace(dp);
    return dp[0];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); 
    srand((unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
    /* 
    int n;
    cin >> n;
    vector<ll> dp(n);
    dp[0] = 1;
    forn(i, 1, n) {
        dp[i] = 1;
        //forn(j, 0, i) dp[i] += dp[j];
        for (int j = 0; j <= i; ++j)
            forn(len, 1, j)
                for (int cnt = 2; len * cnt <= j; ++cnt)
                    dp[i] += dp[len];
    }
    trace(dp);
    return 0;
    */
    string s;
    cin >> s;
    //s = string(100, '1');
    cout << solve(s) << '\n';
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    a,b,c=MI()
    L=[a,b,c]
    L.sort()
    if L==[5,5,7]:
        print("YES")
    else:
        print("NO")
    

main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int INF = 1<<30;
const ll LINF = 1LL<<61;

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

Measured memory_bytes: 3988
main :: IO ()
main = do
    [n,a,b,c,d] <- getInts
    putStrLn $ if solve n a b c d then "YES" else "NO"

getInts :: IO [Int]
getInts = map read . words <$> getLine

solve :: Int -> Int -> Int -> Int -> Int -> Bool
solve n a b c d
    | abs b > a + d*(n-1) = False
    | otherwise = or $ map (\i -> a+i*c+(i-n+1)*d <= b && b <= a+(i-n+1)*c+i*d) [0..n-1]


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

using namespace std;
#define ull unsigned long long
#define ll long long
const double inf = 2e9;
const int MAXN = 2e5 + 10;
ll mod = 998244353;

void solve () {
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22) cout<<"bust";
    else cout<<"win";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n=1;
    for(int i=0;i<n;i++) solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<P> xy[n];

    rep(i, n){
        cin >> a[i];
        rep(j, a[i]){
            int x, y;
            cin >> x >> y;
            x--;
            xy[i].push_back(make_pair(x, y));
        }
    }
    int ans = 0;
    bool flag = true;
    for(int bit=0; bit<(1<<n); bit++){
        int tmp = 0;
        flag = true;
        rep(i, n){
            if(!flag) break;
            if(bit & (1<<i)){
                tmp++;
                rep(j, a[i]){
                    if(!flag) break;
                    int tmp_x, tmp_y;
                    tmp_x = xy[i][j].first;
                    tmp_y = xy[i][j].second;
                    if(((bit & (1<<tmp_x)) and tmp_y==1) or (!(bit & (1<<tmp_x)) and tmp_y==0)){
                        continue;
                    }else{
                        flag = false;
                        break;
                    }
                }
            }
        }
        if(flag){
            chmax(ans, tmp);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    string s,t;
    cin >> s >> t;
    int size = s.size();
    vector<int> cacheS(26),cacheT(26);
    bool pattern_match = true;
    for(int i = 0; i < size; i++)
    {
        if (cacheS.at(s.at(i) - 'a') != cacheT.at(t.at(i) - 'a')) {
            pattern_match = false;
            break;
        }
        cacheS.at(s.at(i) - 'a') = i;
        cacheT.at(t.at(i) - 'a') = i;
    }

    string ans;
    if(pattern_match) ans = "Yes";
    else ans = "No";

    cout << ans << endl;
}

Measured memory_bytes: 776
sx, sy, tx, ty = map(int, input().split())
x = tx - sx
y = ty - sy
s = ''
s += 'U' * y + 'R' * x
s += 'D' * y + 'L' * x
s += 'L' + 'U' * (y+1) + 'R' * (x+1) + 'D'
s += 'R' + 'D' * (y+1) + 'L' * (x+1) + 'U'
print(s)

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <algorithm>
#include <string.h>
#include <memory.h>

using namespace std;

typedef long long ll;
int const N = 1e2 + 1, oo = 2e9 + 1;
int n, m, q, k, a[N];
vector<vector<int> > g;

int main() {
	int x, t;
	scanf("%d %d", &x, &t);

	if(t <= x)
		printf("%d\n", x - t);
	else
		puts("0");

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  long S, h, m, s;
  scanf("%ld",&S);
  h = S / 3600;
  m = (S - h*3600) / 60;
  s = S - h*3600 - m*60;
  printf("%ld:%ld:%ld\n",h ,m ,s);
  return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define crap ios_base::sync_with_stdio(0);cin.tie(0)
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define int ll

using namespace std;

const int N = 3005;
int A[N];
int dp[N][N][2];
int n;


int solve(int start,int end,int turn){
	if(start==end) return A[start];
	if(start>end) return 0;

   if(dp[start][end][turn]!=-1) return dp[start][end][turn];

   return dp[start][end][turn] = max(A[start] - solve(start+1,end,1^turn), A[end] - solve(start,end-1,1^turn));


}

int32_t main()
{
   
    crap;
    memset(dp,-1,sizeof(dp));
    cin>>n;
    for(int i=0;i<n;i++) cin>>A[i];

    int ans = solve(0,n-1,0);
	cout<<ans<<endl;

}

Measured memory_bytes: 141568
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long int L, R; cin >> L >> R; 
	if(R - L >= 2019) cout << 0 << endl; 
	else{
		long long int ans = 114514; 
		for(long long int i = L; i < R; i++){
			for(long long int j = i+1; j <= R; j++){
				long long int tmp; 
				tmp = (i * j) % 2019; 
				ans = min(tmp, ans); 
			}
		}
		cout << ans << endl; 
	}	
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector< vector<int> > x(n), y(n);
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        x[i].resize(a);
        y[i].resize(a);
        for (int j = 0; j < a; ++j) {
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }

    int ans = 0;
    for (int i = 0; i < (1 << n); ++i) {
        bool ok = true;
        for (int j = 0; j < n; ++j) {
            if (!(i & (1 << j))) continue;
            for (int k = 0; k < x[j].size(); ++k) {
                bool f = (i & (1 << x[j][k])) > 0;
                if (f != y[j][k]) {
                    ok = false;
                    break;
                }
            }
            if (!ok) break;
        }
        if (ok) ans = max(ans, __builtin_popcount(i));
    }
    cout << ans << endl;
    return 0;
}

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

void scoring()
{
	int D;
	vector<int> cs(26);
	cin >> D;
	for (auto &&c : cs)
	{
		cin >> c;
	}
	vector<vector<int>> sss(D, vector<int>(26));
	vector<int> ts(D);
	for (auto &&ss : sss)
	{
		for (auto &&s : ss)
		{
			cin >> s;
		}
	}
	for (auto &&t : ts)
	{
		cin >> t;
		t--;
	}

	vector<int> last(26, -1);

	int score = 0;

	for (int d = 0; d < D; d++)
	{
		score += sss[d][ts[d]];

		last[ts[d]] = d;

		for (int i = 0; i < 26; i++)
		{
			score -= cs[i] * (d - last[i]);
		}

		cout << score << endl;
	}
}

int main()
{
	scoring();

	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 1e9 + 7, mxn = 1e5 + 1;

int solve(){
    long double d, t, s, time;
    cin>> d>> t>> s;
    time = d/s;
    if(time <= t)
        cout<< "Yes\n";
    else
        cout<< "No\n";
    return 0;
}
//Counting problems: Sometimes easier to find complement of the answer
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


Measured memory_bytes: 3748