akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 100010
/*---------------------------------------------------------*/
int n,m;

int main(){
	in2(n,m);
	if(n>m)out(m-(n-m));
	 else out(m+(m-n)); 
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
ans=[]
xyz=[[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1],[-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]]
if(m==0):
  print("0")
else:
 for j in xyz:
   x,y,z=j
   lst=[]
   for i in range(m):
      b=a[i][0]*x+a[i][1]*y+a[i][2]*z
      lst+=[b]
   for i in range(m,n):
      b=a[i][0]*x+a[i][1]*y+a[i][2]*z
      if(min(lst)<b):
         lst.remove(min(lst))
         lst+=[b]
   ans+=[sum(lst)]
 print(max(ans))


Measured memory_bytes: 3316
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n<=0){
    cout<<"No\n";
    return 0;
  }
  if(n<=9){
    cout<<"Yes\n";
    return 0;
  }
  if(n>81){
    cout<<"No\n";
    return 0;
  }
  for(int i=2;i<=9;i++){
    if(n%i==0 and (n/i)<10){
      cout<<"Yes\n";
      return 0;
    }
  }
  cout<<"No\n";
  return 0;
}

Measured memory_bytes: 256
import sys

N = int(sys.stdin.readline())

# 4*h*n*w = N * (h*n + n*w + w*h)
# (4*h*n - N*n - N*h) * w = N*h*n
# w = N*h*n / (4*h*n - N*n - N*h)

for h in range(1, 3501):
    for n in range(1, 3501):
        a = N*h*n
        b = (4*h*n - N*n - N*h) 
        # print(h, n, a, b)
        if b > 0 and a % b == 0:
            w = a // b
            # print(4/N, 1/h + 1/n + 1/w)
            print(h, n, w)
            sys.exit()
else:
    print("something wrong")

Measured memory_bytes: 66536
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.Stack;

public class Main {
    
    public static void main(String[] args) throws FileNotFoundException {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            String temp = sc.nextLine();
            if(temp.equals(".")) return;
            if(solve(temp)){
                System.out.println("yes");
            }else{
                System.out.println("no");
            }
        }
    }

    static boolean solve(String line){
        int cirNum=0, sqNum=0;
        Stack<Character> balance = new Stack<Character>();
        for(int i=0;i<line.length();i++){
            char temp = line.charAt(i);

            if(temp=='(' || temp=='['){
              balance.push(temp);
            }else if(temp==')'){
                if(balance.isEmpty()) return false;
                if(balance.peek()!='('){
                    return false;
                }else{
                    balance.pop();
                }
            }else if(temp==']'){
                if(balance.isEmpty()) return false;
                if(balance.peek()!='['){
                    return false;
                }else{
                    balance.pop();
                }
            }
        }
        if(!balance.isEmpty()) return false;
        return true;
    }
}

Measured memory_bytes: 32732
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,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 fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll 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())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N , K; cin >> N >> K;
  vector<ll> a(N); rep(i,N) cin >> a[i];

  SORT(a);
  ll ans = 0;
  rep(i,K) ans += a[i];
  cout << ans << endl;


}


Measured memory_bytes: 3628
#include <iostream>
#include <map>
#include <ctime>
#include <vector>
#include <climits>
#include <algorithm>
#include <random>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <bitset> 
#include <queue>
#define inf 0x3f3f3f3f
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i, a, n) for(register int i = a; i <= n; ++ i)
#define per(i, a, n) for(register int i = n; i >= a; -- i)
#define ONLINE_JUDGE
using namespace std;
typedef long long ll;
const int mod=1e9+7;
template<typename T>void write(T x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}
 
template<typename T> void read(T &x)
{
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;};
ll ksm(ll a,ll n){//看是否要mod 
	ll ans=1;
	while(n){
		if(n&1) ans=((ans%mod)*(a%mod))%mod;
		a=((a%mod)*(a%mod))%mod;
		n>>=1;
	}
	return ans%mod;
}
//==============================================================
int h,w,k;
char mp[10][10];
char posmp[10][10];
int ans;
bool check(){
    int cnt=0;
    rep(i,1,h){
        rep(j,1,w){
            if(posmp[i][j]=='#') cnt++;
        }
    }
    return cnt==k;
}
void solve(int pos){
    if(pos>h+w){
        if(check()){
            ans++;
        }
        return;
    }
    if(pos<=h){
        solve(pos+1);
        char back[10];
        rep(i,1,w)back[i]=posmp[pos][i];
        rep(i,1,w) posmp[pos][i]='x';
        solve(pos+1);
        rep(i,1,w) posmp[pos][i]=back[i];
    }
    else{
        int pp=pos-h;
        solve(pos+1);
        char back[10];
        rep(i,1,h) back[i]=posmp[i][pp];
        rep(i,1,h) posmp[i][pp]='x';
        solve(pos+1);
        rep(i,1,h) posmp[i][pp]=back[i];
    }
}


