akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;

int main(){

    int h, w, n; cin >> h >> w >> n;

    int sr, sc; cin >> sr >> sc;

    string s, t; cin >> s >> t;

    int templ = sc, tempu = sr, tempr = sc, tempd = sr;
    bool flag = false;
    for(int i=0; i<n; i++){
        switch(s[i]){
            case 'L': templ--; break;
            case 'U': tempu--; break;
            case 'R': tempr++; break;
            case 'D': tempd++; break;
        }
        // cout << tempr << endl;

        if(templ <= 0 || tempu <= 0 || tempr > w || tempd > h){
            flag = true;
            break;
        }

        switch(t[i]){
            case 'L': if(tempr != 1) tempr--; break;
            case 'U': if(tempd != 1) tempd--; break;
            case 'R': if(templ != w) templ++; break;
            case 'D': if(tempu != h) tempu++; break;
        }
        // cout << tempr << endl;
        // cout << endl;
    }

    cout << (flag ? "NO" : "YES") << endl;

    return 0;
}

Measured memory_bytes: 776
n=int(input())
List=list(map(int,input().split()))
# print(len(a),s,a[0])
k=0
while(True):
    # print(List)
    s=0
    t=n 
    c=False
    for i in range(0,n):
        if(not(c) and List[i]>0):
            s=i
            c=True
        elif(c and List[i]<=0):
            t=i
            break
    # print(s,t)
    if(not(c) and t==n):
        print(k)
        exit()
    for i in range(s,t):
        List[i]-=1
    k+=1



Measured memory_bytes: 3064
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        int size=1000000;
        long[] fact=new long[size];
        long[] inv=new long[size];
        fact[0]=1;
        inv[0]=1;
        long mod=1000000007;
        for (int i = 1; i < size; i++) {
            fact[i]=(fact[i-1]*i)%mod;
            inv[i]=power(fact[i],(int)mod-2)%mod;
        }
        //comb=fact[n]*inv[k]%mod*inv[n-k]%mod
        int n=sc.nextInt();
        int m=sc.nextInt();
        if(m==1){
            out.println(1);
        }else{
            HashMap<Integer,Integer> map=new HashMap<>();
            for (int i = 2; i <= m; i++) {
                while(m%i==0){
                    m/=i;
                    map.put(i,map.getOrDefault(i, 0)+1);
                }
            }
            long ans=1;
            for(int k:map.keySet()){
                ans=(ans*fact[n-1+map.get(k)]%mod*inv[n-1]%mod*inv[map.get(k)]%mod)%mod;
            }
            out.println(ans);
        }
      }
    static long power(long x,int n){
        long mod=1000000007;
        long ans=1;
        while (n>0) {
            if((n&1)==1){
                ans=(ans*x)%mod;
            }
            x=(x*x)%mod;
            n>>=1;
        }
        return ans;
    }
}


Measured memory_bytes: 40148
#include<stdio.h>
#include<math.h>

int isPrime(int a)
{
    int b=sqrt(a);
    for(int i=2;i<=b;i++)
    {
        if(a%i==0)return 0;
    }
    return 1;
}

int main()
{

    int n,m,count=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&m);
        count+=isPrime(m);
    }
    printf("%d\n",count);
    return 0;
}



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

const int N = 5e5;

void make_fail(string s, int *fal){
	int l = 0;
	for(int i=1;i<s.size();i++){
		if(s[i] == s[l]){
			fal[i] = ++l;
		} else {
			if(l == 0){
				fal[i] = 0;
			} else {
				l = fal[l-1];
				i--;
			}
		}
	}
}

bool cek(int id, int *fal){
	int pan = id;
	int tmp = pan - fal[id-1];
//	cout << tmp << " " << endl;
	return (pan%tmp != 0 || tmp==pan);
}

string s,s2;
int fal[N+5];
int fal2[N+5];

int main(){
	cin >> s;
	make_fail(s,fal);
//	cout << ">> " ;
//	for(int i=0;i<s.size();i++){
//		cout << fal[i] << " ";
//	}
//	cout << endl;
	int tmp = s.size() - fal[s.size()-1];
	if(s.size()%tmp!=0 || tmp == s.size()){
		printf("1\n1\n");
		return 0;
	}
	if(tmp == 1){
		printf("%d\n",s.size());
		printf("1\n");
		return 0;
	}
	s2 = s;
	reverse(s2.begin(),s2.end());
	make_fail(s2,fal2);
//	for(int i=0;i<s.size();i++){
//		cout << fal2[i] << " ";
//	}
//	cout << endl;
	int ans = 0;
	for(int i=1;i<s.size();i++){
//		cout << ">> " << i << endl;
		if(cek(i,fal) && cek(s.size()-i,fal2)) ans++;
	}
//	if(mult == 2) ans++;
	printf("2\n");
	printf("%d\n",ans);
	return 0;
}

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

