akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define M ((ll)(1e9)+7)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
void solve()
{
    int n;
    cin>>n;
    vector<pair<string,ll>> v;
    string s;ll a;
    for(int i=0;i<n;i++)
    {
        cin>>s>>a;
        v.pb({s,a});
    }
    cin>>s;
    int i=0;
    while(i<n&&v[i].F!=s)
    i++;
    i++;ll ans=0;
    while(i<n)
    {
        ans+=v[i].S;i++;
    }
    cout<<ans<<endl;
}
int main()
{
    solve();
}

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

int main() {
    
    
    int a, b, c, cnt=0, mult = 0;
    
    cin >> a >> b >> c;
    
    for(int i=1; i<=100; i++){
        if(mult == b || mult > b) break;
        mult = i*c;
        if(mult>=a && mult<=b) ++cnt;
        
    }

    cout << cnt << endl;
    
    
    
	return 0;
}

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

int main() {
	string word;
	string sentence;
	int count=0,i;
	getline(cin,word);
	while(1) {
		cin >> sentence;
		if(sentence=="END_OF_TEXT") break;
		if(sentence[(int)sentence.length()-1]=='.') {
			sentence.pop_back();
		}
		if(sentence.length()==word.length()) {
			for(i=0;i<(int)sentence.length();++i) {
				if(sentence[i]!=word[i]&&sentence[i]+'a'-'A'!=word[i]&&sentence[i]-'a'+'A'!=word[i]) break;
			}
			if(i==(int)sentence.length()) ++count;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3176
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))

ll left[100010],right[100010];
ll leftV[100010],rightV[100010];

ll t[100010];
ll v,k;
int main(){
	scanf("%lld%lld",&v,&k);
	rep(i,1,k+1)scanf("%lld",t+i);
	left[0]=0,leftV[0]=0;
	right[0]=v,rightV[0]=v;
	
	//前処理
	//上にある砂の量がわかる
	rep(i,1,k+1){
		//「初期値aと時刻tiにおける砂の量」のグラフは
		//(0,leftV)-(left,leftV)-(right,rightV)-(v,rightV)
		//の4点を結ぶ直線になっている（ _/¯ か ¯\_ の形）
		//各時刻tiにおけるleft,leftV,right,rightVを求める
		ll time=t[i]-t[i-1];
		if(i%2){
			//時刻tiの直前で_/¯
			if(rightV[i-1]<=time){
				//全部落ちる
				left[i]=v,leftV[i]=v;
				right[i]=v,rightV[i]=v;
			}else if(leftV[i-1]>=time){
				//ひっくり返すだけ
				left[i]=left[i-1],leftV[i]=v-(leftV[i-1]-time);
				right[i]=right[i-1],rightV[i]=v-(rightV[i-1]-time);
			}else{
				//leftの位置が変わる
				left[i]=left[i-1]+(time-leftV[i-1]);leftV[i]=v;
				right[i]=right[i-1];rightV[i]=v-(rightV[i-1]-time);
			}
		}else{
			//時刻tiの直前で¯\_
			if(leftV[i-1]<=time){
				//全部落ちる
				left[i]=v,leftV[i]=v;
				right[i]=v,rightV[i]=v;
			}else if(rightV[i-1]>=time){
				//ひっくり返すだけ
				left[i]=left[i-1],leftV[i]=v-(leftV[i-1]-time);
				right[i]=right[i-1],rightV[i]=v-(rightV[i-1]-time);
			}else{
				//rightの位置が変わる
				left[i]=left[i-1];leftV[i]=v-(leftV[i-1]-time);
				right[i]=right[i-1]-(time-rightV[i-1]);rightV[i]=v;
			}
		}
	}
	
//	rep(i,0,k+1)printf("%lld %lld %lld %lld\n",left[i],leftV[i],right[i],rightV[i]);
	
	ll q;
	scanf("%lld",&q);
	while(q--){
		ll time;
		ll a;
		scanf("%lld%lld",&time,&a);
		//timeがどの区間[t_i,t_{i+1})に属するかにぶたん
		ll l=0,r=k+1;
		while(r-l>1){
			ll m=(l+r)/2;
			if(t[m]<=time)l=m;
			else r=m;
		}
//		printf("%lld ",l);
		time-=t[l];
		ll ans;
		
		if(a<=left[l]){
			ans=max(leftV[l]-time,0);
		}else if(a>=right[l]){
			ans=max(rightV[l]-time,0);
		}else{
			if(l%2){
				//¯\_
				ans=max(leftV[l]-(a-left[l])-time,0);
			}else{
				//_/¯
				ans=max(leftV[l]+(a-left[l])-time,0);
			}
		}
		printf("%lld\n",l%2?v-ans:ans);
	}
	return 0;
}

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

int main() {
    string S;
    cin >> S;
    int a = 0; 
    int b = 0; 
    rep(i,S.size()) {
        if (S[i] == 'A' || S[i] == 'T' || S[i] == 'C' || S[i] == 'G') {
            a++;
        }
        else {
            a = 0;
        }
        if (a > b) {
            b = a;
        }
    }
    cout << b << endl;
}

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

int main() {
  int k;
  cin >> k;
  ll ans = 0;
  rep(a,k)rep(b,k)rep(c,k) ans += gcd(a,gcd(b,c));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef vector <int> vi;
typedef vector <string> vs;

int main(void){
	vi x;
	string suit = "IVXLCDM";
	int num[] = {1,5,10,50,100,500,1000};
	while (true){
		string roman;
		cin>>roman;
		if (cin.eof()) break;
		int tmp, tmp2=9999;
		for (int i=0; i<(int)roman.size(); i++)
			for (int j=0; j<(int)suit.size(); j++)
				if (roman[i]==suit[j]){
					tmp = num[j];
					if (i!=0 && tmp2<tmp)
						x[i-1] = -tmp2;
					x.push_back(tmp);
					tmp2 = tmp;
					break;
				}
		int s=0;
		for (int i=0; i<(int)x.size(); i++)
			s += x[i];
		cout<<s<<endl;
		x.clear();
	}
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    ll n;   cin >> n;
    vector<vector<ll>> dp(n+1, vector<ll>(2, 0));
    vector<ll> a(n);
    rep(i, n)   cin >> a[i];
    rep(i, n+1) rep(j, 2) dp[i][j] = -LINF;
    dp[0][0] = 0;
    rep(i, n){
        dp[i+1][0] = max(dp[i][0]+a[i], dp[i][1]-a[i]);
        dp[i+1][1] = max(dp[i][1]+a[i], dp[i][0]-a[i]);
    }
    cout << dp[n][0] << endl;
}


Measured memory_bytes: 9592
#include<iostream>
#include<string>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int i;
	string O,E;
	string result;
	cin >> O;
	cin >> E;
    for(i=0;i<E.size();i++){
        result=result+O[i]+E[i];
    }
    if(O.size()>E.size()) result=result+O[O.size()-1];
	cout << result << "\n";
}

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

int main() {
  
  int N, M, X; cin >> N >> M >> X;
  
  int leftCost = 0; int rightCost = 0;
  
  for (int i = 0; i < M; i++) {
    int A; cin >> A;
    if (A < X) leftCost++;
    else rightCost++;
  }
  
  cout << min(leftCost, rightCost) << endl;
  
}

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

const int maxN = 1e5+1;
const int maxMod = 101;
const long long MOD = 1e9+7;

int n,d;
char str[maxN];

long long dp[maxN][maxMod][2];

int main(){
    cin >> (str+1) >> d;
    n = strlen(str+1);
    
    dp[0][0][0] = 1;
    for(int i = 0; i < n; i++){
        int digit = str[i+1] - '0';
        for(int j = 0; j < d; j++){
            for(int dig = 0; dig < 10; dig++){
                dp[i+1][(j+dig) % d][1] = (dp[i+1][(j+dig) % d][1] + dp[i][j][1]) % MOD;
            }
            for(int dig = 0; dig < digit; dig++){
                dp[i+1][(j+dig) % d][1] = (dp[i+1][(j+dig) % d][1] + dp[i][j][0]) % MOD;
            }

            dp[i+1][(j+digit) % d][0] = (dp[i+1][(j+digit) % d][0] + dp[i][j][0]) % MOD;
        }
    }

    cout<<(dp[n][0][0] + dp[n][0][1] + MOD - 1) % MOD;

    return 0;
}

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

#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif

//{{{
using namespace std;
typedef long long LL;
typedef vector<int> VI;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
// clang-format off
#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); cerr<<endl;}
vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x; while
(getline(ss, x, c)) v.push_back(x); return v;} void err(vector<string>::iterator) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args)
{cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}
// clang-format on
//}}}

