akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;


#define ff				first
#define ss				second
#define int				long long
#define pb				push_back
#define mp				make_pair
#define pii				pair<int,int>
#define vi				vector<int>
#define mii 			map<int,int>
#define	pqb				priority_queue<int>
#define pqs				priority_queue<int,vi,greater<int> >
#define setbits(x)		__builtin_popcountll(x)
#define zrobits(x)		__builtin_ctzll(x)
#define mod				1000000007
#define inf 			1e18
#define ps(x,y)			fixed<<setprecision(y)<<x
#define mk(arr,n,type)	type *arr = new type[n]
#define w(x)			int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}


bool isPrime(int n)
{
	if (n <= 1)
		return false;
	if (n <= 3)
		return true;
	if (n % 2 == 0 || n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6)
	{
		if (n % i == 0 || n % (i + 2) == 0)
			return false;

	}
	return true;
}

vector<int> Sieve(int n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));
	for (int i = 2; i * i <= n; i++)
	{
		if (prime[i])
		{
			for (int j = i * i; j <= n; j += i)
			{
				prime[j] = false;
			}
		}
	}
	vi primes;
	for (int i = 2; i <= n; i++)
	{
		if (prime[i])
			primes.pb(i);
	}
	return primes;
}



set<int> primeFactors(int  n)
{
	set<int> factors;
	while (n % 2 == 0)
	{
		n /= 2;
		factors.insert(2);

	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		while (n % i == 0)
		{
			factors.insert(i);
			n /= i;
		}
	}
	if (n > 2)
		factors.insert(n);
	return factors;
}


// int power(int x, unsigned int y, int p)
// {
// 	int res = 1;     // Initialize result

// 	x = x % p; // Update x if it is more than or
// 	// equal to p

// 	if (x == 0) return 0; // In case x is divisible by p;

// 	while (y > 0)
// 	{
// 		// If y is odd, multiply x with result
// 		if (y & 1)
// 			res = (res * x) % p;

// 		// y must be even now
// 		y = y >> 1; // y = y/2
// 		x = (x * x) % p;
// 	}
// 	return res;
// }
// Graph------------------------------------------------------------------------
void max_self(int &a, int b)
{
	a = max(a, b);
}
int32_t main()
{
	FIO;
	// c_p_c();
//--------------------------------------------------



	int n, w;
	cin >> n >> w;
	vector<int> dp(w + 1);
	// dp[i] -- maximum total value with weight i
	// cout << dp[3] << endl;
	for (int i = 0; i < n; i++)
	{
		int weight, val;
		cin >> weight >> val;
		for (int weight_already = w - weight; weight_already >= 0; weight_already--)
		{
			dp[weight_already + weight] = max(dp[weight_already + weight], dp[weight_already] + val);

		}
	}
	int answer = 0;
	for (int i = 0; i <= w; i++)
	{
		// cout << dp[i] << endl;
		answer = max(answer, dp[i]);
	}

	cout << answer << endl;
}



Measured memory_bytes: 1024
import java.lang.reflect.Array;
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

    static int N;
    static int K;
    static int Q;
    static int A;
    static long B;
    static long C;
    //    static int[][] map;
    static int min = 9999999;
    static long ans = 0;


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

        int N = scanner.nextInt();
        int T = scanner.nextInt();

        int min = 99999999;

        for (int i = 0; i < N; i++) {
            int c = scanner.nextInt();
            int tt = scanner.nextInt();

            if(tt <= T){
                min = Math.min(min, c);
            }
        }

        if(min == 99999999){
            System.out.println("TLE");
        }else{
            System.out.println(min);
        }


    }
}



Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define debug(a) cout << #a ": " << a << endl
#define int long long
using namespace std;
typedef long long ll;
const int N = 55;
const int M = 110;
const int K = 10010;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
int n, m, money;
struct edge{
    int v, cost, tim, nxt;
}e[M<<2];
int tot, head[N], c[N], d[N];
ll dis[N][K];
struct node{
    int u, cst;
    ll dis;
    node(int u = 0, int cst = 0, ll dis = 0):u(u),cst(cst),dis(dis){}
    bool operator<(const node& rh)const{
        return dis > rh.dis;
    }
};
void init(void){
    tot = 0; memset(head, -1, sizeof head);
}
void addedge(int u, int v, int a, int b){
    e[tot] = (edge){v, a, b, head[u]}; head[u] = tot++;
    e[tot] = (edge){u, a, b, head[v]}; head[v] = tot++;
}
void dijkstra(int s){
    for (int i = 1; i <= n; ++i){
        for (int j = 0; j < K; ++j) dis[i][j] = INF;
    }
    for (int i = 0; i <= min(money, K-1); ++i){
        dis[s][i] = 0;
    }
    priority_queue<node> q;
    q.push(node(s, min(money, K-1), 0));
    while (!q.empty()){
        node p = q.top(); q.pop();
        int u = p.u, cost = p.cst, ds = p.dis;
        if (ds != dis[u][cost]) continue;
        for (int i = head[u]; i != -1; i = e[i].nxt){
            int v = e[i].v, cst = e[i].cost, tim = e[i].tim;
            if (cost >= cst && dis[v][cost-cst] > dis[u][cost]+tim){
                dis[v][cost-cst] = dis[u][cost]+tim;
                q.push(node(v, cost-cst, dis[v][cost-cst]));
            }
        }
        if (cost+c[u] < K){
            if (dis[u][cost+c[u]] > dis[u][cost]+d[u]){
                dis[u][cost+c[u]] = dis[u][cost]+d[u];
                q.push(node(u, cost+c[u], dis[u][cost+c[u]]));
            }
        }
    }
}
signed main(void){
    IOS;
    init();
    cin >> n >> m >> money;
    for (int i = 1; i <= m; ++i){
        int u, v, a, b; cin >> u >> v >> a >> b;
        addedge(u, v, a, b);
    }
    for (int i = 1; i <= n; ++i){
        cin >> c[i] >> d[i];
    }
    dijkstra(1);
    for (int i = 2; i <= n; ++i){
        ll t = INF;
        for (int j = 0; j < K; ++j){
            t = min(t, dis[i][j]);
        }
        cout << t << endl;
    }
    return 0;
}

