akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    std::vector<int>a(26,0) ;
    for(;;){
    string s;
    getline(cin,s);
    if(s.size()==0)break;
    rep(i,s.size()){
        if(s[i]-'A'<=25&&s[i]-'A'>=0)a[s[i]-'A']++;
        if(s[i]-'a'<=25&&s[i]-'a'>=0)a[s[i]-'a']++;
    }}
    rep(i,26){
        std::cout << char('a'+i)<<" "<< ':' <<' '<<a[i] << std::endl;
    }
}


Measured memory_bytes: 3144
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> P;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n)  for(int i=0; i<(n); i++)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}
int main(){
    string s;
    cin >> s;
    LL cnt=0;
    REP(i, s.size()-1){
        if(s[i]!=s[i+1]) cnt++;
    }
    cout << cnt << endl;
}
    




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

using namespace std;

int main(void)
{
	int a,b,n,M,m;
	cin>>n>>a>>b;
	M=min(a,b);
	if((a+b)>n){
		m=a+b-n;
	}else{
		m=0;
	}
	cout<<M<<endl;
	cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize "03"
#include"bits/stdc++.h"
using namespace std;
 
#define input_from_file freopen("inp.txt","r",stdin)
#define output_to_file freopen("out.txt" , "w",stdout)
#define fastio ios_base::sync_with_stdio(0)

int main() {
	#ifdef LOCAL 
	input_from_file; 
	output_to_file; 
	#endif
   
    fastio;cin.tie(0);cout.tie(0);
	unsigned long long int h,n=0,t;
	cin >> h;
	t=h;

	while(t!=1)
	{
		t/=2;
		n++;
	}
	
	cout<<2*static_cast<unsigned long long>(pow(2,n))-1;

	
	
	return 0;
}

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

//this implements the shell sort algorithm
public class Main {
	public static int cnt = 0;
	// do insertion sort with a given interval
	
	public static void insertion_sort(int[] arr, int inv) {
		int n = arr.length;
		for(int i = inv; i < n; i ++) {
			int key = arr[i];
			int j = i - inv;
			
			while( j >= 0 && arr[j] > key) {
				arr[j+inv] = arr[j]; // do the shift
				j -= inv;
				cnt++;
			}
			
			arr[j+inv] = key;
		}
	}
	
	
	// we will also use the g_{n+1} = 3*g_{n} + 1 
	
	//give the array length, generate a possible list of interval's according to the recurrent relation above
	public static ArrayList<Integer> generate_inv(int n) {
		ArrayList<Integer> invs = new ArrayList<Integer>();
		
		int q = 1;
		while(q <= n) {
			invs.add(q);
			q = 3*q+1;
		}
		
		return invs;
	}
	
	
	public static void main(String [] args) {
		Scanner cin = new  Scanner(System.in);
		int n = cin.nextInt();
		int [] arr = new int[n];
		
		//read in the array
		for(int i = 0; i < n; i++) {
			arr[i] = cin.nextInt();
		}
		
		ArrayList<Integer> invs = generate_inv(n);
		
		System.out.println(invs.size());
		
		for(int i = invs.size()-1; i >= 0; i--) {
			System.out.print(invs.get(i));
			if(i == 0) {
				System.out.print("\n");
			}else {
				System.out.print(" ");
			}
			insertion_sort(arr, invs.get(i));
		}
		
		//finally output cnt
		System.out.println(cnt);
		for(int i = 0; i < arr.length; i++) {
			System.out.print(arr[i]);
			
			if(i < arr.length -1) {
				System.out.print("\n");
			}
		}
		
		cin.close();
		
	}
	
}

Measured memory_bytes: 299640
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int gcd(int a, int b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}

int main()
{
	int k;
	long long sum = 0;
	cin >> k;
	for (int i = 1; i <= k; i++)
		for (int i2 = 1; i2 <= k; i2++)
		{
			int x = gcd(i, i2);
			for (int i3 = 1; i3 <= k; i3++)
				sum += gcd(x, i3);
		}
	cout << sum;
	return 0;
}


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

    int x;
    cin >> x;

    int k = x / 100;
    int j = x % 100;
    if(k*5 >= j){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 384
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N, M = map(int, input().split())
S = input()
T = input()

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)
lcm = N * M // gcd(N, M)
# SとTそれぞれindexが何個進むとlcm番目の文字が出現するか求める
si = lcm // M
ti = lcm // N

i = 0
j = 0
ok = True
while i < N and j < M:
    if S[i] != T[j]:
        ok = False
        break
    i += si
    j += ti
if ok:
    print(lcm)
else:
    print(-1)

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

int main()
{
  int64_t N, color = 0;
  cin >> N;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  vector<priority_queue<int64_t>> vpq(N + 1);
  multimap<int64_t, int64_t> mp; // top, color
  vpq.at(0).push(A[0]);
  mp.insert({A[0], 0});
  for (int i = 1; i < N; i++)
  {
    auto it = mp.lower_bound(A.at(i));
    if (it == mp.begin())
    {
      color++;
      vpq.at(color).push(A.at(i));
      mp.insert({A.at(i), color});
    }
    else
    {
      it--;
      auto p = *it;
      vpq.at(p.second).push(A.at(i));
      mp.erase(it);
      mp.insert({vpq.at(p.second).top(), p.second});
    }
  }
  cout << color + 1 << endl;
}

Measured memory_bytes: 13568
import java.util.*;
public class Main{

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        
        int d = a/b;
        int r = a%b;
        double f = (double)a/(double)b;
        
        System.out.println(d+" "+r+" "+ String.format("%.8f",f));

    }

}