int main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	//===========================================================
	read(h),read(w),read(k);
    rep(i,1,h){
        rep(j,1,w){
            cin>>mp[i][j];
        }
    }
    memcpy(posmp,mp,sizeof(mp));
    solve(1);
    write(ans);
	//===========================================================
	return 0;
}

Measured memory_bytes: 3552
import sys


sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


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


def main():
    K = int(input())
    A, B = map(int, input().split())
    for i in range(A, B + 1):
        if i % K == 0:
            print("OK")
            break
    else:
        print("NG")


if __name__ == "__main__":
    main()


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

#define rep(i,n) for (int i=0;i<(n);++i)
#define rep2(i,a,b) for (int i=(a);i<(b);++i)
#define rrep(i,n) for (int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;--i)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1e9;
const int mod = 1e9 + 9;
using Graph = vector<vector<int>>;

string parse(string s, int l, int r) {
    if (l >= r) return "";

    if (s[l] == '[') {
        int depth = 0;
        rep2(i, l, r) {
            if (s[i] == '[') depth++;
            if (s[i] == ']') depth--;
            if (!depth) {
                string t = parse(s, l + 1, i);
                reverse(all(t));
                return t + parse(s, i + 1, r);
            }
        }
        assert(false);
    }

    int t = 0;
    rep2(i, l, r) {
        if (s[i] == '+') {
            (t += 1) %= 26;
        }
        else if (s[i] == '-') {
            (t += 25) %= 26;
        }
        else {
            assert(isalpha(s[i]));
            return char((s[i] - 'A' + t) % 26 + 'A') + parse(s, i + 1, r);
        }
    }

    assert(false);
}

string replace(string s, vi v) {
    int j = 0;
    rep(i, s.size()) {
        if (s[i] == '?') {
            s[i] = 'A' + v[j++];
        }
    }
    return s;
}

string dfs(string s, int i, int q, vi v) {
    if (i == q) {
        auto t = replace(s, v);
        return parse(t, 0, t.size());
    }

    string ret(s.size(), '~');
    rep(j, 26) {
        v.emplace_back(j);
        chmin(ret, dfs(s, i + 1, q, v));
        v.pop_back();
    }
    return ret;
}

string solve(string s) {
    int q = std::count(all(s), '?');
    return dfs(s, 0, q, vector<int>{});
}

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

    string s;
    while (cin >> s, s != ".") {
        cout << solve(s) << endl;
    }
}

Measured memory_bytes: 3212
using System;
using System.Diagnostics;
using System.IO;

namespace AtCoder.ABC119 {
    class B {
        static void Main() => CustomMain();

        static void Solve() {
            var n = ReadInt();

            double ans = 0;
            for (int i = 0; i < n; i++) {
                double x;
                string u;
                ReadMulti(out x, out u);

                if (u.Equals("JPY")) {
                    ans += x;
                } else {
                    ans += x * 380000.0;
                }
            }

            WriteAnswer(ans);
        }

        static void CustomMain() {
#if DEBUG
            // ファイルからテストケースを読み込む
            global::Common.ChangeStdIn();
            // 時間計測
            var stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            // 出力高速化
            var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            // 回答
            Solve();
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
#endif
            Console.Out.Flush();
        }

        static string ReadString() => Console.ReadLine().Trim();
        static int ReadInt() => int.Parse(ReadString());
        static long ReadLong() => long.Parse(ReadString());
        static float ReadFloat() => float.Parse(ReadString());
        static double ReadDouble => double.Parse(ReadString());

        static string[] ReadStringArray() => ReadString().Split(' ');
        static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);

        static bool IsOdd(long num) {
            return (num & 1) == 1;
        }

        static bool IsEven(long num) {
            return (num & 1) == 0;
        }
    }
}

Measured memory_bytes: 11348
#include <stdio.h>

int main(){
	int n, k, read, can = 0;
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; ++i){
		scanf("%d", &read);
		if (read >= k) can++;
	}
	printf("%d\n", can);
	return 0;
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int H,W;
  while(cin>>H>>W){
    if(H==0 && W==0) return 0;
    rep(i,H){
      rep(j,W) cout<<"#";
      cout<<endl;
    }
    cout<<endl;
  }
  
  return 0;
}


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