Measured memory_bytes: 19416
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    unused_imports,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
//use proconio::marker::*;
use std::collections::*;
//use std::cmp::*;
//use std::num;
//use petgraph::unionfind::UnionFind;
const MOD: i64 = 1_000_000_007;
fn main() {
    input! {
        N:i64,mut K:i64
    }
    let mut ans = 0;
    let mut gcd_num = vec![0i64; K as usize + 1];
    for a in (1..=K).rev() {
        gcd_num[a as usize] = modPow(K / a, N);
        for i in 2..=K / a {
            gcd_num[a as usize] = (gcd_num[a as usize] - gcd_num[(a * i) as usize]) % MOD;
        }
        ans = (ans + gcd_num[a as usize] * a % MOD) % MOD;
    }

    ans = (ans + MOD) % MOD;
    println!("{}", ans);
}

fn modPow(x: i64, a: i64) -> i64 {
    if a == 1 {
        x
    } else if a & 1 == 1 {
        x * modPow(x, a - 1) % MOD
    } else {
        modPow(x, a / 2).pow(2) % MOD
    }
}


Measured memory_bytes: 2772
n=int(input())
ind='0'+str(n)+'b'

t=list(map(int,input().split()))
k=t[0]
t.pop(0)
T=t
T.reverse()
ind='0'+str(k)+'b'

for i in range(2**k):
    compare=[int(j) for j in format(i,ind)]
    disp=[T[j] for j in range(k) if compare[j]==1]
    disp.reverse()
    if len(disp)==0:
        print("0:")
    else:
        calc=[2**j for j in disp]
        print(str(sum(calc))+":",end="")
        print(" "+' '.join(map(str,disp)))



Measured memory_bytes: 5776
#include <bits/stdc++.h>
 
using namespace std;
 
#define x first
#define y second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
 
const ll MOD = 1e9+7;
const ll INF = 1e9+5;
 
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
 
int n;
int d[505][505];
int ima[505][505];
vector <int> v;
bool de;
 
void dfs(int i, int j, int k) {
	if (i<0 or j<0 or i>=n or j>=n) return ;
	if (d[i][j] <= k) return ;
	d[i][j] = k;
	for (int s=0 ; s<4 ; s++) {
		int nx = i+dx[s];
		int ny = j+dy[s];
		dfs(nx, ny, k+ima[i][j]);
	}
}
 
int main() {
	scanf("%d", &n);
	for (int i=0 ; i<n ; i++) {
		for (int j=0 ; j<n ; j++) {
			int x;
			scanf("%d", &x);
			v.pb(--x);
			d[i][j] = min(min(i, n-i-1), min(j, n-j-1));
			ima[i][j] = 1;
		}
	}
	int sol = 0;
	for (int k=0 ; k<v.size() ; k++) {
		int i = v[k]/n;
		int j = v[k]%n;
		sol += d[i][j];
		ima[i][j] = 0;
		dfs(i, j, d[i][j]++);
	}
	printf("%d\n", sol);
	return 0;
}

Measured memory_bytes: 21516
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())

    def rec(n, used):
        ans = 0
        if all(used):
            ans += 1
        for i, d in enumerate((3, 7, 5)):
            if 10 * n + d <= N:
                cur = used[i]
                used[i] = True
                ans += rec(10 * n + d, used)
                used[i] = cur
        return ans

    print(rec(0, [False, False, False]))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
    int n;
    cin>>n;
    vector<long long> a;
    map<long long,long long> nums;
    int firstdup;
    int seconddup;
    rep(i,n+1){
        long long tmp;
        cin>>tmp;
        a.push_back(tmp);
        if(nums.count(tmp)){
            firstdup=nums[tmp];
            seconddup=i;
        }else{
            nums[tmp]=i;
        }
    }
    COMinit();

