akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h> 
using namespace std;

typedef long long ll;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0) 
#define rep(pp,nn) for (int ii = pp; ii < nn; ++ii)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

string int_to_string(int x) {
    stringstream ss;
	ss << x;
	string ni = ss.str();
	return ni;
}
int string_to_int(string x) {
	int n;
	stringstream s(x);
	s >> n;
	return n;
}

int64_t power_mod(ll a, ll b, ll mo) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = (ans % mo * a % mo) % mo;
		}
		a = (a % mo * a % mo) % mo;
		b /= 2;
	}
	return ans;
}
int64_t POW(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = ans * a;
		}
		a = a * a;
		b /= 2;
	}
	return ans;
}

vector<int64_t> INVERSE(int64_t nn, int64_t mo) {
	vector<int64_t> inv(nn + 1);
	vector<int64_t> mul(nn + 1);
	inv[0] = 1;
    inv[1] = 1;
	for (ll i = 2; i <= nn; ++i) {
		inv[i] = (mo - (mo / i) * inv[mo % i] % mo) % mo; 
	}
	mul[0] = 1;
	for (int i = 1; i <= nn; ++i) {
		mul[i] = (mul[i - 1] * inv[i]) % mo;
	}
	return mul;
}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int main() {
	IOS;
	int x;
	cin >> x;
	if (x > 29) {
		cout << "Yes";
	}else {
		cout << "No";
	}
}













Measured memory_bytes: 3656
#include<cstdio>
#include<algorithm>
#define MAX 200005
using namespace std;

struct A{ int par; int dis; }; 
A a[MAX];

void getp(int x){
  if(a[x].par != x){
    getp(a[x].par);
    a[x].dis += a[a[x].par].dis;
    a[x].par = a[a[x].par].par;
  }
}

int main(){
  int n, m, l, r, d, i;
  bool flag = true;
  scanf("%d%d", &n, &m);
  for(i = 1; i <= n; i++){
    a[i].par = i;
    a[i].dis = 0;
  }
  for(i = 0; i < m; i++){
    scanf("%d%d%d", &l, &r, &d);
    getp(l);
    getp(r);
    if(a[l].par == a[r].par){
      if(a[r].dis - a[l].dis != d) flag = false;
    }else{
      a[a[r].par].dis = -a[r].dis + d + a[l].dis;
      a[a[r].par].par = a[l].par;
    }
  }
  if(flag) printf("Yes\n");
  else printf("No\n");
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A , B ,C,D  ;
  
  cin >> A >> B >> C >> D ;
  
  if(A+B > C+D){
  cout << "Left" << endl;
  }
  else if (A+B == C+D) {
  cout << "Balanced" << endl;
  }
  else {
  cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).ok();
    let mut it = buf.split_whitespace();
    let n = it.next().unwrap().parse::<usize>().unwrap();
    let p : Vec<(i64, i64)> = (0..n).map(|_| (it.next().unwrap().parse().unwrap(), it.next().unwrap().parse().unwrap())).collect();
    let mut b = vec![0; 31];
    for i in 0..31 { b[i] = 1 << (30 - i as i64) }
    let mut cnt_odd = 0;
    for &pt in &p {
        cnt_odd += (pt.0.abs() + pt.1.abs()) % 2;
    }
    if cnt_odd == 0 {
        b.push(1)
    } else if cnt_odd < n as i64 {
        println!("-1");
        return;
    }
    println!("{}", b.len());
    print!("{}", b[0]);
    for i in 1..b.len() { print!(" {}", b[i]); }
    println!("");
    for &pt in &p {
        let mut x = pt.0;
        let mut y = pt.1;
        let mut res = vec!();
        let dir = [b'D', b'L', b'U', b'R'];
        for &d in &b {
            let dx = vec![0, -d, 0, d];
            let dy = vec![-d, 0, d, 0];
            let mut max_dist = 1 << 40;
            let mut min_idx = 0;
            for i in 0..4 {
                let cur_dist = (x - dx[i]).abs() + (y - dy[i]).abs();
                if cur_dist < max_dist {
                    max_dist = cur_dist;
                    min_idx = i;
                }
            }
            res.push(dir[min_idx]);
            x -= dx[min_idx];
            y -= dy[min_idx];
        }
        println!("{}", String::from_utf8(res).unwrap());
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
    int n;
    std::cin >> n;

    std::vector<int> A(n);
    for (int i = 0; i < n; i++) {
        std::cin >> A[i];
    }

    if (std::prev_permutation(A.begin(), A.end())) {
        for (auto it = A.begin(); it < A.end(); it++) {
            if (it != A.begin()) std::cout << " ";
            std::cout << *it;
        }
        std::cout << std::endl;
    }

    std::next_permutation(A.begin(), A.end());
    for (auto it = A.begin(); it < A.end(); it++) {
        if (it != A.begin()) std::cout << " ";
        std::cout << *it;
    }
    std::cout << std::endl;

    if (std::next_permutation(A.begin(), A.end())) {
        for (auto it = A.begin(); it < A.end(); it++) {
            if (it != A.begin()) std::cout << " ";
            std::cout << *it;
        }
        std::cout << std::endl;
    }
}



Measured memory_bytes: 3112
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: int, B: int, C: int):
    if A+B >= C:
        print(YES)
    else:
        print(NO)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

