akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    double t = sc.nextDouble();
    double a = sc.nextDouble();
    int[] h = sc.nextIntArray(n);
    double min = Double.MAX_VALUE;
    int index = -1;
    for (int i = 0; i < n; i++) {
      double temp = t - (double) h[i] * 0.006;
      if (Math.abs(temp - a) < min) {
        min = Math.abs(temp - a);
        index = i + 1;
      }
    }
    System.out.println(index);
  }
}

Measured memory_bytes: 23124
n = input().split()
stack = []
for i in range(len(n)):
    if n[i] not in ("+","-","*","/"):
        stack.append(int(n[i]))
    else:
        if n[i] == "+":
            stack.append(stack.pop()+stack.pop()) 
        elif n[i] == "-":
            a = stack.pop()
            stack.append( stack.pop() - a) 
        elif n[i] == "*":
            stack.append(stack.pop()*stack.pop()) 
        elif n[i] == "/":
            a = stack.pop()
            stack.append( stack.pop() / a) 
print(stack[0])
        
    

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

#define pb push_back

int X[100005], W[100005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, M;
    cin >> N >> M;
    if (N >= M)
    {
        cout << "0\n";
        return(0);
    }
    for (int i = 0; i < M; i++) cin >> X[i];
    sort(X, X + M);
    for (int i = 1; i < M; i++) W[i - 1] = X[i] - X[i - 1];
    sort(W, W + M - 1);
    int res = 0;
    for (int i = 0; i < M - N; i++) res += W[i];
    cout << res << '\n';
    return(0);
}

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

struct edge{
	int nxt,to;
}e[200005];
int n,m,c1,c2,ft[100005],c[100005];
long long ans;
bool v[100005],f;
void dfs(int x){
	v[x]=1;
	if(c[x]==1)c1++;else c2++;
	for(int i=ft[x];i;i=e[i].nxt)if(!c[e[i].to]){
		c[e[i].to]=3-c[x];
		dfs(e[i].to);
	}else if(c[e[i].to]==c[x])f=0;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int a,b;scanf("%d%d",&a,&b);
		e[i<<1]=(edge){ft[a],b};ft[a]=i<<1;
		e[i<<1|1]=(edge){ft[b],a};ft[b]=i<<1|1;
	}
	for(int i=1;i<=n;i++)if(!v[i]){
		c[i]=1;f=1;c1=c2=0;
		dfs(i);
		if(f)ans+=1ll*c1*c2;else ans+=1ll*(c1+c2)*(c1+c2-1)/2;
	}
	printf("%lld\n",ans-m);
	return 0;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a + b + c >= 22){
        cout << "bust" << endl;
        return 0;
    }
    cout << "win" << endl;
}


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

#define int long long

int32_t main()
{
	double n, r;
	cin >> n >> r;
	
	if (n == 1)
		cout << 1 << endl;
	else
		cout << ceil(log(n) / log(r)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
vector<int> v[26];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int n = S.length();
    rep(i, 26) v[i].push_back(-1);
    rep(i, n) {
        v[S[i] - 'a'].push_back(i);
    }
    rep(i, 26) v[i].push_back(n);
    int ans = n;
    rep(i, 26) {
        int tmp = 0;
        rep(j, (int)v[i].size() - 1) {
            tmp = max(tmp, v[i][j + 1] - v[i][j]);
        }
        ans = min(ans, tmp);
    }
    cout << ans - 1 << endl;

    return 0;
}
// 10203456789

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

void PrintAns(bool* flags);

int main() {
  std::string S;
  std::cin >> S;

  // 字符串 S 必须满足如下三个条件:
  //   1. 第一个字符必须是 'A'
  //   2. 在 S 中只出现一次 'C', 且他必须是在第三个与倒数第二个字符之间
  //   3. 所有除了 'A' 和 'C' 之外的字符必须都是小写.
  //   如果满足所有条件, 打印 "AC"; 否则, 打印 "WA"
  bool flags[3] = {true, true, true};

  // [TEST 1.]
  if (S[0] != 'A') {
    puts("WA");
    return 0;
  }

  // [TEST 2.]
  if (S[1] == 'C' || S.back() == 'C') {
    puts("WA");
    return 0;
  }
  int count_c = 0;
  for (int i = 2; i < S.length() - 1; i++)
    if (S[i] == 'C') count_c++;
  if (count_c != 1) {
    puts("WA");
    return 0;
  }

  // [TEST 3.]
  bool flag = true;
  for (int i = 0; i < S.length(); i++) {
    if (i == 0 || S[i] == 'C') continue;  // Exclude TEST1 && TEST2
    if (S[i] >= 'a' && S[i] <= 'z')
      ;
    else {
      flag = false;
      break;
    }
  }
  if (flag)
    puts("AC");
  else
    puts("WA");

  return 0;
}


Measured memory_bytes: 256
import numpy as np
import math
n,d=map(int,input().split())
count=0
x=[list(map(int,input().split())) for i in range(n)]
for i in range(n):
    for j in range(n):
        x[i]=np.array(x[i])
        x[j]=np.array(x[j])
        l=np.linalg.norm(x[j]-x[i])
        if l.is_integer()==True and i!=j and i<j:
            count+=1
print(count)

Measured memory_bytes: 12488
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    int memo=0;
    rep(i, n)
    {
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    rep(i, n)
    {
        if (i == 0)
        {
            memo++;
        }
        else if (s[i] == s[i - 1])
        {
            continue;
        }
        else
        {
            memo++;
        }
    }
    cout << memo << endl;
}

Measured memory_bytes: 9536
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> x(n + 1), y(n + 1);
    for(int i = 1; i <= n; i++) {
        cin >> x[i] >> y[i];
    }
    ll max_d2 = 0;
    for(int dx : {-1, 1}) {
        for(int dy : {-1, 1}) {
            vector<pair<ll, ll>> pts = {{0, 0}};
            for(int i = 1; i <= n; i++) {
                int sz = pts.size();
                for(int j = 0; j < sz; j++) {
                    ll nx = pts[j].first + x[i] * dx, ny = pts[j].second + y[i] * dy;
                    max_d2 = max(max_d2, nx * nx + ny * ny);
                    pts.push_back({nx, ny});
                }
                sort(pts.begin(), pts.end());
                vector<pair<ll, ll>> new_pts;
                for(auto& p : pts) {
                    while(not new_pts.empty() and new_pts.back().second <= p.second) {
                        new_pts.pop_back();
                    }
                    new_pts.push_back(p);
                }
                new_pts.swap(pts);
            }
        }
    }
    cout << fixed << setprecision(10) << sqrtl(max_d2) << endl;
    return 0;
}