const int N = 1e5 + 10;
struct E
{
    int v, next;
} edge[N << 1];
int head[N], e;
void addedge(int u, int v)
{
    edge[e].v = v;
    edge[e].next = head[u];
    head[u] = e++;
}

int n;
int mod;

LL dp1[N], dpf[N], dp2[N];

LL dfs1(int u, int f)
{
    LL ret = 1;
    for (int i = head[u]; ~i; i = edge[i].next)
    {
        int v = edge[i].v;
        if (v == f) continue;
        LL val = dfs1(v, u);
        ret = ret * (1 + val) % mod;
    }
    return dp1[u] = ret;
}

LL pre[N], suf[N], val[N];
int idx[N];

void dfs2(int u, int f)
{
    int cnt = 0;
    for (int i = head[u]; ~i; i = edge[i].next)
    {
        int v = edge[i].v;
        if (v == f) continue;
        ++cnt;
        idx[cnt] = v;
        val[cnt] = dp1[v];
    }

    // if (cnt == 0) return;

    // assert(cnt >= 0);
    // assert(cnt <= n - 1);

    pre[0] = 1;
    for (int i = 1; i <= cnt; i++) pre[i] = pre[i - 1] * (1 + val[i]) % mod;
    suf[cnt + 1] = 1;
    for (int i = cnt; i >= 1; i--) suf[i] = suf[i + 1] * (1 + val[i]) % mod;

    for (int i = 1; i <= cnt; i++)
    {
        int p = idx[i];
        // assert(p >= 1);
        // assert(p <= n);

        LL v1 = pre[i - 1];
        LL v2 = suf[i + 1];
        LL v = v1 * v2 % mod;  // 同级

        dpf[p] = (dpf[u] * v + 1) % mod;
        dp2[p] = dpf[p] * dp1[p] % mod;
    }

    for (int i = head[u]; ~i; i = edge[i].next)
    {
        int v = edge[i].v;
        if (v == f) continue;
        dfs2(v, u);
    }
}

int main()
{
#ifdef LOCAL
    freopen("in2", "r", stdin);
// freopen("out", "w", stdout);
#endif

    while (~scanf("%d%d", &n, &mod))
    {
        clr(head, -1), e = 0;
        int u, v;
        for (int i = 1; i < n; i++)
        {
            scanf("%d%d", &u, &v);
            addedge(u, v);
            addedge(v, u);
        }

        // int root = rand() % n + 1;
        int root = 1;

        dfs1(root, -1);
        dp2[root] = dp1[root];
        dpf[root] = 1;

        dfs2(root, -1);

        for (int i = 1; i <= n; i++) printf("%lld\n", dp2[i]);
    }

    return 0;
}


Measured memory_bytes: 13632
N=int(input())
C=str(input())

S=0
T=N-1

t=0
while S<T:
  if C[S]=='R' and C[T]=='R':
    S+=1
  elif C[S]=='R' and C[T]=='W':
    S+=1
    T-=1
  elif C[S]=='W' and C[T]=='R':
    S+=1
    T-=1
    t+=1
  else:#C[S]=='W' and C[T]=='W'
    T-=1

