akhauriyash/Code-Regression huggingface dataset:
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	ll A,B,C;
	cin >>A>>B>>C;
	// 解法
	ll ans = min(C, A+B+1)+B;
	
	//出力
	cout << ans << endl;
	
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#define MN 505
using namespace std;
char ch[MN][MN];int n,m;bool a[MN][MN],b[MN][MN];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%s",ch[i]+1);
	for(int i=1;i<=n;i++)a[i][1]=b[i][m]=1;
//	for(int i=1;i<=n;i++){for(int j=1;j<=m;j++)printf("%c",a[i][j]?'#':'.');puts("");}
//	for(int i=1;i<=n;i++){for(int j=1;j<=m;j++)printf("%c",b[i][j]?'#':'.');puts("");}
	for(int i=1;i*2<=n;i++){
		for(int j=2;j<m;j++)a[i*2-1][j]=b[i*2][j]=1;
	}
	if(n%2)for(int i=2;i<m;i++)a[n][i]=1;
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)a[i][j]|=(ch[i][j]=='#'),b[i][j]|=(ch[i][j]=='#');
	for(int i=1;i<=n;i++){for(int j=1;j<=m;j++)printf("%c",a[i][j]?'#':'.');puts("");}
	for(int i=1;i<=n;i++){for(int j=1;j<=m;j++)printf("%c",b[i][j]?'#':'.');puts("");}
}



Measured memory_bytes: 1408
import sys

# fp = open("input.txt", "r")
fp = sys.stdin

res = 0
for i in xrange(28):
    num = int(fp.readline())
    res += 1 << (num-1)

for i in xrange(30):
    if((res & (1<<i)) == 0) :
        print i+1
        

Measured memory_bytes: 4216
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> x(n);
	rep(i, n) cin >> x[i];
	vector<int> x_ = x;
	sort(x_.begin(), x_.end());
	int res1 = x_[n / 2 - 1];
	int res2 = x_[n / 2];
	for (int i = 0; i < n; ++i) {
		if (x[i] >= res2) printf("%d\n", res1);
		else printf("%d\n", res2);
	}
	return 0;
}


Measured memory_bytes: 3840
#include <stdio.h>

