akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>  // sort, 二分探索, etc
#include <iomanip>  // setprecision (浮動小数点の出力の誤差)
#include <map>
#include <queue>
#include <set>
#include <stack>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=a,i##_len=(b);i<i##_len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define cauto const auto&
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SIZE(x) ((ll)(x).size()) // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

using namespace std;
using ll = long long;
using ull = unsigned long long;

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

const char newl = '\n';

ll qp(ll a,ull b){ll ans=1;do{if(b&1u)ans*=a;a*=a;}while(b>>=1u);return ans;}
ll qp(ll a,ull b,ll mod){ll ans=1;do{if(b&1u)ans=ans*a%mod;a=a*a%mod;}while(b>>=1u);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll comb(int n, int r) {
    vector<vector<ll> > v(n+1, vector<ll>(r+1, 0));
    for(int i=0;i<n+1;i++) {v[i][0]=1; if(i < r+1)v[i][i]=1; }
    for(int i=1;i<n+1;i++) {for(int j=1;j<min(i,r+1);j++) {v[i][j]=v[i-1][j-1]+v[i-1][j];}}
    return v[n][r];
}

// INT_MAX   = 2.1e+09 (2147483647)
// LONG_MAX  = 9.2e+18 (9223372036854775807)
// LLONG_MAX = 9.2e+18 (9223372036854775807)


int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> A;
    rep(i, n) {
        ll x;
        cin >> x;
        A.push_back(x);
    }

    ll period;
    map<ll, ll> mp;
    ll town = 0;
    vector<ll> towns;
    towns.push_back(0);
    mp[0] = 1;
    while(1) {
        town = A[town] - 1;
        ll idx = mp[town] - 1;
        if (idx != -1) {
            period = towns.size() - idx;
            break;
        }
        towns.push_back(town);
        mp[town] = towns.size();
    }

    if (k < towns.size()) {
        cout << towns[k] + 1 << newl;
    } else {
        ll offset = (k - towns.size()) % period;
        cout << towns[towns.size() - period + offset] + 1 << newl;
    }
    return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int solve(int x, const vector<int>& a) {
  int N = a.size();
  int ret = 0;
  ll cum = 0;
  REP(i,N) {
    cum += a[i];
    if(x < cum) return ret;
    ++ret;
  }
  if(cum != x) --ret;
  return ret;
}

int main(){
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  REP(i,N) cin >> a[i];
  sort(ALL(a));

  cout << solve(x, a) << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n, x, t;
    cin >> n >> x >> t;
    int ans;
    if (n % x == 0)
    {
        ans = n/x * t;
    }
    else{
        ans = (n/x + 1) * t;
    }
    cout << ans << endl;
}

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

using namespace std;
int main()
{
    long long r,d,x[20];
    cin>>r>>d>>x[0];
    for(int i=1;i<11;i++)
    {
        x[i] = r*x[i-1]-d;
        cout<<x[i]<<endl;
    }
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define sci1(a) scanf("%d",&a)
#define sci2(a,b) scanf("%d %d",&a,&b)
#define sci3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define scs(s) scanf("%s",s)
#ifndef GET_MACRO

#define GET_MACRO(__1,__2,__3,NAME,...) NAME

#endif // GET_MACRO

#define sci(...) GET_MACRO(__VA_ARGS__,sci3,sci2,sci1)(__VA_ARGS__)
#define ll long long
#define pii pair<int,int>
#define mp(a,b) make_pair(a,b)
#define LSB(i) ((i)&(-i))
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
#define infl 0x7ffffffffffffff
#define infi  0x7fffffff
#define fill_(a,b) fill(a.begin(),a.end(),b)
#define pb push_back
#define xx first
#define yy second
int main(){
    int n,i;
    sci(n);
    vector<int> data(n);
    vector<int> sdata(n);
    for(i=0;i<n;i++){
        sci(data[i]);
        sdata[i]=data[i];
    }
    sort(sdata.begin(),sdata.end());
    map<int,int> map_;
    for(i=0;i<n;i++){
        map_[sdata[i]]=i+1;
    }
    int cnt=0;
    for(i=0;i<n;i++){
        data[i]=map_[data[i]];
        if((data[i]%2)!=(i+1)%2)cnt++;
    }
    cout<<cnt/2<<endl;
}


Measured memory_bytes: 5760
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <deque>
using namespace std;

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


int main() {
	int n;
	cin >> n;
	deque<int> dq;
	rep(i, n) {
		int a;
		cin >> a;
		if (i==0) dq.push_back(a);
		else if (n%2==0) {
			if (i%2==1) dq.push_front(a);
			else dq.push_back(a);
		}
		else if (n%2==1) {
			if (i%2==1) dq.push_back(a);
			else dq.push_front(a);
		}
	}
	rep(i, n) cout << dq.at(i) << " ";
}

Measured memory_bytes: 3072
from collections import deque
n,k = map(int,input().split())
vertices = [[] for _ in range(n+1)]
visite = [[] for _ in range(n+1)]
value = [0 for _ in range(n+1) ]
c = 0
done = set()
queue = deque()
queue.append(1)
mod = 1000000007
for i in range(n-1):
    a,b = map(int,input().split())
    vertices[a].append(b)
    vertices[b].append(a)
value[1]= k
done.add(1)
while(len(queue)>0):
    next = queue.popleft()
    done.add(next)
    for v in vertices[next]:
        if v not in done:
            visite[next].append(v)
            value[v] = k - len(visite[next])
            visite[v].append(next)
            queue.append(v)
ans=1
for i in range(1,n+1):
    ans*=value[i]
    ans%=mod
print(ans)


Measured memory_bytes: 45840
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
	int a,b,c[199],sum,digit,set,i=0;	
	while(scanf("%d ", &a)!=EOF){
		scanf("%d",&b );
	    sum = a + b;
	    if(sum/10<1){
	    	digit=1;
		}
		if(1<=(sum/10) && (sum/10)<10){
	    	digit=2;
		}
		if(10<=(sum/10) && (sum/10)<100){
	    	digit=3;
		}
		if(100<=(sum/10) && (sum/10)<1000){
	    	digit=4;
		}
		if(1000<=(sum/10) && (sum/10)<10000){
	    	digit=5;
		}
		if(10000<=(sum/10) && (sum/10)<100000){
	    	digit=6;
		}
		if(100000<=(sum/10) && (sum/10)<1000000){
	    	digit=7;
		}
		c[i]=digit;
	    i++;
	    set = i;
	}
	for(i=0;i<set;i++){
		printf("%d\n",c[i]);
	}
	return 0;
}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll q,h,s,d;
  cin >> q >> h >> s >> d;
  ll n;
  cin >> n;
  q*=4;
  h*=2;
  s=min({q,h,s});
  d=min(d,s*2);
  ll ans=n/2*d+n%2*s;
  cout << ans << endl;
}

