akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

signed main(){
    int x[10];
    REP(i, 5) cin >> x[i];
    REP(i, 5){
        if(x[i] == 0){
            PRINT(i + 1);
        }
    }
    return 0;
}

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

int main()
{
    ll n,x;
    string s;
    cin>>x>>s;
    n = s.size();
    x%=26;
    ll i;
  
    for(i=0;i<n;i++)
    {
        if((s[i] + x)>'Z')
            s[i] = 'A' + x - ('Z' - s[i]) - 1;
        else
            s[i] = s[i] + x;
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pf push_front
#define pii pair <int, int>
#define all(vv) (vv).begin(), (vv).end()
#define time cerr << '\n' << (double)clock()/CLOCKS_PER_SEC << '\n'; return 0

int n, x;
map <int, int> mp;
int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int ans = 0;
	cin >> n;
	for(int i = 0; i < n; ++i) {
		cin >> x; ++mp[x];
	}
	for(auto it:mp) {
		if (it.second < it.first) ans += it.second;
		else ans += it.second - it.first;
	}
	cout << min(ans, n);
	time;
}

Measured memory_bytes: 9716
import java.io.BufferedReader
import java.util.*
import kotlin.math.min

fun main() = abc073d()

@OptIn(ExperimentalStdlibApi::class)
fun abc073d() = SimpleFastIOWithToken_abc073d().exec {
    data class Line(val first: Int, val second: Int, val weight: Long)

    val (n, m, r) = List(3) { readInt() }
    val rList = List(r) { readInt() - 1 }
    val lines = List(m) { Line(readInt() - 1, readInt() - 1, readLong()) }

    val distances = Array(n) { LongArray(n) { Long.MAX_VALUE / 10000 } }
    lines.forEach { (first, second, weight) ->
        distances[first][second] = weight
        distances[second][first] = weight
    }

    for (k in 0 until n) for (i in 0 until n) for (j in 0 until n) {
        distances[i][j] = min(distances[i][j], distances[i][k] + distances[k][j])
    }

    val answer = permutations(rList).map { visitOrder ->
        (0 until r - 1).map { distances[visitOrder[it]][visitOrder[it + 1]] }.sum()
    }.min()!!

    println(answer)
}

private fun permutations(src: List<Int>): List<List<Int>> {
    if (src.size == 1) return listOf(src)
    val perms = mutableListOf<List<Int>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for (i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// region kokokara template dayo (^o^)
@Suppress("unused", "HasPlatformType", "MemberVisibilityCanBePrivate", "ClassName")
private class SimpleFastIOWithToken_abc073d(private val separator: String = System.lineSeparator()) {
    private val br: BufferedReader = System.`in`.bufferedReader()
    private var st: StringTokenizer = StringTokenizer("")
    private val sb: StringBuilder = StringBuilder()
    private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }

    fun readString(): String = run { prepareNext() }.run { st.nextToken() }
    fun readInt(): Int = Integer.valueOf(readString())
    fun readLong(): Long = java.lang.Long.valueOf(readString())

    fun println(): Unit = run { sb.append(separator) }
    fun print(any: Any): Unit = run { sb.append(any) }
    fun println(any: Any): Unit = run { sb.append(any.toString() + separator) }

    fun exec(action: SimpleFastIOWithToken_abc073d.() -> Unit) {
        var t: Throwable? = null
        Thread(null, { action() }, "solve", 128 * 1024 * 1024)
            .apply { setUncaughtExceptionHandler { _, t1 -> t = t1 } }
            .apply { start() }.join()
        t?.let { throw it }
        kotlin.io.print(sb)
    }

    fun readLine(): Nothing = error("readLine is disabled.")
}
// endregion kokomade template dayo (^o^)


Measured memory_bytes: 64752
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    int N, res, next; cin >> N;
    int a[N];
    res = next = 0;
    for (int i = 0; i < N; i++){ cin >> a[i]; }
    while(true)
    {
        res++;
        if (res > N_MAX)
        {
            res = -1;
            break;
        }
        if (a[next] == 2)
        {
            break;
        }
        next = a[next] - 1;
    }
    cout << res << endl;
	return 0;
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pi acos(-1)
#define mod 1000000007
#define all(x) x.begin(), x.end()
using namespace std;

ll ans[100000];

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

    int tc = 1;
    //cin >> tc;
    while(tc--){
        int n;
        cin >> n;
        for(int i = 1; i <= 100; i++){
            for(int j = 1; j <= 100; j++){
                for(int k = 1; k <= 100; k++){
                    ll val = i*i + j*j + k*k + i*j + j*k + i*k;
                    ans[val]++;
                }
            }
        }
        for(int i = 1; i <= n; i++){
            cout << ans[i] << endl;
        }
    }
}



Measured memory_bytes: 4152
# encode: utf-8

def selectionSort(A, N):
    count = 0
    for i in xrange(0, N):
        minj = i
        for j in xrange(i, N):
            if A[j] < A[minj]:
                minj = j
        if i != minj:
            A[i] , A[minj] = A[minj], A[i]
            count += 1
    return A, count

def main():
    n = input()
    a = map(int, raw_input().split())
    a, count = selectionSort(a, n)
    print " ".join(map(str, a))
    print count

main()

Measured memory_bytes: 6400
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    
    int a[N][3];
    long int dp[N][3];
    for(int i=0; i<N; i++) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
        dp[i][0]=0;
        dp[i][1]=0;
        dp[i][2]=0;
    }
    
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    
    for(int i=1; i<N; i++) {
        // cout << i << " :" << endl;
        for(int j=0; j<3; j++) {
            for(int k=0; k<3; k++) {
                if(k==j) continue;
                // cout << dp[i][j] << " " << dp[i-1][j]+a[i][k] << " a " << a[i][k] << " ";
                dp[i][k] = max(dp[i][k], dp[i-1][j]+a[i][k]);
            }
            // cout << " max " << dp[i][j];
            // cout << endl;
        }
        // cout << endl;
    }
    
    long int ans=dp[N-1][0];
    for(int i=1; i<3; i++) {
        ans = max(ans, dp[N-1][i]);
    }
    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	string s;
	lint red=0,blue=0;
	cin>>s;
	each(it,s){
		if(*it=='0')red++;
		else blue++;
	}
	cout<<min(red,blue)*2<<"\n";
}

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

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)

