akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
//#include"Bignum/bignum.h"
//#define big bignum
#define lowbit(x) (x & -x)
#define debug(x) (cout << "#x = " << (x) << endl)
#define Set(x, i) memset (x, i, sizeof(x))
#define R register
#define For(i, j, k) for(R int i = (j); i <= (int) (k); ++i)
#define Rep(i, j, k) for(R int i = (j); i >= (int) (k); --i)
#define Cross(i, j, k) for(R int i = (j); i; i = (k))
using namespace std;
typedef long long ll;
const ll N = 100011;
const ll INF = 5e16;

namespace IO {

	inline char gc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return (p1 == p2) && (p2 = (p1 = buf) +
			fread(buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
	}

	#define dd ch = getchar()
	inline ll read() {
		R ll x = 0; R int f = 0; R char dd;
		for (; !isdigit(ch); dd) f ^= (ch == '-');
		for (; isdigit(ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write ( ll x ) {
		if (x < 0) x = -x, putchar('-');
		if (x > 9) write(x / 10); putchar(x % 10 | 48);
	}

	inline void wrn ( ll x ) { write(x), putchar(' '); }

	inline void wln ( ll x ) { write(x), putchar('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn(x), wln(y); }

}

using IO::wln;
using IO::read;

namespace Cesare {
	
	/*
		设 f[S] 表示选到第 i 个，钥匙状态为 S 的最小花费。
		f[S | St[i]] =  min(f[S | St[i]], f[S] + a[i])
		Ans = min(f[n][Max])
	*/
	
	const ll M = 2011;
	
	ll n, m, a[M], b[M], T[N], St[M], c[M][M], f[(1 << 12) + 1];
	
	int main() {
		n = read(), m = read();
		ll Max = (1 << n) - 1;
		For ( i, 1, m ) {
			a[i] = read(), b[i] = read();
			For ( j, 1, b[i] ) T[c[i][j] = read()] = 1;
			For ( j, 1, b[i] ) St[i] |= 1 << (c[i][j] - 1);
		} 
 		Set (f, 0x3f); f[0] = 0;
		For ( S, 0, Max ) For ( i, 1, m ) {
			f[S | St[i]] = min(f[S | St[i]], f[S] + a[i]);
		} return wln(f[Max] > INF? -1: f[Max]), 0;
	}
	
}

int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);

	return Cesare :: main();
}

/*

*/






Measured memory_bytes: 15232
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int r;
    cin >> r;
    double pi = atan2(0, -1);
    cout << fixed << setprecision(10) << 2.0 * r * pi;
    return 0;
}


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

int main(int argc, char **argv) {
  int N, X;
  int L;
  int sum = 0, cnt = 1;

  cin >> N >> X;

  for (int i = 0; i < N; i++) {
    cin >> L;
    sum += L;
    if (sum <= X)
      cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int ans;
string s;
int N,W,dp[111111][111],w[111111],v[111111];
signed main(){
	 cin>>N>>W;
	 rep(i,N)cin>>w[i]>>v[i];
	 for(int i=0;i<=W;i++){
	 	for(int j=0;j<N;j++){
	 		if(i>=w[j])dp[i][j+1]=max(dp[i][j],dp[i-w[j]][j]+v[j]);
	 		else dp[i][j+1]=max(dp[i][j],dp[i][j+1]);
	 	}
	 }
	 cout<<dp[W][N]<<endl;
}


Measured memory_bytes: 88576
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    long A = sc.nextLong();
    long B = sc.nextLong();
    long ans = 0;
    ans = func(A, B);
    System.out.println(ans);
  }
  
  static long func(long A, long B){
    if(A == B){
      return A;
    }
    if(A%2 == 1){
      return A^func(A+1, B);
    }
    
    if(B%2 == 0){
      return func(A, B-1)^B;
    }
    
    long C = (B-A+1)/2;
    return C%2 == 0 ? 0 : 1;
  }
}

Measured memory_bytes: 23124
#!/usr/bin/env python3
import sys

def main():
    N, K = map(int, input().split())
    d = [None] * K
    A = [[] for _ in range(K)]
    for i in range(K):
        d[i] = int(input())
        A[i] = list(map(int, input().split()))
    
    ans = [1] * N
    for i in range(K):
        for j in range(d[i]):
            ans[A[i][j]-1] = 0
    print(sum(ans))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9224
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a+2>=b){
      System.out.println(k+1);
      return;
    }
    int count = 0;
    long bis = 1l;
    while(a>bis){
      count++;
      bis++;
    }
    while(k-1>count){
      count+=2;
      bis += b-a;
    }

    while(k>count){
      count++;
      bis++;
    }
    System.out.println(bis);
  }
}


Measured memory_bytes: 35740
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
 *
 * @author mikit
 */
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);
        ABetweenTwoIntegers solver = new ABetweenTwoIntegers();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABetweenTwoIntegers {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();
            out.println(a <= c && c <= b ? "Yes" : "No");
        }

    }
}



Measured memory_bytes: 23380
# coding: utf-8
S = input()
ans = 0
P = 2019
N = len(S)
S = S[::-1]
dp = [0 for _ in range(N)]
d = {}
for i in range(N):
    dp[i] = int(S[i]) * pow(10, i, P) % P