Measured memory_bytes: 8476
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

//range minimum query
template<typename T>
struct segtree {
    T INF = ((ll)1 << 31) - 1;
    int n;
    vector<T> dat;
 
    void init(int n_) {
        n = 1;
        while (n < n_) {
            n *= 2;
        }
        dat.assign(2 * n - 1, INF);
    }
 
    void update(int k, T a) {
        k += n - 1;
        dat[k] = a;
        while (k > 0) {
            k = (k - 1) / 2;
            dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
 
    T basequery(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) {
            return INF;
        }
        if (a <= l && r <= b) {
            return dat[k];
        } else {
            T vl = basequery(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = basequery(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }

    //[l, r)の範囲の最小値を返す
    T query(int l, int r) {
        return basequery(l, r, 0, 0, n);
    }
};

int main() {
    ll n, q;
    cin >> n >> q;
    segtree<ll> seg;
    seg.init(n);
    REP(i, 0, q) {
        ll com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            seg.update(x, y);
        } else {
            cout << seg.query(x, y + 1) << endl;
        }
    }
}



Measured memory_bytes: 4956
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const long long mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

ll powMod(ll n, ll k, ll m) {
	if (k == 0) {
		return 1;
	} else if (k % 2 == 1) {
		return powMod(n, k - 1, m) * n % m;
	} else {
		ll t = powMod(n, k / 2, m);
		return t * t % m;
	}
}

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

	ll ans=(n+1)/2;
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    double l;
    cin>>l;
    double a=l/3;
    cout<<a*a*a<<endl;


}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    solve();


    return 0;
}

Measured memory_bytes: 3764
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    val S = next().toCharArray()
    val A = IntArray(N)
    val B = IntArray(N)
    for (i in 1 until N) {
        A[i] = A[i - 1]
        if (S[i - 1] == 'W') A[i]++
    }
    for (i in N - 2 downTo 0) {
        B[i] = B[i + 1]
        if (S[i + 1] == 'E') B[i]++
    }
    println(A.zip(B).map { it.first + it.second }.min())
}

