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

public class Main {


  private static void solve() {
    int n = ni();
    int m = ni();
    long[] a = nal(n);
    long[] sum = new long[n + 1];
    for (int i = 0; i < n; i ++) {
      sum[i + 1] = (sum[i] + a[i]) % m;
    }
    
    Map<Long, Long> map = new HashMap<>();
    for (long v : sum) {
      map.put(v, map.getOrDefault(v, 0L) + 1);
    }
    
    long ret = 0;
    for (Map.Entry<Long, Long> entry : map.entrySet()) {
      long u = entry.getValue();
      ret += u * (u - 1) / 2;
    }
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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

typedef long long ll;
typedef long double ld;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)

int f(int len, int goal){
    return len / goal - (len % goal == 0);
}

void solve(){
    
    int n, k; cin >> n >> k;
    int a[n];
    for(int& u : a){ cin >> u; }
    int lo = 1, hi = 1e9;
    int ans;
    while(lo <= hi){
        int mid = (lo + hi) / 2;
        int cnt = 0;
        for(int u : a){
            cnt += f(u, mid);
        }
        if(cnt <= k){
            ans = mid;
            hi = mid - 1;
        }
        else{
            lo = mid + 1;
        }
    }
    cout << ans << '\n';
    
}


int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    boost;

    int t = 1;
    // cin >> t;


    for(int i = 1; i <= t; i++){
        // cout << "Case #" << i << ": ";

        solve();

    }
    return 0;
}

Measured memory_bytes: 4372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n,q;
  cin >> n >> q;
  int s[n],t[n],x[n];
  rep(i,n) cin >> s[i] >> t[i] >> x[i];

  pair<int, int> left[n];
  rep(i,n) left[i] = mp(s[i]-x[i],i);
  sort(left,left+n);
  int d[q];
  rep(i,q) cin >> d[i];
  int lcou=0;
  //  priority_queue<long long> small;
  //  priority_queue<long long, vector<long long>, greater<long long> > large;
  priority_queue<pair<ll,int>, vector<pair<ll,int> >, greater<pair<ll,int> > > qu;
  multiset<int> ms;
  rep(i,q){    
    if(lcou!=n){
      while(d[i]>=left[lcou].first){
	int ind= left[lcou].second;
	ms.insert(x[ind]);
	qu.push(mp(t[ind]-x[ind]-1, ind));
	lcou++;
	if(lcou==n) break;
      }
    }
    if(!qu.empty()){
      while(qu.top().first < d[i]){
	auto tm = qu.top();qu.pop();
	auto it = ms.lower_bound(x[tm.second]);
	ms.erase(it);
	if(qu.empty()) break;
      }
    }
    if(qu.empty()) cout << -1 << endl;
    else{
      cout << *(ms.begin()) << endl;
    }
  }

    
  

  
  return 0;
    

}


Measured memory_bytes: 19052
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
ll dp[301][301][301];

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

  cin >> n >> m;
  dp[0][1][1] = 1;
  rrep(i, 1, m + 1) {
    rrep(j, 1, n + 1) {
      rrep(k, 1, n + 1) {
        (dp[i][j][k] += dp[i - 1][j - 1][k] * (n - j + 1)) %= MOD;
        if (j - k >= 0) (dp[i][j][k] += dp[i - 1][j][k] * (j - k)) %= MOD;
        (dp[i][j][j] += dp[i - 1][j][k] * k) %= MOD;
      }
    }
  }
  ans = dp[m][n][n];
  Cout(ans);
  return 0;
}