for i in range(N-1):
    dp[i+1] += dp[i]
    dp[i+1] %= P
dp[-1] %= P
for i in range(N):
    if dp[i] not in d:
        if dp[i] == 0:
            ans += 1
        d[dp[i]] = 1
    else:
        if dp[i] == 0:
            ans += 1
        ans += d[dp[i]]
        d[dp[i]] += 1
print(ans)

Measured memory_bytes: 16716
import java.util.Scanner;

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

		int W = scan.nextInt();
		int H = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		int r = scan.nextInt();

		System.out.println((x >= r && x <= W-r) && (y >= r && y <= H-r) ? "Yes" : "No");
	}
}



Measured memory_bytes: 26312
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define fur(i,x,y) for(i=x;i<=y;i++)
#define fdr(i,x,y) for(i=x;i>=y;i--)
#define Fur(i,x,y) for(ll i=x;i<=y;i++)
#define Fdr(i,x,y) for(ll i=x;i>=y;i--)
#define in2(x,y) in(x);in(y)
#define in3(x,y,z) in2(x,y);in(z)
#define in4(a,b,c,d) in2(a,b);in2(c,d)
#define clr(x,y) memset(x,y,sizeof(x))
using namespace std;
/*---------------------------------------*/
namespace fib{char b[300000]= {},*f=b;}
#define gc ((*fib::f)?(*(fib ::f++)):(fgets(fib::b,sizeof(fib::b),stdin)?(fib::f=fib::b,*(fib::f++)):-1))
inline void in(ll &x){x=0;char c;bool f=0;while((c=gc)>'9'||c<'0')if(c=='-')f=!f;x=c-48;while((c=gc)<='9'&&c>='0')x=x*10+c-48;if(f)x=-x;}
namespace fob{char b[300000]= {},*f=b,*g=b+300000-2;}
#define pob (fwrite(fob::b,sizeof(char),fob::f-fob::b,stdout),fob::f=fob::b,0)
#define pc(x) (*(fob::f++)=(x),(fob::f==fob::g)?pob:0)
struct foce{~foce(){pob;fflush(stdout);}} _foce;
namespace ib{char b[100];}
inline void out(ll x){if(x==0){pc(48);return;}if(x<0){pc('-');x=-x;}char *s=ib::b;while(x) *(++s)=x%10,x/=10;while(s!=ib::b) pc((*(s--))+48);}
inline void outn(ll x){out(x);pc('\n');}
inline void swap(ll &x,ll &y){ll t=x;x=y;y=t;}
inline ll jdz(ll x){return x>=0?x:-x;}
/*------------------------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------------------------------*/
#define N 101
struct zb{ll x,y;}a[N],b[N];
bool v[N][N],u[N];
ll n,p[N],ans;
inline bool find(ll x){
	Fur(i,1,n)
	if(v[x][i]&&!u[i]){
		u[i]=1;
		if(!p[i]||find(p[i])){p[i]=x;return 1;}
	}
	return 0;
}
int main(){
	in(n);
	Fur(i,1,n){in2(a[i].x,a[i].y);}
	Fur(i,1,n){
		in2(b[i].x,b[i].y);
		Fur(j,1,n)if(a[j].x<b[i].x&&a[j].y<b[i].y)v[i][j]=1;
	}
	Fur(i,1,n){clr(u,0);if(find(i))ans++;}
	outn(ans);
}

/*

*/

Measured memory_bytes: 256
//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber
// 19 04 2020

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define    pi    acos(-1.0)

void task()
{
    int r;
    double ans;

    scanf("%d", &r);

    ans = 2*pi*r;
    cout << ans << endl;
}

int main()
{
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);

    //clock_t tStart = clock();

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    task();

    //printf("Time taken: %.3fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);

    return 0;
}