Measured memory_bytes: 88712
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int ans = 0;
        for(int i = 0; i < n; i++){
            int x = sc.nextInt();
            ans += 2 * Math.min(Math.abs(x),Math.abs(k-x));
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <map> #include <algorithm> #include <vector> #include <string.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <chrono> #include <thread> #include <iomanip>

using namespace std;

#define endl "\n"
#define rep(i,a,b) for(int i=a; i<b; ++i)
#define re(i,a) for(int i=0; i<a; ++i)
#define tr(i,v) for(auto &i: v)
#define mem(a,val) memset(a,val,sizeof(a))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define in(v,n) vi v(n);re(i,n) cin>>v[i]
#define printVec(v,s) cout << s; tr(i, v) cout << i << " ";
#define sz(a) int((a).size())
#define dbgv(c, v) cout << c << " = " << v << endl;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef vector< pii > vii;
typedef vector< ll > vll;
typedef complex<double> point;

const long long MOD = 1000000007;
const long long inf = 1e18;

void solve(){
	
}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif 
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cin.exceptions(cin.failbit);
    // int t;cin>>t;
    // while(t--){
    // 	solve();
    // }
    string s;
    cin>>s;
    if(s[1] == 'B') cout << "ARC";
    else cout << "ABC"; 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 3792
#include<stdio.h>
int main(){
  int n,x;
  while(1){
    scanf("%d%d",&n,&x);
    if(n==0 && x==0){break;}
    int i,j,k,count=0;
    for(i=1;i<=n;i++){
      for(j=i+1;j<=n;j++){
	for(k=j+1;k<=n;k++){
	  if(i+j+k==x){
	    count++;
	  }
	}
      }
    }
    printf("%d\n",count);
  }
  return 0;
}



Measured memory_bytes: 2688
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<String> lines = new ArrayList<String>();
		while (br.ready()){
			lines.add(br.readLine());
		}
		String[] tmp = lines.get(0).split(" ");
		int[] num = new int[tmp.length];
		for(int i=0; i<tmp.length; i++){
			num[i] = Integer.parseInt(tmp[i]);
		}
		System.out.println(gcd(num[0],num[1]));

	}
	static int gcd(int x, int y){
		if (x%y ==0)
			return y;
		return gcd(y, x%y);
	}

}

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

int main()
{
    int n,k,kei=0,tmp;
    scanf("%d %d",&n,&k);
    int *box = malloc(sizeof(int)*n);
    for(int i=0;i<n;i++){
        scanf("%d",&tmp);
        kei += tmp;
        box[i]=tmp;
    }
    int lf=1,rh=kei,st,cnt,x,flg;
    st = (lf+rh)/2;
    //fprintf(stderr,"chk1");
    while(1)
    {
        //printf("lf=%d,rh=%d\n",lf,rh);
        //printf("st=%d\n",st);
        x = st;
        flg = 0;
        cnt = 0;
        for(int i=0;i<n;i++)
        {
            //printf("iの数%d\n",i);
            if(x<box[i])
            {
                //printf("cnt++\n");
                cnt++;
                x = st;
                if(st < box[i]){
                    flg = 1;
                    break;
                }
                else x -= box[i];
            }else
            {
                //printf("not cnt++\n");
                x -= box[i];
            }
            //printf("x=%d\n",x);
            if(cnt == k){
                flg = 1;
                //printf("nuke\n");
                break;
            }
        }
        if(lf == rh) break;
        else {
            if(flg==1){
                lf = st+1;
            }else {
                rh = st;
            }
        }
        st = (rh+lf)/2;
    //fprintf(stderr,"while chk end");
    }
    printf("%d\n",rh);
}


Measured memory_bytes: 2200
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
using ll = long long;
const ll INF = LLONG_MAX - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;

class fact {
public:
	int fmod = 1e9+7;
	vector<int> fac, inv;
	fact (int n, int Mod = 1e9+7) {
		fmod = Mod;
		fac = vector<int>(n,0);
		inv = vector<int>(n,0);
		fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
		for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
	}
	ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
	ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}

bool solve() {
	mod = 1000003;
	fact f(2*mod+114,mod);
	int q; cin >> q;
	REP (i,q) {
		int x,d,n; cin >> x >> d >> n;
		if (d % mod == 0) {
			cout << POW(x,n) << endl;
			continue;
		}
		if (n >= mod || x % mod == 0) {
			cout << 0 << endl;
			continue;
		}
		//fac[x/d+(n-1)] / fac[x/d-1] * d^n;
		int xd = x*POW(d,mod-2)%mod;
		int tmp = f.fac[xd+n-1] * f.inv[xd-1] % mod * POW(d,n) % mod;
		cout << tmp << endl;
	}
}

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

Measured memory_bytes: 32128
import scala.io.StdIn

object Main extends App {
  val s =  StdIn.readLine()

  def solve(s: String): Long = {
    var ret :Long = s.toLong

    (1 to s.length - 1).foreach {i =>

      (1 to s.length - 1).combinations(i).foreach {j =>

        if (j.isEmpty)
          ret += s.toInt

        (0 to j.length).foreach { k =>
          if (k == 0) {
            ret = ret + s.substring(0, j(k)).toInt
          } else if (k == j.length) {
            ret = ret + s.substring(j(k - 1)).toInt
          } else {
            ret = ret +  s.substring(j(k - 1), j(k)).toInt
          }
        }
      }
    }
    ret
  }

  println(solve(s))
}
  