print (t)



Measured memory_bytes: 9436
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll, ll>;
constexpr ll INF = (1LL << 60);
constexpr ll MOD = (1e9 + 7);
//constexpr ll MOD = (998244353);

typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

ll maxVec(vector<ll> &v) {
	ll ans = -INF;
	rep(i, v.size()) {
		ans = max(ans, v[i]);
	}
	return ans;
}


int main() {
	ll n;
	cin >> n;
	vector<double> p(n, 0);
	vector<vector<double>> dp(n + 1, vector<double>(n + 1,0));
	rep(i, n) {
		cin >> p[i];
	}

	dp[0][0] = 1.0;
	/*
	rep(i, n + 1) {
		if (i == 0)continue;
		rep(j, n + 1) {
			dp[i][j] += dp[i - 1][j] * (1 - p[i - 1]);
			if (j - 1 >= 0)dp[i][j] += dp[i - 1][j - 1] * p[i - 1];
		}
	}
	*/
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= i; ++j) {
			dp[i + 1][j + 1] += dp[i][j] * p[i];
			dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
		}
	}

	/*
	rep(i, n + 1) {
		rep(j, n + 1) {
			cout << dp[i][j] << " ";
		}
		cout << "\n";
	}
	*/

	double ans = 0.0;
	for (ll i = (n + 1) / 2; i < n + 1; i++) {
		ans += dp[n][i];
	}
	printf("%.10g", ans);
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main(){
  ll A = 0, B = 0, C = 0;
  vector<ll>z(3);
  cin >> A >> B >> C;
  z[0] = A; z[1] = B; z[2] = C;
  if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0){
    cout << "0";
    return 0;
  }
  sort(z.begin(), z.end()); //小さい順
  cout << z[0] * z[1];
}
  

Measured memory_bytes: 256
import java.util.Scanner;

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

        int M1 = stdin.nextInt();
        int D1 = stdin.nextInt();
        int M2 = stdin.nextInt();
        int D2 = stdin.nextInt();
        
        if(M1 != M2) {
        	System.out.print("1");
        }
        else {
        	System.out.print("0");
        }
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <string.h>

using namespace std;
typedef pair<int, int> P;
int N, A, B, C;
vector<int> l;

int dfs(int cur, int a, int b, int c)
{
	if (cur == N)
	{
		if (a > 0 && b > 0 && c > 0)
		{
			return(abs(a - A) + abs(b - B) + abs(c - C) - 30);
		}
		else
		{
			return(1e9);
		}
	}
	int res0 = dfs(cur + 1, a, b, c);
	int res1 = dfs(cur + 1, a + l[cur], b, c) + 10;
	int res2 = dfs(cur + 1, a, b + l[cur], c) + 10;
	int res3 = dfs(cur + 1, a, b, c + l[cur]) + 10;
	return(min(min(min(res0, res1), res2), res3));
}

void solve()
{
	cin >> N >> A >> B >> C;
	l.resize(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> l[i];
	}
	cout << dfs(0, 0, 0, 0) << endl;
}

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