Measured memory_bytes: 3848
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e9+7;
typedef long long ll;
ll ksm(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1) ans=ans*a%maxn;
		b>>=1;
		a=a*a%maxn;
	}
	return ans;
}
ll niu(ll a,ll b)
{
	ll sns=1;
	ll ans=1;
	for(int i=0;i<b;i++)
	{
		ans=ans*(a-i)%maxn;
		sns=sns*(b-i)%maxn;
	}
	return ans*ksm(sns,maxn-2)%maxn;
}
int main()
{
	ll k,n;
	scanf("%lld%lld",&n,&k);
	ll cns;
	for(ll i=1;i<=k;i++)
	{
		cns=n-k+1;
		printf("%lld\n",niu(cns,i)*niu(k-1,i-1)%maxn);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>

using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vvi = vector<vi>;
const ll MOD = 1e9 + 7;


int main() {
	int N;
	string S;
	cin >> N >> S;
	int sum = 0;
	int countl = 0;
	rep(i, N) {
		if (S[i] == '(') sum++;
		else sum--;
		if (sum < 0) {
			countl++;
			sum++;
		}
	}
	if(sum>0){
		rep(i, sum) S = S + ")";
	}
	if (countl > 0) {
		rep(i, countl) S = "(" + S;
	}
	cout << S << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(114514)
N=int(input())
path=[[] for _ in range(N+1)]
for _ in range(N-1):
	a,b=map(int,input().split())
	path[a].append(b)
	path[b].append(a)
fenne=[-1 for _ in range(N+1)]
snuke=[-1 for _ in range(N+1)]
def walk(ar, i, d):
	if ar[i] == -1:
		ar[i] = d
		for x in path[i]:
			walk(ar, x, d+1)
walk(fenne, 1, 0)
walk(snuke, N, 0)
f,s=0,0
for i in range(1, N+1):
	if snuke[i] < fenne[i]:
		s+=1
	else:
		f+=1


print("Fennec" if f > s else "Snuke")


Measured memory_bytes: 117444
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

const ll mod = 1e9 + 7;
const ll IMF = 1LL<<29;
const double PI = 3.14159265358979323846;


      
int main(){

        int n,q;
        string s;

        cin >> n >> q;
        cin >> s;

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

        vector<int> sum(n+1,0);

        //累積和
        for(int i = 1; i < n; i++){
                if(s[i-1] == 'A' && s[i] == 'C'){
                        sum[i+1] = sum[i] + 1;
                }
                else sum[i+1] = sum[i];
        }

        for(int i = 0; i < q; i++){
                int ans = sum[r[i]] - sum[l[i]];
                cout << ans << endl;
        }
        return 0;
}



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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int dp[200000] = {};

void init(){
    rep(i, 200000) dp[i] = mod;
}

int rec(int N){
    if(N == 0) return dp[0] = 0;
    if(dp[N] != mod) return dp[N];
    int stand = __builtin_popcount(N);
    return dp[N] = 1 + rec(N%stand);
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    init();
    int N; cin >> N;
    string S; cin >> S;
    rep(i, 200000){
        rec(i);
    }
    int stand = 0;
    rep(i, N) if(S[i] == '1') stand++;
    int md[] = {stand-1, stand+1};
    int pow2[2][200000];
    pow2[0][0] = pow2[1][0] = 1;
    for(int i = 1; i < 200000; i++){
        if(stand >= 2) pow2[0][i] = pow2[0][i-1]*2 % md[0];
        pow2[1][i] = pow2[1][i-1]*2 % md[1];
    }
    int s1 = 0, s2 = 0;
    reverse(S.begin(), S.end());
    rep(i, N){
        if(stand >= 2) s1 = (s1 + pow2[0][i]*(S[i]-'0')) % md[0];
        s2 = (s2 + pow2[1][i]*(S[i]-'0')) % md[1];
    }

    vector<int> ans;
    rep(i, N){
        int temp;
        if(S[i] == '0'){
            temp = (s2 + pow2[1][i]) % md[1];
        }
        else if(stand >= 2){
            temp = (s1 - pow2[0][i]) % md[0];
            if(temp < 0) temp += md[0];
        }
        else{
            temp = -1;
        }
        ans.push_back(temp);
        //cout << temp << endl;
    }
    reverse(ans.begin(), ans.end());
    rep(i, N) {if(ans[i] != -1) cout << dp[ans[i]]+1 << endl; else cout << 0 << endl;}
    return 0;
}

Measured memory_bytes: 6748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[1005];
int b[1005];
int n,h;
int dp[100000005];
int main(){
	cin >> h >> n;
	int maxn=h;
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i];
		maxn=max(a[i],maxn);
	}
	memset(dp,0x3f,sizeof(dp));
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=1;j<=2*maxn;j++){
			if(a[i]>=j)
			dp[j]=min(dp[0]+b[i],dp[j]);
			else
			dp[j]=min(dp[j-a[i]]+b[i],dp[j]);
		}
	}
	int ans=0x3f3f3f3f;
	for(int i=h;i<=maxn;i++){
		ans=min(ans,dp[i]);
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 390912
import math

S = int(input())

sqrtS = math.ceil(math.sqrt(S))
rest = sqrtS*sqrtS - S

X1,Y1 = 0,0
X2,Y2 = sqrtS, 1
X3,Y3 = rest, sqrtS
print("{} {} {} {} {} {}".format(X1,Y1,X2,Y2,X3,Y3))



Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();

		if (Math.abs(x - a) < Math.abs(x - b)) {
			System.out.println("A");
		} else {
			System.out.println("B");
		}
	}

}


Measured memory_bytes: 21844
I=lambda:list(map(int,input().split()))
n=I()[0];arr=I();q=I()[0];
cnt={};
for i in arr:cnt[i]=0;
for i in arr:cnt[i]+=1;
s=sum(arr)
while(q):
  q-=1;b,c=I();
  if(b not in cnt or not cnt[b]):print(s);continue;
  s-=(cnt[b]*b);s+=(cnt[b]*c);
  if(c not in cnt):cnt[c]=0;
  cnt[c]+=cnt[b];cnt[b]=0;
  print(s)


Measured memory_bytes: 20640
class UnionFind:
    def __init__(self, elements):
        self.elements = {e: -1 for e in elements}

    def same(self, a, b):
        return self.find(a) == self.find(b)

    def find(self, a):
        parent = self.elements[a]
        if parent < 0:
            return a
        self.elements[a] = self.find(parent)
        return self.elements[a]

    def unite(self, a, b):
        a_parent = self.find(a)
        b_parent = self.find(b)

        # already same union
        if a_parent == b_parent:
            return

        self.elements[a_parent] += self.elements[b_parent]
        self.elements[b_parent] = a_parent