//    cout << firstdup<<":"<<seconddup << endl;
    int x,y,z;
    x=firstdup;
    z=n-seconddup;
    long long ans=0;
    rep2(i,1,n+2){
        ans=(COM(n+1,i)-COM(x+z,i-1))%MOD;
        if(ans<0){
            ans=ans+MOD;
        }
//        cout << x << ":" << y << ":" << z<<endl;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 22024
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 100100100100100100
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> PLL;

int main() 
{
    int H,W,h,w;
    cin>>H>>W>>h>>w;

    cout << (H-h)*(W-w) << endl;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll a, b;
  cin >> a >> b;

  cout << (b - a) * (b - a + 1) / 2 - b << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

   int l = scan.nextInt();
  String str = scan.next();

  String str1 = "I";
  String str2 = "D";

  String[] strArray= new String[l];
  int x = 0;
 
 int tmp = x;
   
   
   for(int i = 0; i < l; i++){
   //String str3 = String.valueOf(str.charAt(i+1));
    if ((String.valueOf(str.charAt(i))).equals(str1) ){
      x += 1;
   }else{
      x -= 1;
   }

   tmp = Math.max(tmp, x);

}


  System.out.println(tmp);

    
  }
}

Measured memory_bytes: 21716
#include<stdio.h>
#include<iostream>
using namespace std;
int a[101][101];
int main()
{
	int m,f,r;
	while(1)
	{
		cin>>m>>f>>r;
		if(m==-1&&f==-1&&r==-1)
		{
			break;
		}
		if(m==-1||f==-1||m+f<30)
			cout<<'F'<<endl;
		else if(m+f>=80)
			cout<<'A'<<endl;
		else if(m+f>=65&&m+f<80)
			cout<<'B'<<endl;
		else if(m+f>=50&&m+f<65||m+f>=30&&m+f<50&&r>=50)
			cout<<'C'<<endl;
		else if(m+f>=30&&m+f<50)
			cout<<'D'<<endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define int long long
#define inf 1000000007
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
struct edge{int to,cost;};
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
int n,k,w[114514];
bool check(int num){
    int count=1;
    int wei=0;
    rep(i,0,n){
        if(wei+w[i]<=num)wei+=w[i];
        else {
            count++;
            wei=w[i];
        }
    }
    return count<=k;
}
signed main(){
    cin>>n>>k;
    int maxi=0;
    rep(i,0,n){
        cin>>w[i];
        maxi=max(maxi,w[i]);
    }
    int li=maxi-1,ans=inf;
    while(ans-li>1){
        int mid=(ans+li)/2;
        if(check(mid))ans=mid;
        else li=mid;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3872
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;


int main()
{
    int K, N;
    vector<int> A;

    cin >> K >> N;
    rep(i, N)
    {
        int a;
        cin >> a;
        A.emplace_back(a);
    }

    int length = 0;
    int* prev = &A[0];

    length = A[0] + K - A[N - 1];

    rep1(i, N)
    {
        if (length < abs(*prev - A[i]))
        {
            length = abs(*prev - A[i]);
        }

        prev++;
    }

    cout << K - length;

    return 0;
}

Measured memory_bytes: 1400
from sys import setrecursionlimit
#setrecursionlimit(10**5)
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納
        # par[x]=xの時そのノードは根　
        self.par = [i for i in range(n + 1)]
        # rank
        self.rank = [0] * (n + 1)
        self.size = [1] * (n + 1)

    def find(self, x):
        # 根の番号を返す(所属する集合を確認する)
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def check(self, x, y):
        # x,yが同じ集合に属するかどうか調べる
        return self.find(x) == self.find(y)


    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:return -1
        # rankの小さいものを大きいほうにくっつける
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            temp = self.size[x]
            self.size[y] += temp
            temp1 = self.size[y]
        else:
            self.par[y] = x
            temp = self.size[y]
            self.size[x] += temp
            temp1 = self.size[x]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        return (temp, temp1)

    def count_group(self):
        return len({self.find(x) for x in range(1, n + 1)})

n, m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]

uf = UnionFind(n)
inc = [n * (n - 1) // 2] * m
for i in range(m - 1):
    a, b = ab[- i - 1]
    rec = uf.union(a, b)
    if rec == -1:
        inc[-i-2] = inc[-i-1]
        continue

    temp = rec[1] - rec[0]
    inc[-i-2] = max(inc[-i-1] - temp * rec[0], 0)

    #print(uf.size,inc,rec,temp)
print(*inc, sep = '\n')


Measured memory_bytes: 96984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define fo(i,n) for(ll i=0;i<n;i++)
#define fok(i,k,n) for(ll i=k;i<n;i++)
#define ci(x) cin>>x
#define ci2(x,y) cin>>x>>y
#define co(x) cout<<x<<"\n"
#define co2(x,y) cout<<x<<" "<<y<<"\n"
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define deb1(x) cout<<#x<<" "<<x<<endl
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n"
#define deb3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n"
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;	
int gcd(int a, int b){ if(a==0) return b; return gcd(b%a, a);}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tc=1;
	//ci(tc);
	while(tc--){
		int n,x,t;
		cin>>n>>x>>t;
		int p = ceil((double)n/x);
		co((p*t));
	}
	return 0;
}


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

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

    string s, t;
    cin>>s>>t;
    int cnt = 0;
    for (int i=0; i<s.size(); i++){
        cnt += (s[i]!=t[i]);
    }
    cout<<cnt<<endl;
    return 0 ;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

// 素数列挙
vector<int> prime_list(int n) {
    vector<bool> is_prime(n + 1, true);
    vector<int> res;
    int i = 2;
    while (pow(i, 2) <= n) {
        if (is_prime[i]) {
            int j = i + i;
            while (j <= n) {
                is_prime[j] = false;
                j += i;
            }
        }
        i++;
    }
    for (int i = 0; i <= n; ++i) {
        if (is_prime[i] && i >= 2) {
            res.push_back(i);
        }
    }
    return res;
}

void Main() {
    ll N; cin >> N;
    vector<ll> x;
    for (auto a: prime_list(55555)){
        // cout << a << endl;
        if (a % 5 == 1){x.push_back(a);}
        if (x.size() >= N){break;}
    }
    for (auto a: x){cout << a << " ";}
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <utility>
#include <algorithm>
#include <set>
#include <queue>
#include <climits>
#include <limits>
#include <map>

#define ll long long
#define max(A, B) ((A) > (B) ? (A) : (B))
#define min(A, B) ((A) < (B) ? (A) : (B))
#define mp(A, B) make_pair(A, B)
#define pb push_back
#define fu(A, B, C) for(ll (A) = (B); (A) < (C); (A)++)
#define fu0(A, B) fu((A), 0, (B))
#define fd(A, B, C) for(ll (A) = (B); (A) >= (C); (A)--)
#define mem(A, B) memset((A), (B), sizeof((A)))
#define v(A, B, C) vector<ll> (A)((B), (C));
#define v0(A, B) v((A), (B), 0);


using namespace std;

typedef pair<int, int> pi;

void perform() {
  int n; cin >> n;
  cout << (2 * M_PI * n) << endl;
}

/*
int n; cin >> n;
cout << (2 * M_PI * n) << endl;
*/

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1; //cin >> t;
  fu0(i, t) {perform();}
}


Measured memory_bytes: 3256
//include
//------------------------------------------
#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>

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 vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//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(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
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;

int main(){
    int N;
    cin >> N;
    VI A(N);
    VI B(N);
    REP(i,N){
        cin >> B[i];
    }

    A[0]=B[0];
    A[1]=B[0];
    FOR(i,1,N-1){
        A[i+1]=B[i];
        if(A[i] > B[i]){
            A[i]=B[i];
        }
    }
    int sum = 0;
    REP(i,N){
        sum +=A[i];
    }

    cout << sum << endl;
}


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

#define ll long long
#define ull unsigned long long int
#define INF 0x3f3f3f3f
#define pb push_back
#define pii pair<int, int>

const int t = 100005;
int n, k, h[t];
int memo[t];

int solve(int id) {
    if (id >= n) return INF;
    if (id == n - 1) return 0;
    int &ans = memo[id];
    if (ans != -1)
        return ans;
    ans = INF;
    for (int i = 1; i <= k; i++) {
        ans = min(ans, solve(id + i) + abs(h[id] - h[id + i]));
    }
    return ans;
}

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

    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> h[i];
    memset(memo, -1, sizeof memo);
    cout << solve(0) << "\n";
    
    //cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
	string input;

	while( cin >> input ){
		int answer[10][10];
		for( int i = 0;i < 10;i++ ){
			for( int j = 0;j < 10;j++ ){
				answer[i][j] = 0;
			}
		}

		for( int i = 0;i < 10;i++ ){
			answer[0][i] = input[i] - '0';
		}

		for( int i = 9;i > 0;i-- ){
			for( int j = 0;j < i;j++ ){
				answer[10 - i][j] = answer[9 - i][j] + answer[9 - i][j + 1];
				int a = answer[10 - i][j];
				a /= 10;
				a *= 10;
				answer[10 - i][j] -= a;
			}
		}

		cout << answer[9][0] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
from collections import deque

k = int(input())

q = deque()

for i in range(1, 10):
    q.append(i)

for _ in range(k):
    temp = q.popleft()
    if temp % 10 != 0:
        q.append(temp*10+int(str(temp)[-1])-1)
    
    q.append(temp*10+int(str(temp)[-1]))

    if temp % 10 != 9:
        q.append(temp*10+int(str(temp)[-1])+1)

print(temp)

Measured memory_bytes: 11964
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		if(n>=k) {
		System.out.println(x*k + (n-k)*y);
	}else {
	System.out.println(n*x);

	}
	}
}


Measured memory_bytes: 21716
#![allow(unused_imports)]
#![allow(non_snake_case)]

use procon::*;
use std::cmp::{max, min};
use std::collections::*;
use std::ops::*;
use std::*;

pub fn main() {
    let (N, x) = {
        let words = read_words::<usize>();
        (words[0], words[1] as i64)
    };
    let mut A = read_words::<i64>();

    let mut count = 0_i64;
    for i in 1..N {
        let y = A[i] + A[i - 1];

        // 食べる個数
        let z = max(0, y - x);

        // i 番目から食べる個数
        let az = min(A[i], z);

        // (i - 1) 番目から食べる個数
        let bz = z - az;

        A[i] -= az;
        A[i - 1] -= bz;

        count += z;
    }
    println!("{}", count);

    return;
}

pub mod procon {
    use std;
    use std::collections::*;
    use std::io;
    use std::mem;
    use std::str::FromStr;

    pub fn read_line() -> String {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.trim_right().to_owned()
    }

    pub fn read_words<T>() -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.split_whitespace()
            .map(|word| T::from_str(word).unwrap())
            .collect()
    }

    pub fn read_vec(len: usize) -> Vec<String> {
        let mut vec = Vec::new();
        while vec.len() < len {
            let line = read_line();
            for word in line.split_whitespace() {
                vec.push(word.to_owned());
            }
        }
        assert!(vec.len() == len);
        vec
    }
}


Measured memory_bytes: 8444
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

	static Scanner scan = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		sieve();
		while(true){
			int n = si();
			if(n==0) break;
			int cnt = 0;
			for (int i = 0; prime[i] <= n/2; i++) {
				if(is_prime[n-prime[i]]) cnt++;
			}
			out.println(cnt);
		}
		out.flush();
	}

	static final int N = (int)Math.pow(2,15)+1;
	static boolean[] is_prime = new boolean[N + 1];
	static int[] prime = new int[N];

	static void sieve() {
		int p = 0;
		for (int i = 0; i <= N; i++)
			is_prime[i] = true;
		is_prime[0] = is_prime[1] = false;
		for (int i = 2; i <= N; i++) {
			if (is_prime[i]) {
				prime[p++] = i;
				for (int j = 2 * i; j <= N; j += i)
					is_prime[j] = false;
			}
		}
	}

	static int si() {
		return Integer.parseInt(scan.next());
	}
}