int main(){
	int K,A,B;
	long long int ans=1;
	
	scanf("%d %d %d",&K,&A,&B);
	
	while(K>0){
		if(B-A>2 && ans>=A && K>=2){
			ans+=B-A;
			K-=2;
		}else{
			ans++;
			K--;
		}
	}
	
	printf("%lld",ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
const ll fact_table = 800008;
double Pi = 3.1415926535897932384626;
 
//vector<ll> G[550010];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
//ll mod = 998244353;
ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k;
ll ans;
ll x[500005], y[500005], z[200005];
char s[500005], t[500005];
string table[100];
bool used[500005];
 
int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    for(ll i=0;i<n;i++){
        cin >> table[i] >> x[i];
    }
    string tt;
    cin >> tt;
    bool awake = false;
    for(ll i=0;i<n;i++){
        if(awake){
            ans += x[i];
        }
        if(table[i] == tt){
            awake = true;
        }
    }
    p(ans);
    return 0;
}













Measured memory_bytes: 14592
#include <iostream>
#include <cstdlib>
#include <algorithm>
#define MAXN 55
#define INF (ll)1e19
#define add (ll)1e11
#define ll long long
using namespace std;
struct point{
    ll x, y;
}a[MAXN];
ll x[MAXN], y[MAXN];
int main() {
    ll n, k, cnt, ans = INF;
    ll x1, x2, y1, y2;
    cin >> n >> k;
    for(ll i = 1; i <= n; i++) {
        cin >> a[i].x >> a[i].y;
        a[i].x += add; a[i].y += add;
        x[i] = a[i].x; y[i] = a[i].y;
    }
    sort(x+1, x+1+n);
    sort(y+1, y+1+n);
    for(int xi1 = 1; xi1 <= n; xi1++) {
        for(int xi2 = xi1+1; xi2 <= n; xi2++) {
            for(int yi1 = 1; yi1 <= n; yi1++) {
                for(int yi2 = yi1+1; yi2 <= n; yi2++) {
                    x1 = x[xi1], x2 = x[xi2];
                    y1 = y[yi1], y2 = y[yi2];
                    cnt = 0;
                    for(int i = 1; i <= n; i++) 
                        if(a[i].x >= x1 && a[i].x <= x2 && a[i].y >= y1 && a[i].y <= y2)
                            cnt ++;
                    if(cnt >= k) 
                        ans = min(ans, (x2-x1)*(y2-y1));
                }
            }
        }
    }
    cout << ans << "\n";
    // system("pause");
    return 0;
}

Measured memory_bytes: 256
while n = gets.to_i
	break if n.zero?

	dataset = Hash.new
	dataset.default = 0
	
	n.times do
		id, selling_price, quantity = gets.chomp.split.map(&:to_i)
		dataset[id] += selling_price * quantity
	end
	
	satisfying_id = dataset.select{|id, sales| sales >= 1000000 }.keys
	
	puts (satisfying_id.empty? ? "NA" : satisfying_id)
end

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

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    LD sum = 0;
    rep(i, n){
        LD x;
        string s;
        cin >> x >> s;
        
        if(s == "JPY"){
            sum += (LD)x;
        }else{
            sum += x * 380000.0;
        }
    }
    
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 256
// Integers on a Tree
// * frank_c1
// * 2017 / 09 / 27 
 
#include <bits/stdc++.h>
using namespace std;
 
const int maxn = (int)(1e5) + 5;
int a[maxn], l[maxn], r[maxn], T[maxn];
vector<int> nxt[maxn], g[maxn];
int n;
 
void dfs(int x, int f) {
	for (int i = 0; i < (int)nxt[x].size(); ++i) if (nxt[x][i] ^ f) {
		dfs(nxt[x][i], x); 
		int L = l[nxt[x][i]], R = r[nxt[x][i]];
		if (L == R) g[x].push_back(L);
		l[x] = max(l[x], L - 1); r[x] = min(r[x], R + 1);
	} if (a[x] >= 0) l[x] = max(l[x], a[x]), r[x] = min(r[x], a[x]);
	int mx = g[x].size(); for (int i = 0; i < mx; ++i) T[i] = g[x][i];
	sort(T, T + mx); mx = unique(T, T + mx) - T; g[x].clear();
	for (int i = 0; i < mx; ++i) if (T[i] >= l[x] && T[i] <= r[x]) g[x].push_back(T[i]);
}
 
void gen(int x, int f) {
	for (int i = 0; i < (int)nxt[x].size(); ++i) if (nxt[x][i] ^ f) {
		int L = l[nxt[x][i]], R = r[nxt[x][i]];
		if (L <= a[x] - 1 && a[x] - 1 <= R && find(g[nxt[x][i]].begin(), g[nxt[x][i]].end(), a[x] - 1) == g[nxt[x][i]].end()) a[nxt[x][i]] = a[x] - 1; 
		else a[nxt[x][i]] = a[x] + 1;
		gen(nxt[x][i], x);
	}
}
 
inline bool chk() {
	for (int i = 1; i <= n; ++i) if (l[i] + (int)g[i].size() > r[i]) return 0; return 1;
}
 
int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; ++i) {
		int u, v;
		scanf("%d%d", &u, &v);
		nxt[u].push_back(v);
		nxt[v].push_back(u);
	}
	int K;
	scanf("%d", &K);
	memset(a, -1, sizeof(a));
	for (int i = 1; i <= K; ++i) {
		int x, v; scanf("%d%d", &x, &v); a[x] = v;
	}
	memset(l, 0x80, sizeof(l));
	memset(r, 0x3f, sizeof(r));
	dfs(1, 0);
	if (chk()) {
		printf("Yes\n"); 
		if (a[1] < 0) {
			if (!g[1].size() || g[1][0] > l[1]) a[1] = l[1];
			else for (int i = 1; i < (int)g[1].size(); ++i) if (g[1][i] != g[1][i - 1] + 1) {
				a[1] = g[1][i - 1] + 1; break;
			}
		}
		gen(1, 0);
		for (int i = 1; i <= n; ++i) printf("%d\n", a[i]);
	} else printf("No\n");
	return 0;
}

Measured memory_bytes: 21888
#include<bits/stdc++.h>
#define pi acos(-1)
using namespace std;

int cunt[1000000];

int main ()
{
    /*int tc;
    cin>>tc;


    for(int i=0; i<tc-1; i++)
    {
        int n;
        cin>>n;
        cunt[n]++;
    }

    for(int i=1; i<=tc; i++)
    {
        cout<<cunt[i]<<endl;
    }*/

    int n;

    cin>>n;
    cout<<2*n*pi<<endl;

    return 0;

}




Measured memory_bytes: 3784
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