N, K, L = map(int, input().split())
road_union = UnionFind(i for i in range(1, N + 1))
for _ in range(K):
    a, b = map(int, input().split())
    road_union.unite(a, b)

train_union = UnionFind(i for i in range(1, N + 1))
for _ in range(L):
    a, b = map(int, input().split())
    train_union.unite(a, b)

ma = dict()
for i in range(N):
    p = (road_union.find(i + 1), train_union.find(i + 1))
    ma[p] = ma.get(p, 0) + 1

for i in range(N):
    p = (road_union.find(i + 1), train_union.find(i + 1))
    print(ma[p], end=' ')


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

int main() {
  int a, b, c, d, e;
  cin >> a >> b;
  if( a <= 5 ){
   c = 0;
    cout << c << endl;
  }
  else if( 6 <= a && a <= 12 ){
   d = b / 2;
    cout << d << endl;
  }
  else{
   e = b;
    cout << e << endl;
  }
}

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

int main() {
  std::string S;
  std::cin >> S;
  int max_count = 0;
  int count = 0;
  for (const auto c : S) {
    if (c == 'R') {
      max_count = std::max(max_count, ++count);
    } else {
      count = 0;
    }
  }
  std::cout << max_count << std::endl;
  return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
 int i,n;
 cin >> n;
 int a[n][3];
 for(i=0;i<n;i++)
 cin >> a[i][0] >> a[i][1] >> a[i][2];
 for(i=1;i<n;i++)
 {
  a[i][0]=a[i][0]+max(a[i-1][1],a[i-1][2]);
  a[i][1]=a[i][1]+max(a[i-1][0],a[i-1][2]);
  a[i][2]=a[i][2]+max(a[i-1][0],a[i-1][1]);
 }
 cout << max(a[n-1][0],max(a[n-1][1],a[n-1][2]));
 return 0;
}

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

using namespace std;

int main(){
    //奇数文字目がすべて R, U, D のいずれか。
    //偶数文字目がすべて L, U, D のいずれか。
    string s;
    cin>>s;
    string res="Yes";
    for(int i=0;i<(int)s.length();i++)
    {
        if((i%2==1&&s[i]=='R')||(i%2==0&&s[i]=='L')){
            res="No";
        }
    }
    cout<<res<<endl;
    return 0;
}

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

using namespace std;

int main() {
  int n,m,x;
  cin >> n >> m >> x;
  int a[m];
  
  int b[n];
  for(int i = 0; i < n; i++) {
    b[i] = 0;
  }

  for(int i = 0; i < m; i++) {
    cin >> a[i];
    b[a[i]] = 1;
  }
  int start = 0;
  int goal = 0;

  for(int i = 0; i < n; i++) {
    if(x < i) start += b[i];
    else goal += b[i];
  }
  cout << min(start, goal) << endl;
  return 0;
}

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

// Macros
#define F      first
#define S      second
#define PB     push_back
#define MP     make_pair
#define ALL(c) c.begin(),c.end()

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = std::pair <int,int>;

// Random
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
/* [a,b] */ template<class T> T rnd_IntType(T a, T b){ return uniform_int_distribution<T>(a, b)(rng); }
/* [a,b) */ template<class T> T rnd_RealType(T a, T b){ return uniform_real_distribution<T>(a,b)(rng); }

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m; ll y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// Output, Common Containers
template <typename T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream &os, const deque<T> &v) { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef LOCAL
	#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); d__f(_it, args); }
	void d__f(istream_iterator<string> it) {}
	template<typename Head, typename... Tail> void d__f(istream_iterator<string> it, Head H, Tail... T) { cerr << *it << " <=> [" << H << "]\n"; d__f(++it, T...); }
#else
	#define trace(args...)
#endif


// CODE STARTS HERE

const int mod = 998244353;

ll add(ll a, ll b) { return (a + b) % mod; }
ll sub(ll a, ll b) { return (a - b) % mod; }
ll mul(ll a, ll b) { return (a * b) % mod; }

signed main() {
	std::ios::sync_with_stdio(false); //Warning: Do NOT use C I/O now.
	std::cin.tie(nullptr); //Note: Comment out this line for interactive questions.
	// std::cout.setf(std::ios::fixed); std::cout.precision(20); //Note: To output decimals correctly.

	// int t; cin>>t;
	// for(int test_no = 1; test_no <= t; ++test_no){}

	int n,W;
	cin>>n>>W;

	vector<ll> w(n), v(n);
	for(int i=0; i<n; ++i) cin>>w[i]>>v[i];

	vector<vector<ll>> dp(n, vector<ll>(W+1, 0));
	dp[0][w[0]] = v[0];

	for(int i=1; i<n; ++i)
		for(int j=0; j<=W; ++j){
			dp[i][j] = max(dp[i][j], dp[i-1][j]);
			if(j+w[i] <= W) dp[i][j+w[i]] = max(dp[i][j+w[i]], dp[i-1][j]+v[i]);
		}

	cout<<*max_element(ALL(dp[n-1]));
}

Measured memory_bytes: 79488
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
#define INF ((1LL<<62LL) - 1)

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,a;
    cin >> n;
    set<int>se;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            a = n;
            while (a%i==0) {
                a /= i;
            }
            if (a % i == 1) {
                se.insert(i);
            }

            int b = n / i;
            a = n;
            while (a % b == 0) {
                a /= b;
            }
            if (a % b == 1) {
                se.insert(b);
            }
        }
    }
    se.insert(n);
    n--;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            se.insert(i);
            se.insert(n / i);
        }
    }
    se.insert(n);
    se.erase(1);
    cout << se.size() << endl;



}