main(){
  string s; cin >> s;
  int n = s.size();

  bool f = false;
  if(s[0] == '0' or s[n-1] == '1') f = true;
  rep(i,n/2)
    if(s[i] != s[n-i-2]) f = true;
  if(f){
    cout << -1 << endl;
    return 0;
  }

  int k = n;
  ROF(i,n-1,0){
    cout << i+1 << " " << k << endl;
    if(s[i] == '1') k = i + 1;
  }
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <limits>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define fi(i, n) for( int i=0 ; i<n ; i++ )
#define f(i, a, b) for( int i=a ; i<b ; i++ )
#define vi vector<int>
#define pb push_back
#define MOD 1000000007
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
ll fact(ll n)
{
    ll ans = 1e14;
    for(ll i = 1; i<=sqrt(n); i++)
    {
        if(n%i==0)
        {
            ll sol = (i - 1) + (n/i - 1);
            ans = min(ans,sol);
        }
    }
    return ans;
}
int visited[200000] = {0};
vector<vector<int> > v(200000);
int dfs(int x)
{
    int ans = 0;
    if(visited[x]==0)
    {
        visited[x] = 1;
        ans++;
        int a = v[x].size();
        for(int j = 0; j<a; j++)
        {
            int data = v[x][j];
            ans = ans + dfs(data);
        }
    }
    return ans;
}
void primefactors(int n)
{
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            cout << i << " ";
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        cout << n << " ";

}
double fib(int n)
{
    double sol1,sol2;
    sol1 = (1 + sqrt(5))/2;
    sol2 = (1 - sqrt(5))/2;
    sol1 = pow(sol1,n);
    sol2 = pow(sol2,n);
    double ans = sol1 - sol2;
    ans = ans/sqrt(5);
    //ans = int(ans);
    return ans;
}

ll digits(ll n)
{
    return floor(log10(double(n))) + 1;
}

ll index(ll n)
{
    n = double(n);
    double sol = n*n + n;
    sol = sol*2 + 1;
    double ans = -1 + sqrt(sol);
    ans = ans/2;
    ans = ll(ans);
    return ans;
}
int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans = a*c;
    ans = max(ans,b*c);
    ans = max(ans,a*d);
    ans = max(ans,b*d);
    cout<<ans;

}


