akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
  public static void main(String[] args) {
      // 入力を受けとる
      Scanner sc = new Scanner(System.in);
      // h: 行 w: 列 k : #の希望数
      int h = sc.nextInt();
      int w = sc.nextInt();
      int k = sc.nextInt();
      char[][] box = new char[h][w];
      int existBlack = 0;
      int ansCount = 0;
      for (int i = 0; i < h; i++) {
        String line = sc.next();
        for (int j = 0; j < w; j++) {
          box[i][j] = line.charAt(j);
        }
      }
      // bit全探索
      //行から選択
      for (int i = 0; i < (1 << h); i++) {
        for (int i2 = 0; i2 < (1 << w); i2++) {
          for (int j = 0; j < h; j++) {
            for (int j2 = 0; j2 < w; j2++) {
              if ((1 & (i >> j)) == 0 && (1 & (i2 >> j2)) == 0 && box[j][j2] == '#') {
                existBlack++;
              }
            }
          }
          if (existBlack == k) {
            ansCount++;
          }
          existBlack = 0;
        }
      }
      System.out.println(ansCount);
  }
}

Measured memory_bytes: 35760
#include<bits/stdc++.h>
using namespace std;
int main(){
  string b;
  cin>>b;
  if(b=="A"){
    cout<<"T"<<endl;
  }else if(b=="T"){
    cout<<"A"<<endl;
  }else if(b=="C"){
    cout<<"G"<<endl;    
  }else{
    cout<<"C"<<endl;
  }
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 998244353;
const ll INF = (ll) 1e15;

pll A[200005];
ll dp[200005];
ll mi[200005];

template<typename T>
struct SegmentTree {
    using F = function<T(T, T)>;

    SegmentTree(F func, T id)
            : merge(func), identity(id) {}

    void init(ll n) {
        offset = 1;
        while (offset < n)
            offset <<= 1;
        node.assign(offset << 1, identity);
    }

    void build(const vector<T> &v) {
        int n = static_cast<int>(v.size());
        init(n);
        for (int i = 0; i < n; ++i) {
            node[offset + i] = v[i];
        }
        for (int i = offset - 1; i >= 0; --i) {
            node[i] = merge(node[(1 << i) | 0], node[(1 << i) | 1]);
        }
    }

    void set(int index, T value) {
        index += offset;
        node[index] = value;
        while (index >>= 1) {
            node[index] = merge(node[(index << 1) | 0], node[(index << 1) | 1]);
        }
    }

    //! [left, right]
    T get(int left, int right) {
        left += offset;
        right += offset + 1;

        T val = identity;
        while (left < right) {
            if (left & 1)
                val = merge(val, node[left++]);
            if (right & 1)
                val = merge(val, node[--right]);

            left >>= 1;
            right >>= 1;
        }
        return val;
    }

    T identity;
    F merge;
    vector<T> node;
    int offset;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i].first >> A[i].second;
    }
    sort(A, A + N, [](pll a, pll b) { return a.first < b.first; });
    A[N] = pll(INF, INF);
    memset(dp, 0, sizeof(dp));
    SegmentTree<ll> seg([](ll a, ll b) { return std::max(a, b); }, 0);
    seg.init(N + 1);
    dp[N] = 1;
    mi[N] = N;
    seg.set(N, N);

    ll ans = 1;
    for (ll i = N - 1; i >= 0; --i) {
        //! 右からi番目を起動
        pll a = A[i];
        ll t = 0;
        ll ok = N + 1, ng = i;
        while (abs(ok - ng) > 1) {
            ll mid = (ok + ng) / 2;
            if (A[mid].first >= a.first + a.second)
                ok = mid;
            else
                ng = mid;
        }

        ll index = i + 1;
        if (ok - 1 >= index)
            index = seg.get(i + 1, ok - 1);
        t = dp[index];

        ans = (ans + t) % MOD;
        dp[i] = ans;
        seg.set(i, index);
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
	int n,k;
	cin >> n>>k;
	vector<int> x(n);
	for(int i=0;i<n;i++)
		cin >> x[i];

	vector<int> dp(k+1,0);
	dp[0]=false;

	for(int i=1;i<=k;i++)
	{
		dp[i]=false;
		for(int j=0;j<n;j++)
		{
			if(i-x[j]>=0&&dp[i-x[j]]==false)
				dp[i]=true;
		}
	}

	if(dp[k]==true)
		cout<<"First";
	else
		cout<<"Second";
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
long myPow(long x, long n)
{
    if (n == 0)
        return 1;
    if (n % 2 == 0)
        return myPow(x * x, n / 2);
    else
        return x * myPow(x, n - 1);
}
int main()
{
    ll N;
    ll start = 100;
    int cnt = 0;
    cin >> N;

    //fin((ll)(log10(N / start) / log10(1.01)));
    //log的な累乗を求めるしかない
    //100倍になるまで何回かけるかを求める
    for(;;){
        if(start >= N) break;
        start *= 1.01;
        start = (ll)start;
        cnt++;
        //fin(cnt);
        //fin(start);
    }
    fin(cnt);
    return 0;
}

Measured memory_bytes: 3168
#define ll long long
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<stack>
ll z = 1000000007 ;
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll power(ll a ,ll b){if(b == 0) return 1 ; ll c = power(a , b/2) ; if(b%2 == 0) return ((c*c)%z) ; else return ((((c*c)%z)*a)%z) ;}
ll inverse(ll a ,ll n){return power(a , n-2) ;}
ll max(ll a , ll b){if(a > b) return a ; return b ;}
//ios_base::sync_with_stdio(0);
//cin.tie(0); cout.tie(0);
using namespace std ;



int main()
{
	
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	ll n , m ;
	cin >> n >> m ;
	ll corr[n+1] , pen[n+1] ;
	fo(i , n+1)
	{
		corr[i] = 0 ;
		pen[i] = 0 ;
	}
	fo(i , m)
	{
		ll u ;
		string str ;
		cin >> u >> str ;
		if(str == "WA")
		{
			if(corr[u] == 0)
				pen[u]++ ;
		}
		else
			corr[u]++ ;
	}
	ll corr_ans = 0 , penalty = 0 ;
	for(ll i = 1 ; i <= n ; i++)
	{
		if(corr[i] != 0)
			corr_ans++ ;
		if(corr[i] != 0)	
		    penalty += pen[i] ;
	}
	cout << corr_ans << ' ' << penalty << endl ;
	return 0;
}

Measured memory_bytes: 1792
S = list(str(input()))
count = 0

if(len(S)%2 == 0):
    for i in range(int(len(S)/2)):
        if(S[i] != S[-i-1]):
            count += 1
else:
    for i in range(int((len(S)-1)/2)):
        if(S[i] != S[-i-1]):
            count += 1
print(count)

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
  long n; cin>>n;
  int ans;
  for(int i=0;i<n;i++){
    if(n<4) {ans=1; break;}
    else if(i*i>n) {ans=(i-1)*(i-1); break;}
  }
  cout<<ans<<endl;
  return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

#define fill(a,x) memset(a,x,sizeof(a)) 
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end() 
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const int mod = 1e9+7;
const int N = 1e5+10; 
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
ll f(vector<ll> v){
  int n = sz(v);
  ll sum = v[0];
  ll ret = 0;
  FOR(i,1,n-1){
    ll nsum = sum + v[i];
    if(sum < 0 && nsum > 0){sum += v[i];continue;}
    if(nsum < 0 && sum > 0){sum += v[i];continue;}
    if(sum > 0){
      ret += abs(v[i] - (-sum - 1));
      v[i] = -sum - 1;
    }
    else{
      ret += abs(v[i] - (-sum + 1));
      v[i] = -sum + 1;
    }
    sum += v[i];
    assert(sum != 0);
  }
  // for(auto it : v){
  //   cout << it << " ";
  // }
  return ret;
}
int main(){
  fast;
  int n;
  cin >> n;
  vector<ll> v(n);
  FOR(i,0,n-1)cin >> v[i];
  //assert(v[0] != 0);
  if(v[0] == 0){
    v[0] = 1;
    ll x = f(v);
    v[0] = -1;
    x = min(x,f(v));
    cout << x + 1 << "\n";return 0;
  }
  else{
    ll x = f(v);
    int xx = v[0];
    if(v[0] > 0)v[0] = -1;
    else v[0] = 1;
    x = min(x,f(v) + abs(xx) + 1);
    cout << x << "\n"; 
  }
  return 0;
}

Measured memory_bytes: 1804
#include <iostream>

using namespace std;

int main()
{
    // input
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;

    // range
    // r <= x <= W - r
    // r <= y <= H - r

    // desicion
    if ( (r <= x && x <= (W - r)) && (r <= y && y <= (H - r)) )
    {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}



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

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

	vector<int> ans;
	// 重ならない要素からなる集合をソートして取得
	set_symmetric_difference(begin(a),end(a),begin(b),end(b),inserter(ans, end(ans)));

	for(auto &&ai: ans){
		cout<<ai<<endl;
	}
  return 0;
}



Measured memory_bytes: 6504
#include<cstdio>
char s[200005],t[200005];
int l,d;
int main(){
	scanf("%s",s+1);
	scanf("%s",t+1);
	for(int i=1;i<=200005;i++){
		if(s[i]==0)break;
		if(s[i]!=t[i])d++;
	}
	printf("%d",d);
	return 0;
}

Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define ll long long
#define Arman_Sykot ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
 
using namespace std;

int main()
{
/*********************/
// Author:
        Arman_Sykot;
/*********************/
    
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	
	cout << max(max(a * c, a * d), max(b * c, b * d)) << "\n";
	
	return 0;
} 




Measured memory_bytes: 3704
from heapq import heappush, heappop
import queue
import re
import math
import functools

def s_raw():
    return input().rstrip("\r")

def int_raw():
    return int(input())


def ss_raw():
    return input().split()


def ints_raw():
    return list(map(int, ss_raw()))


INF = 1 << 29


def make1d_arr(n, val=INF):
    return [val for i in range(n)]


def make2d_arr(h, w, val=INF):
    return [[val for i in range(w)]for i in range(h)]


def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)