Measured memory_bytes: 3688
/*  ***  In The Name of God ... ***  */
                                      /* Yani mishe mnm shakh sham ? ...  */
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define bug() cout << "BUG" << endl ;
#define X first
#define Y second
#define sz(x) (int)x.size()
#define per(how) cout << fixed << setprecision(how)
#define bit(a , b) (a >> b) & 1
#define all(v) v.begin() , v.end()
#define LB(x) (x & -x)
typedef long long ll;
typedef long double ld;
const ll INF = 1e18 , MOD = 1e9 + 7 , SQRT = 350 ;
inline void smin(ll &x , ll y) { x = min(x , y) ; }
inline void smax(ll &x , ll y) { x = max(x , y) ; }


ll a[3] ; 

int main ()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	for(ll i = 0 ; i < 3 ; i++)		cin >> a[i] ; 
	ll res = INF ; 
	for(ll i = 0 ; i < 3 ; i++)		for(ll j = i + 1 ; j < 3 ; j++)		smin(res , a[i] + a[j]) ; 
	cout << res << endl ; 
	return 0 ; 
}
// cout << endl + return 0 ; 



Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	string str; getline(cin,str);
	char ch; 
	for(int i=0;i<str.size();i++){
		ch=str[i];
		if(ch-3-'A'>=0 && ch-3-'Z'<=0) str[i]=ch-3;
		else str[i]=ch+23 ;
	};
	cout << str << '\n' ;
}

Measured memory_bytes: 1172
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <stack>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef map<int, int> Mii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

ll sum = 0;
ll d[11];
string s;

void calc(int n, ll st, ll t) 
{
	if (n==len(s)) {
		st += t;
		sum += st;
		return;
	}

	calc(n+1, st+t, d[n]);
	calc(n+1, st, t*10+d[n]);
}

int main()
{
	cin >> s;
	rep(i,0,len(s)) d[i] = s[i]-'0';
	calc(1,0,d[0]);
	cout << sum << endl;
	return 0;
}

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

bool cond2(string s) {
    int cnt = 0;
    for (int i = 2; i < s.size()-1; i++) {
        if (s[i] == 'C') cnt++;
    }
    if (cnt == 1) return true;
    else return false;
}

bool cond3(string s) {
    int cnt = 0;
    for (int i = 0; i < s.size(); i++) {
        if (islower(s[i])) {
            cnt++;
        }
    }
    if (cnt == s.size() - 2) return true;
    else return false;
}

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

    bool cond1 = S.front() == 'A';
    if (cond1 && cond2(S) && cond3(S)) {
        cout << "AC";
    } else {
        cout << "WA";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x;
	cin >> x;
      cout << x*800-int(x/15)*200 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include <vector>
#include<string>
#include<map>

using namespace std;

int a[110];

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

    for (int i = 0; i < k; i++) {
        int temp;
        cin >> temp;
        while (temp--) {
            int id;
            cin >> id;
            a[id - 1]++;
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == 0) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)

template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M,a,b;
    unordered_map<int, bool> mp1,mpN;
    cin >> N >> M;
    rep(i, M){
        cin>>a>>b;
        if(a==1){
            mp1[b] = true;
        }else if(b==1){
            mp1[a] = true;
        }else if(a==N){
            mpN[b] = true;
        }else if(b==N){
            mpN[a] = true;
        }
    }
    repp(i,1,200001){
        if(mp1[i]&&mpN[i]){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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 U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 N;
  string s;
  cin >> N >> s;
  int64 res = 1;
  FOR(i, 1, N) {
    if (s[i] != s[i-1]) res++;
  }
  cout << res << endl;
}


Measured memory_bytes: 892
#include <iostream>
#include <vector>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> ar(n);
	for (int i = 0; i < n; ++i) {
		cin >> ar[i];
	}
	int ans = 0;
	for (int i = 1; i < n; ++i) {
		if (ar[i] == i + 1 && ar[i - 1] == i) {
			swap(ar[i], ar[i - 1]);
			ans++;
		}
	}
	int add = 0;
	if (ar[0] == 1) {
		swap(ar[0], ar[1]);
		ans++;
		add = 1;
	}
	for (int i = 1 + add; i < n; ++i) {
		if (ar[i] == i + 1) {
			swap(ar[i], ar[i - 1]);
			ans++;
		}
	}
	cout << ans << endl;
}

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

int main() {
  int N, K, g = 0, ma = 0;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    int t; cin >> t;
    g = __gcd(g, t);
    ma = max(ma, t);
  }
  if (K % g == 0 && K <= ma) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
}

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