Measured memory_bytes: 25536
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll, ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // Emily <3
  int n;
  cin>> n;
  vector<int> balls(n);
  for (int i = 0; i <n; i++) {
      cin >> balls[i];
  }
  sort(balls.begin(), balls.end());
  int x = balls[n-1];
  int y = balls[0];
  vector<pii> ops;
  for (int i = 1; i<n-1; i++) {
      if (balls[i] < 0) {
          ops.push_back({x, balls[i]});
          x = x - balls[i];
      } else {
          ops.push_back({y, balls[i]});
          y = y - balls[i];
      }
  }
  cout << x - y << endl;
  for (pii o: ops) {
      cout << o.ff <<" " << o.ss << endl;
  }
  cout << x << " " << y << endl;
  
  return 0;
}

Measured memory_bytes: 3188
import java.util.*;
import static java.lang.System.*;
import java.math.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[] list = new double[n];
		for(int i = 0; i < n; i++)
			list[i] = sc.nextDouble();
		
		double sum = 0;
		for(int i = 0; i < n; i++) {
			double d = 1.0 / list[i];
			sum += d;
		}
		double ans = 1.0 / sum;
		out.println(ans);
	}
}

Measured memory_bytes: 23124
import cmath
def f():
 global d
 p=[]
 for i in range(len(d)-1):
  a,b=d[i],d[i+1]
  r=(b-a)/3
  p+=[a,a+r,a+r+r*cmath.rect(1,cmath.pi/3),b-r]
 d=p+[d[-1]]
d=[0j,100+0j]
for _ in[0]*int(input()):f()
for e in d:print(e.real,e.imag)


Measured memory_bytes: 5996
#include <iostream>
#include <queue>
#include <utility>
#define MAX_H   1200
#define MAX_W   1200
#define MAX_N   10
using namespace std;

const int INF = 100000000;
typedef pair<int, int> P;

char maze[MAX_H][MAX_W];
int H, W, N;
int sx, sy;                     // スタートの座標
int gx[MAX_N], gy[MAX_N];       // ゴールの座標

int d[MAX_H][MAX_W];            // 各点までの最短距離の配列

// 移動４方向のベクトル
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int bfs(int s1, int s2, int g1, int g2) {
  queue<P> que;
  // すべての点をINFで初期化
  for (int i = 0; i < MAX_H; i++) {
    for (int j = 0; j < MAX_W; j++) {
      d[i][j] = INF;
    }
  }
  // スタート地点をqueに入れ、その点の距離を0にする
  que.push(P(s1, s2));
  d[s1][s2] = 0;

  // queが空になるまでループ
  while (!que.empty()) {
    // キューの先頭を取り出す
    P p = que.front();
    que.pop();
    // 取り出してきた状態がゴールならば、探索をやめる
    if (p.first == g1 && p.second == g2) {
      break;
    }
    // 移動４方向をループ
    for (int i = 0; i < 4; i++) {
      // 移動したあとの点を(nx, ny)とする
      int nx = p.first + dx[i], ny = p.second + dy[i];

      // 移動が可能かどうかとすでに訪れたことがあるか判定
      if (0 <= nx && nx < H && 0 <= ny && ny < W && maze[nx][ny] != 'X'
          && d[nx][ny] == INF) {
        que.push(P(nx, ny));
        d[nx][ny] = d[p.first][p.second] + 1;
      }
    }
  }
  return d[g1][g2];
}

int main(void) {
  int res = 0;
  cin >> H >> W >> N;

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> maze[i][j];
      if (maze[i][j] == 'S') {
        sx = i;
        sy = j;
      }
      if (isdigit(maze[i][j])) {
        gx[maze[i][j] - '0'] = i;
        gy[maze[i][j] - '0'] = j;
      }
    }
  }

  for (int i = 1; i <= N; i++) {
    if (i == 1) {
      res += bfs(sx, sy, gx[i], gy[i]);
    } else {
      res += bfs(gx[i-1], gy[i-1], gx[i], gy[i]);
    }
  }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 8016
#include<stdio.h>
#define N 1000000
#define NIL -500000000

int c=0,T[N];

int Parent(int i){
  return i/2;
}

int Left(int i){
  return 2*i;
}

int Right(int i){
  return 2*i+1;
}

void maxHeapify(int i){
  int l,r,largest,key;

  l=Left(i);
  r=Right(i);

  if(l<=c&&T[l]>T[i]) largest=l;
  else largest=i;

  if(r<=c&&T[r]>T[largest]) largest=r;

  if(largest!=i){
    key=T[i];
    T[i]=T[largest];
    T[largest]=key;
    maxHeapify(largest);
  }

}

void maxHeapInsert(int key){
  c++;
  T[c]=NIL;
  heapIncreaseKey(c,key);
}

void heapIncreaseKey(int i,int key){
  int box;

  if(key<T[i]) printf("error 新しいキーは現在のキーより小さい\n");
  T[i]=key;
  while(i>1&&T[Parent(i)]<T[i]){
    box=T[i];
    T[i]=T[Parent(i)];
    T[Parent(i)]=box;
    i=Parent(i);
  }
}