def BFord(n,es):
    v_cost = [INF]*n
    v_cost[0] = 0
    for v in range(n*2):
        for e in es:
            frm = e[0]
            to = e[1]
            if v_cost[to] > v_cost[frm]+e[2]:
                v_cost[to] = v_cost[frm]+e[2]
                if v >= n:
                    v_cost[to] = -INF
        if v == n-1:
            prev = v_cost[:]
    v_cost = [-INF if prev[idx]!=v_cost[idx] else v_cost[idx] for idx in range(n)]
    return v_cost
    
def ZAlgo(s):
    l = len(s)
    A = [0]*l
    i =1
    j =0
    A[0]=l
    while i<l:
        while i+j<l and s[j] == s[i+j]:
            j+=1
        if j==0:
            i+=1
            continue
        A[i]=j
        k=1
        while (i+k<l) and (k+A[k]<j):
            A[i+k] =A[k]
            k+=1
        i+=k
        j-=k
    return A


def main():
    n = int_raw()
    if n%2 ==0:
        return 0.5
    return (n//2+1)/n


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 39276
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

ll n;
ll dx[] = {-1,0,1,0};
ll dy[] = {0,1,0,-1};
vector<vector<ll>> vec(500,vector<ll>(500,0));
vector<vector<ll>> arr(500,vector<ll>(500,1));
void dfs(ll x,ll y,ll k){
  vec[x][y] = k;
  ll tx,ty;
  rep(i,4){
    tx = x + dx[i];
    ty = y + dy[i];
    if(0 <= tx && tx < n && 0 <= ty && ty < n && vec[tx][ty] > k+arr[x][y]){
      dfs(tx,ty,k+arr[x][y]);
    }
  }
}

int main(){
  cin >> n;

  rep(i,n){
    rep(j,n){
      t1 = min((ll)i,n-i-1);
      t2 = min((ll)j,n-j-1);
      vec[i][j] = min(t1,t2);
    }
  }
  ll ans = 0;
  ll x;
  rep(i,n){
    rep(j,n){
      cin >> x;
      x--;
      t1 = x / n;
      t2 = x % n;
      ans += vec[t1][t2];
      arr[t1][t2] = 0;
      dfs(t1,t2,vec[t1][t2]);
    }
  }
  cout << ans << endl;
}


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

const int N=100005;
const long long INF=0x3f3f3f3f3f3f3f3f;
int n,m;
long long w[N],v[N];
long long dp[N];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d%d",&w[i],&v[i]);
	for(int i=1;i<=n;i++)
	{
		for(int j=m;j>=w[i];j--)
		{
			dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
		}
	}
	printf("%lld\n",dp[m]);
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    lint N;
    cin >> N;
    vector<lint> A(N);
    rep(i, N) cin >> A[i];
    lint sum = 0;
    lint c   = 0;
    for (int i = 1; i < N; i++) {
        if (A[i - 1] > A[i]) {
            c += A[i - 1] - A[i];
            A[i] += A[i - 1] - A[i];
        }
    }
    cout << c << endl;

    return 0;
}

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

