akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
#define f(i,a,b) for(int i=a;i<b;i++)
#define fll(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define vvi vector<vector<int> >
#define ss second
#define ff first
#define ll long long
#define lld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pq priority_queue< int >
#define pqll priority_queue< ll >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define INF 1000000000
#define NINF -1000000000

vvi edges(2e5);
vector <bool> visited(2e5);
vector <int> ans(2e5 , -1);

void bfs(int a ){

    list <int> queue;
    visited[a] = true;
    queue.pb(a);
    while(! queue.empty()){
        a = queue.front();
        queue.pop_front();
        // cout << -a << endl;
        for (auto i : edges[a]){
            if (!visited[i]){
                ans[i] = a;
                visited[i] = true;
                queue.pb(i);
            }
        }
    }
}

void solve(){
    // cout << 123 << endl;
    int n , m;
    cin >> n >> m;
    int a , b;
    // cout << 0 << endl;
    f( i , 0 , m){
        cin >> a >> b;
        a-- , b--;
        edges[a].pb(b);
        edges[b].pb(a);
    }
    // cout << -1 << endl;
    bfs( 0);
    // cout << -2 << endl;
    int flag = 0;
    for (int i = 1 ; i < n ; i++){
        if (ans[i] == -1)
        {
            flag = 1;
            break;
        }
    }
    // cout << -3 << endl;
    if (flag == 1){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
        for (int i = 1 ; i < n ; i++){
            cout << ans[i]+1 << endl;
        }
    }
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);

    int t = 1;
    // cin >> t;
    // cout << "hehe" << endl;
    while(t--){    
        solve();
    }
}

Measured memory_bytes: 15680
#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;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


struct edge{int to;ll cap;int rev;};
struct Dinic{
private:
    int n;
    vector<vector<edge>> v;
    vector<int> dist,iter;
public:
    Dinic(int sz):n(sz),v(sz),dist(sz),iter(sz){}
    
    void addedge(int from,int to,ll cap){
        int x=v[to].size(),y=v[from].size();
        v[from].push_back({to,cap,x});
        v[to].push_back({from,0,y});
    }
    
    void bfs(int s){
        fill(dist.begin(),dist.end(),-1);
        queue<int> q;
        dist[s]=0;
        q.push(s);
        while(q.size()){
            int x=q.front();q.pop();
            rep(i,v[x].size()){
                edge &e=v[x][i];
                if(e.cap>0&&dist[e.to]<0){
                    dist[e.to]=dist[x]+1;
                    q.push(e.to);
                }
            }
        }
    }
    
    ll dfs(int x,int t,ll f){
        if(x==t)return f;
        for(int& i=iter[x];i<(int)v[x].size();++i){
            edge& e=v[x][i];
            if(e.cap>0&&dist[x]<dist[e.to]){
                ll d=dfs(e.to,t,min(f,e.cap));
                if(d>0){
                    e.cap-=d;
                    v[e.to][e.rev].cap+=d;
                    return d;
                }
            }
        }
        return 0;
    }

    ll max_flow(int s,int t){
        ll flow=0;
        while(1){
            bfs(s);
            if(dist[t]<0)return flow;
            fill(iter.begin(),iter.end(),0);
            ll f;
            while((f=dfs(s,t,1LL<<62))>0)flow+=f;
        }
    }
};
int main(){
    int n;
    cin>>n;
    int p[n], q[n];
    rep(i,n)cin>>p[i];
    rep(i,n)cin>>q[i];
    vector<int> a(n,-1), b(n,-1);
    int id1 = 0, id2 = 0;
    rep(j,n){
        int i = j;
        if(a[i]!=-1)continue;
        a[i]=id1;
        while(a[p[i]]==-1){
            a[p[i]]=id1;
            i=p[i];
        }
        ++id1;
    }
    rep(j,n){
        int i = j;
        if(b[i]!=-1)continue;
        b[i]=id2;
        while(b[q[i]]==-1){
            b[q[i]]=id2;
            i=q[i];
        }
        ++id2;
    }
    Dinic dn(id1+id2+2);
    int s = id1+id2, t = id1+id2+1;
    rep(i,n){
        //dn.addedge(a[i],t,1);
        //dn.addedge(s,id1+b[i],1);
        if(i==q[i]){
            dn.addedge(id1+b[i], t, 1);
        }
        if(i==p[i]){
            dn.addedge(s,a[i], 1);
        }
        dn.addedge(a[i],id1+b[i],1);
        if(p[i]==q[i]){
            dn.addedge(id1+b[i], a[i], 1);
        }
    }
    cout<<n-dn.max_flow(s, t)<<endl;
    return 0;
}


Measured memory_bytes: 16128
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 1e5 + 50;
const int INF = 1e9;

int w[MAXN], val[MAXN];
int dp[150][MAXN];
int cap, n;