int main() {
  int n; cin >> n;
  vector<ll> a(n*3);
  rep(i,n*3) {
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  ll ans = 0;
  for (int i = n; i<n*3; i+=2) {
    ans+=a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5556
def readinput():
    s=int(input())
    return s

def comb(n,k,p):
    """power_funcを用いて(nCk) mod p を求める"""
    from math import factorial
    if n<0 or k<0 or n<k: return 0
    if n==0 or k==0: return 1
    a=factorial(n) %p
    b=factorial(k) %p
    c=factorial(n-k) %p
    return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p

def power_func(a,b,p):
    """a^b mod p を求める"""
    if b==0: return 1
    if b%2==0:
        d=power_func(a,b//2,p)
        return d*d %p
    if b%2==1:
        return (a*power_func(a,b-1,p ))%p

def main(s):
    MOD=10**9+7
    n=s//3
    r=s%3
    ans=0
    while n>=1:
        hnr=comb(n+r-1,r,MOD)
        ans=(ans+hnr)%MOD
        n-=1
        r+=3
    return ans

if __name__=='__main__':
    s=readinput()
    ans=main(s)
    print(ans)


Measured memory_bytes: 9292
import java.io.*;
import java.util.*;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        long[] arr = new long[N];
        st = new StringTokenizer(br.readLine());
        for (int i=0; i<N; i++)
            arr[i] = Long.parseLong(st.nextToken());
        Arrays.sort(arr);

        long res = 1;
        for (int i=0; i<N; i++){
            try{
                res = Math.multiplyExact(res,arr[i]);
            }
            catch (Exception e){
                res = -1;
                break;
            }
            if (res>1000000000000000000L){
                res=-1;
                break;
            }
            if(res==0){
                break;
            }

        }
        System.out.println(res);

    }



}


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

int main()
{
  int n;scanf("%d",&n);
  int num[3];num[2]=1000000007;for(int i=0;i<n;i++)scanf("%d ",&num[i]);
  queue<int> gcd;
  for(int i=1;i<=min({num[0],num[1],num[2]});i++)
  {
    bool check=true;
    for(auto j : num)if(j!=1000000007&&j%i!=0)check=false;
    if(check)gcd.push(i);
  }
  while(!gcd.empty()){printf("%d\n",gcd.front());gcd.pop();}
}


Measured memory_bytes: 3228
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace codeFes2016 {
    class Program {
        static void Main(string[] args) {
            string str = Console.ReadLine();
            for(int i = 0; i < 4; i++) {
                Console.Write(str[i]);
            }
            Console.Write(" ");
            for(int i = 4; i < 12; i++) {
                Console.Write(str[i]);
            }
            Console.WriteLine("");
        }
    }
}


Measured memory_bytes: 2648
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#include <iomanip>

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
const int N = 3e3+5, inf = 1e9+5;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

long double dp[N][N], p[N];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    rep (i, 0, n) cin >> p[i+1];
    dp[1][0] = 1-p[1];
    dp[1][1] = p[1];
    for (int c = 2; c <= n; ++c) {
        for (int h = 0; h <= c; ++h) {
            dp[c][h] += p[c]*dp[c-1][h-1];
            dp[c][h] += (1-p[c])*dp[c-1][h];
        }
    }
    long double ans = 0;
    for (int h = n/2+1; h <= n; ++h) ans += dp[n][h];
    cout << setprecision(15) << fixed << ans << endl;
    return 0;
}

Measured memory_bytes: 139392
package main

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

var pq []int

func push(x int) {
	p := sort.Search(len(pq), func(i int) bool { return pq[i] <= x })
	if p == len(pq) {
		pq = append(pq, x)
		return
	}
	pq = append(pq[:p+1], pq[p:]...)
	pq[p] = x
}

func pop() int {
	if len(pq) == 0 {
		return 0
	}

	ans := pq[0]
	pq = pq[1:]
	return ans
}

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

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	ts := make(map[int][]int)
	for i := 0; i < n; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		b, _ := strconv.Atoi(sc.Text())
		ts[a] = append(ts[a], b)
	}

	pq = make([]int, 0, n)
	ans := 0
	for i := m - 1; i >= 0; i-- {
		if _, ok := ts[m-i]; ok {
			for _, v := range ts[m-i] {
				push(v)
			}
		}
		ans += pop()
	}
	fmt.Println(ans)
}


Measured memory_bytes: 11264
using System;
using System.Linq;
using System.Collections.Generic;
using static program.Input;
using static program.MyMath;