int gcd(int p, int q){
    if (p%q == 0) return q;
    return gcd(q, p%q);
}

int main(){
    int k, sum=0;
    cin >> k;
    for (int i=1; i<=k; i++){
        for (int j=1; j<=k; j++){
            int m = gcd(i, j);
            for (int l=1; l<=k; l++){
                sum += gcd(m, l);
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3600
import math
 
def check(x):
    k = 0
    global h, a, b
    for i in h:
        if x * b < i:
            k += math.ceil((i - x * b) / (a - b))
    return k <= x
 
 
n, a, b = map(int, input().split())
h = []
for i in range(n):
    h.append(int(input()))
l = -1
r = max(h) // b + 1
while r - l > 1:
    m = (l + r) // 2
    if check(m):
        r = m
    else:
        l = m
print(r)

Measured memory_bytes: 7120
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 2002;

int n, x, y, ans[maxn];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//5 2 4
    cin >> n >> x >> y;

    vector<vector<int> > g(n);
    g[x-1].push_back(y-1);
    g[y-1].push_back(x-1);

    for (int i = 0; i < n-1; ++i) {
        g[i].push_back(i+1);
        g[i+1].push_back(i);
    }

    for (int i = 0; i < n; ++i) {
        vector<int> dist(n, n);
        dist[i] = 0;

        queue<int> qu;
        qu.push(i);

        while (!qu.empty()) {
            int u = qu.front();
            qu.pop();

            for (int j = 0; j < g[u].size(); ++j) {
                int v = g[u][j];
                if (dist[v] > dist[u] + 1) {
                    dist[v] = dist[u] + 1;
                    qu.push(v);
                }
            }
        }

        for (int j = 0; j < n; ++j)
            ++ans[dist[j]];
    }

    for (int i = 1; i < n; ++i)
        cout << ans[i]/2 << endl;
	return 0;
}

Measured memory_bytes: 384
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

near = 1000
for i in range(len(H)):
    temp = T-H[i]*0.006
    if abs(temp-A) < near:
        ans = i+1
        near = abs(temp-A)

print(ans)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(Scanner sc = new Scanner(System.in)){
			final long N = sc.nextLong();
			final long M = sc.nextInt();
			
			if(N == 1 && M == 1){
				System.out.println(1);
			}else if(Math.min(N, M) == 1){
				System.out.println(N * M - 2);
			}else if(Math.min(N, M) == 2){
				System.out.println(0);
			}else{
				System.out.println((N - 2) * (M - 2));
			}
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 20564
#include<bits/stdc++.h> 
using namespace std;
typedef long long int ll;
#define MOD 1000000007
#define fo(i,k,n) for(i=k;i<=n;i++)
#define endl '\n'
ll dp[101][100001];
ll knapsnack(ll* w,ll* v,ll n,ll mw){
	if(dp[n][mw]>-1) return dp[n][mw];
	if(n==0) return 0;//no item left
	if(mw==0) return 0;//no more capacity
	ll op1 = knapsnack(w,v,n-1,mw);
	ll op2 = LLONG_MIN;
	if(w[n-1]<=mw) op2 = v[n-1]+knapsnack(w,v,n-1,mw-w[n-1]);
	return dp[n][mw]=max(op1,op2);
}
void solve(){
	ll i,j,n,mw;
	cin>>n>>mw;
	ll* w = new ll[n];
	ll* v = new ll[n];
	fo(i,0,n-1){
		cin>>w[i]>>v[i];
	}
	memset(dp,-1,sizeof(dp));
	cout<<knapsnack(w,v,n,mw)<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll t;
	t=1;//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 79232
#include<iostream>
#define Max 9
using namespace std;
int main(void){
  int c(0);
  for(int i(0);i<Max;i++){
    char a;
    cin>>a;
    if(c==0 || c==4 || c==8)cout<<a;
    c++;
  }
  return 0;
}

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

int main() {
    string S;
    cin>>S;
    int N = S.size();
    int left = (N-1)/2; 
    int right = (N+3)/2; 
    string judge = "Yes";
    REP(i, 0, N){
        if(S[i] != S[N-1-i]) judge = "No";
    }
    REP(i, 0, left){
        if(S[i] != S[left-1-i]) judge = "No";
    }
    cout << judge << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string.h>
#define INF 100000000
using namespace std;
int d[1000][1000];
int V; 


void warshall_floyd(){
  for(int i = 0 ; i <= V ; i++ )d[i][i] = 0;

  for(int k = 0 ; k <= V ; k++){
    for(int i = 0 ; i <= V ; i++){
      for(int j = 0 ; j <= V ; j++ ){
	d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
      }
    }
  }
}


int main(){
  int n;
  while( cin >> n,n){
     V = 0;
    for(int i = 0 ; i < 1000 ; i++){
      for(int j = 0 ; j < 1000 ; j++){
	d[i][j] = INF;
      }
    }
    for(int i = 0 ; i < n ; i++){
      int a,b,c;
      cin >> a >> b >> c;
      d[a][b] = c;
      d[b][a] = c;
      if(a > V )V = a;
      if(b > V )V = b;
    }

    warshall_floyd();

    int ans = INF,ansi;
    for(int i = 0 ; i <= V ; i++){
      int sum = 0;
      for(int j = 0 ; j <= V ; j++){
	sum+=d[i][j];
      }
	if(sum < ans){
	  ans = sum;
	  ansi = i;
	}
    }
    cout << ansi << " " << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 5064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

vector<vector<int>> G;
vector<int> cnt;
vector<int> res;

void dfs(int u,int p,int ans){
	if(cnt[u] > 0) ans += cnt[u];
	res[u] = ans;
	for(int v : G[u]){
		if(v == p) continue;
		dfs(v,u,ans);
	}
}

int main(){
	int N,Q; cin >> N >> Q;
	G.resize(N);
	cnt.resize(N);
	res.resize(N);
	rep(i,N-1){
		int a,b; cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<Pi> px(Q);
	rep(i,Q){
		cin >> px[i].first >> px[i].second;
		px[i].first--;
		cnt[px[i].first] += px[i].second;
	}

	dfs(0,0,0);

	rep(i,N){
		cout << res[i];
		if(i != N-1) cout << " ";
	}
	cout << endl;
    
}
   


Measured memory_bytes: 25892
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int f(int x, bool f) {
	int ret = 0;
	if(f) x *= 2;
	while(x) {
		ret += (x % 10);
		x /= 10;
	}
	return ret;
}

vector<int> id, a;
int n, m;
int cnt = 0;

void dfs(int i, int res) {
	if(i == id.size()) {
		if(res % 10 == 0) {
			cnt++;
		}
		return;
	}

	rep(j, m) {
		if((n - id[i]) % 2 == 0) {
			dfs(i + 1, res + f(a[j], true));
		} else {
			dfs(i + 1, res + f(a[j], false));
		}
	}
}

int main() {
	cin >> n;

	string s;
	cin >> s;

	cin >> m;

	a.resize(m);
	rep(i, m) cin >> a[i];
	sort(a.begin(), a.end());

	int sum = 0;
	rep(i, n) {
		if(s[i] =='*') {
			id.push_back(i);
		} else {
			if((n - i) % 2 == 0) {
				sum += f(s[i] - '0', true);
			} else {
				sum += f(s[i] - '0' , false);
			}
		}
	}

	cnt = 0;
	dfs(0, sum);

	cout << cnt << endl;

	return 0;
}

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

#define f first
#define s second
#define p pair<int,int>
#define P pair<ll,ll>
#define pb push_back
#define ll long long
#define db double
#define zero(a) memset(a,0,sizeof(a))
#define inff(a,n) fill(a,a+n+1,inf)
#define all(a) a.begin(),a.end()
#define sz(a) int((a).size())
#define read(x) scanf("%lld",&x)
#define read2(x,y) scanf("%lld%lld",&x,&y)
#define write(x) printf("%lld\n",x)
#define lson k*2,l,mid
#define rson k*2+1,mid+1,r

const int maxn=505;
const ll inf=1e16;

ll n,m,k,q,a[maxn],b[maxn],ok,flag,sum,ans1,ans2,ans;
string s,t,s1,s2;

int main()
{
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='9')flag=1;
    }
    if(flag)cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        a: i64, b: i64, c: i64, d: i64,
    }
    let ans = vec![a * c, a * d, b * c, b * d].into_iter().max().unwrap();
    println!("{}", ans);
}


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

int main() {
	long long A, B, a, b, c = 0; scanf("%lld%lld", &A, &B);
	a = A; b = B;
	while(1) {
		if(A < 2 && B < 2) break;
		if(A < B) swap(A, B);
		long long D = A >> 1;
		A -= D*2; B += D;
		c += D;
	}
	a += c; b += c;
	a /= 3; b /= 3;
	puts(a^b ? "Alice" : "Brown");
	return 0;
}

Measured memory_bytes: 256
/// d.cpp

# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < __typeof(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("YES")
# define no puts("NO")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < pll >
# define pb push_back
# define pdd pair < db , db >
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)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n;
    fi>>n;
    vi a(n),b(n);
    int xa = 0,xb = 0;
    for (int i = 0;i < n;++i)
        fi>>a[i],xa ^= a[i];
    for (int i = 0;i < n;++i)
        fi>>b[i],xb ^= b[i];
    a.pb(xa);b.pb(xb);
    if (multiset < int > (a.begin(),a.end()) != multiset < int > (b.begin(),b.end()))
        return fail * 0;
    vi ss = a;
    sort(ss.begin(),ss.end());
    ss.resize(unique(ss.begin(),ss.end()) - ss.begin());
    if (a == b)
        return puts("0") * 0;
    for (auto & it : a)
        it = lower_bound(ss.begin(),ss.end(),it) - ss.begin() + 1;
    for (auto & it : b)
        it = lower_bound(ss.begin(),ss.end(),it) - ss.begin() + 1;
    static int f[1 << 20];
    ++n;
    for (int i = 1;i <= n;++i)
        f[i] = i;
    function < int(int) > get = [&](int k)
    {
        return k == f[k] ? k : f[k] = get(f[k]);
    };
    vii e;
    for (int i = 0;i < n;++i)
        if (a[i] != b[i] || i == n - 1)
            e.pb(mp(a[i],b[i]));
    for (auto it : e)
        f[get(it.x)] = get(it.y);
    set < int > S;
    for (auto it : e)
        S.insert(get(it.x)),S.insert(get(it.y));
    fo << (e.size() - 1 + S.size() - 1) << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


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

int main(){
  int a, b;
  cin >> a >> b;
  cout << max(a + b, max(a - b, a * b)) << endl;  
  return 0;
} 


Measured memory_bytes: 256
<?php
$fp = fopen("php://stdin", "r");
$container=array();
$n=10;
while($n>0){
    $h=trim(fgets($fp));
    array_push($container,$h);
    $n--;
}
rsort($container);
echo $container[0]."\n";
echo $container[1]."\n";
echo $container[2]."\n";

Measured memory_bytes: 6556
/*input
4 150
150 140 100 200
*/
#include <iostream>
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);	
	cin.tie(0);
	cout.tie(0);
 	int n,k,count = 0,x;
 	cin>>n>>k;
 	while(n--){
 		cin>>x;
 		if(x>=k) count++;
 	}
 	cout<<count;
	return 0;
}


Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const Arr = (input.trim()).split("\n");
const N1 = Number(Arr[0]);
const arr1 = Arr[1].split(" ").map(Number);
const arr2 = Arr[3].split(" ").map(Number);
console.log(arr2.map(key => {   
  let mid;
  let left = 0;
  let right = N1;
  if (key < arr1[0] || arr1[N1-1] < key) return 0;
  while (left < right) {
    mid = Math.floor((left + right) / 2);
    if (key < arr1[mid]) right = mid;
    else if (key > arr1[mid]) left = mid + 1;
    else return 1;
  }
  return 0;
}).reduce((a, b) => a + b));



Measured memory_bytes: 34944
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	double n,m,d;
	cin>>n>>m>>d;
	fcout(10)<<(d==0?n:(max(n-d,0.0))*2)*(m-1)/n/n<<endl;
	return 0;
}


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

int64_t C(int64_t x){
  int64_t ret=(x*(x-1))/2;
  return ret;
}
int main(){
  int N; cin >> N;
  vector<char> a(10);
  vector<string> b(N);
  string k="abcdefghij";
  for(int i=0;i<N;i++){
    for(int j=0;j<10;j++){
      cin >> a.at(j);
    }
    sort(a.begin(),a.end());
    for(int l=0;l<10;l++){
      k.at(l)=a.at(l);
    }
    b.at(i)=k;
  }
  sort(b.begin(),b.end());
  int64_t ans=0;
  int64_t count=1;
  b.push_back("a");
  for(int i=1;i<=N;i++){
    if(b[i]==b[i-1]){
      count++;
    }
    if(b[i]!=b[i-1]){
      ans+=C(count);
      count=1;
    }
  }
  cout << ans << endl;
}
    

Measured memory_bytes: 7808
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;
#define ll long long 
int main()
{
  ll n,k; cin>>n>>k;
  ll a[n];
  for(int i=0;i<n;++i)cin>>a[i];
  sort(a,a+n);
ll ans=0;
for(int i=0;i<k;++i)ans+=a[i];
cout<<ans;
  return 0;
}

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

using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;


int main() {
    ll N = 0;
    cin >> N;
    vector<ll> A(N,0);
    ll sum = 0;
    for(ll i = 0; i < N; i++) {
        cin >> A.at(i);
        sum += A.at(i);
    }
    ll ans = 0;

    for(ll i = 0; i < N; i++) {
        ans += (((sum - A.at(i))%MOD)*A.at(i))%MOD;
        ans %= MOD;
    }
    
    if(ans%2) {
        cout << (ans + MOD)/2 << endl;
    } else {
        cout << ans/2 << endl;
    }



    return 0;
}

Measured memory_bytes: 4844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int m = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			if (m == -1 && f == -1 && r == -1) {
				break;
			}
			if (m == -1 || f == -1) {
				System.out.println("F");
			} else if (m + f >= 80) {
				System.out.println("A");
			} else if (m + f >= 65 && 80 > m + f) {
				System.out.println("B");
			} else if (m + f >= 50 && 65 > m + f) {
				System.out.println("C");
			} else if (m + f >= 30 && 50 > m + f && 50 > r) {
				System.out.println("D");
			}else if (m + f >= 30 && 50 > m + f && r >= 50) {
					System.out.println("C");
			} else if (30 > m + f) {
				System.out.println("F");
			}
		}
	}
}