Measured memory_bytes: 19976
loop do
  raw_a = gets
  raw_b = gets
  break if raw_a == nil || raw_b == nil

  a = raw_a.split.map(&:to_i)
  b = raw_b.split.map(&:to_i)

  hits, misses = a.zip(b).partition{|n, m| n == m}

  n_hits  = hits.size
  n_brows = misses.select{|n, m| a.include?(m)}.size
  puts "#{n_hits} #{n_brows}"
end

Measured memory_bytes: 8596
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <math.h>
# include <algorithm>
using namespace std;
# define pi acos(-1.0)
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
typedef long long LL;
typedef unsigned long long ULL;

int main()
{
    int a[7]= {1,3,5,7,8,10,12},b[4]= {4,6,9,11},c[1]= {2};
    int x,y,flag=0;
    cin>>x>>y;
    if(x==1||x==3||x==5||x==7||x==8||x==10||x==12)
    {
        if(y==1||y==3||y==5||y==7||y==8||y==10||y==12)flag=1;
    }
    else if(x==4||x==6||x==9||x==11)
    {
        if(y==4||y==6||y==9||y==11)flag=1;
    }
    else if(x==2&&y==2)flag=1;
    if(flag==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}





















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,a) for(int i=0;i<(a);i++)
#define MOD 1000000007