void go()
{
    long long int  n;
    cin>>n;
    vector<long long int> a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a.begin(),a.end());
    long long int ans=a[n-1];
    long long int k=n-2;
    long long int i;
    for(i=n-3;i>0;i-=2)
    {
        ans+=2*a[k];
        k--;
    }
    if(i==0)
        ans+=a[k];
    cout<<ans;
}
int main()
{
    //FIO;
//    int t;
//    cin>>t;
//    while(t--)
        go();
    return 0;
}


Measured memory_bytes: 4748
#include <iostream>
using namespace std;
typedef long long ll;
#define MAX 210000

int main() {
  ll N;
  ll A[MAX];
  ll sumA = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sumA += A[i];
  }

  ll halfA = 0;
  ll half = 1000000000000000000;
  for (int i = 0; i < N; i++) {
    halfA += A[i];
    if (sumA % 2 == 0) {
      if (abs(sumA / 2 - half) > abs(sumA / 2 - halfA))
        half = halfA;
      else
        half = half;
    } else if (sumA % 2 == 1) {
      if (abs(sumA / 2 - half) > abs((sumA / 2 + 1) - halfA))
        half = halfA;
      else
        half = half;
    }
  }

  ll ans = 0;

  if (half > sumA / 2) {
    ans = half - (sumA - half);
  } else if (half < sumA / 2) {
    ans = (sumA - half) - half;
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

using ll = long long;

constexpr double EPS = 1e-6;

int sign(double x) {
    if(x < -EPS) return -1;
    if(x > +EPS) return +1;
    return 0;
}

// https://ei1333.github.io/luzhiled/snippets/geometry/template.html
using Real = double;
using Point = std::complex< Real >;
inline bool eq(Real a, Real b) { return fabs(b - a) < EPS; }
struct Circle {
	Point p;
	Real r;
 
	Circle() = default;
 
	Circle(Point p, Real r) : p(p), r(r) {}
};
 
int intersect(Circle c1, Circle c2) {
	if (c1.r < c2.r) std::swap(c1, c2);
	Real d = abs(c1.p - c2.p);
	if (c1.r + c2.r < d) return 4;
	if (eq(c1.r + c2.r, d)) return 3;
	if (c1.r - c2.r < d) return 2;
	if (eq(c1.r - c2.r, d)) return 1;
	return 0;
}

std::pair< Point, Point > crosspoint(const Circle& c1, const Circle& c2) {
	Real d = abs(c1.p - c2.p);
	Real a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d));
	Real t = atan2(c2.p.imag() - c1.p.imag(), c2.p.real() - c1.p.real());
	Point p1 = c1.p + Point(cos(t + a) * c1.r, sin(t + a) * c1.r);
	Point p2 = c1.p + Point(cos(t - a) * c1.r, sin(t - a) * c1.r);
	return { p1, p2 };
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, K;
    cin >> n >> K;
    vector<int> x(n), y(n), c(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i] >> c[i];
    }

    vector<Point> ps;
    for (int i = 0; i < n; ++i) {
        ps.emplace_back(x[i], y[i]);
    }

    double ng = -1, ok = 1e9;
    for (int loop = 0; loop < 100; ++loop) {
        double mid = (ok + ng) / 2;
        vector<Circle> cs;
        for (int i = 0; i < n; ++i) {
            cs.emplace_back(ps[i], mid / c[i]);
        }

        bool f = false;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < i; ++j) {
                int is = intersect(cs[i], cs[j]);
                if (is == 0 || is == 4) continue;
                auto tmp = crosspoint(cs[i], cs[j]);
                for (const Point& p : {tmp.first, tmp.second}) {
                    int cnt = 0;//2;
                    for (int k = 0; k < n; ++k) {
                        //if (k == i || k == j) continue;
                        double d = c[k] * abs(p - ps[k]);
                        cnt += (sign(mid - d) >= 0);
                    }
                    if (cnt >= K) {
                        f = true;
                        break;
                    }
                }
                if (f) break;
            }
            if (f) break;
        }

        for (const Point& p : ps) {
            int cnt = 0;
            for (int k = 0; k < n; ++k) {
                double d = c[k] * abs(p - ps[k]);
                cnt += (sign(mid - d) >= 0);
            }
            if (cnt >= K) {
                f = true;
                break;
            }                    
        }

        (f ? ok : ng) = mid;
    }

    cout << fixed << setprecision(15) << ok << "\n";
    return 0;
}

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