Measured memory_bytes: 26476
#include<stdio.h>

int A[101][101],n;


int main(){
  int i,j,count=0;
  int color[101],d[101],pi[101],mincost,ii;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&A[i][j]);
    }
  }
  for(i=0;i<n;i++){
    color[i]=0;
    pi[i]=-1;
    d[i]=2001;
  }
  d[0]=0;

  while(1){
    mincost=2001;
    for(i=0;i<n;i++){
      if(color[i]!=2 && d[i]<mincost){
        mincost=d[i];
        ii=i;
      }
    }
    if(mincost==2001)break;
    color[ii]=2;
    for(i=0;i<n;i++){
      if(A[ii][i]!=-1 && color[i]!=2 && A[ii][i]<d[i]){
	pi[i]=ii;
	d[i]=A[ii][i];
	color[i]=1;
      }
    }
  }
  for(i=0;i<n;i++){
    if(pi[i]!=-1)count+=A[i][pi[i]];
    }
  printf("%d\n",count);
  return 0;
}




Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	string s;
	ll ans=1;
	cin>>s;
	for(ll i=0;i<s.size()-1;i++){
		if(s[i]!=s[i+1]){
			ans++;
		}
	}
	cout <<ans;
	return 0;
}

Measured memory_bytes: 512
from itertools import accumulate
import bisect

N,M,K = map(int,input().split())

A = list(map(int,input().split()))
B = list(map(int,input().split()))


#累積和
a_acc =[0] + list(accumulate(A))
b_acc =list(accumulate(B))

ans = 0

for an in range(len(a_acc)):
    rem = K - a_acc[an]
    if rem < 0:
        break
    
    bn  = bisect.bisect_right(b_acc, rem)

    ans = max(ans, an+bn)
    
    
print(ans)

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

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int a, b; cin >> a >> b;
  if (a < b) swap(a, b);
  int diff = a - b;

  if (diff % 2) cout << "IMPOSSIBLE" << endl;
  else cout << a - diff / 2 << endl;
  
  return (0);
}

Measured memory_bytes: 3620
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	edges := make(map[int]map[int]int)
	for i := 0; i < n; i++ {
		edges[i] = make(map[int]int)
	}

	for i := 0; i < n-1; i++ {
		var u, v, w int
		fmt.Scan(&u, &v, &w)
		u--
		v--
		edges[u][v] = w
		edges[v][u] = w
	}

	weights := make([]int, n)
	for i := 0; i < n; i++ {
		weights[i] = -1
	}

	q := make([]int, 0)
	q = append(q, 0)
	weights[0] = 0

	for len(q) > 0 {
		v := q[0]
		q = q[1:]

		e := edges[v]
		for u, w := range e {
			if weights[u] != -1 {
				continue
			}
			weights[u] = weights[v] + w
			q = append(q, u)
		}
	}

	for i := 0; i < n; i++ {
		fmt.Println(weights[i] % 2)
	}
}


Measured memory_bytes: 35584
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <cmath>
#include <functional>

using namespace std;

