akhauriyash/Code-Regression huggingface dataset:
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
 
using ll = long long;
using P = std::pair<ll, ll>;
 
#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << #i <<" "<< i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  ll x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;



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

  ll n;
  std::cin>>n;

  ll ans=0;

  rep(_,0,n){
    ll a,k;
    std::cin>>a>>k;

    while(a%k!=0&&a>=k){
      ll temp=a/k;
      ll cnt=(a-k*temp)/(temp+1);
      a-=std::max(cnt,1ll)*(temp+1);
    }

    ans^=(a/k);
  }

  if(ans==0)std::cout<<"Aoki\n";
  else std::cout<<"Takahashi\n";

  return 0;
}

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

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(void){
    int n;
    cin >> n;
    vector<int> w(n);
    for(int i = 0; i < n; i++) cin >> w.at(i);
    int min = INT_MAX;
    int sum1, sum2;
    for(int i = 0; i < n-1; i++){
        sum1 = accumulate(w.begin(), w.begin()+i+1, 0);
        sum2 = accumulate(w.begin()+i+1, w.end(), 0);
        int absv = abs(sum1-sum2);
        if(min > absv) min = absv;
    }
    cout << min << endl;
    return 0;
}


Measured memory_bytes: 256
function Main(input) {
  "use strict"
  const temp = input.split("\n")
 
  const nk = temp.shift().split(" ");
  const n = parseInt(nk.shift());
  const k = parseInt(nk.shift());
  const s = temp.shift().split("");
 
  let tempChar = s.shift()
  let counter = 0;
  s.forEach(char => {
    if(tempChar === char) counter += 1;
    tempChar = char;
  })
  console.log(Math.min(counter + k * 2,  n - 1));
 
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 8396
N, K = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
ans = sum(b for a, b in AB if a&~K==0)
for i in range(30):
    if K>>i&1:
        k = (K^1<<i)|(1<<i)-1
        ans = max(ans, sum(b for a, b in AB if a&~k==0))
print(ans)


Measured memory_bytes: 27292
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}
#define vec2d(T, v, m, n) vector<vector<T>> (v)(m, vector<T>(n))
#define nvec2d(T, v, m, n) vec2d(T, v, m, n); REP(j, m){REP(i, n) {cin>>(v[j])[i];}}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))

#define GCD(v) gcd(ALL(v), 0l)

/*template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}*/

template <typename T>
using vec =vector<T>;

template <typename T>
using vvec =vector<vector<T>>;

int main(){
  int h,w,m;
  cin>>h>>w>>m;
  vec<int> posh(m),posw(m);
  for (int i = 0; i < m; i++) {
    cin>>posh[i]>>posw[i];
  }
  vec<int> hs(h,0),ws(w,0);
  for (int i = 0; i < m; i++) {
    hs[posh[i]-1]++; ws[posw[i]-1]++;
  }
  int maxh = max_e(hs), maxw = max_e(ws);
  int cross=0;
  for (int i = 0; i < m; i++) {
    if(hs[posh[i]-1]==maxh && ws[posw[i]-1]==maxw) cross++;
  }
  //cout<<cross;
  cout<<maxh+maxw-(count(ALL(hs),maxh)*count(ALL(ws),maxw)==cross);
}


/* きょむ〜 */


Measured memory_bytes: 8004
A, B, C = map(int, input().split())
K = int(input())

for i in range(K):
    if 2*A > (B + C):
        A = A * 2
    elif 2*B > (A + C):
        B = B * 2
    elif 2*C > (B + A):
        C = C * 2
    elif A == B == C:
        A = A * 2

print(A+B+C)


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

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pll = pair<ll, ll>;

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


template <typename T>
using vv = vector<vector<T>>;

void solve() {
    int n, q; cin >> n >> q;
    vi a(n);
    for (auto &i : a) cin >> i, i--;;
    vector<pair<pll, int>> qr(q);
    int cc = 0;
    for (auto &e : qr) cin >> e.first.first >> e.first.second, 
                            e.first.first--, e.first.second--, e.second = cc++;
    sort(all(qr), [&](pair<pll, int> aa, pair<pll, int> bb) {
        auto a = aa.first, b = bb.first;
        if (a.first / 1000 != b.first / 1000) return a.first / 1000 < b.first / 1000;
        return a.second < b.second;
    });

    vi cnt(n);
    ll tmp = 0;
    ll l = 0, r = -1;

    vi res(q);
    
    for (auto e : qr) {
        ll nl, nr;
        tie(nl, nr) = e.first;
        while (r < nr) {
            r++;
            if (cnt[a[r]]++ == 0) tmp++;
        }
        while (l > nl) {
            l--;
            if (cnt[a[l]]++ == 0) tmp++;
        }
        while (r > nr) {
            if (--cnt[a[r--]] == 0) tmp--;
        }
        while (l < nl) {
            if (--cnt[a[l++]] == 0) tmp--;
        }
        res[e.second] = tmp;
    }

    for (auto i : res) cout << i << '\n';
}



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