int main()
{
  int h, w;
  cin >> h >> w;
  
  vector<char> plate(h * w);
  vector<int> w_flag(w);
  vector<int> h_flag(h);
  for (int j = 0; j < h; j ++)
  {
    for (int i = 0; i < w; i ++)
    {
      int pos = j * w + i;
      cin >> plate.at(pos);
      if (plate.at(pos) == '#')
      {
        w_flag.at(i) = true;
        h_flag.at(j) = true;
      }
    }
  }
  
  for (int j = 0; j < h; j ++)
  {
    if (!h_flag.at(j)) continue;
    for (int i = 0; i < w; i ++)
    {
      if (!w_flag.at(i)) continue;
      cout << plate.at(j * w + i);
    }
    cout << endl;
  }
  
  return 0;
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int H,W;
    cin >> H >> W;
    vector<vector<char>> c(H,vector<char> (W));

    rep(h,H) {
        string tmp;
        cin >> tmp;
        rep(w,W) {
            c[h][w] = tmp[w];
        }
    }
    vector<vector<int>> dp(H,vector<int> (W,INF));

    rep(h,H) {
        rep(w,W) {
            if (h==0 && w == 0) {
                if (c[h][w] == '#') dp[h][w] = 1;
                else dp[h][w] = 0;
            }
            else if (h==0) {
                if (c[h][w-1]!=c[h][w]) dp[h][w] = min(dp[h][w],dp[h][w-1]+1);
                else dp[h][w] = min(dp[h][w],dp[h][w-1]); 
            }
            else if (w==0) {
                if (c[h-1][w]!=c[h][w]) dp[h][w] = min(dp[h][w],dp[h-1][w]+1);
                else dp[h][w] = min(dp[h][w],dp[h-1][w]);
            }
            else {
                if (c[h-1][w]!=c[h][w]) dp[h][w] = min(dp[h][w],dp[h-1][w]+1);
                else dp[h][w] = min(dp[h][w],dp[h-1][w]);

                if (c[h][w-1]!=c[h][w]) dp[h][w] = min(dp[h][w],dp[h][w-1]+1);
                else dp[h][w] = min(dp[h][w],dp[h][w-1]); 

            }
        }
    }
    int ans = dp[H-1][W-1];
    if (c[H-1][W-1]=='#') ans++;
    ans = ans/2;
    cout << ans << endl;
}


Measured memory_bytes: 3684
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, x;
	cin >> n >> x;
	vi v(n);
	REP(i, n)cin >> v[i];
	sort(ALL(v), greater<>());
	vl dp(x + 1, 0);
	dp[x] = 1;
	REP(i, n) {
		vl next(x + 1, 0);
		REP(j, x + 1) {
			next[j%v[i]] += dp[j];
		}

		if (i != n - 1) {
			REP(j, x + 1) {
				next[j] += dp[j] * (n - i - 1) % MOD;
			}
		}
		REP(j, x + 1)next[j] %= MOD;
		dp = move(next);
	}
	ll ans = 0;
	REP(i, x + 1) {
		ans += i * dp[i] % MOD;
	}
	cout << ans % MOD << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  vector<int> x(100005);
  for(int i = 0; i < N; i++){
    if(a[i] == 0){
      x[1]++;
    }else{
      x[a[i]-1]++;
      x[a[i]]++;
      x[a[i]+1]++;
    }
  }
  cout << *max_element(x.begin(), x.end()) << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "YES";
    private static final String NO = "NO";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        System.out.println(solve(S));
    }

    private static long solve(String S) {
        int[][] dp = new int[S.length()+1][13];

        dp[S.length()][0] = 1;
        int mul = 1;

        for (int i=S.length()-1; i>=0; i--) {
            if (S.charAt(i) == '?') {
                for (int k=0; k<10; k++) {
                    for (int j=0; j<13; j++) {
                        int p = (mul*k + j) % 13;

                        dp[i][p] += dp[i+1][j];
                        dp[i][p] %= MOD;
                    }
                }
            } else {
                int k = S.charAt(i)-'0';

                for (int j=0; j<13; j++) {
                    int p = (mul*k + j)%13;
                    dp[i][p] += dp[i+1][j];
                    dp[i][p] %= MOD;
                }
            }

            mul *= 10;
            mul %= 13;
        }

        return dp[0][5]%MOD;
    }
}

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

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

    double max = (double)W * H / 2;
    int flag = 0;
    if(2 * x == W && 2 * y == H){
        flag = 1;
    }
    
    printf("%.10f %d\n", max, flag);

    return 0;
}

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

#define       pb                 push_back
#define       sf                 scanf
#define       pf                 printf
#define       mx                 200005
#define       MOD                1000000007
#define 	  optimize           ios::sync_with_stdio(0);cin.tie(0);
#define 	  inf                0x3f3f3f3f
#define       READ               freopen("in.txt", "r", stdin);
#define       WRITE              freopen("out.txt", "w", stdout);

using namespace std;

typedef       long long int      ll;
typedef       vector<int> 	     vi;

int dx[] = {0, 0, +1, -1};
int dy[] = {+1,-1, 0,  0};
/*============GRAPH MOVES==================*/
//const int fx[] = {1, -1, 0, 0};
//const int fy[] = {0, 0, 1, -1};
//const int fx[] = {0, 0, 1, -1, -1, 1, -1, 1};  // Kings move
//const int fy[] = {-1, 1, 0, 0, 1, 1, -1, -1};  // Kings move
//const int fx[] = {-2, -2, -1, -1, 1, 1, 2, 2}; // Knights move
//const int fy[] = {-1, 1, -2, 2, -2, 2, -1, 1}; // Knights move
/*=========================================*/

inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline bool isLeapYear(ll year) { return (year%400==0) || (year%4==0 && year%100!=0); }
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }
inline ll mod(ll a, ll m){ if(a<0) return m-(abs(a)%m); else if(a<m) return a; else return (a%m); }
inline string tstring(ll a) {stringstream ss; ss << a; string str = ss.str(); return str; }


int main()
{
	int n;

	string s;

	cin >> n >> s;

	if((n%2))
    {
        cout << "No" << endl;
        return 0;
    }

	for(int i = 0, j = n/2; i < n/2; i++, j++)
    {
        if(s[i]!=s[j])
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;


    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    for (int i = 1; i < 10; i++){
      if (N % i == 0 & N / i < 10){
        System.out.println("Yes");
        break;
      } else if (i ==9) {
        System.out.println("No");
      }
    }
  }
}

Measured memory_bytes: 23636
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N, H = getNM()

a = []
b = []

for i in range(N):
  x, y = map(int, input().split())
  a.append(x)
  b.append(y)

# 振った場合の最大値
max_a = max(a)

ans = 0
# 振る刀の最大攻撃力より高い攻撃力を持つ投げ刀を高い順にソートする
# 刀iで好きなだけ振って攻撃する→気が済んだら投げることで振りの攻撃力と投げの攻撃力を
# 両方利用することができる
# 実は投げてしまった刀も振ることができるというルールに変更しても
# 問題の答えは変わらない
# 実際のムーブとしては
# ①最も攻撃力が高い振り刀で攻撃する
# ②一定の体力以下になると攻撃力が高い順に投げ刀で攻撃していって撃破
# という流れになる
for x in reversed(sorted(filter(lambda x: x >= max_a, b))):
    H -= x
    ans += 1
    if H <= 0: break

ans += max(0, (H + max_a - 1) // max_a)
print(ans)

Measured memory_bytes: 55388
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
int l[100005], r[100005];
int p1[100005], p2[100005];
bool vis[100005];

bool cmp1(const int a, const int b){
	return l[a] > l[b];
}
bool cmp2(const int a, const int b){
	return r[a] < r[b];
}

int main(){
	int n;
	scanf("%d", &n);
	LL ans = 0, ans1 = 0, ans2 = 0;
	for(int i=1;i<=n;i++){
		scanf("%d%d", &l[i], &r[i]);
		p1[i] = i, p2[i] = i;
	}

	sort(p1+1, p1+1+n, cmp1);
	sort(p2+1, p2+1+n, cmp2);

	int cur1 = 0, cur2 = 0;
	int c1 = 1, c2 = 1;
	for(int i=1;i<=n;i++){
		if(i%2 == 1){
			while(vis[p1[c1]]) c1++;
			vis[p1[c1]] = 1;
			if(cur1 >= l[p1[c1]] && cur1 <= r[p1[c1]]) continue;
			ans1 += abs(cur1-l[p1[c1]]);
			cur1 = l[p1[c1]];
		}
		else{
			while(vis[p2[c2]]) c2++;
			vis[p2[c2]] = 1;
			if(cur1 >= l[p2[c2]] && cur1 <= r[p2[c2]]) continue;
			ans1 += abs(cur1-r[p2[c2]]);
			cur1 = r[p2[c2]];
		}
	}
	ans1 += abs(cur1);
	c1 = 1, c2 = 1;
	memset(vis, 0, sizeof(vis));
	for(int i=1;i<=n;i++){
		if(i%2 == 1){
			while(vis[p2[c2]]) c2++;
			vis[p2[c2]] = 1;
			if(cur2 >= l[p2[c2]] && cur2 <= r[p2[c2]]) continue;
			ans2 += abs(cur2-r[p2[c2]]);
			cur2 = r[p2[c2]];
		}
		else{
			while(vis[p1[c1]]) c1++;
			vis[p1[c1]] = 1;
			if(cur2 >= l[p1[c1]] && cur2 <= r[p1[c1]]) continue;
			ans2 += abs(cur2-l[p1[c1]]);
			cur2 = l[p1[c1]];
		}
	}
	ans2 += abs(cur2);
	ans = max(ans1, ans2);
	printf("%lld\n", ans);
}

Measured memory_bytes: 1920
import math
r = 9999
sqrt = int(math.sqrt(r))
p = [1 for i in range(r)]
p[0] = 0
for i in range(sqrt):
    if p[i]:
        p[2*i+1::i+1] = [0 for j in range(2*i+1,r,i+1)]
prime = []
for i in range(r):
    if p[i]:
        prime.append(i)

while True:
    try:
        n = int(raw_input())
        count = 0
        for i in prime:
            if i > n-1:
                break
            if p[i]*p[n-i-1] == 1:
                count += 1
        print count
    except:
        break

Measured memory_bytes: 4764
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 10 ** 9 + 7

def cmb(n, k):
    if k < 0 or k > n: return 0 
    return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] % MOD

def cumprod(arr, MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]; arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv

def permutation(n, x, mod=10**9+7):
    # nPx 順列　ex) permutaion(5, 2) = 20
    tmp = 1
    for i in range(n, n-x, -1):
        tmp = (tmp * i) % mod
    return tmp

