akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {
  int h1,m1,h2,m2,k;
  cin >>h1 >>m1 >>h2 >>m2 >>k;
  int hm1 = h1*60+m1;
  int hm2 = h2*60+m2;
  if(hm1>hm2) hm2 += 1440;
  int ans = hm2-k-hm1;
  if(ans<0) cout << 0 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
N=int(input())
cnt = 0
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            n+=0
            #if i != n // i:
            divisors.append(max(len(str(n//i)),len(str(i))))

    # divisors.sort()
    return divisors
print(min(make_divisors(N)))

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

using namespace std;

template <class Type> Type GCD(Type a, Type b)
{
	if (a % b == 0) { return b; }
	if (b % a == 0) { return a; }

	if (a > b) { return GCD(b, a % b); }
	if (a < b) { return GCD(a, b % a); }

	return (Type)(-1);
}

template <class Type> Type GCD(vector<Type> v)
{
	Type ret = v[0];

	for (int i = 1; i < v.size(); i++)
	{
		ret = GCD(ret, v[i]);
	}

	return ret;
}

template <class Type> vector<Type> Divisors(Type n)
{
	vector<int> c;

	for (Type i = 1; i * i <= n; i++)
	{
		if (n % i == 0) { c.push_back(i); if (i * i != n) { c.push_back(n / i); } }
	}

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

	return c;
}

int main()
{
	int n;

	cin >> n;

	vector<int> v(n);

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

	vector<int> c = Divisors(GCD(v));

	for (int i = 0; i < c.size(); i++)
	{
		cout << c[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3148
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


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

   }
  
  int sum = 0;
  
  for(int i = 0;i<n;i++){
     for(int k = 0;k<n;k++){
    
       if(i!=k){
         
         sum = sum + a[i]*a[k];
        
       }
     }

   }
  
  cout << sum/2 << endl;
  
   
  return 0;
}

Measured memory_bytes: 3556
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

H, W = MAP()

# 1方向で3つに切る
def check1(h, w):
    if h < 3:
        return INF
    if h % 3 == 0:
        return 0
    else:
        return w

# T字に切る
def check2(h, w):
    if h < 2 or w < 2:
        return INF
    res = INF
    # Tの横棒をどの位置にするか全部試す
    for i in range(1, h):
        a = i * w
        b = (h-i) * (w // 2)
        c = (h-i) * ceil(w, 2)
        res = min(res, max(a, b, c) - min(a, b, c))
    return res

# 2種類の切り方を縦横に試してみて一番小さくなるものを使う
ans = min(check1(H, W), check1(W, H), check2(H, W), check2(W, H))
print(ans)


Measured memory_bytes: 3064
import itertools
n,m=map(int, input().split())
k=[list(map(int, input().split())) for i in range(m)]
p=list(map(int, input().split()))
bit=list(itertools.product([0,1], repeat=n))
ans=0
for i in bit:
  cnt=0
  for j in range(m):
    cnt2=0
    for l in range(1,k[j][0]+1):
      if i[k[j][l]-1]==1:
        cnt2+=1
    if cnt2%2==p[j]:
      cnt+=1
  if cnt==m:
    ans+=1
print(ans)

Measured memory_bytes: 9316
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		doIt();

	}
	public static void doIt(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n != 0){
			int[][] field = new int[n][n];
			boolean bEnd = true;
			for(int i = 0; i < n; i++){
				String s = sc.next();
				for(int j = 0; j < n; j++){
					if(s.charAt(j) == '.'){
						field[i][j] = 1;
						bEnd = false;
					}
				}
			}
			if(bEnd){
				System.out.println(0);
				n = sc.nextInt();
				continue;
			}
			int max = 1;
			//端はやる必要なし
			for(int i = 1; i < n; i++){
				for(int j = 1; j < n; j++){
					if(field[i][j] == 1){
						int min = Math.min(field[i][j - 1], field[i - 1][j]);
						min = Math.min(min, field[i - 1][j - 1]);
						field[i][j] = min + 1;
						if(max < field[i][j]){
							max = field[i][j];
						}
					}
				}
			}
			
			System.out.println(max);
			n = sc.nextInt();
		}
	}
	
	public static void print(int[][] f){
		for(int[] a : f){
			for(int b : a){
				System.out.print(b + " ");
			}
			System.out.println();
		}
	}

}

Measured memory_bytes: 15000
(n,k),a,*q=$<.map{_1.split.map &:to_i}
b=(0..n).map{_1&-_1}
d=b.map{[]}
u=i=0
z=q.map{d[_2]<<[_1-1,~k-=1]}
a.map{t=$*[_1]||n+u+=1
(b[t]-=1;t+=t&-t)until t>n
d[$*[_1]=i+=1].map{|x,y|z[y]=u
(z[y]-=b[x];x&=x-1)while x>0}}
p *z

Measured memory_bytes: 179724
a = gets.chomp!
a = a.split()
for i in 0..1
	a[i] = a[i].to_i
end
if a[0] < a[1]
	x = a[0]
	a[0] = a[1]
	a[1] = x
end


i = 0
while a[i] % a[i+1] != 0
	a.push(a[i] % a[i+1])
	i += 1
end

puts a[-1]

Measured memory_bytes: 8600
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<string> S;


  return (S == "ARC" ? "ABC" : "ARC");
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}


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

void MinkowskiDistance(int x[], int y[], int n, double p);
double Sum(int x[], int y[], int n, double p);
void InitArray(int* data, int num);

//入力するデータの最大値
#define nMAX 100

int main(void)
{
	int n;			//要素の数
	int x[nMAX];	//ベクトルx
	int y[nMAX];	//ベクトルy
	int i;

	//配列を初期化する
	InitArray(x, nMAX);
	InitArray(y, nMAX);

	//要素の数を入力する
	scanf("%d", &n);

	//ベクトルxの要素を入力する
	for (i = 0; i < n; i++)
	{
		scanf("%d", &x[i]);
	}

	//ベクトルyの要素を入力する
	for (i = 0; i < n; i++)
	{
		scanf("%d", &y[i]);
	}

	//それぞれの距離を計算して出力する
	MinkowskiDistance(x, y, n, 1);
	MinkowskiDistance(x, y, n, 2);
	MinkowskiDistance(x, y, n, 3);
	MinkowskiDistance(x, y, n, INFINITY);

	return 0;
}

void MinkowskiDistance(int x[], int y[], int n, double p)
{
	int i;
	double D;

	//pが無限大(チェビシェフ距離)でなかったら
	if (p != INFINITY)
	{
		D = pow(Sum(x, y, n, p), 1 / p);
	}
	else
	{
		D = 0;
		for (i = 0; i < n; i++)
		{
			if (D < fabs(x[i] - y[i]))
			{
				D = fabs(x[i] - y[i]);
			}
		}
	}

	printf("%lf\n", D);
}

double Sum(int x[], int y[], int n, double p)
{
	int i;
	double sum = 0;	//合計

	for (i = 0; i < n; i++)
	{
		sum += pow(fabs(x[i] - y[i]), p);
	}

	return sum;
}

//配列を初期化する
void InitArray(int* data, int num)
{
	int i;
	for (i = 0; i < num; i++)
	{
		data[i] = 0;
	}
}


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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef pair<int,int> ii;

const int IINF = INT_MAX;

struct Point3d {
  int x,y,z;
  bool operator < ( const Point3d &p ) const {
    if( z != p.z ) return z < p.z;
    if( y != p.y ) return y > p.y;
    return x > p.x;
  }
};


int a, b, C = ~(1<<31), M = (1<<16)-1;
int r() {
  a = 36969 * (a & M) + (a >> 16);
  b = 18000 * (b & M) + (b >> 16);
  return (C & ((a << 16) + b)) % 1000000;
}

const int MAX = 300010;
Point3d ps[MAX];



int m,n,A,B;
set<ii> dp[MAX];

bool check(int index,ii v){
  set<ii>::iterator it = dp[index].lower_bound(v);
  while( (*it).second < v.second ){
    if( (*it).first < v.first ) return true;
    --it;
  }
  return false;
}

void update(int index,ii v){
  set<ii>::iterator it = dp[index].lower_bound(v);
  --it;
  if( (*it).second <= v.second ) return;
  ++it;
  while( (*it).second >= v.second ) dp[index].erase(it++);
  dp[index].insert(v);
}

int LIS2D(vector<ii> &vec) {
  rep(i,(int)vec.size()+1) {
    dp[i].clear();
    dp[i].insert(ii(-1,IINF));
    dp[i].insert(ii(IINF,-1));
  }
  dp[0].insert(ii(-1,-1));
  int maxi = 0;
  rep(i,(int)vec.size()){
    int low = 0, hig = i+1;
    while( hig - low ) {
      int mid = ( low + hig ) / 2;
      if( check(mid,vec[i]) ) low = mid + 1;
      else                    hig = mid;
    }
    maxi = max(maxi,low);
    update(low,vec[i]);
  }
  return maxi + 1;
}

void compute(){

  sort(ps,ps+m+n);
  vector<ii> vec;
  rep(i,n+m) vec.push_back(ii(ps[i].y,ps[i].x));
  
  printf("%d\n",LIS2D(vec));

}

int main(){
  while( scanf("%d %d %d %d",&m,&n,&A,&B), m|n|A|B ){
    a = A, b = B;
    rep(i,m) scanf("%d %d %d",&ps[i].x,&ps[i].y,&ps[i].z);
    rep(i,n) {
      ps[m+i].x = r();
      ps[m+i].y = r();
      ps[m+i].z = r();
    }
    compute();
  }
  return 0;
}

Measured memory_bytes: 57276
#include<bits/stdc++.h>
using namespace std;
void Count(string s)
{
	int n = s.length();
	int cnt = 0;

	for(int i=0;i<n/2;i++)
	{
		if(s[i]== s[n-i-1])
        {
			continue;
        }
		cnt++;
		if(s[i]<s[n-i-1])
        {
			s[n-i-1]= s[i] ;
        }
		else
        {
			s[i]= s[n-i-1] ;
        }
	}
	cout<<cnt<<endl;
}
int main()
{
string s;
cin>>s;
Count((s));
return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
ans = True
for i in range(n):
    if a[i] % 2 == 0 and a[i] % 3 != 0 and a[i] % 5 != 0:
        ans = False
        break

if ans:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 502;
map<int,int> G[MAX_N];
bool used[MAX_N];
int n;

void add_edge(int from, int to, int cap){
    G[from][to] = cap;
    G[to][from] = cap;
}
void erase_edge(int from, int to){
    G[from][to] = 0;
    G[to][from] = 0;
}
int dfs(int v,int t,int f){
    if(v == t) return f;
    used[v] = true;
    each(it,G[v]){
        int nx = it.fi;
        int& cap = it.se;
        if(!used[nx] && cap > 0){
            int d = dfs(nx,t,min(f,cap));
            if(d > 0){
                cap -= d;
                G[nx][v] += d;
                return d;
            }
        }
    }
    return 0;
}
int max_flow(int s,int t){
    int flow = 0;
    while(true){
        memset(used,0,sizeof(used));
        int f = dfs(s,t,INF);
        if(f == 0) return flow;
        flow += f;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int E,q;
    cin >> n >> E >> q;
    rep(i,E){
        int a,b;
        cin >> a >> b;
        add_edge(a-1,b-1,1);
    }
    int res = max_flow(0,n-1);
    rep(i,q){
        int a,b,c;
        cin >> a >> b >> c;
        --b,--c;
        if(a == 1){
            add_edge(b,c,1);
            res += max_flow(0,n-1);
        }else{
            int cap = G[b][c];
            erase_edge(b,c);
            //逆向きに1流れてたら
            if(cap == 2){
                swap(b,c);
            }
            if(cap != 1){
                memset(used,0,sizeof(used));
                int f = dfs(b,c,1);
                //aからbにフローを1流せない(枝(a,b)を削除した分をまかなえない)
                if(f == 0){
                    memset(used,0,sizeof(used));
                    dfs(b,0,1);
                    memset(used,0,sizeof(used));
                    dfs(n-1,c,1);
                    --res;
                }
            }
        }
        cout << res << "\n";
    }
}



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

using namespace std;

const int SIZE_LIMIT = 1e3+5;
char maze[SIZE_LIMIT][SIZE_LIMIT];

int dp[SIZE_LIMIT][SIZE_LIMIT];

int main() {
  memset(maze, 0, sizeof(maze));
  memset(dp, 0x3f, sizeof(dp));

  int h = 0, w = 0, ch, cw, dh, dw;
  scanf("%d%d%d%d%d%d", &h, &w, &ch, &cw, &dh, &dw);

  for (int i = 1; i <= h; ++i) {
    scanf("%s", maze[i]+1);
  }

  deque<pair<int, int>> movable;
  movable.push_back({ch, cw});
  dp[ch][cw]=0;

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


  while (!movable.empty()) {
    auto p = movable.front();
    movable.pop_front();

    if (p.first == dh && p.second == dw) {
      break;
    }

    // move
    for (int i = 0; i < 4; ++i) {
      int nx = dx[i]+p.first, ny = dy[i]+p.second;
      if (maze[nx][ny] == '.' && dp[nx][ny] > dp[p.first][p.second]) {
        dp[nx][ny] = dp[p.first][p.second];
        movable.push_front({nx, ny});
      }
    }
    // jump
    for (int i = -2; i <= 2; ++i) {
      for (int j = -2; j <= 2; ++j) {
        int nx = p.first+i, ny = p.second+j;
        if (nx>0 && nx<=h && ny>0 && ny<=w && maze[nx][ny] == '.' && dp[nx][ny] > dp[p.first][p.second]+1) {
          dp[nx][ny] = dp[p.first][p.second]+1;
          movable.push_back({nx, ny});
        }
      }
    }
    
  }

  if (dp[dh][dw] == 0x3f3f3f3f) printf("-1\n");
  else printf("%d\n", dp[dh][dw]);
  


  return 0;
}

Measured memory_bytes: 8744
#include<cstdio>
#include<queue>
using namespace std;

const int MAX_N = 1e5;
int n, m;
int a[MAX_N];
priority_queue<int> q;

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        q.push(x);
    }

    for (int i = 0; i < m; i++) {
        int a = q.top(); q.pop();
        a /= 2;
        q.push(a);
    }
    
    long ans = 0;
    for (int i = 0; i < n; i++) {
        int a = q.top(); q.pop();
        ans += a;
    }

    printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 892
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	int pn = 1;
	if (*ci == '-') {
		pn = -pn;
		ci++;
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	return pn * tmp;
}

ll A[200001];
void pakuri_sort(int N, ll A[]) {
	const int b = 8;
	ll tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N = getint();
	rep1(i, N) {
		A[i] = getint() + A[i - 1];
	}

	pakuri_sort(N + 1, A);

	ll kotae = 0;
	ll mae = 1e18;
	int kazu = 0;
	rep(i, N + 1) {
		if (mae != A[i]) {
			mae = A[i];
			kazu = 0;
		}
		kotae += kazu++;
	}

	printf("%lld\n", kotae);

	Would you please return 0;
}

Measured memory_bytes: 4828
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <queue>

using namespace std;

int main(){
  int N, A, B, C, D;
  string S;
  bool can = true;
  int dot;
  int dotcnt=0;
  //input
  cin >> N >> A >> B >> C >> D;
  cin >> S;

  for(int s=A-1; s <= C-1-1; s++){
    if(S[s] == '#' && S[s+1] == '#') can = false;
  }
  for(int s=B-1; s <= D-1-1; s++){
    if(S[s] == '#' && S[s+1] == '#') can = false;
  }
  if(B>C) {
    if(can){cout << "Yes" << endl; return 0;}
    else {cout << "No" << endl; return 0;}
  }



  if(C>D){


    dot=3;     //3
  //else dot=1;
    for(int s=B-1; s<=D-1;s++){
      if(S[s] == '.'){
        dotcnt++;
        if(dotcnt == dot){
          break;
        }
      }
      else dotcnt=0;
      if(s==D-1) can = false;
    }

    if(B != 1 && B != N){
      if(S[B-1-1] == '.' && S[B] == '.'){
        can = true;
      }
    }
    if(D != 1 && D != N){
      if(S[D-1-1] == '.' && S[D] == '.'){
        can = true;
      }
    }
  }

  //out
  if(can){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
 int main(void){
    unsigned long int a,b,n;
    scanf("%lu %lu %lu",&n,&a,&b);
    if ((b - a) % 2 == 0){
        printf("%lu",((b - a) / 2));
    }else{
        if (b - 1 <= n - a){
            printf("%lu",(((b - a) / 2) + 1) +  (a - 1));
        }else{
            printf("%lu",(((b - a) / 2) + 1) + (n - b));
        }
    }
}
 

Measured memory_bytes: 128
use proconio::{input, fastout};
use std::cmp::{min, max};
#[fastout]
fn main() {
    input! {
        a: i64,
        b: i64,
        _c: i64,
        k: i64,
    }

    let mut ans: i64 = min(a, k);

    ans -= max(0, k-a-b);

    println!("{}", ans);
}

Measured memory_bytes: 2200
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ll long long
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mt make_tuple
#define eb emplace_back
using namespace std;
const int N=2e5+5,mod=998244353;
const ll inf=3e18;
int n;
ll k;
void solve(){
    cin>>n;
    cin>>k;
    int a[n+5];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    if(a[1]==1){cout<<"1"<<endl;return;}
    int j=1;
    ll m=0;
    unordered_set<int> s,t;
    s.insert(j);
    while(1){
        j=a[j];
        //cout<<j<<" "<<m<<endl;
        m++;
        if(m==k){cout<<j<<endl;return;}
        if(s.find(j)==s.end()) s.insert(j);
        else break;
    }
    ll cy=0;
    t.insert(j);
    while(1){
        j=a[j];
        //cout<<j<<" "<<cy<<endl;
        cy++;
        if(t.find(j)==t.end()) t.insert(j);
        else break;
    }
    //cout<<m<<" "<<cy<<endl;
    if(j==a[j]){cout<<j<<endl;return;}
    k=k-(m-cy);
    k=k%cy;
    while(k>0){
        j=a[j];
        k--;
    }
    cout<<j<<endl;
}

int main(){
    #ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll t,p;
    t=1;
    //cin>>t;
    for(p=1;p<=t;p++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 17128
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    X=I()
    N=100
    ans=0
    while(X>N):
        N+=N//100
        ans+=1
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 83580
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main()
{
	string s;cin>>s;
	while(s.size()>0){
		if(s.size()>4 && s.substr(s.size()-5)=="erase"){
			s=s.substr(0,s.size()-5);
		}
		else if(s.size()>5 && s.substr(s.size()-6)=="eraser"){
			s=s.substr(0,s.size()-6);
		}
		else if(s.size()>6 && s.substr(s.size()-7)=="dreamer"){
			s=s.substr(0,s.size()-7);
		}
		else if(s.size()>4 && s.substr(s.size()-5)=="dream"){
			s=s.substr(0,s.size()-5);
		}
		else{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
}


Measured memory_bytes: 764
let N = Int(readLine()!)!

var counter = [String: Int]()
for _ in 1...N {
	let si = readLine()!
	counter[si, default: 0] += 1
}

for k in ["AC", "WA", "TLE", "RE"] {
	print("\(k) x \(counter[k, default: 0])")
}


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

using namespace std;

typedef long long   ll;
typedef pair<int,int> pii;
typedef pair<int,int> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii > vpi;

//#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
  #define db(x) cerr << #x << " == " << x << endl
  #define dbs(x) cerr << x << endl
  #define _ << ", " <<
#else
  #define db(x) ((void)0)
  #define dbs(x) ((void)0)
#endif

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define cl(x, v) memset((x), (v), sizeof(x))
#define all(x) x.begin(),x.end()
#define sz(x) int(x.size())
#define MOD 1000000007LL
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (( (a)/__gcd((a), (b)) )*(b))

ll memo[1010][1010];
char mat[1010][1010];
int n, m;

int dp(int i, int j){
	if(mat[i][j] == '#')
		return 0LL;
	
	if((i == n) and (j == m))
		return 1LL;
		
	if(memo[i][j] != -1LL)	
		return memo[i][j];
	
	return memo[i][j] = (dp(i+1, j) + dp(i, j+1))%MOD;
}

int main() {
	memset(mat, '#', sizeof(mat));
	memset(memo, -1, sizeof(memo));
	
	cin.sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++)
			cin >> mat[i][j];
	
	cout << dp(1, 1) << endl;

	return 0;	
}


Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long ul;
// for文短縮類
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
// iteratorのbeginとendをまとめて渡す
#define ALL(x) (x).begin(), (x).end()
//略
#define PB push_back  // vectorヘの挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素
//出力
#define COUT(x) cout << (x) << endl
#define SCOUT(x) cout << (x) << " "
#define ENDL cout << endl
/************ Combination wtih MOD ************
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// preprocess for some tables
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;
  }
}
// combination
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 argc, char *argv[]) {
  // input高速化。cinとcoutの結合解除。scanfとprintfは使えない。
  cin.tie(0);
  ios_base::sync_with_stdio(0);

  ll n;
  cin >> n;
  vector<ll> a;
  REP(i, n){
      ll ai;
      cin >> ai;
      a.PB(ai);
  }

  sort(ALL(a), greater<ll>());

  ll ans = a[0];
  ll cnt = 2;
  ll ptr = 1;

  while(cnt < n){
      ans += a[ptr];
      cnt += 1;
      if(cnt >= n){
          break;
      }
      ans += a[ptr];
      ptr += 1;
      cnt += 1;
  }
  cout << ans << endl;
}

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

int main() {
  long long m, s = 0; cin >> m;
  vector<int> v(m);
  for(int i = 0; i < m; i++)
    cin >> v.at(i);
  sort(v.begin(), v.end());
  for(int i = 0; i < m - 2; i++){
    for(int j = i + 1; j < m - 1; j++){
      for(int k = j + 1; k < m; k++){
        if(v.at(i) + v.at(j) > v.at(k)) s++;
        else break;
      }
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
all_info = [list('.' + input() + '.') for i in range(H)]
all_info = [['.' for i in range(W+2)]] + all_info + [['.' for i in range(W+2)]]

for row_num, padded_row in enumerate(all_info[1: -1]):
    for collumn_num, s in enumerate(padded_row[1: -1]):
        if s == '#':
            continue
        else:
            all_info[row_num + 1][collumn_num + 1] = str((all_info[row_num][collumn_num: collumn_num +3]
                                                                                     + all_info[row_num + 2][collumn_num: collumn_num + 3]
                                                                                     + all_info[row_num + 1][collumn_num: collumn_num + 3]).count('#'))

for row in all_info[1: -1]:
    print(''.join(row[1: -1]))

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n, a[114514];
	cin>>n;
	cin>>a[0];
	int cand[114514];
	cand[0]=a[0];
	REP(i, n-1){
		cin>>a[i+1];
		cand[i+1]=gcd(cand[i], a[i+1]);
	}
	int cand2[114514];
	cand2[n-1]=a[n-1];
	FORR(i, 0, n-1){
		cand2[i]=gcd(cand2[i+1], a[i]);
	}
	int ans=max(cand2[1], cand[n-2]);
	FOR(i, 1, n-1){
		CHMAX(ans, gcd(cand[i-1], cand2[i+1]));
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using ll = long long;
using PAIR = pair<int, int>;
using Graph = vector<vector<int>>;
const double pi=acos(-1.0);
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/**************************************/
/******** User-defined Function *******/






/**************************************/
/********** Main()  function **********/
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    string s; cin >> s;

    int ans = 0;

    rep(i,10)rep(j,10)rep(k,10){
        bool flag1=false, flag2=false, flag3=false;
        rep(l,n){
            if(flag1==false){
                if(s[l]-'0'==i){
                    flag1 = true;
                    continue;
                }else continue;
            }
            
            if(flag2==false){
                if(s[l]-'0'==j){
                    flag2 = true;
                    continue;
                }else continue;
            }
            
            if(flag3==false){
                if(s[l]-'0'==k){
                    flag3 = true;
                    break;
                }else continue;
            }
        }
        if(flag1&&flag2&&flag3) ans++;
    }

    cout << ans << endl;
}
/********  Main() Ends Here *************/


Measured memory_bytes: 3716
import java.util.Scanner;
public class Main{
    
    public static void main (String[ ]args){
        
        Main main = new Main ();
        main.solve();
    }
    
    private void solve (){
        Scanner sc = new Scanner (System.in);
        
        int N = sc.nextInt();
        int[] list = new int[N];
        
        for (int index=0; index<N; index++){
           list[index]=sc.nextInt(); 
        }
        
        int highest = 0;
        int count = 0;
        
        for (int index=0; index<N; index++){
            int height = list[index];
            if (height>=highest){
                count++;
                highest=height;
            }
        }
        
        System.out.println(count);
        
    }
}

Measured memory_bytes: 21972
a, b, c = map(int, input().split())
cnt = 0
while a%2==0 and b%2==0 and c%2==0:
  if a==b==c:
    print(-1)
    exit()
  a, b, c = b//2+c//2, a//2+c//2, a//2+b//2
  cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int main() {
  int N;
  string S;
  cin>>N>>S;
  
  if(S.size()%2!=0){
    cout<<"No"<<endl;
    return 0;
  }
  
  else{
    string s=S.substr(0,N/2);
    string t=S.substr(N/2,N/2);
    
    if(s==t)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
  
  
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
static const long long MOD_NUM = 1000000007LL;

static void C_task();

int main()
{
	C_task();
	fflush(stdout);
	return 0;
}

static void C_task()
{
	int N;
	get1int(N);

	auto ht = new LLONG[N];
	for (int i = 0; i < N; i++) {
		get1int(ht[i]);
	}

	int mov = 0;
	int maxMov = 0;
	for (int i = 0; i < N - 1; i++) {
		if (ht[i] >= ht[i + 1]) {
			mov++;
			maxMov = std::max(mov, maxMov);
		}
		else {
			mov = 0;
		}
	}

	printf("%d\n", maxMov);

	delete[] ht;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int a,b,c,d; cin >> a >> b >> c >> d;
	if (abs(a-c) <= d) {
		print("Yes");
	}else if( abs(b-a) <= d && abs(c-b) <= d){
		print("Yes");
	}else{
		print("No");
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> c(h);
    for(int i = 0; i < h; i++) cin >> c[i];

    int ans = 0;
    for(int bit = 0; bit < (1 << (h+w)); bit++){
        vector<string> c1 = c;
        for(int i = 0; i < h; i++){
            if(bit & (1 << i)){
                for(int j = 0; j < w; j++) c1[i][j] = '.';
            }
        }
        for(int i = h; i < h+w; i++){
            if(bit & (1 << (i))){
                for(int j = 0; j < h; j++) c1[j][i-h] = '.';
            }
        }

        int count = 0;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(c1[i][j] == '#') count++;
            }
        }
        if(count == k) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
def take_mod(L):
	for i in range(1,len(L)):
		if L[i]%L[0] == 0:
			L[i] = L[0]
		else:
			L[i] = L[i]%L[0]
	L.sort()
	return L

N = int(input())
L = list(map(int, input().split()))
L.sort()

while True:
	L = take_mod(L)
	if len(set(L)) == 1:
		print(L[0])
		exit()

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N;
  cin>>N;
  vector<ll> H(N);
  for(ll i=0;i<N;i++) {
cin>>H[i];
  }
 ll max=H[0];

  for(ll i=1;i<N;i++) {
    if(max<H[i]) {
max=H[i];
      continue;
    }
    if(max>H[i]+1) {
cout<<"No"<<endl;
      return 0;
    }
  }
  
  
  cout<<"Yes"<<endl;
}
  
  



Measured memory_bytes: 4028
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    long long m = 1000000000;
    long long ans = 0;
    long long a;
    int count = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        if (a < 0) count++;
        a = abs(a);
        m = min(m, abs(a));
        ans += a;
    }
    cout << ((count % 2) ? ans - 2 * abs(m) : ans) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char c = s.charAt(0);

    if('a' <= c && c <= 'z'){
      System.out.println("a");
    }else{
      System.out.println("A");
    }
  }
}


Measured memory_bytes: 35576
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <vector>

#define REP(i,n) for(int i=0;i<=(int)n;i++)
#define REP1(j,n) for(int j=0;j<=(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	string s;
	cin >> s;
	s.replace(0,4,"2018");
	cout << s << endl;

	return 0;

}



Measured memory_bytes: 256
#include <iostream>

int main()
{
	int a, b, c;
	std::cin >> a >> b >> c;
	if (a <= b && b <= c) {
		std::cout << a << " " << b << " " << c << std::endl;
	}
	else if (a <= b && c <= b && a <= c){
		std::cout << a << " " << c << " " << b << std::endl;
	}
	else if(a <= b && c <= b && c <= a) {
		std::cout << c << " " << a << " " << b << std::endl;
	}
	else if(b <= a && a <= c) {
		std::cout << b << " " << a << " " << c << std::endl;
	}
	else if(b <= a && c <= a && b <= c) {
		std::cout << b << " " << c << " " << a << std::endl;
	}
	else {
		std::cout << c << " " << b << " " << a << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3080
N=int(input())
S=[input() for _ in range(N)]

a=0
w=0
t=0
r=0

for i in range(N):
  if S[i] =="AC":
    a+=1
  elif S[i] =="WA":
    w+=1
  elif S[i] =="TLE":
    t+=1
  elif S[i] =="RE":
    r+=1

print("AC x "+ str(a))
print("WA x "+ str(w))
print("TLE x "+ str(t))
print("RE x "+ str(r))


Measured memory_bytes: 16316
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll c[10][10];
int main( void )
{
  ios::sync_with_stdio(false);
  int H, W, A;
  cin >> H >> W;
  for( int i=0; i<10; i++ ){
    for( int j=0; j<10; j++ ){
      cin >> c[i][j];
    }
  }
  for( int k=0; k<10; k++ ){
    for( int i=0; i<10; i++ ){
      for( int j=0; j<10; j++ ){
        c[i][j] = min( c[i][j], c[i][k] + c[k][j] );
      }
    }
  }
  ll ret = 0;
  for( int i=0; i<H; i++ ){
    for( int j=0; j<W; j++ ){
      cin >> A;
      if( A >= 0 ){
        ret += c[A][1];
      }
    }
  }
  cout << ret << endl;
}

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

int fact(int N) {
	if (N == 1) {
		return 1;
	}
	else {
		return N * fact(N - 1);
	}
}

int main() {
	int N;
	cin >> N;
	vector<int> x(N);
	vector<int> y(N);
	vector<int> order(N);
	rep(i, N) {
		cin >> x[i];
		cin >> y[i];
		order[i] = i;
	}
	double path = 0;
	do {
		rep(i, N - 1) {
			path += sqrt(pow(x[order[i + 1]] - x[order[i]], 2) + pow(y[order[i + 1]] - y[order[i]], 2));
		}
	} while (next_permutation(order.begin(), order.end()));
	printf("%.6lf\n", path / fact(N));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007
 
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
 
int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};
 
int n, m, l;
 
int main(){
	cin >> n >> m >> l;
	if((n+m-l)*(m+l-n)*(n-m+l)){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    map<string,int>mp;
    map<string,vi>hoge;
    vector<string>v;
    string temp; int cnt;
    while(cin>>temp>>cnt){
        if(mp[temp]==0){v.push_back(temp);hoge[temp].push_back(cnt);mp[temp]++;}
        else{
            hoge[temp].push_back(cnt);
        }
    }
    sort(all(v));
    rep(i,v.size()){
        cout<<v[i]<<endl;
        sort(all(hoge[v[i]]));
        rep(j,hoge[v[i]].size())if(j)cout<<" "<<hoge[v[i]][j]; else cout<<hoge[v[i]][j];
        cout<<endl;
    }
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int k, n, a[200010];
    cin >> k >> n;
    for (int i = 0; i < n; i++) cin >> a[i];

    int max = 0;
    for (int i = 0; i < n - 1; i++) {
        if (a[i+1] - a[i] > max) {
            max = a[i+1] - a[i];
        }
    }
    if (k - a[n-1] + a[0] > max) max = k - a[n-1] + a[0];
    cout << k - max << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
using namespace std;	
 int star_vowels(char s[]) {
 int maxx=0;
    int j = 0;
   int x=0; 
    while (s[j] != '\0'){ 
        if (s[j] == 'I' ) { x++;
             if(x>maxx) maxx=x;
        } else if(s[j]=='D'){x--;
             
        }
        j++;
       int cp=maxx;
    }
    cout<<maxx;
    return 0;
}
int main(){  int n; cin>>n;
	char s[n];
	cin>>s;
	star_vowels(s);
	return 0;
}

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

int main(){
  long double n,m,d;
  cin>>n>>m>>d;
  if(d==0){
    cout<<fixed<<setprecision(10);
    cout<<(m-1)/n<<endl;
    return 0;
  }
  cout<<fixed<<setprecision(10);
  cout<<(2*(n-d)*(m-1))/(n*n)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

P color[110000];
vi e[110000];

void dfs(int v,int d,int c) {
	if (color[v].second >= d)return;
	if (color[v].first == 0)color[v].first = c;
	color[v].second = d;
	if(d>0)for (int vv : e[v])dfs(vv, d - 1, c);
}

int main() {

	int n, m;
	cin >> n >> m;
	while (m--) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}

	int q;
	cin >> q;
	vi v, d, c;
	rep(i, q) {
		int vv, dd, cc;
		cin >> vv >> dd >> cc;
		vv--;
		v.push_back(vv);
		d.push_back(dd);
		c.push_back(cc);
	}
	reverse(all(v));
	reverse(all(d));
	reverse(all(c));
	rep(i, n)color[i].second = -1;
	rep(i, q)dfs(v[i], d[i], c[i]);
	rep(i, n)cout << color[i].first << endl;

}

Measured memory_bytes: 8824
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;




int main(){
  int a,b,c;
  cin >> a >>b >> c;
  if(a==b){cout << c << endl;}
  else if(b==c){cout << a << endl;}else{cout << b << endl;}
}

Measured memory_bytes: 3604
function main(input) {
    var n = input[0]-0;
    var a = input[1].split(" ").map(v=>v-0);
    var b = input[2].split(" ").map(v=>v-0);
    
    var ans = 0;
    for(var i=0;i<n;i++){
        var bb = b[i];
        var a1 = a[i];
        var a2 = a[i+1];
        if(a1<bb){
            a[i]-=a1;
            ans += a1;
            bb-=a1;
            if(a2<bb){
                a[i+1]-=a2;
                ans+=a2;
            }else{
                a[i+1]-=bb;
                ans+=bb;
            }
        }else{
            a[i]-=bb;
            ans += bb;
        }
    }
        console.log(ans);
    
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 34564