typedef pair<int,int> PII;

int main(void){
  vector<PII> v;
  int n;
  
  cin >> n;
  for (int i=0; i<n; i++){
    int f,s;
    cin >> f >> s;
    v.push_back(make_pair(f,s));
  }
  sort(v.begin(), v.end());
  for (int i=0; i<n; i++){
    cout << v[i].first << " " << v[i].second << endl;
  }
  return 0;
}


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

#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define FORN(i, m, n) for(int (i) = (m); (i) <= (n); (i)++)
#define FORR(i, m, n) for(int (i) = (m); (i) >= (n); (i)--)
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> Vec;

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;
const ll MAX_N = 3000;
const ll MAX_T = 3000;

ll dp1[MAX_N+2][MAX_T] = {};
ll dp2[MAX_N+2][MAX_T] = {};

int main(void){
	ll n, t;
	cin >> n >> t;

	Vec a(n+1), b(n+1);
	repn(i, n) cin >> a[i] >> b[i];

	repn(i, n){
		rep(j, t){
			if(j >= a[i]) dp1[i][j] = max(dp1[i-1][j], dp1[i-1][j-a[i]]+b[i]);
			else dp1[i][j] = dp1[i-1][j];
		}
		
	}

	repnr(i, n){
		rep(j, t){
			if(j >= a[i]) dp2[i][j] = max(dp2[i+1][j], dp2[i+1][j-a[i]]+b[i]);
			else dp2[i][j] = dp2[i+1][j];
		}
	}

	ll ans = 0;
	repn(i, n){
		rep(j, t) ans = max(ans, dp1[i-1][j]+dp2[i+1][t-1-j]+b[i]);
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 140928
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int x = Integer.parseInt(in.next());
            int y = Integer.parseInt(in.next());
            int[][] check = {{1, 0}, {2, 2}, {3, 0}, {4, 1}, {5, 0}, {6, 1}, {7, 0}, {8, 0}, {9, 1}, {10, 0}, {11, 1}, {12, 0}};
            boolean ok = false;
            if (check[x - 1][1] == check[y - 1][1]) ok = true;

            out.println(ok ? "Yes" : "No");

        }

    }
}



Measured memory_bytes: 23252
/*
 * Author : Sadi
 * Fri 03/07/2020
 * 23:09:31.01
 */
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int n;
    cin >> n;
    vector<int> h(n);
    int x = 0;
    int total = 0;
    for(int i = 0; i < n; ++i) {
        cin >> h[i];
        if(x >= h[i]) {
            x = h[i];
        }
        else {
            total += h[i] - x;
            x = h[i];
        }
    }
    cout  << total << endl;
    return 0;
}


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

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx")

#define fi first
#define se second

using namespace std;

using ll=long long;
using ld=long double;

int main()
{
    int n,w;
    scanf("%d%d",&n,&w);
    vector<pair<int,int>> x(n);
    for(auto &i:x)
        scanf("%d%d",&i.fi,&i.se);
    const int m=1e5+1,inf=1e9+1;
    vector<int> dp(m,inf);
    dp[0]=0;
    for(auto &i:x)
        for(int j=m;j>=i.se;--j)
            dp[j]=min(dp[j],dp[j-i.se]+i.fi);
    int res=0;
    for(int i=0;i<m;++i)
        if(dp[i]<=w)
            res=i;
    printf("%d\n",res);
}



Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>

int main()
{
    double x1, y1, x2, y2;

    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    printf("%lf\n", sqrt(pow((x2-x1),2)+pow((y2-y1),2)));
    return 0;
}


Measured memory_bytes: 2048
def insertion_sort(A, n, g, count):
    for i in range(g, n):
        v = A[i]
        j = i - g

        while(j>=0 and A[j] > v):
            A[j+g] = A[j]
            j = j - g
            count += 1

        A[j+g] = v

    return count

def shell_sort(A, n):
    count = 0
    g = 1
    G = []

    while g <= n:
        G.insert(0, g)
        g = g*3 + 1

    print(len(G))
    print(' '.join(map(str, G)))

    for i in range(len(G)):
        count = insertion_sort(A, n, G[i], count)

    print(count)
    print('\n'.join(map(str, A)))

if __name__ == '__main__':
    n = int(input())
    A = [int(input()) for i in range(n)]

    shell_sort(A, n)