namespace Flow {
    struct Edge {
        int to, capacity, cost, reverse;
        Edge(int to, int capacity, int cost, int reverse) :
            to(to), capacity(capacity), cost(cost), reverse(reverse) {}
    };
    template <int MaxN> class PrimalDual {
        int n = MaxN;
        vector<Edge> g[MaxN];
    public:
        void clear(int n) {
            this->n = n;
            for (int i = 0; i < n; ++i)
                g[i].clear();
        }
        void push(int from, int to, int capacity = 1, int cost = 0) {
            g[from].emplace_back(to, capacity, cost, g[to].size());
            g[to].emplace_back(from, 0, -cost, g[from].size() - 1);
        }
        pair<int, int> flow(int s, int t, int f = 1 << 30) {
            int flow = f, cost = 0;
            static int prevv[MaxN], preve[MaxN], dist[MaxN], h[MaxN];
            fill(h, h + n, 0);
            while (flow > 0) {
                fill(dist, dist + n, 1 << 30);
                dist[s] = 0;
                using P = pair<int, int>;
                priority_queue<P, vector<P>, greater<P>> q;
                for (q.emplace(0, s); q.size(); ) {
                    auto p = q.top();
                    q.pop();
                    int v = p.second;
                    if (dist[v] < p.first) continue;
                    for (auto& e : g[v]) {
                        int d = dist[v] + e.cost + h[v] - h[e.to];
                        if (e.capacity > 0 && dist[e.to] > d) {
                            dist[e.to] = d;
                            prevv[e.to] = v;
                            preve[e.to] = &e - &g[v][0];
                            q.emplace(d, e.to);
                        }
                    }
                }
                if (dist[t] == 1 << 30) break;
                for (int v = 0; v < n; ++v)
                    h[v] += dist[v];
                int d = flow;
                for (int v = t; v != s; v = prevv[v])
                    d = min(d, g[prevv[v]][preve[v]].capacity);
                flow -= d;
                cost += d * h[t];
                for (int v = t; v != s; v = prevv[v]) {
                    auto& e = g[prevv[v]][preve[v]];
                    e.capacity -= d;
                    g[v][e.reverse].capacity += d;
                }
            }
            return { f - flow, cost };
        }
    };
}

int main() {
    int n, m;
    cin >> n >> m;
    Flow::PrimalDual<100> pd;
    pd.clear(n);
    for (int i = 0; i < m; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        pd.push(a, b, c);
    }
    cout << pd.flow(0, n - 1).first << endl;
    return 0;
}

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

const int MAXN = 1000 + 10, P = 1e9 + 7;

char str[MAXN];
int n, m, mp[MAXN][MAXN], f[MAXN][MAXN];

void add(int& a, int b) { a = (a + b) > P ? a + b - P : a + b; }

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; ++i) {
        scanf("%s", str + 1);
        for (int j = 1; j <= m; ++j) {
            mp[i][j] = (str[j] == '.');
        }
    }
    f[0][1] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (mp[i][j] == 0) f[i][j] = 0;
            else {
                add(f[i][j], f[i - 1][j]), add(f[i][j], f[i][j - 1]);
            }
        }
    }
    printf("%d\n", f[n][m]);
    return 0;
}

Measured memory_bytes: 8192
#include <iostream>



#define REP(i, n) for (long long i = 0; i < (n); i++) 
#define ll long long

using namespace std;

int main(){
    ll N,M,X,Y;
    string res;


    cin >> N >> M >> X >> Y;

    ll yMin = 9999;
    ll xMax = -9999;
    ll tmp;

    REP(i,N)
    {
        cin >> tmp;
        xMax = max(xMax,tmp);
    }
    REP(i,M)
    {
        cin >> tmp;
        yMin = min(yMin,tmp);
    }

    res = "War";

    for(ll Z = -100; Z <= 100; Z++)
    {
        if(X < Z && Z <= Y && xMax < Z && Z <= yMin)res = "No War";
    }

    cout << res << endl;
}




Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons;
import std.math, std.numeric;
import core.bitop;

void main() {
    int n; scan(n);
    auto a = readln.split.to!(int[]);

    auto ans = new long[](n);
    ans[] = a.dup.to!(long[]);

    auto st = Stack!(int)(n);

    foreach (i ; 0 .. n) {
        while (!st.empty && a[st.front] > a[i]) {
            st.removeFront();
        }
        if (st.empty) {
            ans[i] *= i + 1;
        }
        else {
            ans[i] *= (i - st.front);
        }
        st.insert(i);
    }

    debug {
        writeln(ans);
    }

    st.clear();

    foreach_reverse (i ; 0 .. n) {
        while (!st.empty && a[st.front] > a[i]) {
            st.removeFront();
        }
        if (st.empty) {
            ans[i] *= (n - i);
        }
        else {
            ans[i] *= (st.front - i);
        }
        st.insert(i);
    }

    writeln(ans.sum());
}



struct Stack(T) {
    private {
        size_t cap, top;
        T[] data;
    }

    this (int n) in {
        assert(n > 0, "The capacity of a stack must be a positive integer.");
    }
    body {
        cap = n;
        data = new T[](cap);
    }

    void clear() {
        top = 0;
    }

    bool empty() {
        return !top;
    }

    bool full() {
        return top == cap;
    }

    size_t length() {
        return top;
    }

    T front() in {
        assert(!empty, "The stack is empty.");
    }
    body {
        return data[top - 1];
    }

    void removeFront() in {
        assert(!empty, "The stack is empty.");
    }
    body {
        top--;
    }

    alias popFront = removeFront;