Measured memory_bytes: 7828
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int n, a, b;
    cin >> n >> a >> b;

    int sum = 0;
    
    
    for(int i = 1; i <= n; i++){
        
        int tt = i/10000;
        int th = (i % 10000)/1000;
        int hu = (i % 1000)/100;
        int ty = (i % 100)/10;
        int tmp = tt + th + hu + ty+ (i % 10);
        
        if(a <= tmp && tmp <= b){
            sum = sum + i;
        }
    }
    
    // 出力
    cout << sum << endl;
    return 0;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  string s;
  cin >> s;
  while(!s.empty()){
    s.pop_back();
    if(s.size()%2!=0)continue;
    ll t = s.size()/2;
    if(s.substr(0, t)==s.substr(t,t)){
      break;
    }
  }
  cout << s.size();
  return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#define INF (2 << 28)
using namespace std;

int main(){
    
    int n, m, cost[101][101];
    
    while(cin >> n >> m, n||m){
        fill_n(*cost, 101*101, INF);
        for(int i = 1; i <= n; i++) cost[i][i] = 0;
        while(m--){
            int k; cin >> k;
            if(k == 0){
                int a, b; cin >> a >> b;
                cout << (cost[a][b] == INF ? -1 : cost[a][b]) << endl;
            } else {
                int a, b, c; cin >> a >> b >> c;
                cost[a][b] = cost[b][a] = min(cost[a][b], c);
                for(int i = 1; i <= n; i++){
                    for(int j = 1; j <= n; j++){
                        cost[i][j] = min(cost[i][j], cost[i][a] + cost[a][b] + cost[b][j]);
                        cost[i][j] = min(cost[i][j], cost[i][b] + cost[b][a] + cost[a][j]);
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 1200
n = int(input())
h = list(map(int,input().split()))

ans = 0

for j in range (max(h)):
  flag =0 
  
  for i in range(n):
    if h[i]==0 and flag ==0:
      flag=1
      
    if not(h[i]==0) and flag ==1:
      ans +=1
      flag =0

  if h[0]==0:
    ans -=1
  for i in range(n):
    h[i] = max(h[i]-1,0)
  ans +=1

print(ans)



Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    int N,K;
    cin >> N >> K;
    
    int ans = 1;
    for(int i=0;i<N;i++){
        if(ans<K){
            ans *= 2;
        }else{
            ans += K;
        }
    }
    
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
    
        var sc = new Scanner(System.in);
    
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        int ch = Integer.parseInt(sc.next()) -1;
        int cw = Integer.parseInt(sc.next()) -1;
        int dh = Integer.parseInt(sc.next()) -1;
        int dw = Integer.parseInt(sc.next()) -1;
        char[][] s = new char[h][w];
        for(int i = 0; i < h; i++){
            s[i] = sc.next().toCharArray();
        }
    
        int[] dx = {-1, 1, 0, 0};
        int[] dy = {0, 0, -1, 1};
        int[] dx2 = {-2, -1,  0,  1,  2, -2, -1,  1,  2, -2, 2, -2, -1, 1, 2, -2, -1, 0, 1, 2};
        int[] dy2 = {-2, -2, -2, -2, -2, -1, -1, -1, -1,  0, 0,  1,  1, 1, 1,  2,  2, 2, 2, 2};
        
        var warp = new int[h][w];
        for(int i = 0; i < h; i++){
            Arrays.fill(warp[i], -1);
        }
        warp[ch][cw] = 0;
        var queue = new ArrayDeque<Pair>();
        queue.add(new Pair(cw, ch));
        var done = new boolean[h][w];
        done[ch][cw] = true;
        int warpCount = 0;
        while(!queue.isEmpty()){
            var set = new HashSet<Integer>();
            while(!queue.isEmpty()){
                int x = queue.peek().x;
                int y = queue.poll().y;
                for(int i = 0; i < 4; i++){
                    int nx = x + dx[i];
                    int ny = y + dy[i];
                    if(nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
                    if(warp[ny][nx] == -1 && s[ny][nx] == '.'){
                        warp[ny][nx] = warp[y][x];
                        queue.add(new Pair(nx, ny));
                        done[ny][nx] = true;
                    }
                }
                for(int i = 0; i < 20; i++){
                    int nx = x + dx2[i];
                    int ny = y + dy2[i];
                    if(nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
                    if(!done[ny][nx]){
                        set.add(nx*10000 + ny);
                    }
                }
            }
            warpCount++;
            for(Integer i : set){
                int x = i / 10000;
                int y = i % 10000;
                if(!done[y][x]){
                    done[y][x] = true;
                    if(s[y][x] == '.'){
                        warp[y][x] = warpCount;
                        queue.add(new Pair(x, y));
                    }
                }
            }
        }
        System.out.println(warp[dh][dw]);
    }
    
    static class Pair {
        int x, y;
        
        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }
}

Measured memory_bytes: 67912
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  for(auto c:S){
    cout<<(char)((c-'A'+N)%26+'A');
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
 
	// ??°????????\???????????°
	int height, width;
 
	// ???????????????
	while(1) {
		
		scanf("%d %d", &height, &width);
		
		if(height == 0 && width == 0)
			break;
			
		for(int line = 1; line <= height; line++) {
			
			for(int column = 1; column <= width; column++) {
				
				if(column % width == 0) {
				
				printf("#\n");
				
				} else {
				
				printf("#");
				}
			}
		}
		printf("\n");
	}
  	return 0;
}

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

int ns, nt, l = 0;
char s[3005], t[3005], ans[3005];
int dp[3005][3005];
//dp(i,j) = max(dp(i-1, j), dp(i, j-1), dp(i-1,j-1) + 1 if s[i] == t[j]);
void solve(){
	for (int i = 1; i <= ns; i++){
		for (int j = 1; j <= nt; j++){
			dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			if (s[i] == t[j])
				dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1);
		}
	}
//	printf("%d\n", dp[ns][nt]);
	int a = ns, b = nt;
	l = 0;
	while (a && b){
		if (s[a] == t[b]){
			ans[l++] = s[a--]; b--;
		} else {
			if (dp[a][b] == dp[a-1][b]) a--;
			else b--;
		}
	}
	reverse(ans, ans+l);
	ans[l] = '\0';
	puts(ans);
}
int main(){
	scanf("%s %s", s+1, t+1);
	ns = strlen(s+1);
	nt = strlen(t+1);
	solve();
	return 0;
}


Measured memory_bytes: 35456
n = int(input())
num_list = list(map(int, input().split()))

Alice = 0
Bob = 0

for i in range(n):
    current_max = max(num_list)
    if i % 2 == 0:
        Alice += current_max
    else:
        Bob += current_max
    num_list.remove(current_max)

print(Alice - Bob)


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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	string ans;
	if( a == 1 && b == 0 && c == 0 ) ans = "Close";
	else if( a == 0 && b == 1 && c == 0 ) ans = "Close";
	else if( a == 1 && b == 1 && c == 0 ) ans = "Open";
	else if( a == 0 && b == 0 && c == 1 ) ans = "Open";
	else if( a == 0 && b == 0 && c == 0 ) ans = "Close";
	cout << ans << endl;
}

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

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

	int sum = 0;
	for (int i = 0; i < n + 1; i++) {
		sum += abs(a[i + 1] - a[i]);
	}

	for (int i = 1; i <= n; i++) {
		cout
				<< sum - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i])
						+ abs(a[i + 1] - a[i - 1]) << endl;
	}
}


Measured memory_bytes: 1664
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0
inf = float("inf")

n,m=I()
print(((n-m)*100+1900*m)*(2**m))


Measured memory_bytes: 9864
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T & a, const T & b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/


int cnt[15][15];

pii calcDigit(int n) {

	pii num;
	num.first = n % 10;
	while (n / 10) {
		n /= 10;
	}
	num.second = n;
	return num;
}

int main() {

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


	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		int head = 0;
		int tail = 0;
		tie(head, tail) = calcDigit(i);
		cnt[head][tail]++;
	}

	int ans = 0;
	for (int i = 0; i <= 9; i++)
	{
		for (int j = 0; j <= 9; j++)
		{
			ans += cnt[i][j] * cnt[j][i];
		}
	}

	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()

	r := sc.ReadInt()

	fmt.Println(math.Pi * float64(r) * 2)
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Abs64(x int64) int64 {
	if x >= 0 {
		return x
	}
	return -x
}

func Min64(values ...int64) int64 {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max64(values ...int64) int64 {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow64(base int64, exponent uint) int64 {
	answer := int64(1)
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *Scanner) ReadInt64() int64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseInt(text, 10, 64)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 1756
#[allow(unused_imports)]
use std::cmp::max;
#[allow(unused_imports)]
use std::fmt;
#[allow(unused_imports)]
use std::fmt::Debug;
#[allow(unused_imports)]
use std::io;
#[allow(unused_imports)]
use std::str::FromStr;

fn main() {
    let n: usize = get_vec_input()[0];
    let mut taro_point = 0;
    let mut hana_point = 0;
    for _ in 0..n {
        let input: Vec<String> = get_vec_input();
        let taro = &input[0].to_string();
        let hana = &input[1].to_string();

        if taro > hana {
            taro_point += 3;
        } else if hana > taro {
            hana_point += 3;
        } else {
            taro_point += 1;
            hana_point += 1;
        }
    }
    println!("{} {}", taro_point, hana_point);
}

#[allow(dead_code)]
fn sum_digit2(value: String) -> u32 {
    return value.chars().fold(0u32, |a, b| a + b.to_digit(10).unwrap());
}

#[allow(dead_code)]
fn sum_digit(value: i64) -> i64 {
    if value < 10 {
        return value;
    }
    return sum_digit(value / 10) + value % 10;
}

#[allow(dead_code)]
fn update_max<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left < right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn update_min<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left > right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn get_vec_input<T>() -> Vec<T>
where
    T: FromStr,
    T::Err: Debug,
{
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");
    let vec: Vec<T> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    vec
}

#[allow(dead_code)]
fn get_tuple_input() -> (u64, f32) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    let c: u64 = iter.next().unwrap().parse().unwrap();
    let n: f32 = iter.next().unwrap().parse().unwrap();
    (c, n)
}

#[allow(dead_code)]
fn get_string_input() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    s.trim().to_string()
}



Measured memory_bytes: 5048
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b;
    string s;
    cin >> a >> b >> s;
    for (int i = 0 ; i < a ; i++) {
    	if (s[i] < '0' || s[i] > '9') {
    		cout << "No";
    		return 0;
		}
	}
	if (s[a] != '-') {
		cout << "No";
		return 0;
	}
	for (int i = a + 1 ; i < s.length() ; i++) {
		if (s[i] < '0' || s[i] > '9') {
    		cout << "No";
    		return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 3636
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
x = I()
print(0 if x else 1)


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

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

    int result = 1;
    char temp = S[0];
    for (int i=0; i<S.size(); i++) {
        if (i != 0 && temp != S[i]) {
            result++;
            temp = S[i];
        }
        //cout << S[i] << " " << temp << " " << result << "\n";
    }
    cout << result;
 
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    int X,Y,Z,temp,temp2;
     scanf("%d%d%d",&X,&Y,&Z);
    temp=X;
    X=Y;
    Y=temp;
    temp2=X;
    X=Z;
    Z=temp2;
    printf("%d %d %d\n",X,Y,Z);

    return 0;
}




Measured memory_bytes: 1716
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
const int MINF=-2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int N; cin >> N;
    vi W(N); rep(i, N)cin >> W[i];
    int SMALL = INF;
    int ALLSUM = 0;
    for (auto x : W)ALLSUM += x;
    for (int i = 0; i <= N; i++) {
        int sum1 = 0;
        int sum2;
        for (int j = 0; j < i; j++) {
            sum1 += W[j];
        }
        sum2 = ALLSUM - sum1;
        int ABS = abs(sum1 - sum2);
        SMALL = min(SMALL, ABS);
    }
    cout << SMALL << endl;
}



Measured memory_bytes: 3628
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());


        String[] arr = scanner.nextLine().split(" ");

        long[] aArray = new long[n];
        Map<Long, Long> map = new HashMap<>();

        for (int i = 0; i < n; i++) {
            long num = Long.parseLong(arr[i]);
            aArray[i] = num;
            if (map.containsKey(num)) {
                Long count = map.get(num);
                map.put(num, count + 1);
            } else {
                map.put(num, 1L);
            }
        }

        long total = 0;
        for (Long key : map.keySet()) {
            Long j = map.get(key);
            total += j * (j - 1) / 2;
        }

        for (int k = 1; k <= n; k++) {

            long num = aArray[k - 1];
            long count = map.get(num);
            long diff = count - 1;
            System.out.println(total - diff);
        }
    }
}