Measured memory_bytes: 256
#include <iostream> // C++の入出力
#include <stdio.h> // C の入出力
#include <algorithm> // sort などのアルゴリズム
#include <string.h> // C の文字列用
#include <ctype.h> // C の文字種用
#include <string> // C++の文字列
using namespace std;
int main(void){
    int n;
    string in;
    while(1){
        cin>>n;
        if(n==0)break;
        char data[n];
        char into[n];
        for(int i=0;i<n;i++){
            cin>>in;
            data[i]=in[0];
            cin>>in;
            into[i]=in[0];
        }
        int last;
        cin >> last;
        for(int t=0;t<last;t++){
            cin >> in;
            bool f=false;
            for(int i=0;i<n;i++){
                if(data[i]==in[0]){
                    f=true;
                    cout<<into[i];
                }
            }
            if(!f)cout<<in[0];
        }
        cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
#define REP(i, d, n) for(int i=(d); i<(n); i++)
typedef long long ll;
const int mod = 1e9 + 7;
int main() {

    int k, x;
    cin >> k >> x;

    if(500*k >= x){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main() 
{
    int n, m, ans = 0;
    cin >> n >> m;
    vector<vector<int>>   s(m, vector<int>());
    for(int i = 0; i < m; i++) {
        int k;    cin >> k;
        for(int j = 0; j < k; j++) {
            int l;    cin >> l;
            s.at(i).push_back(l);
        }
    }

    vector<int>   p(m);
    for(int i = 0; i < m; i++)
        cin >> p.at(i);

    for(int bit = 0; bit < (1 << n); bit++) {
        bool judge = true;
        vector<bool>    swi(n, false);

        for(int i = 0; i < n; i++) {
            if(bit & (1 << i))
                swi.at(i) = true;
        }

        for(int i = 0; i < m; i++) {

            int sum = 0;

            for(int j = 0; j < swi.size(); j++) {
                for(int k = 0; k < s.at(i).size(); k++) {
                    if(swi.at(j))
                        if(j + 1 == s.at(i).at(k))
                            sum++;
                }
            }

            if((sum % 2) != p.at(i))
                judge = false;
        }

        if(judge)
            ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())

if H % 3 == 0 or W % 3 == 0:
    print(0)
    exit()

ans = min(H, W)
for A, B in ((H, W), (W, H)):
    for a in (A // 3, A // 3 + 1):
        for b in (B // 2, B // 2 + 1):
            X = a * B
            Y = (A - a) * b
            Z = (A - a) * (B - b)

            ans = min(ans, max(X, Y, Z) - min(X, Y, Z))
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()
const int INF = 1e9;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;

/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */

/** Problem0215 : Pachimon Creature **/
int dp[5][1024];

vector<vector<PII> > list(5);
PII sp, gp;

int dist(PII a, PII b)
{
	return abs(a.first - b.first) + abs(a.second - b.second);
}

int solve(int old, int idx, int got)
{
	if (got == 5)
		return dist(gp, list[old][idx]);
	
	if (dp[got][idx] != -1)
		return dp[got][idx];
	
	int next = (old+1)%5;
	
	
	int res = INF;
	for (int i=0; i<list[next].size(); i++) {
		res = min(res, solve(next, i, got+1) + dist(list[old][idx], list[next][i]));
	}
	
	return dp[got][idx] = res;
}

int main()
{
	int W, H;
	while (cin>>W>>H, W||H) {
		for (int i=0; i<5; i++) list[i].clear();
		
		vector<string> field(H);
		rep(i, H) {
			cin>>field[i];
		}
		
		rep(y, H) {
			rep(x, W) {
				if (field[y][x] == 'S') {
					sp = PII(x, y);
				} else if (field[y][x] == 'G') {
					gp = PII(x, y);
				} else if (isdigit(field[y][x])) {
					int n = field[y][x] - '1';
					list[n].push_back(PII(x, y));
				}
			}
		}
		
		int ans = INF, ansFirst=-1;
		rep(first, 5) {
			memset(dp, -1, sizeof(dp));
			int next = (first+1)%5;
			
			for (int i=0; i<list[next].size(); i++) {
				int res = solve(next, i, 2)+ dist(sp, list[next][i]);
				if (ans > res) {
					ans = res;
					ansFirst = first+1;
				}
			}
		}
		
		if (ans < INF) {
			cout << ansFirst << " " << ans << endl;
		} else {
			cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 2192
x = input()
count=0
for i in range(0,len(x),2):
  if x[i]=="R" or x[i]=="U" or x[i]=="D":
    count += 1
for j in range(1,len(x),2):
  if x[j]=="L" or x[j]=="U" or x[j]=="D":
    count += 1
if count==len(x):
  print("Yes")
else:
  print("No")
  

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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

const int inf = 0x3f3f3f3f;

int h, w;

struct SEG {
	static const int mxn = 1 << 18;
	int mn[mxn << 1], tag[mxn << 1], fst[mxn << 1];
	
	void push(int x, int v) {
		tag[x] = v;
		mn[x] = v + fst[x];
	}
	
	void pushdown(int x) {
		if (tag[x] > -inf) {
			push(x << 1, tag[x]);
			push(x << 1 | 1, tag[x]);
			tag[x] = -inf;
		}
	}
	
	void pushup(int i) {
		mn[i] = min(mn[i << 1], mn[i << 1 | 1]);
	}
	
	void build(int i, int l, int r) {
		fst[i] = l;
		tag[i] = -inf;
		if (l + 1 == r) { mn[i] = 0; return ; }
		int m = (l + r) >> 1;
		build(i << 1, l, m);
		build(i << 1 | 1, m, r);
		pushup(i);
	}
	
	void upd(int i, int a, int b, int l, int r, int v) {
		if (l <= a && b <= r) return push(i, v);
		pushdown(i);
		int m = (a + b) >> 1;
		if (l < m) upd(i << 1, a, m, l, r, v);
		if (r > m) upd(i << 1 | 1, m, b, l, r, v);
		pushup(i);
	}
	
	int get(int i, int a, int b, int x) {
		if (a + 1 == b) return mn[i];
		pushdown(i);
		int m = (a + b) >> 1;
		if (x < m) return get(i << 1, a, m, x);
		else return get(i << 1 | 1, m, b, x);
	}
} seg;

int main() {
	scanf("%d %d", &h, &w);
	seg.build(1, 0, w);
	rep(i, h) {
		int l, r; scanf("%d %d", &l, &r); -- l;
		seg.upd(1, 0, w, l, r, l ? seg.get(1, 0, w, l - 1) - (l - 1) : inf);
		int ans = seg.mn[1] + i + 1;
		printf("%d\n", ans >= inf ? -1 : ans);
	}
	return 0;
}


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int i=0;i<(n);i++)        //repeat n times
#define REP2(i,s,n) for(int i=(s);i<(n);i++)   //repeat from s to n 
#define REPD(i,n) for(int i=(n);i>=0;i--)      //repeat from n to 0
#define REPD2(i,s,e) for(int i=(s);i>=(e);i--) //repeat from s to e
#define RANGE(i,v) for(auto &i:v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T1,typename T2> using P = pair< T1, T2 >;
using Pii = P<int,int>;
using Pll = P<LL,LL>;
using Pdd = P<double,double>;
using Psi = P<string,double>;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

int main(){
    int A,B,H,M;
    cin>>A>>B>>H>>M;

    double th = 2.*M_PI*(((double)H+((double)M/60.))/12. - (double)M/60.);
    double x = sqrt(A*A + B*B -2*A*B*cos(th));

    cout<<setprecision(15)<<x<<endl;
    return 0;
}

Measured memory_bytes: 4228
n, s = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

M = 998244353
R2 = 499122177

dp = Array.new(s+1, 0)
dp[0] = 1
n.times {dp[0] = dp[0] * 2 % M}

a.each {|i| (s-i).downto(0) {|j| dp[i+j] = (dp[i+j] + dp[j] * R2) % M}}
p dp[s]

Measured memory_bytes: 14360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    
    if ((a < 0) && (b < 0)) {
        if ((b - a + 1) % 2 == 0) {
            cout << "Positive" << endl;
        }
        else {
            cout << "Negative" << endl;
        }
    }
    else if ((a > 0) && (b > 0)) {
        cout << "Positive" << endl;
    }
    else {
        cout << "Zero" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdlib>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C) (C).begin(),(C).end()
#define pb push_back

const int N = 401;
int len[N];
vector<vector<int> > path;

bool chlen(int val,int now,int *in,bool flag){
  bool ret=true;
  rep(i,now){
    int tmp=abs(val-in[i]);
    if(flag)len[tmp]++;
    else len[tmp]--;
    if (!flag&&len[tmp] < 0)ret=false;
  }

  if (!ret){
    rep(i,now){
      len[abs(val-in[i])]++;
    }
  }
  return ret;
}

bool canput(int val,int now,int *in){
  return chlen(val,now,in,false);
}

int buf[20];
const int sign[2]={1,-1};
void search(int n,int now,int *pos,int p){
  if (n == now){
    vector<int> tmp;
    rep(i,n)buf[i]=pos[i];
    sort(buf,buf+n);
    rep(i,n-1){
      tmp.pb(buf[i+1]-buf[i]);
    }
    path.pb(tmp);
    return ;
  }
  //rep(i,now)cout << pos[i] <<" ";cout << endl;
  
  while(p>0 && len[p]==0)p--;
  rep(k,2){
    rep(i,now){
      bool isok=true;
      int val=pos[i]+sign[k]*p;
      if (val > pos[1] || val <0)continue;
      rep(j,now){
	if (i!=j && pos[j] ==val){isok=false;break;}
	//if(pos[i] < pos[j] < val continue;for prune
      }
      //cout << pos[i]<<" " << sign[k]*p << " " << val <<" " << isok << endl;

      if (!isok)continue;
      if (canput(val,now,pos)){
	pos[now]=val;
	search(n,now+1,pos,p);
	chlen(val,now,pos,true);
      }
    }
  }
}

main(){
  int n;
  int pos[20];
  while(cin>>n && n){
    rep(i,N)len[i]=0;
    path.clear();
    int maxi=0;
    rep(i,n){
      REP(j,i+1,n){
	int tmp;cin>>tmp;len[tmp]++;maxi=max(maxi,tmp);
      }
    }
    pos[0]=0;
    pos[1]=maxi;
    len[maxi]--;

    search(n,2,pos,maxi);
    sort(ALL(path));
    //cout <<"before "<< path.size() << endl;
    path.erase(unique(ALL(path)),path.end());
    //cout <<"after "<< path.size() << endl;
    rep(i,path.size()){
      rep(j,path[i].size()){
	if (j)cout << " ";
	cout << path[i][j];
      }
      cout << endl;
    }
    cout << "-----"<<endl;
  }
  return false;
}




/*
void solve(int n,int now,int *pos){
  if (n-1 == now){
    vector<int> tmp;
    rep(i,n-1){
      //if (i)cout <<' ';
      //cout << op[i+1]-op[i];
      tmp.pb(pos[i+1]-pos[i]);
    }
    path.pb(tmp);
    //    cout << endl;
    //rep(i,n)cout << op[i] <<" ";cout << endl;
    return ;
  }

  //rep(i,now)cout << pos[i] <<" ";cout << pos[n-1] << endl;

  for(int i=pos[n-1]-1;i>=1;i--){
    if (len[i] == 0)continue;
    //cout << "exist "<< i <<":"<<len[i] <<endl;
    if (pos[now-1] +i < pos[n-1] && canput(pos[now-1]+i,n,now,pos)){
	pos[now]=pos[now-1]+i;
	//chlen(pos[now],n,now,pos,false);
	solve(n,now+1,pos);
	chlen(pos[now],n,now,pos,true);
    }
  }
}
*/

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int a[5],diff[5],max=0,itr=0,ans=0;
  for(int i=0;i<5;i++){
    cin>>a[i];
    diff[i]=10-a[i]%10;
    if(diff[i]>max){
      if(diff[i]==10){
        diff[i]=0;
        continue;
      }
      max=diff[i];
      itr=i;
    }
  }
  for(int i=0;i<5;i++){
    if(i!=itr){
      ans+=a[i]+diff[i];
    }else{
      ans+=a[i];
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
//go:generate echo "https://atcoder.jp/contests/dp/tasks/dp_c"
package main

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

type scanner struct{ *bufio.Scanner }

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 100000000)
	return &scanner{s}
}

func (s *scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *scanner) IntSlice(l int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := range sl {
		sl[i] = s.Int()
	}
	return sl
}

func (s *scanner) IntSlice2(l, n int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := 0; i < n; i++ {
		sl[i] = s.Int()
	}
	return sl
}

func solve(n int, u [][]int) int {
	t := make([][]int, n+1, n+1)
	for i := range t {
		t[i] = make([]int, 3, 3)
	}
	for i := 0; i < n; i++ {
		for j := 0; j < 3; j++ {
			for k := 0; k < 3; k++ {
				if j == k {
					continue
				}
				if v := t[i][j] + u[i][k]; t[i+1][k] < v {
					t[i+1][k] = v
				}
			}
		}
	}
	max := math.MinInt64
	for _, v := range t[n] {
		if max < v {
			max = v
		}
	}
	return max
}

func main() {
	scan := newScanner(os.Stdin)
	n := scan.Int()
	u := make([][]int, n+1, n+1)
	for i := 0; i <= n; i++ {
		u[i] = []int{scan.Int(), scan.Int(), scan.Int()}
	}
	fmt.Println(solve(n, u))
}


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

int main() {
    int r, D, x;
    cin >> r >> D >> x;
    for (int i = 0; i < 10; i++) {
        x = r * x - D;
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 8)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    n = Z()
    x = (n + 1000 - 1)//1000
    print(1000*x - n)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 9156
#include <iostream>
#include <iomanip>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;
using std::sqrt;
using std::acos;

int
main()
{
  int a, b, x;
  cin >> a >> b >> x;
  if (a * a * b == x)
  {
    cout << 0 << endl;
    return 0;
  }
  int aa = a * a;
  double h = double(x) / aa;
  if (double(b) / 2 <= h)
  {
    double B = b - h;
    double A = double(a) / 2;
    double C = sqrt(A * A + B * B);
    double pi = 3.141592653589793;
    cout << std::setprecision(10) << 90.0 - acos((B * B + C * C - A * A) / (2 * B * C)) * 180 / pi << endl;
  }
  else
  {
    double A = double(x) / a / b * 2;
    double B = b;
    double C = sqrt(A * A + B * B);
    double pi = 3.141592653589793;
    cout << std::setprecision(10) << 90.0 - acos((B * B + C * C - A * A) / (2 * B * C)) * 180 / pi << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll N,K;

bool judge_m(ll mid, VL &p, VL &n){
	ll sum=0LL;
	rep(i,p.size()){
		ll d=(mid-p[i]+1)/p[i];
		sum+=upper_bound(ALL(n),d)-n.begin();
	}
	return sum>=K;
}

bool judge_p(ll mid, VL &p, VL &n){
	ll sum=0LL;
	rep(i,p.size()){
		ll d=mid/p[i];
		ll tmp=upper_bound(ALL(p),d)-p.begin();
		if(i<tmp) tmp--;
		sum+=tmp;
	}
	rep(i,n.size()){
		ll d=mid/n[i];
		ll tmp=upper_bound(ALL(n),d)-n.begin();
		if(i<tmp) tmp--;
		sum+=tmp;
	}
	sum/=2;
	return sum>=K;
}

signed main(){
  cin>>N>>K;
	VL p,n; ll zero=0LL;

	rep(i,N){
		ll a; cin>>a;
		if(a>0) p.PB(a);
		else if(a<0) n.PB(a);
		else zero++;
	}
	sort(ALL(p)); sort(ALL(n));
	// ll posi=pow(p.size(),2LL)+pow(n.size(),2LL)+N-zero;
	ll nega=p.size()*n.size();
	zero=zero*(zero-1)/2+zero*(N-zero);

	if(K<=nega){
		ll l=-1e18-1, u=-1;
		while(u-l>1){
			ll mid=(l+u)/2;
			if(judge_m(mid,p,n)) u=mid;
			else l=mid;
		}
		cout<<u<<endl;
	}else if(K<=nega+zero){
		cout<<0<<endl;
	}else{
		K-=nega+zero;
		rep(i,n.size()) n[i]*=-1;
		sort(ALL(n));
		ll l=-1, u=1e18;
		while(u-l>1){
			ll mid=(l+u)/2;
			if(judge_p(mid,p,n)) u=mid;
			else l=mid;
		}
		cout<<u<<endl;
	}

  return 0;
}


Measured memory_bytes: 2420
import sys

sys.setrecursionlimit(10 ** 7)

N = int(input())
edges = [[] for _ in range(N)]
for _ in range(1, N):
    a, b, c = map(int, input().split())
    a, b = a - 1, b - 1
    edges[a].append([b, c])
    edges[b].append([a, c])

Q, K = map(int, input().split())
K -= 1
dist = [pow(10, 9) + 1] * N
dist[K] = 0


def dfs(s, before=-1):
    for edge in edges[s]:
        to = edge[0]
        c = edge[1]
        if to != before:
            dist[to] = dist[s] + c
            dfs(to, s)


dfs(K)
for _ in range(Q):
    x, y = map(int, input().split())
    x, y = x-1, y-1
    print(dist[x] + dist[y])

Measured memory_bytes: 158632
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {
  int n, x; cin >> n >> x;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  for(int i=0; i<n; i++){
    if(x < a[i]){
      cout << i << endl;
      return 0;
    }
    x -= a[i];
  }
  if(x == 0) cout << n << endl;
  else cout << n - 1 << endl;

  return 0;
}



//


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
struct loc { int x, y, d; };
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
int trans(char x) {
	if (x == 'N')return 0;
	else if (x == 'E')return 1;
	else if (x == 'S')return 2;
	else return 3;
}
char inv(int x) {
	if (x == 0)return 'N';
	else if (x == 1)return 'E';
	else if (x == 2)return 'S';
	else return 'W';
}
bool eq(loc x, loc y) {
	if (x.x == y.x&&x.y == y.y&&x.d == y.d)return true;
	return false;
}
int main() {
	int w, h; ll n;
	while (cin >> h >> w >> n,h) {
		char board[100][100];
		int used[100][100][4] = {};
		vector<loc> v;
		loc now;
		rep(i, h) {
			string s; cin >> s;
			rep(j, w) {
				board[i][j] = s[j];
				if (s[j] != '.'&&s[j] != '#') {
					now = { i,j,trans(s[j]) };
					used[i][j][trans(s[j])] = 1;
				}
			}
		}
		v.push_back(now);
		loc memo;
		while (true) {
			rep(j, 4) {
				int nx = now.x + dx[(j+now.d)%4];
				int ny = now.y + dy[(j+now.d)%4];
				if (nx < 0 || ny < 0 || nx >= h || ny >= w)continue;
				if (board[nx][ny] == '#')continue;
				now = { nx,ny,(j + now.d) % 4 }; break;
			}
			if (used[now.x][now.y][now.d]) {
				memo = now;
				break;
			}
			used[now.x][now.y][now.d] = 1;
			v.push_back(now);
		}
		int len = v.size(); int chk;
		rep(i, len) {
			if (eq(v[i], memo)) {
				chk = i; break;
			}
		}
		if ((ll)len > n) {
			int r = (int)n;
			int x = v[r].x + 1; int y = v[r].y + 1; char d = inv(v[r].d);
			cout << x << " " << y << " " << d << endl;
		}
		else {
			n -= (ll)chk;
			int r = (int)(n % (ll)(len - chk)) + chk;
			int x = v[r].x + 1; int y = v[r].y + 1; char d = inv(v[r].d);
			cout << x << " " << y << " " << d << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3336
import Control.Applicative

type Problem = [Int]

type Result = [Int]

solve :: Problem -> Result

solve
    = reverse

input :: IO Problem

input
    = do
        getLine
        xs <- map read.words <$> getLine
        return xs

output :: Result -> IO ()

output xs
    = putStrLn $ init $ concat [show x ++ " " | x <- xs]
    
main :: IO ()

main = output =<< solve <$> input

Measured memory_bytes: 4092
<?php
  while ($line = fgets(STDIN)) {
      $inputs[] = trim($line);
  };
  list($n, $m) = explode(" ", $inputs[0]);
  $a_s = explode(" ", $inputs[1]);
$n = (int) $n;
$m = (int) $m;

$sum = 0;
for ($i=0; $i < $m; $i++) {
  $sum = $sum + (int) $a_s[$i];
}
if ($n < $sum) {
  echo -1;
} else {
  echo $n - $sum;
}

Measured memory_bytes: 16904
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll k,i,ans,x;
	cin >> k;
	x = 0;
	for(i=0;i<(int)pow(10,6);i++)
    {
        x = ((x*10)%k + (7%k))%k;
        if(x == 0)
        {
            cout << (i+1) << endl;
            return 0;
        }

    }
    cout << -1;

}


Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  int n;
  cin >> n;
  for(int i=0; i<10; i++){
    for(int j=0; j<10; j++){
      if(n==i*j){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define WHITE 0
#define BLACK 1
#define MAX 101
#define INF (1<<22)

int color[MAX],d[MAX],p[MAX],G[MAX][MAX],n;

void dijkstra(){
  int i,j,u,min;
  for(i=0;i<n;i++){
    d[i]=INF;
    p[i]=-1;
    color[i]=WHITE;
  }
  d[0]=0;
  while(1){
    min=INF;
    // u = -1;//
    for(i=0;i<n;i++){
      if(color[i] != BLACK && d[i] < min){
	u=i;
	min=d[i];
      }
    }
    if(min==INF) break;
    color[u]=BLACK;
    for(j=0;j<n;j++){
      if(color[j] != BLACK && d[j] > d[u]+G[u][j]){
	p[j]=u;
	d[j]=d[u]+G[u][j];
      }
    }
  }
}

int main(){
  int i,j,u,k,v,c;
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    for(j=0;j<n;j++){
      G[i][j]=INF;
      }
  }
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      scanf("%d",&c);
      G[u][v]=c;
    }
  }
     dijkstra();
  
  for(i=0;i<n;i++) {
    printf("%d ",i);
    printf("%d\n",d[i]);
    }
  
  return 0;
}



Measured memory_bytes: 2052
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            var s = ReadLine();
            WriteLine(
                (char)((int)s[0] + 1)
                );
        }
    }
}

Measured memory_bytes: 11092
#include <algorithm>
#include <bitset>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long int;

int main() {
  string S;
  int K;
  cin >> S >> K;
  vector<ll> n(S.size());
  for (size_t i = 0; i < S.size(); i++) {
    n[i] = S[i] - 48;
  }

  vector<vector<vector<ll>>> dp(n.size() + 1,
                                vector<vector<ll>>(4, vector<ll>(2, 0)));

  dp[0][0][0] = 1;

  for (size_t i = 0; i < n.size(); i++) {
    for (size_t d = 0; d < 10; d++) {
      for (size_t k = 0; k <= 3; k++) {
        for (size_t l = 0; l < 2; l++) {
          int nk = (d == 0) ? k : k + 1;
          int nl = l;
          // 元の数より大きい or 0 でない数字が多すぎる
          if ((l == 0 && d > n[i]) || nk > K) {
            continue;
          }
          if (l == 0 && d < n[i]) {
            nl = 1;
          }
          dp[i + 1][nk][nl] += dp[i][k][l];
        }
      }
    }
  }

  cout << (dp[n.size()][K][0] + dp[n.size()][K][1]) << endl;
}

Measured memory_bytes: 256
<?php

$is_honban = 1;

if ($is_honban) {
  //----------------------------------------------------------------------------------
  // Input for honban
  //----------------------------------------------------------------------------------
  $sc = new Scanner();
  $a = $sc->nextInt();
  $b = $sc->nextInt();
  $c = $sc->nextInt();

//  $h = array();
//  for ($i = 0; $i < $n; $i++) {
//    $h[] = $sc->nextInt();
//  }


} else {
  //----------------------------------------------------------------------------------
  // Input for test
  //----------------------------------------------------------------------------------
  error_reporting(E_ERROR | E_WARNING | E_PARSE);

  $n = 5;
  $a = 2;
  $b = 1;
  $h = array(90000,90000,100000,100000,100000);



}
//----------------------------------------------------------------------------------
// Main
//----------------------------------------------------------------------------------

$ans = 0;

$ans = ($a == $b && $b == $c) ? 'Yes' : 'No';



//----------------------------------------------------------------------------------
// Output
//----------------------------------------------------------------------------------
out::println($ans);



//----------------------------------------------------------------------------------
// Ref: https://qiita.com/yoshikyoto/items/6924478283dbdd549e4b
//----------------------------------------------------------------------------------
class Scanner {
  private $arr = array();
  private $count = 0;
  private $pointer = 0;
  public function next() {
    if($this->pointer >= $this->count) {
      $str = trim(fgets(STDIN));
      $this->arr = explode(' ', $str);
      $this->count = count($this->arr);
      $this->pointer = 0;
    }
    $result = $this->arr[$this->pointer];
    $this->pointer++;
    return $result;
  }
  public function hasNext() {
    return $this->pointer < $this->count;
  }
  public function nextInt() {
    return (int)$this->next();
  }
  public function nextDouble() {
    return (double)$this->next();
  }
}

class out {
  public static function println($str = "") {
    echo $str . PHP_EOL;
  }
}

?>


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

signed main() {
    int x;
    cin >> x;
    int a, b;
    for(int i = -1000; i <= 1000; ++i) {
        for(int j = i + 1; j <= 1000; ++j) {
            int one = j * j * j * j * j;
            int two = i * i * i * i * i;
            if(one - two == x) {
                cout << j << " " << i;
                return 0;
            }
            else if(two - one == x) {
                cout << i << " " << j;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3532
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>

using namespace std;
#define lli long long int
#define numberofdigits(x) floor(log10(x)) + 1

int main()
{
    string s;
    cin>>s;
    if(s=="AAA" || s=="BBB")
        cout<<"No\n";
    else
        cout<<"Yes\n";
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>

int n;
double datax[20];
double datay[20];

double keisan();
double nagasa(int,int);

main(){
  double x, y, ans;
  int i;
  for(i=0;;i++){
    if(scanf("%lf,%lf", &x, &y)==EOF) break;
    datax[i]=x;
    datay[i]=y;
    n++;
  }

  ans=keisan();

  printf("%f\n", ans);

  return 0;
}

double keisan(){
  double temp, s, sum=0;
  double a, b, c;
  int i, j;

  for(i=1,j=2;i<n;i++,j++){
    if(j==n) break;
    a=nagasa(0,i);
    b=nagasa(i,j);
    c=nagasa(0,j);
    temp=(a+b+c)/2;
    s=sqrt(temp*(temp-a)*(temp-b)*(temp-c));
    sum+=s;
  }

  return sum;
}

double nagasa(int a, int b){
  return sqrt((datax[a]-datax[b])*(datax[a]-datax[b])+(datay[a]-datay[b])*(datay[a]-datay[b]));
}

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

int main(){
    int D, G;
    cin >> D >> G;
    vector<int> p(D), c(D), p2(D);
    for (int i=0; i<D; i++) cin >> p.at(i) >> c.at(i);
    p2 = p;

    int ans = 10000;
    for (int i=0; i<(1<<D); i++){
        int score = 0;
        int tasks = 0;
        p = p2;

        for (int j=0; j<D; j++){
            if (i & (1<<j)){
                score += c.at(j) + 100 * (j+1) * p.at(j);
                tasks += p.at(j);
                p.at(j) = 0;
            }
        }

        int j = D-1;

        while (true){
            if (score >= G) break;

            if (p.at(j) > 1){
                score += 100 * (j+1);
                p.at(j)--;
                tasks++;
            } else {
                j--;
            }

            if (j < 0) break;
        }

        if (score >= G) ans = min(ans, tasks);
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int arr[15][1005];
int h, w, k, ans = 1e9;
ll get_sum(int i, int j, int ii, int jj) {
    return arr[ii][jj] - arr[i - 1][jj] - arr[ii][j - 1] + arr[i - 1][j - 1];
}
vector<pair<int, int>> get_partitions(int msk) {
    vector<pair<int, int>> ret;
    for (int i = 0; i < h - 1; i++) {
        if (!(msk & (1 << i))) continue;
        if (ret.size()) ret.emplace_back(ret.back().second + 1, i + 1);
        else ret.emplace_back(1, i + 1);
    }
    if (ret.size()) ret.emplace_back(ret.back().second + 1, h);
    else ret.emplace_back(1, h);
    return ret;
}
int solve(vector<pair<int, int>> partitions) {
     int ret = partitions.size(), s = 1;
     while (s <= w) {
         int l = s, r = w, mid, res = -1;
         while (l <= r) {
             mid = (l + r) / 2;
             bool can = true;
             for (auto curr_parition: partitions)
                 if (get_sum(curr_parition.first, s, curr_parition.second, mid) > k)
                     can = false;
             if (can) {
                 res = mid;
                 l = mid + 1;
             }
             else r = mid - 1;
         }
         if (res == -1) return 1e9;
         if (res != w) ret++;
         s = res + 1;
     }
     return --ret;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> h >> w >> k;
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            char c;
            cin >> c;
            arr[i][j] += (c == '1');
            arr[i][j] += arr[i][j - 1];
        }
        for (int j = 1; j <= w; j++) arr[i][j] += arr[i - 1][j];
    }
    for (int msk = 0; msk < (1 << (h - 1)); msk++) {
        vector<pair<int, int>> vec = get_partitions(msk);
        ans = min(ans, solve(vec));
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
  int a[4];
  int b[4];
  int i,j;
  int hit,blow;
  while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3])!=EOF){
    hit=0;
    blow=0;
    scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]);
    for(i=0;i<4;i++){
      for(j=0;j<4;j++){
	if(b[i]==a[j]){
	  if(i==j)hit++;
	  else blow++;
	}
      }
    }
    printf("%d %d\n",hit,blow);
  }
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define ll long long
#define fo(i,n) for(i=0;i<n;++i)
#define forr(i,n) for(i=n-1;i>=0;--i)
using namespace std;

ll gcd(ll a,ll b){while(a&&b)a>=b?a%=b:b%=a;return a+b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
 string st;
 cin>>st;
 ll i, j;
 bool s=0, n=0, e=0, w=0;
 fo(i,st.length())
 {
    if(st[i]=='S')
        s=1;
    else if(st[i]=='W')
        w=1;
    else if(st[i]=='E')
        e++;
    else
        n++;
 }
 if((s==1&&n==0) || (s==0&&n)){
    cout<<"No"<<endl;
 }
 else if((e==1&&w==0) ||(e==0&&w )){
    cout<<"No"<<endl;
 }
 else{
    cout<<"Yes"<<endl;
 }
 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;

int main(){
  string text1, text2;
  cin >> text1 >> text2;
  
  sort(text1.begin(), text1.end());
  sort(text2.begin(), text2.end());
  reverse(text2.begin(), text2.end());
 
  if (text1 < text2){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256