Measured memory_bytes: 127884
using System;
    class Program
    {
        static void Main(string[] args)
        {

        string[] input  = Console.ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int a = int.Parse(input[1]);
        int b = int.Parse(input[2]);
        int max; int min;

        if (a > b)
            max = b;
        else
            max = a;

        min = a + b - n;
        if (min < 0)
            min = 0;
        Console.WriteLine(max + " " + min);

    }
    }

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int a,b;
	std::cin >> a >>b;
	if((a+b) % 2) std::cout << (a + b) / 2 + 1 << std::endl;
	else std::cout << (a + b) / 2 << std::endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		
		// 計算
		String result = "No";
		if(s.charAt(0) == s.charAt(1) && s.charAt(1) == s.charAt(2)) result ="Yes";
		if(s.charAt(1) == s.charAt(2) && s.charAt(2) == s.charAt(3)) result ="Yes";
		
		// 出力
		System.out.println(result);
	}
}



Measured memory_bytes: 21972
# AGC 002: A – Range Product
a, b = [int(s) for s in input().split()]

if a > 0:
    print('Positive')
elif b < 0:
    if (b - a + 1) % 2 == 0:
        print('Positive')
    else:
        print('Negative')
elif a <= 0 <= b:
    print('Zero')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cstdio>
 
using namespace std;
using ll = long long;
 
#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
template<typename T>
inline T GET() {
	T val;
	cin >> val;
	return val;
}

void init();
void solve();

signed main()
{
    init();
    solve();
}

int N, K;
vector<bool> dp;
vector<int> a;

void init()
{
	cin >> N >> K;
	dp.RS(K+1, false);
	CINV(a, N);
}

void solve()
{
	reps(i, 1, K+1) {
		rep(j, N) {
			if (i < a[j]) continue;
			if (!dp[i-a[j]]) dp[i] = true;
		}
	}
	if (dp[K]) {
		cout << "First" << endl;
	} else {
		cout << "Second" << endl;
	}
}



Measured memory_bytes: 256
a, b = map(int, input().split())

if b-a >= 2019:
    print(0)
else:
    c = []
    for i in range(a,b):
        for j in range(i+1,b+1):
            c.append(i*j % 2019)
    #print(c)
    print(min(c))

Measured memory_bytes: 75332
S=input()
T=len(S)-1
count=0

for i in range(2**T):
  op=['']*T
  for j in range(T):
    if((i>>j)&1):
      op[T-1-j]='+'
        
  formula=''
  for a,b in zip(S,op+['']):
    formula+= (a+b)
  count+= eval(formula)
    
print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n; cin >> n;
  vector<int> x(n);
  for(int i = 0; i < n; i++){
    cin >> x[i];
  }
  int l, q; cin >> l >> q;

  static int dp[100001][40];
  for(int i = 0; i < n; i++){
    int pos = upper_bound(x.begin(),x.end(),x[i] + l) - x.begin() - 1;
    dp[i][0] = pos;
  }
  for(int k = 0; k < 30; k++){
    for(int i = 0; i < n; i++){
      dp[i][k+1] = dp[dp[i][k]][k];
    }
  }

  for(int i = 0; i < q; i++){
    int a, b; cin >> a >> b;
    a--, b--;
    if(a > b) swap(a, b);
    int ans = 0;
    for(int k = 30; k >= 0; k--){
      if(dp[a][k] < b){
        a = dp[a][k];
        ans += 1 << k;
        if(b <= a) break;
      }
    }
    cout << ans + 1 << endl;
  }
  return 0;
}


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

int main() {
  int a, b;
  int sum = 0;
  double num = 0;
  int cnt = 0;
  
  while(scanf("%d, %d", &a, &b) != EOF) {
    sum += a*b;
    num += b;
    cnt ++;
  }
  
  cout << sum << endl;
  printf("%.0f\n", (num/cnt)+0.5);
  return 0;
}

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

int main(){
  string s,t;cin>>s>>t;bool f=1;
  vector<vector<int>> x(26,vector<int>(26,0));
  vector<int> ss(26,0),tt(26,0);
  REP(i,s.size()) if(x.at(s.at(i)-'a').at(t.at(i)-'a')==0){
    x.at(s.at(i)-'a').at(t.at(i)-'a')++;
    ss.at(s.at(i)-'a')++;
    tt.at(t.at(i)-'a')++;
  }
  REP(i,26) if(ss.at(i)>1||tt.at(i)>1) f=0;
  cout<<(f?"Yes":"No");
}

Measured memory_bytes: 776
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>

typedef  long long ll;
#define mop 1000000007
#define mop2 998244353

using namespace std;

int main() {
	
	ll n;
	cin >> n;
	vector <ll> v(n+1, 0);
	for (ll i = 0; i < n - 1; i++) {
		ll tmp;
		cin >> tmp;
		v[tmp]++;
	}
	for (ll i = 1; i <= n; i++) {
		cout << v[i] << endl;
	}
	
}

Measured memory_bytes: 4840
// 6/2
// 2-6-3. 素数判定
// 類題
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;