Measured memory_bytes: 256
def gcd(n,m):#n,mは正の整数、最大公約数　許容は？
    if n==0:
        return m
    elif m==0:
        return n
    elif n>m:
        n=n%m
        return gcd(n,m)
    else:
        m=m%n
        return gcd(n,m)


def partions(M):#Mの約数列 O(n^(0.5+e))
    import math
    d=[]
    i=1
    while math.sqrt(M)>=i:
        if M%i==0:
            d.append(i)
            if i**2!=M:
                d.append(M//i)
        i=i+1
    d.sort()
    return d

def main():
    A,B,K=map(int,input().split())
    c=gcd(A,B)
    C=partions(c)
    print(C[len(C)-K])

if __name__ == '__main__':
    main()

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

int main(){
  int t;
  int weight[10];
  int point[4][13];
  int s[5],n[5];
  int kind[4][13];
  string card;
  bool flag;
  bool f = false;

  while(cin >> t){
    if(f)cout << endl;
    f = true;

    for(int i=0;i<4;i++){
      for(int j=0;j<13;j++)cin >> point[i][j];
    }
    weight[0] = 0;
    for(int i=1;i<10;i++)cin >> weight[i];
    
    while(t--){
      for(int i=0;i<4;i++){
	for(int j=0;j<13;j++)kind[i][j] = false;
      }
      int ans = 0;
      for(int i=0;i<5;i++){
	cin >> card;
	if(card[0] == 'A')n[i] = 1;
	else if(card[0] == 'T')n[i] = 10;
	else if(card[0] == 'J')n[i] = 11;
	else if(card[0] == 'Q')n[i] = 12;
	else if(card[0] == 'K')n[i] = 13;
	else n[i] = card[0] - '0';

	if(card[1] == 'S')s[i] = 0;
	else if(card[1] == 'C')s[i] = 1;
	else if(card[1] == 'H')s[i] = 2;
	else if(card[1] == 'D')s[i] = 3;

	kind[s[i]][n[i]-1] = true;
	ans += point[s[i]][n[i]-1];
      }

      flag = false;
      int c = 9;
      //loyal straight flash
      for(int i=0;i<4;i++){
	if(kind[i][0] && kind[i][9] && kind[i][10] && kind[i][11] && kind[i][12]){
	  flag = true;
	}
      }
      if(!flag){
	c--;
	//straight flash
	for(int i=0;i<4;i++){
	  for(int j=0;j<9;j++){
	    if(kind[i][j] && kind[i][j+1] && kind[i][j+2] && kind[i][j+3] && kind[i][j+4])flag = true;
	  }
	}
	if(!flag){
	  c--;
	  //four card
	  sort(n,n+5);
	  if(n[0] == n[1] && n[1] == n[2] && n[2] == n[3])flag = true;
	  if(n[1] == n[2] && n[2] == n[3] && n[3] == n[4])flag = true;
	  if(!flag){
	    c--;
	    //full house
	    if(n[0] == n[1] && n[1] == n[2] && n[3] == n[4])flag = true;
	    if(n[0] == n[1] && n[2] == n[3] && n[3] == n[4])flag = true;
	    if(!flag){
	      c--;
	      //flash
	      if(s[0] == s[1] && s[1] == s[2] && s[2] == s[3] && s[3] == s[4])flag = true;
	      if(!flag){
		c--;
		//straight
		if(n[0] == n[1]-1 && n[1] == n[2]-1 && n[2] == n[3]-1 && n[3] == n[4]-1)flag = true;
		if(n[0] == 1 && n[1] == 10 && n[2] == 11 && n[3] == 12 && n[4] == 13)flag = true;
		if(!flag){
		  c--;
		  //three card
		  if(n[0] == n[1] && n[1] == n[2])flag = true;
		  if(n[1] == n[2] && n[2] == n[3])flag = true;
		  if(n[2] == n[3] && n[3] == n[4])flag = true;
		  if(!flag){
		    c--;
		    //two pair
		    if(n[0] == n[1] && n[2] == n[3])flag = true;
		    if(n[0] == n[1] && n[3] == n[4])flag = true;
		    if(n[1] == n[2] && n[3] == n[4])flag = true;
		    if(!flag){
		      c--;
		      if(n[0] == n[1])flag = true;
		      if(n[1] == n[2])flag = true;
		      if(n[2] == n[3])flag = true;
		      if(n[3] == n[4])flag = true;
		      if(!flag)c--;
		    }
		  }
		}
	      }
	    }
	  }
	}
      }
      cout << ans * weight[c] << endl;
    }

  }
}

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

//const int MAX_LEN = 200002;

int main()
{
int n;
cin >> n;
vector<int> a(n, 0);
rep(i, n) cin >> a[i];
sort(a.begin(), a.end());
vector<int> cnt(a.at(a.size()-1)+1, 0);

for (int x : a)
{ //範囲ベースforループ
  if (cnt[x] != 0){
    cnt[x] = 2;
    continue;
  }
  for (int i = x; i <= cnt.size() - 1; i += x)
    cnt[i]++;
}
//Debug cout << cnt
//rep(i, cnt.size()) cout << cnt[i];
//cout << endl;
//cout << "01234567890123456789012345" << endl;

int ans = 0;
for (int x : a){
  if (cnt[x] <= 1)
    ans++;
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 7992
# -*- coding: utf-8 -*-
"""
https://abc060.contest.atcoder.jp/tasks/arc073_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(data, T):
    ans = 0
    prev_d = data[0]
    for d in data[1:]:
        diff = d - prev_d
        ans += min(T, diff)
        prev_d = d
    ans += T
    return ans


def main(args):
    N, T = map(int, input().split())
    data = [int(x) for x in input().split()]
    ans = solve(data, T)
    print(ans)

if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 25744
N, M, x, y = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))

# print('max(X), min(Y)', max(X), min(Y))
for z in range(x + 1, y - 1):
    # print('z', z)
    if max(X) < z <= min(Y):
        print('No War')
        exit()
print('War')


Measured memory_bytes: 2940
import math

n=int(input())
A=[0 for i in range(n)]
cnt=0
for i in range(n):
    A[i]=int(input())
for i in range(n):
    a=int(math.sqrt(A[i])+1)
    if A[i]<2: pass
    elif A[i]==2 or A[i]==3 or A[i]==5 or A[i]==7:
        cnt+=1
    else:
        for j in range(2,a):
            if A[i]%j==0:
                break
            if j==a-1:
                cnt+=1
print(cnt)


Measured memory_bytes: 5996
N,D = map(int,input().split())
X = []
Y = []
for i in range(N):
    x,y = map(int,input().split())
    X.append(x)
    Y.append(y)
    
ans = 0
for i in range(N):
    if X[i]**2 + Y[i]**2 <= D**2:
        ans += 1

print(ans)

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

ll ans = 0,ci=-1;
string s, t;
vector<int> lst[26];
int main() {
	cin >> s >> t;
	for (int i = 0; i < s.size(); i++)lst[s[i] - 'a'].push_back(i);
	for (int i = 0; i < t.size(); i++) {
		if (lst[t[i] - 'a'].size() == 0) { cout << -1 << endl; return 0; }
		int ni = lower_bound(lst[t[i] - 'a'].begin(), lst[t[i] - 'a'].end(), ci + 1) - lst[t[i] - 'a'].begin();
		if (lst[t[i] - 'a'].size() != ni) {
			ans += lst[t[i] - 'a'][ni] - ci;
			ci = lst[t[i] - 'a'][ni];
		}
		else {
			ans += (ll)lst[t[i] - 'a'][0] + s.size() - ci;
			ci = lst[t[i] - 'a'][0];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1216
# coding:utf-8

import math

def main():
    n = list(raw_input())
    cnt = 0
    total = 0
    for i in n:
        if i == 'x':
            total += 1
    if total >= 8:
        print "NO"
    else:
        print "YES"

if __name__ == "__main__":
    main()



Measured memory_bytes: 2568
#include<stdio.h>
#include<stdlib.h>

int main(){
  int i;
  int j;
  int change = 0;
  int num = 0;
  int count = 0;
  int min = 0;
  int *data;

scanf("%d",&num);
data = (int *)malloc(sizeof(int)*num);

for(j = 0;j < num;j++){
  scanf("%d",&data[j]);
}

for(i = 0;i < num - 1;i++){
  min = i;
  for(j = i;j < num;j++){
    if(data[j] < data[min]){
      min = j;
    }

  }
  if(i != min){
    change = data[i];
    data[i] = data[min];
    data[min] = change;
    count++;
  }
}

for(i = 0;i < num-1;i++){
  printf("%d ",data[i]);
}
printf("%d",data[num - 1]);
printf("\n");
printf("%d",count);
printf("\n");
return 0;
}



Measured memory_bytes: 2124
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

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

  if(S[0]=='A' && S[1]=='A' && S[2]=='A'){
   cout << "No" << endl;
   return 0;
  }
  if(S[0]=='B' && S[1]=='B' && S[2]=='B'){
   cout << "No" << endl;
   return 0;
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

typedef long long ll;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    string n;
    cin >> n;

    if(n[0] == n[1] && n[1] == n[2]) p("Yes")
    else if(n[1] == n[2] && n[2] == n[3]) p("Yes")
    else p("No");
}

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

using namespace std;

int main(int argc, char **argv)
{
	int *array, n, m, tmp, c;
	
	while(1){
		cin >> n >> m;
		if(n == 0 || m == 0){
			break;
		}
		c = 1;
		array = (int *)calloc(n+1, sizeof(int));
		for(int i = 1; i <= n; i++){
			cin >> array[i];
		}

		for(int i = 1, p = 1; i <= m; i++, c++){
			cin >> tmp;
			p += tmp;
			p += array[p];
			if(p < 1){
				p = 1;
			} else if(p >= n){
				break;
			}
		}
		for(int i = c; i < m; i++){
			cin >> tmp;
		}
		
		cout << c << endl;
		
		free(array);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template <typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
    for(auto &e:t) fill_v(e,v);
}
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 (a > b) { a = b; return 1;}
    return 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    FOR(i,1,10){
        FOR(j,1,10){
            if(i * j == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3644
import math
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)

    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(math.floor(a / b))
    elif op == "?":
        break



Measured memory_bytes: 5664
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n, q, k;
ll dist[100001];
bool visited[100001];
vector<pair<ll, ll>> vp[100001]; // edge, cost
int main() {
    cin>>n;

    REP(i, 0, n-1){
        ll a, b, c;
        cin>>a>>b>>c;
        a--; b--;
        vp[a].emplace_back(make_pair(b, c));
        vp[b].emplace_back(make_pair(a, c));
    }
    cin>>q>>k;
    k--;

    queue<ll> que;
    que.push(k);
    while(!que.empty()){
        ll cur=que.front();
        que.pop();

        if(visited[cur]) continue;

        visited[cur]=true;
        for(auto itr:vp[cur]){
            if(visited[itr.first]) continue;

            dist[itr.first]=dist[cur]+itr.second;
            que.push(itr.first);
        }
    }

    REP(i, 0, q){
        ll x, y;
        cin>>x>>y;
        x--;
        y--;
        cout<<dist[x]+dist[y]<<endl;
    }

    return 0;
}

Measured memory_bytes: 10112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0, i_l = (int)n; i < i_l; i++)
#define loop(i, a, b) for (int i = a; i < (int)(b); i++)


int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx;
    int dy = ty - sy;

    string s = "";
    //行き
    rep(i, dx) s += "R";
    rep(i, dy) s += "U";
    //帰り
    rep(i, dx) s += "L";
    rep(i, dy) s += "D";
    //行き
    s += "L";
    rep(i, dy + 1) s += "U";
    rep(i, dx + 1) s += "R";
    s += "D";
    //帰り
    s += "R";
    rep(i, dy + 1) s += "D";
    rep(i, dx + 1) s += "L";
    s += "U";

    cout << s << endl;
    return 0;
}



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

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

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


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
	FastScanner in;
	PrintWriter out;

	void solve() {
		final int mod = (int) 1e9 + 7;
		int n = in.nextInt();
		int m = in.nextInt();
		// num different, can go to 1
		int[][] dp = new int[n + 1][n + 1];
		dp[1][1] = 1;
		int[][] dp2 = new int[n + 1][n + 1];
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < dp2.length; j++) {
				Arrays.fill(dp2[j], 0);
			}
			for (int curDiff = 0; curDiff <= n; curDiff++) {
				for (int canGo = 0; canGo <= curDiff; canGo++) {
					long res = dp[curDiff][canGo];
					if (res == 0) {
						continue;
					}
					if (curDiff < n) {
						// new city
						dp2[curDiff + 1][canGo] = (int) ((dp2[curDiff + 1][canGo] + res
								* (n - curDiff)) % mod);
					}
					{
						dp2[curDiff][curDiff] = (int) ((dp2[curDiff][curDiff] + res
								* (canGo)) % mod);
					}
					{
						dp2[curDiff][canGo] = (int) ((dp2[curDiff][canGo] + res
								* (curDiff - canGo)) % mod);
					}
				}
			}
			int[][] tmp = dp;
			dp = dp2;
			dp2 = tmp;
		}
		out.println(dp[n][n]);
	}

	void run() {
		try {
			in = new FastScanner(new File("object.in"));
			out = new PrintWriter(new File("object.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
				new Main().runIO();
			}
		}, "1", 1 << 26).start();
	}
}

Measured memory_bytes: 10064
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int MAX_N = 1e5;
const int SQRT_N = 317;
int dat[MAX_N] = {};
int bucket_add[SQRT_N] = {};
int bucket_sum[SQRT_N] = {};

void add(int l, int r, int val) {
	for (int k = 0; k < SQRT_N; k++) {
		int bl = k * SQRT_N, br = (k + 1) * SQRT_N;
		if (r <= bl || br <= l)
			continue;
		if (l <= bl && br <= r) {
			bucket_add[k] += val;
			bucket_sum[k] += val*SQRT_N;
		}
		else {
			for (int i = max(l, bl); i < min(r, br); i++) {
				dat[i] += val;
				bucket_sum[k] += val;
			}
		}
	}
}

int get_sum(int l, int r) {
	int ret = 0;
	for (int k = 0; k < SQRT_N; k++) {
		int bl = k * SQRT_N, br = (k + 1) * SQRT_N;
		if (r <= bl || br <= l)
			continue;
		if (l <= bl && br <= r) {
			ret += bucket_sum[k];
		}
		else {
			for (int i = max(l, bl); i < min(r, br); i++) {
				ret += dat[i] + bucket_add[k];
			}
		}
	}
	return ret;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	rep(i, 0, q) {
		int c; cin >> c;
		if (c == 0) {
			int s, t, x; cin >> s >> t >> x;
			add(s - 1, t, x);
		}
		else {
			int s, t; cin >> s >> t;
			cout << get_sum(s - 1, t) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3932
import re
N, Q = map(int, input().split())
S=input()
lr=[]
for _ in range(Q):
    lr.append(tuple(map(int, input().split())))
#print(N, Q, S, lr)



accum=[0]*(N+1)
should_plus=0
for i in range(2, N+1):
    if S[i-2]=='A' and S[i-1]=='C':
        should_plus+=1
    accum[i]=should_plus
#print(accum)

for val in lr:
    OK=accum[val[1]]-accum[val[0]-1]
    if S[(val[0]-2):val[0]]=='AC':
        OK-=1
    print(OK)



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

int main() {
    int X; // 数字
    int Xsub;
    int Xsum = 0;
    int Harshad = 0;
    cin >> X;

    Xsub = X;
    
    while (Xsub > 0) {
        Xsum += Xsub % 10;
        Xsub /= 10;
    }

    Harshad = X % Xsum;
    if (Harshad == 0) {
        cout << "Yes" << endl;
    }
    else {
    cout << "No" << endl;
    }
    
}

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

const int MAX = 1000005;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    COMinit();

    int xx, yy;
    cin >> xx >> yy;
    int x = max(xx, yy);
    int y = min(xx, yy);

    if ((x * 2 < y) || ((x+y) % 3 != 0)) {
        cout << "0" << endl;
        return 0;
    }
    int h = (x+y) / 3;
    cout << COM(h, x-h) << endl;
}


Measured memory_bytes: 23680
# bitDP(集合を数に変換して状態(=添字)として持つようなDPのこと)
# dp[i][S]=(男性はi人目までで、既にペアになった女性の集合がSであるような場合の数)
# 「既にペアになった女性の集合がS」なら「bitpopcount(S)人目までをチェックした」ってことになるから、iを状態として持つ必要は無いことがわかる
import sys
input = sys.stdin.readline
mod=10**9+7
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
dp=[0]*(1<<n)
dp[0]=1
for i in range(1,1<<n):
    k=bin(i).count("1")
    for j in range(n):
        if i>>j&1 and a[k-1][j]:
            dp[i]+=dp[i^(1<<j)]
    dp[i]%=mod
print(dp[(1<<n)-1])

Measured memory_bytes: 57452
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>


using namespace std;

typedef long long ll;

const ll INF = 1ll << 60;

int main(void){
	int n;
	cin >> n;
	vector<int> w(n);

	for (int i = 0; i < n; i++){
		cin >> w[i];
	}

	vector<int> s1;
	vector<int> s2;

	for (int t = 0; t < n; t++){
		int total1 = 0;
		int total2 = 0;
		for (int i = 0; i < n; i++){
			if (i <= t){
				total1 += w[i];
			} else {
				total2 += w[i];
			}
		}

		s1.push_back(total1);
		s2.push_back(total2);
	}

	int ans = 1e9;

	for (int i = 0; i < s1.size(); i++){
		int tmp = abs(s1[i] - s2[i]);
		ans = min(ans, tmp);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    
    vector<vector<int>> ans(h, vector<int>(w));
    for(int i = 0; i < b; i++){
        for(int j = 0; j < a; j++){
            ans[i][j] = 1;
        }
    }
    for(int i = b; i < h; i++){
        for(int j = a; j < w; j++){
            ans[i][j] = 1;
        }
    }
    for(int i = 0; i < h; i++){
        int cnt[2] = {};
        for(int j = 0; j < w; j++){
            cnt[ans[i][j] == 1]++;
        }
        if(cnt[0] != a && cnt[1] != a){
            cout << "No" << endl;
            return 0;
        }
    }
    for(int j = 0; j < w; j++){
        int cnt[2] = {};
        for(int i = 0; i < h; i++){
            cnt[ans[i][j] == 1]++;
        }
        if(cnt[0] != b && cnt[1] != b){
            cout << "No" << endl;
            return 0;
        }
    }
    for(auto &i : ans){
        for(auto &j : i){
            cout << j;
        }
        cout << endl;
    }
}


Measured memory_bytes: 5120
s = input()
s_origin = s
t = ""
word_list = ["dream", "dreamer", "erase", "eraser"]
while True:
    flag = True
    if len(s) <= 4:
        break

    if len(s) == 5:
        s_child_1 = s[-5:]
        if s_child_1 in word_list:
            t = s[-5:] + t
            s = s[:-5]
        break
    
    if len(s) == 6:
        s_child_1 = s[-6:]
        if s_child_1 in word_list:
            t = s[-6:] + t
            s = s[:-6]
        break

    s_child_2 = s[-7:]
    if s_child_2 in word_list:
        t = s[-7:] + t
        s = s[:-7]
        flag = False

    s_child_1 = s[-6:]
    if s_child_1 in word_list:
        t = s[-6:] + t
        s = s[:-6]
        flag = False

    s_child_1 = s[-5:]
    if s_child_1 in word_list:
        t = s[-5:] + t
        s = s[:-5]
        flag = False
    
    if flag:
        break

if s_origin == t:
    print("YES")
else:
    print("NO")
    

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

int main() {

	int length;
	cin >> length;
	int *a = new int[length];
	int *b = new int[length];
	for (int i = 0; i < length; i++) {
		cin >> a[i];
	}

	int left = 0, right = length - 1;
	if (length % 2 == 0) {
		for (int i = length - 1; i > 0; i -= 2) {
			b[left++] = a[i];
			b[right--] = a[i - 1];
		}
	}
	else {
		for (int i = length - 1; i > 0; i -= 2) {
			b[left++] = a[i];
			b[right--] = a[i - 1];
		}
		b[length / 2] = a[0];
	}


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




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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

ll N, X;
ll b[200000];
ll l[200000];
ll u[200000];

// i番目のテストでx点を取った時の青木くんとの得点差
ll diff(int i, ll x) {
  if (x >= b[i]) {
    return (x-b[i])*u[i];
  } else {
    return (x-b[i])*l[i];
  }
}

bool check(ll sumX) {
  ll p = sumX/X; // X点を取るテストの数
  ll r = N-p-1;  // 0点を取るテストの数
  ll q = sumX%X; // 1個のテストは、q点を取る

  vector<PLL> v(N); // {0点とX点での得点差、ID}
  for (int i=0; i<N; i++) {
    v[i] = make_pair(diff(i,X) - diff(i,0), i);
  }
  sort(begin(v),end(v));

  set<ll> smallIDs, largeIDs;

  // 0点をr個取る
  for (int i=0; i<r; i++) {
    smallIDs.insert(v[i].second);
  }

  // X点をp個取る
  for (int i=N-p; i<N; i++) {
    largeIDs.insert(v[i].second);
  }

  ll sumDiff = 0;
  for (auto id : largeIDs) {
    sumDiff += diff(id, X);
  }
  for (auto id : smallIDs) {
    sumDiff += diff(id, 0);
  }

  // p点を1回とる
  sumDiff += diff(v[r].second, q);

  for (int i=0; i<N; i++) {
    // i番目のテストでq点を取る。 v[r].second目と入れ替え
    ll ss = sumDiff;
    if (smallIDs.find(i) != smallIDs.end()) {
      ss += diff(i, q)           - diff(i, 0);
      ss += diff(v[r].second, 0) - diff(v[r].second, q);
    } else if (largeIDs.find(i) != largeIDs.end()) {
      ss += diff(i, q)           - diff(i, X);
      ss += diff(v[r].second, X) - diff(v[r].second, q);
    }
    // printf("sumX=%d i=%d sumDiff=%d ss=%d q=%d\n",sumX, i,sumDiff,ss,q);
    // printf("smallIDs="); for (auto id: smallIDs) { printf("%d ", id); } printf("\n");
    // printf("largeIDs="); for (auto id: largeIDs) { printf("%d ", id); } printf("\n");
    if (ss >= 0)
      return true;
  }

  return false;
}

signed main() {
  cin>>N>>X;
  rep(i,0,N){
    cin>>b[i]>>l[i]>>u[i];
  }
  ll ng = -1, ok = X * N;
  while (ng+1 < ok) {
    ll m = (ok+ng)/2;
    if (check(m)) {
      ok = m;
    } else {
      ng = m;
    }
  }
  cout<<ok<<endl;
  return 0;
}


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

int main() {
  int N, A, B, plan1, plan2;
  cin >> N >> A >> B;
  plan1 = A * N;
  plan2 = B;
  if(plan1 <= plan2){
    cout << plan1 << endl;
  }
  else{
    cout << plan2 << endl;
  }
}

Measured memory_bytes: 3628
//#pragma GCC optimize(2)
//南京市第三区OI委提醒您：
//代码千万条，-O2第一条。
//-O2不规范，超时两行泪。
// Happy TLE and WA every day!
// by: zxb
#include<bits/stdc++.h>
#define mp              make_pair
#define rep(i,n)        for(int i = 0; i < n; i++)
#define foreach(i,c)    for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define BINF            0x7fffffff
#define INF             0x3f3f3f3f
#define LINF            4557430888798830399
#define pb              push_back
#define F               first
#define S               second
#define Time            clock()/CLOCKS_PER_SEC
#define read            ZXBs_fast_input
#define write           ZXBs_fast_output
//#define usingFiles
using namespace std;

typedef unsigned int ui;
typedef pair<int, int> pii;
typedef long long ll;

inline bool read(int& x){
	x = 0;
	int c;
	int sign = 1;
	while( (c = getchar()) < '0' || c > '9' ) if(c == '-') sign = -1;
	x = c ^ '0';
	while( (c = getchar()) >= '0' && c <= '9' ) x = (x<<3) + (x<<1) + (c ^ '0');
	x *= sign;
	return 1;
}

inline bool write(int x){
	if(x >= 10) write(x / 10);
	putchar(x % 10 + '0');
	return 1;
}

const int rp = 666666;
const bool debug = 1;
const bool I_good_vegetable_a = 1;

int n, x;
int l[111]; 

signed main(){
	ios::sync_with_stdio(false);
	#ifdef usingFiles
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	cin >> n >> x;
	int pos = 0;
	rep(i, n){
		cin >> l[i];
	}
	int i = 0;
	while(pos <= x && i < n){
		pos += l[i];
		i++;
	}
	if(pos <= x) i++;
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 1005
ll mod=1e9+7;
ll mul(ll a,ll b){
  return (a*b)%mod;
}

int n,m,a,b;
vector<int> G[MAX],g[MAX];
int p[MAX];
bool flg[MAX];

int update(int x){
  flg[x]=true;
  if(p[x]==x)return x;
  return p[x]=update(p[x]);
}

int find(int x){
  if(p[x]==x)return x;
  return find(p[x]);
}

ll dfs(int pos){
  ll res=1;
  for(int i=0;i<(int)g[pos].size();i++)
    res=mul(res,dfs(g[pos][i]));  
  return (res+1LL)%mod;
}

int main(){
  cin>>n>>m;
    for(int i=1;i<=n;i++)p[i]=i;
    for(int i=0;i<m;i++){
      cin>>a>>b;
      G[b].push_back(a);
      if(find(b)==a)update(b);
      else p[a]=b;
    }
    for(int i=1;i<=n;i++){
      for(int j=0;j<(int)G[i].size();j++){
        int w=G[i][j];
        if(flg[w])continue;
        if(flg[i])g[p[i]].push_back(w);
        else g[i].push_back(w);
      }
    }
    ll ans=1;
    for(int i=1;i<=n;i++)if(p[i]==i)ans=ans*dfs(i)%mod;
    cout<<ans<<endl;
  return 0;
}

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

using namespace std;
typedef long long int ll;

int main()
{
    int H,W,K;
    cin >> H >> W >> K;
    vector<vector<char>>G(H,vector<char>(W,' '));
    vector<vector<char>>g = G;
    for(int i = 0; i < H; i++)
    {
        for(int j = 0; j < W; j++)
        {
            cin >> G[i][j];
        }
    }
    int ans = 0;
    for(int bith = 0; bith < (1<<H); bith++)
    {
        for(int bitw = 0; bitw < (1<<W); bitw++)
        {
            g = G;
            for(int i = 0; i < H; i++)
            {
                if(bith & (1<<i))
                {
                    for(int j = 0; j < W; j++) g[i][j] = '.';
                }
            }
            for(int i = 0; i < W; i++)
            {
                if(bitw & (1<<i))
                {
                    for(int j = 0; j < H; j++) g[j][i] = '.';
                }
            }
            int sum = 0;
            for(int i = 0; i < H; i++)
            {
                for(int j = 0; j < W; j++)
                {
                    if(g[i][j] == '#') sum++;
                }
            }
            if(sum == K) 
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
int main(){
  int n;cin>>n;
  vector<T>data(n);
  rep(i,n)cin>>get<0>(data[i])>>get<1>(data[i])>>get<2>(data[i]);
  vector<vector<bool> >one(101,vector<bool>(101,true));
  for(int x=0;x<=100;x++){
    for(int y=0;y<=100;y++){
      bool ans=true;
      bool first=true;
      ll h;
      for(int i=0;i<n;i++){
        ll part=get<2>(data[i])+abs(x-get<0>(data[i]))+abs(y-get<1>(data[i]));
        if(get<2>(data[i])==0){
          continue;
        }
        if(first){
          h=get<2>(data[i])+abs(x-get<0>(data[i]))+abs(y-get<1>(data[i]));
          first=false;
          continue;
        }
        

        if(h!=part)ans=false;
      }
      for(int i=0;i<n;i++){
        ll part=get<2>(data[i])+abs(x-get<0>(data[i]))+abs(y-get<1>(data[i]));
        if(get<2>(data[i])==0){
          if(h-(abs(x-get<0>(data[i]))+abs(y-get<1>(data[i])))>0)ans=false;
        }
      }
      if(ans){
        printf("%d %d %lld\n",x,y,h);
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		int m = stdIn.nextInt();
		int l = stdIn.nextInt();
		
		long[][] A = new long[n][m];
		long[][] B = new long[m][l];
		long[][] C = new long[n][l];
		
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				A[i][j] = stdIn.nextInt();
			}
		}
		
		for(int i = 0; i < m; i++) {
			for(int j = 0; j < l; j++) {
				B[i][j] = stdIn.nextInt();
			}
		}
		
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < l; j++) {
				for(int k = 0; k < m; k++) {
					C[i][j] += A[i][k] * B[k][j];
				}
			}
		}
		
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < l-1; j++) {
				System.out.print(C[i][j] + " ");
			}
			System.out.println(C[i][l-1]);
		}
	}
}

Measured memory_bytes: 45376
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;
const int sz = 1e6 + 1;

int n;
ll dp[sz][4];

void solve() {
	cin >> n;
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		dp[i + 1][0] += (dp[i][0] * 8) % mod;
		dp[i + 1][0] %= mod;

		dp[i + 1][1] += dp[i][0] % mod;
		dp[i + 1][1] %= mod;

		dp[i + 1][1] += (dp[i][1] * 9) % mod;
		dp[i + 1][1] %= mod;

		dp[i + 1][2] += dp[i][0] % mod;
		dp[i + 1][2] %= mod;

		dp[i + 1][2] += (dp[i][2] * 9) % mod;
		dp[i + 1][2] %= mod;

		dp[i + 1][3] += dp[i][1] % mod;
		dp[i + 1][3] %= mod;

		dp[i + 1][3] += dp[i][2] % mod;
		dp[i + 1][3] %= mod;

		dp[i + 1][3] += (dp[i][3] * 10) % mod;
		dp[i + 1][3] %= mod;
	}

	cout << dp[n][3];
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		//cout << endl;
	}
}

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

using namespace std;

#define N 1
int n, x;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long t;
    cin >> n >> t;
    long long ans = 0, pt = 0;
    for (int i = 0; i < n; i++) {
        cin >> x;
        ans += min(x - pt, t);
        pt = x;
    }
    ans += t;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        String [] sArray = new String[s.length()];
        String [] tArray = new String[t.length()];
        for (int i = 0 ; i < s.length() ; i ++) {
            sArray[i] = String.valueOf(s.charAt(i));
        }
        for (int i = 0 ; i < t.length() ; i ++) {
            tArray[i] = String.valueOf(t.charAt(i));
        }
        Arrays.sort(sArray);
        Arrays.sort(tArray);

        String sDash = "";
        String tDash = "";
        for (int i = 0 ; i < sArray.length ; i++) {
            sDash += sArray[i];
        }
        for (int i = 0 ; i < tArray.length ; i++) {
            tDash += tArray[tArray.length - 1 - i];
        }
        if (sDash.compareTo(tDash) < 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,K;scanf("%d%d",&N,&K);
    long long a[N];
    for(int i=0;i<N;i++)scanf("%lld",&a[i]);
    long long ans=1000000000000000;
    for(long long bit=0;bit<(1<<N);bit++){
        if(__builtin_popcount(bit)<K)continue;
        long long height=0,now=0;
        for(long long i=0;i<N;i++){
            if(bit&(1<<i)){
                if(height>=a[i]){
                    now+=height+1-a[i];
                    height++;
                }
                else height=a[i];
            }
            height=max(height,a[i]);
        }
        ans=min(ans,now);
    }
    printf("%lld\n",ans);
    return 0;
}

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

int main()
{
    ll d;
    cin >> d;
    if (d % 2 == 0) {
        cout << -1 << endl;
        return 0;
    }
    if (d == 1) {
        cout << 1 << endl;
        return 0;
    }

    ll i = 1;
    ll x = 7;
    while(1) {
        int rem = x % d;
         if (rem == 0) {
            cout << i << endl;
            return 0;
        }
        x = rem*10 + 7;

        ++i;
        if (i > 1000000) break;
    }
    cout << -1 << endl;


    return 0;
}

Measured memory_bytes: 3600
l = int(input())
edge = []
for i in range(1, 19):
    edge.append((i, i + 1, 1 << (i - 1)))
    edge.append((i, i + 1, 0))
sm = 0
for i in range(19, 0, -1):
    v = 1 << (i - 1)
    while l >= v:
        edge.append((i, 20, sm))
        sm += v
        l -= v
print(20, len(edge))
for x, y, z in edge:
    print(x, y, z)

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

long long h[100001][4];
long long hap(int arr[][4],int n ,int ind)
{
     if(h[n][ind]!=-1)
        return h[n][ind];
    if(n==0)
        return 0;
    int ans,max;
    max=-1;
    for(int i=1;i<=3;i++)
    {
        if(i==ind)
            continue;
        ans=arr[n][i]+hap(arr,n-1,i);
        if(ans>max)
            max=ans;
    }
    if(ind!=-1)
    {
        h[n][ind]=max;
    }
    return max;
}
int main()
{
    long long n,ans;
    cin>>n;
     memset(h,-1,sizeof(h));
    int arr[n+1][4];
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=3;++j)
            cin>>arr[i][j];
    }
    ans=hap(arr,n,-1);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 12800
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max()/4 ;
const ll linf = numeric_limits<ll>::max()/4 ;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////
int n,k;
vector<int> v;

int dfs(int m, int num){
    if(n <= m){
       // cout << m << " " << num << endl;
        v.pb(num);
        ret 0;
    }

    dfs(m+1,num*2);
    dfs(m+1,num+k);
    ret 0;
}


int main(){

	
    cin >> n >> k;
    dfs(0,1);

    vsort(v);
    P(v[0]);
    
	return  0;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())
if a%2 == 0 or b%2 == 0 or c%2 == 0:
    print(0)
else:
    ans = [a,b,c]
    print(ans.pop(ans.index(min(ans)))*ans.pop(ans.index(min(ans))))

Measured memory_bytes: 2940
n, m, x = map(int, input().split())
c = []
a = [[] for _ in range(n)]
for i in range(n):
  inp = list(map(int, input().split()))
  c.append(inp[0])
  for j in range(m):
    a[i].append(inp[j+1])
kumi=1
for i in range(n):
  kumi *= 2
  
min_score = 10000000000000
for i in range(1, kumi):
  t = [0 for _ in range(m)]
  p = 0
  ni = format(i, 'b').zfill(n)
  for j in range(n):
    if(ni[j]=="1"):
      for kk in range(m):
        t[kk] += a[j][kk]
      p += c[j]
  flag = True
  for j in range(m):
    if(t[j] < x):
      flag = False
  if(flag):
    if(min_score > p):
      min_score = p
      
if(min_score == 10000000000000):
  print(-1)
else:
  print(min_score)
      

Measured memory_bytes: 9264
#include <bits/stdc++.h>
using namespace std;
int kaijo(int k){
  int x = 1;
  for(int i=1; i<=k; i++){
    x *= i;
  }
  return x;
}
int henkan(vector<int> vec,int N){
  vector<int> maina(N);
  for(int i=0; i<N; i++){
    for(int j=0; j<i; j++){
      if(vec.at(j) < vec.at(i))
        maina.at(i)++;
    }
  }
  int ans=1;
  for(int i=0; i<N; i++){
    vec.at(i) -= maina.at(i);
    ans += (vec.at(i)-1)*kaijo(N-i-1);
  }
  return ans;
}

int main(){
  int N;
  cin >> N;
  vector<int> vecP(N);
  vector<int> vecQ(N);
  for(int i=0; i<N; i++){
    cin >> vecP.at(i);
  }
  for(int i=0; i<N; i++){
    cin >> vecQ.at(i);
  }
  
  int a, b;
  a= henkan(vecP,N);
  b= henkan(vecQ,N);
  if(a>=b)
    cout << a-b << endl;
  else
    cout << b-a << endl;
}

Measured memory_bytes: 256