akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#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 irep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    string s;
    cin>>s;
    reverse(all(s));
    
    int n=s.size();
    int i=0;
    string ans="YES";
    while(i<n){
        bool ok=false;
        if(i<n-4&&s.at(i)=='m'&&s.at(i+1)=='a'&&s.at(i+2)=='e'&&s.at(i+3)=='r'&&s.at(i+4)=='d'){
            ok=true;
            i+=5;
        }
        if(i<n-4&&s.at(i)=='e'&&s.at(i+1)=='s'&&s.at(i+2)=='a'&&s.at(i+3)=='r'&&s.at(i+4)=='e'){
            ok=true;
            i+=5;
        }
       if(i<n-6&&s.at(i)=='r'&&s.at(i+1)=='e'&&s.at(i+2)=='m'&&s.at(i+3)=='a'&&s.at(i+4)=='e'&&s.at(i+5)=='r'&&s.at(i+6)=='d'){
            ok=true;
            i+=7;
        }
        if(i<n-5&&s.at(i)=='r'&&s.at(i+1)=='e'&&s.at(i+2)=='s'&&s.at(i+3)=='a'&&s.at(i+4)=='r'&&s.at(i+5)=='e'){
            ok=true;
            i+=6;
        }
        if(!ok){
            ans="NO";
            break;
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 512
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

int main(){
	int N;
	cin>>N;
	if(N<1000){
		cout<<"ABC"<<endl;
	}else{
		cout<<"ABD"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	var out []string

	for {
		var a string

		fmt.Scan(&a)

		if a == "-" {
			break
		}

		var m int

		fmt.Scanf("%d", &m)

		for i := 0; i < m; i++ {

			var h int
			fmt.Scanf("%d", &h)

			a = a[h:len(a)] + a[0:h]

		}

		out = append(out, a)

	}

	for _, v := range out {
		fmt.Println(v)
	}

}



Measured memory_bytes: 1152
import heapq

N, M = list(map(int, input().split()))
jobs = [[] for _ in range(M)]

for i in range(N):
    d, r = list(map(int, input().split()))
    if d-1 < M:
        jobs[d-1].append(-r)

#解法
rewards = 0
heap = []
for i in range(M):
    for reward in jobs[i]:
        heapq.heappush(heap, reward)
    if len(heap) >0:
        reword = heapq.heappop(heap)
        rewards += -reword

print(rewards)

Measured memory_bytes: 23752
#include <iostream>
using namespace std;
int main(){
    int c1,c5,c10,c50,c100,c500;cin>>c1>>c5>>c10>>c50>>c100>>c500;
    long long a = c1+c5*5+c10*10+c50*50+c100*100+c500*500;
    if(a >= 1000)cout <<1 << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int h,w,x;
char s[1000][1000];
bool visited [1000][1000];
pair<int,int> start,goal;
queue<pair<int,pair<int,int>>> q;
vector<pair<int,int>> ino;

int main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  //int a[3];cin>>a[0]>>a[1]>>a[2];sort(a,a+3);
  /*if(a[2]==a[1]+a[0]){
    cout<<"Yes";
  }else{
    cout<<"No";
  }*/
  cout << min(a,b)*c+max(0,a-b)*d;
}


Measured memory_bytes: 256
n=int(input())
cl=[]
for i in range(1,n+1) :
  count=0
  temp=i
  while(True) :
    if temp % 2== 0:
      temp=temp/2 
      count+=1
    else :
      break
  cl.append(count)
  
print((cl.index(max(cl)))+1)

Measured memory_bytes: 3060
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath>
#include<set>
#include<utility>

using namespace std;


int main()
{
int k, a, b;
	cin >> k >> a >> b;
	if (b - a <=2)
	{
		cout << k + 1 << endl;
	}
	else
	{
		long long int x = max(0,((k-(a-1))/2));
		cout << a + x * (b-a)+(k-(a-1))%2 << endl;

	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001; // > 10^9
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

  int n,h; cin >>h>>n;
  vector<int> a(n); vector<int> b(n);
  rep(i,n) cin >> a[i] >> b[i];

  vector<vector<int> > dp(n+1, vector<int>(3*h, INF));
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3*h; j++) {
      dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - a[i]] + b[i]);
    }
  }

  int ans = INF;
  for (int j = h; j < 3*h; j++) {
    ans = min(ans, dp[n][j]);
  }

  cout << ans << endl;

  return 0;
}