int main(void)
{
	int n, m;
	vector <string> a, b;
	string s;

	cin >> n >> m;

	for (int i = 0; i < n; i++)
	{
		cin >> s;
		a.push_back(s);
	}
	for (int j = 0; j < m; j++)
	{
		cin >> s;
		b.push_back(s);
	}

	for (int i = 0; i < n - m + 1; i++)
	{
		for (int j = 0; j < n - m + 1; j++)
		{
			bool flag = true;
			for (int x = 0; x < m; x++)
			{
				for (int y = 0; y < m; y++)
				{
					if (b[x][y] != a[i + x][j + y])
					{
						flag = false;
						break;
					}
				}
				if (flag == false)
				{
					break;
				}
			}
			if (flag == true)
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
def resolve():
    import math
    a = [int(input()) for _ in range(5)]
    a = sorted(a, key=lambda x: 10 - (x % 10) if x % 10 != 0 else 0)
    count = sum([math.ceil(i/10) * 10 for i in a[:-1]])
    count += a[-1]
    print(count)

resolve()

Measured memory_bytes: 3060
#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)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;


int main() {

  ll A, B, K;

  cin >> A;
  cin >> B;
  cin >> K;

  ll ans1, ans2;

  ans1 = max((ll)0, A-K); // eat (A-ans1) cookies, so rest is K - (A-ans1)
  ans2 = max((ll)0, B - (K - (A - ans1)));

  cout << ans1 << " " << ans2 << endl;

  return 0;
}


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

int main(void) {
    int64_t x;
    int64_t remains;
    int64_t ans;
    
    cin >> x;
    ans = (x / 11) * 2;

    remains = x % 11;
    if(remains == 0) {
    } else if(remains > 6) {
        ans+=2;
    } else {
        ans++;
    }

    cout << ans << "\n";
    return 0;
}


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

int main(void)
{
  ll H, W;
  cin >> H >> W;
  if ( H == 1 || W == 1 )
  	cout << 1 << endl;
  else
    cout << (H * W + 1) / 2 << endl;
    
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define min(a, b) (a>b?b:a)

int a = (1 << 30), p[3], n, i, j;

int main(){
    scanf("%d", &n);
    for(i = 0;i < n;i++){
	scanf("%d",p + i);
	a = min(a, p[i]);
    }
    for(i = 1;i <= a;i++){
	int x = 1;
	for(j = 0;j < n;j++){
	    if(p[j]%i)x=0;
	}
	if(x)
	    printf("%d\n", i);
    }
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

const int N = 1e5 +5;

int n,ret,ans,pos,pos1;
int a[N],buc[N],buc1[N];

int main()
{
	scanf("%d",&n);
	for (int i = 1 ; i <= n ; i++) scanf("%d",&a[i]);
	for (int i = 1 ; i <= n ; i += 2) buc[a[i]]++;
	for (int i = 1 ; i <= N ; i++) if (buc[i] > ret) {ret = buc[i];pos = i;}
	ans = ret;
	ret = 0;
	for (int i = 2 ; i <= n ; i += 2) buc1[a[i]]++;
	for (int i = 1 ; i <= N ; i++) if (buc1[i] > ret) {ret = buc1[i];pos1 = i;}
	if (pos == pos1)
	{
		int ret2 = 0,ret3 = 0;
		for (int i = 1 ; i <= N ; i++) if (buc[i] > ret2 && i != pos) ret2 = buc[i];
		for (int i = 1 ; i <= N ; i++) if (buc1[i] > ret3 && i != pos1) ret3 = buc1[i];
		int A = min(n - ret2 - ret,n - ans - ret3);
		printf("%d\n",A);
		return 0;
	}
	ans += ret;
	printf("%d\n",n - ans);
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0; i<x; i++)
#define repn(i,x) for(int i=1; i<=x; i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main() {
    int n, k;
    cin >> n >> k;
    int num = int('A') - int('a');
    string s;
    cin >> s;
    s[k-1] -= num;
    cout << s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define int long long
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
const int INF = 1e9;

int N;
int a[303030];

signed main()
{
    cin >> N;
    REP(i,3*N) cin >> a[i];

    sort(a, a + 3 * N, greater<int>());
    ll ans = 0;
    REP(i,N) {
        ans += a[2 * i + 1];
    }

    cout << ans << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;

signed main(){
    int h,w; cin>>h>>w;
    if(h%3==0 or w%3==0){
        cout<<0<<endl;
        return 0;
    }
    int ans=min(h,w);
    for(int i=1; i<=h-1; i++){
        int a=w*i,b=(h-i)*(w/2),c=(h-i)*w-b;
        int dif=max({abs(a-b),abs(a-c),abs(b-c)});
        ans=min(ans,dif);
    }
    for(int i=1; i<=w-1; i++){
        int a=h*i,b=(w-i)*(h/2),c=(w-i)*h-b;
        int dif=max({abs(a-b),abs(a-c),abs(b-c)});
        ans=min(ans,dif);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;

public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;
    String[]       in_str_split;

    int   in_N;
    int   in_X;
    int[] in_x;

    int                    cnt;
    LinkedHashSet<Integer> diff;
    ArrayList<Integer>     diff_s;
    int                    ans;

    try
    {
      in_stream = new BufferedReader(new InputStreamReader(System.in));

      /*----------------
       * 引数
       *----------------*/
      in_str       = new String(in_stream.readLine());
      in_str_split = in_str.split(" ");
      in_N         = Integer.parseInt(in_str_split[0]);
      in_X         = Integer.parseInt(in_str_split[1]);

      in_str       = new String(in_stream.readLine());
      in_str_split = in_str.split(" ");
      in_x         = new int[in_N+1];
      for(cnt=0; cnt<in_N; cnt++)
      {
        in_x[cnt] = Integer.parseInt(in_str_split[cnt]);
      }
      in_x[in_N] = in_X;

      /*----------------
       * 計算
       *----------------*/
      Arrays.sort(in_x);

      diff = new LinkedHashSet<Integer>();
      for(cnt=1; cnt<(in_N+1); cnt++)
      {
        diff.add(in_x[cnt] - in_x[cnt-1]);
      }
      diff_s = new ArrayList<Integer>(diff);

      ans = gcd(diff_s);


      System.out.println(String.valueOf(ans));
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }



  public static int gcd(int val1, int val2)
  {
    int tmp;


    if(val1 < val2)
    {
      tmp = val1;
      val1 = val2;
      val2 = tmp;
    }

    int r = -1;
    while(r != 0)
    {
      r = val1 % val2;
      val1 = val2;
      val2 = r;
    }

    return val1;
  }



  public static int gcd(ArrayList<Integer> val)
  {
    int len;
    int g;
    int cnt;


    len = val.size();

    if(1 < len)
    {
      g = gcd(val.get(0), val.get(1));

      for(cnt=1; cnt<len-1; cnt++)
      {
        g = gcd(g, val.get(cnt + 1));
      }
    }
    else
    {
      g = val.get(0);
    }

    return g;
  }



}


Measured memory_bytes: 39468
n = int(input())
d, x = list(map(int, input().split()))

a = []
for i in range(n):
    a.append(int(input()))

count = x

for i in range(n):
    j = 0
    while d >= j * a[i] + 1:
        count += 1
        j += 1


print(count)

Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var k, s int
	fmt.Scan(&k, &s)

	count := 0
	double := 0
	triple := 0
	for x := 0; x <= k; x++ {
		for y := x; y <= k; y++ {
			for z := y; z <= k; z++ {
				if x+y+z == s {
					count++
					if x == y && y == z {
						triple++
					} else if x == y || y == z || z == x {
						double++
					}
				}
			}
		}
	}
	count = (count-(double+triple))*6 + double*3 + triple
	fmt.Println(count)
}


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

int gcd(int a, int b){
  if(b == 0){ return a; }
  return gcd(b, a % b);
}

int main(void){
  int x, y;
  cin >> x >> y;
  cout << gcd(x, y) << endl;
  return 0;
}

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

int main() {
	long n,z,w,k;
	cin>>n>>z>>w;
	vector<long>v(n);
	vector<long>e(n);
	for(int i=0;i<n;i++)cin>>v.at(i);
	for(int i=0;i<n;i++){
		e.at(i)=max(v.at(i)-v.at(n-1),v.at(n-1)-v.at(i));
		
	}
	k=max(w-v.at(n-1),v.at(n-1)-w);
	if(n>=2){
		
	
	cout<<max(k,e.at(n-2))<<endl;
	}
	else{
		cout<<k<<endl;
	}
	return 0;
}

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

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

    int N, M; cin >> N >> M;
    int ans = 0;
    for (int i = 1; i <= N || i * i <= M; ++i) {
        if (M % i == 0) {
            if (i >= N) ans = max(ans, M / i);
            if (M / i >= N) ans = max(ans, i);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] AB = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            int cnt = 0;
            for(long j= AB[0]; j <= AB[1]; j++)
            {
                string strNum = j.ToString();
                string head = strNum.Substring(0,2);
                if (strNum.Substring(3, 2) == head.Substring(1, 1) + head.Substring(0, 1))
                {
                    cnt++;

                }
            }
            Console.WriteLine(cnt);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


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

int main(){
int n,k;
cin >> n >> k;
vector<int> p(n);
rep(i,n) cin >> p.at(i);
sort(p.begin(), p.end());
int ans=0;
//int cnt=0; 
for(int i=0; i<k; i++){
        ans +=p.at(i);
}
cout << ans << endl;


}

Measured memory_bytes: 3592
def num(x):
	sum = 0
	while (x > 0):
		sum += x % 10
		x //= 10
	return sum

n = int(input())
ans = 1 << 30

for i in range(1, n):
	j = n - i
	ans = min(ans, num(i) + num(j))

print(ans)

Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main() {
  int N, A[4];
  cin >> N;
  for (int i = 0; i < 4; i++) {
    A[i] = N % 10;
    N /= 10;
  }
  if ((A[0]==A[1]&&A[1]==A[2]) || (A[1]==A[2]&&A[2]==A[3]))
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7


n=I()
k=I()
x=I()
y=I()
if n<=k:
    ans=n*x
else:
    ans=k*x+(n-k)*y
print(ans)

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

const double INF = 1e9;
const double EPS = 1e-11;

// ????¬????
struct P3{
  double x,y,z;
  double vx,vy,vz;
  double r,vr;
  P3(double x=0, double y=0, double z=0):x(x),y(y),z(z){}
  P3 operator + (const P3 &a) const{ return P3(x+a.x, y+a.y, z+a.z); }
  P3 operator - (const P3 &a) const{ return P3(x-a.x, y-a.y, z-a.z); }
  P3 operator * (const double &c) const{ return P3(x*c, y*c, z*c); }
  void input(){cin>>x>>y>>z>>vx>>vy>>vz>>r>>vr;}
  P3 v ()const{return P3(vx,vy,vz);}
};
P3 operator * (double c, const P3 &a){ return P3(c * a.x, c * a.y, c * a.z); }


double norm(P3 a){ return a.x*a.x + a.y*a.y + a.z*a.z; }
double abs(P3 a){ return sqrt(norm(a)); }

typedef pair<int,int> P;
typedef pair<double,P> PP;

double calc(P3 A,P3 B,double t){
  if((A.r-t*A.vr)<0|| (B.r-t*B.vr)<0) return -1;
  return abs((A+t*A.v())-(B+t*B.v())) - ((A.r-t*A.vr) + (B.r-t*B.vr));
}

double calc(P3 A,P3 B){
  double L=0,R=INF,cnt = 65;
  while(cnt--){
    double M = (L+R)/2;
    double y1 = calc(A,B,M);
    double y2 = calc(A,B,M+EPS);
    if(y1<0||y1-y2<0) R = M;
    else L = M+EPS;
  }
  return L-EPS;
}

int main(){
  int n;
  while(cin>>n,n){
    vector<P3>A(n);
    for(int i=0;i<n;i++) A[i].input();

    priority_queue<PP,vector<PP>,greater<PP> >Q;
    for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++){
	double t = calc(A[i],A[j]);
	if(abs(calc(A[i],A[j],t))<2e-8)Q.push(PP(t,P(i,j)));
      }

    vector<double> ans(n,-1);
    while(!Q.empty()){
      PP t = Q.top();Q.pop();
      double c = t.first;
      int a = t.second.first;
      int b = t.second.second;
      if(ans[a]>=0||ans[b]>=0)continue;
      ans[a] = ans[b] = c;
    }

    for(int i=0;i<n;i++){
      if(ans[i]<0) ans[i] = A[i].r / A[i].vr;
      ans[i] = min(ans[i],A[i].r / A[i].vr);
      printf("%.10Lf\n",ans[i]);
    }    
    
  }
  return 0;    
}

Measured memory_bytes: 3236
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int L, R, d;
  cin >> L >> R >> d;

  int ans = 0;
  FOR(i, L, R+1){
    if(i%d == 0) ans++;
  }
   
  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 3640
using System;
using System.Linq;

namespace ALDS1_2_B {
    class Program {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int count = 0;
            for(int i = 0; i < n; i++) {
                int minj = i;
                for(int j = i; j < n; j++) {
                    if (A[j] < A[minj]) {
                        minj = j;
                    }
                }

                if (minj != i) {
                    int temp = A[i];
                    A[i] = A[minj];
                    A[minj] = temp;
                    count++;
                }
            }

            Console.Write(A[0]);
            for(int i = 1; i < n; i++) {
                Console.Write(" {0}", A[i]);
            }
            Console.WriteLine("\n{0}", count);
        }
    }
}

Measured memory_bytes: 9592
#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 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

int main() {
    int N, A; cin >> N >> A;
    if (A >= (N % 500)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#if _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#ifndef ONLINE_JUDGE 
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

// Reads a 1D vector
template <class T>
void read1d(vector<T> & arg) {
	const int l = arg.size();
	for (int i = 0; i < l; ++i) cin >> arg[i];
}

void read() {}
// Reads arbitrary values
template <class T1, class... T2>
void read(T1& var1, T2&... var2) { cin >> var1; read(var2...); }



void pln() { cout << (DEBUG ? "]\n" : "\n"); }
template <class T1, class... T2>
void pln(const T1& var1, const T2& ... var2) { cout << var1 << " "; pln(var2...); }

// Prints arbitrary values and goes to next line
template <class T1, class... T2>
constexpr void print(const T1& var1, const T2& ... var2) { cout << (DEBUG ? " [ " : ""); pln(var1, var2...); }

// Prints arbitrary values and goes to next line ONLY IF IN DEBUG MODE
template <class T1, class... T2>
constexpr void debug(const T1& var1, const T2& ... var2) { if (!DEBUG) return;  cout << " debug : [ "; pln(var1, var2...); }





using ll = long long;
using ull = unsigned long long;


#define all(x) begin(x), end(x)

const bool MULTIPLE_TEST_CASES = 0;


void exec() 
{
	ll a, b, c, d;
	read(a, b, c, d);

	ll MAX = a * c;
	MAX = max(MAX, a * d);
	MAX = max(MAX, b * c);
	MAX = max(MAX, b * d);

	print(MAX);
}

















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

	if (!MULTIPLE_TEST_CASES)
		exec();
	else {
		int n;
		cin >> n;

		while (n--)
			exec();
	}

    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
main()
{
	int i, n, k, sum=0;
	cin>>n>>k;
	vector<int> vect(n);
	
	for(i=0;i<vect.size();i++)
		cin>>vect[i];
	
	sort(vect.begin(),vect.end());
	
	for(i=0;i<k;i++)
		sum+=vect[i];
		
	cout<<sum;
	
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    ll n;
    ll k;
    cin>>n>>k;
    vector<ll> a(2*n);
    map<ll,vector<ll>> mp;
    rep(i,n) {
        cin>>a[i];
        a[i+n]=a[i];
        mp[a[i]].push_back(i);
    }
    
    for(auto &p:mp) {
        auto &v=p.second;
        for(ll x:v) {
            v.push_back(x+n);
        }
    }
    
    ll cnt=0;
    ll idx=0;
    ll num=a[idx];
    do {
        ll new_idx=*upper_bound(all(mp[num]),idx);

        //cout<<idx<<" "<<new_idx<<endl;
        
        cnt+=new_idx-idx+1;
        idx=(new_idx+1)%n;
        num=a[idx];
    } while(idx>0);
    
    k=(k*n)%cnt;
    while(true) {
        ll new_idx=*upper_bound(all(mp[num]),idx);
        if(k-(new_idx-idx)<=0) break;
        k-=new_idx-idx+1;
        idx=(new_idx+1)%n;
        num=a[idx];
    }
    
    rep(i,k) {
        ll new_idx=*upper_bound(all(mp[num]),idx);
        if(i+(new_idx-idx)<k) {
            i+=new_idx-idx;
            idx=(new_idx+1)%n;
            num=a[idx];
        }
        else {
            cout<<num<<endl;
            num=a[idx];
            idx=(idx+1)%n;
            num=a[idx];
        }
    }
    
}


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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

pair<ll, ll> alldp[303][303];
bool allused[303][303];
vector<pair<ll, ll>> toc[303];

const ll inf = (1LL << 50);

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n, m, l;
    cin >> n >> m >> l;

    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        toc[a].emplace_back(b, c);
        toc[b].emplace_back(a, c);
    }

    rep(i, n) {
        int s = i;
        bool *used = (allused[i]);
        pair<ll, ll> *dp = (alldp[i]);
        rep(k, n) dp[k] = make_pair(inf, inf);

        rep(j, n) {
            used[j] = false;   
        }

        auto comp = [](const tuple<ll,ll,ll>& a, const tuple<ll,ll,ll>& b) {
            ll a1, a2, a3, b1, b2, b3;
            tie(a1, a2, a3) = a;
            tie(b1, b2, b3) = b;
            if (a1 == b1) {
                return b2 > a2;
            }
            else return a1 > b1;
        };

        priority_queue<tuple<ll, ll, ll>, vector<tuple<ll, ll, ll>>, decltype(comp)> que(comp);
        que.emplace(0, l, s);
        
        while(!que.empty()) {
            int x, y, z;
            tie(x, y, z) = que.top();
            que.pop();
            if (used[z]) continue;
            used[z] = true;
            dp[z] = make_pair(x, y);

            for(auto& p: toc[z]) {
                int dist = p.second;
                int j = p.first;
              	if (used[j]) continue;
                int nx = x, ny = y;
                if(dist > l) continue;
                else if (dist > ny) {
                    nx++;
                    ny = l;
                }
                ny -= dist;
                que.emplace(nx, ny, j);
            }
        }
    }

    int q;
    cin >> q;
    rep(i, q) {
        int s, t;
        cin >> s >> t;
        s--, t--;

        if (alldp[s][t].second == inf) {
            cout << -1 << endl;
        } else {
            cout << alldp[s][t].first << endl;
        }
    }

    return 0;
}


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

LL dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
LL dy[] = {0, 0, 1, -1, -1, 1, -1, 1};

///**************************DONE****************************///

int ch[mx2];

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

    for(int i = 0; i < k; i++){
        int d;
        cin >> d;

        for(int j = 0; j < d; j++){
            int a;
            cin >> a, ch[a] = 1;
        }
    }

    int ans = 0;
    for(int i = 1; i <= n; i++)
        ans += (!ch[i]);

    cout << ans << '\n';
    return 0;
}


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

int main(){
    string a,b,c;
    cin>>a>>b>>c;
    if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;



int main(void) {
  ll i, j, k;
  ll N, M;
  cin >> N >> M;
  P p[MAX];
  
  for(i=0; i<N; i++) {
    cin >> p[i].first >> p[i].second;
  }
  sort(p, p+N);
  
  ll ans=0;
  k=0;
  priority_queue<ll> q;
  for(i=M-1; i>=0; i--) {
    
    while(k<N && i+p[k].first<=M) {
      q.push(p[k].second);
      k++;
    }
    
    if(q.size()) {
      ans+=q.top(); q.pop();
    }
    
  }
  
  pt(ans);
  
}





Measured memory_bytes: 2936
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var count = 0;
        for (int i = 0; i < n; i++) if (a[i] % 2 == 0) count++;
        Console.WriteLine(count);
    }
}



Measured memory_bytes: 15976
#include<bits/stdc++.h>
#define INF ((1LL<<62)-(1LL<<31))
using namespace std;
int main(){
    long long n, m, l; cin >> n >> m >> l;
    long long dp[n][n];
    for(long long i=0; i<n; i++){
        for(long long j=0; j<n; j++){            
            dp[i][j] = INF;
        }
    }
    for(long long i=0; i<m; i++){
        long long a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        dp[a][b] = c;
        dp[b][a] = c;
    }
    //ワーシャルフロイド
    for(long long k=0; k<n; k++){
        for(long long i=0; i<n; i++){
            for(long long j=0; j<n; j++){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    //燃料追加なしでいける場所に辺を追加
    for(long long i=0; i<n; i++){
        for(long long j=0; j<n; j++){
            if(dp[i][j] <= l){
                dp[i][j] = 1;
            }else{
                dp[i][j] = INF;
            }
        }
    }
    //ワーシャルフロイド
    for(long long k=0; k<n; k++){
        for(long long i=0; i<n; i++){
            for(long long j=0; j<n; j++){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    long long q; cin >> q;
    for(long long i=0; i<q; i++){
        long long s, t;
        cin >> s >> t;
        s--; t--;
        cout << (dp[s][t] < INF ? dp[s][t]-1 : -1) << endl;
    }

}


Measured memory_bytes: 1280
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Reflection.Metadata.Ecma335;
using System.Numerics;

namespace AtCoder
{
    class Program
    {

        const int BiggestMod = 1000000007;
        public static void Main()
        {

            var num = int.Parse(Console.ReadLine());
            var result = 1L;
            
            var max = 1000L;
            max *= max * max;
            max *= max;

            var multiplicater = Console.ReadLine().Split(' ').Select(x => long.Parse(x));

            foreach (var data in multiplicater)
                if (data == 0)
                {

                    Console.WriteLine(0);
                    return;

                }
                else if (result != -1)
                    if (max / result < data)
                        result = -1;
                    else
                        result *= data;

            Console.WriteLine(result);

        }

    }

}


Measured memory_bytes: 40956
s = gets.chomp
i = 0
j = s.size - 1
ans = 0
fin = false

while j > i
  front = s[i]
  back = s[j]
  if front != back && front != 'x' && back != 'x'
    fin = true
    break
  elsif front != back
    ans += 1
    if front == 'x'
      i += 1
    else
      j -= 1
    end
  else
    i += 1
    j -= 1
  end
end

if !fin
  puts ans
else
  puts -1
end

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
//#define int int64_t
#define pcnt __builtin_popcount
#define pb push_back
#define ALL(x) (x).begin(),(x).end()
#define vec vector<int>
#define mat vector<vector<int>> //mat データ名(縦,vec(横));
int64_t INF = 1000000000000000001; //10^18+1
int MOD = 1000000007; //10^9+7
//cout << fixed << setprecision(15); (小数点以下表示)

signed main () {
  string S;
  bool can=true;
  cin >> S;
  for(int i=0;i<S.size();i++){
    if(i%2==0&&S.at(i)=='L'){
      can=false;
      break;
    }
    if(i%2==1&&S.at(i)=='R'){
      can=false;
      break;
    }
  }
  if(can){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// input! macro is published in the following URLs.
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// https://github.com/tanakh/competitive-rs.git
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a_s: [u32],
    }
    let ans = a_s.iter().map(|a| a.trailing_zeros()).sum::<u32>();
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  ll c;
  cin>>c;
  vector<ll>vec(a);
  for(ll i=0;i<a;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  ll b=vec.at(a-1);
  for(ll i=c-1;i<a;i++){
    b=min(b,vec.at(i)-vec.at(i-c+1));
  }
  cout<<b<<endl;
  return 0;
}
    
    
  


Measured memory_bytes: 3984
#include<cstdio>
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>

using namespace std;

const int CMax = 100002;

int n, A[CMax], ats;

string S;

int main(){
    cin >> S;
    for (int i = 0; i < 6; i++){
        if (S[i] == '1') ats++;
    }
    printf("%d\n", ats);
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	multiset<string> s;
	while (a --) s.insert("a");
	while (b --) s.insert("b");
	while (c --) s.insert("c");
	while ((int) s.size() > 1) {
		string t = *s.begin() + *--s.end();
		s.erase(s.begin());
		s.erase(--s.end());
		s.insert(t);
	}
	printf("%s\n", s.begin() -> c_str());
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

const ll INF = 1LL << 50;

int main() {
  int N,M;
  cin >> N >> M;

  const int NMAX = 1000;
  const int MMAX = 2000;
  int a[MMAX], b[MMAX];
  ll c[MMAX];

  rep(i,M) {
    cin >> a[i] >> b[i] >> c[i];
    c[i] = -c[i];
  }

  ll dist[NMAX];

  rep(i,N) dist[i] = INF;

  dist[0] = 0;

  for (int loop = 0; loop < N-1; ++loop) {
    for (int i = 0; i < M; ++i){
      if (dist[a[i] - 1] == INF) continue;

      if (dist[b[i] - 1] > dist[a[i] - 1] + c[i]) {
        dist[b[i] - 1] = dist[a[i] - 1] + c[i];
      }
    }
  }

  ll ans = dist[N-1];

  bool negative[NMAX];

  rep(i,N) negative[i] = false;

  for (int loop = 0; loop < N-1; ++loop) {
    for (int i = 0; i < M; ++i) {
      if (dist[a[i] - 1] == INF) continue;

      if (dist[b[i] - 1] > dist[a[i] - 1] + c[i]) {
        dist[b[i] - 1] = dist[a[i] - 1] + c[i];
        negative[b[i] - 1] = true;
      }

      if (negative[a[i] - 1] == true) {
        negative[b[i] - 1] = true;
      }
    }
  }

  if (negative[N - 1]) {
    cout << "inf" << endl;
  } else {
    cout << -ans << endl;
  }
}


Measured memory_bytes: 256
n=int(input()) 
b=list(map(int, input().split())) 
m = [0]*n

for i in range(0,n):
  if i == 0:
    m[i] = b[i]
    continue
  elif i == n-1 :
    m[n-1] = b[i-1]
    continue
  m[i] = min(b[i],b[i-1])

print(sum(m))
    
    
    

Measured memory_bytes: 3060
def get_index(DATA):
    for y, f in enumerate(DATA):
        try:
            x=f.index(0)
            return x,y
        except ValueError:
            pass
        

def solve(i, DATA):
    if i==9:
        return 1
        
    result=0
    x1,y1=get_index(DATA)
    DATA[y1][x1]=i
    
    for dx, dy in ds:
        x2=x1+dx
        y2=y1+dy
        if not (0 <= x2 < 4 and 0 <= y2 < 4 ):
            continue
        if DATA[y2][x2]:
            continue
        DATA[y2][x2]=i
        result+=solve(i+1,DATA)
        DATA[y2][x2]=0
    DATA[y1][x1]=0
    return result

while True:

    data=list(map(int,input().split()))
    if len(data)==1:
        break
    ds=list(zip(*[iter(data)]*2))
    print(solve(1,[[0]*4 for _ in range(4)]))
        


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
int n,x,y,ans[20010];

int main() 
{	cin>>n>>x>>y;
	for(int i=1;i<=n;++i)
		for(int j=i+1;j<=n;++j)
		{
			if(i<=x)
			{
				if(j<=x)
					ans[j-i]++;
				else if(j<=y)
					ans[min(j-i,(x-i)+1+(y-j))]++;
				else
					ans[x-i+1+j-y]++;
			}
			else if(i<=y)
			{
				if(j<=y)
					ans[min(j-i,i-x+1+y-j)]++;
				else
					ans[min(j-i,j-y+1+i-x)]++;
			}
			else
				ans[j-i]++;
		}
	for(int i=1;i<n;++i)
		cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 256