Measured memory_bytes: 89940
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;

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

    string aa, bb, cc;
    cin >> aa >> bb >> cc;

    queue<char> a, b, c;
    for (auto &&e : aa) {
        a.push(e);
    }
    for (auto &&e : bb) {
        b.push(e);
    }
    for (auto &&e : cc) {
        c.push(e);
    }

    char ans;
    for (int i = 0;;) {
        if (i == 0) {
            if (a.empty()) {
                ans = 'A';
                break;
            }

            i = a.front() - 'a';
            a.pop();
        } else if (i == 1) {
            if (b.empty()) {
                ans = 'B';
                break;
            }

            i = b.front() - 'a';
            b.pop();
        } else {
            if (c.empty()) {
                ans = 'C';
                break;
            }

            i = c.front() - 'a';
            c.pop();
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    int a, b;
    cin >> a >> b;
    if (a > b){
            cout << 2 * a - 1 << endl;
    }else if (a != b){
        cout << 2 * b - 1 << endl;
    }else{
        cout << a + b << endl;
    }
}

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

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

  int x = a % 3;
  int y = b % 3;
  int z = (a + b) % 3;

  if (x == 0 || y == 0 || z == 0) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(){
  int N,i,k,kizyun;
  double x[8],y[8],kyori[100],sx,sy,answer;
  answer=0;
  
  scanf("%d\n", &N);
  for(i=0;i<N;i++){
    scanf("%lf %lf\n", &x[i], &y[i]);
  }
  k=0;
 for(kizyun=0;kizyun<=N-2;kizyun++){ 
    for(i=kizyun;i<N-1;i++){
      sx =(x[kizyun] - x[i+1]) * (x[kizyun] - x[i+1]);
      sy =(y[kizyun] - y[i+1]) * (y[kizyun] - y[i+1]);
      kyori[k] = sqrt(sx + sy);
      k++;
    }
 }
  for(i=0;i<k;i++){
    answer=answer+kyori[i];
  }
  answer=answer/k;
  answer=answer*(N-1);
  printf("%lf\n",answer);
  return 0;
}
  
  


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define vii vector<ll> 
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int MOD = 1e9 + 7, N = 1e4 + 3;

int main(){
    fast;
    int n, k;
    cin >> n >> k;
    --k;
    ll a[n], pre_mul[n];
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    for(int i = k + 1; i < n; ++i){
        if(a[i] > a[i-k-1]) cout << "Yes\n";
        else cout << "No\n";
    }
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}

Measured memory_bytes: 5364
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits>


int main(){
    long N;
    std::cin >> N;
    long A[200000+1];
    for(long i=1; i<=N; i++){
        std::cin >> A[i];
    }
    long sum=0;
    long MOD=1000000000+7;
    for(long i=2; i<=N;i++){
        sum+=A[i];
        sum=sum%MOD;
    }
    long sum2=0;
    for(long i=1; i<=N; i++){
        long temp2=sum*A[i];
        temp2=temp2%MOD;
        sum2+=temp2;
        sum2=sum2%MOD;
        if(i!=N){
        sum=sum-A[i+1];
        sum=sum%MOD;
        if(sum<0){
            sum+=MOD;
        }
        }
    }
    std::cout << sum2 << std::endl;
    return 0;
}

Measured memory_bytes: 4724
// AOJ 0574: Nails
// 2017.11.1 bal4u@uu

#include <stdio.h>
#include <string.h>

int dp[5002][5002];

char buf[30], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
    int n, m, x, y, r, t, ans;

    fgets(p=buf, 30, stdin);
	n = getint(), p++, m = getint();
	memset(dp, 0, sizeof(dp));
	while (m--) {
		fgets(p=buf, 30, stdin);
		y = getint(), p++, x = getint(), p++, r = getint();
		dp[y][x] = r+1;
	}
	ans = 0;
	for (y = 1; y <= n; y++) for (x = 1; x <= y; x++) {
		t = dp[y-1][x]-1;
		if (t > dp[y][x]) dp[y][x] = t;
		t = dp[y-1][x-1]-1;
		if (t > dp[y][x]) dp[y][x] = t;
		if (dp[y][x] > 0) ans++;
	}
	printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 99568
n,o = map(int, input().split())
X = list(map(int, input().split()))
X = [abs(x-o) for x in X]

def euclid(a, b):
    if a>b:
        tmp = a
        a = b
        b = tmp
    while a>0:
        c = b%a
        b = a
        a = c
    return b

def sub_gcd(X):
    Y = []
    P, Q = len(X)//2, len(X)%2
    for p in range(P):
        y = euclid(X[2*p], X[2*p+1])
        Y.append(y)
    if Q!=0:
        Y.append(X[-1])
    return Y

def gcd(X):
    Y = sub_gcd(X)
    while len(Y)>1:
        Y = sub_gcd(Y)
    return Y[0]

print(gcd(X))


Measured memory_bytes: 63640
n, y = (int(_) for _ in input().split())

total = n*10000
found = False
five = 0
one = 0
if total < y:
    print('-1 -1 -1')
elif total == y:
    print(str(n) + ' ' + str(five) + ' ' + str(one))
else:
    for i in range(n, -1, -1):
        ten = i
        remainder = n - i
        for j in range(n - i + 1):
            five = j
            one = n - i - j
            total = ten*10000 + five*5000 + one*1000
            if total == y:
                print(str(ten) + ' ' + str(five) + ' ' + str(one))
                found = True
                exit()
        if found:
            break
            
    if not found:
        print('-1 -1 -1')
                
            

Measured memory_bytes: 40428
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
     char s[10];
     int k=0;
     scanf("%s",s);
     for(int i=0;i<strlen(s);i++)
     {
          if(s[i]=='A'&&s[i+1]=='C')
          {
               k=1;
               break;
          }
     }
     if(k==1)
          printf("Yes\n");
     else
          printf("No\n");
     return 0;
}

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