namespace program {
  class Program {
    static void Main()
    {
      var n = ScanInt();
      var s = ScanStrArray();
      for(int i=0; i<n; i++){
        Console.Write($"{s[0][i]}{s[1][i]}");
      }
      Console.WriteLine();
    }
    static public void Out(object s) { Console.Write($"{s} "); }
  }
  
  static class Input {
    static public int ScanInt() { return int.Parse(Console.ReadLine()); }
    static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
    static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
    static public long ScanLong() { return long.Parse(Console.ReadLine()); }
    static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
    static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
    static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
    static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
    static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
    static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

    static public string ScanStr() { return Console.ReadLine(); }
    static public string[] ScanStrArray() { return ScanStr().Split(); }
  }
  
  static class MyMath {
    public static int GCD(int a, int b) {
        Func<int, int, int> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static long GCD(long a, long b) {
        Func<long, long, long> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
      if(b==0) {
        x=1; 
        y=0;
        return a;
      }
      var d = extGCD(b, a%b, ref y, ref x);
      y -= a/b *x;
      return d;
    }
    public static int LCM(int a, int b) { return a * b / GCD(a, b); }
    public static long LCM(long a, long b) { return a * b / GCD(a, b); }
  }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-5;
const ll MOD=1e9+7;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int a[4];
    cin>>a[0]>>a[1]>>a[2]>>a[3];
    sort(a,a+4);
    if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}   


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

int main(){
    int n;
    cin>>n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin>>vec[i];
    }
    int min,max;
    int64_t sum;
    min=vec[0];
    max=vec[0];
    sum=0LL;
    for(int i=0;i<n;i++){
        if(min>vec[i])min=vec[i];
        if(max<vec[i])max=vec[i];
        sum+=(int64_t)vec[i];
    }
    printf("%d %d %lld\n",min,max,sum);
}


Measured memory_bytes: 3228
#include<iostream>
#include<cmath>

int judge(int x);
int main(void){
	int x;
	std::cin >> x;
	std::cout << judge(x) << std::endl;
	return 0;
}