Measured memory_bytes: 26288
#include <bits/stdc++.h>
#define ll long long  
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n;
  cin>>n;
  int a[100005];
  for(int i=0;i<100005;i++) a[i]=-1;
  for(int i=0;i<n;i++){
      int x;
     cin>>x;
     a[x-1]=i+1;
    
  }
 for(int i=0;i<n;i++) cout<<a[i]<<" ";
  cout<<endl;
  return 0;
}


Measured memory_bytes: 1280
/*Shivam Bhalla */
  /* f2016941@pilani.bits-pilani.ac.in */



  #include <iostream>
  #include <cstdio>
  #include <cstring>
  #include <cstdlib>
  #include <cctype>
  #include <algorithm>
  #include <map>
  #include <vector>
  #include <list>
  #include <set>
  #include <queue>
  #include <deque>
  #include <stack>
  #include <iostream>
  #include <string>
  #include <cmath>
  #include <cassert>
  #include <bits/stdc++.h>
  #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
  using namespace std;
  long long maxv = 1e9;


  int main()
  {
      int N;
      cin>>N;
      if(N<=81){
            for(int i=1;i<=9;i++){
                for(int j=1;j<=9;j++){
                    if(i*j == N){
                        cout<<"Yes";
                        return 0;
                    }
                }
            }
            cout<<"No";
            return 0;
      }
      else
        cout<<"No";
      return 0;
  }