Measured memory_bytes: 27176
import sys
import math
import collections
import bisect
import itertools
import decimal

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
# MOD = 10 ** 9 + 7
MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===
def prime_factorize(n):
    two = 0
    five = 0
    while n % 2 == 0:
        two += 1
        n //= 2

    while n % 5 == 0:
        five += 1
        n //= 5

    return two, five


def main():
    n = ni()
    a = [int(decimal.Decimal(sys.stdin.readline().rstrip()) * (10 ** 9)) for _ in range(n)]
    res = {}
    border = 18

    twoflg = False
    fiveflg = False
    for ai in a:
        two, five = prime_factorize(ai)

        if two >= 9:
            twoflg = True
        if five >= 9:
            fiveflg = True

        if (two, five) not in res.keys():
            res[(two, five)] = 1
        else:
            res[(two, five)] += 1

    ans = 0
    if twoflg and fiveflg:
        for k, v in res.items():
            two, five = k
            for tk, tv in res.items():
                t_two, t_five = tk
                if two + t_two >= border and five + t_five >= border:
                    if two == t_two and five == t_five:
                        ans += v * (tv - 1)
                    else:
                        ans += v * tv

    print(ans // 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 289552
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(A == b) {
			System.out.println(c);
		} else if(A == c) {
			System.out.println(b);
		} else {
			System.out.println(A);
		}
	}
}

Measured memory_bytes: 22612
#include <iostream>

inline long long GetMulti(int val)
{
  return (long long)val * val * val * val * val;
}

int main()
{
  unsigned int X;
  std::cin >> X;
  
  for(int A = -200; ; ++A)
  {
    const long long mulA = GetMulti(A);
    const long long result = mulA - X;
    
    if(result < 0)
    {
      long long mulB = 0;
      for(int B = 0; mulB >= result; --B)
      {
        mulB = GetMulti(B);
        if(result == mulB)
        {
          std::cout << A << " " << B << std::endl;
          return 0;
        }
      }
    }
    else
    {
      long long mulB = 0; 
      for(int B = 0; mulB <= result; ++B)
      {
        long long mulB = GetMulti(B);
        if(result == mulB)
        {
          std::cout << A << " " << B << std::endl;
          return 0;
        }
      }
    }
  }
  return 0;
}


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

#define FOR(i, s, e)   for(int i = (s); i < (e); i++)
#define FOR64(i, s, e) for(ll  i = (s); i < (e); i++)
#define ALL(x)         (x).begin(), (x).end()
#define SORT(b, e)     sort((b), (e))
#define REV(b, e)      reverse((b), (e))
#define VSORT(v)       sort((v).begin(), (v).end())
#define VREV(v)        reverse((v).begin(), (v).end())
#define pb(a)          push_back(a)
#define INF            999999999

typedef long long ll;