Measured memory_bytes: 117760
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
 	ll n,k;
  cin>>n>>k;
  ll a[n+1];
  ll dp[n+1];
  for(int i=1;i<=n;i++)
    dp[i]=100000000000;
  for(int i=1;i<=n;i++)
    cin>>a[i];
  dp[1]=dp[0]=0;dp[2]=abs(a[2]-a[1]);
  for(ll i=3;i<=n;i++){
   for(ll j=i-1;j>=i-k&&j>=1;j--){
    dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j])); 
   }
  }
  cout<<dp[n];
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int n, m;
const int maxn = 1000 + 10;
typedef long long ll;
struct Edge
{
    int from, to;
    ll dist;
    Edge(int u, int v, ll d) : from(u), to(v), dist(d){}
};
vector<Edge> edges;
vector<int> G[maxn];
ll d[maxn];
int inq[maxn], cnt[maxn];
void addEdge(int from, int to, ll dist) {
    edges.push_back(Edge(from, to, dist));
    int t = edges.size();
    G[from].push_back(t - 1);
}
bool done[maxn];
bool ok = false;
void dfs(int u){
    if(u == n) {
        ok = true;
        return;
    }
    if(done[u]) return;
    done[u] = true;
    for(int i = 0; i < (int)G[u].size(); ++i) {
        Edge&e = edges[G[u][i]];
        dfs(e.to);
    }
}
const ll inf = (ll)1e18;
bool judge(int u){
    ok = false;
    dfs(u);
    return ok;
}
bool dijkstra(){
    for(int i = 1; i <= n; ++i){
        d[i] = inf;
    }
    d[1] = 0;
    inq[1] = 1;
    queue<int> Q;
    Q.push(1);
    while(!Q.empty()) {
        int u = Q.front(); Q.pop();
        inq[u] = 0;
        for(int i = 0; i < (int)G[u].size(); ++i){
            Edge&e = edges[G[u][i]];
            if(d[u] < inf && d[e.to] > d[u] + e.dist){
                d[e.to] = d[u] + e.dist;
                if(!inq[e.to] && cnt[e.to] <= n + 1) {
                    Q.push(e.to);
                    inq[e.to] = 1;
                    if(++cnt[e.to] > n) {
                        if(judge(e.to))
                          return false;
                    }
                }
            }
        }
    }
    return true;
}
int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(0);
    cin >> n >> m;
    for(int i = 1; i <= m; ++i) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        c = -c;
        addEdge(a, b, c);
    }
    if(dijkstra()){
        cout << -d[n] << endl;
    }else{
        cout << "inf\n";
    }
    return 0;
}

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


using namespace std;


int main()
{
  int n, alpha[123]={50}, cnt;
  string s;

  for (int i=0; i<123; i++) alpha[i] = 50;

  cin >> n;
  for (int i=0; i<n; i++){
    cin >> s;
    for (int j='a'; j<='z'; j++){
      cnt = 0;
      for (int k=0; k<s.length(); k++){
	if (s[k] == (char)j){
	  cnt++;
	}
      }
      if (cnt < alpha[j]){
	alpha[j] = cnt;
      }
    }
  }

  for (int i='a'; i<='z'; i++){
    for (int j=0; j<alpha[i]; j++){
      cout << (char)i;
    }
  }
  cout << endl;
	  
  return 0;
}


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

using namespace std;