bool is_prime(int n) {
    if (n == 1) return false;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

map<ll, ll> mp;
void prime_factor(ll n) {
    for(ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            n /= i;
            mp[i]++;
        }
    }
    if (n != 1) mp[n]++;
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
using ll = long long;
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
    combination comb(1e6);

    ll N, M;
    cin >> N >> M;

    prime_factor(M);

    mint ans = 1;

    for (auto p : mp) {
        // p.first : 素数の値
        // p.second : 個数（c）
        ans *= comb(p.second + N - 1, p.second);
    }

    cout << ans.x << endl;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int n;
  cin >> n;
  set<char> s;
  rep(i,n) {
    char c;
    cin >> c;
    s.insert(c);
  }
  if(sz(s) == 3) cout << "Three" << endl;
  if(sz(s) == 4) cout << "Four" << endl;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF   = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)

void solve()
{
    string S;
    cin >> S;
    REP0 (i, S.length())
    {
        if ((i + 1) % 2 == 1 and S[i] == 'L')
        {
            cout << "No" << endl;
            return;
        }
        if ((i + 1) % 2 == 0 and S[i] == 'R')
        {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
    return;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
/* This code was submitted by
  "Anand Dubey" on 
   18th January 2019
*/

#include <bits/stdc++.h> // Include every standard library 
using namespace std; 
  
typedef long long LL; 
typedef pair<int, int> pii; 
typedef pair<LL, LL> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<LL> vl; 
typedef vector<vl> vvl; 
  
double EPS = 1e-9; 
int INF = 1000000005; 
long long INFF = 1000000000000000005LL; 
double PI = acos(-1); 
int dirx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 }; 
int diry[8] = { 0, 1, -1, 0, -1, 1, -1, 1 }; 

#ifdef TESTING 
#define DEBUG fprintf(stderr, "====TESTING====\n") 
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl 
#define debug(...) fprintf(stderr, __VA_ARGS__) 
#else 
#define DEBUG 
#define VALUE(x) 
#define debug(...) 
#endif 
  
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a)) 
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a)) 
#define FORD(a, b, c) for (int(a) = (b); (a) >= (c); --(a)) 
#define FORSQ(a, b, c) for (int(a) = (b); (a) * (a) <= (c); ++(a)) 
#define FORC(a, b, c) for (char(a) = (b); (a) <= (c); ++(a)) 
#define FOREACH(a, b) for (auto&(a) : (b)) 
#define REP(i, n) FOR(i, 0, n) 
#define REPN(i, n) FORN(i, 1, n) 
#define MAX(a, b) a = max(a, b) 
#define MIN(a, b) a = min(a, b) 
#define SQR(x) ((LL)(x) * (x)) 
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back 
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define PERMUTE next_permutation 
#define TC(t) while (t--)  
#define g(str) getline(cin,str)  


inline string IntToString(LL a) 
{ 
    char x[100]; 
    sprintf(x, "%lld", a); 
    string s = x; 
    return s; 
} 
  
inline LL StringToInt(string a) 
{ 
    char x[100]; 
    LL res; 
    strcpy(x, a.c_str()); 
    sscanf(x, "%lld", &res); 
    return res; 
} 
  
inline string GetString(void) 
{ 
    char x[1000005]; 
    scanf("%s", x); 
    string s = x; 
    return s; 
} 
  
inline string uppercase(string s) 
{ 
    int n = SIZE(s); 
    REP(i, n) 
    if (s[i] >= 'a' && s[i] <= 'z') 
        s[i] = s[i] - 'a' + 'A'; 
    return s; 
} 
  
inline string lowercase(string s) 
{ 
    int n = SIZE(s); 
    REP(i, n) 
    if (s[i] >= 'A' && s[i] <= 'Z') 
        s[i] = s[i] - 'A' + 'a'; 
    return s; 
} 
  
inline void OPEN(string s) 
{ 
    
}

bool comp(int a, int b) 
{ 
    return (a < b); 
} 

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    
        LL h,w,n;
        cin>>h>>w>>n;
        int s=n/max(h,w);
        if(n%max(h,w)!=0)
            s++;
        cout<<s<<endl;  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