int main()
{
	int x1, y1, x2, y2, x3, y3, x4, y4;
	int dx, dy;

	cin >> x1 >> y1 >> x2 >> y2;

	dx = -(y2 - y1);
	dy = x2 - x1;

	x3 = x2 + dx;
	y3 = y2 + dy;

	x4 = x1 + dx;
	y4 = y1 + dy;

	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll MOD = 1e9+7;

int main(){
  string a;
  cin>>a;
  for(int i=0;i<3;i++){
	if(a[i]=='1')cout<<9;
	else if(a[i]=='9')cout<<1;
	else cout<<a[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <vector>
#include <map>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

long long n, bg, tn, su;
	
	while(cin >> n){
		if(n==0 || cin.eof()) break;
		map<int,long long> sk;
		vector<int> jun;
		rep(i,n){
			cin >> bg >> tn >> su;
			if(sk[bg]==0) jun.push_back(bg);
			sk[bg] += tn * su;
		}
		int cnt=0;
		rep(i,jun.size()){
			if(sk[jun[i]] >= 1000000){
				cout << jun[i] << endl;
				cnt++;
			}
		}	
		if(cnt==0) cout << "NA" << endl;
	}
	return 0;
	
}

Measured memory_bytes: 1280
main=do
 getLine
 d<-zip[2..].map read.words<$>getLine
 let k=length d
 ans<-unlines.map(show.(\[n,x,m]->n-1-div(x`mod`m+sum[(m-(-e)`mod`m)*div(n-i+k)k|(i,e)<-d])m).map read.words).lines<$>getContents
 putStr ans

Measured memory_bytes: 5500
import sys

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


H, W = na()

A_array = [ns() for _ in range(H)]

mod = 10 ** 9 + 7

ans = [[0] * W for _ in range(H)]

ans[0][0] = 1
for i in range(1, W):
    if A_array[0][i] == "#":
        continue
    ans[0][i] = ans[0][i-1]

for i in range(1, H):
    if A_array[i][0] == "#":
        continue
    ans[i][0] = ans[i-1][0]


for i in range(1, H):
    for j in range(1, W):
        if A_array[i][j] == "#":
            continue
        ans[i][j] = (ans[i-1][j] + ans[i][j-1]) % mod

print(ans[H-1][W-1])


Measured memory_bytes: 76820
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(a + c, min(a + b, c + b));
}

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

using namespace std;

using ll = long long;
using ii = pair<int,int>;

#define ff first
#define ss second

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,m;
	cin >> n >> m;
	cout << (m>=n ? "Yes":"No") << '\n';
}

Measured memory_bytes: 3644
import math
a, b = (int(i) for i in input().split())
x = math.ceil(a / 0.08)
flag = False
while math.floor(x * 0.08) == a:
    if (math.floor(x * 0.1) == b):
        flag = True
        break
    x = x + 1
if flag:
    print(int(x))
else:
    print(-1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define INF (1ll<<60)
typedef pair<int, int> pii;
#define FI first
#define SE second
#define all(s) s.begin(),s.end()
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define pb push_back
#define l_b lower_bound
#define u_b upper_bound

int N;
int A[100100];
int s[100100];
signed main() {
	cin >> N;
	rep(i,N)
	{
		cin >> A[i];
	}
	sort(A, A + N);
	rep(i,N)
	{
		s[i + 1] = s[i] + A[i];
	}
	int l = -1, r = N - 1;
	while (r - l > 1) {
		int m = (l + r) / 2;
		if (s[m + 1] >= (A[N - 1] + 1) / 2) {
			r = m;
		} else {
			int prev = -1;
			int cur = m;
			while (cur != prev) {
				prev = cur;
				cur = u_b(A, A + N, s[prev + 1] * 2) - A - 1;
				//cerr << " " << prev << " " << cur << endl;
			}
			if (cur == N - 1)
				r = m;
			else
				l = m;
		}
		//cerr << l << " " << r << endl;
	}
	cout << N - r << endl;
}


Measured memory_bytes: 1792
import sys

from numba import njit, b1, i8


@njit(b1(i8, i8, i8), cache=True)
def solve(K, A, B):
    for i in range(A, B + 1):
        if i % K == 0:
            return True
    return False


def main():
    input = sys.stdin.buffer.readline
    K = int(input())
    A, B = map(int, input().split())

    print('OK' if solve(K, A, B) else 'NG')


if __name__ == '__main__':
    main()


Measured memory_bytes: 106264
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

#define FOR(i, a, b) for((i)=a; i<b; ++(i))
#define EFOR(i, a, b) for((i)=a; i>b; --(i))

#define MLC(n, type) (type*)malloc(n*sizeof(type))
#define CLC(n, type) (type*)calloc(n, sizeof(type))

#define MAXN 100001

int solver(int *nums, int numsSize) {
	int i,j;
	int dp[MAXN] = {0};
	int minN1 = 0, minN2 = 0;
	int minS1 = 0, minS2 = 0;

	int n = 0;

	for (i = 0; i < numsSize; i += 2) {
		dp[nums[i]] += 1;
		if (dp[nums[i]] > minS1) {
			minN1 = nums[i];
			minS1 = dp[nums[i]];
		}
		else if (dp[nums[i]] > minS2) {
			minN2 = nums[i];
			minS2 = dp[nums[i]];
		}
	}

	memset(dp, 0, MAXN*sizeof(int));

	int minN3 = 0, minN4 = 0;
	int minS3 = 0, minS4 = 0;

	for (i = 1; i < numsSize; i += 2) {
		dp[nums[i]] += 1;
		if (dp[nums[i]] > minS3) {
			minN3 = nums[i];
			minS3 = dp[nums[i]];
		}
		else if (dp[nums[i]] > minS4) {
			minN4 = nums[i];
			minS4 = dp[nums[i]];
		}
	}

	if (minN1 == minN3) {
		n = numsSize - max(minS1+minS4, minS2+minS3);
	}
	else {
		n = numsSize - minS1 - minS3;
	}

	//printf("%d %d %d %d %d\n", n, minS1, minS2, minS3, minS4);
	//printf("%d %d %d %d %d\n", n, minN1, minN2, minN3, minN4);
	return n;
}

int main() {
	int i,n;
	int a[MAXN] = {0};

	scanf("%d", &n);

	FOR(i, 0, n) {
		scanf("%d", &a[i]);
	}
	printf("%d\n", solver(a, n));
	return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
void mergeSort(int A[],int,int );
void merge(int A[],int,int,int );
int Mid;
int c=0;
int L[500000],R[500000];
int main(){
        int A[1000000];
        int n,i;

        scanf("%d",&n);
        for(i=0; i<n; i++) {
                scanf("%d",&A[i]);
        }

        mergeSort(A,0,n);
        for(i=0; i<n; i++) {
                printf("%d",A[i]);
                if(i<n-1) printf(" ");
        }
        printf("\n");
        printf("%d\n",c);


        return 0;
}
void mergeSort(int A[],int Left,int Right){

        if(Left+1<Right) {
                int Mid=(Left+Right)/2;
                mergeSort(A,Left,Mid);
                mergeSort(A,Mid,Right);
                merge(A,Left,Mid,Right);

        }
}

void merge(int A[],int Left,int Mid,int Right){
        int i,j,l1,l2,k;
        l1=Mid-Left;
        l2=Right-Mid;

        for(i=0; i<l1; i++) {
                L[i]=A[Left+i];
        }
        for(j=0; j<l2; j++) {
                R[j]=A[Mid+j];
        }
        L[l1]=1000000000;
        R[l2]=1000000000;
        i=0;
        j=0;
        for(k=Left; k<Right; k++)
                if(L[i]<=R[j]) {
                        A[k]=L[i];
                        i++;
                        c++;

                }
                else{
                        A[k]=R[j];
                        j++;
                        c++;

                }
}



Measured memory_bytes: 5596
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;



int main() {
    int n;
    cin >> n;
    vector<P> red(n), blue(n);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        red[i] = P(a, b);
    }
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        blue[i] = P(a, b);
    }

    sort(all(red));
    sort(all(blue));
    vector<bool> used(n);

    rep(i, n) {
        vector<P>::iterator itr = lower_bound(all(red), blue[i]);
        int ma=-1;
        int x;
        itr--;
        for(;itr >= red.begin(); --itr) {
            if(!used[distance(red.begin(), itr)] && blue[i].second > (*itr).second) {
                if(ma < (*itr).second) {
                    ma = (*itr).second;
                    x = distance(red.begin(), itr);
                }
            }
        }
        if(ma != -1) {
            used[x] = true;
        }
    }

    int ans = 0;
    rep(i, n) {
        if(used[i]) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#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 a,b,h;
  cin>>a>>b>>h;
  cout<<(a+b)*h/2<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int sx, sy, tx, ty;
  int i;

  scanf("%d %d %d %d", &sx, &sy, &tx, &ty);
  for(i=sx;i<tx;i++){
    printf("R");
  }
  for(i=sy;i<ty;i++){
    printf("U");
  }
  for(i=tx;i>sx;i--){
    printf("L");
  }
  for(i=ty;i>sy;i--){
    printf("D");
  }
  printf("D");
  for(i=sx;i<tx+1;i++){
    printf("R");
  }
  for(i=sy;i<ty+1;i++){
    printf("U");
  }
  printf("L");
  printf("U");
  for(i=tx;i>sx-1;i--){
    printf("L");
  }
  for(i=ty;i>sy-1;i--){
    printf("D");
  }
  printf("R");

  return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mod 1000000007
 
using namespace std;

int main(){
  int count,tmp,i,K;
  cin >> K;
  vector<vector<int>> ansCount(17,vector<int>(9));
  vector<int> zeroCount(17,1);
  for(i=0; i<9; i++){
    ansCount.at(0).at(i) = 1;
  }
  int digit = 1, num = -1;
  count = 9;
  while(count < K){
    if(num != 8) num++;
    else{
      num = 0;
      zeroCount.at(digit) = zeroCount.at(digit-1) + ansCount.at(digit-1).at(0);
      digit++;
    }
    tmp = ansCount.at(digit-1).at(num);
    if(num != 0) tmp += ansCount.at(digit-1).at(num-1);
    else tmp += zeroCount.at(digit-1);
    if(num != 8) tmp += ansCount.at(digit-1).at(num+1);
    ansCount.at(digit).at(num) = tmp;
    count += tmp;
  }
  int diff, ansnum;
  long long ans =0;
  long long ten = 10;
  if(num == -1) cout << K;
  else{
    diff = K - count + tmp;
    tmp = 0;
    ansnum = num+1;
    for(i=digit; i>0; i--){
      ans += ansnum * pow(10, i);
      if(num != 0){
        tmp += ansCount.at(i-1).at(num-1);
        if(diff<=tmp){ansnum = num;tmp -= ansCount.at(i-1).at(num-1);num--;continue;}
      }
      else{
        tmp += zeroCount.at(i-1);
        if(diff<=tmp){ansnum = 0;tmp -= zeroCount.at(i-1);continue;}
      }
      tmp += ansCount.at(i-1).at(num);
      if(diff<=tmp){ansnum = num+1;tmp -= ansCount.at(i-1).at(num);continue;}
      if(num != 8){ansnum = num +2;num++;continue;}
    }
    ans += ansnum;
    cout << ans;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <cstring>

int c[16];
int x[20001];
int dp[256][20001];

int main() {
	int n, m;
	while (std::cin >> n >> m && (n || m)) {
		std::memset(dp, 0xff, sizeof(dp));
		for (int i = 0; i < m; i++) std::cin >> c[i];
		for (int i = 0; i < n; i++) std::cin >> x[i + 1];

		dp[128][0] = 0;
		for (int i = 1; i <= n; i++) { //????????????????????????
			for (int j = 0; j < 256; j++) { //?????????0~255??¨???????????????
				if (dp[j][i - 1] < 0) continue; //??????????????????
				for (int k = 0; k < m; k++) { //??¨?????????????????????????????????????????????
					int ny = j + c[k];
					if (ny < 0) ny = 0;
					else if (ny > 255) ny = 255;

					int v = (x[i] - ny) * (x[i] - ny);
					if (dp[ny][i] < 0) dp[ny][i] = dp[j][i - 1] + v;
					else {
						dp[ny][i] = std::min(dp[j][i - 1] + v, dp[ny][i]);
					}
				}
			}
		}
		int min = INT_MAX;
		for (int i = 0; i < 256; i++) if (dp[i][n] >= 0) min = std::min(dp[i][n], min);
		std::cout << min << std::endl;
	}

	return 0;
}

Measured memory_bytes: 23160
#include <iostream>
#include <vector>
#include <map>
using namespace std;

const int divisor = 1000000007;

int main(){
	vector<int> ansvec;

	// 100000!までの数をdivisorで割った余りを格納しておく
	long long* factmodary = new long long[100001];
	long long fact = 1;
	for (int i = 1; i <= 100000; i++){
		fact *= i;
		fact %= divisor;
		factmodary[i] = fact;
	}

	for (;;){
		int N, R;
		cin >> N;
		if (N == 0) break;
		cin >> R;

		int* word = new int[N];
		for (int i = 0; i < N; i++) word[i] = i + 1; //まず0番目の単語を入れておく

		for (int i = 0; i < R; i++){
			int s, t;
			cin >> s >> t;
			/* swap */
			int tmp = word[s - 1]; word[s - 1] = word[t - 1]; word[t - 1] = tmp;
		}

		long long ans = 0;
		map<int, int> bubblehist;

		for (int i = 0; i < N; i++){
			int facttime = word[i] - 1;
			int bubblenum;
			map<int, int>::iterator it = bubblehist.find(word[i] - 1);

			if (it != bubblehist.end()){
				bubblenum = it->second + 1;
			}
			else {
				it = bubblehist.find(word[i] + 1);
				if (it != bubblehist.end()){
					bubblenum = it->second;
				}
				else{
					bubblenum = 0;
					for (int j = 0; j < i; j++){
						if (word[j] < word[i]) bubblenum++;
					}
				}
			}
			pair<int, int> p;
			p.first = word[i];
			p.second = bubblenum;
			bubblehist.insert(it, p);
			for (map<int, int>::iterator it2 = bubblehist.upper_bound(word[i]); it2 != bubblehist.end(); it2++) ++(it2->second);

			facttime -= bubblenum;
			ans += factmodary[N - (i + 1)] * facttime;
			ans %= divisor;
		}

		delete[] word;
		ansvec.push_back((int)ans);
	}

	for (vector<int>::iterator it = ansvec.begin(); it != ansvec.end(); it++){
		cout << *it << "\n";
	}

	delete[] factmodary;
	return 0;
}

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

int main(){
  string toi;
  cin >> toi;
  char mozi[4];
  for(int i=0;i<4;i++){
    mozi[i]=toi[i];
  }
  bool frg=0;
  if(mozi[0]==mozi[1]&&mozi[2]==mozi[3])frg=1;
  if(mozi[0]==mozi[2]&&mozi[1]==mozi[3])frg=1;
  if(mozi[0]==mozi[3]&&mozi[1]==mozi[2])frg=1;
  if(mozi[0]==mozi[3]&&mozi[1]==mozi[2]&&mozi[1]==mozi[3])frg=0;
  if(frg==0){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
}


Measured memory_bytes: 256
package main

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

func main() {
	S := getStdin()
	for i := 0; i < len(S); i++ {
		if i%2 == 1 && (S[i] == 'R') {
			fmt.Printf("No\n")
			return
		}
		if i%2 == 0 && (S[i] == 'L') {
			fmt.Printf("No\n")
			return
		}
	}
	fmt.Printf("Yes\n")
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinIntU64() uint64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return uint64(rtn)
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func getStdinIntArrU64() []uint64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]uint64, len(list))
	for idx, val := range list {
		r, _ := strconv.ParseInt(val, 10, 64)
		rtn[idx] = uint64(r)
	}
	return rtn
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}
func abs64(n int64) int64 {
	if n < 0 {
		return -n
	}
	return n
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2176
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a;
vector<int>edge[100005];
int dp[100005];
void dfs(int v,int u){
	vector<int>vec;
	for(int i=0;i<edge[v].size();i++){
		if(edge[v][i] == u) continue;
		dfs(edge[v][i],v);
		vec.pb(dp[edge[v][i]]);
	}
	sort(vec.begin(),vec.end(),greater<int>());
	for(int i=0;i<vec.size();i++){
		dp[v] = max(dp[v],vec[i]+i+1);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;i++){
		scanf("%d",&a);
		edge[i].pb(a);
		edge[a].pb(i);
	}
	dfs(1,-1);
	cout << dp[1] << endl;
}

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

#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int A,B,K; cin >> A >> B >> K;
    set<int> ans;

    REP(i,min(B-A+1,K)){
        ans.insert(A+i);
        ans.insert(B-i);
    }
    for(auto a: ans) cout << a << endl;

    return 0;
}

Measured memory_bytes: 3624
/*
(1)for binary shift operator always use 'LL' 1LL<<63

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set_pair tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
  const double  pi=3.1415926535; 
  struct pair_hash
{
	template <class T1, class T2>
	std::size_t operator () (std::pair<T1, T2> const &pair) const
	{
		std::size_t h1 = std::hash<T1>()(pair.first);
		std::size_t h2 = std::hash<T2>()(pair.second);

		return h1 ^ h2;
	}
};
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;cin>>n;
	ll i,j,c1=0,c2=0,c3=0,c4=0;
	for(i=0;i<n;i++){
		string s;
		cin>>s;
		if(s=="AC")
			c1++;
		else if(s=="WA")
			c2++;
		else if(s=="TLE")
			c3++;
		else c4++;

	}
	cout<<"AC x "<<c1<<endl;
	cout<<"WA x "<<c2<<endl;
	cout<<"TLE x "<<c3<<endl;
	cout<<"RE x "<<c4<<endl;

	return 0;
} 

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

//____________________________________________________________________________________________________________________________________

#define PI  2*acos(0.0)
#define pf  printf
#define sf  scan
#define ff  first
#define ss  second
#define mp  make_pair
#define pb  push_back
typedef long long ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef vector<long long> vll ;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define sc(n)       sf("%d",&n);
#define scf(f)      sf("%f",&f);
#define FOR(i,a,n)  for(int i = a; i < n; i++)
#define TEST(test)  for(int cse = 1; cse <= test; cse++)

#define all(x) (x).begin(), (x).end()
#define fap(x) cout << __LINE__ << " says: " << #x << " = " << x << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const ll INF = 2000000000000000000LL;
const int inf = 0x3f3f3f3f;
const long double EPS = 1e-9;
//____________________________________________________________________________________________________________________________________

int is_find[200];


int main()
{
#ifdef PARTHO
    freopen("/home/partho/Desktop/IO/input.txt","r",stdin);
    freopen("/home/partho/Desktop/IO/output.txt","w",stdout);
    int start_time = clock();
#endif
FastIO;


int value;

int x, n;

cin >> x >> n;
for(int i = 0; i < n; i++) 
{
	cin >> value;
	is_find[ value ] = 1;
}

int ans = -1, mn = inf;
for(int i = 0; i <= 101; i++)
{
	if(is_find[i] == 0){

		if(mn > abs(i - x)){
			mn = abs(i - x);
			ans = i;
		}
	}
}

cout << ans << endl;


#ifdef PARTHO
    int end_time = clock(); 
    printf("Time = %.4f\n",(end_time-start_time+0.0)/CLOCKS_PER_SEC);
#endif

    return 0;
}
///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1


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

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>
#include <set>

using namespace std;

#define ALL(co) co.begin(), co.end()

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> IP;
typedef pair<P, P> PP;
typedef vector<int> Array;
typedef vector<vector<int> > Array2;
typedef vector<int> LArray;

const int INF = 1 << 29;
const LL LINF = 1LL << 60;

int itiv;
inline int getInt() { return (cin >> itiv, itiv); }
void readAll(Array& vec, int n) { for (int i = 0; i < n; i++) cin >> vec[i]; }
inline bool between(int first, int last, int n) { return first <= n && n <= last; }
inline bool inRange(int begin, int end, int n) { return begin <= n && n < end; }
inline bool inRange(int size, int n) { return 0 <= n && n < size; }

int w, h;
int dx[] = { -1, 0, 1, 0 }, dy[] = { 0, -1, 0, 1 };
int dr[] = { 0, -1, 0, 1 }, dc[] = { -1, 0, 1, 0 };


int main(void)
{
	while(cin >> w >> h && w)
	{
		int n = getInt();
		Array ws(n), hs(n);
		for (int i = 0; i < n; i++)
		{
			cin >> ws[i] >> hs[i];
		}
		int ans = 0;
		for (int i = 1; i < n; i++)
		{
			int wsa = ws[i - 1] - ws[i], hsa = hs[i - 1] - hs[i];
			if(wsa * hsa < 0)
				ans += abs(wsa) + abs(hsa);
			else
				ans += max(abs(wsa), abs(hsa));
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
using System;
using System.Linq;
using System.Collections.Generic;
namespace AtCoderBeginnerContest152
{
	class Program
	{
		static void Main(string[] args)
		{

			var n = Console.ReadLine();
			var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
			// var input = new long[]{
			// 	4, 1, 3, 1, 6, 26
			// };

			var set = new HashSet<long>();

			for (var i = 0; i < input.Length; i++)
			{
				if (set.Contains(input[i]))
				{
					System.Console.WriteLine("NO");
					return;
				}
				else
				{
					set.Add(input[i]);
				}
			}

			System.Console.WriteLine("YES");
		}
	}
}

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

int main() {
    int n, t;
    cin >> n;
    int x[n], y[n], h[n];
    rep(i, n) {
        cin >> x[i] >> y[i] >> h[i];
        if (h[i] > 0) t = i;
    }

    rep(cx, 101) rep(cy, 101) {
        bool ok = true;
        int H = h[t] + abs(x[t] - cx) + abs(y[t] - cy);
        if (H < 1) continue;

        rep(i, n) {
            if (h[i] != max(H - abs(x[i] - cx) - abs(y[i] - cy), 0)) ok = false;
        }

        if (ok) {
            cout << cx << ' ' << cy << ' ' << H << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>
#define MAX 100
#define INFTY 100000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[MAX][MAX];

void dijkstra(){
  int minv,i,u,v;
  int d[MAX],color[MAX];

  for(i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }

  d[0]=0;
  color[0]=GRAY;
  while(1){
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i]!=BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1) break;
    color[u]=BLACK;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i]!=BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1) break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK && M[u][v]!=INFTY){
	if(d[v]>d[u] + M[u][v]){
	  d[v]=d[u]+M[u][v];
	  color[v]=GRAY;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d ",i);
    if(d[i]==INFTY) printf("-1\n");
    else printf("%d\n",d[i]);
  }
}

int main(){
  int i,j,k,c,u,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=INFTY;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      M[u][v]=c;
    }
  }

  dijkstra();

  return 0;
}


 



Measured memory_bytes: 2104
while True:
    n,x = map(int,raw_input().split())
    if n==0 and x==0:
        break
    ct = 0
    for i in xrange(1, n+1):
       for j in xrange(i+1, n+1):
           for k in xrange(j+1, n+1):
               if (i+j+k) == x:
                   ct += 1
    print ct

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

int	main()
{
	int	n;
	double	s;
	double	square_sum = 0, ave = 0;
	while (cin >> n) {
		if (n == 0) break;
		square_sum = 0;
		ave = 0;
		for (int i = 0; i < n; ++i) {
			cin >> s;
			ave = (ave * i + s) / (i + 1);
			square_sum += s * s;
		}
		cout << fixed << setprecision(8);
		cout << sqrt((square_sum - n * ave * ave) / n) << endl;
	}
}


Measured memory_bytes: 3216
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
 
// ここから
function main(){

  var primeNumbers = new Int32Array(65535);
  var maxNum = 0;

  // 最大値
  for(var line = 0, inputLength = input.length; line < inputLength - 1; line++){
    var num = input[line] - 0;
    maxNum = maxNum < num ? num : maxNum;
  }

  // 素数計算
  primeNumbers[0] = 2;
  var pcount = 1;
  for(var i = 3; i <= maxNum; i+=2){
    var isPrime = true;
    for(var j = 3, maxJ = ~~Math.sqrt(i); j <= maxJ; j+=2){
      if(!(i % j)){
        isPrime = false;
        break;
      }
    }

    if(isPrime){
      primeNumbers[pcount] = i;
      pcount++;
    }
  }

  // 出力
MLOOP: for(var line = 0, inputLength = input.length; line < inputLength - 1; line++){
    for(var k = 0; k < pcount; k++){
      var prime = primeNumbers[k];
      if(prime > (input[line] - 0)){
        console.log(k);
        continue MLOOP;
      }
    }
  console.log(pcount);
  
  }

  
  
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


vector<i64> G[23];

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

    REP(i, s.length()) {
        i64 si = s[i] - 'a';
        if (G[si].size() == 0) G[si].reserve(s.length());
        G[si].emplace_back(i);
    }

    i64 ans;
    i64 cur = -1;
    i64 rc = 0;
    REP(i, t.length()) {
        i64 ti = t[i] - 'a';
        if (G[ti].size() == 0) {
            ans = -1;
            break;
        }
        auto ub = upper_bound(G[ti].begin(), G[ti].end(), cur);
        if (ub == G[ti].end()) {
            cur = G[ti][0];
            rc++;
        } else {
            cur = *ub;
        }

        if (i == t.length() - 1) {
            ans = s.length() * rc + (cur + 1);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1488
#include <iostream>

using namespace std;

int main()
{
  int H;
  int W;
  int i;
  int j;
  
  while(1)
  {
    cin >> H >> W;
    
    if(H==0 && W==0)
      goto EXIT;
    
    for(i=0;i<H;i++)
    {
      for(j=0;j<W;j++)
      {
        cout << "#";
      }
      cout <<"\n";
    }
  
  cout << "\n";
  }
  EXIT:;
}

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

struct UnionFind {
  vector<int> par, siz;
  UnionFind (int n) {
    par.resize(n), siz.resize(n);
    for (int i = 0; i < n; i++) {
      par.at(i) = i, siz.at(i) = 1;
    }
  }
  int root(int x) {
    if (par.at(x) == x) return x;
    return par.at(x) = root(par.at(x));
  }
  int size(int x) {
    return siz.at(root(x));
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  bool unit(int x, int y) {
    x = root(x), y = root(y);
    if (x == y) return false;
    if (siz.at(x) > siz.at(y)) {
      par.at(y) = x, siz.at(x) += siz.at(y);
    } else {
      par.at(x) = y, siz.at(y) += siz.at(x);
    }
    return true;
  }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  UnionFind UF(N);
  for (int x, y, z; cin >> x >> y >> z;) {
    UF.unit(--x, --y);
  }
  set<int> SE;
  for (int i = 0; i < N; i++) {
    SE.insert(UF.root(i));
  }
  cout << SE.size() << "\n";
}

Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e9;
const long long LINF = 1LL << 50;
#define int long long

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	int ans = 0;
	char now = s.at(0);
	rep(i, s.size()) {
		if (now != s.at(i)) {
			ans++;
			now = s.at(i);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>    // cin, cout
#include <string>    // string, stoi, to_string
#include <algorithm>    // sort, lower_bound, heap, min, next_permutation 
#include <functional>    // greater, less
#include <vector>    // vector
#include <stack>    // stack
#include <queue>    // queue
#include <list>    // list
#include <map>    // map
#include <set>    // set
#include <tuple>    // tuple
#include <bitset>    // bitset
#include <cstdio>  // fopen, printf, scanf, puts
#include <cmath>    // sin, exp, log, pow, sqrt
#include <iomanip>    // setfill, setbase
#include <ctime>    // clock

using namespace std;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30));
const long long linf = (1LL<<60);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a=0, b=0, c=0, d=0;
    for(int i=0; i<n; i++)
    {
        string s;
        cin >> s;
        if(s == "AC") a++;
        else if(s == "WA") b++;
        else if(s == "TLE") c++;
        else d++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
    return 0;
}


Measured memory_bytes: 3640
s=str(input())
a=0
b=0
c=0
for i in range(len(s)):
    if(s[i]=='a'):
        a+=1
    if(s[i]=='b'):
        b+=1
    if(s[i]=='c'):
        c+=1

if(abs(a-b)<2 and abs(c-b)<2 and abs(c-a)<2):
    print("YES")
else:
    print("NO")
   

Measured memory_bytes: 3188
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)



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

	if (a + b >= 10) {
		cout << "error" << endl;
	} else {
		cout << a + b << endl;
	}
	return 0;
}




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

int main(){
    int n;
    cin >> n;
    int cnt = 0;
    
    for(int i = 1; i<=n; i++) {
        int a;
        cin >> a;
        if(a%2 == 1 && i% 2 == 1) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}



int dp[55][55][5505];
const int mod=1e9+7;

signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif      

    int n,k;
    cin>>n>>k;
    int lim=2500;
    dp[0][0][lim]=1;

    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            for(int l=0;l<=5000;l++)
            {
                dp[i][j][l]+=dp[i-1][j][l]*(2*j+1)%mod;
                if(l+2*i<=5000 && j>0)
                    dp[i][j][l]+=dp[i-1][j-1][l+2*i];
                if(l-2*i>=0 && j<=i)
                    dp[i][j][l]+=dp[i-1][j+1][l-2*i]*(j+1)*(j+1)%mod;
                dp[i][j][l]%=mod;
            }
        }
    }

    cout<<dp[n][0][k+lim];

}       


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

#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(ll i = (m); i < (n); ++i)

#define INF 1e9

int main(){
  string A;
  cin >> A;
  vector<int> cnt(26, 0);
  REP(i, A.size()){
    cnt[A[i] - 'a']++;
  }
  ll ans = (ll)A.size()*(A.size()+1)/2;
  REP(i, 26){
    ans -= (ll)cnt[i] * (cnt[i]+1)/2;
  }
  cout << ans+1 << endl;

  return 0;
}


Measured memory_bytes: 640