U = 10 ** 5 + 10 # 階乗テーブルの上限
fact, fact_inv = make_fact(U, MOD)

N, K = lr()
graph = [[] for _ in range(N+1)] # 1-indexed
for _ in range(N-1):
    a, b = lr()
    graph[a].append(b)
    graph[b].append(a)

answer = K # rootの色の塗り方
if K-1-len(graph[1]) < 0:
    answer = 0
else:
    answer *= fact[K-1] * fact_inv[K-1-len(graph[1])] % MOD
answer %= MOD
root = 1
stack = []
for child in graph[1]:
    if len(graph[child]) > 1:
        stack.append((child, 1))
while stack:
    cur, p = stack.pop()
    l = len(graph[cur])
    if K-2-(len(graph[cur])-1) < 0:
        answer = 0
    elif l > 1:
        answer *= fact[K-2] * fact_inv[K-2-(len(graph[cur])-1)] % MOD
    for child in graph[cur]:
        if child == p:
            continue
        stack.append((child, cur))
    answer %= MOD

print(answer%MOD)
# 10


Measured memory_bytes: 47328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

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

	int a, b;
	cin >> a >> b;
	string str;
	int count = 0;
	for (int i = a; i <= b; i++) {
		str = to_string(i);
		if (str[0] == str[4] && str[1] == str[3]) {
			count++;
		}
	}
	cout << count << "\n";

	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (x,y,z) = readLine()!!.split(" ").map(String::toInt)
    val a = mutableListOf<Int>()
    for (i in 0 until y){
        a.add(x * i % y)
    }
    var r = if(a.contains(z)) "YES" else "NO"
    println(r)
}

Measured memory_bytes: 37696
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())
mod = 10**9+7

SUM = sum(As)
ans = 0
for i in range(N):
    a = As[i]
    ans += (SUM-a)*a
    ans %= mod
print(ans*pow(2, mod-2, mod)%mod)

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