int heapExtractMax(){
  int max;

  if(c<1) printf("error ヒープアンダーフロー\n");
  max=T[1];
  T[1]=T[c];
  c--;
  maxHeapify(1);
  return max;
}

int main(void){
  int x,i;
  char com[20];

  while(1){
    scanf("%s",com);
    if(com[0]=='i'){
      scanf("%d",&x);
      maxHeapInsert(x);
    }
    else if(com[1]=='x')  printf("%d\n",heapExtractMax());
    else break;
    
  }
    return 0;
}

Measured memory_bytes: 4508
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF_LL 1e18
#define INF 1e9

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

using namespace std;

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

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int d[2020][2020];
vector<int> G[2020];
bool used[2020];

int dfs(int x, int dis, int K){
	used[x] = true;
	ll res = 0;
	REP(i, G[x].size()){
		if(!used[G[x][i]]){
			res += dfs(G[x][i], dis+1, K);
		}
	}
	if(dis > K) return res+1;
	return res;
}

int main(void){
	int N, K;
	int res = INF;
	cin >> N >> K;
	REP(i, N-1){
		int a, b;
		d[i][i] = 0;
		cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
		d[a][b] = d[b][a] = 1;
	}
	if(K%2 == 0){
		REP(i, N){
			memset(used, 0, sizeof used);
			res = min(res, dfs(i, 0, K/2));
			cout << endl;
		}
	}else{
		REP(i, N){
			REP(j, G[i].size()){
				memset(used, 0, sizeof used);
				used[i] = true;
				used[G[i][j]] = true;
				res = min(res, dfs(i, 0, (K-1)/2)+dfs(G[i][j], 0, (K-1)/2));
			}
		}
	}
	cout << res << endl;
}


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

def sumdigit(num):
    sum=0
    for i in num:
        sum+=int(i)
    return sum

ans=0
for i in range(1,n+1):
    sum=sumdigit(str(i))
    if a<=sum<=b:
        ans+=i
print(ans)


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

int main() 
{
	int a;
	int b;
	for(a=1; a<10; a++) {
		for(b=1; b<10; b++) {
			cout << a << "x" << b << "=" << a*b << endl;
		}
	}
	return 0;
}

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

int main() {
    ll n;
    cin >> n;
    vector<ll> keiro(5);
    for(int i=0; i<5; i++){
        cin >> keiro[i];
    }
    ll min_k = *min_element(keiro.begin(), keiro.end());
    ll ans = 0;
    if(n%min_k == 0){
        ans += n/min_k-1;
    }else{
        ans += n/min_k;
    }
    ans += 5;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(n);i++)
#define fori(a,b,i) for(int i=(a);i<=(b);i++)
#define ford(a,b,i) for(int i=(a);i>=(b);i--)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);


#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define eps  1e-9

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
typedef long long int llint;


int main()
{
	llint n, m;
	cin>>n>>m;
	vector <llint> v[n], h(n);
	loop(i, n) cin>>h[i];
	loop(i, m){
		llint a, b;
		cin>>a>>b;
		a--; b--;
		v[a].pb(b);
		v[b].pb(a);
	}
	llint ans = 0;
	loop(i, n){
		llint mh = h[i];
		bool flag = 1;
		for(auto j : v[i]){
			if(mh <= h[j]) flag = 0;
		}
		if(flag) ++ans;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 9848
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
	string s = ReadLine();
	char[] ans = new char[10];
	int pt = 0;

	for (int i = 0; i < s.Length; i++)
	{
	    char c = s[i];

	    if (c == 'B')
	    {
		pt = (pt == 0) ?  0 : pt - 1;
	    }
	    else
	    {
		ans[pt++] = c;
	    }
	}

	Array.Resize(ref ans, pt);
	WriteLine(new String(ans));
    }
}


Measured memory_bytes: 13140
#include <iostream>

using namespace std;

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2")

using namespace std;

using ll = long long;
#define all(x) begin(x), end(x)

int main()
{
    ios_base::sync_with_stdio(0);
    long double d,t,s; cin >> d >> t >> s;
    if(d/s<=t)
        cout << "Yes" << "\n";
    else
        cout << "No" << "\n";
   
}


Measured memory_bytes: 3744
#include <iostream>
#include <queue>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
#define INF 100000000
using namespace std;
typedef pair<int, int> pii;

int N, M, K, D[16], V[100][100];
bool visited[1 << 16];