Measured memory_bytes: 256
#include<stdio.h>

typedef long long ll;

int main (void)
{
  ll nums[500];
  ll num = 0;
  int n = 0;
  int flag = 0;
  char c[1000] = {'\0'};
  int i;
  fgets(c, 1000, stdin);
  for (i = 0; c[i] != '\n' && c[i] != '\0'; i++) {
    if (c[i] == ' ') {
      if (flag == 1) {
	nums[n] = num;
	n++;
	num = 0;
	flag = 0;
      }
      continue;
    }
 
    switch(c[i]) {
    case '+': {
      nums[n-2] = nums[n-2] + nums[n-1];
      n--;
      num = 0;
      break;
    }
    case '*': {
      nums[n-2] = nums[n-2] * nums[n-1];
      n--;
      num = 0;
      break;
    }
    case '-': {
      nums[n-2] = nums[n-2] - nums[n-1];
      n--;
      num = 0;
      break;
    }
    default: {
      flag = 1;
      num *= 10;
      num += c[i] - '0';
      break;
    }
    }
  }
  printf("%lld\n", nums[0]);
  return 0;
}

Measured memory_bytes: 524
a = gets.to_i
ac = 0
tle = 0
wa = 0
re = 0
a.times do |n|
  ab= gets.chomp
  if ab =="AC"
      ac +=1
  elsif ab =="TLE"
      tle +=1
  elsif ab =="WA"
      wa +=1
  else
      re+=1
  end