int main(){
	int a,b;
	cin>>a>>b;
	int sum=0;
	for(int i=0;i<b;i++){
		int x;
		cin>>x;
		sum+=x;
	}
	if(sum>=a)
	cout<<"Yes";
	else
	cout<<"No";
	
	
	
	
	return 0;
} 

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  int ans = 0;
  rep(i, n) REP(j, i + 1, n) ans += d[i] * d[j];
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void) {
	char s[100001] = { 0 }, x[50001] = { 0 };
	int len, i, j = 0;

	scanf("%s", &s);
	len = strlen(s);

	for (i = 0; i < len; i++) {
		if ((i + 1) % 2 == 1) x[j++] = s[i];
	}

	printf("%s\n", x);

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
bool check(string s){
	int l = (int)s.size();
	int half = l/2;
	string tmp1 = s;
	string tmp2 = s;
	tmp1.erase(0,half);
	tmp2.erase(half,l);
	return tmp1 == tmp2;
}
int main () {
	string s;
	cin >> s;
	while(true){
		s.erase((int)s.size()-1);
		if(check(s)){
			break;
		}
		
	}
	cout << (int)s.size() << endl;
}

Measured memory_bytes: 256
// 最適化
#pragma GCC target("avx")
#pragma GCC optimize("O3")

#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>

#define endl "\n"
#define ll long long
#define REP(i,a,b) for (int i = (a); i < (int)(b); ++i)
#define IN_NUMS_V(vec, N) REP(i, 0, N) cin >> vec.at(i); // 入力される複数の数値を vector に代入する
#define OUT_V(vec) REP(i, 0, vec.size()) cout << vec.at(i) << endl;
#define V_SORT(vec) sort(vec.begin(), vec.end())
#define V_REVERSE(vec) sort(vec.rbegin(), vec.rend())

using namespace std;

///////////// BEGIN_LIB //////////////////
void sayYes(bool f){ if (f) cout << "Yes" << endl; else cout << "No" << endl; } // print 'Yes' or 'No'
void sayYES(bool f){ if (f) cout << "YES" << endl; else cout << "NO" << endl; } // print 'YES' or 'NO'
int gcd(int a, int b){ if (a%b==0) return(b); else return(gcd(b,a%b)); }        // 最大公約数
int lcm(int a, int b){ return a*b/gcd(a,b); }                                   // 最小公倍数
int digitSum(int n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; }        // 各桁の和
bool isprime(ll n){                                                             // 素数判定
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;
    for (ll i = 3; i <= sqrt(n); i += 2){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}
///////////// END_LIB //////////////////

//////////// BEGIN_SOLVE ///////////////

void solve() {
    int N, D;
    cin >> N >> D;
    int count = 0;
    REP(i, 0, N) {
        ll x, y;
        cin >> x >> y;
        if (sqrt(x*x+y*y) <= D) count++;
    }
    cout << count << endl;
}

//////////// END_SOLVE ///////////////
int main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); solve(); return 0;}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
int prime[1000000];
int main(){
    fill_n(prime,1000000,1);
    prime[0]=prime[1]=0;

    for(int i=2;i<1000000;i++){
        prime[i]+=prime[i-1];
        if(prime[i]==prime[i-1])continue;
        for(int j=i+i;j<1000000;j+=i)prime[j]=0;
    }

    int n;
    while(scanf("%d",&n)!=EOF)printf("%d\n",prime[n]);

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define f first
#define s second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define SQ(a) (a)*(a)

int main(){

	int n;
	cin>>n;
	vector<int> a(n);
	int k;
	cin>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];


	sort(a.begin(),a.end());
	int gcd = a[0];
	for(int i=0;i<n;i++)
	{
		gcd = __gcd(a[i],gcd);
	}
	//cout<<gcd<<"\n";
	if(a[n-1] < k)
		cout<<"IMPOSSIBLE";
	else
	{
		if( k % gcd == 0)
			cout<<"POSSIBLE";
		else
			cout<<"IMPOSSIBLE";
	}
	return 0;
}


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

signed main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vector<int>b(n - 1);
	for (int i = 0; i < n - 1; i++)cin >> b[i];
	vector<int>a(n);
	a[0] = b[0]; a[n - 1] = b[n - 2];
	for (int i = 1; i < n - 1; i++) {
		if (b[i] < b[i - 1])a[i] = b[i];
		else a[i] = b[i - 1];
	}
	int ans = 0;
	for (auto now : a)ans += now;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007
