akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main() {
    int n, ans = 0;
    string s;
    cin >> n;
    cin >> s;
    for (int i = 0; i < n; i++) {
      int cnt = 0;
        for (char c = 'a'; c <= 'z'; c++) {
            bool left = false, right = false;
            for (int j = 0; j < i; j++) {
                if (s.at(j) == c) left = true;
            }
            for (int j = i; j < n; j++) {
                if (s.at(j) == c) right = true;
            }
            if (left && right) cnt++;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
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; }

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


int main() {
    cout<<fixed<<setprecision(10);

    ll n,m; cin>>n>>m;

    vvint edges(n);
    rep(i,m){
        ll a,b; cin>>a>>b;
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }


    queue<ll> q;
    q.push(0);
    set<ll> s;
    s.insert(0);

    vint ans(n, -1);
    ans[0] = 0;


    while(!q.empty()){
        ll now = q.front();
        q.pop();

        for(auto to:edges[now]){
            if(s.count(to)) continue;
            q.push(to);
            ans[to] = now;
            s.insert(to);
        }

    }

    if(*min_element(ALL(ans)) == -1) puts("No");
    else{
        puts("Yes");
        repf(i,1,n) cout<<ans[i]+1<<endl;
    }

    return 0;

}

Measured memory_bytes: 17600
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

const int SZ = 300000;
vector<ll> BIT0(SZ+1);
vector<ll> BIT1(SZ+1);
ll sum(int a,vector<ll>& BIT) {
  ll ans=0;
  while(a) {
    ans+=BIT[a];
    a-=a&-a;
  }
  return ans;
}
ll sum(int a,int b,vector<ll>& BIT) {
  return sum(b,BIT)-sum(a-1,BIT);
}

void add(int a,ll x, vector<ll>& BIT) {
  while(a<=SZ) {
    BIT[a]+=x;
    a+=a&-a;
  }
}

void reset(vector<ll>& BIT) {
  fill(BIT.begin(),BIT.end(),0);
}

// pass reference!!!
ll find_r(int i, ll x, ll d, vector<pair<ll,ll>>& xh) {
  ll ok = i;
  ll ng = xh.size();
  while(ng-ok>1) {
    int m = (ok+ng)/2;
    ll tx, th;
    tie(tx,th) = xh[m];
    if(tx<=x+2*d) {
      ok = m;
    } else {
      ng = m;
    }
  }
  return ok;
}

ll calc_discount(int i) {
  ll ret=0;
  ret+=sum(i+1,BIT0)+sum(i+1,BIT1)*(i+1);
  ret-=sum(i,BIT0)+sum(i,BIT1)*i;
  return ret;
}

void apply_discount(int l, int r, ll h) {
  l=l+1;
  r=r+1;
  add(l,-h*(l-1),BIT0);
  add(l,h,BIT1);
  add(r+1,h*r,BIT0);
  add(r+1,-h,BIT1);
}

int main() {
  ll n,d,a;
  cin>>n>>d>>a;
  vector<pair<ll,ll>> xh;
  rep(i,n) {
    ll x,h;
    cin>>x>>h;
    h=(h+a-1)/a;
    xh.push_back(make_pair(x,h));
  }
  sort(xh.begin(),xh.end());
  vector<ll> r(n);
  r[n-1]=n-1;
  rep(i,n-1) {
    ll x,h;
    tie(x,h)=xh[i];
    r[i]=find_r(i,x,d,xh);
  }
  ll ans=0;
  rep(i,n) {
    ll x,h;
    tie(x,h)=xh[i];
    ll discount = calc_discount(i);
    h-=discount;
    if(h>0) {
      ans+=h;
      apply_discount(i,r[i],h);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11120
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

int N;

int main() {
    cin >> N;
    vector<double> v(N);
    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    double two = 2.0;
    double ans = v[0];
    for (int i = 1; i < N; i++) {
        ans = (ans + v[i]) / two;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
#define TSUKASA_DIARY_S_TEMPLATE
// define
#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) int((a).size())
#define cauto const auto
// typedef
typedef long long lint;
typedef double Double;
typedef pair< int, int > pii;
template< typename T > using Vec = vector< T >;
template< typename T > using Matrix = Vec< Vec< T > >;
template< typename T > using USet = unordered_set< T >;
template< typename T, class C > using MyUSet = unordered_set< T, C >;
template< typename T, typename F > using UMap = unordered_map< T, F >;
template< typename T, typename F, class C > using MyUMap = unordered_map< T, F, C >;
// hash
class PiiHash { public: size_t operator () (const pii& p) const { return (p.first << 16) | p.second; } };
// popcount
inline int POPCNT(int x) { return __builtin_popcount(x); }
inline int POPCNT(lint x) { return __builtin_popcount(x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
const Double EPS = 1e-9;
const Double PI = acos(-1);
// inrange
template< typename T >
inline bool in_range(T v, T mi, T mx) { return mi <= v && v < mx; }
template< typename T >
inline bool in_range(T x, T y, T W, T H) { return in_range(x,0,W) && in_range(y,0,H); }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
template< typename T > inline void modAdd(T& a, T b, T mod) { a = (a + b) % mod; }
template< typename T > inline void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > inline void maxUpdate(T& a, T b) { a = max(a, b); }
// converter
template< typename F, typename T >
inline void convert(F& from, T& to) {
	stringstream ss;
	ss << from; ss >> to;
}


int N, A[100010];


int main() {
	cin >> N;
	for_(i,0,N) cin >> A[i];
	
	int cnt = 0;
	for_(i,0,N) cnt += A[i] % 2;
	int rem = (N - cnt) + (cnt / 2);
	
	if (cnt % 2) {
		if (rem > 0) puts("NO");
		else puts("YES");
	} else {
		if (rem > 0) puts("YES");
		else puts("NO");
	}
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
	int a,b;
	while(cin>>a>>b,a||b){
		vector<bool>me(a,true);
		int k=0;
		int co=0;
		loop(i,1,b+1){
			string s;
			cin>>s;
			bool h=false;
			if(i%15==0){if(s=="FizzBuzz")h=true;}
			else if(i%5==0){if(s=="Buzz")h=true;}
			else if(i%3==0){if(s=="Fizz")h=true;}
			else if(atoi(&s[0])==i)h=true;
			while(1){
				if(!me[k]){k++;if(k==a)k=0;}
				else break;
			}
			if(!h){co++;me[k]=false;}	
			if(co+1==a){rep(q,b-i)cin>>s;break;}
			k++;
			if(k==a)k=0;
		}
		vector<int>out;
		rep(i,a)if(me[i])out.pb(i+1);
		rep(i,out.size()-1)cout<<out[i]<<" ";
		cout<<out[out.size()-1]<<endl;
	}
}

Measured memory_bytes: 1256
package main

import "fmt"

func main() {

	var a, b, c int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)

	tmp := a - b
	if c >= tmp {
		fmt.Println(c - tmp)
	} else {
		fmt.Println(0)
	}
}


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

const ll INF = pow(10, 9) + 7;

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


Measured memory_bytes: 256
# D - Megalomania

N = int(input())
T = []
for i in range(N):
    T.append([int(x) for x in input().split()])
T = sorted(T, key=lambda x:x[1])

total = 0
ans = 'Yes'

for a, b in T:
    total += a
    if total > b:
        ans = 'No'
        break

print(ans)

Measured memory_bytes: 42832
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}

	public Main(){
		new AOJ0030().doIt();
	}
	
	class AOJ0030{
		int n,m;
		int cnt;
		void  dfs(int num,int sum,int k){
			if(sum==m&&k==n){
				cnt++;return;
			}else if(k==n)return;
			for(int i=num+1;i<10;i++){
				dfs(i,sum+i,k+1);
			}
		}
		
		void doIt(){
			while(in.hasNext()){
				n = in.nextInt();m = in.nextInt();
				if(n+m==0)break;
				cnt = 0;
				dfs(-1, 0, 0);
				System.out.println(cnt);
			}
		}
	}
	
}

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

int main()
{
	long long n;
	cin >> n;

	long long b = 0;
	cin >> b;

	long long ret = 0;
	for (long long i = 1; i < n; ++i)
	{
		long long a;
		cin >> a;
		if (a <= b) {
			ret += b - a;
		}
		else {
			b = a;
		}
	}
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 3632
N = int(input())
A = list(map(int, input().split()))
flag = None #True:増加  False:減少
temp = A[0]
result = 1
for a in A:
    if a == temp:
        continue
    if flag == None:
        if a > temp:
            flag = True
        else:
            flag = False
    elif (flag and a < temp) or (not flag and a > temp):
        flag = None
        result += 1
    temp = a
print(result)

Measured memory_bytes: 14228
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int a[51]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin>>K;
  cout<<a[K-1]<<endl;
}

Measured memory_bytes: 256
import sys
for i in range(sys.maxsize):
    a,op,b=input().split()
    if op == "?":
        break
    elif op == "+":
        print(int(a)+int(b))
    elif op == "-":
        print(int(a)-int(b))
    elif op == "*":
        print(int(a)*int(b))
    elif op == "/":
        print(int(int(a)/int(b)))


Measured memory_bytes: 5600
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<queue>
#include<stack>
#define Max 100002
using namespace std;

vector<pair<int,int>>vec;

bool cmp(pair<int,int>&a,pair<int,int>&b){
	return (a.first<b.first);
}

int main(){

	int n,i,c=0;
	char s[Max],x = '\0';
	scanf("%d",&n);
	scanf("%s",s);
	for(i=0;i<n;i++){
		if(x == '\0'){
			c++;
			x = s[i];
		}else{
			if(x != s[i]){
				x = s[i];
				c++;
			}
		}
	}

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


	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
//#include<cmath>
#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
//#include<bitset>
#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

LLI gcd(LLI x, LLI y) {
	LLI  r;
	if (x < y) {
		swap(x, y);
	}
	r = x % y;
	while (r != 0) {
		x = y;
		y = r;
		r = x % y;
	}
	return y;
}
LLI lcm(LLI x, LLI y) {
	return x / gcd(x, y) * y;
}

//long nCr(int n, int r) {
//	long ans = 1;
//	for (int i = n; i > n - r; i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; i++) {
//		ans = ans / i;
//	}
//	return ans;
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI A, B, C, D,c,d,e,E;
	cin >> A >> B >> C >> D;
	E = lcm(C, D);
	c = B / C;
	c -= A / C;
	if (A%C == 0) {
		c++;
	}
	d = B / D;
	d -= A / D;
	if (A%D == 0) {
		d++;
	}
	e = B / E;
	e -= A / E;
	if (A%E == 0) {
		e++;
	}
	LLI res = B - A + 1;
	res = res - c - d + e;
	cout << res << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    // Your code here!
    var (a,b) = readLine()!!.split(" ").map{it.toLong()}
    
    print(lcm(a,b))    
}

fun gcd(ia:Long,ib:Long):Long{

    if(ib === 0L){
        return ia
    }
    
    return gcd(ib,ia%ib)
}

fun lcm(ia:Long,ib:Long):Long{
    return ia*ib / gcd(ia,ib)
}

Measured memory_bytes: 38024
#include<iostream>
using namespace std;
int main(){
    int x,y,i,j;
    cin >> x >> y;
    while(x!=0 or y!=0){
        for(i=0;i<x;i++){
            for(j=0;j<y;j++){
                if(i==0 or j==0 or i==x-1 or j==y-1) cout << "#";
                else cout << ".";
            }
            cout << endl;
        }
        cout << endl;
        cin >> x >> y;
    }
    return 0;
}


Measured memory_bytes: 3068
class UnionFind :
    def __init__(self, size) :
        self.parent = list(range(size))
        self.height = [0] * size
        self.size = [1] * size
        self.component = size

    def root(self, index) :
        if self.parent[index] == index :  # 根の場合
            return index
        rootIndex = self.root(self.parent[index])  # 葉の場合親の根を取得
        self.parent[index] = rootIndex  # 親の付け直し
        return rootIndex

    def union(self, index1, index2) :  # 結合
        root1 = self.root(index1)
        root2 = self.root(index2)

        if root1 == root2 :  # 連結されている場合
            return

        self.component -= 1  # 連結成分を減らす

        if self.height[root1] < self.height[root2] :
            self.parent[root1] = root2  # root2に結合
            self.size[root2] += self.size[root1]
        else :
            self.parent[root2] = root1  # root1に結合
            self.size[root1] += self.size[root2]
            if self.height[root1] == self.height[root2] :
                self.height[root1] += 1
        return

    def isSameRoot(self, index1, index2) :
        return self.root(index1) == self.root(index2)

    def sizeOfSameRoot(self, index) :
        return self.size[self.root(index)]

    def getComponent(self) :
        return self.component

N, M = map(int, input().split())
AB = [tuple(map(lambda a: int(a) - 1, input().split())) for _ in range(M)]

tree = UnionFind(N)
now = N * (N - 1) // 2

ans = [now]
for a, b in AB[::-1]:
    if not tree.isSameRoot(a, b):
        now -= tree.sizeOfSameRoot(a) * tree.sizeOfSameRoot(b)
    tree.union(a, b)
    ans.append(now)
print(*ans[::-1][1:], sep='\n')

Measured memory_bytes: 26228
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
const long long INF = 4299999996000000001;
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 ll = long long;
#define int long long
signed main(void){
    int n,K; cin>>n>>K;
    //if(n==2) {cout<<0<<endl; return 0;}
    vector <pair<int,int>> xs(n);
    for(int i=0;i<n;i++){
        int a,b; cin>>a>>b;
        xs[i] = {a,b};
    }
    ll ans = INF;
    //x1,x2,y1,y2を選ぶ(x1!=x2)(y1!=y2)
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++){
                for(int l=0;l<n;l++){
                    if(i==j|| k==l) continue;
                    ll x1=xs[i].F, x2 = xs[j].F, y1 = xs[k].S, y2 = xs[l].S;
                    if(x1>x2) { ll tmp = x1; x1 = x2; x2 = tmp;}
                    if(y1>y2) { ll tmp = y1; y1 = y2; y2 = tmp;}
                    int cnt = 0;
                    for(int z=0;z<n;z++){
                        if(xs[z].F>=x1&&xs[z].F<=x2&& xs[z].S >= y1&& xs[z].S<=y2 ) cnt++;
                    }
                    if(K<=cnt) chmin(ans, (x2-x1)*(y2-y1));
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int a, b, n;
int f(int x) {
	return ((a*x)/b) - a * (x / b);
}
int32_t main() {
	ios::sync_with_stdio(0);cin.tie(0);
	cin >> a >> b >> n;
	cout << f(min(n, b-1));
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main () {
  int N, ans;
  ans = 0;
  cin >> N;
  ans = N % 2;
  ans += N / 2;
  printf("%d\n", ans);
  return 0;
}

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

int N, M;
const int MAX_M = 10000;
int rec = 0;

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

  for (int i = 0; i < M; i++) {
    int a;
    cin >> a;
    rec += a;
  }

  int ans = N - rec;

  if (ans >= 0) {
    printf("%d", ans);
  } else {
    printf("-1");
  }

  return 0;
}

Measured memory_bytes: 3804
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,ans=1e9;
struct node
{
	int a[2];
}a[21];
void dfs(int x,int y)
{
	if(y>=ans)
	return;
	if(x==n+1)
	{
		ans=y;
		return;
	}
	for(int i=x;i<=n;i++)
	if(a[i].a[(i-x)%2]>=a[x-1].a[0])
	{
		for(int j=i;j>x;j--)
		{
			swap(a[j].a[0],a[j-1].a[1]);
			swap(a[j].a[1],a[j-1].a[0]);
		}
		dfs(x+1,y+i-x);
		for(int j=x;j<i;j++)
		{
			swap(a[j].a[0],a[j+1].a[1]);
			swap(a[j].a[1],a[j+1].a[0]);
		}
	}
}
signed main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i].a[0]);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i].a[1]);
	dfs(1,0);
	if(ans!=1e9)
	printf("%d",ans);
	else
	printf("-1");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int M=1000005;
int n,a,U,res,cnt[M];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a;
		cnt[a]++;
	} 
	for(int i=1;i<=M;i++)
		if(cnt[i]){
			for(int j=2;j*i<=M;j++)
				cnt[j*i]=0;
		}
	for(int i=1;i<=M;i++)
		if(cnt[i]>=2)
			cnt[i]=0;
	res=0;
	for(int i=1;i<=M;i++)
		if(cnt[i])
			res++;
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 7552
N = gets.chomp.to_i

arr = Array.new(4){ Array.new(4){ Array.new(4){ Array.new(2, 1) }}}

arr[0][2][1][0]=0
arr[0][1][2][0]=0
arr[2][0][1][0]=0

for i in 4..N
  for j in 0..3
    for k in 0..3
      for l in 0..3
        if j == 2 && l == 1
          arr[j][k][l][(i+1)%2] = (arr[1][j][k][i%2] + arr[2][j][k][i%2] + arr[3][j][k][i%2])%1000000007
        elsif k == 2 && l == 1
          arr[j][k][l][(i+1)%2] = (arr[1][j][k][i%2] + arr[2][j][k][i%2] + arr[3][j][k][i%2])%1000000007
        else
          arr[j][k][l][(i+1)%2] = (arr[0][j][k][i%2] + arr[1][j][k][i%2] + arr[2][j][k][i%2] + arr[3][j][k][i%2])%1000000007
        end
      end
    end
  end
  arr[0][2][1][(i+1)%2]=0
  arr[0][1][2][(i+1)%2]=0
  arr[2][0][1][(i+1)%2]=0
end

answer = 0
for j in 0..3
  for k in 0..3
    for l in 0..3
      answer += arr[j][k][l][(N+1)%2]
    end
  end
end
puts(answer%1000000007)

Measured memory_bytes: 1788
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
answer = 0

for i in range(N-1):
    if A[i+1]==A[i]+1:
        answer += C[A[i]-1]

print(answer+sum(B))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)a;i<=(sign)b;++i)
#define Fordown(i,a,b) for(register sign i=(sign)a;i>=(sign)b;--i)
const int N=100+5;
bool cmax(sign &a,sign b){return (a<b)?a=b,1:0;}
bool cmin(sign &a,sign b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
  T ans=0,f=1;
  char ch=getchar();
  while(!isdigit(ch)&&ch!='-')ch=getchar();
  if(ch=='-')f=-1,ch=getchar();
  while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
  return ans*f;
}
template<typename T>void write(T x,char y)
{
  if(x==0)
  {
      putchar('0');putchar(y);
      return;
  }
  if(x<0)
  {
      putchar('-');
      x=-x;
  }
  static char wr[20];
  int top=0;
  for(;x;x/=10)wr[++top]=x%10+'0';
  while(top)putchar(wr[top--]);
  putchar(y);
}
void file()
{
  #ifndef ONLINE_JUDGE
      freopen("d.in","r",stdin);
      freopen("d.out","w",stdout);
  #endif
}
int n,k;
void input()
{
	n=read<int>(),k=read<int>();
}
ll ans;
void work()
{
	int j;
	For(i,k+1,n)
	{
		for(j=0;j+i-1<=n;j+=i)ans+=i-k;
		ans+=max(0,n-j-k+1);
	}
	if(k==0)ans-=(n-k);
	printf("%lld\n",ans);
}
int main()
{

	input();
	work();
	return 0;
}

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

int main()
{
    int n;
    cin>>n;
    int A[n];
    for(int i=0;i<n;i++)
    	cin>>A[i];
    sort(A,A+n);
    cout<<A[n/2]-A[n/2-1]<<endl;


}

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

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

  ll N, K; cin >> N >> K;
  vector<ll> V(N); for (ll i = 0; i < N; i++) cin >> V[i];
  vector<ll> S(N + 1, 0);
  for (ll i = 0; i < N; i++) {
    S[i + 1] = S[i] + V[i];
  }

  ll ans = 0;
  for (ll l = 0; l < N + 1; l++) {
    for (ll r = l; r < N + 1; r++) {
      if (N - (r - l) > K) continue;
      ll t = K - (N - (r - l));
      ll s = 0;

      vector<ll> A(N, 1);
      for (ll i = 0; i < N; i++) {
        if (!(l <= i && i < r)) {
          s += V[i];
          A[i] = V[i];
        }
        sort(A.begin(), A.end());
      }
      for (ll i = 0; i < t; i++) {
        if (A[i] >= 0) break;
        s -= A[i];
      }
      // cout << l << ' ' << r << ' ' << s << '\n';
      ans = max(ans, s);
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int x, y, z;
    cin >> x >> y >> z;
    cout << ((x - z) / (y + z)) << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		int sum=0,ans=0;
		for(int i=1;sum<=n;i++){
			sum+=i;
			if((n-sum)%(i+1)==0 && sum!=n)ans++;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1160
/*
 * a.c
 *
 *  Created on: 2017/06/13
 *      Author: AWV060608
 */

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

int		main(void)
{
	int 	i;
	int		x;
	int		n;

	scanf("%d",&n);

	for(i=1; i<=n; i++)
	{
		x = i;
		if ( x % 3 == 0 )
		{
			printf(" %d",i);
		}
		else
		{
			while(1)
			{
				if ( x % 10 == 3 )
				{
					printf(" %d",i);
					break;
				}
				x /= 10;
				if( x==0 )
					break;

			}
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
N=int(input())

def cf(n):
  a=[]
  for f in range(1,int(n**(1/2)+1)):
    if n%f==0:
      a.append(f)
      if n//f!=f:
        a.append(n//f)
  return a

def pf(n):
  a=[]
  while n%2==0:
    a.append(2)
    n//=2
  f=3
  while f*f<=n:
    if n%f==0:
      a.append(f)
      n//=f
    else:
      f+=2
  if n!=1:
    a.append(n)
  return sorted(a)

def main():
  c,p,t=1,N+1,1
  for f in pf(N-1):
    if p==f:
      t+=1
    else:
      c*=t
      t=2
    p=f
  c=c*t-1

  for f in cf(N):
    t=N
    if f!=1:
      while t%f==0:
        t//=f
      if t%f==1:
        c+=1
  print(c)

main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main()
{
    // 整数の入力
	string s;
    bool flag = false;
    
    cin >> s;
    for(int i=0;i<s.length();i++){
        if((i+1)%2==1){
            if(s[i]=='L'){
                flag = true;
            }
        }else{
            if(s[i]=='R'){
                flag = true;
            }
        }
    }
    if(flag){
        cout << "No" << endl;
    }else {
        cout << "Yes" << endl;
    }
   
    return 0;
}

Measured memory_bytes: 256
//#define TIMER_
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
int n, k;
const int maxn = 1e5+10;
int dp[maxn];
const int md = 1e9 + 7;

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

inline void add(int &a, int b) {
 a += b;
 if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mdpow(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

int main() {
  fastio;
  cin >> n >> k;
  for (int i = k; i >= 1; i--) {
    dp[i] = mdpow(k/i, n);
  }

  for (int i = k; i >= 1; i--) {
    for (int j = i + i; j <= k; j += i) {
      sub(dp[i], dp[j]);
    }
  }

  int res = 0;
  for (int i = 1; i <= k; i++) {
    add(res, mul(dp[i], i));
  }

  cout << res << "\n";
  
  #ifdef TIMER_
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  #endif
}


Measured memory_bytes: 3952
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N, M; cin >> N >> M;
	vector<long long>A(N);
	vector<vector<bool>>C(N, vector<bool>(M, false));
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
		vector<long long>B(A.at(i));
		for (int j = 0; j < A.at(i); j++) {
			cin >> B.at(j);
			C.at(i).at(B.at(j) - 1) = true;
		}
	}
	int ans = M;
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N; j++) {
			if (!C.at(j).at(i)) {
				ans--;
				break;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

int score(int a)
{
    if(a%10==0)return 0;
    return a;
}
int n,dp[110][110];
int a[110];
int main()
{
    int k=0,res=0,t=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        int x;
        scanf("%d",&x);
        if(x%10==0)
        {
            res+=x;
        }
        else
        {
            a[k++]=x;
            t+=x;
        }
    }
    int drs=0;
    if(t%10==0)
    {
        sort(a,a+k);
        for(int i=0;i<k;i++)
        {
            if(a[i]%10)
            {
                drs=a[i];
                break;
            }
        }
    }
    if(drs==0&&t%10==0)
    cout << 0 << endl;
    else
        cout << res+t-drs << endl;
    return 0;
}


Measured memory_bytes: 256
import Data.Bits
import Data.List
import Control.Monad
import qualified Data.Vector.Unboxed as V
import Control.Monad.ST
import Data.Maybe (fromMaybe)
import qualified Data.ByteString.Lazy.Char8 as B
import Debug.Trace

main :: IO ()
main = do
  ls <- getLine
  putStrLn $ if (length. group. sort) ls == 2 && (length. head . group. sort) ls == 2
    then "Yes"
    else "No"


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

using namespace std;
int num[3];

void solve() {
  sort(num, num+3);
  int diff1 = num[2] - num[1];
  int diff2 = num[2] - num[0];
  cout << (diff1 + (diff2 - diff1 + 1) / 2 + (diff2 - diff1) % 2) << endl;
}

int main() {
  cin >> num[0] >> num[1] >> num[2];
  solve();
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        scan.close();
        String[] strs = str.split(" ");

        int a = Integer.parseInt(strs[0]);
        int b = Integer.parseInt(strs[1]);

        int max = a + b;
        int sub = a - b;
        int mul = a * b;

        if (max < sub) {
            max = sub;
        }

        if (max < mul) {
            max = mul;
        }

        System.out.print(max);
    }
}


Measured memory_bytes: 23764
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		String s = in.next();
		System.out.println(solve(s));
		in.close();
	}

	private static int solve(String s) {
		int ans = 0;
		int t = 0;
		for (int i = 0; i < s.length(); i++)
			if (s.charAt(i) == 'A' || s.charAt(i) == 'T' || s.charAt(i) == 'G' || s.charAt(i) == 'C') {
				t++;
				if (t > ans)
					ans = t;
			} else
				t = 0;
		return ans;
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int a,b;
string s1,s2,s3; 
int main() {
	cin>>s1>>s2;
	cin>>a>>b;
	cin>>s3;
	if(s1[0]==s3[0]) a--;
	else b--;
	cout<<a<<" "<<b;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int i,j,h,w;
	char c[10];
	scanf("%d %d",&h,&w);
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			scanf("%s",c);
			if(c[0]=='s'&&c[1]=='n'&&c[2]=='u'&&c[3]=='k'&&c[4]=='e'){
				printf("%c%d",'A'+j,i+1);
				return 0;
			}
		}
	}
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

ll ans = 1;

//Number theory
ll gcd(ll a, ll b){ return a % b == 0 ? b : gcd(b, a%b); }
ll lcm(ll a, ll b){ return a * b/ gcd(a, b); }
ll extgcd(ll a, ll b, ll& x, ll& y){
	ll d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	} else{
		x = 1; y = 0;
	}
	return d;
}

ll mod_pow(ll x, ll n){
	if(n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n/2);
	if(n & 1) res = res * x % MOD;
	return res;
}

ll mod_div(ll x, ll y) {
	return (x * mod_pow(y, MOD - 2)) % MOD;
}

vector<pair<ll, int> > factorize(ll n){
	vector<pair<ll, int> > res; //sum(first[i]^second[i]) 
	for(ll i=2; i*i<=n; i++){
		if(n%i) continue;
		res.emplace_back(i, 0);
		while(n%i == 0){
			n /= i;
			res.back().second++;
		}
	}
	if(n != 1)res.emplace_back(n, 1);
	return res;
}

int main(void){
	ll h; cin >> h;
	ll depth = 1;
	{
		ll f = 1;
			while(1){
				if(h <= f) break;
				depth++;
				f *= 2;
			}
			if(h != f) depth--;
	}

	rep(i, depth){
		ans *= 2;
	}
	ans -= 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
list = [int(x) for x in input().split()]

result = [0] * N

#print(list)

for i in range(N-1):
    #print(list[i])
    result[list[i]-1] = result[list[i]-1] + 1 

#print(result)

for i in range(N):
    print(result[i])

#print(list)


Measured memory_bytes: 32172
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int n, k;
	cin >> n >> k;
	V a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(all(a), greater<int>());
	int ans = upper;
	rep(i, n - k + 1) {
		chmin(ans, a[i] - a[i + k - 1]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3760
import java.util.Scanner;

public class Main {

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

//入力変数
int N = sc.nextInt();
int A = sc.nextInt();

//出力変数
String ans;

//計算
if(N%500 <= A){
ans = "Yes";
}else{
ans = "No";
}

//出力
System.out.println(ans);

}
}


Measured memory_bytes: 23124
#include<stdio.h>
int main(void){
    int a,b,c,i,d = 0;
    scanf("%d%d%d",&a,&b,&c);
    for(i = a; i <= b; i++)
    {
        if(c % i == 0)
        {
            d++;
        }
    }
    printf("%d\n",d);
    return 0;
}

Measured memory_bytes: 596
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
//import org.apache.commons.lang3.StringUtils;
 
 
/**
 *
 * @author aj
 */
public class Main {
    
    public static void main(String[] args){
        try {
            //Scanner sc = new Scanner(System.in);
            BufferedInputStream bf = new BufferedInputStream(System.in);
            BufferedReader in = new BufferedReader(
                    new InputStreamReader(bf, StandardCharsets.UTF_8));
            OutputStream out = new BufferedOutputStream ( System.out );
            String[] abc = in.readLine().split(" ");
            int a = Integer.parseInt(abc[0]);
            int b = Integer.parseInt(abc[1]);
            int cnt = ( a * b) / 2;
            out.write((cnt+"\n").getBytes());
            out.flush();
        }catch(Exception ex){
            ex.printStackTrace();
        }
    }
}

Measured memory_bytes: 22484
#include<iostream>
using namespace std;
const int MAX_T = 3000, MAX_M=300;
int M, start, goal,dice[6], *N;
 
bool isPositionValid(int p){return 0<=p && p<M;}
 
int* MakePath(int *path, int from){
    static bool visit[MAX_M] = {};
    static auto checkPath = [&path](int moveto)->int{
        if(!isPositionValid(moveto))	return 2*MAX_T;
        else{
            int position = moveto+ N[moveto];
            if(!visit[position]) MakePath(path, position);
            return  path[position]+1;
        }
    };
 
    if(path==NULL){
        path = new int[M];
        for(int m=0; m<M; m++) path[m] = MAX_T+1;
    }
 
    visit[from] = true;
    int bestpath = MAX_T;
    if(from==goal)  bestpath = 0;
    else{
        for(int r=0; r<6; r++){
            bestpath = min(bestpath, checkPath(from + dice[r]));
            bestpath = min(bestpath, checkPath(from - dice[r]));
        }
    }
    path[from] = bestpath;
    return path;
}
 
int main(){
    // 入力
    cin >> M;
    for(int r=0; r<6; r++)   cin >> dice[r];
    cin >> start >> goal;
	start--, goal--;
	N = new int[M];
    for(int m=0; m<M; m++)   cin >> N[m];
    
    int* path = MakePath(NULL, start);
     
    //本番
    int position = start;
    for(int t=0; t<MAX_T; t++){
        if(position == goal) break;
     
        int r;
        cin >> r;
        int d = dice[r-1];
 
        static auto tryMove = [&path](int moveto, int path_before, int& position)->bool{
			if(isPositionValid(moveto)){
                if(path_before > path[moveto + N[moveto]]){
					position = moveto + N[moveto];
					return true;
				}
			}
            return false;
        };
     
		int output;
        if     (tryMove(position + d, path[position], position)) output = 1;
		else if(tryMove(position - d, path[position], position)) output = -1;
		else output = 0;
		cout << output << endl;
    }
 
    delete[] N;
    delete[] path;
    return 0;
}

Measured memory_bytes: 1304
n = int(input())
a = list(map(int, input().split()))
c = 0
for i, j in enumerate(a[:]):
    if i > 0:
        if a[i-1] > a[i]:
            c+=(a[i-1] - a[i])
            a[i] = a[i-1]
print(c)

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

int main() {
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    rep(i,N) cin >> P.at(i);
    rep(i,N) cin >> Q.at(i);
    vector<int> num(N);
    rep(i,N) num.at(i) = i + 1;
    int a, b;
    int i = 1;
    do {
        if (P == num) a = i;
        if (Q == num) b = i;
        ++i;
    } while (next_permutation(num.begin(), num.end()));
    cout << abs(a - b) << endl;
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String country = sc.next();
		int N =country.length();
		String F_1 = country.substring(0, (N-1)/2);
		String F_2 = country.substring((N-1)/2+1,N);
		
		StringBuffer str = new StringBuffer(F_1);
		String A_1 = str.reverse().toString();
		
		StringBuffer str2 = new StringBuffer(F_2);
		String A_2 = str2.reverse().toString();
        //StringBuffer str = new StringBuffer(F_1);
        //String A_1 = str.reverse().toString();
		//String s_1 = "z",s_2 = "v";
		//int F1_len = F_1.length();
		//if(F1_len%2==1) {
		//	s_1 = F_1.substring(0,(F1_len-1)/2);
		//	s_2 = F_1.substring((F1_len-1)/2+1,F1_len);
		//}else if(F1_len%2==0) {
		//	s_1 = F_1.substring(0,F1_len/2);
		//	s_2 = F_1.substring(F1_len/2,F1_len);
		//}
        
        
		if(!F_1.equals(A_2)) {
			System.out.println("No");
		}else

       // if(s_1.equals(s_2)) {
		if(!F_1.equals(A_1)) {
        	System.out.println("No");
        }else {
        	System.out.println("Yes");
        }
       // System.out.println("F1  "+F_1+"  F2  "+F_2+"  s1  "+s_1+"  s2  "+s_2+"  A1  "+A_1+"  A2  "+A_2);
        
	}

}


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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 1000010, M = 1010;

int n, m;
int h[N], e[N], ne[N], idx;
int q[N], d[N], st[N];
int g[M][M], match[M][M];

void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

int top_sort()
{
	int hh = 0, tt = -1;
	for (int i = 1; i <= m; i ++ )
		if (!d[i])
		{
			q[ ++ tt] = i;
			st[i] = 1;
		}
	
	while (hh <= tt)
	{
		int t = q[hh ++ ];
		
		for (int i = h[t]; ~i; i = ne[i])
		{
			int j = e[i];
			if ( -- d[j] == 0)
			{
				q[ ++ tt] = j;
				st[j] = st[t] + 1;
			}
		}
	}
	
	int res = 0;
	for (int i = 1; i <= m; i ++ )
		if (!st[i]) return -1;
		else res = max(res, st[i]);
	
	return res;
}

int main()
{
	memset(h, -1, sizeof h);
	
	scanf("%d", &n);
	
	for (int i = 1; i <= n; i ++ )
		for (int j = 0; j < n - 1; j ++ )
		{
			int a = i, b;
			scanf("%d", &b);
			g[i][j] = b;
			
			if (match[a][b]) continue;
			match[a][b] = match[b][a] = ++ m;
		}
		
	for (int i = 1; i <= n; i ++ )
		for (int j = 0; j < n - 2; j ++ )
		{
			int a = match[i][g[i][j]], b = match[i][g[i][j + 1]];
			d[b] ++ ;
			add(a, b);
		}
		
	printf("%d\n", top_sort());
	return 0;
}

Measured memory_bytes: 31616
H,W = map(int, input().split())

ans = []

if H > 2:
    ans.append(W*max(H//3, (H-H//3)//2, H-H//3-(H-H//3)//2)-W*min(H//3, (H-H//3)//2, H-H//3-(H-H//3)//2))
if W > 2:
    ans.append(H*max(W//3, (W-W//3)//2, W-W//3-(W-W//3)//2)-H*min(W//3, (W-W//3)//2, W-W//3-(W-W//3)//2))

num = 10**10
for x in range(1, W):
    num = min(num, max(H*x, (W-x)*(H//2), (W-x)*(H-H//2))-min(H*x, (W-x)*(H//2), (W-x)*(H-H//2)))
ans.append(num)
num = 10**10
for x in range(1, H):
    num = min(num, max(W*x, (H-x)*(W//2), (H-x)*(W-W//2))-min(W*x, (H-x)*(W//2), (H-x)*(W-W//2)))
ans.append(num)
print(min(ans))

Measured memory_bytes: 3188
#coding=UTF-8


N=int(input())
mozir=input()
hyo=mozir.split(' ')
a=[int(mono) for mono in hyo]

kirei_a=sorted(a,reverse=True)
ans=0

for idx in range(0,N,1):
    ans=ans+kirei_a[idx*2+1]

print(ans)


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

using namespace std;

int INF=1e9;

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

    long long n,m;
    cin>>n>>m;
    long long ans;
    if(n==1&&m==1)ans=1;
    else if(n==1||m==1)ans=max(n-2,m-2);
    else ans=(n-2)*(m-2);
    cout<<ans<<endl;
}

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

char a[105][105];
int t[105],y[105];

int main(void){
    int h,w;cin>>h>>w;
    //int h2=h,w2=w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
            if(a[i][j]=='.'){
                y[i]++;t[j]++;
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(y[i]==w||t[j]==h){
                continue;
            }else{
                cout<<a[i][j];
            }
        }
        if(y[i]!=w)cout<<endl;
    }
    cout<<endl;
    /*
    for(int i=0;i<h;i++){
        cout<<y[i]<<endl;
    }
    
    for(int i=0;i<w;i++){
        cout<<t[i]<<endl;
    }
    */
    
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<i64>();
    let y = read::<i64>();

    let mut b;
    let mut c;
    for a in 0..n+1 {
        b = (y - 1000 * n - 9000 * a) / 4000;
        c = n - a - b;
        if (y - 1000*n - 9000*a) % 4000 == 0 && c >= 0 && b >= 0 {
            println!("{} {} {}", a, b, c);
            return;
        }
    }

    println!("-1 -1 -1");
}

Measured memory_bytes: 4352
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N, long M, long[] A, long[] B) {
    long rem = M;
    long ans;
    foreach (a, b; zip(A, B).sort()) {
        auto buy = min(b, rem);
        ans += a * buy;
        rem -= buy;
        if (rem <= 0)
            break;
    }
    return ans;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long M;
    M = input.front.to!long;
    input.popFront;

    long[] A = new long[](cast(size_t) (N));
    long[] B = new long[](cast(size_t) (N));
    foreach (i; 0 .. cast(size_t) (N)) {
        A[i] = input.front.to!long;
        input.popFront;
        B[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, M, A, B);
    else
        solve(N, M, A, B).writeln;
}


Measured memory_bytes: 4732
#include<iostream>
using namespace std;
int main(){
  int a,b,c,k;
  cin>>a>>b>>c;
  cin>>k;
  for(int i=0;i<k;i++){
    if(a>=b){
      b*=2;
    }else if(b>=c){
      c*=2;
    }
  }
  if(a<b && b<c){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define PER(a,b,c) for(int a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
using namespace std;
const int MAXN=1e6+5;
int n,m,t;
int v[MAXN];
char s[MAXN];
int main(){
    cin>>n>>m;
    REP(i,1,m){
        int a;
        sci(a);
        n-=a;
    }
    if(n<0)cout<<-1;
    else cout<<n;
}

Measured memory_bytes: 3260
#include<bits/stdc++.h>
#include<sstream>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define loop(i,a,b) for(i=(int)a;i<(int)b;i++)
#define revloop(i,a,b) for(i=(int)a;i>=(int)b;i--)
#define stloop(it,v) for(it=v.begin();it!=v.end();++it)
#define ii pair<int,string>
#define MP make_pair
#define pb push_back
#define ll long long int
#define fill(v,d) memset(v,d,sizeof(v))
#define INF 0x3f3f3f3f
ll readli()
{
    register char c;
    for(c=getchar(); !(c>='0' && c<='9'); c=getchar());
    register long a=c-'0';
    for(c=getchar(); c>='0' && c<='9'; c=getchar())
        a=(a<<3)+(a<<1)+c-'0';
    return a;
}
template<class R,class E>
R find(R first,R last,const E& value)
{
  while(first!=last && *first!=value) first++;
  return first;
}
int main()
{  std::ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int a,b,t,m,n,q,i;
   cin>>n>>m>>q;
   bool c[n]={false},r[m]={false};
   while(q--)
   {
     cin>>a>>b>>t;
     if(t==1)
     {
        loop(i,0,a)
         c[i]=1;
     }
     else
     { if(t==2)
       {
         loop(i,a,n)
          c[i]=1;
       }
       else
       { if(t==3)
         {
           loop(i,0,b)
            r[i]=1;
         }
         else
         { loop(i,b,m)
             r[i]=1;
         }
       }
     }
   }
   int ans1=0,ans2=0;
   loop(i,0,n)
   {
     if(c[i]==0)
       ans1++;
   }
   loop(i,0,m)
   { if(r[i]==0)
       ans2++;
   }
   cout<<ans1*1LL*ans2;
   return 0;
}


Measured memory_bytes: 256