ll a[100000], K;

bool f(ll x){
  for(int i=0;i<K;i++){
    if(x<a[i]) return 0;
    x-=x%a[i];
  }
  if(x==2) return 1;
  else return 0;
}

int main(){
  cin>>K;
  for(int i=0;i<K;i++) cin>>a[i];
  ll l=2, r=3;
  for(int i=K-1;i>=0;i--){
    l=(l+a[i]-1)/a[i]*a[i];
    r=(r+a[i]-1)/a[i]*a[i];
  }
  if(!f(l)){
    cout<<-1<<endl;
    return 0;
  }
  cout<<l<<" "<<r-1<<endl;
  return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = input().split()
a = [int(m) for m in a]

a.sort(reverse=True)

ali = []
bli = []

for i in range(n):
    if i % 2 == 0:
        ali.append(a[i])
    else:
        bli.append(a[i])
print(sum(ali) - sum(bli))

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x * x + y * y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;

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

	cout << (N - 2) * 180 << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;

int main(){
     
    int x;
    
    cin>>x;
    if(x<1200)cout<<"ABC"<<endl;
    else cout<<"ARC"<<endl;
     
    return 0;
}
 

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll dp[100010][13];

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

  ll n;
  const ll m=13;
  string s;
  cin>>s;
  n=s.size();
  dp[0][0]=1;
  rep(i,n)rep(j,m){
    if(s[i]=='?'){
      rep(k,10){
        ll r=(j*10+k)%m;
        (dp[i+1][r]+=dp[i][j])%=mod;
      }
    }else{
      ll r=(j*10+s[i]-'0')%m;
      (dp[i+1][r]+=dp[i][j])%=mod;
    }
  }

  cout<<dp[n][5]<<endl;

  return 0;
}