    void insertFront(T x) in {
        assert(!full, "The stack is full.");
    }
    body {
        data[top++] = x;
    }

    alias insert = insertFront;

    T[] array() {
        import std.algorithm.mutation : reverse;

        T[] arr = data[0 .. cap].dup;
        arr.reverse();
        return arr;
    }

    string toString() {
        import std.format : format;
        import std.range : retro;

        return format("[%(%s, %)]", data[0 .. top].retro());
    }
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

#define ll long long
#define endl '\n'

using namespace std;

int main() {
    int n, m, sum = 0;

    cin >> n >> m;
    ll v[n];

    for(int i = 0; i < m; i++) {
        cin >> v[i];
        sum += v[i];
    }

    sum = n - sum;

    if(sum < -1) {
        cout << -1 << endl;
    }

    else {
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll INF = (1LL<<58);

int n;
vector<pair<int,ll>> adj[100005];
ll d[100005];

void dijkstra(){
    priority_queue<pair<ll, int>> PQ;
    bool visited[n+1];
 
    for(int i=0; i<n+1; i++){
        visited[i] = false;
        d[i] = INF;
    }
 
    PQ.push({0, 1});
    d[1] = 0;
 
    while(!PQ.empty()){
 
        pair<ll, ll> p = PQ.top(); PQ.pop();
        ll u = p.second;
 
        visited[u] = true;
 
        //if(d[u] < p.first * (-1)) continue;
         
        for(int i=0; i<adj[u].size(); i++){
            ll v = adj[u][i].first;
            if(visited[v] == false && d[v] > d[u] + adj[u][i].second){
                d[v] = d[u] + adj[u][i].second;
                PQ.push({d[v] * (-1), v});
            }
        }
    }
 
    
 
}
 
int main(void){
    cin >> n;
    for(int i=0; i<n-1; i++){
        int u,v; cin >> u >> v;
        ll w; cin >> w;
        adj[u].push_back({v, w});
        adj[v].push_back({u, w});
    }
 
    dijkstra();

    for(int i=1; i<=n; i++){
        if(d[i]%2 == 0) cout << 0 << endl;
        else cout << 1 << endl;
    }

    //for(int i=1; i<=n; i++) cout << d[i] << endl;
}


Measured memory_bytes: 8832
#include<iostream>

using namespace std;

int main(){
    long int l, r;
    cin >> l >> r;
    if (r - l + 1 >= 2019) {
        cout << 0 << endl;
        return 0;
    }
    long int ans = 2020;
    for(long int i = l; i < r; i++){
        for(long int j = i + 1; j <= r; j++){
            long int mul = i * j;
            mul %= 2019;
            if (mul < ans) {
                ans = mul;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vl> mat;
//#define sort(a) sort(a.begin(),a.end())
//#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define ft first
#define sd second
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mp make_pair
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
ll INF = 1e14;

struct edge{ ll from, to, cost;};

edge es[2010];
ll d[1010];
bool avail[1010];
ll N,M;

int main(){
    cin>>N>>M;
    fr(i,M){
        ll a,b,c;cin>>a>>b>>c;
        es[i] = {a,b,-c};
    }
    fr(i,N)d[i] = INF;
    d[0] = 0;
    fr(loop,N-1){
        fr(i,M){
            if(d[es[i].from-1]==INF)continue;
            if(d[es[i].to-1] > d[es[i].from-1]+es[i].cost){
                d[es[i].to-1] = d[es[i].from-1] + es[i].cost;
            }
        }
    }
    ll ans = -d[N-1];
    
    fr(i,N)avail[i]=false;

    fr(loop,N){
        fr(i,M){
            if(d[es[i].from-1]==INF)continue;
            if(d[es[i].to-1] > d[es[i].from-1] + es[i].cost){
                d[es[i].to-1] = d[es[i].from-1] + es[i].cost;
                avail[es[i].to-1] = true;
            }
            if(avail[es[i].from-1] == true)avail[es[i].to-1] = true;
        }
    }
    if(avail[N-1])cout << "inf"<<endl;
    else cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fr(a,b) for(ll i = a; i < b; i++)
#define inf (1LL<<60)
using namespace std;

struct line
{
    ll slope;
    ll intercept;
    line(ll sp, ll intr)
    {
        slope = sp;
        intercept = intr;
    }
    ll valueAtX(ll X)
    {
        return slope*X + intercept;
    }
    ll x_intersect(line l2)
    {
       return ceil((1.0*l2.intercept - intercept)/(slope - l2.slope));
    }
};

class CHT
{
    deque<pair<line,ll>> dq;
public:
    void insert(line l1, ll next_hi)
    {
        if(next_hi == -1)
            return;
        if(dq.empty())
        {
                dq.push_back({l1, 0});
                return;
        }
        ll x0 = l1.x_intersect(dq.back().first);
        while(!dq.empty() && x0 <= dq.back().second){
            dq.pop_back();
            if(!dq.empty())
                x0 = l1.x_intersect(dq.back().first);
        }
        dq.push_back({l1,x0});
    }
    ll query(ll hi)
    {
        while(dq.size() > 1)
        {
            if(dq[1].second<=hi)
                dq.pop_front();
            else break;
        }
        return dq.front().first.valueAtX(hi);
    }
};

int main(){
    int n;
    ll c;
    cin >> n>>c;
    vector<ll> v(n);
    vector<ll> dp(n);
    CHT sol;

    fr(0,n)
        cin >> v[i];

    dp[0] = 0;
    sol.insert({-2*v[0], dp[0] + v[0]*v[0] + c}, v[1]);

    fr(1,n)
    {
        dp[i] = v[i]*v[i] + sol.query(v[i]);
        sol.insert({-2*v[i], dp[i] + v[i]*v[i] + c}, (i + 1 < n) ? v[i+1] : -1);
    }
    cout << dp[n-1];
    return 0;
}


Measured memory_bytes: 6656
#
# File    : B.rb
# Author  : Kazune Takahashi
# Created : 12/7/2018, 10:06:45 PM
# Powered by Visual Studio Code
#

n, k = gets.chomp.split(" ").map{|i| i.to_i}
puts k * (k - 1) ** (n - 1)


Measured memory_bytes: 1788
n, h, d = map(int, input().split())
MOD = 10 ** 9 + 7


fact = [1] * (n + 1)
for i in range(n):
    fact[i + 1] = fact[i] * (i + 1)
    fact[i + 1] %= MOD

# fact_sum = fact[1] + fact[2] + ... + fact[n]
fact_sum = 0
for i in range(1, n + 1):
    fact_sum += fact[i]
    fact_sum %= MOD

dp = [0] * (h + 1)
ru = [0] * (h + 2)
dp[0] = 1
ru[1] = 1
for i in range(h):
    l = max(i + 1 - d, 0)
    dp[i + 1] += (ru[i + 1] - ru[l]) * fact_sum
    dp[i + 1] %= MOD
    ru[i + 2] = ru[i + 1] + dp[i + 1]
    ru[i + 2] %= MOD

print((dp[-1] * fact[n] * pow(fact_sum, MOD - 2, MOD)) % MOD)

Measured memory_bytes: 90440
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>

using namespace std; using ll=long long; const int INF=1e9;
typedef pair<int,int> P;

int main() {
  ll a,b,n; cin>>a>>b>>n;
  ll x=min(n, b-1);
  cout<<(a*x/b) - a*(x/b)<<endl;
}

Measured memory_bytes: 3636
//ID:computerbox --> Hajiyev Huseyn
#include <bits/stdc++.h>
#define FAST_READ ios_base::sync_with_stdio(false);
#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define COUT(n, a) cout<< fixed << setprecision(a) << n<<endl
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";
#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
#define DTIME(ccc) __begin = clock(); ccc; cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<endl;
#define MAXN 200010

using namespace std;

ll n,massiv[MAXN];
ll cnt=0;
int main(){
FAST_READ;
cin>>n;
for(ll i=1;i<=n;i++)
{
	cin>>massiv[i];
}

for(ll i=1;i<=n;i++)
{
	if(massiv[i]==i)
	 {
	 	swap(massiv[i],massiv[i+1]);
	 	cnt++;
	 }
}

cout<<cnt<<endl;



return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  int d, t, s;
  cin >> d >> t >> s;

  cout << (d <= t * s ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 3604
s = input()
t = input()

used = []
res = []
for i in range(len(s)):
    if s[i] not in used:
        used.append(s[i])
    res.append(used.index(s[i]))
used = []
ret = []
for i in range(len(t)):
    if t[i] not in used:
        used.append(t[i])
    ret.append(used.index(t[i]))
if res == ret:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 6832
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int sen=0,num,page[1000][100]={},nu[1000]={};
    memset(nu,0,sizeof(nu));
    string str[1000],s;
    while(cin>>s>>num){
        for(int i=0;i<sen;i++){
            if(str[i]==s){
                nu[i]++;
                page[i][nu[i]]=num;
                num=0;
                break;
            }
        }
        if(num!=0){
            str[sen]=s;
            page[sen][0]=num;
            sen++;
        }
    }
    for(int i=0;i<sen;i++){
        for(int j=0;j<sen;j++)if(str[num]>str[j])num=j;
        cout<<str[num]<<endl;
        str[num]=123;
        for(int j=0;j<nu[num];j++){
            for(int k=nu[num];k>j;k--){
                if(page[num][k]<page[num][k-1]){
                    int kawa=page[num][k-1];
                    page[num][k-1]=page[num][k];
                    page[num][k]=kawa;
                }
            }
        }
        cout<<page[num][0];
        for(int j=1;j<=nu[num];j++)cout<<" "<<page[num][j];
        cout<<endl;
    }
}

Measured memory_bytes: 1624
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, j , k) for(int i = j; i < k; j++)

using namespace std;

int main(){
	int N;
	cin >> N;
	vector<int> L(N);
	rep(i, N) {
		cin >> L.at(i);
	}

	int count = 0;
	
	sort(L.begin(), L.end());
	
	rep(i, N-2){
		for(int j = i+1; j < N-1; j++){
			if(L.at(i) == L.at(j)) continue;
			for(int k = j+1; k < N; k++){
				if(L.at(i) == L.at(k) || L.at(j) == L.at(k)) continue;
				if(L.at(i) + L.at(j) > L.at(k)) count++;
			}
		}
	}
	
	cout << count << endl;


}

Measured memory_bytes: 3628