int main() {
    int n, m;
    cin >> n >> m;
    int x = ((1900 * m + 100 * (n - m)) * pow(2, m));
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define AIMAX 10000

int main(void)
{
	int i, j, n, a, cnt, flag=0;
	int C[AIMAX+1]={0};
	
	scanf("%d",&n);
	for(i=0; i<n; i++) {
		scanf("%d",&a);
		C[a]++;
	}
	
	for (i=0; i<=AIMAX; i++) {
		cnt = C[i];
		for (j=0; j<cnt; j++) {
			if(flag) printf(" ");
			else flag = 1;
			printf("%d",i);
		}
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  rep(i,a+1){
    rep(j,b+1){
      rep(k,c+1){
        if(i*500 + j*100 + k*50 == x)ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

template <class S>
void print(vector<S> &v) {
  for (ll i = 0; i < (ll)v.size(); i++) {
    cout << v[i] << ' ';
  }
  cout << endl;
}

int main(void) {
  int n, k, c;
  string s;
  cin >> n >> k >> c;
  cin >> s;
  vector<int> l(k);
  vector<int> r(k);
  int day = 0;
  int work = 0;
  while (day < n && work < k) {
    if (s[day] == 'o') {
      l[work++] = day;
      day += c;
    }
    day++;
  }
  day = n - 1;
  work = k - 1;
  while (day >= 0 && work >= 0) {
    if (s[day] == 'o') {
      r[work--] = day;
      day -= c;
    }
    day--;
  }
  rep(i, k) {
    if (l[i] == r[i]) cout << l[i]+1 << endl;
  }
}

Measured memory_bytes: 3332
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e15;
const ll MOD=1000000007;

int main(){
    int N;cin>>N;
    rep(i,50000){
        if((ll)(i*1.08)==N){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<":("<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define long int64_t
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef priority_queue<pii, vector<pii>, greater<pii>> min_pq;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OST;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> dis(0, INF<<1);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args)
{ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma+1, args...); }

const int N = 101;

int main()
{
	fio;
	int n;
	cin >> n;
	int v = n + ((n & 1) ^ 1);
	vector<pii> ans;
	for(int i=1; i<=n; i++)
		for(int j=i+1; j<=n; j++)
			if(i + j != v)
				ans.pb(mp(i, j));
	cout << ans.size() << endl;
	for(pii it : ans)
		cout << it.ff << ' ' << it.ss << endl;
	return 0;
}

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

int n;
vector<int> a;

int gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

int l(int i) { // a[1]...a[i-1]のgcd
    if (i == 1) return  a[i];
    return gcd(l(i-1), a[i-1]);
}

int r(int i) { // a[i+1]...a[n]のgcd
    if (i == n-1) return  a[i+1];
    return gcd(a[i+1], r(i+1));
}

int m(int i) {
    if (i == 1) return r(i);
    if (i == n) return l(i);
    return gcd(l(i), r(i));
}

int main() {
    cin >> n;
    a.resize(n+1);
    rep(i, n+1) {
        if (i == 0) continue;
        cin >> a[i];
    }
    int max_v = 0;

    vector<int> l(n+1), r(n+1), m(n+1);
    for (int i = 2; i <= n; i++) {
        l[i] = gcd(l[i-1], a[i-1]);
    }
    for (int i = n-1; i >= 1; i--) {
        r[i] = gcd(a[i+1], r[i+1]);
    }
    for (int i = 1; i <= n; i++) {
        // if (i == 1) m[i] = r[i];
        // else if (i == n) m[i] = l[i];
        // else m[i] = gcd(l[i], r[i]);
        m[i] = gcd(l[i], r[i]);
        max_v = max(m[i], max_v);
    }
    for (int i = 1; i <= n; i++) {
        // max_v = max(m(i+1), max_v);
        // max_v = max(m[i], max_v);
    }
    printf("%d\n", max_v);
}

Measured memory_bytes: 4800
// --------------
// Tejas Pandey  |
// 11 - 04 - 20  |
// Atcoder BC 162|
// --------------

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

#define mod 1000000007
#define lim 1000000000000000000
#define vi vector<int>
typedef long long int ll;

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

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

int main (void)
{
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  //cin >> t;
  while(t--){
  	//cout << "Case :" << c - t << ": ";
  	int n;
  	cin >> n;
  	ll a[n];
  	for(int i = 0;i < n;i++) cin >> a[i];
  	ll dp[2 + (n&1)][n/2];
  	ll su[2 + (n&1)];
  	memset(dp,0,sizeof(dp));
  	ll ans = -lim;
  	for(int i = 0;i < 2 + (n&1);i++){
  		ll sum = 0,cur = 0;
  		for(int j = i;j < i + (n/2)*2;j += 2)
  			sum += a[j],dp[i][cur] = sum,cur++;
  		//cout << cur << "\n";
  		su[i] = sum;
  		ans = max(ans,sum);
  	}
  	for(int i = 0;i < 1 + (n&1);i++){
  		ll cur = 0;
  		for(int j = i;j < i + (n/2 - 1)*2;j += 2){
  			for(int k = 0;k < 2 + (n&1);k++)
  				ans = max(ans,dp[i][cur] + su[k] - dp[k][cur]);
  			cur++;
  		}
  	}
  	if(n&1){
  		for(int i = 1;i < 2;i++){
  			ll cur = n/2 - 1;
  			dp[i][cur] = max(a[1 + cur*2],a[2 + cur*2]);
  			while(cur--){
  				dp[i][cur] = a[1 + cur*2] + max(dp[i][cur + 1],su[i + 1] - dp[i + 1][cur]);
  			}
  		}
  		for(int i = 0;i < 1;i++){
  		ll cur = 0;
  			for(int j = i;j <= i + (n/2 - 1)*2;j += 2){
  				for(int k = 1;k < 1 + (n&1);k++)
  					ans = max(ans,dp[i][cur] + dp[k][cur + 1]);
  				cur++;
  			}
  	    }
  	}
  	cout << ans;
  }
  return 0;
}

Measured memory_bytes: 7524
#include <stdio.h>
int main(){
  int n, c[551]={}, s[551]={}, f[551]={}, ans=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d%d%d",&c[i],&s[i],&f[i]);
  }
  for(int i=0;i<n;i++){
    for(int j=i;j<n-1;j++){
      if(ans<s[j]){
        ans=s[j]+c[j];
      }
      else{
        if(ans%f[j]!=0){
          ans+=f[j]-ans%f[j];
        }
        ans+=c[j];
      }
    }
    printf("%d\n",ans);
    ans=0;
  }
  return 0;
}


Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		boolean flg = true;

		ArrayList<Integer> weightList = new ArrayList<Integer>();
		ArrayList<Integer> heightList = new ArrayList<Integer>();

		while (flg) {
			scanner.hasNext();
			int h = scanner.nextInt();
			int w = scanner.nextInt();

			if ((h == 0) && (w == 0)) {
				flg = false;
				break;
			}

			// Integer????????°??????????????????
			weightList.add(Integer.valueOf(w));
			heightList.add(Integer.valueOf(h));
		}

		for(int i=0; i<weightList.size(); i++){

			for(int k = 0; k<heightList.get(i); k++){
				for(int j=0; j<weightList.get(i); j++){
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}

	}
}

Measured memory_bytes: 26772
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[][] board = new char[n + 1][];
		for(int i = 0; i < n + 1; i++) {
			board[i] = sc.next().toCharArray();
		}
		int sum = 0; //print
		for(int i = 1; i <= n; i++) {//?????????????????£????????????
			out: for(int j = 0; j < board[i].length; j++) {//1??????????????¢?´¢
				if(board[i][j] == board[0][0]) {
					for(int k = j + 1; k < board[i].length; k++) {//2??????????????¢?´¢
						if(board[i][k] == board[0][1]) {
							int interval = k - j;//1???????????¨2??????????????????
							int cnt = 2;//?????????????????¢?´¢???????????????
							for(int m = k + interval; m < board[i].length; m = m + interval) {//3???????????\????????¢?´¢
								if(board[i][m] == board[0][cnt]) {
									cnt = cnt + 1;
									if(cnt == board[0].length) {
										sum = sum + 1;
										break out;
									}
								} else {
									break;
								}
							}
						}
					}
				}
			}
		}
		System.out.println(sum);
	}

}

Measured memory_bytes: 27644
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
ll N,M,K;
  cin>>N>>M>>K;
  vector<ll> A(N);
  vector<ll> B(M);
  for(ll i=0;i<N;i++) {
    cin>>A[i];
  }
  for (ll i=0;i<M;i++) {
cin>>B[i];
  }
ll Aindex=-1;
  ll Bindex=-1;
  ll min=0;
  for(ll i=0;i<N;i++) {
if(min+A[i]<=K) {
min+=A[i];
  Aindex=i;
}
 else {
   break;
 }
  }
  
  for(ll i=0;i<M;i++) {
if(min+B[i]<=K) {
  min+=B[i];
  Bindex=i;
}
    else {
break;
    }
  }
  
  ll ans=Aindex+Bindex+2;
  
  while(Aindex>=0) {
min-=A[Aindex];
    Aindex--;
    ll index=Bindex;
    
    for(ll i=index+1;i<M;i++) {
      if(min+B[i]<=K) {
min+=B[i];
        Bindex=i;
      }
      else {
break;
      }
    }
    if(ans<Aindex+Bindex+2) {
      ans=Aindex+Bindex+2;
    }

  }
  
  cout<<ans<<endl;
}
    
     

  
  
  
  
  
  
  


Measured memory_bytes: 6408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}

	Scanner cin;

	const int MOD = 1000000007;
	const int INF = int.MaxValue - 10;
	const long INFL = long.MaxValue - 10;
	const double EPS = 1e-8;
	const double PI = 3.1415926536;
	int[,] dir8;
	int[,] dir4;



	void prog()
	{
		cin = new Scanner();
		dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		long A = cin.nextLong();
		char op = cin.next()[0];
		long B = cin.nextLong();
		if (op == '+')
		{
			Console.WriteLine(A+B);
		}
		else
		{
			Console.WriteLine(A-B);
		}
	}
}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

Measured memory_bytes: 2776
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int n,m;
int main()
{
    n=read(),m=read();
    for(reg int i=0;i<=1000;++i)
    {
        if(i*n-i+1>=m)
        {
            cout<<i<<"\n";return 0;
        }
    }
	return 0;
}


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

/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)