Measured memory_bytes: 10704
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
const int INF=1e9;
int main()
{
    int h,w,sx,sy,gx,gy;
    cin>>h>>w>>sx>>sy>>gx>>gy;
    sx--;
    sy--;
    gx--;
    gy--;
    vector<vector<char>> map(h,vector<char> (w));
    vector<vector<int>> d(h,vector<int>(w,INF));
    rep(i,h) rep(j,w) cin>>map[i][j];
    const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
    deque<P> que;//場所
    que.emplace_front(P(sx,sy));
    d[sx][sy]=0;//コスト
    while(que.size()){
        int qx=que.front().first,qy=que.front().second;
        que.pop_front();
        for(int i=0;i<4;i++){
            int nx=qx+dx[i],ny=qy+dy[i];
            if(0<=nx&&nx<h&&0<=ny&&ny<w&&map[nx][ny]!='#'&&d[nx][ny]>d[qx][qy]){
                d[nx][ny]=d[qx][qy];
                que.emplace_front(P(nx,ny));
            }
        }
        for(int i=-2;i<=2;i++){
            for(int j=-2;j<=2;j++){
                int nx=qx+i,ny=qy+j;
                if(0<=nx&&nx<h&&0<=ny&&ny<w&&map[nx][ny]!='#'&&d[nx][ny]>d[qx][qy]+1){
                    d[nx][ny]=d[qx][qy]+1;
                    que.emplace_back(P(nx,ny));
                }
            }
        }
    }
    int ans=d[gx][gy];
    if(ans==INF) cout<<"-1";
    else cout<<ans;
}

Measured memory_bytes: 8604
S = input()

s = S.replace('<>', '<,>').replace('><', '>,<').split(',')
lst = [ss.count('<') - ss.count('>') for ss in s]

ans = [0]

for i in lst:
    if i > 0:
        ans += list(range(1,i+1))
    else:
        ans[-1] = max(ans[-1], -i)
        ans += list(range(-i-1,-1, -1))

print(sum(ans))


Measured memory_bytes: 27400
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
const long INF = 1e9;
const long MOD = 1e9 + 7;
#define repi(i, n, init) for (int i = init; i < int(n); i++)