const int dx[8] = {1, 0, -1, 0, -1, 1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0;i < n;i++)
        cin >> v[i];
    int now = 0;
    now = 1;
    for(int i = 1;i < n;i++)
    {
        now = v[now - 1];
        if(now == 2)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

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

int main(){
  char s;
  cin >> s;
  if(s == 'a' || s == 'i' || s == 'u' || s == 'e' || s == 'o') cout << "vowel" << endl;
  else cout << "consonant" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<char,LL> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<30;

vector<vector<int>> nextIndex(const string &s){
    int n = s.length();
    vector<vector<int>> ret(n+1,vector<int> (2,n));
    for (int i = n-1; i >= 0; i--) {
        for (int j = 0; j < 2; j++) ret[i][j] = ret[i+1][j]; 
        ret[i][s[i] - '0'] = i;
    }
    return ret;
}


int main(){
    string s,t;cin >> s >> t;
    auto p = nextIndex(s);
    auto q = nextIndex(t);
    int sn = s.length(),tn = t.length();
    vector<vector<int>> dp(sn+2,vector<int> (tn+2,INF));
    vector<vector<pair<char,pair<int,int>>>> recon(sn+2,vector<pair<char,pair<int,int>>>(tn+2,mp('0',mp(sn,tn))));
    dp[sn+1][tn+1] = 0;
    dp[sn][tn] = 1;
    for (int i = sn+1; i >= 0; i--) {
        for (int j = tn+1; j >= 0; j--) {
            if(i==sn+1&&j==tn+1) continue;
            for (int k = 0; k < 2; k++) {
                int ni,nj;
                if(i>=sn) ni = sn; else ni = p[i][k];
                if(j>=tn) nj = tn; else nj = q[j][k];
                if(dp[i][j] > dp[ni+1][nj+1]+1){
                    dp[i][j] = dp[ni+1][nj+1]+1;
                    recon[i][j] = mp('0'+k,mp(ni+1,nj+1));
                }
            }
        }
    }
    int i=0,j=0;
    string ans="";
    for (int k = 0; k < dp[0][0]; k++) {
        auto st = recon[i][j];
        ans += st.fs;
        i = st.sc.fs;
        j = st.sc.sc;
    }
    cout << ans << endl;
    return 0;
}



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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  string s; cin >> s;
  string t;
  rep(i, s.size()) t += s[s.size() - 1 - i];
  cout << t << '\n';
}



Measured memory_bytes: 2992
N = int(input())
P = list(map(int, input().split()))
c=0
for i in range(N-2):
    if P[i] < P[i+1] < P[i+2]:
        c += 1
    elif P[i] >  P[i+1] > P[i+2]:
        c+=1
print(c)

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

typedef long long ll;
typedef long double ld;
typedef double db;

ll S(ll x){
    ll d=1;
    ll ret=0;
    while(d<=x){
        ret+=(x%(d*10)-x%d)/d;
        d*=10;
    }
    return ret;
}
ll next(ll pred){
    if(pred==0) return 1;
    pred++;
    ll d=1;
    while(d<=pred){
        ll x = (pred%(d*10)-pred%d)/d;
        if(x!=9){
            if(pred*S(pred+(9-x)*d)>(pred+(9-x)*d)*S(pred)){
                pred=pred+(9-x)*d;
            }
        }
        d*=10;
    }
    return pred;
}

int main()
{
    //ios_base::sync_with_stdio(false);
    //cout<<setprecision(20);
    int k;
    cin>>k;
    ll x=0;
    for(int i=0;i<k;i++){
        x=next(x);
        cout<<x<<endl;
    }
    return 0;
}

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

using namespace std;
const int N = (int)(1e5 + 123);
const int INF = (int)(1e9 + 7);

int a[N] , b[N] , c[N];
int dp[N][3];
int main() {
	int n;
	cin >> n;
	for (int i=1; i<=n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	
	for (int i=1; i<=n; i++) {
		dp[i][0] = max(dp[i-1][1] , dp[i-1][2]) + a[i];
		dp[i][1] = max(dp[i-1][0] , dp[i-1][2]) + b[i];
		dp[i][2] = max(dp[i-1][0] , dp[i-1][1]) + c[i]; 		
	}
	
	cout <<max(dp[n][0] , max(dp[n][1] , dp[n][2]));
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<set>
using namespace std;
typedef unsigned int fox;
int b[10][2];
struct wolf{
	int s;
	int d;
	int c[8][2];
	wolf(){}
};
inline bool operator<(const wolf &a,const wolf &b){
	if(a.s+a.d!=b.s+b.d)return a.s+a.d>b.s+b.d;
	return false;
}
inline int ABS(int a){return max(a,-a);}
fox mul=1000000007;
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++){
			scanf("%d%d",&b[i][0],&b[i][1]);
			if(b[i][0]>b[i][1])swap(b[i][0],b[i][1]);
		}
		int n=a;
		priority_queue<wolf>Q;
		wolf st;
		for(int i=0;i<a;i++){
			st.c[i][0]=b[i][0];
			st.c[i][1]=b[i][1];
		}
		st.s=0;
		int sL=0;
		int sR=0;
		for(int i=0;i<a;i++){
			if(st.c[i][0]-1>i)sL+=st.c[i][0]-1-i;
			else sR+=i-st.c[i][0]+1;
			if(st.c[i][1]-1>i)sL+=st.c[i][1]-1-i;
			else sR+=i-st.c[i][1]+1;
		}
		bool big=true;
		for(int i=0;i<a;i++)if(!(st.c[i][0]+i==8&&st.c[i][1]+i==8))big=false;
		if(big){
			printf("40\n");continue;
		}
		int jk=sL+sR;
		jk=min(jk,41);
		st.d=max(sL,sR);
		Q.push(st);
		set<fox>S;
		fox goal=0;
		for(int i=0;i<n;i++){
			goal*=mul;
			goal+=i+1;
			goal*=mul;
			goal+=i+1;
		}
		int ret=9999999;
		while(Q.size()){
			if(Q.size()>100000){
				priority_queue<wolf> nq;
				for(int i=0;i<10000;i++){
					nq.push(Q.top());
					Q.pop();
				}
				Q=nq;continue;
			}
			wolf now=Q.top();
			Q.pop();
			
			fox key=0;
			for(int i=0;i<n;i++){
				key*=mul;
				key+=now.c[i][0];
				key*=mul;
				key+=now.c[i][1];
			}
			if(now.s+now.d>jk)continue;
			if(key==goal){
				printf("%d\n",now.s);
				break;
			}
			if(S.count(key))continue;
			S.insert(key);
			for(int i=0;i<n-1;i++){
				for(int j=0;j<2;j++)for(int k=0;k<2;k++){
					if(j&&now.c[i][j]==now.c[i][j-1])continue;
					if(k&&now.c[i+1][k]==now.c[i+1][k-1])continue;
					if(now.c[i][j]<=now.c[i+1][k])continue;
					wolf to=now;
					swap(to.c[i][j],to.c[i+1][k]);
					to.s=now.s+1;
					if(to.c[i][0]>to.c[i][1])swap(to.c[i][0],to.c[i][1]);
					if(to.c[i+1][0]>to.c[i+1][1])swap(to.c[i+1][0],to.c[i+1][1]);
					to.d=0;
					int tR=0;
					int tL=0;
					for(int l=0;l<n;l++){
						if(to.c[l][0]-1<l)tL+=l-to.c[l][0]+1;
						else tR+=to.c[l][0]-1-l;
						if(to.c[l][1]-1<l)tL+=l-to.c[l][1]+1;
						else tR+=to.c[l][1]-1-l;
					}
					to.d=max(tR,tL);
					jk=min(jk,tR+tL+to.s);
					//to.d=(to.d+1)/2;
					if(to.s+to.d<=jk)Q.push(to);
				}
			}
		}
	}
}