int main(void) {
  cin >> N >> M >> K;
  REP(i, 0, M) cin >> D[i], D[i]--;
  REP(i, 0, N) REP(j, 0, K) {
    int v; cin >> v; v--;
    V[i][j] = -1;
    REP(k, 0, M) if(i == D[k]) REP(l, 0, M) if(v == D[l]) V[i][j] = l;
  }
  REP(i, 0, 1 << M) visited[i] = false;

  queue<pii> q;
  q.push(pii((1 << M) - 1, 0));

  while(q.size()) {
    int s = q.front().first, d = q.front().second;
    q.pop();

    if(visited[s]) continue;
    visited[s] = true;

    if(s == 0) {
      cout << d << endl;
      break;
    }

    REP(i, 0, K) {
      int t = 0;
      REP(j, 0, M) if(((s >> j) & 1) && V[D[j]][i] >= 0) t = t | (1 << V[D[j]][i]);
      q.push(pii(t, d + 1));
    }
  }

  return 0;
}

Measured memory_bytes: 32408
#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.at(i);
  }
  
  long long sum = 0;
  int max_height = 0;
  for (int i = 0; i < n; i++) {
    if (a.at(i) < max_height) {
      sum += max_height - a.at(i);
    }
    max_height = max(max_height, a.at(i));
  }
  cout << sum << endl;
}


Measured memory_bytes: 3952
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
bool is_integer( double x ){
  return floor(x)==x;
}
int main(){
  int n,a,b; cin >> n >> a >> b;
  cout << min(n*a,b) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int H,W; cin >> H >> W;
    char maze[H][W]; rep(i,H)rep(j,W)cin >> maze[i][j];
    //Right
    int R[H][W] = {}; rep(i,H)if(maze[i][W-1] == '#') R[i][W-1] = 0; else R[i][W-1] = 1;
    for(int i = 0; i<H; ++i){
        for(int j = W-2; j>=0; --j){
            if(maze[i][j] == '#')R[i][j] =0;
            else if(maze[i][j+1] == '#')R[i][j] = 1;
            else R[i][j] = R[i][j+1] + 1;
        }
    }
    //Left
    int L[H][W] = {}; rep(i,H)if(maze[i][0] == '#') L[i][0] = 0; else L[i][0] = 1;
    for(int i = 0; i<H; ++i){
        for(int j = 1; j<W; ++j){
            if(maze[i][j] == '#')L[i][j] =0;
            else if(maze[i][j-1] == '#')L[i][j] = 1;
            else L[i][j] = L[i][j-1] + 1;
        }
    }
    //Up
    int U[H][W] = {}; rep(i,W)if(maze[0][i] == '#') U[0][i] = 0; else U[0][i] = 1;
    for(int i = 0; i<W; ++i){
        for(int j = 1; j<H; ++j){
            if(maze[j][i] == '#')U[j][i] =0;
            else if(maze[j-1][i] == '#')U[j][i] = 1;
            else U[j][i] = U[j-1][i] + 1;
        }
    }
    //Down
    int D[H][W] = {}; rep(i,W)if(maze[H-1][i] == '#') D[H-1][i] = 0; else D[H-1][i] = 1;
    for(int i = 0; i<W; ++i){
        for(int j = H-2; j>=0; --j){
            if(maze[j][i] == '#')D[j][i] =0;
            else if(maze[j+1][i] == '#')D[j][i] = 1;
            else D[j][i] = D[j+1][i] + 1;
        }
    }
    int ans = -INF;
    rep(i,H)rep(j,W){
        ans = max(ans, D[i][j] + U[i][j] + R[i][j] + L[i][j] -3);
    }
    cout << ans << endl;
}


Measured memory_bytes: 66688
import bisect
n,q = map(int,input().split())
s = input()
acindex = []
for i in range(n-1):
	if s[i]=="A" and s[i+1]=="C":
		acindex.append(i+1)
for _ in range(q):
	l,r = map(int,input().split())
	count = bisect.bisect_left(acindex, r)-bisect.bisect_left(acindex, l)
	print(count)

Measured memory_bytes: 5816
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      System.out.println(tmp.substring(0,1) + (tmp.length() - 2) + tmp.substring(tmp.length() - 1,tmp.length()));
	}
}


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

using namespace std;
using ll = long long;
const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const { return mint(*this) += a; }

    mint operator-(const mint a) const { return mint(*this) -= a; }

    mint operator*(const mint a) const { return mint(*this) *= a; }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }

    mint &operator/=(const mint a) { return *this *= a.inv(); }

    mint operator/(const mint a) const { return mint(*this) /= a; }
};