int main()
{
    int W, a, b;
    cin >> W >> a >> b;
    if (a <= b)
    {
        cout << max(0, b - W - a) << endl;
        return 0;
    }
    else
    {
        cout << max(0, a - b - W) << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
using P = pair<int, int>;
const long long INF = 1LL << 60;

int main(){
  int N; cin >> N;
  vector<int> t(N),x(N),y(N);
  rep(i,N){
    cin >> t[i] >> x[i] >> y[i];
  }
  //現在地と現在時間の初期化
  int current_x = 0, current_y = 0,current_t = 0;
  rep(i,N){
    //移動量moveと移動時間move_t
    int move = abs(x[i]-current_x)+abs(y[i]-current_y);
    int move_t = t[i] - current_t;
    //そもそもそこに行くまでに時間が足りているか確認
    if(move <= move_t){
      //移動量moveと移動時間move_tがどちらも偶数もしくは奇数でないと到達不可能
      if(move%2 != move_t%2){
        cout << "No" << endl;
        return 0;
      }
    }else{
      cout << "No" << endl;
      return 0;
    }
    current_x = x[i]; current_y = y[i]; current_t = t[i];
  }
  cout << "Yes" << endl;
  return 0;
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int cnt[201010];
int main(){
    string s;
    cin >> s;

    ll ans = 0;
    int cu=0;int dg=1;
    REPR(i,s.size()-1){
       cu = (cu+dg*(s[i]-'0'))%2019;
       dg = (dg*10)%2019;
       ans += cnt[cu];
       if(cu==0)ans++;
       cnt[cu]++;
    }
    COUT(ans);
    return 0;
}

Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
using namespace std;

int main() {
	string ans;
	cin >> ans;
	for (int i = 0; i < 19; i++) {
		if (i != 5 && i != 13) {
			cout << ans[i];
		}
		else {
			cout << ' ';
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    x = kwargs["x"]
    res = 1 - x
    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    kwargs["x"] = [int(i) for i in cin][0]

    cout = main(kwargs)
    print(cout)

Measured memory_bytes: 31176
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    string s;
    cin >> s;
    int a, b, c, d;
    a = (int)(s[0] - '0');
    b = (int)(s[1] - '0');
    c = (int)(s[2] - '0');
    d = (int)(s[3] - '0');
    for(int mask = 0; mask < (1 << 3); mask++){
        int num = a;
        if(mask & (1 << 0)) num -= b;
        else num += b;

        if(mask & (1 << 1)) num -= c;
        else num += c;

        if(mask & (1 << 2)) num -= d;
        else num += d;
        
        if(num == 7){
            cout << a;

            if(mask & (1 << 0)) cout << '-';
            else cout << '+';
            
            cout << b;

            if(mask & (1 << 1)) cout << '-';
            else cout << '+';
            
            cout << c;

            if(mask & (1 << 2)) cout << '-';
            else cout << '+';

            cout << d << "=7" << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;

int main()
{
    int N;

    if (scanf("%d", &N) < 1) return 0;

    char s[101];
    char t[101];

    if (scanf("%s", s) < 1) return 0;
    if (scanf("%s", t) < 1) return 0;

    int match = 0;
    int tmp = 0;
    for (int i = 0; i < N; i++)
    {
        if (tmp == N) break;
        tmp = i;
        for (int j = 0; j < N; j++)
        {
            if (j == 0) match = 0;
            if (s[tmp] != t[j]) break;
            else
            {
                tmp++;
                match++;
            }
        }
    }

    printf("%d\n", 2 * N - match);
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
bool chmax(T &a, const T &b) {if (a < b){ a = b; return 1;} return 0;}
template <class T>
bool chmin(T &a, const T &b) {if (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int N;
    cin >> N;

    vi p(N);

    REP(i,N) cin >> p[i];

    bool ok = true;
    REP(t,N-1) if (p[t] > p[t+1]) ok = false;
    if (ok) {
        cout << "YES" << endl;
        return 0;
    }
    vi c(N);

    REP(i,N) REP(j,N) {
        if (i == j) continue;
        copy(ALL(p),c.begin());

        c[j] = p[i];
        c[i] = p[j];

        ok = true;
        REP(t,N-1) if (c[t] > c[t+1]) ok = false;
        //printv(c);

        if (ok) {
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;


ll N,P;


int main()
{
    cin >> N >> P;
    
    map<ll,ll> A;
    ll PP = P;
    for (ll i = 2; i*i <= P; i++) {
        if(PP%i==0){
            A[i]++;
            PP /= i;
            while (PP%i == 0) {
                A[i]++;
                PP/=i;
            }
        }
        
    }
    A[PP]++;
    ll ans = 1;
    //for (auto p : A) cout << p.first << " - " << p.second << endl;
    
    for (auto p : A) if(p.second >= N) {
        while (p.second >= N) {
            p.second -= N;
            ans*=p.first;
        }
    }
    cout << ans << endl;
    
    
    return 0;
}



Measured memory_bytes: 256
n, x, y = map(int, input().split())
li = [0] * (n-1)
num=0
for i in range(1, n+1):
  for j in range(i+1, n+1):
    num = min(j-i, abs(x-i)+abs(y-j)+1)
    li[num-1] += 1
for i in li:
  print(i)

Measured memory_bytes: 3572
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
void solve(){
  ll n;
  cin >> n;
  ll r_feet,l_feet,next=1,cnt=0;
  r_feet=l_feet=0;
  if(n==0) return;
  string s[n];
  for(int i=0;i<n;i++){
    cin >> s[i];
    if(s[i][0]=='l'){
      l_feet=(l_feet+1)%2;
    }else{
      r_feet=(r_feet+1)%2;
    }
    if(next==1&&r_feet==1&&l_feet==1){
      cnt++;
      next=0;
    }else if(next==0&&r_feet==0&&l_feet==0){
      cnt++;
      next=1;
    }
  }
  cout << cnt << endl;
  solve();
}
signed main(){
  solve();
}



Measured memory_bytes: 3632
# 入力
input_int = lambda:int(input())
input_ints = lambda:map(int,input().split())
input_str = lambda:input()
input_strs = lambda:input().split()
input_lines = lambda n,f:[f() for _ in range(n)]

import functools,fractions
import numpy as np
gcd = lambda a:functools.reduce(fractions.gcd,a) # 最大公約数（リスト）
lcm_base = lambda a,b:(a*b)//fractions.gcd(a,b) # 最小公倍数(2値)
lcm = lambda a:functools.reduce(lcm_base,a,1) # 最小公倍数(リスト)

def solution():
    N = input_int()
    As = input_ints()
    ans = gcd(As)
    print(ans)

if __name__ == '__main__':
    solution()

Measured memory_bytes: 21064
function Main(inputs) {
	const inputline = inputs.split("\n").map(x => parseInt(x, 10));
  	const line = inputline[0];
  
  	function base26(number) {
    	　let remainder26 = number % 26;
    	　let division26 = Math.floor(number / 26) ;
    	　let output = (remainder26 != 0) ? String.fromCharCode(64 + remainder26) : (--division26, 'Z');
      	　return output = (division26 != 0) ? base26(division26) + output : output;
	}
  
  	console.log(base26(line).toLowerCase());
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define scd second
#define fst first
#define pb push_back
#define mkp make_pair
#define all(x) x.begin(), x.end()
#define VT(T) vector<T>

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
typedef vector<ll> vlong;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vint> vvint;
typedef vector<vlong> vvlong;
typedef list<int> lint;
typedef list<ll> llong;
typedef list<pii> lpii;
typedef list<pll> lpll;
typedef list<lint> llint;
typedef list<llong> lllong;

int const N=1e6+100;
ll const LINF=numeric_limits<long long int>::max();
int const INF=numeric_limits<int>::max();
int const BN = 31;

ll gcd(ll a, ll b){
	return b ? gcd(b,a%b) : a;
}

ll pow_mod(ll a, ll e, ll m){
	ll res=1;
	while(e){
		if(e&1) res=res*a%m;
		a=a*a%m;
		e>>=1;
	}
	return res;
}

ll inv_mod(ll b, ll m){
	b%=m;
	ll x=0, y=1, r, q, a=m;
	while(b){
		q=a/b;
		r=a%b;
		a=b;
		b=r;
		r=x;
		x=y;
		y=r-q*y;
	}
	x+=m;
	return x%m;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	string s, t;
	cin>>s>>t;
	cout<<(s[0]==t[0])+(s[1]==t[1])+(s[2]==t[2])<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int height[10];
	int x;

	for(int i=0;i<10;i++){
		cin >> height[i];
		}

	for(int j=10;j>0;j--){
		for(int i=10;i>0;i--){
			if(height[i]>height[i-1]){
				x=height[i-1];
				height[i-1]=height[i];
				height[i]=x;
			}
		}
	}

	for(int i=0;i<3;i++){
		cout << height[i] <<endl;
	}
	return 0;
}

Measured memory_bytes: 0
def bfs(i)
  q = [i]
  m = 0
  while q != []
    f = q.first
    if $m[f]
      $m[f].each do |val|
        if $check[val] == 0
          q.push(val)
          $check[val] = 1
          m += 1
        end
      end
    end
    q.shift
  end
  return m
end
ma = 1

N, M = gets.split(" ").map(&:to_i)
$m = [[]]
$check = [0] * (N+1)
M.times do
  a, b = gets.split(" ").map(&:to_i)
  if $m[a]
    $m[a].push(b)
  else
    $m[a] = [b]
  end
  if $m[b]
    $m[b].push(a)
  else
    $m[b] = [a]
  end
end
1.upto(N) do |i|
  if $check[i] == 0
    ma = [ma, bfs(i)].max
  end
end
puts ma

Measured memory_bytes: 32580
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    int ans = 0;
    string plus = "+";
    string minus = "-";
    string str;
    cin >> str;
    for(int i=0;i<4;i++){
        if(str.compare(i,1,plus)==0){
            ans ++;
        }else{
            ans --;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
K,S=map(int,input().split())
count=0
for i in range(0,K+1):
    if i<=S:
        if max(S-2*i,0)<=2*K:
            for j in range(0,K+1):
                if (S-i-j<=K)&(0<=S-i-j):
                    count=count+1
print(count)

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

int main(){
    ll N; cin >> N;
    string s; cin >> s;

    bool ok = true;
    if(N % 2){
        cout << "No" << endl;
        return 0;
    }else{
        rep(i,N/2){
            if(s[i] != s[N/2+i]) ok = false;
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main(){
string s;
cin>>s;
ll n;
if(s=="RRR")n=3;
else if(s=="RRS")n=2;
else if(s=="SRR")n=2;
else if(s=="RSR")n=1;
else if(s=="RSS")n=1;
else if(s=="SRS")n=1;
else if(s=="SSR")n=1;
else if(s=="SSS")n=0;

cout<<n<<endl;


}

Measured memory_bytes: 3624