Measured memory_bytes: 17608
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)
// コンパイル　g++ -std=c++17 a.cpp

int main() {
    ll n;
    cin >> n;
    vector<ll> vec(n);
    rep(i, n){
        cin >> vec.at(i);
        vec.at(i)--;
    }

    //vector<ll> tmp(INF);
    map<ll, ll> map;
    rep(i,n){
        if(map.find(vec.at(i)) == map.end()){
            map[vec.at(i)]++;
        }else{
            cout << "NO" << endl;
            return 0;
        }


        /*

        if(tmp.at(vec.at(i)) == 0){
            tmp.at(vec.at(i))++;
        }else{
            cout << "NO" << endl;
            return 0;
        }
        */
    }

    cout << "YES" << endl;

}

Measured memory_bytes: 14336
#include <cstdio>
#include <vector>
using namespace std;
typedef long long ll;
int main()
{
	int a,b;
	vector<int>tanka,suryou;
	while(scanf("%d,%d",&a,&b)!=EOF)
	{
		tanka.push_back(a);
		suryou.push_back(b);
	}
	ll sum=0,s=0;
	double ave1;
	int ave;
	for(int i=0;i<tanka.size();i++)
	{
		sum += tanka[i]*suryou[i];
	}
	for(int i=0;i<suryou.size();i++)
	{
		s += suryou[i];
	}
	ave1 = (double)s/(double)(suryou.size());
	ave = (int)(ave1+0.5);
	printf("%lld\n",sum);
	printf("%d\n",ave);
	return 0;
}

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

inline int read()
{
	int ret=0; char c=getchar();
	while(c<48||c>57)c=getchar();
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}

int n,m,u,v,h[150][150];

int main()
{
	n=read(); m=read();
	u=1; v=1;
	--n; --m;
	
	for(int i=1; i<=n; ++i){
		h[u][v]=1;
		v+=2; if(v>100){
			u+=2;
			v-=100;
		}
	}
	
	for(int i=51; i<=100; ++i)
	for(int j=1; j<=100; ++j)h[i][j]=1ll;
	
	u=55; v=1;
	for(int i=1; i<=m; ++i){
		h[u][v]=0;
		v+=2; if(v>100){
			u+=2;
			v-=100;
		}
	}
	
	printf("%d %d\n",100,100);
	for(int i=1; i<=100; ++i){
		for(int j=1; j<=100; ++j)if(h[i][j])printf(".");
		else printf("#");
		puts("");
	}
}

Measured memory_bytes: 256
N = int(input())
lst = list(map(int, input().split()))
if 0 in lst:
  print(0)
else:
  ans = 1
  for i in lst:
    ans *= i
    if ans > 1000000000000000000:
      print(-1)
      ans = -1
      break
  if ans != -1:
    print(ans)