Measured memory_bytes: 212608
n=int(input())
l=list(map(int,input().split()))
l.sort()
s=0
c=0
s+=l[-1]
t=0
for i in range(n-2,n//2-1,-1):
    s+=l[i]*2
    #print(l[i]*2)
if (n%2):
    s-=l[n//2]
    #print(l[n//2])
print(s)
    
    

Measured memory_bytes: 31748
object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  val ls = in(0).split(' ').map(_.toInt)
  val K = ls(1) - 1
  val S = in(1).toArray
  val diff = ('A'.toInt - 'a'.toInt)
  if('A' <= S(K) && S(K) <= 'C' )
  S(K) = (S(K).toInt - diff).toChar
  else
  S(K) = (S(K).toInt + diff).toChar
  S.map(print)
  println("")
}


Measured memory_bytes: 27200
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef long long ull;
typedef long double ld;
#define inp_arr(name,size) for(int i = 0;i<size;i++)\
cin >> name[i];
#define QUICK cin.tie(0);
#define MOD 1e9+7

int main(){
    QUICK

    string a;
    cin >> a;
    if(a[2]==a[3]&&a[4]==a[5])
        cout << "Yes";
    else
        cout << "No";


    return 0;
}








Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define ssort(a) sort(a.begin(), a.end())
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int x;
  cin >> x;
  cout << 1-x << endl;
  return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>
int main(){
int a,b,c,d,e;
scanf ("%d%d%d",&a,&b,&c);
if (b-a>0){d=b-a;}
  else {d=a-b;}
  if (c-a>0){e=c-a;}
  else {e=a-c;}
  if(d>e){printf ("B");}
  else{printf ("A");}
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    ll N,C;
    cin >> N >> C;
    vector<vector<pair<ll,ll>>> tab(C);
    for(int i = 0; i < C; i++){
        tab[i] = vector<pair<ll,ll>>(0);
    }
    for(int i = 0; i < N; i++){
        ll s,t,c;
        cin >> s >> t >>c;
        tab[c - 1].push_back(pair<ll,ll>(s, t));
    }

    int sum[200000];
    for(ll i = 0; i < 200000; i++){
        sum[i] = 0;
    }

    for(ll ci = 0; ci < C; ci++){
        int tmp[200000];
        for(int i = 0; i < 200000; i++){
            tmp[i] = 0;
        }
        for(ll i = 0; i < tab[ci].size(); i++){
            ll s = tab[ci][i].first;
            ll t = tab[ci][i].second;
            for(ll j = s; j <= t; j++){
                tmp[j] = 1;
            }
        }
        for(ll i = 0;i < 200000; i++){
            sum[i] += tmp[i];
        }
    }


    int M = 0;
    for(int i = 0; i < 200000; i++){
        M = max(M, sum[i]);
    }
    cout << M << endl;

}


Measured memory_bytes: 4352
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 7;
int main(){
    string s, t;
    cin >> s >> t;
    cout << t << s;
}

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

int main(int argc, char* argv[])
{
	string s1,s2,s3;
	cin>>s1>>s2>>s3;
	cout<<char(s1[0]-'a'+'A')<<char(s2[0]-'a'+'A')<<char(s3[0]-'a'+'A')<<endl;
	return 0;
}

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

int main() {
    string s; cin >> s;
    int a, b, c, d;
    a = s.at(0) - '0';
    b = s.at(1) - '0';
    c = s.at(2) - '0';
    d = s.at(3) - '0';

    int ans = 0;
    rep(i, 2) {
        ans = (i ? (a + b) : (a - b));
        rep(j, 2) {
            int tmpc = 0;
            tmpc = ans;
            tmpc = (j ? (ans + c) : (ans - c));
            rep(k, 2) {
                int tmpd = 0;
                tmpd = tmpc;
                tmpd = (k ? (tmpd + d) : (tmpd - d));

                if (tmpd == 7) {
                    printf("%d%c%d%c%d%c%d=%d\n", a, (i ? '+': '-'),
                                                b, (j ? '+': '-'),
                                                c, (k ? '+': '-'),
                                                d, tmpd);
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; i++)
#define pb push_back
using namespace std;

vector<int> e[100];
bool used[100];
int ans;

void dfs(int x, int y){
	if(used[x]){
		if(y > ans) ans = y;
		return;
	}
	used[x] = true;
	rep(i,e[x].size()){
		//if(used[e[x][i]]) continue;
		dfs(e[x][i],y+1);
	}
	used[x] = false;
}

int main(){
	int n;
	while(scanf("%d", &n),n){
		rep(i,100) e[i].clear();
		rep(i,n){
			int a, b;
			scanf("%d%d", &a, &b);
			a--; b--;
			e[a].pb(b);
			e[b].pb(a);
		}
		ans = 0;
		rep(i,100){
			rep(j,100) used[j] = false;
			dfs(i,0);
		}
		printf("%d\n", ans);
	}
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int N; cin >> N;
  int F = 0, K = 0;
  rep(i, N) {
    int a; cin >> a;
    F += a % 4 == 0;
    K += a % 2;
  }

  if (N % 2) {
    cout << (K - 1 <= F ? "Yes" : "No") << "\n";
  } else {
    cout << (K <= F ? "Yes" : "No") << "\n";
  }
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by zzt on 17-1-26.
 */
public class Main {

    private static int n, m;
    private static char[] chars;
    private static int[] l, r, newR, sum;
    private static long[][] dp;
    private static final int MOD = (int) (1e9 + 7);

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        m = scanner.nextInt();
        chars = scanner.next().toCharArray();

        l = new int[m];
        r = new int[m];

        for (int i = 0; i < m; i++) {
            l[i] = scanner.nextInt() - 1;
            r[i] = scanner.nextInt() - 1;
        }
        newR = new int[n + 1];
        for (int i = 0; i < n; i++) {
            newR[i] = i;
        }
        for (int i = 0; i < m; i++) {
            newR[l[i]] = Math.max(newR[l[i]], r[i]);
        }
        for (int i = 1; i < n; i++) {
            newR[i] = Math.max(newR[i], newR[i - 1]);
        }
        sum = new int[n];
        for (int i = 0; i < n; i++) {
            sum[i] = chars[i] - '0';
        }
        for (int i = 0; i < n - 1; i++) {
            sum[i + 1] += sum[i];
        }
        dp = new long[n + 1][n + 1];
        for (int i = 0; i < n + 1; i++) {
            Arrays.fill(dp[i], -1);
        }
        System.out.println(dfs(0, newR[0], sum[newR[0]]));
    }

    static long dfs(int L, int R, int c) {
        if (L == n)
            return 1;
        if (dp[L][c] != -1)
            return dp[L][c];
        long ret = 0;
        int add = 0;
        if (R < newR[L + 1])
            add = sum[newR[L + 1]] - sum[R];
        if (c > 0)
            ret += dfs(L + 1, newR[L + 1], c - 1 + add) % MOD;
        if (c < R - L + 1) {
            ret += dfs(L + 1, newR[L + 1], c + add) % MOD;
        }
        ret %= MOD;
        return dp[L][c] = ret;
    }
}

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

struct Judge{
  int team, sum, score;
  int pena[100];
};

bool operator<(const Judge &a, const Judge &b){
  if(a.sum != b.sum) return a.sum > b.sum;
  else if(a.score != b.score) return a.score < b.score;
  else return a.team < b.team;
}

int main(){
  int t, p, r;
  while(cin >> t >> p >> r, t | p | r){
    Judge team[100];
    for(int i = 0; i < t; i++){
      team[i].team = i + 1;
      team[i].sum = 0;
      team[i].score = 0;
      for(int j = 0; j < 100; j++) team[i].pena[j] = 0;
    }
    for(int i = 0; i < r; i++){
      int id, pid, timer;
      string msg;
      cin >> id >> pid >> timer >> msg;
      if(msg == "WRONG"){
        for(int j = 0; j < t; j++){
          if(team[j].team == id) team[j].pena[pid]++;
        }
      }else if(msg == "CORRECT"){
        for(int j = 0; j < t; j++){
          if(team[j].team == id){
            team[j].score += timer + team[j].pena[pid] * 1200;
            team[j].sum++;
          }
        }
      }
    }
    sort(team, team+t);
    for(int i = 0; i < t; i++){
      cout << team[i].team << " " << team[i].sum << " " << team[i].score << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3192
import javax.print.DocFlavor;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;

public class Main {

    //グローバル変数を定義

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

    void run() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        ArrayList array = new ArrayList();

        array.add(a);

        int count = 1;

        while(true) {

            if (a % 2 == 0) {
                a = a / 2;
            } else {
                a = 3 * a + 1;
            }

            count++;

            if (array.contains(a)) {
                System.out.println(count);
                break;
            }

            array.add(a);

        }
    }
}


Measured memory_bytes: 23764
#include<iostream>
using namespace std;
typedef long long int ll;

ll solve(ll n, ll w, ll* a, ll* b)
{
  ll dp[n+1][w+1];
  for (ll i = 0; i <= n; i++)
  {
    for (ll j = 0; j <= w; j++)
    {
      if (i == 0 || j == 0)
      {
        dp[i][j] = 0;
      }
      else if (a[i-1] > j)
      {
        dp[i][j] = dp[i-1][j];
      }
      else
      {
        dp[i][j] = max(dp[i-1][j], b[i-1] + dp[i-1][j-a[i-1]]);
      }
    }
  }
  return dp[n][w];
}

int main()
{
  ll n,w;
  cin >> n;
  cin >> w;
  ll weights[n];
  ll values[n];
  for (ll i = 0; i < n; i++)
  {
    cin >> weights[i];
    cin >> values[i];
  }
  ll x = solve(n, w, weights, values);
  cout << x << endl;
}


Measured memory_bytes: 81988
// AOJ 0221: FizzBuzz
// 2017.8.24 bal4u@uu
// 2017.11.18

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

#define MAX		 10000
#define DIGIT	 0
#define FIZZ     (-1)
#define BUZZ     (-2)
#define FIZZBUZZ (-3)
#define OTHER	 (-9)

char tbl[MAX+1];
char p[1010];

char buf[30], *bp;
int getint()
{
	int n = 0;
	while (*bp >= '0' && *bp <= '9') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	return n;
}

int main()
{
	int m, n;
	int k, dig, must, idx, len;

	for (n = 3; n <= MAX; n += 3) tbl[n] |= 1;
	for (n = 5; n <= MAX; n += 5) tbl[n] |= 2;

	while (fgets(bp=buf, 30, stdin) && *bp != '0') {
		m = getint(), bp++, n = getint();
		memset(p, 0, sizeof(p));
		len = m-1, idx = dig = 1;

		while (n--) {
			must = -tbl[dig];
			
			fgets(bp=buf, 30, stdin);
			if      (!memcmp(bp, "Fizz",     4) && *(bp+4) < ' ') k = FIZZ;
			else if (!memcmp(bp, "Buzz",     4) && *(bp+4) < ' ') k = BUZZ;
			else if (!memcmp(bp, "FizzBuzz", 8) && *(bp+8) < ' ') k = FIZZBUZZ;
			else { k = getint(); if (*bp >= ' ') k = OTHER; }

			if ((k >= 0 && (must != DIGIT || k != dig)) ||
				(k < 0 && k != must)) {
				p[idx] = 1;
				if (--len == 0) break;
			}
			++dig;
			if (++idx > m) idx = 1;
			while (p[idx]) { if (++idx > m) idx = 1; }
		}
		while (n-- > 0) fgets(buf, 30, stdin);

		idx = 1; while (p[idx]) idx++; printf("%d", idx++);
		for (k = 1; k <= len; k++) {
			while (p[idx]) idx++;
			printf(" %d", idx++);
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 1772
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String[] c = S.split("/");
		if (Integer.parseInt(c[1]) > 4) {
			System.out.println("TBD");
		}
		else System.out.println("Heisei");
	}

}

Measured memory_bytes: 21972
import sys
sys.setrecursionlimit(10**6)

def perm(n, k):
    if n < 0:
        return 0
    if k > n:
        return 0
    return fact[n] * ifact[n-k] % mod

def dfs(v, p):
    global ans
    for nv in link[v]:
        if nv == p:
            continue
        dfs(nv, v)
    # p = -1の時は根である。根も含めて塗り分け方を考えるので、
    # n = K、c = 子の数+根の数で塗り分け方を求める
    # 見るのが子の時はその上の頂点とその親が塗られているので、
    # n = K-2、c = 子の数となる
    if p == -1:
        n = K
    else:
        n = K - 2
    if p == -1:
        k = len(link[v]) + 1
    else:
        k = len(link[v]) - 1

    ans *= perm(n, k)
    ans %= mod

N, K = map(int, input().split())
link = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    link[a-1].append(b-1)
    link[b-1].append(a-1)

mod = 10 ** 9 + 7
ans = 1

fact = [0] * (10**5+1)
fact[0] = 1
fact[1] = 1
for i in range(2, 10**5+1):
    fact[i] = fact[i-1] * i
    fact[i] %= mod
ifact = [0] * (10**5+1)
for i in range(10**5+1):
    ifact[i] = pow(fact[i], mod-2, mod)
    ifact[i] %= mod

dfs(0, -1)

print(ans % mod)


Measured memory_bytes: 95312
n = int(input())
s = str(input())
ans = 0
count = 0
ch = []
for i in range(1,n):
    a = s[:i]
    b = s[i:]
    for j in range(i):
        if a[j] in b and a[j] not in ch:
            count += 1
        ch.append(a[j])
    ans = max(count,ans)
    count = 0
    ch = []
print(ans)

Measured memory_bytes: 9212
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for i in range(1, len(A)):
    A[i] += A[i - 1]
for i in range(1, len(B)):
    B[i] += B[i - 1]
A.insert(0, 0)
B.insert(0, 0)
r = 0
for i, a in enumerate(A):
    min_idx = 0
    max_idx = len(B) - 1
    while min_idx < max_idx:
        j = (min_idx + max_idx + 1) // 2
        k = K - A[i] - B[j]
        if k < 0:
            max_idx = j - 1
        else:
            min_idx = j
    j = min_idx
    while j + 1 < len(B) and K - A[i] - B[j + 1] >= 0:
        j += 1
    if K - A[i] - B[j] >= 0:
        r = max(r, i + j)
print(r)

Measured memory_bytes: 111264
N = int(input())
Pn = list(map(int, input().split()))

Qn = list(range(1, N+1))

cnt = 0
for i in range(N):
    if Pn[i] != Qn[i]:
        cnt += 1
    else:
        continue

if cnt == 0 or cnt == 2:
    print('YES')
else:
    print('NO')
          



Measured memory_bytes: 3060
import itertools
N, M = map(int, input().split())

ans_list = [0]*(N+1)
pen_list = [0]*(N+1)

for i in range(M):
  p_i, S_i = input().split()
  p_i = int(p_i)
  
  if (ans_list[p_i] == 0):
    if(S_i == "WA"):
      a = pen_list[p_i]
      a += 1
      pen_list[p_i] = a
    elif(S_i == "AC"):
      ans_list[p_i] = 1

pen_lis_ans = list(itertools.compress(pen_list, ans_list))
cor_num = sum(ans_list)
pen_num = sum(pen_lis_ans)
                   
print("{} {}".format(cor_num,pen_num))
  
  


Measured memory_bytes: 5560
#include <stdio.h>
#include <stdlib.h>
#define MAX 1000000


struct queue{
    char name[10];
    int time;
};

void initialize();
int isFull();
int isEmpty();
void enqueue(struct queue);
struct queue dequeue();

int head;
int tail;

struct queue A[MAX];
struct queue Q[MAX];

int main(){
    int n,q;
    int total = 0;
    int flag = 1;
    struct queue x;

    scanf("%d %d",&n,&q);

    initialize();

    for(int i = 0;i < n;i++){
        scanf("%s %d",A[i].name,&A[i].time);
        enqueue(A[i]);
    }

    while(flag){
        x = dequeue();
        
        if(x.time - q > 0){
            total += q;
            x.time = x.time - q;
            enqueue(x);
        }
        else if(x.time - q == 0){
            total += q;
            printf("%s %d\n",x.name,total);
        }
        else{
            total += x.time;
            printf("%s %d\n",x.name,total);
        }

        flag = isEmpty() - 1;
    }

    return 0;
}

void initialize(){
    head = 0;
    tail = 0;
}

int isEmpty(){
    if(head == tail)return 1;
    return 0;
}

int isFull(){
    if(head == (tail+1) % MAX)return 1;
    return 0;
}

void enqueue(struct queue x){
    if(isFull()){
        fprintf(stderr,"OverFlow");
        exit(1);
    }
    Q[tail] = x;
    if(tail + 1 == MAX)tail = 0; 
    else tail++;
}

struct queue dequeue(){
    struct queue x;
    if(isEmpty()){
        fprintf(stderr,"AnderFlow");
        exit(1);
    }
    x = Q[head];
    if(head + 1 == MAX)head = 0;
    else head++;
    return x;
}


Measured memory_bytes: 5464
#include <iostream>
#include <string>
#include <vector>

int main()
{
  std::string S;
  std::cin >> S;
  
  long K;
  std::cin >> K;
  
  std::vector<unsigned> v(S.size(), 0);
  for(unsigned i=0; i<S.size(); ++i)
  {
    v[i] = S[i] - 'a';
  }
  
  for(unsigned i=0; i<S.size(); ++i)
  {
    if(v[i] != 0)
    {
      unsigned d = (('z' + 1) - 'a') - v[i];
      if(d <= K)
      {
        v[i] = 0;
        K -= d;
      }
    }
  }
  
  if(K > 0)
  {
    v[S.size() - 1] = (v[S.size() - 1] + K) % 26;
  }
  
  for(unsigned i=0; i<S.size(); ++i)
  {
    std::cout << static_cast<char>(v[i] + 'a');
  }
  std::cout << std::endl;
  
  return 0;
}

Measured memory_bytes: 1024
h,w,d=map(int,input().split())

m={}
for i in range(1,h+1):
  for (j,k) in enumerate(map(int,input().split())):
    m[k]=(i,j+1)

s=[0 for _ in range(1+h*w)]
for i in range(d+1,1+h*w):
  s[i]=s[i-d]+abs(m[i][0]-m[i-d][0])+abs(m[i][1]-m[i-d][1])

for _ in range(int(input())):
  a,b=map(int,input().split())
  print(s[b]-s[a])

Measured memory_bytes: 24212
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int H = in.nextInt();
            int W = in.nextInt();
            int[][] s = new int[H][W];
            for (int i = 0; i < H; i++) {
                String line = in.next();
                for (int j = 0; j < W; j++) {
                    s[i][j] = line.charAt(j) == '.' ? 0 : 1;
                }
            }

            int[] dr = new int[] { -1, 0, 0, 1, };
            int[] dc = new int[] { 0, -1, 1, 0, };
            for (int r = 0; r < H; r++) {
                for (int c = 0; c < W; c++) {
                    if (s[r][c] == 0) {
                        continue;
                    }
                    boolean isValid = !true;
                    for (int d = 0; d < dr.length; d++) {
                        int nr = r + dr[d];
                        int nc = c + dc[d];
                        if (nr < 0 || nr >= H || nc < 0 || nc >= W) {
                            continue;
                        }
                        if (s[nr][nc] == 1) {
                            isValid = true;
                        }
                    }
                    if (!isValid) {
                        System.out.println("No");
                        return;
                    }
                }
            }

            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 27092
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    vector<int> count_a(n+1, 0), count_b(n+1, 0);
    for(int i=0;i<n;++i) {
        cin >> a[i];
        ++count_a[a[i]];
    }
    for(int i=0;i<n;++i) {
        cin >> b[i];
        ++count_b[b[i]];
    }

    for(int i=1;i<=n;++i) {
        if(count_b[i] > n - count_a[i]) {
            cout << "No" << endl;
            return 0;
        }
        count_a[i] += count_a[i-1];
        count_b[i] += count_b[i-1];
    }

    int x = 0;
    for(int i=1;i<=n;++i) {
        x = max(x, count_a[i] - count_b[i-1]);
    }

    cout << "Yes\n";
    for(int i=0;i<n;++i) {
        if(i) cout << " ";
        cout << b[(i-x+n) % n];
    }
    cout << "\n";
}

Measured memory_bytes: 6348
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	x := nextInts(n)
	sort.Ints(x)
	ans := 1001001001
	for j := 0; j < x[n-1]+1; j++ {
		var c int
		for i := 0; i < n; i++ {
			c += (x[i] - j) * (x[i] - j)
		}
		if c < ans {
			ans = c
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#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 k, x;
    cin >> k >> x;
    for(int i = (x - k + 1); i < (x + k); i++){
        cout << i << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            n = input()
            if n == 0:
                break
            p = []
            for i in range(n):
                p.append(map(int, raw_input().split())[1:])
            l = map(int, raw_input().split())[1:]
            flg = False
            num = -1
            for i in range(n):
                if set(l) <= set(p[i]):
                    if flg:
                        num = -1
                        break
                    else:
                        flg = True
                        num = i + 1
            print num
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

Measured memory_bytes: 4832
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {
    char buf[131072];
    scanf("%s", buf);

    string S(buf);
    char cur=S[0];
    size_t n=1;
    for (size_t i=1; i<S.length(); ++i) {
        if (S[i] != cur) {
            ++n;
            cur = S[i];
        }
    }

    printf("%zd\n", n-1);
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc096_c.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int H, W;
  cin >> H >> W;

  vector<string> s(H);
  rep(i, H) { cin >> s[i]; }

  bool ok = true;
  rep(i, H) rep(j, W) {
    if (s[i][j] == '#') {
      char t = i > 0 ? s[i - 1][j] : '-';
      char b = i < H - 1 ? s[i + 1][j] : '-';
      char l = j > 0 ? s[i][j - 1] : '-';
      char r = j < W - 1 ? s[i][j + 1] : '-';
      if (t != '#' && b != '#' && l != '#' && r != '#') {
        ok = false;
        break;
      }
    }
  }

  cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define rep(i,n) for(int i=0;i<int(n);i++)
using namespace std;
const ll pa=1000000007;

inline int max(int a, int b) {//最大
	if (a > b) return a;
	return b;
}
inline int min(int a, int b) {//最小
	if (a < b) return a;
	return b;
}

ll mod(ll a) {
	return a % pa;
}

ll gcd(ll a, ll b) {
	ll r = a % b;
	if (r == 0) return b;
	gcd(b, r);
}
 
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

ll h = 0;

int main() {
	cin >> h;
	ll ans = 0;
	ll i = 2;
	while (true) {
		if (h < i) break;
		i *= 2;
	}
	cout << i - 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define mod 10e9+7
#define ll long long int

int main(void){
    int n;
    scanf("%d", &n);
    int h[n];
    for(int i = 0;i < n;i++){
        scanf("%d", &h[i]);
    }
    int count = 0;
    while(1){
        int i = 0;
        while(i < n){
            while(i < n){
                if(h[i] > 0){
                    count++;
                    break;
                }
                i++;
            }
            while(i < n){
                if(h[i]<=0)break;
                i++;
            }
        }
        int count0 = 0;
        for(int j = 0;j < n;j++){
            h[j]--;
            if(h[j] > 0)count0++;
        }
        if(count0 == 0)break;
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) {
    return a < b ? b = a, true : false;
}
template<typename T> bool chmax(T a, T &b) {
    return a > b ? b = a, true : false;
}

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool isprime(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
vll sieve(ll n) {
    str flg(n + 1, '1');
    for (ll i = 2; i * i <= n; i++) {
        if (flg[i] == '0') continue;
        for (ll j = i * i; j <= n; j += i)
            flg[j] = '0';
    }
    vll res;
    for (ll i = 2; i <= n; i++)
        if (flg[i] == '1') res.push_back(i);
    return res;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

/*----------------------------------------------------------------*/

void solve();

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    solve();
}
void solve() {
    ll n; str s;
    std::cin >> n >> s;
    
    std::map<char, std::set<ll>> map;
    for (ll i = 0; i < n; i++)
        map[s[i]].insert(i);
    
    ll ans = 0;
    for (ll i = 0; i < 1000; i++) {
        str t = std::to_string(i);
        t = str(3 - t.length(), '0') + t;
        ll p = -1;
        for (ll j = 0; j < 3; j++) {
            auto k = map[t[j]].upper_bound(p);
            if (k != map[t[j]].end())
                p = *k;
            else {
                p = -1;
                break;
            }
        }
        if (p != -1) ans++;
    }
    
    std::cout << ans << '\n';
}


Measured memory_bytes: 5100
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
	)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	out := make([][]string, 100)
	for i := range out {
		out[i] = make([]string, 101)
	}
	dx := []int{0, 1, 0, -1}
	dy := []int{-1, 0, 1, 0}
	scanner.Scan()
	a, _ := strconv.Atoi(scanner.Text())
	for a > 0 {
		a--
		scanner.Scan()
		b, _ := strconv.Atoi(scanner.Text())
		for i := 0; i < b; i++ {
			for j := 0; j < b; j++ {
				out[i][j] = " "
			}
			out[i][b] = "0"
		}
		if b == 1 {
			fmt.Println("#")
			if a != 0 {
				fmt.Println()
			}
			continue
		}
		if b == 2 {
			fmt.Printf("##\n# \n")
			if a != 0 {
				fmt.Println()
				continue
			}
		}
		row := b -1
		col := 0
		dir := 0
		l := 0
		out[row][col] = "#"
		for {
			nrow := row+dy[dir%4]
			ncol := col+dx[dir%4]
			if dir%4 == 0 && nrow == 0 || dir%4==3&&ncol==0 || dir%4==2&&nrow==b-1 || dir%4==1&&ncol==b-1 {
				row=nrow
				col=ncol
				out[row][col]="#"
				dir++
				l = 1
			} else if out[nrow+dy[dir%4]][ncol+dx[dir%4]]=="#" {
				if l < 3 {
					break
				}
				dir++
				l = 1
			} else {
				row=nrow
				col=ncol
				out[row][col]="#"
				l++
			}
		}
		for i := 0; i < b; i++ {
			for j := 0; j < b; j++ {
				fmt.Printf("%s", out[i][j])
			}
			fmt.Println()
		}
		if a != 0 {
			fmt.Println()
		}
	}
}


Measured memory_bytes: 1588
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	int flag = 0,x = 1;
	while(true)
	{
		if(x==1)
		{
			c -= b;
			if(c<=0)
			{
				flag = 1;
				break;
			}
		}
		else
		{
			a -= d;
			if(a<=0)
			{
				flag = 2;
				break;
			}
		}
		x ^=1;
	}
	if(flag ==1 )
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3648
"""
Atcoder Beginner Contest 173
D - Chat in a circle

""" 
n = int(input())
a = list(map(int,input().strip().split()))
a.sort(reverse=True)
ans = a[0]

i=0
for t in range(n-2):
    i+= 1 if t%2==0 else 0
    ans+=a[i]

print(ans)

Measured memory_bytes: 105352
import java.io.*;
import java.util.*;
public class Main {

    private static void solver(InputReader sc, PrintWriter out) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        double hour_angle = (0.5 * (h*60 + m));
        int minute_angle = (6*m);
        double angle = Math.abs(hour_angle - minute_angle);
        angle = Math.min(360-angle, angle);
        angle = Math.toRadians(angle);
        double ans = (a *a) + (b*b) - (2 *a * b * (Math.cos(angle)));
        ans = Math.sqrt(ans);
        out.printf("%.10f",ans);
    }
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int[] readIntArray(int n){
            int arr[] = new int[n];
            for(int i=0;i<n;i++) arr[i] = nextInt();
            return arr;
        }
    }
}
class Pair{
    int x,y;
    Pair(int x, int y){
        this.x = x;
        this.y = y;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair pair = (Pair) o;
        return x == pair.x &&
                y == pair.y;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }
}

Measured memory_bytes: 34708
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw				"\n"
int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	cin>>n>>m;
	for(ll i=n;i<=m;i++){
		if((i/10000==i%10) && (i/1000%10==i%100/10))ans++;
	}
	cout<<ans<<nw;
}

Measured memory_bytes: 3608
read n a b
ans=0
for (( k = 1; k <= n; k++ )); do
    dsum=0
    for (( j = 0; j < ${#k}; j++ )); do
        (( dsum += ${k:j:1} ))
    done
    if (( dsum >= a && dsum <= b )); then
        (( ans += k ))
    fi
done
echo ${ans}

Measured memory_bytes: 376
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

int f(int a, int b) {
	if (a == 1)return 0;
	return (f(a - 1, b) + b) % a;
}

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

	while (cin >> N >> M >> K, N) {
		cout << (f(N-1, M) + K) % N + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3524
double x[101][100],y[100][100],r;
main(n,m,i,j,k){for(;scanf("%d%d",&n,&m),m;printf("%.2f\n",r)){
memset(x,0,sizeof(x));
for(i=0;i<n;i++)for(j=0;j<n;j++)scanf("%lf",y[i]+j);
for(j=0;j<n;j++)x[0][j]=1;
for(i=1;i<m;i++)for(j=0;j<n;j++)for(k=0;k<n;k++)if(x[i][j]<x[i-1][k]*y[k][j])x[i][j]=x[i-1][k]*y[k][j];
for(r=j=0;j<n;j++)if(r<x[m-1][j])r=x[m-1][j];
}exit(0);}

Measured memory_bytes: 824
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for i in range(M)]
A.sort(key=lambda x:-x)
BC.sort(key=lambda x:x[1])
C = []
while BC and len(C) < N:
    b,c = BC.pop()
    for i in range(b):
        C.append(c)
        if len(C) == N:
            break
C.sort()
ans = 0
while C:
    a = A.pop()
    c = C.pop()
    ans += max(a,c)
ans += sum(A)
print(ans)

Measured memory_bytes: 95128
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;
int main() {
	cin >> N;
	vector<int>res(N,-1);
	vector<int> u(N), v(N), w(N);
	vector<vector<pair<int,int>>> t(N);
	for (int i = 0; i < N-1; i++) {
		cin >> u[i] >> v[i] >> w[i];
		u[i]--, v[i]--;
		t[u[i]].push_back({ v[i],w[i] });
		t[v[i]].push_back({ u[i],w[i] });
	}
	queue<pair<int,int>> q;
	q.push({ 0,0 });
	res[0] = 0;
	while (!q.empty()) {
		pair<int,int> now = q.front();
		q.pop();
		for (int i = 0; i < t[now.first].size(); i++) {
			if (res[t[now.first][i].first] != -1)continue;
			int len = now.second + t[now.first][i].second;
			if (len % 2 == 0) {
				res[t[now.first][i].first] = 0;
			}
			else res[t[now.first][i].first] = 1;
			q.push({ t[now.first][i].first,len });
		}
	}
	for (int i = 0; i < N; i++)cout << res[i] << endl;
}


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

typedef long long ll;

const ll mod = 1e9 + 7;
const int N = 200010;
ll fac[N], inv[N], f[N];
int h, w, n;
struct Node { int x, y; } a[N];

ll power(ll a, ll b) {
	ll ans = 1;
	while(b) {
		if(b & 1) ans = ans * a % mod;
		a = a * a % mod; b >>= 1;
	} return ans;
}

bool operator < (Node a, Node b) { 
	if(a.x == b.x) return a.y < b.y;
	return a.x < b.x;
}

ll C(int n, int m) {
	return fac[m] * inv[n] % mod * inv[m - n] % mod;
}

int main() {
	scanf("%d%d%d", &h, &w, &n);
	fac[0] = inv[0] = 1;
	for(int i = 1; i < N; ++i) {
		fac[i] = 1LL * fac[i - 1] * i % mod;
		inv[i] = power(fac[i], mod - 2);
	}
	for(int i = 1; i <= n; ++i) {
		scanf("%d%d", &a[i].x, &a[i].y);
	}
	sort(a + 1, a + n + 1);
	a[n + 1] = (Node) { h, w };
	for(int i = 1; i <= n + 1; ++i) {
		f[i] = C(a[i].x - 1, a[i].x + a[i].y - 2);
		for(int j = 1; j < i; ++j) {
			if(a[j].x <= a[i].x && a[j].y <= a[i].y) {
				f[i] -= C(a[i].x - a[j].x, a[i].x - a[j].x + a[i].y - a[j].y) * f[j] % mod;
				(f[i] += mod) %= mod;
			}
		}
	}
	printf("%lld\n", f[n + 1]);
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;

#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}


signed main(){
	IOS();
	vector<int>ans;
	while(1){
		int R,W,C,r;
		cin>>R>>W>>C>>r;
		if(R+W+C+r==0)break;
		int cnt = 0;
		while((R+r*cnt)<W*C){
			cnt++;
		}
		ans.push_back(cnt);
	}
	for(auto e:ans){
		cout<<e<<endl;
	}
}


Measured memory_bytes: 3216