akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        String S = ns();
        long ans = 0;
        for (int i = 0; i < S.length(); i++) {
            ans += Integer.valueOf(S.substring(i,i+1));
        }
        if(ans%9==0) out.println("Yes");
        else out.println("No");
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);
    int upperBound(ArrayList<Long> list, Long target){
        int i = Collections.binarySearch(list, target, new UpperBoundComparator<Long>());
        return ~i;
    }
    class UpperBoundComparator<T extends Comparable<? super T>> implements Comparator<T>{
        public int compare(T x, T y){
            return (x.compareTo(y) > 0) ? 1 : -1;
        }
    }
    int lowerBound(ArrayList<Long> list, Long target){
        int i = Collections.binarySearch(list, target, new LowerBoundComparator<Long>());
        return ~i;
    }
    class LowerBoundComparator<T extends Comparable<? super T>> implements Comparator<T>{
        public int compare(T x, T y){
            return (x.compareTo(y) >= 0) ? 1 : -1;
        }
    }
    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 46328
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 998244353;
const int MAX = 510000;

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

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
ll COM(int n, int k) {
  if(n < k) return 0;
  if(n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll n ) {
  ll res = 1;
  while(n > 0) {
    if(n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,m,k;
  cin >> n >> m >> k;
  COMinit();
  ll ans = 0;
  REP(i, k+1){
    ll tmp = m;
    tmp = tmp * modpow(m-1, n-i-1) % MOD;
    tmp = tmp * COM(n-1, i) % MOD; 
    ans = (ans + tmp) % MOD;
  }
  cout << ans << '\n';
  return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

typedef pair<int,int> P;
const int MAX_N = 112345;
P p[MAX_N];
const int INF = 1001001001;


int calc(int N) {
  int ans = 0;
  int L1 = 0, R1 = INF;
  int L2 = 0, R2 = INF;
  vector<P> Ls, Rs;
  for (int i = 1; i < N; i++) {
    Ls.push_back({p[i].first, i});
    Rs.push_back({p[i].second, i});
  }
  sort(ALL(Ls)); reverse(ALL(Ls));
  sort(ALL(Rs));

  chmax(L1, p[0].first);
  chmin(R1, p[0].second);

  int l = 0, r = 0;
  L2 = Ls[l].first;
  R2 = Rs[r].first;

  for (int i = 1; i < N; i++) {
    // cout << i << ": " << R1 << " " << L1 << "     " << R2 << " " << L2 << endl;
    int val = max(0, R1-L1+1) + max(0, R2-L2+1);
    chmax(ans, val);

    chmax(L1, p[i].first);
    chmin(R1, p[i].second);
    while (l < (int)Ls.size() && Ls[l].second <= i) l++;
    while (r < (int)Rs.size() && Rs[r].second <= i) r++;

    L2 = Ls[l].first;
    R2 = Rs[r].first;
  }
  return ans;
}


int main2() {
  int N = nextInt();
  REP(i, N) {
    p[i].first = nextInt();
    p[i].second = nextInt();
  }

  int ans = 0;
  sort(p, p+N);
  chmax(ans, calc(N));

  sort(p, p+N, [](const P&a, const P&b){ return a.second < b.second; });
  chmax(ans, calc(N));

  sort(p, p+N, [](const P&a, const P&b){ return a.first + a.second < b.first + b.second; });
  chmax(ans, calc(N));

  sort(p, p+N, [](const P&a, const P&b){ return a.first - a.second < b.first - b.second; });
  chmax(ans, calc(N));

  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 3932
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    n, m = map(int, input().split())

    for i in reversed(range(1, m // n + 1)):
        if (m - i * n) % i == 0:
            print(i)
            return




# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """3 14"""
        output = """2"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """10 123"""
        output = """3"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """100000 1000000000"""
        output = """10000"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 71936
lingTry ss [] = True
lingTry (s:ss) (p:ps) = if s == p then lingTry ss ps else False

lingSearch (s:ss) ps cnt = if flag 
  then if res
    then cnt
    else lingSearch (ss ++ [s]) ps (cnt + 1) 
  else -1
  where
    flag = cnt <= (length (s:ss)) + (length ps)
    res = lingTry (s:ss) ps

main = do
  s <- getLine
  p <- getLine
  putStrLn $ if lingSearch s p 0 /= -1 then "Yes" else "No"

Measured memory_bytes: 4028
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 1; i*i <= n; ++i) {
    if (n % i == 0) { 
      ll m = i - 1; //m : nの約数-1
      if (m > 0 && n/m == n%m) ans += m;
      m = n/i - 1;
      if (m > 0 && n/m == n%m) ans += m;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>


int main(void){
  long long int max=-2147483647,min= 2147483647,sum=0,i,j,k;
  std::cin >> i;
  for(j=0;j<i;j++){
    std::cin >> k;
    if(min > k)
      min = k;
    if(max < k)
      max = k;
    sum += k;
  }
  std::cout << min << ' ' << max << ' ' << sum << std::endl;
  return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi   = vec<int>;
using vvi  = vec<vi>;
using vvvi = vec<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!
vector<pair<ll,ll>> prime_factor(ll num){
  vector<pair<ll,ll>> vpl;
  ll cnt;
  for(ll i=2;i*i<=num;i++){
    if(num%i!=0) continue;
    cnt=0;
    while(num%i==0){
      num/=i;
      cnt++;
    }
    vpl.push_back(mp(i,cnt));
  }
  if(num>1) vpl.push_back(make_pair(num,1));
  return vpl;
}
// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  ll a, b;
  cin >> a >> b;
  auto pa = prime_factor(a);
  auto pb = prime_factor(b);
  unordered_set<int> sa, sb;
  for(auto kv : pa){
    sa.insert(kv.first);
  }
  for(auto kv : pb){
    sb.insert(kv.first);
  }
  int cnt = 1;  // 1 は公約数
  for(auto i : sa){
    if(sb.find(i)!=sb.end()) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3664
n = int(input())
s = list(input())

count = 0

if n % 2 == 0:
    for i in range(int(n/2)):
        if s[i] == s[i + int(n/2)]:
            count += 1
    else:
        if count == int(n/2):
            print("Yes")
        else:
            print("No")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,i,j;
    cin>>n;
    ll a,b,c,h[3][n];
    for (i=0;i<n;i++)
    {
        cin>>a>>b>>c;
        h[0][i]=a;
        h[1][i]=b;
        h[2][i]=c;
    }
    ll ans[3][n];
    ans[0][0]=h[0][0];
    ans[1][0]=h[1][0];
    ans[2][0]=h[2][0];
    for (i=1;i<n;i++)
    {
        ans[0][i]=max(ans[1][i-1],ans[2][i-1])+h[0][i];
        ans[1][i]=max(ans[0][i-1],ans[2][i-1])+h[1][i];
        ans[2][i]=max(ans[0][i-1],ans[1][i-1])+h[2][i];
    }
    cout<<max(max(ans[0][n-1],ans[1][n-1]),ans[2][n-1])<<endl;
}

Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    private const int MOD_N = 1000000000 + 7;

    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());

        int count = 0;
        int now = 1, next = 10;
        for (; next <= n; now = next, next *= 10)
        {
            if (now.ToString().Length % 2 == 1)
            {
                count += next - now;
            }
        }
        if (now.ToString().Length % 2 == 1)
            count += n - now + 1;

        Console.WriteLine(count);
    }

    private static int GCD(int a, int b) => a > b ? GCD_impl(a, b) : GCD_impl(b, a);
    private static int GCD_impl(int a, int b) => b == 0 ? a : GCD_impl(b, a % b);
    private static long LCM(int a, int b) => (long)a * b / GCD(a, b);

    private static int Comb(int m, int n)
    {
        var t = m - n;
        if (n > t)
            n = t;

        long numerator = 1;
        for (int i = 0; i < n; ++i)
        {
            numerator *= m - i;
            numerator %= MOD_N;
        }
        long denominator = 1;
        for (; n != 0; --n)
        {
            denominator *= n;
            denominator %= MOD_N;
        }

        var inv_denominator = ModInv((int)denominator, MOD_N);
        var ret = (int)(numerator * inv_denominator % MOD_N);

        return ret >= 0 ? ret : ret + MOD_N;
    }

    private static int ModInv(int a, int m)
    {
        int b = m, x = 1, y = 0;
        while (b != 0)
        {
            var t = a / b;
            a -= t * b;
            Swap(ref a, ref b);
            x -= t * y;
            Swap(ref x, ref y);
        }
        x %= m;
        return x >= 0 ? x : x + m;
    }

    private static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
}


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

/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//main function
fn main() {
    let n: i64 = read();
    let div: i64 = 1000000007;
    let mut sum: i64 = 1;
    for i in 2..n+1{
	sum *= i;
	while sum >= div{
	    sum%=div;
	}
    }
    println!("{}",sum);
}


Measured memory_bytes: 4352
t = []
m = []

5.times do |i|
  v = gets.chomp.to_i
  vm = v % 10
  m.push(vm == 0 ? 0: 10 - vm)
  t.push(((v + 9) / 10 * 10))
end

sum = 0 
t.map {|v| sum += v }
r = sum - m.max
puts r



Measured memory_bytes: 1788
//BadWaper gg
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int a=read(),b=read();
	if(a<=0&&b>=0){printf("Zero\n");}
	else if(a>=0)printf("Positive\n");
	else {(b-a+1)&1?printf("Negative\n"):printf("Positive\n");}
	return 0;
}


Measured memory_bytes: 3568
A,B = map(int,input().split())
q = 100000
for i in range(A):
  S = list(map(int,input().split()))
  if S[1] <= B and S[0] < q:
    q=S[0]
  else:
    pass
if q < 10000:
  print(q)
else:
  print('TLE')

Measured memory_bytes: 3060
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j, k;

  for(int testcase = 0;testcase < 1234567;testcase++){
    ll dp[11][1201] = {0};
    dp[0][0] = 1;
    rep(i, 101)per(j, 10)rep(k, 1001){
      dp[j + 1][k + i] += dp[j][k];
    }

    for(;;){
      int2(n, s);
      if(n == 0 && s == 0)break;
      pri(dp[n][s]);
    }

/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 1316
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var w = o.a();
  var v = o.m(n);
  var dp = Array(1e3*n+1).fill(9e9);
  dp[0] = 0;
  for(var i = 0; i < n; i++){
    var t = v[i];
    for(var j = dp.length-1; j >= t[1]; j--){
      if(dp[j-t[1]] + t[0] <= w){
        dp[j] = Math.min(dp[j-t[1]] + t[0], dp[j]);
      }
    }
  }
  var ans = 0;
  for(j = dp.length-1; j >= 0; j--)if(dp[j] <= w)return j;
}

Measured memory_bytes: 21948
#include <bits/stdc++.h>
#define fi first
#define se second
#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORD(i, a, b) for(int i = (a); i > (b); --i)
#define REPD(i, a, b) for(int i = (a); i >=(b); --i)
#define TR(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define endl '\n'
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ins insert
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define unmap unordered_map
#define pq priority_queue
#define minEle min_element
#define maxEle max_element
#define lb lower_bound //first pos >= val
#define ub upper_bound // first pos > val
#define bp __builtin_popcount
#define debug(a) cout << a << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef pair <pii, int> ppi;
typedef pair <int, pii> pip;
typedef pair <ll, ld> pld;
typedef pair <ll, pll> pllp;
typedef pair <pll, ll> ppll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pll> vpll;
typedef vector <pii> vpii;
typedef map <int, int> mii;
typedef map <ll, ll> mll;
typedef string BigNum;

const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int baseHash = 331;
const int bigNumLength = 5000;
const ld PI = acos(-1);

//Remember limit for IT, etc..., and +1 in limit of any array
const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;
const ll limit2 = 1e3 + 5;
//If TLE let's use int instead of ll because it's as slow as your WPM :)))

/*----IMPORTANT THINGS----*/
pii dir[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
//right down left up rightdown leftdown rightup leftup
pii NON = {-1, -1};
/*------------------------*/

ll n;
vll g[limit];
ll f[limit][2];

void dfs(ll u, ll par) {
    bool isLeave = true;

    f[u][0] = f[u][1] = 1;
    for (auto it : g[u]) {
        if (it != par) {
            dfs(it, u);
            f[u][0] = f[u][0] * (f[it][1] + f[it][0]) % MOD;
            f[u][1] = f[u][1] * f[it][0] % MOD;
        }
    }
}

void solveProblem() {
    dfs(1, 0);
    cout << (f[1][0] + f[1][1]) % MOD << endl;
}

void fastInput() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void readInput() {
    cin >> n;
    REP(i, 1, n - 1) {
        int u, v;
        cin >> u >> v;
        g[u].pb(v); g[v].pb(u);
    }
}

int main() {
    fastInput();
    readInput();
    solveProblem();
}



Measured memory_bytes: 19836
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int W, H, N;

int main() {
  cin >> W >> H >> N;
  int lx, ly;
  cin >> lx >> ly;
  int ans = 0;
  for (int i=0; i<N-1; i++) {
    int x, y;
    cin >> x >> y;
    int dx = x - lx, dy = y - ly;
    ans += abs(dx) + abs(dy);
    if (dx > 0 && dy > 0) ans -= min(dx, dy);
    if (dx < 0 && dy < 0) ans -= min(abs(dx), abs(dy));
    lx = x, ly = y;
  }
  cout << ans << "\n";
  return 0;
}

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

string str;
vector<string> s(4);

bool exist(string s, int i) {
  if (str.substr(i, s.size()) == s) {
    return true;
  } else {
    return false;
  }
}

bool check() {
  int i = 0;
  for (i = 0; i < str.size();) {
    if (exist(s[0], i)) {
      i += s[0].size();
    } else if (exist(s[1], i)) {
      i += s[1].size();
    } else if (exist(s[2], i)) {
      i += s[2].size();
    } else if (exist(s[3], i)) {
      i += s[3].size();
    } else {
      return false;
    }
  }
  return true;
}

void solve() {
  int k;

  s[0] = "dream";
  s[1] = "dreamer";
  s[2] = "erase";
  s[3] = "eraser";

  reverse(str.begin(), str.end());

  for (k = 0; k < 4; k++) {
    reverse(s[k].begin(), s[k].end());
  }

  if (check()) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }

  return;
}

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


Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int i,idx,k,work,n=3;
  int data[n];
  for(i=0;i<n;i++){
    scanf("%d",&data[i]);
  }
  for(i=0;i<n;i++){
    idx=i;
    for(k=i+1;k<n;k++){
      if(data[k]<data[idx]){
        idx=k;
      }
    }
    work=data[i];
    data[i]=data[idx];
    data[idx]=work;
  }
  for(i=0;i<n;i++){
    if(i>0){
      printf(" ");
    }
    printf("%d",data[i]);
  }
  printf("\n");
  return 0;
}

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

public class Main
{
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String args[])
    {
        FastReader obj = new FastReader();
        int a = obj.nextInt(),b = obj.nextInt(),c = obj.nextInt();
        if((a==b && a!=c) || (b==c && b!=a) || (a==c && c!=b))
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


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

using namespace std;

vector<int> water;
vector<int> sugar;

int main(){
    int A, B, C, D, E, F;

    cin >> A >> B >> C >> D >> E >> F;

    for(int i = 0; i <= F;i += 100 * A){
        for(int j = 0; i + j <= F; j += 100 * B){
            if(i + j != 0)water.push_back(i + j);
        }
    }

    for(int i = 0; i <= F;i += C){
        for(int j = 0; i + j <= F; j += D){
            sugar.push_back(i + j);
        }
    }

    int b = 0;
    int a = 0;
    double c = 0;

    for(vector<int>::iterator itw = water.begin(); itw != water.end();itw++){
        for(vector<int>::iterator its = sugar.begin(); its != sugar.end();its++){
            int w = *itw;
            int s = *its;
            if(w + s > F)continue;
            double nc = 1.0 * s / (w + s);
            if((w + s) * E >= (100 + E) * s && c <= nc){
                a = w;
                b = s;
                c = nc;
            }
        }
    }

    cout << a + b << " " << b << endl;

    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main(){
    int n;
    string s1,s2;
    cin >> n >> s1 >> s2;
    ll ans;
    bool b;
    if(s1[0]==s1[1]) {ans=6;b=1;}
    else {ans=3;b=0;}
    for(int i = 1+b;i < n;i ++){
        if(i<n-1&&s1[i]==s1[i+1]){
            ans *= (b+2);
            b = 1;
            i ++;
        }else{
            ans *= (2-b);
            b = 0;
        }
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n,a,b = list(map(int, input().split()))
s = input()
success = 0
success_b = 0
for S in s:
    if S == 'a' and success < a + b:
        print('Yes')
        success += 1
    elif S == 'b' and success < a + b and success_b < b:
        print('Yes')
        success += 1
        success_b += 1
    else:
        print('No')

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

const int N = 1e6 + 5;

int n;
char s[N];
int sum[N], pmx[N], pmi[N];

int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  sum[0] = 0;
  pmx[0] = 0;
  pmi[0] = 0;
  for (int i = 1; i <= n; i++) {
    sum[i] = sum[i - 1] + 1 - 2 * (s[i] == '0');
    pmx[i] = max(pmx[i - 1], sum[i]);
    pmi[i] = min(pmi[i - 1], sum[i]);
  }
  int suf_mi = sum[n], suf_mx = sum[n];
  int ans = pmx[n] - pmi[n];
  for (int i = n; i; i--) {
    suf_mi = min(suf_mi, sum[i]);
    suf_mx = max(suf_mx, sum[i]);
    if (s[i] == '?') {
      if (pmx[i - 1] + 1 < suf_mx) {
        suf_mx -= 2;
        suf_mi -= 2;
        ans = min(ans, max(pmx[i - 1], suf_mx) - min(pmi[i - 1], suf_mi));
      }
    }
  }
  suf_mi = sum[n], suf_mx = sum[n];
  bool found = false;
  for (int i = n; i; i--) {
    suf_mi = min(suf_mi, sum[i]);
    suf_mx = max(suf_mx, sum[i]);
    if (s[i] == '?') {
      if (pmx[i - 1] + 1 == suf_mx) {
        ans = min(ans, max(pmx[i - 1], suf_mx - 2) - min(pmi[i - 1], suf_mi - 2));
        if (!found) {
          suf_mi -= 2;
          suf_mx -= 2;
          found = true;
        }
      } else if (pmx[i - 1] + 1 < suf_mx) {
        suf_mx -= 2;
        suf_mi -= 2;
        ans = min(ans, max(pmx[i - 1], suf_mx) - min(pmi[i - 1], suf_mi));
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 16500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;
typedef pair<double, double> dd;
#define mp make_pair
#define pb push_back
#define debug(x) cerr << #x << " = " << x << " "


int n;
set<int> pos;
map<int, int> cnt;
vector<int> buf;
void go(int cur)
{
  //  cerr << "go " << cur << endl;
  for (;;)
    {
      cur <<= 1;
      if (cur < (1<<(n+1))) buf.pb(cur|1);//, cerr << "add " << (cur|1) << endl;
      else break;
    }
}
  
void solve()
{
  pos.clear();
  cnt.clear();
  pos.insert(1);
  for (int i = 0; i < (1<<n); ++i)
    {
      int u; scanf("%d", &u);
      ++cnt[-u];
    }
  for (auto e : cnt)
    {
      if (pos.size() < e.second)
	{
	  //	  cerr << "insert " << -e.first << " fail expected = " << e.second << " actual = " << pos.size() << endl;
	  puts("No");
	  return;
	}
      for (int i = 0; i < e.second; ++i)
	{
	  int cur = *pos.begin();
	  pos.erase(pos.begin());
	  go(cur);
	}
      for (auto e : buf) pos.insert(e);
      buf.clear();
    }
  puts("Yes");
}
int main()
{

  while (~scanf("%d", &n)) solve();


}


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

int main() {
   long long  sum=0;
string a; cin >> a;
  for (int bit=0;bit < (1<<a.length()-1); bit++){
     int s=0; int f=0; long long tmp = 0; 
  for (int i=0; i<a.length()-1;i++){
  	if(bit & (1 << i)){
    f = i;
    for (int j=0; j<=f-s; j++){tmp += (a.at(f-j)-'0')*pow(10,j);}
      //cout <<"tmp:"<< tmp<<endl;
    s = i+1;
    }
  }
    for (int k=0; k<a.length()-s;k++){tmp += (a.at(a.length()-k-1)-'0')*pow(10,k); //cout <<"zyou"<<(a.at(a.length()-k-1)-'0')*((int)pow(10,k))<< "tmpha"<<tmp <<endl;
                                     }
      sum += tmp; //cout << sum<<endl;
      }
  
  cout << sum;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <climits>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

const int MAX = 510000;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
    //cout << fixed << setprecision(8);
    
    int H = readInt(), W = readInt(), A = readInt(), B = readInt();
    
    COMinit();
    
    LL ans = 0;
    
    for(int i=0; i<H-A; ++i){
        ans += COM(i+B-1, i) * COM(H-(i+1)+W-(B+1), H-(i+1));
        ans %=MOD;
    }
    cout << ans << endl;
    
	return 0;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define SORT(x) sort((x).begin(),(x).end(),greater<int>())
using LL=long long;
using ULL=unsigned long long;
using PII=pair<int,int>;
const int INF = numeric_limits<int>::max();
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int N;
    cin >> N;
    vector<int> vc( N + 1 );
    REP2( i, 1, N + 1 )
    {
        cin >> vc[ i ];
    }
    int cnt{};
    REP2( i, 1, N + 1 )
    {
        if( i == vc[ i ] && i != N + 1 )
        {
            swap( vc[ i ], vc[ i + 1 ] );
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>

using namespace std;

typedef long long ll;



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

   int N;
   cin >> N;

   for(ll n=1; n < 3501; n++){
       for(ll h=1; h < 3501; h++){
           ll a = 4*h*n;
           ll b = N*(n+h);
           ll t = a - b;
           if(t <= 0)continue;
        
           if((N*n*h)%t==0){
               ll w = (N*n*h)/t;
               if(w <= 0)continue;
               printf("%d %d %lld",h,n,w);
               return 0;
           }
        
       }
   }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
int main(void){
    long long     x;
    long long     money = 100;
    int     cnt=0;
 
    scanf("%lld",&x);
    while (money < x)
    {
        money += money / 100;
        cnt++;
    }
    printf("%d\n",cnt);
    return(0);
}


Measured memory_bytes: 1732
fun main( args : Array<String> ) {
  val m = mutableMapOf<Int, Int>()
  val n = readLine()!!.toInt()
  (1..n).map {
    val o = readLine()!!.toInt()
    when {
      m[o] == null -> m[o] = o
      else -> m.remove(o)
    }
  }
  println( m.size )
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n= sc.nextInt();
		int[] color = new int[9];
		Arrays.fill(color, 0);

		for(int i = 0; i < n; i++) {
			int gt = sc.nextInt();
			if(gt >= 1 && gt <= 399) {
				color[0] = 1;
			} else if(gt >= 400 && gt <= 799) {
				color[1] = 1;
			}  else if(gt >= 800 && gt <= 1199) {
				color[2] = 1;
			}  else if(gt >= 1200 && gt <= 1599) {
				color[3] = 1;
			}  else if(gt >= 1600 && gt <= 1999) {
				color[4] = 1;
			}  else if(gt >= 2000 && gt <= 2399) {
				color[5] = 1;
			}  else if(gt >= 2400 && gt <= 2799) {
				color[6] = 1;
			}  else if(gt >= 2800 && gt <= 3199) {
				color[7] = 1;
			}  else if(gt >= 3200) {
				color[8] += 1;
			}
		}

		int min = 0;


		for(int i = 0; i < color.length - 1; i++) {
			min += color[i];
		}
		int max = min + color[8];

		if(min == 0 && color[8] >= 1) {
			min = 1;
		}

		System.out.println(min + " " + max);
	}

}


Measured memory_bytes: 23252
from heapq import heapify,heappush,heappop

T = int(input())
for _ in range(T):
  N = int(input())
  base = 0
  A = []
  C = []
  B = [0 for _ in range(N)]
  Q = []
  S = []
  for i in range(N):
    K, L, R = map(int,input().split()) 
    tmp = min(L, R)
    K -= 1
    if L > R:
      A.append((K,L-R))
    if R >= L:
      if K < N - 1:
        C.append((N-2-K,R-L))
    base += tmp
  A.sort(reverse = True)
  C.sort(reverse = True)
  #print(base)
  #print(A,C)
  
  for i in range(N):
    if len(A) == 0:
      break
    while A[-1][0] == i:
      a = A[-1][1] 
      A.pop()
      heappush(Q, a)
      if len(A) == 0:
        break
    while i+1 < len(Q):
      heappop(Q)
      if len(Q) == 0:
        break
  
  for i in range(N):
    if len(C) == 0:
      break
    while C[-1][0] == i:
      a = C[-1][1] 
      C.pop()
      heappush(S, a)
      if len(C) == 0:
        break
    while i+1 < len(S):
      heappop(S)
      if len(S) == 0:
        break
      
  print(base + sum(Q) + sum(S))
     
  """
  l = 0
  r = N-1
  for a in A:
    if a[2] == 0:
      if l < a[0]:
        l += 1
        base += a[1] 
    else:
      if r >= N-a[0]:
        r -= 1
        base += a[1]
  print(base)
  """
#print(A)

Measured memory_bytes: 99832
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll n;

    cin >> n;

    cout << n * (n - 1) / 2 << endl;
}

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

int main(){
	int N;
	int i;
	int var_a[100];
	int max;
	int min;
	int diff;
	
	
	
	
	cin >> N;
	
	for(i=0;i<N;i++)
	{
		cin >> var_a[i];
		
		if(i == 0 )
		{
			max = var_a[i];
			min = var_a[i];
		}
		
		if(max<var_a[i]){	max = var_a[i];}
		if(min>var_a[i]){	min = var_a[i];}
	}
	
	diff = max-min;
	
	cout << diff << endl;
	
	return 0;
}

Measured memory_bytes: 256
n, p = map(int, input().split())
import math

# 0以上整数x「未満」の素数をリストに格納して返す
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]

PS = primes(1000000)
def factorint(x):
  d = {}
  for k in PS:
    if(x % k== 0):
      m = 1
      while(x % (k**m) == 0):
        m += 1
      d[k] = m - 1
      x = x / (k ** (m - 1))
      if x == 1:
        break
  return d

fac = factorint(p)
result = 1
for i,j in fac.items():
  result *= i **math.floor(j/n)
if n == 1:
  result = p
print(result)

Measured memory_bytes: 44696
from itertools import accumulate

N, K = list(map(int,input().split()))
P = list(map(int,input().split()))

A = []
for i in P:
    A.append(1/2*(i+1))
    #A.append(1/2*i*(i+1)/i)

ans = 0
'''
for i in range(len(A)):
    ans = max(ans,sum(A[i:i+K]))
'''
    
accum = [0] + list(accumulate(A))
for i in range(len(accum)):
    ans = max(ans,accum[i] - accum[i-K])
print(ans)

Measured memory_bytes: 26236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m;
ll ans;
struct P
{
    ll x,y;
}pnt1[256],pnt2[256];

int cmp1(P a,P b)
{
    return a.x<b.x;
}

int cmp2(P a,P b)
{
    return a.y<b.y;
}
int vis[256];

void judge(ll lx,ll rx)
{
    ll y[256];
    int u=0,d=0;
    for(int i=0;i<n;++i)
        if(pnt2[i].x>=lx&&pnt2[i].x<=rx){
            y[u++]=pnt2[i].y;
            if(u-d==m){
                ans=min(ans,(y[u-1]-y[d])*(rx-lx));
                ++d;
            }
        }
}

int main()
{
    while(~scanf("%d%d",&n,&m)){

        for(int i=0;i<n;++i){
            scanf("%lld%lld",&pnt1[i].x,&pnt1[i].y);
            pnt2[i]=pnt1[i];
        }
        sort(pnt1,pnt1+n,cmp1);
        sort(pnt2,pnt2+n,cmp2);
        ans=1;
        for (int i=0; i<62; i++)  ans *= 2;
        int l,r;
        for(int i=0;i<n;++i)
            for(int j=i;j<n;++j)
                judge(pnt1[i].x,pnt1[j].x);
        printf("%lld\n",ans);
    }
    return 0;
}


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

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

	vector<double> v(N);
	for(int i = 0; i < N; ++i) cin >> v[i];

	sort(v.begin(), v.end(), greater<int>());

	while(v.size() > 1) {
		double first = v[v.size() - 1];
		double second = v[v.size() - 2];

		// 最小値と次に小さい値をpopする
		v.pop_back();
		v.pop_back();

		// 平均を計算する
		double avr = (first + second) / 2;

		// 出力された平均値をpush_backする
		v.push_back(avr);

		sort(v.begin(), v.end(), greater<int>());
	}

	cout << v[0] << endl;
}


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


Measured memory_bytes: 2112
#include<stdio.h>

#define MaxT 50
#define MaxP 10

int rank[MaxT];
int time[MaxT];
int correct[MaxT];
int wrong[MaxT][MaxP];

int less(int a, int b) {
    if(correct[a] != correct[b]) return correct[a] < correct[b];
    if(time[a] != time[b]) return time[a] > time[b];
    return a < b;
}

int main(void) {
    int M, T, P, R;
    int m, t, p, j;
    int i, ii;
    while(scanf("%d %d %d %d", &M, &T, &P, &R), M | T | P | R) {
        for(i = 0; i < T; i++) {
            rank[i] = i;
            time[i] = 0;
            correct[i] = 0;
            for(ii = 0; ii < P; ii++) wrong[i][ii] = 0;
        }

        for(i = 0; i < R; i++) {
            scanf("%d %d %d %d", &m, &t, &p, &j);
            t--;
            p--;
            if(j) {
                wrong[t][p]++;
            } else {
                correct[t]++;
                time[t] += m + 20 * wrong[t][p];
            }
        }

        for(i = 0; i < T; i++) {
            for(ii = 0; ii < T - i - 1; ii++) {
                if(less(rank[ii], rank[ii + 1])) {
                    rank[ii] ^= rank[ii + 1];
                    rank[ii + 1] ^= rank[ii];
                    rank[ii] ^= rank[ii + 1];
                }
            }
        }

        printf("%d", rank[0] + 1);
        for(i = 1; i < T; i++) {
            if((correct[rank[i]] == correct[rank[i - 1]]) && (time[rank[i]] == time[rank[i - 1]])) {
                printf("=");
            } else {
                printf(",");
            }
            printf("%d", rank[i] + 1);
        }
        printf("\n");
    }
    return 0;
}

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

template <uint32_t mod>
class modint{
    uint64_t value;
public:
    constexpr modint(const int64_t x=0) noexcept: value(x % mod + (x < 0 ? mod : 0)){ }
    constexpr explicit operator uint64_t() const noexcept{ return value; }
    constexpr modint inverse() const noexcept{ return pow(*this, mod-2); }
    constexpr bool operator==(const modint &rhs) const noexcept{ return value == rhs.value; }
    constexpr bool operator!=(const modint &rhs) const noexcept{ return value != rhs.value; }
    constexpr modint operator+() const noexcept{ return modint(*this); }
    constexpr modint operator-() const noexcept{ return modint(mod - value); }
    constexpr modint operator+(const modint &rhs) const noexcept{ return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const noexcept{ return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const noexcept{ return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const noexcept{ return modint(*this) /= rhs; }
    constexpr modint &operator+=(const modint &rhs) noexcept{
        if((value += rhs.value) >= mod) value -= mod;
        return *this;
    }
    constexpr modint &operator-=(const modint &rhs) noexcept{ return *this += mod - rhs.value; }
    constexpr modint &operator*=(const modint &rhs) noexcept{
        if((value *= rhs.value) >= mod) value %= mod;
        return *this;
    }
    constexpr modint &operator/=(const modint &rhs) noexcept{ return *this *= rhs.inverse(); }
    constexpr modint operator++(int) noexcept{
        modint ret(*this);
        if((++value) >= mod) value -= mod;
        return ret;
    }
    constexpr modint operator--(int) noexcept{
        modint ret(*this);
        if((value += mod - 1) >= mod) value -= mod;
        return ret;
    }
    constexpr modint &operator++() noexcept{ return *this += 1; }
    constexpr modint &operator--() noexcept{ return *this -= 1; }
    friend std::ostream &operator<<(std::ostream &os, const modint<mod> &x){ return os << x.value; }
    friend std::istream &operator>>(std::istream &is, modint<mod> &x){
        int64_t i;
        is >> i;
        x = modint<mod>(i);
        return is;
    }
    friend constexpr modint<mod> pow(const modint<mod> &x, uint64_t y){
        modint<mod> ret{1}, m{x};
        while(y > 0){
            if(y & 1) ret *= m;
            m *= m;
            y >>= 1;
        }
        return ret;
    }
};
constexpr int64_t mod = 1'000'000'007; //'

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

    int64_t n, k;
    modint<mod> ans = 0;

    cin >> n >> k;
    for(int64_t i=k;i<=n+1;++i){
        ans += n * (n + 1) / 2 - (n - i) * (n - i + 1) / 2 - (i - 1) * i / 2 + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 300003
#define MOD 998244353

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

  vector<ll> B(N);
  int small=1;
  int large=N-1;
  int left=N/2-1;
  int right=N/2+1;
  B.at(N/2)=A.at(0);
  for(int i=1;i<N;i++){
    if(i%2==1){
      if((N/2-left)%2==1){
        B.at(left)=A.at(large);
        left--;
        large--;
      }else{
        B.at(left)=A.at(small);
        left--;
        small++;
      }
    }else{
      if((right-N/2)%2==1){
        B.at(right)=A.at(large);
        right++;
        large--;
      }else{
        B.at(right)=A.at(small);
        right++;
        small++;
      }
    }
  }

  ll ans=0;
  for(int i=0;i<N-1;i++){
    ans+=abs<ll>(B.at(i+1)-B.at(i));
  }

  reverse(A.begin(),A.end());
  small=1;
  large=N-1;
  left=N/2-1;
  right=N/2+1;
  B.at(N/2)=A.at(0);
  for(int i=1;i<N;i++){
    if(i%2==1){
      if((N/2-left)%2==1){
        B.at(left)=A.at(large);
        left--;
        large--;
      }else{
        B.at(left)=A.at(small);
        left--;
        small++;
      }
    }else{
      if((right-N/2)%2==1){
        B.at(right)=A.at(large);
        right++;
        large--;
      }else{
        B.at(right)=A.at(small);
        right++;
        small++;
      }
    }
  }
  ll sum=0;
  for(int i=0;i<N-1;i++){
    sum+=abs<ll>(B.at(i+1)-B.at(i));
  }
  ans=max<ll>(ans,sum);


  cout<<ans<<endl;
}


Measured memory_bytes: 1792