end
puts "AC x #{ac}"
puts "WA x #{wa}"
puts "TLE x #{tle}"
puts "RE x #{re}"

Measured memory_bytes: 14224
#include <stdio.h>
int main(){
    int a,b,c,d,i,sum=0;
    scanf("%d",&a);
    for(i=1;i<=a;i++){
    scanf("%d%d",&c,&d);
    b=d-c+1;
    sum=sum+b;
    }
    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 128
N,K=gets.split.map(&:to_i)
S=gets.chomp

region=Array.new
old=""
temp=0
sum=0
max=0

S.each_char do |char|
    if old==char
        temp+=1
    elsif char=="1"
        sum+=temp
        region.push(temp)
        old=char
        temp=1
    elsif char=="0"
        sum+=temp
        max=sum if sum>max
        region.push(temp)
        sum-=region.shift if region.length>2*K-1
        sum-=region.shift if region.length>2*K-1
        old=char
        temp=1
    end
end

sum+=temp
max=sum if sum>max

puts max


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

int main(){
	std::vector<int> A(4);
	std::vector<int> B(4);
	int a,b,c,d;
	while(std::cin>>a){
		A[0]=a;
		for(int i=1;i<4;++i)std::cin>>A[i];
		for(int i=0;i<4;++i)std::cin>>B[i];
		int hit=0,blow=0;
		for(int i=0;i<4;++i){
			for(int j=0;j<4;++j){
				if(A[i]==B[j]&&i==j)hit++;
				if(A[i]==B[j]&&i!=j)blow++;
			}
		}
		std::cout<<hit << " " << blow <<std::endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include <iostream>

int main() {
	long long int n, a, b; 
  	std::cin >> n >> a >> b;
	if ((b - a) % 2 == 0) {
		std::cout << (b - a) / 2 << std::endl;
	}
	else {
		auto min = std::min(a - 1, n - b);
		std::cout << min + (b - a + 1) / 2 << std::endl;
	}
}


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

int main(){
  int i,j;
  int H,W;
  int flg = 0;
  int a = 0;
  cin>>H>>W;
  char mass[52][52];
  for(i=1;i<=H;i++){
    for(j=1;j<=W;j++){
      cin>>mass[i][j];
    }
  }
  for(i=1;i<=H;i++){
    for(j=1;j<=W;j++){
      if(mass[i][j] == '#'){
        if(mass[i+1][j] == '#'){
          flg = 1;
        }else if(mass[i-1][j] == '#'){
          flg = 1;
        }else if(mass[i][j+1] == '#'){
          flg = 1;
        }else if(mass[i][j-1] == '#'){
          flg = 1;
        }else{
          a = 1;
          break;
        }
      }     
    }if(a == 1){
      break;
    }
  }

  if(a == 1){
    cout << "No";
  }else{
    cout << "Yes";
  }

  return 0;
}




Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll A, B, C;

int main() {
	scanf("%lld %lld %lld", &A, &B, &C);
	ll ans = B / A;
	ans = min(ans, C);
	printf("%lld\n", ans);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

using namespace std;

int main(){
  int a,b,c,t,g=0,r;
  vector<int> d;
  while(cin >> a >> b >> c,a){
    d.clear();g=0;
    for(int i=0;i<a;i++){
      cin >> t;
      d.push_back(t);
    }r=b;
    //for(int i=0;i<a;i++)cout << d[i] << endl;
    for(int i=b;i<=c;i++){
      // cout << d[i-1] << " " << d[i] << (d[i-1]-d[i]>=g) << endl;
      if((d[i-1]-d[i])>=g){
        g=d[i-1]-d[i];
        r=i;
      }
    }
    cout << r << endl;
  }
}

Measured memory_bytes: 3024
#include <stdio.h>

int main(){
  int i, j, n, S[100000], q, T[50000], c=0, left, right, middle;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d", &S[i]);
  }
  scanf("%d", &q);
  for(i=0;i<q;i++){
    scanf("%d", &T[i]);
  }
  for(i=0;i<q;i++){
    left=0;
    right=n;
    while(left<right){ 
      middle=(left+right)/2;
      if(S[middle]==T[i]){
	c++;
	break;
      }
      else if(S[middle]<T[i]){
	left=middle+1;
      }
      else if(T[i]<=S[middle]){
	right=middle;
      }
      else break;
    }
  }
  
  printf("%d\n", c);

  return 0;
}

Measured memory_bytes: 1184
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstring>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <memory.h>
using namespace std;
typedef long long ll;
typedef long double ldbl;

int c[11][11];
int dc[11];

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      scanf("%d", &c[i][j]);
    }
  }
  for (int k = 0; k < 10; k++) {
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int a;
      scanf("%d", &a);
      if (a >= 0) {
        dc[a]++;
      }
    }
  }

  ll ans = 0;
  for (int i = 0; i < 10; i++) {
    ans += 1ll * dc[i] * c[i][1];
  }
  printf("%lld", ans);

  return 0;
}