/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define MP make_pair 

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

/* func */
int gcd(int a,int b){return b?gcd(b,a%b):a;}

/*struct*/
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

//#define int ll
//#define int long long

signed main()
{
  int a,b,c; cin >> a >> b >> c;
  int cnt= 0;
  
  while(b/a>=1){
   b-= a;
    
    ++cnt;
    if(cnt == c)
      break;
    
  }
  cout << cnt;
  return 0;
}

Measured memory_bytes: 256
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[] p = new int[n];
		int sum = 0;
		for(int i = 0;i < n;i ++) {
			p[i] = sc.nextInt();
			sum += p[i];
		}
		Arrays.sort(p);	
		System.out.println(sum - (p[n-1]/2));
	}
}

Measured memory_bytes: 22100
#include<iostream>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<string>
using namespace std;

int main(){
    int A,B,X;
    cin>>A;
    cin>>B;
    abs(X=A-B);
    if(A<9&&B<9&&A+B<17){
    if(X<3){
        cout<<"Yay!"<<endl;
    }
    else{
        cout<<":("<<endl;
    }
    }
    else{
                cout<<":("<<endl;
    }
    
}


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

int main() {
	int L, N;
	string s[1001];
	cin >> N >> L;
	for (int i = 0; i < N; i++) {
		cin >> s[i];
	}
	sort(s, s + N);
	for (int i = 0; i < N; i++) {
		cout << s[i];
	}
	cout << endl;
}



Measured memory_bytes: 256
N = int(input())

def abc(a, b, c):
    return a**2 + b**2 + c**2 + a*b + b*c + c*a

for n in range(1, N+1):
    ans = 0
    for a in range(1, 101):
        if 6*a**2 < n:
          continue
        if abc(a, 1, 1) > n:
            break
        for b in range(1, a+1):
            if abc(a, b, 1) > n:
                break
            for c in range(1, b+1):
                if abc(a, b, c) == n:
                    if a == b and b == c:
                        ans += 1
                    elif a == b or b == c:
                        ans += 3
                    else:
                        ans += 6
                elif abc(a, b, c) > n:
                    break
    print(ans)

Measured memory_bytes: 71460
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
using namespace std;

int main(){
  ll N,ans=0ll,cnt=0ll;
  cin>>N;
  ll A[N],DP[N+1][N+1];
  REP(i,N) cin>>A[i];
  REP(i,N+1){
    REP(j,N+1){
      DP[i][j]=0;
    }
  }
  
  vector<pair<ll,ll>> P;
  REP(i,N) P.push_back(make_pair(A[i],i));
  SORT(P);
  REVERSE(P);
  
  
  
  for(int i=0; i<N; ++i){
    for(int j=0; j<=i; ++j){
      DP[j+1][i-j]=max(DP[j+1][i-j],DP[j][i-j]+P[i].first*abs(P[i].second-j));
      DP[j][i-j+1]=max(DP[j][i-j+1],DP[j][i-j]+P[i].first*abs(P[i].second-N+i-j+1));
    }
  }
  
  for(int i=0; i<=N; ++i){
    if(ans<DP[i][N-i]) ans=DP[i][N-i];
  }
  
  cout<<ans<<endl;
  return 0;
}

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