using ll = long long;
#define int long long

// [a -> b-1]
#define reps(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
// [0 -> a-1]
#define rep(i, a) reps(i, 0, (a))
// [a-1 -> b]
#define rreps(i, a, b) for (int i = (int)((a)-1); i >= (int)(b); i--)
// [a-1 -> 0]
#define rrep(i, a) rreps(i, a, 0)
#define all(v) (v).begin(), (v).end()
// next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
 * (v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v)\
	sort(all(v));\
	(v).erase(unique(all(v)), v.end())
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
// b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
// c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(15)
#define YES(f) cout << ((f) ? YES_STR : NO_STR) << endl;

using namespace std;

int solve(int n) {
	int st = 0;
	int nt = 3;
	int res = 0;
	while (n--) {
		string s; cin >> s;
		if (s[0] == 'l') st ^= 2;
		else st ^= 1;
		if (st == nt) {
			res++;
			nt ^= 3;
		}
	}
	return res;
}

signed main() {
	int n;
	while (cin >> n, n) cout << solve(n) << endl;
}




Measured memory_bytes: 3176
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    string x;
    cin >> x;
    for(int i=0;i<4;++i){
        cout << x[i];
    }
    cout << " ";
    for (int i=4;i<12;++i){
        cout << x[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
h, w = map(int,input().split())

if w == 1 or h == 1:
    print(1)
    exit()

ans = (w // 2) * h
if w % 2 == 1:
    if h % 2 == 0:
        ans += h // 2
    else:
        ans += h // 2 + 1
print(ans)


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

using namespace std;
typedef pair<int,int> pii;

const int MAXN = 1000010;
const int INF = 1000000010;

int n, m;
int cntNode;

int dist[MAXN];
int center[MAXN];

vector< int > adj[MAXN];
vector< int > peso[MAXN];

vector< pii > aux[MAXN];

map< int , int > indColor[MAXN];//Dado uma cor, ele retorna qual é a expansão desse vértice c essa cor

void buildEdge(int U, int V, int W)
{
	adj[ U ].push_back( V );
	peso[ U ].push_back( W );
}

void Dijkstra()
{
	set< pii > s;

	for(int i = 1 ; i <= cntNode ; i++)
		dist[i] = INF;

	dist[ center[1] ] = 0;
	s.insert( { 0 , center[1] } );

	while( !s.empty() )
	{
		int cur = s.begin()->second;
		s.erase( s.begin() );

		for(int i = 0 ; i < adj[cur].size() ; i++)
		{
			int viz = adj[cur][i];
			int w = peso[cur][i];

			if( dist[viz] > dist[cur] + w )
			{
				s.erase( { dist[viz] , viz } );
				dist[viz] = dist[cur] + w;
				s.insert( { dist[viz] , viz } );
			}
		}
	}
}

int main()
{
	scanf("%d %d",&n,&m);

	for(int i = 1 ; i <= m ; i++)
	{
		int U, V, C;
		scanf("%d %d %d",&U,&V,&C);

		aux[ U ].push_back( { V , C } );
		aux[ V ].push_back( { U , C } );
	}

	for(int i = 1 ; i <= n ; i++)
	{
		center[i] = ++cntNode;//Vértice de troca

		set< int > s;

		for(int j = 0 ; j < aux[i].size() ; j++)
			s.insert( aux[i][j].second );

		for(auto it = s.begin() ; it != s.end() ; it++)
		{
			int c = *it;

			indColor[i][ c ] = ++cntNode;

			buildEdge( cntNode , center[i] , 0 );
			buildEdge( center[i] , cntNode , 1 );
		}
	}

	for(int i = 1 ; i <= n ; i++)
	{
		for(int j = 0 ; j < aux[i].size() ; j++)
		{
			int V = aux[i][j].first;
			int C = aux[i][j].second;

			buildEdge( indColor[i][C] , indColor[V][C] , 0 );
		}
	}

	Dijkstra();

	int ans = dist[ center[n] ];

	if( ans == INF ) printf("-1\n");
	else printf("%d\n",ans);
}

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

int place(int i,int* sugoroku);

int main(void){
    int sugoroku[2020]={0};
    int X;
    int A;
    int N,M;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>X;
        sugoroku[X]=1;
    }
    int p;
    cin>>M;
    for(int i=0;i<M;i++){
        cin>>A;
        p=place(A,sugoroku);
        if(p==2019);
        else if(sugoroku[p+1]==0){
            sugoroku[p]=0;
            sugoroku[p+1]=1;
        }
    }
    for(int i=1;i<=N;i++){
        cout<<place(i,sugoroku)<<endl;
    }
    return 0;
}

int place(int i,int* sugoroku){
    int count=0;
    for(int j=0;j<2020;j++){
        count+=sugoroku[j];
        if(count==i){return j;}
    }
}



Measured memory_bytes: 3112
a, b, k = map(int, input().split())
for i in range(k):
    if i%2 is 0:
        if a%2 is 1:
            a = (a-1)//2
            b += a
        else:
            a //= 2
            b += a
    
    elif i%2 is 1:
        if b%2 is 1:
            b = (b-1)//2
            a += b
        else:
            b //= 2
            a += b
print(a, b)
        


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

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

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;

int main(){
   int n,m,sum = 0; cin>>n>>m;
   vector<int> a(n);
   rep(i,n){
        cin>>a[i];
        sum += a[i];
   }
   sort(a.begin(),a.end(),greater<int>());
   bool ans = true;
    rep(i,m){
        if(a[i]<(double)sum/(4*m)) ans = false;
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, M = MAP()
LR = [LIST() for _ in range(M)]
lis = [0]*(N+1)

for L, R in LR:
	lis[L] += 1
	if R+1 <= N:
		lis[R+1] -= 1

tmp = 0
max_ = 0
range_ = 0
flag = False
for i in lis:
	tmp += i
	if tmp == M:
		flag = True
		range_ += 1
if flag == True:
	print(range_)
else:
	print(0)


Measured memory_bytes: 29068