int main() {
    long long K, N;
    cin >> K >> N;
    long long arr[N];
    for(long long i = 0; i < N; i++){
        cin >> arr[i];
    }
    if(N > 2){
        long long final_dist = LLONG_MAX;
        long long dist1;
        long long dist2;
        for(long long i = 0; i < N-1; i++){
            dist2 = K + min(arr[i], arr[i + 1]) - max(arr[i], arr[i + 1]);
            final_dist = min(final_dist, dist2);
        }
        dist1 = max(arr[N - 1], arr[0]) - min(arr[N - 1], arr[0]);
        final_dist = min(final_dist, min(dist1, dist2));
        cout << final_dist << endl;
    }
    else{
        long long diff1 = abs(arr[0] - arr[1]); 
        long long diff2 = abs(K + min(arr[0], arr[1]) - max(arr[0], arr[1]));
        cout << min(diff1, diff2) << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int ans=0;
	char s;
	while(cin>>s)
		ans|=1<<s-'a';
	if(ans==67108863)
		cout<<"None"<<endl;
	else
		cout<<char(__builtin_ctz(~ans)+'a')<<endl;
}


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

using namespace std;

int cnt[2020];
char s[200005];

int main() {
	scanf("%s", s);
	
	int l = strlen(s);
	
	long long res = 0;
	long long cur = 0;
	long long pw = 1;
	
	cnt[0] = 1;
	for (int i = l - 1; i >= 0; i--) {
		cur = (cur + pw * (s[i] - '0')) % 2019;
		pw = (pw * 10) % 2019;
		res += cnt[cur];
		cnt[cur]++;
	}
	
	printf("%lld\n", res);
}


Measured memory_bytes: 4032
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main()
{
    int N;
    cin>>N;
    vector<int> a(N);
    for (int &t: a)
        cin>>t,
        t--;

    vector<int> b(N);
    for (int i=0; i<N; i++)
        b[a[i]] = i;

    set<int> S;
    S.insert(-1);
    S.insert(N);

    long long ans = 0LL;

    for (int i=0; i<N; i++)
    {
        auto t = S.lower_bound(b[i]);
        t--;
        int l = *t;
        int r = *S.upper_bound(b[i]);
        ans += (long long)(i+1)*(b[i]-l)*(r-b[i]);

        S.insert(b[i]);
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 11136
package main

import (
	"fmt"
)

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)
	l := n / (a + b)
	fmt.Println(a*l + min(n-l*(a+b), a))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
void YesNo(bool);
void YESNO(bool);


int main(){
    int a, b;
    cin >> a >> b;
    
    if (a < 9 && b < 9) {
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
    
    return 0;
}


void YesNo(bool x){
    if (x) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

void YESNO(bool x){
    if (x) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}


Measured memory_bytes: 256
s = input()
t = input()
ans = len(t)

for i in range(len(s)):
  if (i + len(t) - 1 >= len(s)): break
  dif = 0
  for j in range(len(t)):
    if (s[i + j] != t[j]):
      dif += 1
  ans = min(ans, dif)
print(ans)

Measured memory_bytes: 8800
#include <iostream>
#include<vector>
using namespace std;
int main(){
int n,m;
cin>>n>>m;
vector<vector<int>> dp(n,vector<int>(n,1e9));
vector<int[3]> g(m);
for(auto &a:g){
for(auto&b:a)cin>>b,b--;
a[2]++;
dp[a[0]][a[1]]=dp[a[1]][a[0]]=a[2];
}
for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)if(dp[i][k]+dp[k][j]<=dp[i][j])dp[i][j]=dp[i][k]+dp[k][j];
int ans=0;
for(auto &a:g)if(dp[a[0]][a[1]]!=a[2])ans++;
cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

// ref : http://wk1080id.hatenablog.com/entry/2018/01/18/114818

vector<int> g[100010];
bool seen[100010];

int main(){
    int n, m, v; // v : スタート地点
    cin >> n >> m;
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
        v = a;
    }

    vector<int> path;

    while(true){    
        bool flag = 0;
        for(auto nv : g[v]){
            if (seen[nv]) continue;
            path.push_back(nv);
            v = nv;
            seen[nv] = 1;
            flag = 1;
            break;
        }
        if(!flag) break;
    }

    v = path[0];
    reverse(path.begin(), path.end());

    while(true){    
        bool flag = 0;
        for(auto nv : g[v]){
            if (seen[nv]) continue;
            path.push_back(nv);
            v = nv;
            seen[nv] = 1;
            flag = 1;
            break;
        }
        if(!flag) break;
    }

    cout << path.size() << endl;
    for(auto e : path) cout << e + 1 << " ";
    cout << endl;

    return 0;
}


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

int main(){

    int ans,minv,n,tem;

    cin >> n;
    cin >> tem;

    minv = tem;
    ans = -2000000000;

    for(int i = 1; i < n; i++ ){
        cin >> tem;

    if (ans < tem - minv) ans = tem - minv; 
    if (tem < minv) minv = tem;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3104
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
int num[200010];
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>num[i];
	for(int i=k+1;i<=n;i++)
		if(num[i]>num[i-k])
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 5200
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
using namespace std;

int N;
vector<int> A, B, C;

int main()
{
  cin >> N;
  A.resize(N);
  B.resize(N);
  C.resize(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++)
  {
    cin >> B[i];
  }
  for (int i = 0; i < N; i++)
  {
    cin >> C[i];
  }

  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());

  long long int ans = 0;

  for (int b = 0; b < N; b++)
  {
    vector<int>::iterator a_lb_it = lower_bound(A.begin(), A.end(), B[b]);
    long long int a_lb_index = a_lb_it - A.begin();

    vector<int>::iterator c_ub_it = upper_bound(C.begin(), C.end(), B[b]);
    long long int c_ub_index = c_ub_it - C.begin();

    ans += a_lb_index * (N - c_ub_index);
  }

  cout << ans << endl;
}

Measured memory_bytes: 1408
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     mt           make_tuple
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=3e3+10;

vector<vector<ld>> dp(N,vector<ld>(N,-1));       // (index, heads till now)

vector<ld> p;
int n;

ld rec(int ind,int h)
{
    if(ind==-1)
        return h>(n/2);

    if(dp[ind][h]!=-1)
        return dp[ind][h];

    ld res=0;
    res=( (1-p[ind])*rec(ind-1,h) + p[ind]*rec(ind-1,h+1) );

    //cout<<ind<<" "<<h<<" "<<res<<"\n";

    return (dp[ind][h]=res);
}

void solve()
{
    cin>>n;

    p.resize(n);
    for(int i=0;i<n;++i)
        cin>>p[i];

    ld ans=rec(n-1,0);

    cout<<fixed<<setprecision(10)<<ans;
}

int32_t main()
{
    //fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];

  ll now = 1;
  ll ans = 0;
  REP(i, n) {
    if (a[i] != now) {
      ++ans;
    } else {
      ++now;
    }
  }

  if (now == 1) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1792
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    s = input()
    if s == 'SUN':
        print(7)
    if s == "MON":
        print(6)
    if s == "TUE":
        print(5)
    if s == "WED":
        print(4)
    if s == "THU":
        print(3)
    if s == "FRI":
        print(2)
    if s == "SAT":
        print(1)
    return


# B
def B():
    al = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
    n = I()
    s = S()
    for i in range(len(s)):
        ni = (al.index(s[i]) + n) % 26
        s[i] = al[ni]
    print(''.join(s))
    return


# C
def C():
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    B()
    return


# Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 39920
from collections import deque
n = int(input())
nums =[]

for i in range(n):
  nums.append(int(input()))

nums.sort()
nums = deque(nums)
a = [nums.pop()]
a = deque(a)

while not len(nums) == 0:
  try:
    a.appendleft(nums.popleft())
    a.append(nums.popleft())
    a.appendleft(nums.pop())
    a.append(nums.pop())
  except IndexError:
    pass

tmp_1 = abs(a[-1] - a[-2])
tmp_2 = abs(a[-1] - a[0])

if tmp_1 < tmp_2:
  a.appendleft(a.pop())

sub = 0
for i in range(1, len(a)):
  sub += abs(a[i-1]-a[i])
print(sub)


Measured memory_bytes: 8120
#include <iostream>
#include <vector>

using namespace std;

int N;
vector<int> L(int n){
    vector<int> V(N*N);
    for(int i=0;i<N*N;i++) V[i]=i;
    for(int i=N*(n-1);i<N*n-1;i++){
        V[i]=i+1;
    }
    V[N*n-1]=N*(n-1);
    return V;
}

vector<int> R(int n){
    vector<int> V(N*N);
    for(int i=0;i<N*N;i++) V[i]=i;
    for(int i=N*(n-1)+1;i<N*n;i++){
        V[i]=i-1;
    }
    V[N*(n-1)]=N*n-1;
    return V;
}

vector<int> U(int n){
    vector<int> V(N*N);
    for(int i=0;i<N*N;i++) V[i]=i;
    for(int i=n-1;i+N<N*N;i+=N) V[i]+=N; 
    V[N*(N-1)+(n-1)]=n-1;
    return V;
}

vector<int> D(int n){
    vector<int> V(N*N);
    for(int i=0;i<N*N;i++) V[i]=i;
    for(int i=N+n-1;i<N*N;i+=N) V[i]-=N;
    V[n-1]=N*(N-1)+(n-1);
    return V;
}   

vector<int> C(vector<int> V1, vector<int> V2){
    vector<int> V(N*N);
    for(int i=0;i<N*N;i++) V[i]=V1[V2[i]];
    return V;
}

vector<int> T(vector<int> V ,int n){
    int b=1;
    vector<int> B=V;
    vector<int> ret(N*N);
    for(int i=0;i<N*N;i++) ret[i]=i;
    while(n>=b){
        if(b&n){
            ret=C(ret,B);
        }
        B=C(B,B);
        b<<=1;
    }
    return ret;
}

int number(string S, int& ite){
    int n=0;
    while('0'<=S[ite]&&S[ite]<='9'){
        n*=10;
        n+=S[ite]-'0';
        ite++;//テ」ツ?禿」ツ?ョテヲツ卍づァツつケテ」ツ?ァテ」ツ?ッ')'テ」ツ?凝ヲツ慊ォテ・ツーツセ
    }
    return n;
}

vector<int> rec(string S, int& ite){
    vector<int> ret(N*N),fac;
    for(int i=0;i<N*N;i++) ret[i]=i;
    while(ite<S.size()){
        if(S[ite]=='('){
            ite++;
            fac=rec(S,ite);
            ite++;//')'テ」ツつ津ィツェツュテ」ツ?ソテゥツ」ツ崚」ツ?ーテ」ツ??
            fac=T(fac,number(S,ite));
            ret=C(ret,fac);
        }else{
            if(S[ite]=='R'){
                ite++;
                fac=R(number(S,ite));
            }else if(S[ite]=='L'){
                ite++;
                fac=L(number(S,ite));
            }else if(S[ite]=='D'){
                ite++;
                fac=D(number(S,ite));
            }else if(S[ite]=='U'){
                ite++;
                fac=U(number(S,ite));
            }else{
                cout<<"err"<<endl;
                exit(1);
            }
            ret=C(ret,fac);
        }
        if(S[ite]==')') break;
    }
    return ret;
}

int main(){
    int l;
    cin>>N>>l;
    string S;
    cin>>S;
    if(N==1){
        cout<<1<<endl;
        return 0;
    }
    int i=0;
    vector<int> ans = rec(S,i);
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(j)cout<<' ';
            cout<<ans[i*N+j]+1;
        }
        cout<<endl;
    }

    return 0;
}

Measured memory_bytes: 16544
### constant

MAX_P = 10000

### subroutines

def gen_primes(max_p)
  primes = Array.new(max_p + 1){true}
  primes[0] = primes[1] = false

  s_max_p = Math.sqrt(max_p + 0.5).to_i

  for p in (2..s_max_p)
    if primes[p]
      for q in (p * p).step(max_p, p)
        primes[q] = false
      end
    end
  end

  primes
end

### main

primes = gen_primes(MAX_P)

while line = gets
  n = line.strip.to_i

  count = 0

  for i in (1..n)
    if primes[i] && primes[n + 1 - i]
      count += 1
    end
  end

  puts count
end

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

int main() {
    int i,j,n;
    string s;
    scanf("%d", &n);
    cin >> s;
    vector<int> suff(n + 5, 0);
    vector<int> pref(n + 5, 0);
    suff[0] = 0;
    for(i = 0; i < n; i++){
        suff[i + 1] = (suff[i] | (1 << (s[i] - 'a')));
    }
    
    pref[n] = 0;
    for(i = n - 1; i >= 0; i--){
        pref[i + 1] = (pref[i + 2] | (1 << (s[i] - 'a')));
    }
    
    int maxi = 0;
    for(i = 1; i <= n; i++){
        // printf("%d %d %d %d\n", i, suff[i], pref[i], suff[i] & pref[i + 1]);
        maxi = max(maxi, __builtin_popcount(suff[i] & pref[i + 1]));
    }
    printf("%d", maxi);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		sc.close();
		if(N.charAt(0) == N.charAt(2)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <bitset>
#define SIZE 200002

using namespace std;

int main(){
    int X,Y;
    int flg = 0;
    cin >> X >> Y;

    for(int i = 0 ; i <= X ; i++){
        if(i*2+(X-i)*4 == Y){
            flg++;
            break;
        }
    }
    if(flg){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
  	return 0;
}

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

ll K,S,ans;

int main(void){
    cin >> K >> S;
    for(int i =0;i<=K;i++){
        for(int j=0;j<=K;j++){
            if(S-i-j>=0 && S-i-j<=K)ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define cY cout << "Yes" << endl;
#define cN cout << "No" << endl;

int main() {
  ll n;
  cin >> n;
  vector<ll>a(n);
  rep(i,n) cin >> a.at(i);
  sort(a.begin(),a.end());
  bool x = true;
  rep(i,n-1){
    if(a.at(i) == a.at(i+1)){
      x = false;
      break;
    }
  }
  if(x) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 1792
n = int(input())
ans = 0

d = 2
while d * d <= n:
    if n % d != 0:
        d += 1
        continue

    e = d
    while n % e == 0:
        n //= e
        e *= d
        ans += 1

    while n % d == 0:
        n //= d
if n != 1:
    ans += 1

print(ans)

Measured memory_bytes: 9188
import itertools
n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]

way = 0
p_list = [i for i in range(n)]
for P in itertools.permutations(p_list):
    for i in range(n-1):
        way += ((xy[P[i+1]][1]-xy[P[i]][1])**2+(xy[P[i+1]][0]-xy[P[i]][0])**2)**0.5

kai = 1
for i in range(n):
    kai *= (i+1)

print(way/kai)

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

int N, M, Q;
ll func(vector<ll> q, const vector<vector<int>> &v){
    if(q.size()==N){
        ll ret = 0;
        for (int i = 0; i < Q; i++)
        {
            if(q[v[i][1]-1] - q[v[i][0]-1] == v[i][2]) ret+=v[i][3];
        }
        return ret;
    }
    ll m = 0;
    for (int i = q[q.size()-1]; i <= M; i++)
    {
        vector<ll> r = q;
        r.push_back(i);
        m = max(m, func(r, v));
    }
    return m;
}

int main(){
    cin >> N >> M >> Q;
    vector<vector<int>> v(Q, vector<int>(4));
    for (int i = 0; i < Q; i++)
        for (int j = 0; j < 4; j++) cin >> v[i][j];

    vector<ll> q(1, 1);
    ll ans = func(q, v);
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,w) for (int i = 0;i < (w); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;

int main(){
  int n,t;cin >> n >> t;
  vector<int> a(n),m(n+1);
  rep(i,n) cin >> a[i];
  for(int i = n-1;i >= 0;i--){
    m[i] = max(m[i+1],a[i]);
  }

  int mx = 0;
  int ans = 0;
  rep(i,n){
    if(a[i]!= m[i]) a[i] = m[i]-a[i];
    else a[i] = 0;
    mx = max(mx,a[i]);
  }
  rep(i,n) if(a[i]==mx) ans++;
  cout << ans << endl;

  
  
}

Measured memory_bytes: 4032
n = int(input())
a = list(map(int, input().split()))

sum_a = 0
ans_plus = 0
ans_minus = 0
for i in range(n):
    if i % 2 == 0:
        sum_a += a[i]
        if sum_a <= 0:
            ans_plus += (1 - sum_a)
            sum_a = 1
    else:
        sum_a += a[i]
        if sum_a >= 0: 
            ans_plus += (sum_a - -1)
            sum_a = -1

sum_a = 0
for i in range(n):
    if i % 2 == 0:
        sum_a += a[i]
        if sum_a >= 0:
            ans_minus += (sum_a - -1)
            sum_a = -1
    else:
        sum_a += a[i]
        if sum_a <= 0: 
            ans_minus += (1 - sum_a)
            sum_a = 1


print(min(ans_plus, ans_minus))

Measured memory_bytes: 14468
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

public class Program
{

    public static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        if (s[0][s[0].Length - 1] == s[1][0] && s[1][s[1].Length - 1] == s[2][0]) Console.WriteLine("YES");
        else Console.WriteLine("NO");
    }
}

Measured memory_bytes: 13140
/**
	������������ Author : Avi J Patel ������������
	������������ University : DA-IICT ������������
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair 
#define mt make_tuple
#define N 100000
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define large 10000000000000001

#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
/*void calc()
{
	for(int i=0;i<2005;i++)
	{
		a[i][0]=1;
		a[i][i]=1;
		for(int j=1;j<i;j++)
		{
			a[i][j]=(a[i-1][j-1]+a[i-1][j])%MOD;	
		}
	}
}*/
int main()
{
	int t;
	cin>>t;
	cout<<3*t*t;
	return 0;
}









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

using namespace std;
//#define DEBUG
#ifdef DEBUG
#define dump(x) cout << "[*] " #x ": " << x << endl
#define debug(x) x
#else
#define dump(x)
#define debug(x)
#endif

//#define int long long
typedef long long ll;
//constexpr int INF = 1e9;
//constexpr int MOD = 1000000007;

decltype(1) main()
{
    //cin.tie(nullptr);
    //ios_base::sync_with_stdio(false);
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    vector<int> d(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    int sum = 0;
    int len_max = 0;
    for (int i = 0; i < n - 1; ++i)
    {
        d[i + 1] = a[i + 1] - a[i];
        sum += d[i + 1];
        len_max = max(len_max, d[i + 1]);
        dump(d[i + 1]);
        dump(sum);
        dump(len_max);
    }
    //d[0] = k - sum;
    len_max = max(len_max, k - sum);
    //dump(d[0]);
    dump(len_max);
    cout << k - len_max << endl;
    return 0;
}


Measured memory_bytes: 1920
import sys
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]

def main():
    N = I()
    if N%2==1:
        print(0)
        return

    ans = 0
    ans += N//10
    q = 50
    while(N//q>0):
        ans += N//q
        q *= 5

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
import java.util.Iterator;
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();
		sc.close();

		if(exist(new TestIterator(A, B, C))){
			System.out.println("YES");
		}
		else{
			System.out.println("NO");
		}

	}

	static boolean exist(TestIterator ti){
		for(int i: ti){
			if(i == 0){
				return true;
			}
		}
		return false;
	}

}

// (n*A - C) % B where n = 1, ... ,B を返すイテレータ
class TestIterator implements Iterable<Integer>, Iterator<Integer> {

	private int n = 1;
	private int A;
	private int B;
	private int C;

	TestIterator(int A, int B, int C){
		this.A = A;
		this.B = B;
		this.C = C;
	}

	public boolean hasNext() {
		if(n > B){
			return false;
		}
		return true;
	}

	public Integer next() {
		int ret = (n*A - C) % B;
		n++;
		return ret;
	}

	public Iterator<Integer> iterator() {
		return this;
	}

}

Measured memory_bytes: 21972
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
#define ll long long 
const int N=5e5+10;
string str;
ll ans=0;
int a[N];
int main(){
    cin>>str;
    int len=str.size();
    int i=0,j=0;
    while(j<len){
        if(str[i]==str[j]) j++;
        else{
            if(str[i]=='>'){
                int t=1;
                for(int k=j-1;k>=i;k--){
                    a[k]=t++;
                }
                if(i){
                    if(a[i]<=a[i-1]) a[i]=a[i-1]+1;
                }
            }
            else{
                int t=0;
                for(int k=i;k<=j;k++){
                    a[k]=t++;
                }
            }
            i=j;
        }
    }

    if(str[len-1]=='>'){
        int t=0;
        for(int k=len;k>=i;k--){
            a[k]=t++;
        }
        if(i){
            if(a[i]<=a[i-1]) a[i]=a[i-1]+1;
        }
    }
    else{
        int t=0;
        for(int k=i;k<=len;k++){
            a[k]=t++;
        }
    }
    for(int k=0;k<=len;++k){
        //cout<<a[k]<<" ";
        ans+=a[k];
    }
    //cout<<endl;
    cout<<ans<<endl; 
    return 0;
}

Measured memory_bytes: 2820
n = int(input())
an = [int(i) for i in input().split()]
ans = ''

if sum(an)==0:
  print(0)
  exit()

for i in range((n//2)-1,-1,-1):
  an[i] =  sum(an[i*2+1::i+1])%2 ^ an[i]  

print(sum(an))
for i in range(n):
  if an[i]:
     ans += str(i+1) + ' '
print(ans)

Measured memory_bytes: 7792
#include <iostream>
#include <algorithm>
#include <stack>

using namespace std;

int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};

int h, w, c;
struct map{
	int m[12][12];
	map(){
		fill( m[0], m[0]+12*12, 0 );
	}
};
struct status{
	int to, x, y;
	status(int t, int _x, int _y){
		x = _x;
		y = _y;
		to = t;
	}
};
void calc(int to, map &m){
	stack<status> st;
	st.push( status(to, 1, 1) );
	while(!st.empty()){
		status s = st.top();
		st.pop();
//	cout << s.x << " " << s.y << endl;
		if( m.m[s.x][s.y] > 9 || m.m[s.x][s.y] == to ){
			m.m[s.x][s.y] = to + 10;
			for(int i=0; i<4; i++){
				if( m.m[ s.x+vx[i] ][ s.y+vy[i] ] != to + 10 )
					st.push( status(to, s.x+vx[i], s.y+vy[i]) );
			}
		}
	}
}
int solve(int count, int to, map m){
	int result=0;
	calc(to, m);
//	for(int i=0; i<10; i++){
//		for(int j=0; j<10; j++)
//			cout << m.m[i][j] << ' ';
//		cout << endl;
//	}
	if( count == 4 ){
		calc(c, m);
//	for(int i=0; i<10; i++){
//		for(int j=0; j<10; j++)
//			cout << m.m[i][j] << ' ';
//		cout << endl;
//	}
		for(int i=1; i<=h; i++){
			for(int j=1; j<=w; j++){
				if( m.m[i][j] > 9 )
					result++;
			}
		}
	}else{
		for(int i=1; i<=6; i++){
			if( i != to )
				result = max( result, solve(count+1, i, m) );
		}
	}
	return result;
}

int main(){
	while(cin >> h >> w >> c, h|w|c){
		map m;
		for(int x=1; x<=h; x++){
			for(int y=1; y<=w; y++){
				cin >> m.m[x][y];
			}
		}
		int ans = solve(0, m.m[1][1], m);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
	int a[6];
	for(int i=1;i<=5;i++)
	cin>>a[i];
	for(int i=1;i<=5;i++){
		if(!a[i]){
			cout<<i;
			return 0;
		}
	}
    return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
using namespace std;

int main(){
    int N,ans;cin>>N;
    double T,A,H[1010],tem[1010],d[1010],m=10000;cin>>T>>A;
    for(int i=1;i<=N;i++){
        cin>>H[i];
        tem[i]=T-H[i]*0.006;
        if(tem[i]>=A)d[i]=tem[i]-A;
        else d[i]=A-tem[i];
        
        if(d[i]<m){
            m=d[i];
            ans=i;
        }
    }
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const ll mod = 998244353;
const int N = 500006;
const ll INF = 1e18;

struct seg_tree {
 
    int sz;
    vector<int> val;
 
    void init(int x) {
        sz = 1;
        while(sz < x) sz *= 2;
        val.resize(sz * 2);
    }
 
    int merge(int a, int b) {
        return max(a, b);
    }
 
    void build(int node, int l, int r, vector<int>& a) {
        if (r - l == 1) {
            if (l < a.size()) {
                val[node] = a[l];
            }
            return;
        }
        int mid = (l + r) / 2;
        build(node * 2 + 1, l, mid, a);
        build(node * 2 + 2, mid, r, a);
        val[node] = merge(val[node * 2 + 1], val[node * 2 + 2]);
    }   
 
    void build(vector<int>& a) {
        build(0, 0, sz, a);
    }
 
    void upd(int node, int l, int r, int pos, ll x) {
        if (r - l == 1) {
            val[node] = x;
            return;
        }
        int mid = (l + r) / 2;
        if (mid > pos) upd(node * 2 + 1, l, mid, pos, x);
        if (mid <= pos) upd(node * 2 + 2, mid, r, pos, x);
        val[node] = merge(val[node * 2 + 1], val[node * 2 + 2]);
    }
    void upd(int pos, ll x) {
        upd(0, 0, sz, pos, x);
    }
 
    int ask(int node, int l, int r, int st, int dr) {
        if (dr <= l || st >= r) return 0;
        if (l >= st && r <= dr) return val[node];
        int mid = (l + r) / 2;
 
        return max(ask(node * 2 + 1, l, mid, st, dr),
            ask(node * 2 + 2, mid, r, st, dr));
    }
    int ask(int st, int dr) {
        return ask(0, 0, sz, st, dr);
    }
};

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

    int n, k;
    cin >> n >> k;
    seg_tree st;
    st.init(N);

    int ans = 0;
    vector<int> dp(N, 0);

    for(int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        int mx = max(st.ask(max(0, x - k), x + 1), st.ask(x, min(N, x + k + 1)));
        dp[i] = mx + 1;
        st.upd(x, dp[i]);
        ans = max(ans, dp[i]);
    }

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

// 1 1 524288
// 5 5 524292
// 4 4 131072
// 3 3 524290
// 8 8 65536
// 6 6 262146
// 9 9 524296
// 7 7 524294
// 2 2 262144
// 4 4 131072

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

int main(void){
    string b;
    cin >> b;
    int cnt = 0, max=0;
    for(int i=0;i<b.size();++i){
        if(b[i]=='A' || b[i]=='C' || b[i]=='G' || b[i]=='T'){
            ++cnt;
        }else{
            if(max < cnt) max = cnt;
            cnt = 0;
        }
    }
    if(max < cnt) max = cnt;
    cnt = 0;
    cout << max << endl;
}

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

int N,A[110];
int main(){
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    int max_A=1,min_A=1000000000;
    int ans=0;

    for(int i=0;i<N;i++){
        if(A[i]>max_A)max_A=A[i];
        if(A[i]<min_A)min_A=A[i];
    }
    ans=max_A-min_A;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

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

		ArrayList<Integer>a=new ArrayList<Integer>();
		for(int i=0;i<6;i++)a.add(sc.nextInt());
		Collections.sort(a);
		for(int i=0;i<a.size()-1;i++) {
			if(a.get(i)==a.get(i+1)) {
				a.remove(i);a.remove(i);i--;
			}
		}
		if(a.size()==2)
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main()
{
    double a,b,x;
    cin>>a>>b>>x;
    long double pai=acos(-1);
    if(x<=(a*a*b)/2)
    {
        double tant=b/(2*x/(a*b));
        double ang=(atan(tant)/pai)*(180.000000);
        printf("%.8lf\n",ang);
    }
    else
    {
        double tant=(2*b-2*x/(a*a))/a;
        double ang=(atan(tant)/pai)*(180.000000);
        printf("%.8lf\n",ang);
    }
    return 0;
}

Measured memory_bytes: 256
from sys import stdin,stdout
def fn(div):
    cnt=0
    mul=1
    while (n-(mul*div))>0:
        cnt+=1
        mul+=1
    return cnt
n=int(stdin.readline());ans=0
# a=list(map(int,stdin.readline().split()))
for x in range(1,n):
    ans+=fn(x)
print(ans)


Measured memory_bytes: 9172
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<cstring>
//#include<cstdlib>
//#include<cmath>
//#include<algorithm>
//#include<vector>
//#include<queue>
//#include<stack>
//#include<map>
//#include<set>
using namespace std;
#define SC scanf
#define PR printf
#define pb push_back
#define mp make_pair
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define db double
#define ldb long double
#define uint unsigned
#define ll long long
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef pair<pii,pii> ppp;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef map<int,int> mii;
const int INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const int xx[4]={1,-1,0,0};
const int yy[4]={0,0,1,-1};
int inline in(){
	int x=0,c;
	for(;(uint)((c=getchar())-'0')>=10;){
		if(c=='-')return -in();
		if(!~c)throw ~0;
	}
	do{
		x=(x<<3)+(x<<1)+(c-'0');
	}while((uint)((c=getchar())-'0')<10);
	return x;
}
int main(){
    cin.sync_with_stdio(false);cin.tie(0);
	ll a,b;
	cin>>a>>b;
	if(abs(a-b)%2!=0){
		puts("IMPOSSIBLE");
		return 0;
	}
	cout<<min(a,b)+abs(a-b)/2<<endl;
	return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n, x, t;
	cin >> n >> x >> t;
    int total = 0, ans = 0;
    while (total < n) {
    	total += x;
    	ans += t;
    }
    cout << ans << "\n";
    return 0;
}

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

int main(){
	int n;
	scanf("%d",&n);
	set<int> v;
	for(int i=0;i<n;i++){
		int o,x;
		scanf("%d%d",&o,&x);
		if(o==0){
			v.insert(x);
			printf("%d\n",v.size());
		}
		if(o==1){
			printf("%d\n",v.count(x));
		}
		if(o==2){
			v.erase(x);
		}
		if(o==3){
			int s;
			scanf("%d",&s);
			for(set<int>::iterator j=v.lower_bound(x);j!=v.upper_bound(s);j++)printf("%d\n",*j);
		}
	}
	return 0;
}






Measured memory_bytes: 12512
#include <stdio.h>

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

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

	int minj, j, buf, cnt = 0;
	for(i = 0; i <= n - 1; i++){
		minj = i;
		for(j = i; j <= n - 1; j++){
			if(a[j] < a[minj]){
				minj = j;
			}
		}
		if(i != minj){
			buf = a[i];
			a[i] = a[minj];
			a[minj] = buf;
			cnt++;
		}
	}

	for(i = 0; i < n - 1; i++){
		printf("%d ", a[i]);
	}
	printf("%d\n", a[n - 1]);
	printf("%d\n", cnt);
	
	return 0;
}



Measured memory_bytes: 2112
#include<stdio.h>
int main(void)
{
	int n[5],i,s,ss;
	for(i=0;i<5;i++){
		scanf("%d",&n[i]);
		if(40>n[i]){
			n[i]=40;
		}
		s+=n[i];
	}
	ss=s/5;
	printf("%d\n",ss);
	return 0;
}

Measured memory_bytes: 1028
h , n = map(int,input().split())
maho = []
for i in range(n):
    a,b = map(int,input().split())
    maho.append((a,b))
dp = [10**8 for i in range(h+1)]
for i in range(1,h+1):
    for a,b in maho:
        if i <= a:
            dp[i] = min(dp[i],b)
        elif i > a:
            dp[i] = min(dp[i],dp[i-a]+b)

print(dp[h])

Measured memory_bytes: 42476
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/26/20 20:43:51
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int k; cin>>k;
  for (int i = 0; i < k; i++)
    cout<<"ACL";
  cout << endl;

  return 0;
}


Measured memory_bytes: 3652
/***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt) blesses with knowledge whom he wants."***/
/*** "ALHAMDULILLAH for Everything..." ***/
#include<bits/stdc++.h>
using namespace std;
#define  fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  ll         long long
#define  debug      printf("Come here!")
#define  inf        1000000000000000000
#define  pb         push_back
#define  mp         make_pair
#define  sz(a)      a.size()
#define  mem(a,b)   memset(a,b,sizeof(a))
#define  clr(x)     x.clear()
#define  ff         first
#define  ss         second
#define  case(x)    cout << "Case " << x <<": "

#define  md         1000000007
#define  pi         acos(-1.0)
#define  cos(a)     cos(a*pi/180)
#define  sin(a)     sin(a*pi/180)
#define  tan(a)     tan(a*pi/180)
#define  cosi(a)    acos(a)/(pi/180)
#define  sini(a)    asin(a)/(pi/180)
#define  tani(a)    atan(a)/(pi/180)

#define  vl         vector <ll>
#define  vs         vector <string>
#define  vc         vector <char>
#define  vpll       vector < pair <ll, ll> >
#define  vpsl       vector < pair <string, ll> >
#define  vpls       vector < pair <ll, string> >
#define  pql        priority_queue<ll>
#define  minpql     priority_queue<ll,vector<ll>,greater<ll> >

#define  setbits(x)     __builtin_popcountll(x)
#define  zerobits(x)    __builtin_ctzll(x)

#define toll(a) atoll(a.c_str())
string tostr(ll a) {stringstream rr;rr<<a;return rr.str();}
ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}

/* mpp.max_load_factor(0.25); mpp.reserve(1024); */
/* cout << fixed << setprecision(12);*/

int main()
{
    fastt;
    ll n, m, k, i, j, x, y, p=0, ss=0, h, f=0;
    string s, a, b;
    char c;
    cin>>n;
    cin>>s;
    for(i=0; i<=999; i++){
        a="";
        b="";
        x=i;
        if(i<1){
            a="000";
        }
        else if(i<10){
            a="00";
            c=i+'0';

            a+=c;
        }
        else if(i<100){
            a="0";
            while(x>0){
                y=x%10;
                c=y+'0';
                x/=10;
                b+=c;
            }
            a+=b[1];
            a+=b[0];
        }
        else{
            while(x>0){
                y=x%10;
                x/=10;
                c=y+'0';
                b+=c;
            }
            a+=b[2];
            a+=b[1];
            a+=b[0];
        }
        k=0;
        f=0;
        for(j=0; j<s.size(); j++){
            if(a[k]==s[j]){
                k++;
                if(k==3){
                    f=1;
                    break;
                }
            }
        }
        if(f==1)ss++;

    }
    cout<<ss<<endl;
    return 0;
}



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

int main() {
  string s;
  cin >>s;
  int a=0;
  int b=s.size();
  for(int i=0;i<b/2;i++){
    if(s.at(i)!=s.at(b-i-1)){
      a++;
    }
  }
  cout <<a <<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
    int x1,y1,x2,y2;
    int x3,y3,x4,y4;
    int dx,dy;
    cin >> x1 >> y1 >> x2 >> y2;
    dx=x2-x1;
    dy=y2-y1;
    x3=x2-dy;
    y3=y2+dx;
    x4=x3-dx;
    y4=y3-dy;
    cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4;
    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 int ll;
typedef pair<int, int> P;
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 gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

map<ll, ll> prime_factor(ll n){
	map<ll, ll> res;
	for(ll i = 2; i*i <= n; i++){
		while(n%i == 0){
			res[i]++;
			n /= i;
		}
	}
	if(n != 1) res[n] = 1;
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b;
	cin >> a >> b;
	ll g = gcd(a, b);
	cout << prime_factor(g).size() + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int x,y,z,sl,fh;
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int main()
{
	x=rd();y=rd();z=rd();
	if(x>z) swap(x,z);
	if(y>z) swap(y,z);
	printf("%d\n",x+y);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int n,m,i,c,x,f,a[1001];
  while(scanf("%d %d",&n,&m),n+m){
    for(i=1;i<=n;i++)
      a[i]=1;
    c=0;x=n;f=0;
    while(1){
      for(i=1;i<=n;i++){
	if(a[i]){
	  if(x==1){
	    f=1;
	    printf("%d\n",i);
	    break;
	  }
	  c++;
	  if(c==m){
	    c=0;
	    a[i]=0;
	    x--;	  
	  }
	}
      }
      if(f)break;
    }
  }
  return 0;
}

Measured memory_bytes: 600