int main(void) {
  long long a[6], n, ans, min = 1000000000000001;

  if(scanf("%lld", &n) == 1);

  for(int i = 0; i < 5; i++) {
    if(scanf("%lld", &a[i]) == 1);
    if(a[i] < min) {
      min = a[i];
    }
  }

  if(n % min != 0) {
    ans = n / min + 5;
  } else {
    ans = n / min + 4;
  }

  printf("%lld", ans);

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

main(){
  int n, *a, p, r, x, i, j, k;

  scanf("%d", &n);

  a = malloc(sizeof(int)*n+1);

  for(i = 0;i < n;i++) scanf("%d", &a[i]);
  p = 0;
  r = n - 1;

  x = a[r];
  i = p - 1;
  
  for(j = p;j <= r-1;j++){
    if(a[j] <= x){
      i = i+1;
      k = a[j];
      a[j] = a[i];
      a[i] = k;
    }
  }
  k = a[r];
  a[r] = a[i+1];
  a[i+1] = k;

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

Measured memory_bytes: 992
#include <iostream>
#include <utility>
#include <string>

struct Dice
{
  int top;
  int bottom;
  int north, east, south, west;

  Dice (int n1, int n2, int n3, int n4, int n5, int n6) {
    top = n1;
    south = n2;
    east = n3;
    west = n4;
    north = n5;
    bottom = n6;
  }

  void move(char dir){
    if (dir == 'N') {
      setNum(south, top, east, bottom, west, north);
    }
    if (dir == 'S') {
      setNum(north, bottom, east, top, west, south);
    }
    if (dir == 'W') {
      setNum(east, north, bottom, south, top, west);
    }
    if (dir == 'E') {
      setNum(west, north, top, south, bottom, east);
    }
  }

  void setNum(int top, int north, int east, int south, int west, int bottom) {
    Dice::top = top;
    Dice::north = north;
    Dice::east = east;
    Dice::south = south;
    Dice::west = west;
    Dice::bottom = bottom;
  }
};

int main() {
  int n1, n2, n3, n4, n5, n6;
  std::cin >> n1 >> n2 >> n3 >> n4 >> n5 >> n6;
  Dice dice(n1, n2, n3, n4, n5, n6);
  std::string cmds;
  std::cin >> cmds;
  for (int i = 0; i < cmds.size(); i++)
  {
    dice.move(cmds[i]);
  }
  std::cout << dice.top << "\n";
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n,cnt=1,ans=0,a[10000000],b,c,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("snuke"),alphh("ABCDEFGHIJK"),s;

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

        cin >> n;
       rep(i,n)cin >>a[i];
       rep(i,n){
           if(i+1==a[a[i]-1]){
               ans++;
           }
       }
       Cout(ans/2);
return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
 int a, b, c, i;
 int k = 0;

scanf("%d", &a);
scanf("%d", &b);
scanf("%d", &c);

for(i = a; i <= b; i++)
{
 if(c % i == 0)
  k += 1;
}

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

return 0;
}



Measured memory_bytes: 2148
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    ll x,y;
    cin>>x>>y;
    int ans = 0;
    while (x <= y) ++ans,x = x + x;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
a, b = map(int,input().split())

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)
    
print(lcm(a,b))
    
    

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

const int MAX = 510000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void init_ncr() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll ncr(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  ll N,K;cin>>N>>K;
  vector<ll> A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  sort(A.begin(), A.end());

  init_ncr();

  ll ans=0;
  for(int i=0;i<N;i++){
    if(N-i-1<K-1)break;
    ans += A[N-i-1]%MOD*ncr(N-i-1, K-1)%MOD;
    ans %= MOD;
  }
  for(int i=0;i<N;i++){
    ans -= A[i]%MOD*ncr(N-i-1, K-1)%MOD;
    if(ans<0)ans += MOD;
    ans %= MOD;
  }
  cout<<ans<<endl;

  
  return 0;
}


Measured memory_bytes: 15840
#include <bits/stdc++.h>
using namespace std;
long long fac[2001000], finv[2001000], inv[2001000]; 
long long MOD = 1000000007;
int X1, X2, X3, X4, X5, X6; 
int Y1, Y2, Y3, Y4, Y5, Y6;
int dx, dy; 
void COMinit(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i = 2; i < 2000500; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
long long COM(int n, int k){
	if(n < k) return 0;
	if(n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long total(int Ax, int Ay, int Bx, int By){
	/* (0, 0) から (Ax, Ay) まで行く経路で，
	(i, j) を通るものの個数を [0, Bx] x [0, By] で加えた値
	*/
	long long cnt = 0; 
	for(int i = 0; i < By; i++){
		/* (Bx, i) で [0, Bx] x [0, By] から抜ける経路の本数に
		領域内で通る点の個数をかける
		*/
		long long add = COM(Bx + i, i) * COM(Ax + Ay - Bx - i - 1, Ay - i) % MOD; 
		add *= Bx + i + 1; add %= MOD; 
		cnt += add;
	}
	for(int i = 0; i < Bx; i++){
		long long add = COM(By + i, i) * COM(Ax + Ay - By - i - 1, Ax - i) % MOD;
		add *= By + i + 1; add %= MOD; 
		cnt += add;
	}
	long long add = COM(Bx + By, Bx) * COM(Ax + Ay - Bx - By, Ax - Bx) % MOD; 
	add *= Bx + By + 1; add %= MOD; 
	cnt += add; 
	return cnt % MOD; 
}
long long total2(int Ax, int Ay, int Bx, int By){
	return (MOD * 2 + total(Ax, Ay, Bx + dx, By + dy) - total(Ax, Ay, Bx + dx, By - 1) - total(Ax, Ay, Bx - 1, By + dy) + total(Ax, Ay, Bx - 1, By - 1)) % MOD; 
}
int main(){
	cin >> X1 >> X2 >> X3 >> X4 >> X5 >> X6; 	 
	cin >> Y1 >> Y2 >> Y3 >> Y4 >> Y5 >> Y6; 
	COMinit(); 
	dx = X4 - X3; dy = Y4 - Y3; 
	/* 中央エリアの点 (s, t) を固定すると，ABC154-F より前半は
		C(s+t-X1-Y1+2, s-X1+1) - C(s+t-X1-Y2+1, s-X1+1)
		-C(s+t-X2-Y1+1, s-X2) + C(s+t-X2-Y2, s-X2)
	   後半は
		C(X6+Y6-s-t+2, X6-s+1) - C(X6+Y5-s-t+1, X6-s+1)
		-C(X5+Y6-s-t+1, X5-s) + C(X5+Y5-s-t, X5-s)
	   これらの積を展開して 16 回やるのです！
	*/
	int A[4], B[4], C[4], D[4], E[4], F[4]; 
	A[0] = 2 - X1 - Y1; A[1] = 1 - X1 - Y2; 
	A[2] = - X2 - Y2; A[3] = 1 - X2 - Y1; 
	B[0] = - X1 + 1; B[1] = B[0]; B[2] = - X2; B[3] = B[2]; 
	C[0] = X6 + Y6 + 2; C[1] = X6 + Y5 + 1; 
	C[2] = X5 + Y5; C[3] = X5 + Y6 + 1; 
	D[0] = X6 + 1; D[1] = D[0]; D[2] = X5; D[3] = D[2];
	E[0] = X3 - X1 + 1; E[1] = E[0]; 
	E[2] = X3 - X2; E[3] = E[2]; 
	F[0] = Y3 - Y1 + 1; F[1] = Y3 - Y2; 
	F[2] = F[1]; F[3] = F[0]; 
	long long ans = MOD * 8; 
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 4; j++){
			long long tmp = total2(B[i] + D[j], A[i] + C[j] - B[i] - D[j], E[i], F[i]); 
			if((i + j) & 1) ans -= tmp;
			else ans += tmp;
		}
	}
	cout << ans % MOD << "\n";
}

Measured memory_bytes: 50524
#include <bits/stdc++.h>
using namespace std;
int main(){
  char c[101];
  cin>>c;
  for (int i=0;i<strlen(c);i++)
	if(c[i]=='R' && i%2!=0 || c[i]=='L' && i%2==0)return puts("No"),0;
  return puts("Yes"),0;
}	

Measured memory_bytes: 256
/**
 *    author:  FromDihPout
 *    created: 2020-09-19
**/

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> primes(n + 1);
    for (int i = 2; i <= n; i++) {
        if (primes[i] == 0) {
            for (int j = i; j <= n; j += i) {
                primes[j] = i;
            }
        }
    }
    
    auto factorize = [&](int x) {
        int factors = 1;
        while (x > 1) {
            int p = primes[x], cnt = 0;
            while (x % p == 0) {
                x /= p;
                cnt++;
            }
            factors *= cnt + 1;
        }
        return factors;
    };
    
    long long ans = 1;
    for (int x = 2; x < n; x++) {
        ans += factorize(x);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 7088
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
using namespace std;

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

    int N;
    cin >> N;
    vector<int> A(1E6), B(1E6);
    REP(i, N) {
        int x;
        cin >> x;
        if (i % 2 == 0) {
            A[x]++;
        } else {
            B[x]++;
        }
    }

    int amax = 0, bmax = 0;
    int amax2 = 0, bmax2 = 0;
    int ai, bi;
    REP(i, 1E6) {
        if (A[i] < amax && 0 < A[i])
            amax2 = max(amax2, A[i]);
        if (B[i] < bmax && 0 < B[i])
            bmax2 = max(bmax2, B[i]);
        if (amax <= A[i]) {
            ai    = i;
            amax2 = amax;
            amax  = A[i];
        }
        if (bmax <= B[i]) {
            bi    = i;
            bmax2 = bmax;
            bmax  = B[i];
        }
    }
    int ans;
    if (ai != bi) {
        ans = N - amax - bmax;
    } else {
        if (amax2 > bmax2) {
            ans = N - amax2 - bmax;
        } else {
            ans = N - amax - bmax2;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  
  if(b-a <= 0)
    cout << "delicious" << endl;
  else if(b-a <= x)
    cout << "safe" << endl;
  else
    cout << "dangerous" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include<cstdio>
#include <vector>
#include<queue>
#include<limits.h>
#include<string.h>
#include<functional>
using namespace std;

signed main() {
	int a, b; 
	while (cin >> a >> b, a | b) {
		for (int c = 0; c < a; c++) {
			for (int d = 0; d < b; d++) {
				if ((c+d)%2==0) {
					cout << '#';
				}
				else cout << '.';
			}
			cout << endl;
		}
		puts("");
	}
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ALL(obj) (obj).begin(), (obj).end()

int main() {
  int X, N;
  cin >> X >> N;
  if (N==0){
    cout << X << endl;
    return 0;
  }
  vector<int> p(N);

  int min = 1000;
  for (int i=0; i<N; i++){
    cin >> p[i];
  }
  sort(ALL(p));
  
  int ng = -1;
  int ok = (int)p.size();

  while(abs(ok-ng) > 1){
    int mid = (ok+ng)/2;
    if(p[mid] >= X){
      ok = mid;
    }else{
      ng = mid;
    }
  }

  if (p[ok] != X){
    cout << X << endl;
    return 0;
  }else;
  int index = 1;
  int left = ok-index;
  int right = ok+index;
  while(1){

    if(ok-index<0){
      cout << X-index << endl;
      return 0;
    }else if(p[ok-index]!=X-index){
      cout << X-index << endl;
      return 0;
    }else if(ok+index>=N){
      cout << X+index << endl;
      return 0;      
    }else if(p[ok+index]!=X+index){
      cout << X+index << endl;
      return 0;
    }else{
      index++;
    }
  }
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

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

    int total = 0;
    for (int n = 0; n < N; n++) {
        int l, r;
        cin >> l >> r;
        total += (r - l) + 1;
    }

    cout << total << endl;

    return 0;
}

Measured memory_bytes: 256
N,M=map(int, input().split())
H =list(map(int, input().split()))

A = []
B = []
for i in range(M):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
C=[1]*N
for i in range(M):
  if H[A[i]-1]>H[B[i]-1]:
    C[B[i]-1]=0
  elif H[A[i]-1]<H[B[i]-1]:
    C[A[i]-1]=0
  elif H[A[i]-1]==H[B[i]-1]:
    C[A[i]-1]=0    
    C[B[i]-1]=0
print(len(C)-C.count(0))

Measured memory_bytes: 22296
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#define mod 998244353
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int fac[2500010],inv[2500010];
inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}return ans;
}
inline int C(int n,int m)
{
	if(n<0 || m<0)return 0;
	return 1LL*fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    fac[0]=1;
    for(int i=1;i<=2500000;i++)fac[i]=1LL*fac[i-1]*i%mod;inv[2500000]=power(fac[2500000],mod-2);
    for(int i=2500000;i>=1;i--)inv[i-1]=1LL*inv[i]*i%mod;
    int n=read(),m=read(),ans;
    ans=C(n-1+3*m,n-1);
    for(int i=m+1;i<=min(n,3*m);i++)
	{
		if((3*m-i)&1)continue;
		(ans-=1LL*C(n,i)*C((3*m-i)/2+n-1,n-1)%mod-mod)%=mod;
	}
    for(int i=2*m+1;i<=3*m;i++)(ans-=1LL*n*C(3*m-i+n-2,n-2)%mod-mod)%=mod;
    pr2(ans);
    return 0;
}

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

int main(){
  string S;
  int N;
  cin >> N >> S;
  long long ans=1;
  long long a[26]={};
  for(char c:S){
    a[c-'a']++;
  }
  for(long long n:a){
    ans=ans*(n+1)%1000000007;
  }
  cout << ans-1 << endl;
}

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

int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  rep(i,0,n) cin>>a[i];
  rep(i,0,n-k){
    if(a[i]<a[i+k]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 4412
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	lint n,k;
	cin>>n>>k;
	map<lint,lint>m;
	rep(i,n){
		lint a,b;
		cin>>a>>b;
		if(m.count(a))m.at(a)+=b;
		else m.emplace(a,b);
	}
	each(it,m){
		k-=(*it).second;
		if(k<=0){
			cout<<(*it).first<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
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; }

signed main(){
    int n;
    int streek = 0;
    bool isOK = false;
    cin >> n;
    rep(i, n){
        int a, b;
        cin >> a >> b;
        if(a == b) streek++;
        else streek = 0;
        if(streek == 3){
            isOK = true;
        }
    }
    if(isOK) cout << "Yes" << endl;
    else cout << "No" <<endl;
}

Measured memory_bytes: 3620
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * (n)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


def solve():
    H, W = il()
    S = imi(H, str)
    from itertools import product

    dst = ((i, j) for i, j in product(range(-1, 2), repeat=2))
    dst = list(dst)
    B = [[0] * W for _ in range(H)]
    sharp_pos = []
    for i, j in product(range(H), range(W)):
        if S[i][j] == "#":
            B[i][j] = "#"
            sharp_pos.append((i, j))
    for i, j in sharp_pos:
        for d in dst:
            x = i + d[1]
            y = j + d[0]
            if 0 <= x < H and 0 <= y < W:
                if S[i][j] == "#" and S[x][y] == ".":
                    B[x][y] += 1
    for b in B:
        print("".join(map(str, b)))


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3192
str = gets.chomp
result = true

(0...str.length).each do |i|
  if (i + 1).odd?
    result = false unless ["R", "U", "D"].include?(str[i])
  else
    result = false unless ["L", "U", "D"].include?(str[i])
  end
end

puts result ? "Yes" : "No"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    string s;
    cin >> s;

    rep(i, s.size()) cout << 'x';
    cout << endl;
    
    return 0;
}

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

public class Main {

	/**
	 * @param args65538
	 */
	public static void main(String[] args) throws java.io.IOException {

		Scanner scan = new Scanner(System.in);
		Map<String, ArrayList<Integer>> index = new HashMap<String, ArrayList<Integer>>();
		ArrayList<String> keys = new ArrayList<String>();
		while (scan.hasNext()) {

			String key = scan.next();
			int value = scan.nextInt();

			if (!index.containsKey(key)) {
				keys.add(key);
				ArrayList<Integer> tmp = new ArrayList<Integer>();
				tmp.add(value);
				index.put(key, tmp);
			} else {
				ArrayList<Integer> list = index.get(key);
				list.add(value);
			}
		}
		Collections.sort(keys);
		for (int i = 0; i < keys.size(); i++) {
			String key = keys.get(i);
			System.out.println(key);
			ArrayList<Integer> cout = new ArrayList<Integer>();
			cout = index.get(key);
			Collections.sort(cout);
			boolean isFirst = true;

			for (int j = 0; j < cout.size(); j++) {
				if (isFirst) {
					isFirst = false;
				} else {
					System.out.print(" ");
				}
				System.out.print(cout.get(j));
			}
			System.out.println();

		}
	}
}

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

#define ll long long
#define int ll
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define files(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(a) a.begin(), a.end()
#define pii pair<int, int>

using namespace std;

const int inf = 1e12;
const int mod = 1e9 + 7;
const int max_n = 1e6 + 5;
const ld pi = acos(-1);

void run() {
    int a, b;
    cin >> a >> b;
    cout << a * b;
}

signed main() {
#ifndef ONLINE_JUDGE
    files("input.txt", "output.txt");
#endif
    //files("multiply.in", "multiply.out");
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //cin >> t;
    while (t--)
        run();
    return 0;
}

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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int a,b;

main() {
    cin >> a >> b;
    if (a%2 && b%2) ct("Odd")
    else ct("Even")
}






Measured memory_bytes: 256
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    N = int(input())
    X = list(map(int, input().split()))

    s = list(sorted(X))
    m = defaultdict(int)
    for i, x in enumerate(s):
        m[x] = i

    for x in X:
        i = m[x]
        if i < N // 2:
            print(s[N // 2])
        else:
            print(s[N // 2 - 1])

if __name__ == '__main__':
    main()


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

int main(){
    int n, ans=0, p, maxp=0;
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        cin >> p;
        ans += p;
        maxp = max(maxp, p);
    }
    ans -= (maxp/2);
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int x = Integer.parseInt(sc.next());
    int y = Integer.parseInt(sc.next());
    Map<Integer, Node> nodes = new HashMap<>();
    for (int i = 1; i <= n; i++) {
      Node node = new Node(i, n);
      nodes.put(i, node);
    }
    for (Node base : nodes.values()) {
      for (Node target : nodes.values()) {
        base.calculate(target, x, y);
      }
    }

    Map<Integer, Long> answer = nodes.values().stream()
      .flatMapToInt(v -> Arrays.stream(v.idToDistanceArray))
      .mapToObj(Integer::valueOf)
      .collect(Collectors.groupingBy(
        i -> i,
        Collectors.counting()
      ));
    for (int i = 1; i < n; i++) {
      pw.println(answer.getOrDefault(i, 0L) / 2);
    }
  }

  static class Node {

    private int id;

    private int[] idToDistanceArray;

    public Node(int id, int numOfNode) {
      this.id = id;
      this.idToDistanceArray = new int[numOfNode];
    }

    void calculate(Node target, int x, int y) {
      int targetId = target.id;
      idToDistanceArray[targetId - 1] = Math.min(Math.min(
        Math.abs(id - target.id),
        Math.abs(x - id) + 1 + Math.abs(y - targetId)),
        Math.abs(y - id) + 1 + Math.abs(x - targetId)
      );
    }

    @Override
    public boolean equals(Object o) {
      if (this == o) {
        return true;
      }
      if (o == null || getClass() != o.getClass()) {
        return false;
      }
      Node node = (Node) o;
      return id == node.id;
    }

    @Override
    public int hashCode() {
      return Objects.hash(id);
    }

    @Override
    public String toString() {
      return "Node{" +
        "id=" + id +
        '}';
    }
  }
}


Measured memory_bytes: 106376
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 100000000000000009
#define int long long
using P = pair<int,int>;
signed main(){
  int k,a,b;
  cin >> k >> a >> b;
  if(k-a > 0){
    if(b-a < 2){
      cout << k + 1 << endl;
    }
    else{
      cout << (b-a)*((k-a+1)/2) + (k-a+1)%2 + a << endl; 
    }
  }
  else{
    cout << k + 1 << endl;
  }
}

Measured memory_bytes: 256
while True:
    H, W = map(int, input().split())
    if H == W == 0:
        break

    for i in range(H):
        for j in range(W):
            if(i+j) % 2 == 0:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()



Measured memory_bytes: 7008
#include<stdio.h>
#include<string.h> 
int main()
{
	char a[200]={0};
	int i,l,ans;
	scanf("%s",a);
	l=strlen(a);
	if(l%2==1)
	{
		ans=0;
		for(i=1;i<=l/2;i++)
		{
			if(a[(l/2)-i]!=a[(l/2)+i])
			ans++;
		}
	}
	else 
	{
		ans=0;
		for(i=0;i<l/2;i++)
		{
			if(a[(l/2)-1-i]!=a[(l/2)+i])
			ans++;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
N, K = map(int, input().split())
p = list(map(int, input().split()))

for i in range(N):
    p[i] = (p[i]+1)/2

sum_list = [0] * N

for i in range(N):
    if i == 0:
        sum_list[i] = p[i]
    else:
        sum_list[i] = sum_list[i-1]+p[i]
res = sum_list[K-1]

for i in range(N):
    if i < K:
        continue
    if sum_list[i] - sum_list[i-K] > res:
        res = sum_list[i] - sum_list[i-K]

print(res)


Measured memory_bytes: 25060
#include<iostream>
using namespace std;
int main()
{
int a,b; 
cin>>a>>b;
if(a==1)a=14;
if(b==1)b=14;
if(a==b)
cout<<"Draw";
else if(a>b)
cout<<"Alice";
else cout<<"Bob";
system ("pause");
return 0;
}

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

int n, k;

int main() { 
 std::cin >> n >> k;
 std::vector<int> l(n);
 for(int i = 0; i < n; ++i) {
  std::cin >> l[i];
 }
 std::sort(l.begin(), l.end(), [](int a, int b) {
  return a > b;
 });
 int length_max = 0;
 for (int i = 0; i < k; ++i){
   length_max += l[i];
 }
 std::cout << length_max << std::endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        solve();
    }

    void solve() {
        int count = 0;
        while (n > 0) {
            if (n % 10 == 1) {
                count++;
            }
            n /= 10;
        }
        System.out.println(count);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 22484
#include <iostream>
#include <cstdio>
#define F first
#define S second

typedef long long ll;

using namespace std;

ll h, w;
string s[405];
ll dx[4] = {0, 1, 0, -1};
ll dy[4] = {1, 0, -1, 0};
pair<ll, ll> cp[404][404];
ll sz1[404][404];
ll sz2[404][404];
ll ans;

pair<ll, ll> fnd(ll p, ll q)
{
    if(cp[p][q] == make_pair(p, q)) return make_pair(p, q);
    return cp[p][q] = fnd(cp[p][q].F, cp[p][q].S);
}

int main()
{
    cin>>h>>w;
    for(ll i = 0; i <= w; i++) s[0].push_back(' '), s[h].push_back(' ');
    for(ll i = 1; i <= h; i++) cin>>s[i], s[i] = ' ' + s[i] + ' ';
    for(ll i = 1; i <= h; i++)
    {
        for(ll j = 1; j <= w; j++)
        {
            cp[i][j] = make_pair(i, j);
            sz1[i][j] = (s[i][j] == '#');
            sz2[i][j] = (s[i][j] == '.');
        }
    }
    for(ll i = 1; i <= h; i++)
    {
        for(ll j = 1; j <= w; j++)
        {
            for(ll k = 0; k < 4; k++)
            {
                if(s[i][j] == '#' && s[i + dx[k]][j + dy[k]] == '.')
                {
                    if(fnd(i, j) == fnd(i + dx[k], j + dy[k])) continue;
                    sz1[fnd(i + dx[k], j + dy[k]).F][fnd(i + dx[k], j + dy[k]).S] += sz1[fnd(i, j).F][fnd(i, j).S];sz1[fnd(i, j).F][fnd(i, j).S] = 0;
                    sz2[fnd(i + dx[k], j + dy[k]).F][fnd(i + dx[k], j + dy[k]).S] += sz2[fnd(i, j).F][fnd(i, j).S];sz2[fnd(i, j).F][fnd(i, j).S] = 0;
                    cp[fnd(i, j).F][fnd(i, j).S] = fnd(i + dx[k], j + dy[k]);
                }
            }
        }
    }
    for(ll i = 1; i <= h; i++) for(ll j = 1; j <= w; j++) ans += sz1[i][j] * sz2[i][j];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5632
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	ll A, B, C, X; cin >> A >> B >> C >> X;

	ll cnt = 0;
	repe(i, 0, A) {
		repe(j, 0, B) {
			repe(k, 0, C) {
				if (X == i * 500 + j * 100 + k * 50) {
					cnt++;
				}
			}
		}
	}
	cout << cnt << endl;

	return 0;
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

const int N = 102;
long memo[N][2][N];
string s; 
int k, n;

int dp(int i, bool lss, int cur){
  if (i == n){
    return cur == k;
  }
  if (memo[i][lss][cur] != -1) return memo[i][lss][cur];
  int ans = 0;
  for (int d = 0; d < 10; d++){
    if (!(d <= (s[i] - '0') || lss)) continue;
    ans += dp(i + 1, lss | (d < (s[i] - '0')), cur + (d != 0));
  }
  return memo[i][lss][cur] = ans;
}

int main()
{
  fastio;
  cin >> s >> k;
  n = s.size();
  for (int i = 0; i <= n; i++){
    for (int j = 0; j < 2; j++){
      for (int x = 0; x <= n; x++){
        memo[i][j][x] = -1;
      }
    }
  }
  cout << dp(0, 0, 0);
  return 0;
}

Measured memory_bytes: 384
n=int(input())
ki=[[] for _ in range(n)]
for _ in range(n-1):
  a,b=map(int,input().split())
  a-=1
  b-=1
  ki[a].append(b)
  ki[b].append(a)
# 0とn-1の最短ルートのうち0側に属するものn-1側に属するもの
from collections import deque
# seen[i]:0からの最短ルートでiの一つ前の頂点
seen=[-2]*n
seen[0]=-1
todo=deque([0])
while todo:
  t=todo.popleft()
  l=ki[t]
  for li in l:
    if seen[li]==-2:
      seen[li]=t
      todo.append(li)
      if li==n-1:
        break
root=[n-1]
now=n-1
while now!=0:
  root.append(seen[now])
  now=seen[now]
bend=root[(len(root)-2)//2+1]
wend=root[(len(root)-2)//2]
# 頂点数数え
seen=[0]*n
seen[bend]=1
seen[wend]=1
todo=[bend]
cnt=0
while todo:
  t=todo.pop()
  l=ki[t]
  cnt+=1
  for li in l:
    if seen[li]==0:
      todo.append(li)
      seen[li]=1
if n-cnt<cnt:
  print('Fennec')
else:
  print('Snuke')
#print(root)
#print(bend,wend)

Measured memory_bytes: 28308
import java.io.*;

class Main{
	public static void main (String[ ] args) throws Exception{
		BufferedReader br = new BufferedReader (new InputStreamReader (System.in));

		String str = br.readLine();
		int n = Integer.parseInt(str);

		for(int i = 1; i <= n; i++)
		{
			if(0 == i % 3)
			{
				System.out.print(" " + i);
			}
			else{
				int j = i;
				while(0 != j)
				{
					if(3 == j % 10)
					{
						System.out.print(" " + i);
						break;
					}
					j /= 10;
				}
			}
		}
		System.out.println("");
	}
}

Measured memory_bytes: 26532
N=int(input())
cnt = 0
ans = 0
for i in range(N):
    D1,D2 = map(int,input().split())
    if D1 == D2:
        cnt += 1
        if cnt == 3:
            ans += 1
            print("Yes")
            break
    else:
        cnt = 0
if ans == 0:
    print("No")


Measured memory_bytes: 9172