int solve(int id, int restou)
{
	if(id == n or restou < 0) return 0;
	if(dp[id][restou] != -1) return dp[id][restou];
	
	int ans = solve(id+1, restou);
	if(restou - w[id] >= 0)
	{
		int esc = solve(id+1, restou - w[id]);
		return dp[id][restou] = max(ans, esc+val[id]);
	}
	
	return dp[id][restou] = ans;
}



int32_t main()
{
	cin >> n >> cap;
	for(int i = 0; i < n; i++)
		cin >> w[i] >> val[i];
	memset(dp, -1, sizeof dp);
	cout << solve(0, cap) << '\n';
}

Measured memory_bytes: 119040
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int mod = 1e9 + 7;

int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    bool f = 0;
    for (int i = a; i <= a * b;i++){
        if(i%a==0&&i%b==c)
            f = 1;
    }
    cout << (f ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Applicative

-- 1 bubbleSort(A, N) // N 個の要素を含む 0-オリジンの配列 A
-- 2   flag = 1 // 逆の隣接要素が存在する
-- 3   while flag
-- 4     flag = 0
-- 5     for j が N-1 から 1 まで
-- 6       if A[j] < A[j-1]
-- 7         A[j] と A[j-1] を交換
-- 8         flag = 1

bubbleSort :: [Int] -> ([Int], Int)
bubbleSort xs = loop (1, 0, xs)
  where
    loop (0, count, xs) = (xs, count)
    loop (1, count, xs) = loop $ foldr f (0, count, xs) [0 .. length xs - 2]
    f i (flag, count, xs)
      | b > c     = (1, count + 1, as ++ c : b : ds)
      | otherwise = (flag, count, xs)
      where (as, b : c : ds) = splitAt i xs

main :: IO ()
main = do
  _  <- getLine
  xs <- map read . words <$> getLine
  let (ys, c) = bubbleSort xs
  putStrLn $ unwords $ map show ys
  print c



Measured memory_bytes: 4728
def main():
    buf = input()
    N = int(buf)
    x = []
    y = []
    h = []
    for i in range(N):
        buf = input()
        buflist = buf.split()
        x.append(int(buflist[0]))
        y.append(int(buflist[1]))
        h.append(int(buflist[2]))
    x = [z for _, z in sorted(zip(h,x), key=lambda pair: pair[0])][::-1]
    y = [z for _, z in sorted(zip(h,y), key=lambda pair: pair[0])][::-1]
    h = sorted(h)[::-1]
    for cx in range(101):
        for cy in range(101):
            H = h[0] + dist(cx, cy, x[0], y[0])
            correct = True
            for i in range(1, N):
                if h[i] + dist(cx, cy, x[i], y[i]) != H:
                    if dist(cx, cy, x[i], y[i]) <= H:
                        correct = False
                        break
                    else:
                        if h[i] != 0:
                            correct = False
                            break
            if correct == True:
                print(cx, cy, H)
                return


def dist(x1, y1, x2, y2):
    return abs(x1 - x2) + abs(y1 - y2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e3 + 7;
char lst[Max][Max];
int ls[Max][Max];

int main()
{
	ll n;
	cin >> n;
	ll a = 2, b = 1;
	for (int i = 1; i <= n ; i++)
	{
		ll t = b;
		b = a + b;
		a = t;
	}
	cout << a;

}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std ;
int main(){
    int A,B;
    cin >> A >> B;
    long int An=A,Bn=B;
    while(1){
        if(A<B)swap(A,B);
        if(!B)break;
        A%=B;
    }
    if(A==1){
        long int Ans = An*Bn;
        cout << Ans << endl;
    }else{
        long int Ans = An*(Bn/A);
        cout << Ans << endl;
    }
}

Measured memory_bytes: 3584
package main

import (
	"bufio"
	"fmt"
	"os"
	// "sort"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)
var rdr = bufio.NewReaderSize(os.Stdin, 0x100000)
var wtr = bufio.NewWriter(os.Stdout)

// SplitSpace 空白で分割設定
func SplitSpace() {
	scanner.Split(bufio.ScanWords)
}

// NextLine 標準入力から１行読み込む
func NextLine() string {
	scanner.Scan()
	return scanner.Text()
}

// NextInt 標準入力から数値を一つ読み込む
func NextInt() int {
	n, _ := strconv.Atoi(NextLine())
	return n
}

// ReadLine 標準入力から長めの1行を読み込む
func ReadLine() string {
	buf := make([]byte, 0, 0x100000)
	for {
		line, isPrefix, err := rdr.ReadLine()
		if err != nil {
			panic(err)
		}
		buf = append(buf, line...)
		if !isPrefix {
			break
		}
	}
	return string(buf)
}

func Abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func Min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func ChMin(a *int, b int) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}

func ChMax(a *int, b int) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}

//================

func main() {
	SplitSpace()
	N := NextInt()
	W := NextInt()
	w := make([]int, N)
	v := make([]int, N)
	dp := make([][]int, N+1)
	for i := 0; i < N; i++ {
		w[i] = NextInt()
		v[i] = NextInt()
		dp[i] = make([]int, W+1)
	}
	dp[N] = make([]int, W+1)

	for i := 0; i < N; i++ {
		for sw := 0; sw <= W; sw++ {
			if sw-w[i] >= 0 {
				ChMax(&dp[i+1][sw], dp[i][sw-w[i]]+v[i])
			}
			ChMax(&dp[i+1][sw], dp[i][sw])
		}
	}
	fmt.Println(dp[N][W])
}


Measured memory_bytes: 81792
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
const int inf = 100000000;
int i,j;
const int maxn = 35; ////100005
char str1[maxn];
char str2[maxn];
char str[maxn];

int getmid(char str[], int begin, int end)
{
	int left = 0;
	int right = 0;
	for (i = begin; i < end; i++)
	{
		if (str[i] == '(')
		{
			left++;
		}
		else if (str[i] == ')')
		{
			right++;
		}
		if (left == right+1 && str[i] == ',')
		{
			break;
		}
	}
	return i;
}

int insert(int begin1, int end1, int begin2, int end2, int begin)
{
	if (begin1 >= end1 || begin2 >= end2)
	{
		return begin;
	}
	str[begin] = '(';    ///qian
	int mid1 = getmid(str1, begin1, end1);
	int mid2 = getmid(str2, begin2, end2);
	int stop1 = insert(begin1+1, mid1, begin2+1, mid2, begin+1);
	str[stop1] = ',';    ///zhong
	int stop2 = insert(mid1+1, end1-1, mid2+1, end2-1, stop1+1);
	str[stop2] = ')';    ///hou
	return stop2+1;
}

void insert()
{
	int len1 = strlen(str1);
	int len2 = strlen(str2);
	int end = insert(0, len1, 0, len2, 0);
	str[end] = '\0';
}

int merge(int begin1, int end1, int begin2, int end2, int begin)
{
	if (begin1 >= end1)
	{
		for (i = 0; i < end2-begin2; i++)
		{
			str[begin+i] = str2[begin2+i];
		}
		return begin+i;
	}
	if (begin2 >= end2)
	{
		for (i = 0; i < end1-begin1; i++)
		{
			str[begin+i] = str1[begin1+i];
		}
		return begin+i;
	}
	str[begin] = '(';    ///qian
	int mid1 = getmid(str1, begin1, end1);
	int mid2 = getmid(str2, begin2, end2);
	int stop1 = merge(begin1+1, mid1, begin2+1, mid2, begin+1);
	str[stop1] = ',';    ///zhong
	int stop2 = merge(mid1+1, end1-1, mid2+1, end2-1, stop1+1);
	str[stop2] = ')';    ///hou
	return stop2+1;
}

void merge()
{
	int len1 = strlen(str1);
	int len2 = strlen(str2);
	int end = merge(0, len1, 0, len2, 0);
	str[end] = '\0';
}

int main()
{
	char sstr[10];
	while (cin >> sstr >> str1 >> str2)
	{
		if (sstr[0] == 'i')
		{
			insert();
		}
		else
		{
			merge();
		}
		cout << str << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


int main(){
  int i=0;
  int x[100];
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      x[i-2]=x[i-2]+x[i-1];
      i--;
    } else if ( s[0] == '-' ){
      x[i-2]=x[i-2]-x[i-1];
      i--;
    } else if ( s[0] == '*' ){
      x[i-2]=x[i-2]*x[i-1];
      i--;
      } else {
      x[i] = atoi(s);
      i++;
    }
    
  }
  printf("%d\n",x[0]);

  return 0;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
LL dp[321123];

int main(){

    // 1. 入力情報取得.
    int M;
    LL K;
    scanf("%d %lld", &M, &K);
    
    // 2. 数列作成(K >= 2 の M乗).
    int l = 1 << M; // 数列の長さ.
    // sample_02 で, WA となったので, if文 を 修正.
    // if(K >= l){
    if(K >= l || (M == 1 && K == 1)){
        printf("%d\n", -1);
        return 0;
    }
    
    // 3. 数列作成(K < 2 の M乗).
    int base = l - 1, counter = 0;
    // 3-1. K == 0
    // ex.
    // M = 2, K = 0
    // 0 0 -> 1 0 0 1 -> 2 1 0 0 1 2 -> 3 2 1 0 0 1 2 3 とすれば良さそう.
    if(K == 0){
        dp[base] = K, dp[base + 1] = K;
        for(int i = 0; i < l; i++) if(i != K) counter++, dp[base - counter] = dp[base + 1 + counter] = i;
    }
    
    // 3-2. K > 0
    // M = 2, K = 1
    // 1 -> 0 1 0 -> 2 0 1 0 2 -> 3 2 0 1 0 2 3 -> 3 2 0 1 0 2 3 1 とすれば良さそう.
    // 
    // M = 2, K = 2
    // 2 -> 0 2 0 -> 1 0 2 0 1 -> 3 1 0 2 0 1 3 -> 3 1 0 2 0 1 3 2 とすれば良さそう.
    // 
    // M = 2, K = 3
    // 3 -> 0 3 0 -> 1 0 3 0 1 -> 2 1 0 3 0 1 2 -> 2 1 0 3 0 1 2 3 とすれば良さそう.
    if(K > 0){
        dp[base] = K, dp[2 * base + 1] = K;
        for(int i = 0; i < l; i++) if(i != K) counter++, dp[base - counter] = dp[base + counter] = i;
    }
    
    // 3. 後処理.
    for(int i = 0; i < 2 * l; i++) printf("%lld ", dp[i]);
    return 0;

}

Measured memory_bytes: 3968
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

manzoku = 0
last = [-1]*26

for day in range(D):
    t = int(input())-1
    manzoku += S[day][t]
    last[t] = day
    for i in range(26):
        manzoku -= C[i]*(day-last[i])
    print(manzoku)

Measured memory_bytes: 9276
import java.util.Scanner;
public class Main {
      
	public static void main(String[] args) {
	 Scanner sc = new Scanner (System.in);
	 int n = sc.nextInt();  int y = sc.nextInt();
	 sc.close();
	        for(int j =0; j<=y/5000;j++) {
	        	for(int i =0; i<=y/10000; i++)  {
   		       
   			 int a = i;   int b = j;    int c= n-i-j;       
    	if(10000*a+5000*b+1000*c==y&&a>=0&&b>=0&&c>=0) {
    			System.out.println(a+" "+b+" "+c);
    			System.exit(0);}
    		}
      }
     System.out.println("-1 -1 -1");
        
	 }
}


Measured memory_bytes: 23764
abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
H, W = map(int, input().split())
S = [[] for i in range(H)]
for i in range(H):
    S[i] = list(input().split())
    
for i in range(H):
    for j in range(W):
        if S[i][j] == "snuke":
            print(abc[j] + str(i + 1))
            break

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

int main() {
	int c[3][3];
	int a, b;
	for (a = 0; a < 3; ++a)
		for (b = 0; b < 3; ++b)
			cin >> c[a][b];

	bool flag = true;
	for (a = 0; a < 2; ++a)
		for (b = 0; b < 2; ++b)
			if (c[a][b] - c[a][b + 1] != c[a + 1][b] - c[a + 1][b + 1])
				flag = false;

	cout << (flag ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3128
import sys


def input(): return sys.stdin.readline().strip()


def main():
    S = input()
    if S == 'Sunny':
        ans = 'Cloudy'
    elif S == 'Cloudy':
        ans = 'Rainy'
    else:
        ans = 'Sunny'

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
takeSeq _ [] = []
takeSeq n (x:xs) = if x == n + 1 then x:(takeSeq x xs) else []
dropSeq _ [] = []
dropSeq n (x:xs) = if x == n + 1 then (dropSeq x xs) else (x:xs)

sq :: [Int] -> [[Int]]
sq [] = []
sq (x:xs) = 
    let a = x:(takeSeq x xs)
        r = dropSeq x xs
    in
        a:(sq r)

pt s = unwords $ map (\a -> if 1 == length a
                            then show $ head a
                            else (show $ head a) ++ "-" ++ (show $ last a) ) s

ans' x = 
    let s = sq x
        p = pt s
    in
        p

ans ([0]:_) = []
ans (_:x:xs) =
    let a = ans' x
    in
        a:(ans xs)

main = do
    c <- getContents
    let i = map (map read) $ map words $ lines c :: [[Int]]
        o = ans i
    mapM_ putStrLn o



Measured memory_bytes: 4268
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func main() {
    sc.Split(bufio.ScanWords)
    r := nextInt() * 100
    g := nextInt() * 10
    b := nextInt()

    if (r + g + b) % 4 ==0{
        fmt.Println("YES")
    }else{
        fmt.Println("NO")
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int n;
  cin>>n;
  vector<int> A(n+2);
  A[0]=0;
  rep(i,n) cin>>A[i+1];
  A[n+1]=0;
  vector<int> lsums(n+2);
  lsums[0]=0;
  rep(i,n+1) lsums[i+1]=lsums[i]+abs(A[i+1]-A[i]);
  reverse(A.begin(),A.end());
  vector<int> rsums(n+2);
  rsums[0]=0;
  rep(i,n+1) rsums[i+1]=rsums[i]+abs(A[i+1]-A[i]);
  reverse(A.begin(),A.end());
  
  rep(i,n){
    int ans=0;
    ans+=lsums[i];
    ans+=rsums[n-i-1];
    ans+=abs(A[i]-A[i+2]);
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#include "unistd.h"
using namespace std;
#define WA cout<<"char134217728";exit(0)
#define RE throw
#define TLE sleep(1000)
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end());
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 60;
int a[] = {0,2,5,5,4,5,6,3,7,6};
V<int> v;
V<pii> vv;
int n, m;
lll DP[N];
V<char> ans;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  FOR(i, 0, m){
    int b;
    cin >> b;
    v.pb(b);
    vv.pb(mp(a[b], -b));
  }
  sort(all(vv));
  Fill(DP, -1);
  DP[0] = 0;
  FOR(i, 1, N) for(int b:v) if(a[b]<=i && DP[i-a[b]]>=0) maxs(DP[i], DP[i-a[b]]*10 + b);
  while(n >= N){
    ans.pb('0' +(-vv[0].se));
    n -= vv[0].fi;
  }
  while(DP[n]){
    ans.pb('0' + DP[n]%10);
    DP[n] /= 10;
  }
  sort(all(ans));
  reverse(all(ans));
  for(char c:ans) cout << c;
  cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int i,n,big=-1000000,little=1000000;
	long long int sum=0;
	cin>>i;
	for(;i>0;i--){
		cin>>n;
		sum+=n;
		if(n>big){
			big=n;
		}
		if(n<little){
			little=n;
		}
	}
	cout<<little<<' '<<big<<' '<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1160
/*
          ,     \    /      ,
         / \    )\__/(     / \
        /   \  (_\  /_)   /   \
   ____/_____\__\@  @/___/_____\____
  |             |\../|              |
  |              \VV/               |
  |        ------hoi-------         |
  |_________________________________|
   |    /\ /      \\       \ /\    |
   |  /   V        ))       V   \  |
   |/     `       //        '     \|
   `              V                '
*/

#include <bits/stdc++.h>

#define ld long double
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define f first
#define se second
#define Speedforce boost();
#define fop(s1, s2) freopen(s1, "r", stdin);freopen(s2, "w", stdout);

using namespace std;

void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const int N = 1e6;
const ll inf = 1e9 + 9;
const ld PI = acos(-1);

ll bin_pow(ll x, ll y){
    ll res = 1, base = x;
    while(y){
        if(y & 1){
            res *= base;
            res %= inf;
        }
        base *= base;
        base %= inf;
        y /= 2;
    }
    return res;
}

string s, t;

int main(){
    Speedforce
    //fop("", "")
    cin >> s >> t;
    cout << (s[0] == t[0]) + (s[1] == t[1]) + (s[2] == t[2]);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,n;
  cin>>x>>n;
  vector<int> k(n);
  vector<bool> a(1000,true);
  for(int i=0;i<n;i++){
    cin>>k[i];
    k[i]--;
    a[k[i]]=false;
  }
  int p=0,q=0;
  for(int i=x-1;i<1000;i++){
    if(a[i]){
      p=i+1;
      break;
    }
  }
  for(int i=x-1;i>=0;i--){
    if(a[i]){
      q=i+1;
      break;
    }
  }
  if(p-x>=x-q){
    cout<<q<<endl;
  }else{
    cout<<p<<endl;
  }
  return 0;
}

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

ll f(ll a, ll b, ll x) {
    return a*x/b - a * (ll)(x/b);
}

int main(void){
    ll a, b, n;
    cin >> a >> b >> n;
    cout << f(a,b,min(b-1,n)) << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <regex>
#include <cmath>

using namespace std;

int main() {
    int a, b, c, d, ab, cd;
    cin >> a >> b >> c >> d;
    ab = a*b;
    cd = c*d;

    if(ab > cd){
        cout << ab << endl;
    } else if(cd > ab){
        cout << cd << endl;
    } else {
        cout << ab << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
using ull = unsigned long long;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  int q; cin >> q;
  bitset<64> bit(0uLL);
  for (int i = 0; i < q; ++i) {
    int op; cin >> op;
    if (op == 0) {
      int pos; cin >> pos;
      cout << (int) bit.test(pos) << '\n';
    } else if (op == 1) {
      int pos; cin >> pos;
      bit.set(pos);
    } else if (op == 2) {
      int pos; cin >> pos;
      bit.reset(pos);
    } else if (op == 3) {
      int pos; cin >> pos;
      bit.flip(pos);
    } else if (op == 4) {
      cout << (int) bit.all() << '\n';
    } else if (op == 5) {
      cout << (int) bit.any() << '\n';
    } else if (op == 6) {
      cout << (int) bit.none() << '\n';
    } else if (op == 7) {
      ull x = bit.to_ullong();
      cout << __builtin_popcountll(x) << '\n';
      //cout << bit.count() << '\n';
    } else if (op == 8) {
      ull x = bit.to_ullong();
      cout << x << '\n';
    }
  }

  return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	// debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, left, right)  (a).begin()+(left),(a).begin()+(right)	// left to (right-1)


int main() {
	int n;
	cin >> n;
	vector<int> time(n);
	map<string, int> idx;
	FOR(i, 0, n-1) {
		string s;
		cin >> s;
		int t;
		cin >> t;
		idx[s] = i;
		time[i] = t;
	}
	string x;
	cin >> x;
	int res=0;
	int start = idx[x] + 1;
	FOR(i, start, n - 1) {
		res += time[i];
	}
	pv(res)
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <stdio.h>
#include <algorithm>
//#include <string>
//#include <math.h>
//#include <vector>

using namespace std;

int main() {
  int N;
  long int A[100000];

  int i;
  int nseq=1; 
  int ud;
  
  cin >> N; 
  
  for(i=0; i<N; i++){
    scanf("%ld",&A[i]);
  }

  ud = 0; 
  for(i=0; i<N-1; i++){
    if(ud == 0){
      while(A[i]==A[i+1]){
	i++;
      }      
      if(A[i]<A[i+1]) ud = 1;
      else ud = -1;
    }else if(ud == 1 && A[i]>A[i+1]){nseq++; ud = 0;}
    else if(ud == -1 && A[i]<A[i+1]){nseq++; ud = 0;}    
  }

  cout << nseq;
  
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  string s;
  cin >> s;
  if((s.size() % 2 == 0) ^ (s[0] == s[s.size()-1]))
    cout << "Second" << endl;
  else
    cout << "First" << endl;
  return 0;
}



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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int prime[1000000];
bool is_prime[1000001];

int sieve(int n)
{
	int p = 0;
	rep(i, 0, n + 1)is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;
	rep(i, 2, n + 1)
	{
		if (is_prime[i])
		{
			prime[p++] = i;
			for (int j = i + i; j <= n; j += i)is_prime[j] = false;
		}
	}
	return p;
}

bool flag[100010];
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, K, R, S, P;
	string T;
	cin >> N >> K >> R >> S >> P >> T;
	map<char, int> smap;
	smap['r'] = P;
	smap['s'] = R;
	smap['p'] = S;

	int ans = 0;
	rep(i, 0, SZ(T))
	{
		if (i >= K)
		{
			if (T[i] != T[i - K] || !flag[i - K])
			{
				ans += smap[T[i]];
				flag[i] = true;
			}
		}
		else
		{
			ans += smap[T[i]];
			flag[i] = true;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}

int D;
int N = 26;
vi c;
vvi s;
vi ans;
vi las;



pii rec(int n, int dd, vi lass){
    
    if(dd >= D || n == 5) return {0,1};
    
    int los = 0;
    rep(i,N) los += c[i]*(dd-lass[i]);
    int res = -infi;
    int an = 1;
    set<int> sss;
    ve<pii> AA(N);
    rep(i,N) AA[i] = {s[dd][i],i};
    sort(all(AA));
    rep(i,7) sss.insert(AA[N-i-1].se);
    
    
    rep(i,N){
        if(!sss.count(i)) continue;
        vi la = lass;
        int ddd = s[dd][i]-los+c[i]*(dd-lass[i]);
        la[i] = dd;
        int da = ddd+rec(n+1,dd+1,la).fi;
        if(chmax(res,da)) an = i+1;
        
    }
    
    return {res,an};
    
}



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

    //int ti = clock();
    
    
    cin >> D;
    c.resize(N);
    s.resize(D, vi(N));
    
    in(N,c);
    rep(i,D) rep(j,N) cin >> s[i][j];
    
    ans.resize(D);
    las.assign(N,-1);
    
    
    
    
    
    rep(d,D){
        ans[d] = rec(0,d,las).se;
        las[ans[d]-1] = d;
    }









    
    
    
    rep(i,D) cout << ans[i] << endl;
    
    
    //printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);

    return 0;
}


Measured memory_bytes: 3684
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) 
{
	cout << *it << " = " << a;
	nl;
	err(++it, args...);
}
typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}
const int mod=1e9+7;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
ll binpow(ll a, ll b, ll m) 
{a %= m;b%=(m-1);ll res = 1;while (b > 0) {if (b & 1)res = res * a % m;a = a * a % m;b >>= 1; }return res;}
void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,c,temp,x,y;
string str;
ll factorial[1000000+1];
#define MAXN 3*100000
long long binomial_coefficient(int n, int k) {
    return (factorial[n] * modInverse(factorial[k]) % m)%m * modInverse(factorial[n - k]) % m;
}
void solveforthiscase(const int & test)
{//deb(test);
cin>>n;
ll k;
cin>>k;
ll ans=0;
if(k>n-1)
k=n-1;
factorial[0] = 1;
m=mod;
for (int i = 1; i <= MAXN; i++) {
    factorial[i] = factorial[i - 1] * i % m;
}
if(k>1)
{ans++;ans%=mod;}
for(int i=1;i<=k;i++)
{
  ans=(ans+(binomial_coefficient(n-1,n-i-1)%m*binomial_coefficient(n,i)%m)%m)%m;  
}
cout<<ans;
return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    int N;
    bool result = false;
    
    cin >> N;
    
    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            if(N == i*j){
                result = true;
            }
        }
    }
    
    if(result){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

const int MAXN = 2*100000;
vector<int> bit(MAXN+1);

int sum(int i) {
  int s = 0;
  while (i > 0) {
    s += bit.at(i);
    i -= i & -i;
  }
  return s;
}

void add(int i, int x) {
  while (i <= MAXN) {
    bit.at(i) += x;
    i += i & -i;
  }
}

void reset() {
  for(int i=0; i<=MAXN; i++) {
    bit.at(i) = 0;
  }
}

int main() {
  ll n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  rep(i, n) {
    cin >> a.at(i);
    b.at(i) = a.at(i);
  }

  sort(b.begin(), b.end());

  ll total = n*(n+1)/2;
  ll th = total/2;
  if (total%2 == 1) {
    th++;
  }

  int mi = 0;
  int ma = n-1;
  vector<int> c(n);
  while (mi < ma) {
    int pos = (mi+ma+1)/2;
    int now = b.at(pos);

    rep(i, n) {
      if (a.at(i) < now) {
        c.at(i) = -1;
      } else {
        c.at(i) = 1;
      }
    }
    for(int i=1; i<n; i++) {
      c.at(i) += c.at(i-1);
    }
    ll ans = 0;
    add(n, 1);
    rep(i, n) {
      c.at(i) += n;
      ans += sum(c.at(i));
      add(c.at(i), 1);
    }

    reset();

    if (ans >= th) {
      mi = pos;
    } else {
      ma = pos-1;
    }
  }
  cout << b.at(mi) << endl;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define long long long
#define read cin >>
#define echo cout <<
#define fin << endl
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)

// for debug macro
bool global_debug_flag = false;
#define DEBUG(val) \
  if (global_debug_flag) cout << #val << " = " << val << endl

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  string s = "No";
  if ((x == y && y != z && x != z) || (y == z && y != x && z != x) ||
      (x == z && x != y && z != y)) {
    s = "Yes";
  }
  cout << s << endl;
}


Measured memory_bytes: 256
S = input()
K = int(input())
if(S[0]!='1'):
  print(S[0])
else:
  i=0
  while(S[i]=='1'):
    i += 1
    if(i==len(S)):
      break
  if(K<=i):
    print('1')
  else:
    print(S[i])

Measured memory_bytes: 3060
#include<set>
#include<map>
#include<ctime>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
    int f=1,x=0;char s=getchar();   
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
#define MAXN 10
#define INF 0x3f3f3f3f
char Map[MAXN+5][MAXN+5];
int main(){
	int h=read(),w=read(),cnt=0;
	for(int i=1;i<=h;i++){
		scanf("%s",Map[i]+1);
		for(int j=1;j<=w;j++)
			if(Map[i][j]=='#')
				cnt++;
	}
	if(cnt!=h+w-1){
		puts("Impossible");
		return 0;
	}
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			if(Map[i][j]=='#'&&Map[i+1][j-1]=='#'){
				puts("Impossible");
				return 0;
			}
	puts("Possible");
	return 0;
}

Measured memory_bytes: 256
S = input()
S_odd = S[::2]
S_even = S[1::2]

cond = True
for s in S_odd:
    if s not in ['R', 'U', 'D']:
        cond = False
        
for s in S_even:
    if s not in ['L', 'U', 'D']:
        cond = False

print('Yes' if cond else 'No')

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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> cities(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        cities[a - 1]++;
        cities[b - 1]++;
    }
    for (int i = 0; i < n; i++) {
        cout << cities[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
X, K, D = map(int, input().split())
y = abs(X)//D
if y >= K:
  ans = abs(X) - K * D
elif (K - y)%2 == 1:
  ans = abs(abs(X) - y * D - D)
else:
  ans = abs(abs(X) - y * D)
print(ans)

Measured memory_bytes: 9088
#include <iostream>

using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    if (A != B && B == C) {
        cout << A << endl;
    } else if (A == C && A != B) {
        cout << B << endl;
    } else if (A == B && B != C) {
        cout << C << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

int v = 2505,e;
vector<vector<pair<ll,ll>>> graph(v,vector<pair<ll,ll>>());
vector<ll> shortest(v,INF);

//ベルマンフォードもし負の閉路があったらfalseをかえす
bool bellmanford(ll start){
    shortest[start] = 0;
    int cnt = 0;
    while(1){
        bool update = false;
        bool goal = false;
        for(int i=0;i<v;i++){
            if(shortest[i] == INF) continue;
            for(pair<ll,ll> edge:graph[i]){
                if(shortest[edge.second] > shortest[i] + edge.first){
                    if(cnt < v) shortest[edge.second] = shortest[i] + edge.first;
                    else shortest[edge.second] = -INF;
                    update = true;
                    if(edge.second == v-1){
                        goal = true;
                    }
                }
            }
        }
        if(!update) break;
        cnt ++;
        if(cnt >= v && goal){
            return false;
        }
        if(cnt > 2*v + 2*e + 10){
            return true;
        }
    }
    return true;
}

int main(){
    int p;
    cin >> v >> e >> p;
    rep(i,e){
        int a,b,c;
        cin >> a >> b >> c;
        --a;--b;
        graph[a].push_back(pll(p-c,b));
    }

    //cout << v << endl;

    if(!bellmanford(0)){
        cout << -1 << endl;
    }else{
        if(shortest[v-1] > 0) cout << 0 << endl;
        else cout << -shortest[v-1] << endl;
    }

    //rep(i,v) cout << canreach[i] << " " ;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a; i<=b; ++i)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
using vl=vector<ll>;
using vp=vector<pll>;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin>>n;
    ll ans=0;
    FOR(a,1,n) ans+=(n-1)/a;
    cout<<ans;
    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int c = 0;
  int nplace = 0;

  while (c <= n) {
    c++;
    if (a[nplace] == 2) {
      cout << c << endl;
      return 0;
    }
    nplace = a[nplace] - 1;
  }
  cout << -1 << endl;
}


Measured memory_bytes: 640
#include<stdio.h>

int A[7],B[7],i;
int G[55][6]={
	{1,2,3},{1,3,5},{1,5,4},{1,4,2},
	{2,1,4},{2,4,6},{2,6,3},{2,3,1},
	{3,1,2},{3,2,6},{3,6,5},{3,5,1},
	{4,1,5},{4,2,1},{4,6,2},{4,5,6},
	{5,1,3},{5,3,6},{5,4,1},{5,6,4},
	{6,2,4},{6,4,5},{6,5,3},{6,3,2}};

int main()
{
	for(i=1;i<7;i++)scanf("%d",A+i);
	for(i=1;i<7;i++)scanf("%d",B+i);
	for(i=0;i<24;i++)
	{
		if(A[1]==B[G[i][0]]&&
		   A[2]==B[G[i][1]]&&
		   A[3]==B[G[i][2]]&&
		   A[6]==B[7-G[i][0]]&&
		   A[5]==B[7-G[i][1]]&&
		   A[4]==B[7-G[i][2]])
		{puts("Yes");
		return 0;
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <vector>
#include <algorithm>
struct Goods {
	long long int value{ 0 }, weight{ 0 };
	Goods operator+(const Goods &other) const {
		return Goods{ value + other.value, weight + other.weight };
	}
	Goods operator+=(const Goods &other) {
		value += other.value; weight += other.weight;
		return *this;
	}
	bool operator<(const Goods &other) const {
		return (weight == other.weight) ? value > other.value : weight < other.weight;
	}
	bool operator>(const Goods &other) const {
		return (weight == other.weight) ? value < other.value : weight < other.weight;
	}
	bool operator==(const long long int w) const { return w == weight; }
};
std::istream &operator>>(std::istream &is, Goods &g) {
	return is >> g.value >> g.weight;
}
int main() {
	long long int n, w;
	std::cin >> n >> w;
	std::vector<Goods> half1(n / 2);
	std::vector<Goods> half2(n - (n / 2));
	for (auto &good : half1) std::cin >> good;
	for (auto &good : half2) std::cin >> good;
	std::vector<Goods> combination1(1 << half1.size());
	std::vector<Goods> combination2(1 << half2.size());
	for (auto i = 0; i < combination1.size(); ++i) {
		combination1[i] = Goods{ 0, 0 };
		for (auto j = 0; j < half1.size(); ++j)
			if ((i & (1 << j)) != 0)
				combination1[i] += half1[j];
	}
	for (auto i = 0; i < combination2.size(); ++i) {
		combination2[i] = Goods{ 0, 0 };
		for (auto j = 0; j < half2.size(); ++j)
			if ((i & (1 << j)) != 0)
				combination2[i] += half2[j];
	}
	std::sort(combination1.begin(), combination1.end());
	std::sort(combination2.begin(), combination2.end());
	std::vector<Goods> for_search{ Goods{0, 0} };
	long long int max_value{ 0 };
	for (auto i = 0; i < combination2.size() && combination2[i].weight <= w; ++i) {
		if (for_search.back().weight != combination2[i].weight && max_value < combination2[i].value) {
			for_search.push_back(combination2[i]);
			max_value = combination2[i].value;
		}
	}
	auto right = for_search.end();
	for (auto i = 1; i < combination1.size() && combination1[i].weight <= w; ++i) {
		if (combination1[i].weight != combination1[i - 1].weight) {
			right = std::upper_bound(for_search.begin(), right, Goods{ 0, w - combination1[i].weight });
			if (combination1[i].value + (right - 1)->value > max_value) {
				max_value = combination1[i].value + (right - 1)->value;
			}
		}
	}
	std::cout << max_value << std::endl;
}


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

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



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long 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 {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= 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 {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};

int main() {
	ll N,ans;
	cin>>N;
	cout << N * N * N;
}


Measured memory_bytes: 3196