Measured memory_bytes: 256
#define NDEBUG

#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <utility>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <tuple>
#include <set>
#include <map>

// [0, max)
#define FOR0(var, max) for (sl (var) = 0; (var) < (max); ++(var))
// [min, max)
#define FORi(var, min, max) for (sl (var) = (min); (var) < (max); ++(var))
// [min, max)
#define FORi_INV(var, min, max) for (sl (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

// a < b < c
#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
// a <= b < c
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
// a < b <= c
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
// a <= b <= c
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

#ifndef NDEBUG
#  define MASSERT(cond) m_assert(cond, __LINE__, #cond);
#else
#  define MASSERT(...)
#endif

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

using ld = long double;

void m_assert(const bool& cond, const sl& line, const char *condstr) {
  if (!cond) {
    cerr << "Assertion Failed: " << condstr << " at line " << line << endl;
    exit(1);
  }
}

bool isprime(const sl& n) {
  if (n < 2 || n % 2 == 0) {
    return false;
  }
  for (sl i = 3; i * i < n; i += 2) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}

static sl X;

void solve(void) {
  if (X == 2) {
    cout << 2 << endl;
  } else {
    sl i = X;
    while (!isprime(i)) {
      i++;
    }
    cout << i << endl;
  }
}

int main(void) {
  cin >> X;
  solve();
  return 0;
}