long long int mod_pow(long long int n, long long int p, long long int mod)
{
    if (p == 0)
    {
        return 1;
    }
    if (p % 2 == 0)
    {
        // long long int t = mod_pow(n, p / 2, mod);
        //return mod_pow(mod_pow(n, p / 2, mod), 2, mod) % mod;
        return mod_pow(n * n % mod, p / 2, mod) % mod;
    }
    return (n * mod_pow(n, p - 1, mod)) % mod;
}

//x*(x-1)*(x-2)*...*(x-k+1)
long long int permutation(long long int x, long long int k, long long int mod)
{
    long long int ans = 1;

    for (long long int i = 0; i < k; i++)
    {
        ans *= x - i;
        ans %= mod;
    }

    return ans;
}

long long int factorial(long long int n, long long int mod)
{
    return permutation(n, n, mod);
}

long long int combination(long long int n, long long int k, long long int mod)
{
    long long int X, Y;

    X = permutation(n, k, mod);
    Y = factorial(k, mod);

    long long int inverse_Y = mod_pow(Y, mod - 2, mod);

    return (X * mod_pow(Y, mod - 2, mod)) % mod;
}

int main()
{
    /* ------- 宣言と入力 ------- */

    long long int n, a, b;

    cin >> n >> a >> b;

    /* ------- 計算 ------- */

    long long int mod = 1000000007;

    long long int ans;

    ans = mod_pow(2, n, mod);

    a = min(a, n - a);
    b = min(b, n - b);

    long long int nCa = combination(n, a, mod);
    long long int nCb = combination(n, b, mod);
    long long int nC0 = combination(n, 0, mod);

    ans -= (nCa + nCb + nC0) % mod;

    if (ans < 0)
    {
        ans += mod;
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    int N;
    cin >> N;
    int a[N];
    for (int i=0; i < N; i++) cin >> a[i];
    int test = a[0];
    for (int j=1; j<N; j++){
        test ^= a[j];
    }
    if (test==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 640
module Main where
--import Debug.Trace
import Data.List
import Data.Array
import Data.Maybe
import Data.Ord
import Control.Monad

solve :: [[Int]] -> String
solve notes = toString (iter (listArray ((1,1,1), (4,3,10)) (replicate 120 0)) notes) (range ((1,1,1), (4,3,10))) where
    toString ar = iterS 0 0 where
        iterS _ _ [] = []
        iterS pb pf ((b, f, r):xs)
            | pb == b && pf == f = ' ':show (ar ! (b,f,r)) ++ iterS pb pf xs
            | pb == b && pf /= f = '\n':' ':show (ar ! (b,f,r))++ iterS pb f xs
            | otherwise = '\n':replicate 20 '#' ++ '\n':' ':show (ar ! (b,f,r))++ iterS b f xs
    iter ar [] = ar
    iter ar ([b, f, r, v]:xs) = iter (ar // [((b, f, r), ar ! (b,f,r) + v)]) xs

readLine:: IO [Int]
readLine = fmap (map read . words) getLine

readLines :: Int -> IO [[Int]]
readLines 0 = return []
readLines n = readLine >>= (\a -> fmap (a:) (readLines (pred n)))

main :: IO() 
main = do
    [n] <- readLine
    l  <- readLines n
    putStrLn $ drop 22 (solve l)



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

using namespace std;

int main() {
  string s;
  cin >> s;
  deque<char> dq(s.begin(), s.end());
  bool remained(true);
  int q, t, f;
  char c;
  cin >> q;
  while (q--) {
    cin >> t;
    if (t == 1) remained = !remained;
    else {
      cin >> f >> c;
      remained ^ (f - 1) ? dq.push_front(c) : dq.push_back(c);
    }
  }
  
  while (!dq.empty()) {
    cout << (remained ? dq.front() : dq.back());
    remained ? dq.pop_front() : dq.pop_back();
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 896
# -*- coding: utf-8 -*-

# input
N = int(input())
d = list(map(int, input().split()))

# solve
ans = 0
d = sorted(d)
center = int(N / 2)
if d[center - 1] != d[center]:
    for i in range(d[center] - d[center - 1]):
        ans += 1

# output
print(ans)


Measured memory_bytes: 14556
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    int N, A, B;

    cin >> N >> A >> B;

    cout << min(A, B) << " " << max(A+B-N, 0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,ans=0,i;
	string s;
	cin >> s;
	n = s.l_ength();
	for(i=1; i<n; ++i){
		if(s[i-1]!=s[i]){
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;

int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	int L, R;
	int l=-1e9, r=1e9;
	for (int i = 0; i < m; i++){
		scanf("%d %d", &L, &R);
		L = max(L, l);
		l = L;
		R = min(r, R);
		r = R;
	}
	if (R - L + 1 < 0) {
		printf("0");
		return 0;
	}
	printf("%d",R-L+1);
	
}

Measured memory_bytes: 1724