int judge(int x){
	if(x == 2) return x;
	while(true){
		//�������͂���
		if(x % 2 == 0){
			x++;
			continue;
		}
		else{
			int count = 0;
			for(int i = 3; i < (int)(sqrt(x) + 1); i += 2){
				if(x % i == 0){
					count++;
				}
			}
			if(count > 0){
				x++;
				continue;
			}else{
				break;
			}
		}
	}
	return x;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		/*
		 * Scannerで値取得。
		 */
		Scanner row = new Scanner(System.in);
		Scanner sForNum = new Scanner(System.in);

		int[] day = new int[4];
		
		for (int i = 0; i < 4; i++) {
			day[i] = row.nextInt();
		}

		if(day[0]==day[2]) {
		//表示
		System.out.print(0);
		}else {
			System.out.println(1);
		}
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

ll gcd(ll a, ll b){
  ll c = min(a, b), d = max(a, b);
  while(c != 0){
    ll tmp = c;
    c = d % c;
    d = tmp;
  }
  return d;
}

int main(){
  int T;
  cin >> T;
  cout << endl;
  for(int i=0; i<T; i++){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    bool ok = true;
    if(a < b)
      ok = false;
    else if(b > d)
      ok = false;
    else if(b > c){
      ll g = gcd(b, d);
      ll max = b - g + a % g;
      if(max > c)
	ok = false;
    }
    if(ok)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}


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

using namespace std;

int solve(int d, const vector<int> &A) {
  int r = 0;
  vector<int> mods;
  for (int a : A) {
    int mod = a % d;
    r += mod;
    mods.push_back(mod);
  }
  sort(mods.begin(), mods.end());
  if (not r) {
    // cout << d << " " << 0 << endl;
    return 0;
  }
  int l = 0, n = (int) mods.size();
  for (int i = 0; i < n; ++i) {
    l += mods[i];
    r -= mods[i];
    if ((n - i - 1) * d - r == l) {
      // cout << d << " " << l << endl;
      return l;
    }
  }
  // cout << d << " " << INT_MAX << endl;
  return INT_MAX;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vector<int> A(n);
  int sum = 0;
  for (int &a : A) {
    cin >> a;
    sum += a;
  }
  int asw = 0;
  for (int i = 1; i * i <= sum; ++i) {
    if (sum % i) {
      continue;
    }
    if (solve(i, A) <= k) {
      asw = max(asw, i);
    }
    if (solve(sum / i, A) <= k) {
      asw = max(asw, sum / i);
    }
  }
  cout << asw << endl;
  return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> v(N);
    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        v[a-1]++;
        v[b-1]++;
    }
    for(int i = 0; i < N; ++i) {
        cout << v[i] << endl;
    }
}


Measured memory_bytes: 256
/*input
2 3 1
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define mp   make_pair
#define pb   emplace_back
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define int long long
#define MAX 
#define INF 0x3f3f3f3f

int n , m , d;
int32_t main(){
    cin >> n >> m >> d;
    if(d == 0){
        printf("%.11f\n", double(m - 1) * (1.0 / n));
    }
    else {
        double ans = 0;
        int v1 = d , v2 = n - d + 1;
        // cout << v1 << " " << v2 << endl;
        if(v1 > v2){
            v1 = n - d , v2 = d + 1;
            double add = v1 + (n - v2 + 1);
            // cout << add << endl;
            ans += (add / n) * (1.0 / n);
            // cout << ans << endl;
            ans *= (m - 1);
            printf("%.11f\n", ans);
        }
        else{
            double add = v1 + (n - v2 + 1);

            ans += (add / n) * (1.0 / n);
            double las = n - add;
            ans += (las / n) * (2.0 / n);

            ans *= (m - 1);
            printf("%.11f\n", ans);
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define saken string
#define erba continue
using namespace std;

const ll MAXN = 1e5 + 100;

ll n, a[MAXN];

ll sum = 0;

int main(){

cin >> n;

for(ll i = 1; i <= n; ++i) {
    cin >> a[i];
}

if(n == 1) {cout << 1;return 0;}


int start = 1;
bool kek = 0;


int ans = 0;


for(int i = 2; i <= n; ++i) {

    if(a[start + 1] > a[start]) {kek = 1;}
    else if(a[start + 1] < a[start]){kek = 0;}
    else {start = i; erba;}


    if(kek) {

        if(a[i] < a[i - 1]) {ans++; kek = 0; start = i;}

    }

    else {

        if(a[i] > a[i - 1]) {ans++; kek = 1; start = i;}

    }


}

cout << ans + 1;

return 0;
}



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

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N;
    string S;
    cin >> N >> S;

    int i = 0;
    int ans = 0;
    while (i < N) {
        ans++;
        int j = i + 1;
        while (j < N and S[i] == S[j]) j++;
        i = j;
    }
    
    cout << ans;
    return 0;
}

Measured memory_bytes: 512
s = input().split(" ")
s = [int(i) for i in s]
N = s[0]
A = s[1]
B = s[2]

cnt = 0
for i in range(N + 1) : 
    l = [int(x) for x in list(str(i))]
    rst = sum(l)
    if (rst >= A) & (rst <= B) : 
        cnt += i
print(cnt)

Measured memory_bytes: 3064
N, M = map(int, input().split())
a = [True] * (N + 1)
for _ in range(M):
    a[int(input())] = False

arr = [0] * (N + 1)
arr[1] = 1 if a[1] else 0
if 2 <= N:
    arr[2] = arr[1] + 1 if a[2] else 0
    for i in range(3, N + 1):
        arr[i] = arr[i - 2] + arr[i - 1] if a[i] else 0

print(arr[N] % 1000000007)

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long double a;
  cin >> a;
  long double b = a/3;
  cout << fixed << b * b * b << "\n";
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define int ll


signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  int ans = inf;

  ans = min(abs(a-b)+abs(b-c),abs(a-c)+abs(b-c));
  ans = min(ans,abs(b-a)+abs(a-c));

  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

vector<ll> DIS;
vector<vector<pair<int, int>>> V;

void dfs(int node){
	for(int i = 0; i < V[node].size(); i ++){
		if(DIS[V[node][i].first] < 0){
			DIS[V[node][i].first] = DIS[node] + V[node][i].second;
			//cout << "node = " << node << " "  << V[node][i].first << " " << V[node][i].second << endl;
			dfs(V[node][i].first);
		}
	}
}
int main(){

	int N;
	cin >> N;
	int u, v, w;
	V = vector<vector<pair<int, int>>>(N);
	for(int i = 0; i < N - 1; i ++){
		cin >> u >> v >> w;
		u --;
		v --;
		V[u].pb(mp(v, w));
		V[v].pb(mp(u, w));
	}
	DIS = vector<ll>(N, -1);
	DIS[0] = 0;
	dfs(0);
	for(int i = 0; i < N; i ++){
		cout << DIS[i]%2 << endl;
	}

	return 0;
}

Measured memory_bytes: 7808
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

vector<int> hyou[110];

int hyou2[110];

int bfs(int s, int d) {
	queue<int> q;
	q.push(s);
	int k;
	hyou2[s] = 0;
	while (!q.empty()) {
		k = q.front();
		q.pop();
		for (int i = 0; i < hyou[k].size(); i++) {
			int t = hyou[k][i];
			if (hyou2[t] != -1) {
			} else {
				hyou2[t] = hyou2[k]+1;
				if (t == d) {
					return hyou2[t];
				}
				q.push(t);
			}
		}
	}
	return 0;
}

int main() {
	int n;
	cin >> n;
	int a, b, c;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		for (int j = 0; j < b; j++) {
			cin >> c;
			hyou[a].push_back(c);
		}
	}
	int k;
	int p, q, r;
	cin >> k;
	for (int i = 0; i < k; i++) {
		cin >> p >> q >> r;
		for (int j = 0; j <= n; j++) {
			hyou2[j] = -1;
		}
		int g = bfs(p, q);
		if (g != 0 && r > g) {
			cout << g+1 << endl;
		} else {
			cout << "NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <algorithm>
#include <string>
#include <unordered_map>
#include <vector>
#include <numeric>

#define rep(i,min,max) for(int i=min;i<max;i++)
#define rrep(i,min,max) for(int i=max;i>=min;i--)

using namespace std;

int main(){
  int N;cin >> N;
  int s1[N];
  int s2[N];
  int tmp[N];
  int l,m;
  rep(i,0,N){cin >> s1[i];}
  rep(i,0,N){cin >> s2[i];}

  int ans = s1[0];
  for(int t:s2) {ans += t;}
  tmp[0] = ans;
  rep(i,1,N){
    tmp[i] = tmp[i-1] + s1[i] - s2[i-1];
    ans = max(tmp[i], ans);
  }

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


Measured memory_bytes: 256
arr[1<<18];
n=1<<18;
cnt;

main(i,j) {
	memset(arr, -1, sizeof arr);
	arr[0] = arr[1] = 0;
	for(i = 2; i * i <= n; i++)
		if(arr[i])
			for(j = 2 * i; j <= n; j += i)
				arr[j] = 0;

	for(;scanf("%d",&n),n;) {
		cnt = 0;
		for(i = n + 1; i <= 2 * n; i++)
			if(arr[i])
				cnt++;
		printf("%d\n", cnt);
	}
	exit(0);
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	string s;
	cin>>s;
	int n = s.size();
	int m = n - 1;
	ll sum = 0;
	for(int mask = 0; mask < (1<<m); mask++){
		ll cur = s[0] - '0';
		for(int i = 0; i < m; i++){
			if(mask&(1<<i)){
				sum += cur;
				cur = s[i + 1] - '0';
			}else{
				cur = cur*10 + s[i + 1] - '0';
			}
		}
		sum += cur;
	}
	cout<<sum<<endl;

	return 0;
}

Measured memory_bytes: 256
package main

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

// one string
func strStdin() string {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	return strings.TrimSpace(scanner.Text())
}

//one int64
func int64stdin() int64 {
	stringin := strStdin()
	val, _ := strconv.ParseInt(strings.TrimSpace(stringin), 10, 64)
	return val
}

// eliminate space
func splitWithoutEmpty(stringTargeted string, delim string) []string {
	stringSplited := strings.Split(stringTargeted, delim)
	strs := []string{}

	for _, str := range stringSplited {
		if str != "" {
			strs = append(strs, str)
		}
	}
	return strs
}

//strings in line
func sliceStrsStdin(delim string) []string {
	stringin := strStdin()
	return splitWithoutEmpty(stringin, delim)
}

func sliceInt64Stdin() []int64 {
	splitted := sliceStrsStdin(" ")

	ret := make([]int64, len(splitted), len(splitted))

	for i := range splitted {
		val, _ := strconv.ParseInt(splitted[i], 10, 64)
		ret[i] = val
	}
	return ret
}

func main() {
	num := sliceInt64Stdin()

	ans := (num[0]-1)/num[1] + 1
	ans *= num[2]

	fmt.Println(ans)

}


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

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

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

  for (int i = x - k + 1; i <= x + k - 1; ++i) {
    if (i != x - k + 1) cout << " ";
    cout << i;
  }

  cout << endl;

  return (0);
}


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

int main(){
    int a,b,h,m;
    double c;
    scanf("%d %d %d %d",&a,&b,&h,&m);

    double hourangle = 2*M_PI/12*h+2*M_PI/720*m;
    double minangle = 2*M_PI/60*m;
    double angle = abs(hourangle - minangle); 
    
    //余剰定理　c^2 = a^2+b^2-2abcosC
    c=a*a+b*b-2*a*b*cos(angle);
    c=sqrt(c);

    printf("%.10lf",c);


    return 0;
}

Measured memory_bytes: 2552
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int int_min(int a,int b)
{
  if(a>=b){
    return b;
  }else{
    return a;
  }
}
void main(void)
{
  long int N,r=0,g=0,b=0,ans=0;
  //char *str;
  scanf("%d",&N);
  //str=(char*)malloc(sizeof(char)*N);
  char str[N+1];
  scanf("%s",str);
  for(int i=0;i<N;i++){
    //scanf("%c",&str[i]);
    if(str[i]=='R'){
      r++;
    }else if(str[i]=='G'){
      g++;
    }else if(str[i]=='B'){
      b++;
    }
  }
  long int tmp=0;
  for(int i=1;i<=(N-2);i++){
    for(int j=1;j<=int_min(i,N-1-i);j++){
      if((str[i-j]!=str[i])&&(str[i-j]!=str[i+j])&&(str[i]!=str[i+j])){
        tmp++;
      }
    }
   }
                              
   printf("%ld",r*g*b-tmp);
  //for(int i=0;i<N;i++){
    //printf("%c",str[i]);
  //}


}

Measured memory_bytes: 1704
#include <stdio.h>
#include <string.h>
 
int main(void){
    char b[65];
    char p[7][33] = {
        "1100000011",
        "1000000010000000100000001",
        "1111",
        "1000000110000001",
        "11000000011",
        "100000001100000001",
        "110000011",
    };
    char *bi;
 
    int t = 0;
    while(true){
        if(scanf("%s", b) == EOF){ break; }
        for(int i=1; i<8; ++i){
            scanf("%s", b+i*8);
        }
        bi = strchr(b, '1');
        for(int i=0; i<7; ++i){
            if(memcmp(bi, p[i], strlen(p[i])) == 0){
                printf("%c\n", 'A' + i);
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        long[] sum = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            if (i == 0) {
                sum[i] = a[i];
            } else {
                sum[i] = sum[i - 1] + a[i];
            }
        }

        int l, m, r;

        long min = Long.MAX_VALUE;
        int se = 10;

        if (n == 4) {
            long mmax = Long.MIN_VALUE;
            long mmin = Long.MAX_VALUE;
            for (int k = 0; k < 4; k++) {
                if (a[k] >= mmax)
                    mmax = a[k];
                if (a[k] <= mmin)
                    mmin = a[k];
            }
            System.out.println(mmax - mmin);
            return;
        }

        for (m = 2; m < n - 1; m++) {
            int ml, mr;
            ml = Arrays.binarySearch(sum, sum[m - 1] / 2);
            if (ml < 0)
                ml = -ml - 1;
            mr = Arrays.binarySearch(sum, (sum[n - 1] - sum[m - 1]) / 2 + sum[m - 1]);
            if (mr < 0)
                mr = -mr - 1;

            for (int i = ml - se; i <= ml + se; i++) {
                for (int j = mr - se; j <= mr + se; j++) {
                    if (i <= 1)
                        i = 1;
                    if (i >= m)
                        break;
                    if (j <= m)
                        continue;
                    if (j >= n)
                        break;
                    long[] p = new long[4];
                    p[0] = sum[i - 1];
                    p[1] = sum[m - 1] - sum[i - 1];
                    p[2] = sum[j - 1] - sum[m - 1];
                    p[3] = sum[n - 1] - sum[j - 1];
                    long mmax = Long.MIN_VALUE;
                    long mmin = Long.MAX_VALUE;
                    for (int k = 0; k < 4; k++) {
                        if (p[k] >= mmax)
                            mmax = p[k];
                        if (p[k] <= mmin)
                            mmin = p[k];
                    }
                    if (mmax - mmin <= min)
                        min = mmax - mmin;
                    // System.out.println(i + ", " + m + ", " + j + ", " + (mmax - mmin));
                }
            }
        }

        System.out.println(min);
    }
}


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

 
int main() {
    long long int n,i;
     string s;
     cin>>n>>s;
     for(i=0;i<s.length();i++)
     {
         if((s[i]+n)>90)
         s[i]=((s[i]+n)%90)+64;
         else
         s[i]+=n;
     }
     cout<<s;
     
   
        
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();

    int max=Math.max(a+b,a-b);
        max=Math.max(max,a*b);

    System.out.println(max);
  }
}


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

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int inf = 1000000000;
const int mod = 1000000007;
const double eps = 1e-9;
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1};

int main() {
	int n;
	while (cin >> n, n) {
		int ans = 0;
		string now = "", next;
		rep(i, n) {
			cin >> next;
			if (now == "lu" && next == "ru") ans++;
			else if (now == "ru" && next == "lu") ans++;
			else if (now == "ld" && next == "rd") ans++;
			else if (now == "rd" && next == "ld") ans++;
			now = next;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <cmath>

int main(){
    long long N, A, B, tmp;
    std::cin >> N >> A >> B;
    tmp = (B - A) * (N - 2) + 1;
    if(N < 1) std::cout << 0 << std::endl;
    else if(A != B && N == 1) std::cout << 0 << std::endl;
    else if(tmp < 0) std::cout << 0 << std::endl;
    else std::cout << tmp << std::endl;
}


Measured memory_bytes: 256
#include <iostream>

int main () {
  int A, B;
  std::cin >> A >> B;
  int X = A + B;
  int Y = A - B;
  X = (X > Y) ? X : Y;
  Y = A * B;
  X = (X > Y) ? X : Y;
  std::cout << X << std::endl;  
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class Recording {
        int[] S;
        int[] T;
        int[] C;
        int[] SUM;
        int[] TT;
        int MAX = 100000;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int CH = in.nextInt();
            S = new int[2 * MAX + 2];
            T = new int[2 * MAX + 2];
            C = new int[2 * MAX + 2];
            SUM = new int[2 * MAX + 2];
            TT = new int[2 * MAX + 2];

            for (int i = 0; i < N; i++) {
                S[i] = in.nextInt();
                T[i] = in.nextInt();
                C[i] = in.nextInt();
            }

            for (int c = 1; c <= CH; c++) {
                Arrays.fill(TT, 0);
                for (int i = 0; i < N; i++) {
                    if (C[i] == c) {
                        TT[2 * S[i] - 1]++;
                        TT[2 * T[i]]--;
                    }
                }

                for (int i = 1; i < TT.length; i++) {
                    TT[i] += TT[i - 1];
                }

                for (int i = 0; i < TT.length; i++) {
                    if (TT[i] > 0) SUM[i]++;
                }
            }

            int ans = 0;
            for (int i = 0; i < SUM.length; i++) {
                ans = Math.max(ans, SUM[i]);
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 48764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ll a,b,c,d,t;
cin >> a >> b >> c >> d >> t;
ll s = abs(a-c);
if(b*t - d*t>=s) cout <<"YES";
else cout << "NO";
return 0;
}

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

int main(void)
{
    double r;
    cin >> r;
    cout << fixed << setprecision(6) << r*r*3.141592653589 << " " << 2*r*3.141592653589 << endl;
    
    return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
  int N;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  //整合性チェック
  int guki=N%2;
  vector<int> num((N+1)/2,0);
  bool flag=true;
  for(int i=0;i<N;i++){
    if(guki==1){
      if(a[i]%2==1||a[i]>2*(N/2)){
        flag=false;
        break;
      }
      num[a[i]/2]++;
    }else{
      if(a[i]%2==0||a[i]>2*((N-1)/2)+1){
        flag=false;
        break;
      }
      num[a[i]/2]++;
    }
    
  }
  
  for(int i=0;i<num.size();i++){
      if(guki==1&&i==0){
        if(num[i]!=1){
          flag=false;
          break;
        }
      }else if(num[i]!=2){
        flag=false;
        break;
      }
  }

  if(!flag){
    cout<<"0"<<endl;
    return 0;
  }
  ll ans=1;
  if(guki==1){
    for(int i=0;i<num.size()-1;i++){
      (ans*=2)%=mod;
    }
  }else{
    for(int i=0;i<num.size();i++){
      (ans*=2)%=mod;
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 896
n = int(input())
s = input()
t = input()

if len(s)+len(t)<= n:
  print(n)
  exit()
  
dup = min(len(s)+ len(t)-n, len(s), len(t))
for i in range(dup, 0 , -1):
  if s[-i:] == t[:i]:
    print(len(t)+len(s) - i)
    break
else:
  print(len(s)+len(t))

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

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

    for(int64_t i = 0 ; i < t.size() ; i++){
        if(t.at(i) == '?'){
            t.at(i) = 'D';
        }
    }

    cout << t;
}

Measured memory_bytes: 3756