Measured memory_bytes: 256
"""
Problem A: Sum of Consecutive Prime Numbers
https://onlinejudge.u-aizu.ac.jp/problems/1257
input : 2 < n < 10000

"""
def prime_list(n):
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1 ):
        if not is_prime[i]:
            continue
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

def subset_sum_problem(prime_list, length):

    subset_dict = {}
    for i in range(length):
        now = 0
        for j in range(i, length):
            now += prime_list[j]
            if not now in subset_dict:
                subset_dict[now] = 1
            else:
                subset_dict[now] = subset_dict[now] + 1

    return subset_dict

if __name__ == '__main__':
    prime_list = prime_list(10000)
    length = len(prime_list)
    subset_dict = subset_sum_problem(prime_list, length)
    ans = []
    while(True):
        n = int(input())
        if n == 0:
            break
        if not n in subset_dict:
            ans.append(0)
        else:
            ans.append(subset_dict[n])

    print(*ans, sep='\n')



Measured memory_bytes: 48056
using System;
using System.Linq;

namespace C___Alchemist
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var vi = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
            vi = vi.OrderBy(v => v).ToArray();
            double result = (vi[0] + vi[1]) / 2.0;
            for (int i = 2; i < N; i++) result = (result + vi[i]) / 2.0;
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13396
#include<stdio.h>

int isPrime[50000];
int a[100000];
void func(){
	for(int i = 0; i < 50000; i++)isPrime[i] = 1;
	isPrime[0] = 0;
	isPrime[1] = 0;
	
	for(int i = 4; i < 50000; i++){
		for(int j = 2; j*j <= i; j++){
			if(i % j == 0){
				isPrime[i] = 0;
				break;
			}
		}
	}
	
	for(int i = 0; i < 50000; i++){
		for(int j = i; j < 50000; j++){
			if(isPrime[i]&&isPrime[j])a[i+j]++;
		}
	}
}


int x;
int main(void){
	
	int n;
	func();
	while(scanf("%d", &n),n){
		printf("%d\n", a[n]);
	}
}

Measured memory_bytes: 1612
s = int(raw_input())
flag = 1
L = [s]
val = s
while flag == 1:
    if val % 2 == 0:
        val /= 2
        val = int(val)
        # print(val)
    else:
        val = val*3 + 1
        # print(val)
    if val in L:
        flag = 0
        point = len(L) + 1
        val = int(val)
        print(point)
    L.append(val)
# print(L)



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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=21;

int main(){
    
    string K;cin>>K;
    int D;cin>>D;
    ll dp[2][K.size()+1][D];//1個目=0のときは確実にK以下、=1のときはわからん 2個目は上から何桁(1スタート) 3個目はあまり(0~D-1)
    for(int i=0;i<2;i++){
        for(int j=0;j<K.size()+1;j++){
            for(int k=0;k<D;k++){
                dp[i][j][k]=0;
            }
        }
    }
    dp[1][0][0]=1;
    
    for(int j=0;j<K.size();j++){
        for(int k=0;k<D;k++){
            for(int l=0;l<10;l++){
                dp[0][j+1][(k+l)%D]=(dp[0][j+1][(k+l)%D]+dp[0][j][k])%mod;
            }
        }
        for(int k=0;k<D;k++){
            for(int l=0;l<K[j]-'0';l++){
                dp[0][j+1][(k+l)%D]=(dp[0][j+1][(k+l)%D]+dp[1][j][k])%mod;
            }
            dp[1][j+1][(k+(K[j]-'0'))%D]=(dp[1][j+1][(k+(K[j]-'0'))%D]+dp[1][j][k])%mod;
        }
    }
    cout<<(dp[0][K.size()][0]+dp[1][K.size()][0]+mod-1)%mod<<endl;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch RoadToMillionaire | diff RoadToMillionaire.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address RoadToMillionaire.cpp && ./a.out

/*

 7/25/2020

 5:22-

 */

const int MAX_N=100+1;
LL A[MAX_N];
int N;

void solve() {
  LL mon=1000;
  REP(i,N-1) {
    if(A[i]<A[i+1]) {
      LL cnt=mon/A[i]; mon-=A[i]*cnt;
      mon+=A[i+1]*cnt;
      //dump(i,cnt,A[i],A[i+1],mon);
    }
  }
  cout<<mon<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>N;
  REP(i,N) cin>>A[i];
  solve();

  return 0;
}


Measured memory_bytes: 3640