istream &operator>>(istream &is, const mint &a) { return is >> a.x; }

ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<mint> B(n + 1);
    B[0] = m;
    for (int i = 1; i <= n; ++i) {
        B[i] = B[i - 1] * (m - 1);
    }
    combination C = combination(2e5);
    mint ans = 0;
    for (int i = 0; i <= k; ++i) {
        ans += C.operator()(n - 1, i) * B[n - i - 1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7984
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  ll n;
  cin >> n;
  
  ll q = n / 11;
  
  ll r;
  if(n%11 == 0){
    r = 0;
  }else if(n%11 <= 6){
    r = 1;
  }else r = 2;
  
  cout << q*2 + r;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;

int main(){

    int a,b;
    cin >> a >> b;

    int cnt = 0;
    for(int i=a;i<=b;i++){
        int tmp = i;
        int c[5] = {0};
        for(int j=0;j<5;j++){
            c[j] = tmp%10;
            tmp /= 10;
        }
        if(c[0]==c[4] && c[1] == c[3])cnt++;
    }

    cout << cnt << endl;



   return 0;
}

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

int main(){
    int n,w;
    cin >> n >> w;
    int values[n],weight[n];
    vector<pair<int,int>> vect;
    for(int i=0;i<n;i++){
        cin >>  weight[i] >> values[i];
        vect.push_back({weight[i],values[i]});
    }
    long long dp[100001];
    for(int i=0;i<=100000;i++) dp[i] = 0;
    sort(vect.begin(),vect.end());
    for(int i=0;i<vect.size();i++){
        int wgh = vect[i].first;
        int vl =  vect[i].second;
        for(int j= 100000;j>=wgh;j--){
            dp[j] = max(dp[j - wgh] + vl,dp[j]);
        }
    }
    long long max_ = 0;
    for(int i=w;i>=0;i--){
        max_ = max(max_,dp[i]);
    }
    cout << max_;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define mod (int)1e9+7
#define inf (int)1e16
#define rep(i,n) for (int i = 0; i < n; i++)
#define Rep(i,n) for (int i = n; i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define cend cout<<endl;
#define P pair<int, int>
#define F first
#define S second
#define prique priority_queue<P, vector<P>, greater<P>>
using namespace std;

int n,m;
P a[50];
vector<int> ta[60];
bool u[60];
int ans;

void dfs(int x){
	u[x]=true;
	rep(j,(int)ta[x].size()){
		if(!u[ta[x][j]])dfs(ta[x][j]);
	}
	return;
}

signed main() {
	cin>>n>>m;
	rep(i,m){
		cin>>a[i].F>>a[i].S;
	}
	rep(i,m){
		rep(j,n)ta[j+1].clear();
		fill(u,u+n+1,false);
		rep(j,m){
			if(i!=j){
				ta[a[j].F].push_back(a[j].S);
				ta[a[j].S].push_back(a[j].F);
			}
		}
		dfs(1);
		rep(j,n){
			if(!u[j+1]){
				ans++;
				break;
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
// AOJ 2275: Fox Number
// 2017.12.11 bal4u@uu

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

#define MAX  707106			// sqrt(10^12/2)
char tbl[MAX+1];

int sz;						// max sz = 57084, prime[0] = 2, prime[57083] = 707099
int prime[57100] = {  		// prime[146] = 853, prime[147] = 857
  2, 3,  5,  7, 11, 13, 17, 19, 23, 29, 
 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 
 73, 79, 83, 89, 97,101,103,107,109,113, 
127,131,137,139,149,151,157,163,167,173,
179,181,191,193,197,199,211,223,227,229, 
233,239,241,251,257,263,269,271,277,281, 
283,293,307,311,313,317,331,337,347,349, 
353,359,367,373,379,383,389,397,401,409, 
419,421,431,433,439,443,449,457,461,463, 
467,479,487,491,499,503,509,521,523,541, 
547,557,563,569,571,577,587,593,599,601, 
607,613,617,619,631,641,643,647,653,659, 
661,673,677,683,691,701,709,719,727,733, 
739,743,751,757,761,769,773,787,797,809, 
811,821,823,827,829,839,853 };

void sieve()
{
	int i, j, k;

	for (i = 1; i < 147; i++) {
		k = prime[i];
		for (j = k*k; j < MAX; j += k) tbl[j] = 1;
	}
	for (sz = 146, i = 853; i <= MAX; i += 2) if (!tbl[i]) prime[sz++] = i;
//	printf("sz %d, prime[%d]=%d\n", sz, sz-1, prime[sz-1]);
//	        sz 57084, prime[57083]=707099
}

int base[1000002];
int idx [1000002];
long long pp[41];		// 2^40 = 1099511627776 >= 10^12

int bsch(int x)
{
	int m, l = 0, r = sz;

    while (l < r) {
        m = (l + r) >> 1;
		if (prime[m] == x) return m;
        if (prime[m] < x) l = m + 1; else r = m;
    }
	return l-1;
}

int main()
{
	int i, k, p, ans;
	long long A, B, a, b, j, n;

	sieve();

	scanf("%lld%lld", &A, &B);
	a = A-B, b = A+B;
	if (b <= 1) { puts("0"); return 0; }
	if (a <= 1) a = 2;

	sz = bsch((int)sqrt((double)(b >> 1)));

	memset(idx, 1, sizeof(idx));
	for (i = 0; i <= sz; i++) {
		for (p = prime[i], k = 1, j = p; j <= b; j *= p) pp[k++] = j;
		while (--k) for (j = pp[k], n = j*(1+(a-1)/j); n <= b; n += j) {
			int x = (int)(n-a);
			if (!idx[x] || base[x] == p) continue;
			if (idx[x] < k) idx[x] = 0;
			else base[x] = p, idx[x] = k;
		}
	}

	ans = 0, i = (int)(b-a+1); while (i--) if (idx[i]) ans++;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 10452
#include<stdio.h>

int main(){
  int A,B,S1,S2,S3,max;
  scanf("%d %d",&A,&B);
  S1=A+(A-1);
  S2=A+B;
  S3=B+(B-1);
  max=S1;
  if(max<=S2){
    max=S2;
    if(max<=S3){
      max=S3;
      printf("%d\n",S3);
    }else{
      printf("%d\n",S2);
    }
  }else if(max<=S3){
    max=S3;
    if(max<=S2){
      max=S2;
      printf("%d\n",S2);
    }else{
      printf("%d\n",S3);
    }
  }else{
    printf("%d\n",S1);
  }
  return 0;
}


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

int main() {
  int N, M;
  const int MAX = 50;
  cin >> N >> M;
  vector<int> a(MAX);
  vector<int> b(MAX);
  vector<int> counter(MAX);
  for (int i = 0; i < M; i++) {
    cin >> a.at(i) >> b.at(i);
  }
  
  for (int i = 0; i < M; i++) {
    counter.at(a.at(i) - 1) += 1;
    counter.at(b.at(i) - 1) += 1;
  }

  for (int i = 0; i < N; i++) {
    cout << counter.at(i) << endl;
  }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		boolean[] b = new boolean[10];
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] < 3200) {
				b[a[i] / 400] = true;
			} else {
				cnt++;
			}
		}

		int min = 0;
		for (int i = 0; i < b.length; i++) {
			if (b[i]) {
				min++;
			}
		}
		if (min == 0) {
			min++;
			cnt--;
		}
		System.out.println(min + " " + (min + cnt));
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



string reverse(string s){
  string t = s;
  int N = s.size();
  for(int i=0;i<N;i++){
    t[N-i-1] = s[i];
  }
  return t;
}


string n;

int main(){
  string s;
  int cnt = 0;
  cin >> s;
  int Q;
  cin >> Q;
  for(int i = 0; i < Q; i++){
    int t,f;
    string c;
    cin >> t;
    if(t == 1) cnt++;
    else{
      cin >> f >> c;
      if(f - (cnt % 2) == 1) n = n+c;
      else s = s + c;
    }
  }
  n = reverse(n);
  s = n+s;
  if(cnt % 2 == 1) cout << reverse(s) << endl;
  else cout << s << endl;
  return 0;
}


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


int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  
  int count = 3;
  
  if (a == b) {
    count--;
  }
  if (a == c) {
    count--;
  }
  if (b == c) {
    count--;
  }
  if (a == b && b == c) {
    count = 1;
  }  
    cout << count << endl;
}

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

int main(){
	int n;
	cin >> n;
	double sum = 0;
	rep(i, n){
		double a;
		string s;
		cin >> a >> s;
		if(s == "BTC"){
			a *= 380000;
		}
		sum += a;
	}
	cout  << fixed << setprecision(10) << sum << endl;
	return 0;
}

Measured memory_bytes: 256
eval'A,B,*C=#'+`tr ' ' ,`;z=x=0;C.map{x^=_1};999.times{45.downto(0){|i|(x^A^B)[i]>0&&(z+=t=[A[0,i]+1,2**i-B[0,i]].min;A-=t;B+=t)}};p A>0?z:-1

Measured memory_bytes: 14884
fun main(arg: Array<String>) {
    val n = readLine()!!.toInt()
    fun popcount(N: Int): Int {
        var n = N
        var count = 0
        while (n > 0) {
            if ((n and 1) == 1) count++
            n = n shr 1
        }
        return count
    }
    if (popcount(n) == 1) { println( "No"); return }
    println("Yes")
    fun prt(a: Int, b: Int) = println("${a} ${b}")
    for( i in 2 until n step 2) {
        prt(i + 1, i);
        prt(i, 1);
        prt(1, i + n + 1);
        prt(i + n + 1, i + n);
    }
    prt(n + 1, 3);
    if (n % 2 == 0) {
        var k = 30
        while ((n and (1 shl k)) == 0) k--
        val s = (1 shl k) // even
        val r = (n xor s xor 1) // odd
        prt(n, s)
        prt(n + n, r + n)
    }
}


Measured memory_bytes: 41972