Measured memory_bytes: 21780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
//const ll mod=1e+9+7;
int main(void){
    char c;cin>>c;
    int x=c-'a';
    x++;
    char res=x+'a';
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>

std::string str;

int main()
{
    std::cin >> str;
    for (int i = 0; str[i]; ++i)
        for (int j = i + 1; str[j]; ++j)
            if (str[i] == 'C' && str[j] == 'F')
            {
                std::cout << "Yes" << std::endl;
                return 0;
            }
    std::cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
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);}
/*
 <url:https://atcoder.jp/contests/abc133/tasks/abc133_d>
 問題文============================================================
 =================================================================
 解説=============================================================
 
 山iに降った水の量を2*xiとすると

 ダムiについて　Ai = xi + x_{i+1} が成り立つ
 周期性を考えてxiについて解く
 
 2*xi = Ai - A_{i+1} + A_{i+2} - ..... + A_{i-1}
 
 となる。
 よって、ある山iについて降った水の量はO(N)で一意に求まる。
 
 残りのN-1の山についても解く必要があるが、これはAi = xi + x_{i+1}を用いることで
 隣り合う山の降った量についてO(1)で求まる。
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    vector<ll> ans(N);
    
    for(int i = 0; i < N;i++){
        ans[0] += i%2==0?A[i]:-A[i];
    }
    for(int i = 1; i < N; i++){
        ans[i] = 2*(A[i-1]-ans[i-1]/2);
    }
    res = ans;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<vector<ll>>() << endl;
    return 0;
}


Measured memory_bytes: 2560
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Item implements Comparable<Item> {
    int cost;
    int index;

    public Item(int cost, int index) {
        this.cost = cost;
        this.index = index;
    }

    @Override
    public int compareTo(Item other) {
        return Integer.compare(this.cost, other.cost);
    }

}

class Solver {

    private String buildKey(int x, int y) {
        StringBuilder sb = new StringBuilder();
        sb.append(x);
        sb.append(",");
        sb.append(y);
        return sb.toString();
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int M = sc.nextInt();

        List<Item> a = new ArrayList<>();
        for (int i = 0; i < A; i++) {
            a.add(new Item(sc.nextInt(), i));
        }
        List<Item> as = new ArrayList<>(a);
        Collections.sort(as);

        ArrayList<Item> b = new ArrayList<>();
        for (int i = 0; i < B; i++) {
            b.add(new Item(sc.nextInt(), i));
        }
        ArrayList<Item> bs = new ArrayList<>(b);
        Collections.sort(bs);

        Map<String, Integer> m = new HashMap<String, Integer>();
        for (int i = 0; i < M; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            int c = sc.nextInt();
           String key = buildKey(x, y);
            if (m.containsKey(key)) {
                int v = m.get(key);
                m.put(key, Math.max(v, c));
            } else {
                m.put(key, c);
            }
        }


        int minCost = as.get(0).cost + bs.get(0).cost;
        String minKey = buildKey(as.get(0).index, bs.get(0).index);
        if (m.containsKey(minKey)) {
            minCost = as.get(0).cost + bs.get(0).cost  - m.get(minKey);
        }

        for (Map.Entry e : m.entrySet()) {
            String k = (String) e.getKey();
            if (m.containsKey(k)) {
                String[] keys = k.split(",");
                int key1 = Integer.parseInt(keys[0]);
                int key2 = Integer.parseInt(keys[1]);
                int c1 = a.get(key1 - 1).cost;
                int c2 = b.get(key2 - 1).cost;
                minCost = Math.min(c1 + c2 - m.get(k), minCost);
            }
        }
        System.out.println(minCost);
        

        return;
    }

}


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

#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>

const int N = 3002;
int dp[N][N][2];
int a[N];
int n;

void solve()
{
   cin >> n;
    
   f(i,n) cin >> a[i];
    
   for(int i=1;i<=n;i++)
     for(int j=0;j<n-i+1;j++)
        for(int k=0;k<=1;k++)
          dp[i][j][k] = max(-dp[i-1][j][k^1]+a[j+i-1],-dp[i-1][j+1][k^1]+a[j]);  
       
   cout << dp[n][0][0] << '\n'; 
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 139648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

int main(){
  ll i,j;
  ll n;
  cin>>n;
  ll a[n];
  for(i=0;i<n;i++) cin>>a[i];
  vector<ll> v;
  for(j=0;j<2;j++){
    for(i=1;i*i<=a[j];i++){
      if(a[j]%i==0) {
        v.pb(i);
        v.pb(a[j]/i);
      }
    }
  }

  ll m=1;
  for(i=0;i<v.size();i++){
    ll f=0;
    for(j=0;j<n;j++){
      if(a[j]%v[i]!=0) {
        if(f==1) break;
        else f=1;
      }
      if(j==n-1) m=max(m,v[i]);
    }
  }
  cout<<m<<endl;
  return 0;
}

Measured memory_bytes: 1024