akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) ((int)a.size())
#define pow2(n) (n * n)
#define int ll
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-8;
ll mod = static_cast<ll>(1e9 + 7);
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, std::forward<Args>(args)...); }
};
template <class F>
constexpr decltype(auto) funcs(F &&f) { return FixPoint<F>{std::forward<F>(f)}; }
template <class T>
std::vector<T> vecs(int n, T &&val) { return std::vector<T>(std::forward<int>(n), std::forward<T>(val)); }
template <class... Args>
decltype(auto) vecs(int n, Args &&... args) { return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...)); }
template <class V, class T>
void fill(V &x, const T &val) { x = val; }
template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    int x;
    cin >> x;
    cout << !x << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3636
n = int(input())
A = 0
W = 0
T = 0
R = 0
for i in range(n):
  i = input()
  if i[0] == 'A':
    A += 1
  elif i[0] == 'W':
    W += 1
  elif i[0] == 'T':
    T += 1
  elif i[0] == 'R':
    R += 1
print('AC x {}'.format(A))
print('WA x {}'.format(W))
print('TLE x {}'.format(T))
print('RE x {}'.format(R))

Measured memory_bytes: 69892
import java.io.*;

class Main
{
	public static void main(String args[]) throws IOException
	{
		BufferedReader br =
			new BufferedReader(new InputStreamReader(System.in));
		
		String str1 = br.readLine();
		String str2[] = str1.split(" ");
		int a = Integer.parseInt(str2[0]);
		int b = Integer.parseInt(str2[1]);
		int c = a*b;
		int d = 2*(a+b);
		System.out.println(c+" "+d);
	}
}

Measured memory_bytes: 24276
A, B = map(int, input().split())
S = input()

flag = False
if S[A] == '-':
    S_ = S.split('-')
    if len(S_) == 2:
        if len(S_[0]) == A and len(S_[1]) == B:
            if S_[0].isdigit() and S_[1].isdigit():
                flag = True

if flag:
    print('Yes')
else:
    print('No')

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

int main(){
  int A;
  cin >> A;
  if(A/100==1){
    cout << 9;
  }
  else{
    cout << 1;
  }
  if((A%100-A%10)/10==1){
    cout << 9;
  }
  else{
    cout << 1;
  }
  if(A%10==1){
    cout << 9;
  }
  else{
    cout << 1;
  }
}

Measured memory_bytes: 3600
N,M,X,Y = map(int,input().split())
x_list = list(map(int,input().split()))
y_list = list(map(int,input().split()))

for i in range(max(x_list)+1,min(y_list)+1):
  if i > X and i <= Y and max(x_list) < i and min(y_list) >= i:
    print('No War')
    break
else:
  print('War')

Measured memory_bytes: 3064
use text_io::*;
use std::collections::HashMap;
use std::process::exit;

fn main() {
    let k: usize = read!();
    let mut v = 0;
    let mut n = 0;
    let mut a = 0;
    if k%2==0 {
        println!("-1");
        exit(0);
    }
    if k%5==0 {
        println!("-1");
        exit(0);
    }
    while v != 0 || a == 0{
        v = ((v*10)+7) % k;
        n += 1;
        a = 1;
    }
    println!("{}",n);
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,T; cin>>N>>T;
    vint t(N+1);
    REP(i,N) cin>>t[i];
    t[N]=1e18;

    int ans=0;
    REP(i,N){
        ans+=min(T,t[i+1]-t[i]);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 1792
from fractions import gcd
import math
A, B = map(int, input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

gcd = gcd(A, B)
divisors = make_divisors(gcd)

def is_prime(n):
    if n == 1: return True

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

count = 0
for i in range(len(divisors)):
    if is_prime(divisors[i]):
        count += 1

print(count)

Measured memory_bytes: 5216
N = int(input())
board = [0, 0]
board[0] = [int(i) for i in input().split()]
board[1] = [int(i) for i in input().split()]
ans = 0
for i in range(N):
    sum_1 = sum(board[0][:i+1])
    sum_1 += sum(board[1][i:])
    if sum_1 > ans:
        ans = sum_1

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<ll,ll>
#define vint vector<ll>
#define pb push_back
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
ll read(){
	ll g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
ll a,b,A,B,C,D,re,tag;
void get(ll mid){
	a=A-mid/(re+1)*re-mid%(re+1);
	b=B-mid/(re+1);
}
signed main(){
	for(ll T=read();T--;){
		A=read(),B=read(),C=read(),D=read();
		re=max((ll)ceil((double)A/(B+1)),(ll)ceil((double)B/(A+1)));
		ll l=0,r=A+B;
		while(l<r){
			ll mid=l+r>>1;get(mid);
			if(b<=a*re)l=mid+1;
			else r=mid;
		}ll pos=l;get(pos);tag=pos+1+b-a*re;
		for(ll i=C;i<=D;i++){
			if(i<=pos){if(i%(re+1))cout<<'A';else cout<<'B';}
			else{if((i-tag)%(re+1))cout<<'B';else cout<<'A';}
		}cout<<'\n';
	}return signed();
}

Measured memory_bytes: 3724
N,K = [int(c) for c in input().split()]
h = [int(c) for c in input().split()]

dp=[0]*N
for i in range(1,N):
    dp[i]=dp[i-1]+abs(h[i]-h[i-1])
    for j in range(1,K+1):
        if i-j>=0:
            dp[i]=min([dp[i],dp[i-j]+abs(h[i]-h[i-j])])
            
print(dp[N-1])


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

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

    ll N,K;
    string S;
    cin >> N>>K;

    vector<ll> h(N);
    REP(i,N){
        cin >> h.at(i);
    }

    sort(h.begin(), h.end());

    ll ans = INF;

    REP(i,N+1-K){
        ll tmp = h.at(i + K - 1) - h.at(i);
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4000
#include <iostream>
using namespace std;
int main(void){
    long n,d;
    cin >> n >> d;
    long ans = 0;
    for(long i = 0;i < n;i++){
          long x,y;
          cin >> x >> y;
          if(x * x + y * y <= d * d)ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int H, W;
bool visited[1000][1000];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
vector<string> m;

int main(void)
{
    int num = 0;
    cin >> H >> W;
    REP(i, H)
    {
        string st;
        cin >> st;
        m.push_back(st);
    }

    REP(i, H)
    {
        REP(j, W)
        {
            if (m[i][j] == '.')
            {
                num++;
            }
        }
    }
    memset(visited, false, sizeof(visited));
    queue<int> queueX;
    queue<int> queueY;
    queue<int> dist;

    queueX.push(0);
    queueY.push(0);
    dist.push(0);
    visited[0][0] = true;

    while (!queueX.empty())
    {
        int x = queueX.front();
        int y = queueY.front();
        int distance = dist.front();
        queueX.pop();
        queueY.pop();
        dist.pop();

        if (x + 1 == W && y + 1 == H)
        {
            int ans = num - (distance + 1);
            cout << ans << endl;
            return 0;
        }

        REP(i, 4)
        {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (nx < 0 || ny < 0 || nx >= W || ny >= H)
                continue;
            if (visited[ny][nx])
                continue;
            if (m[ny][nx] == '#')
                continue;
            visited[ny][nx] = true;
            queueX.push(nx);
            queueY.push(ny);
            dist.push(distance + 1);
        }
    }
    cout << "-1" << endl;
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
    int i,j;
    int n;
    cin >> n;
    int ans = 0;
    rep(i,n){
        int a, b;
        cin >> a >> b;
        ans += b - a + 1;
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
intt gcd(intt a, intt b) {return b ? gcd(b, a % b) : a;}
intt lcm(intt a, intt b) {return a * b / gcd(a, b); }
intt bpow(intt a,intt b) 
{
  intt res = 1;
  while (b > 0) {
    if (b & 1)res = ((res) * (a));
      a = a * a;
      b >>= 1;
  }
  return res;
}
intt fact(intt n) { 
   if ((n==0)||(n==1))
      return 1; 
   else
      return n*fact(n-1);
}
void go()
{
#ifndef ONLINE_JUDGE
  freopen("inn.txt","r",stdin);
  freopen("ouut.txt","w",stdout);
  #endif
}
///////////U L R D
int dx[4]={0,-1,1,0};
int dy[4]={1,0,0,-1};
 
template <typename T1, typename T2>
struct less_second {
    typedef pair<T1, T2> type;
    bool operator ()(type const& a, type const& b) const {
        return a.second > b.second;
    }
};
 
int main() 
{ 
    fast_io
    go();
    int n;cin>>n;
    set<string> s;
    for0(i,n)
    {
      string ss;
      cin>>ss;
      s.insert(ss);
    }
    cout << s.size() <<"\n";
    
}
 
 
 
/*
2
6


*/
 
 
 
 
 
 

Measured memory_bytes: 19152
// AGC022
// A - Diverse Word

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int AZ = 26;

string s;

string solve() {
    string ans;
    if (s.length() < AZ) {
        vector<bool> used(AZ);
        for (char c : s) {
            used[c - 'a'] = true;
        }
        for (int i = 0; i < AZ; i++) {
            if (!used[i]) {
                ans = s + (char)('a' + i);
                break;
            }
        }
    } else {
        ans = s;
        next_permutation(ans.begin(), ans.end());
        if (ans < s) {
            return "-1";
        }
        for (int i = 0; i < AZ; i++) {
            if (ans[i] != s[i]) {
                ans = ans.substr(0, i + 1);
            }
        }
    }
    return ans;
}

int main() {
    cin >> s;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a[10000],n,Min=1000000,Max=-1000000,i;
	long int Sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(Max<a[i]){
			Max = a[i];
		}
		if(Min>a[i]){
			Min = a[i];
		}
		Sum = Sum + a[i];
	}
	printf("%d %d %ld\n",Min,Max,Sum);
		
	return 0;
}

Measured memory_bytes: 2796
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n = k()
dict_a = {}

for i in range(n):
    s = "".join(sorted(input()))
    if s in dict_a:
        dict_a[s] += 1
        cnt += dict_a[s]
    else:
        dict_a[s] = 0

print(cnt)


Measured memory_bytes: 23592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
	    double l = sc.nextInt();

		double a = l/3.0;

		System.out.println(Math.pow(a,  3));

	}
}

Measured memory_bytes: 20308
K = input()
D = int(input())
dp = [[0] * D for _ in range(len(K))]
mod = 10 ** 9 + 7
#桁DP
#0 ~ K[0] - 1までの数をトップとする場合
for i in range(int(K[0])):
  dp[0][i % D] += 1
#tightは上限付近の制御に使う
#K[0]をトップとする場合がtight
#tightは上限ギリギリを攻める
tight = int(K[0]) % D
if len(K) > 1:
  for i in range(len(K) - 1):
    for j in range(D):
      for k in range(10):
        dp[i + 1][(j + k) % D] += dp[i][j]
        dp[i + 1][(j + k) % D] %= mod
    #Kを超えないようにしている
    for k in range(int(K[i + 1])):
      dp[i + 1][(tight + k) % D] += 1
    #上から(i + 1)桁まで見たもので、上限ギリギリのものの剰余
    tight = (tight + int(K[i + 1])) % D
#tightは最終的に上限の剰余に一致するので、0でないならその分を除く
print((dp[len(K) - 1][0] + (tight == 0) - 1) % mod)

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

int main(){
    int N, a[100], t = 0;
    cin >> N;
    for(int i = 0 ; i < N ; i++) cin >> a[i];
    for(int i = 0 ; i < N ; i++){
        for(int j = N - 1 ; j > i ; j--){
            if(a[j] < a[j - 1]){
                swap(a[j], a[j - 1]);
                t++;
            }
        }
    }
    for(int i = 0 ; i < N - 1 ; i++) cout << a[i] << " ";
    cout << a[N-1] << endl;
    cout << t << endl;
    return 0;
}


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


int main(){
  ll a;
  string b;
  cin >> a >> b;
  ll bb=(b[0]-'0')*100+(b[2]-'0')*10+(b[3]-'0');
  ll ans=a*bb;
  ans/=100;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Numerics;
 
public class Program
{
    public static void Main()
    {
        string[] S= Console.ReadLine().Split('/');
 
        int a = int.Parse(S[0]);
        int b = int.Parse(S[1]);
        int c = int.Parse(S[2]);
 
       if(a<2019)Console.WriteLine("Heisei");
       else if(a==2019&&b<=4)Console.WriteLine("Heisei");
       else Console.WriteLine("TBD");
 
    }
}

Measured memory_bytes: 11092
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author hakamada
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC106_3 solver = new ABC106_3();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC106_3 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String S = in.nextLine();
            String K = in.nextLine();
            int hitIndex = 0;
            int ceilK = 0;
            if (K.length() > 3) {
                ceilK = Integer.parseInt(String.valueOf(K.substring(0, 4)));
            } else {
                ceilK = Integer.parseInt(String.valueOf(K));
            }

            for (int i = 0; i < S.length(); i++) {
                if (Integer.parseInt(String.valueOf(S.charAt(i))) >= 2) {
                    hitIndex = i;
                    break;
                }
            }
            if (ceilK < (hitIndex + 1)) {
                out.println(1);
                return;
            }
            //if (hitIndex<ceilK) {
            out.println(String.valueOf(S.charAt(hitIndex)));
            //} else {
//            out.println(String.valueOf(S.charAt(ceilK-1)));
            //}
        }

    }
}



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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  if (d.at(N / 2 - 1) == d.at(N / 2)) {
    cout << 0 <<endl;
  }
  else {
    cout << d.at(N / 2) - d.at(N/2 - 1);
  }
}

Measured memory_bytes: 640
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

int main(){
    int a , b ; 
    cin >> a >> b ; 
    a = a * 3 + b ; 
    cout << a / 2 << endl;
    return 0 ;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const long long inf = 1e17;

struct RMQ {
	long long t[200010 * 4];
	long long add;
	int n;
	RMQ () {
		for(int i = 0; i < (200000 * 4); i++) {
			t[i] = inf;
		}
		add = 0;
	}
	void set_size(int N) {
		n = N;
	}
	void update(int x, long long val, int c, int b, int e) {
		if(b == e) {
			t[c] = min(t[c], val - add);
			return ;
		}
		int m = (b + e) >> 1;
		int l = c << 1;
		int r = l + 1;
		if(x <= m) update(x, val, l, b, m);
		else update(x, val, r, m+1, e);
		t[c] = min(t[l], t[r]);
	} 
	long long query(int x, int y, int c, int b, int e) {
		if(x <= b && e <= y) {
			return t[c] + add;
		}
		if(e < x || y < b) return inf;
		int m = (b + e) >> 1;
		int l = c << 1;
		int r = l + 1;
		return min(query(x, y, l, b, m), query(x, y, r, m+1, e));
	}
	void addAll(long long x) {
		add += x;
	}
	void update(int x, long long val) {
		update(x, val, 1, 1, n);
	}
	long long query(int x, int y) {
		return query(x, y, 1, 1, n);
	} 
} P, Q, T;

int x[200010];

int main(int argc, char const *argv[])
{
	int n, q, A, B;
	scanf("%d %d %d %d", &n, &q, &A, &B);
	P.set_size(n);
	Q.set_size(n);
	T.set_size(n);

	for(int i = 1; i <= q; i++) {
		scanf("%d", &x[i]);
	}
	P.update(A, abs(x[1] - B) - A);
	Q.update(A, abs(x[1] - B) + A);
	P.update(B, abs(x[1] - A) - B);
	Q.update(B, abs(x[1] - A) + B);
	T.update(A, abs(x[1] - B));
	T.update(B, abs(x[1] - A));

	for(int i = 2; i <= q; i++) {
		int c = abs(x[i] - x[i - 1]);
		long long opt = min(x[i] + P.query(1, x[i]), Q.query(x[i], n) - x[i]); 
		P.addAll(c);
		Q.addAll(c);
		T.addAll(c);
		P.update(x[i - 1], opt - x[i - 1]);
		Q.update(x[i - 1], opt + x[i - 1]);
		T.update(x[i - 1], opt);
	}
	long long ans = inf;
	for(int i = 1; i <= n; i++) {
		ans = min(ans, T.query(i, i));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 19840
N, M = map(int, input().split())
sum = 0
height = list(map(int, input().split()))
road = []
for i in range(M):
  R = list(map(int, input().split()))
  road.append(R)

other = []

for i in range(N):
  other.append([0])

for i in range(M):
  other[road[i][0] - 1].append(height[road[i][1] - 1])
  other[road[i][1] - 1].append(height[road[i][0] - 1])
for i in range(N):
  if height[i] > max(other[i]):
    sum += 1

print(sum)

Measured memory_bytes: 44436
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n;ll x;cin>>n>>x;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    vector<vector<ll>> dp(2020,vector<ll>(2020,1e+18));
    rep(i,n)rep(j,n+1)dp[i][j]=a[i];
    priority_queue<pair<ll,int>, vector<pair<ll,int>>, greater<pair<ll,int>> > que;
    rep(i,n){
        dp[i][0]=a[i];
        que.push({a[i],0});
    }
    rep(i,n){
        rep(j,n){
            dp[(i+j+1)%n][j+1]=min(dp[(i+j+1)%n][j+1],min(dp[(i+j+1)%n][j],a[i]));
        }
    }
    rep(i,n){
        ll tmp=1e+18;
        rep(j,n+1){
            chmin(dp[i][j],tmp);
            chmin(tmp,dp[i][j]);
        }
    }
    ll res=1e+18;
    rep(i,n+1){
        ll tmp=0;
        rep(j,n)tmp+=dp[j][i];
        tmp+=x*i;
        chmin(res,tmp);
    }
    cout<<res<<endl;
}


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

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

	int G[100][100]={0};

	for(int i=0; i<n; i++){
		int u,k;
		cin >> u >> k;
		
		for(int j=0 ; j<k; j++){
			int v;
			cin >> v;
	
			G[u-1][v-1] = 1;
		}
	}

	int d[100];
	for(int i=0; i<n; i++){
		d[i] = -1;
	}
	queue<int> Q;

	Q.push(0);
	d[0] = 0;

	while(!Q.empty()){
		int u = Q.front();
		int v = -1;
		for(int j=0; j<n; j++){
			if(G[u][j]==1 && d[j]==-1){
				v = j;
				break;
			}
		}

		if(v!=-1){
			Q.push(v);
			d[v] = d[u]+1;
		}else{
			Q.pop();
		}
	}
	
	for(int i=0; i<n; i++){
		cout << i+1 << ' ' << d[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll n, m, t, k, Q, base, a[500005];
#define ari for( int i = 0 ; i < n ; i++ ) cin >> a[i];
#define ginp for( int i = 0 ; i < m ; i++ ){ int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u);}
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
vector< pair<ll, ll> > End;
vector< ll > tree;

void printar(vector< ll > ar, int start, int stop){
	for(int i = start ; i < stop ; i++)
		cout << ar[i] << " ";
	cout << endl;
}

void Set(int val, int pos){
	int change = val - tree[pos];
    End[pos] = mp(pos - base + 1, pos - base + 1);
	tree[pos] = val;
	for(int node = pos / 2 ; node > 0 ; node /= 2){
        if( End[node].ss < pos - base + 1 )
            End[node].ss = pos - base + 1;
        if( End[node].ff == 0 )
            End[node].ff = pos - base + 1;
		tree[node] += change;
    }
}

ll sum(int node, int l, int r){
    if( End[node].ff == l and End[node].ss == r )
        return tree[node];
	ll ans = 0;
	ll mid = End[node * 2].ss;
    if( mid < l )
        ans += sum(node * 2 + 1, l, r);
    else if( mid >= r )
        ans += sum(node * 2, l, r);
    else{
        ans += sum(node * 2 + 1, mid + 1, r);
        ans += sum(node * 2, l, mid);
    }
    return ans;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> Q;
    ari;
    
    ll temp = n;
    base = 1;
    while( n >= 1 ){
    	n /= 2;
    	base *= 2;
    }
    n = temp;
    tree.resize(2 * base, 0);
    End.resize(2 * base, mp(0, 0));

    vector< pair< pair<ll, ll>, ll> > queries;
    for(int i = 0 ; i < n ; i++)
    	Set(0, i + base);
    
    ll r, l;
    for(int i = 0 ; i < Q ; i++){
    	cin >> l >> r;
    	queries.pb(mp(mp(r, l), i));
    }
    
    vector< ll > lastPos(n + 1, -1), q(Q + 1, 0);
    sort(queries.begin(), queries.end());
    k = 0;
    for(int i = 0 ; i < n ; i++){
    	if( lastPos[a[i]] != -1 )
    		Set(0, lastPos[a[i]] + base);
    	lastPos[a[i]] = i;
    	Set(1, i + base);
    	while( k < queries.size() and queries[k].ff.ff == i + 1 ){
    		q[queries[k].ss] = sum(1, queries[k].ff.ss, queries[k].ff.ff);
    		k++;
    	}
    }
    for(int i = 0 ; i < Q ; i++)
    	cout << q[i] << endl;
	return(0);
}

Measured memory_bytes: 51844
#include <bits/stdc++.h>
using namespace std;
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
constexpr int match[10] = {100000000, 2, 5, 5, 4, 5, 6, 3, 7, 6};
constexpr int MAX = 10010;
constexpr int INF = 1e9;

int main() {
    int n, m;
    cin >> n >> m;
    vector<bool> ok(10, false);
    for (int i = 0; i < m; i++) {
        int e; cin >> e;
        ok[e] = true;
    }
    
    int dp[MAX];
    fill(dp, dp + MAX, -INF);
    dp[0] = 0;
    // dp[i] : i 本のマッチをちょうど使う時の最大の桁数
    for (int i = 0; i <= n; i++) {
        for (int j = 1; j < 10; j++) if (ok[j]) {
            if (dp[i] == INF) continue;
            int w = match[j];
            if (i - w >= 0) chmax(dp[i], dp[i-w] + 1);
        }
    }
    
    
    vector<int> ans;
    int i = n;
    while (0 < i) {
        for (int j = 9; j > 0; j--) if (ok[j]) {
            int w = match[j];
            if (i - w >= 0 and dp[i - w] == dp[i] - 1) {
                i -= match[j];
                ans.emplace_back(j);
                break;
            }
        }
    }
    
    sort(ans.rbegin(), ans.rend());
    for (auto& e : ans) cout << e; cout << '\n';
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long A = long.Parse(str[0]);
		long B = long.Parse(str[1]);
		long C = long.Parse(str[2]);
		string ans = "No";
		if(A+B>=C){
			ans = "Yes";
		}
		Console.WriteLine(ans);
	}
}

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

int main(){
  vector<int> hoge;
  int n, tmp;
  cin >> n;
  for (int i = 0; i < n; i++){
    cin >> tmp;
    hoge.push_back(tmp);
  }

  bool flag = true;
  vector<int> swaped;
  int s_c = 0;
  for (int i = 0; i < n; i++){
    if(hoge[i] == i + 1){
      // cout << hoge[i] << "ccc" << endl;
      continue;
    }else{
      auto itr = find(swaped.begin(), swaped.end(), hoge[i]);
      if (itr != swaped.end()){
        // cout << hoge[i] << "aaa" << endl;
        continue;
      }
      if (s_c >= 1){
        flag = false;
        break;
      }
      
      if(hoge[hoge[i] - 1] == i + 1){ 
        // cout << hoge[i] << "bbb" << endl;
        s_c += 1;
        swaped.push_back(hoge[hoge[i] - 1]);
        continue;
      }

      flag = false;
      break;
    }
  }

  if (flag){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
  

  // int f, l;
  // bool flag = true;
  // int count = 0;
  // for (int i = 0; i < n/2; i++){
  //   f = hoge[i];
  //   l = hoge[n - 1 - i];
  //   if (f + l != n + 1){
  //     flag = false;
  //     break;
  //   }

  //   if(f > l){
  //     count += 1;
  //   }
  // }

  // if(flag){
  //   if (count == 1 || count == 0){
  //     cout << "YES" << endl;
  //   }else{
  //     cout << "NO" << endl;
  //   }
  // }else{
  //   cout << "NO" <<endl;
  // }

  
}

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


int main(){

    string b;
    cin >> b;
    if(b == "A"){
        cout << "T";
    }else if(b=="T"){
        cout << "A";
    }else if(b=="C"){
        cout << "G";
    }else{
        cout << "C";
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
char s[1000001];
int main()
{
	int i, j;
	int cnt_j, cnt_o, cnt_i;
	int max=0;
	cin >> s;
	for (i = 0;s[i] != '\0';i++)
	{
		if (s[i] == 'J')
		{
			cnt_j = 0;
			while (s[i] == 'J')
			{
				cnt_j++;
				i++;
			}
			if (max >= cnt_j)
			{
				i--;
				continue;
			}
			cnt_o = 0;
			while (s[i] == 'O')
			{
				cnt_o++;
				i++;
			}
			if (cnt_j < cnt_o)
			{
				i--;
				continue;
			}
			if (max >= cnt_o)
			{
				i--;
				continue;
			}
			cnt_i = 0;
			while (s[i] == 'I')
			{
				cnt_i++;
				i++;
			}
			if (cnt_i < cnt_o)
			{
				i--;
				continue;
			}
			max = cnt_o;
			i--;
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 4084
#include<stdio.h>
int gcd(int a,int b)
{
	if(a<0)
	{
		a=-a;
	}
	if(b<0)
	{
		b=-b;
	}
	if(b==0)
	{
		return a;
	}
	return gcd(b,a%b);
}
int a[65536],b[65536],c[65536];
int fa1[1048576],fa2[1048576];
int findroot1(int x)
{
	if(fa1[x]==x)
	{
		return x;
	}
	return fa1[x]=findroot1(fa1[x]);
}
int findroot2(int x)
{
	if(fa2[x]==x)
	{
		return x;
	}
	return fa2[x]=findroot2(fa2[x]);
}
int main()
{
	int n,m,q,mod;
	scanf("%d%d%d%d",&n,&m,&q,&mod);
	int g=mod;
	for(int i=0;i<m;i++)
	{
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
		if(i)
		{
			g=gcd(g,c[i]-c[i-1]);
		}
	}
	mod=gcd(mod,g*3);
	for(int i=0;i<m;i++)
	{
		c[i]%=mod;
	}
	for(int i=0;i<mod;i++)
	{
		fa1[i]=i;
	}
	for(int i=0;i<mod;i++)
	{
		int x=findroot1(i);
		int y=findroot1(i*4%mod);
		fa1[x]=y;
	}
	int dd=mod/g;
	for(int i=1;i<=n*dd*2;i++)
	{
		fa2[i]=i;
	}
	int st=c[0]%g;
	for(int i=0;i<m;i++)
	{
		c[i]-=st;
		c[i]/=g;
		for(int j=0;j<2;j++)
		{
			for(int k=0;k<dd;k++)
			{
				int x=findroot2(a[i]+j*n+k*n*2);
				int y=findroot2(b[i]+(j^1)*n+((k+k+c[i])%dd)*n*2);
				fa2[x]=y;
				x=findroot2(b[i]+j*n+k*n*2);
				y=findroot2(a[i]+(j^1)*n+((k+k+c[i])%dd)*n*2);
				fa2[x]=y;
			}
		}
	}
	while(q--)
	{
		int s,t,r;
		scanf("%d%d%d",&s,&t,&r);
		r=(r+st)%mod;
		bool ok=false;
		for(int i=0;i<2;i++)
		{
			for(int j=0;j<dd;j++)
			{
				if(findroot2(s+i*n+j*n*2)==findroot2(t))
				{
					if(findroot1(((st<<i)+j*g)%mod)==findroot1(r))
					{
						ok=true;
					}
				}
			}
		}
		if(ok)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 6144
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

int main(){
  int N;
  cin >> N;
  vector<pair<int, int> > A(N);
  rep(i,N){
    int temp;
    cin >> temp;
    A[i]=make_pair(temp, i);
  }

  sort(A.begin(), A.end());

  rep(i,N){
    printf("%d ", A[i].second+1);
  }
  printf("\n");


}


Measured memory_bytes: 1664
import java.util.Scanner;

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

		int T = sc.nextInt();
		int X = sc.nextInt();
		
		double t =(double) T / X;

		System.out.println(String.format("%.5f", t));
    }
}

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

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

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

const ll mod = 1e9 + 7;
const ll IMF = 1LL << 60;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//













int N;
vector<double> p;

double dp[3100][3100];

int main(){
        cin >> N;
        p.resize(N);

        for(int i = 0; i < N; i++) cin >> p[i];

        dp[0][0] = 1.0;

        for(int i = 0; i < N; i++){
                for(int j = 0; j <= i; j++){
                        dp[i+1][j+1] += dp[i][j] * p[i];
                        dp[i+1][j] += dp[i][j] * (1.0 - p[i]);
                }
        }

        double res = 0.0;
        for(int j = (N+1)/2; j <= N; j++) res += dp[N][j];
        cout << fixed << setprecision(10) << res << endl;
}







































Measured memory_bytes: 72320
#include <bits/stdc++.h>
using namespace std;
string a, b, c;

int main(){
  cin>>a>>b>>c;
  if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/

using namespace std;
bool compare(const pair<int,int> &x,const pair<int,int> &y){
	return x.second<y.second;
}
int solve()
{
	int n;
	cin>>n;
	vpii g;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		g.pb(mkp(x,y));
	}
	sort(g.begin(),g.end(),compare);
	int time=0;
	for(int i=0;i<g.size();i++){
//		cout<<g[i].first<<" "<<g[i].second<<endl;
		int a=g[i].first;
		int b=g[i].second;
		if(time+a>b){
			cout<<"No";
			return 0;
		}
		time+=a;
	}
	cout<<"Yes";
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}


Measured memory_bytes: 7416
Module Module1

sub Main(ByVal args() as String)
    dim s as String
    dim c, i as integer

    s=Console.ReadLine()
    c=0
    for i=1 to s.length()
        if mid(s,i,1)="1" then
            c+=1
        end if
    next i

    Console.WriteLine(c)
end sub

end Module

Measured memory_bytes: 19792
import sys
import itertools

def func(n):
    count = 0
    for a, b, c, d in itertools.product(range(10), repeat=4):
        if a + b + c + d == n:
            count += 1
    return count

def main():
    for l in sys.stdin:
        n = int(l.strip())
        print(func(n))

if __name__ == '__main__':
    main()

Measured memory_bytes: 7660
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sync ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD  1000000007 
#define lld long long
lld powm(lld base,lld exp,lld mod=MOD) {lld ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
int32_t main()
{
	int n;
	cin>>n;
	vector<string>s;
	for(int i=0;i<n;i++){
		string temp;
		cin>>temp;
		s.push_back(temp);
	}
	unordered_map<string,int>m;
	for(int i=0;i<n;i++)
	{
		string temp=s[i];
		int length=temp.length();
		sort(temp.begin(),temp.end());
		m[temp]++;
	}
	int ans=0;
	for(auto i:m)
	{
		int k=(i.second);
		//cout<<k<<" ";
		int add=k*(k-1)/2;
		ans+=add;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 17652
/**
  *  @Author: Pranta Sarker
  *
  */

#include<bits/stdc++.h>

using namespace std;

#define fast ios_base::sync_with_stdio(0)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define pfn(x , k) printf(k , x)
#define nl puts("")
#define psb push_back
#define mset(c,v) memset(c , v , sizeof c)
#define loop0(n) for(int i=0; i<n; i++)
#define loop1(n) for(int i=1; i<=n; i++)
#define mpair(x , y) make_pair(x , y)
#define all(x) x.begin(), x.end()
#define pi acos(-1.0)
#define psb push_back
#define clr clear()

typedef unsigned long long ull;
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
typedef vector<string>vs;
typedef map<int, int>mpii;
typedef map<string, int>mpsi;
typedef map<char, int>mpci;
typedef map<LL, LL>mpll;

const int mod = 1000007;
const int high = 1002;

int main()
{
	fast;
	int A , B , C , D;
	while(cin >> A >> B >> C >> D)
	{
		int start = max(A , C);
		int end = min(B , D);

		if(start > end) outn(0);
		else cout << end - start << "\n";
	}

	return 0;
}


Measured memory_bytes: 256
import numpy as np
def f(s):
    s = s.replace('.', '0')
    s = s.replace('#', '1')
    lst = [int(n) for n in s]
    return np.array(lst)
h, w = list(map(int, input().split()))
a = np.array([f(input()) for i in range(h)])
b = a[:, ~np.all(a==0, axis=0)]
ans_ = b[~np.all(a==0, axis=1)]
ans = ans_.tolist()
for i in range(len(ans)):
    out3 = [str(n) for n in ans[i]]
    out2 = ''.join(out3)
    out1 = out2.replace('0', '.')
    out0 = out1.replace('1', '#')
    print(out0)

Measured memory_bytes: 21492
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll n, m, q;
    cin >> n >> m >> q;

    ll cnt[555][555] = {};
    rep(i, m){
        ll l, r;
        cin >> l >> r;
        cnt[l][r]++;
    }

    ll sum[n+1][n+1] = {};
    for(ll i = 1; i <= n; ++i){
        for(ll j = 1; j <= n; ++j){
            sum[i][j] = sum[i][j-1] + cnt[i][j]; 
        }
    }

    ll ans[q] = {};
    rep(i, q){
        ll a, b;
        cin >> a >> b;
        for(ll j = a; j <= b; ++j)ans[i] += sum[j][b] - sum[j][a-1];
    }

    rep(i, q)cout << ans[i] << endl;

}

Measured memory_bytes: 6016
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
using namespace std;
int n, q, a[123456];
signed main() {
	cin >> n >> q;
	for1(i, n)cin >> a[i];
	sort(a + 1, a + n + 1);
	for1(hoge, q) {
		int l, r; cin >> l >> r;
		int p1 = 0, p2 = n + 1;
		while (p2 - p1 > 1) {
			int mid = (p1 + p2) / 2;
			if (a[mid] < l)p1 = mid;
			else p2 = mid;
		}
		int ans1 = p1;
		p1 = 0, p2 = n + 1;
		while (p2 - p1 > 1) {
			int mid = (p1 + p2) / 2;
			if (a[mid] <= r)p1 = mid;
			else p2 = mid;
		}
		cout << p1 - ans1 << endl;
	}
}


Measured memory_bytes: 3904
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	N := getInt()

	n := N % 10
	if n == 3 {
		out("bon")
		return
	}
	if n == 0 || n == 1 || n == 6 || n == 8 {
		out("pon")
		return
	}

	out("hon")
}


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


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

    bool res = true;
    ll A[100010];

    rep (i, N) {
        cin >> A[i];
        if (A[i] == 0) res = false;
    }
    if (res == false) {
        cout << 0 << endl;
        return 0;
    }

    ll s = 1;
    res = true;
    rep (i, N) {
         if (A[i] <= (1000000000000000000 / s)) {
             s *= A[i];
         } else {
             res = false;
             break;
         }
    }
    if (res == false) {
        cout << -1 << endl;
        return 0;
    }

    cout << s << endl;

}

Measured memory_bytes: 4412
#!/usr/bion/env python3

S = input()

ans = 0

if S == "SUN":
    ans = 7
if S == "MON":
    ans = 6
if S == "TUE":
    ans = 5
if S == "WED":
    ans = 4
if S == "THU":
    ans = 3

if S == "FRI":
    ans = 2
if S == "SAT":
    ans = 1


print(ans)


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    int N; cin >> N;
    cout << (N + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256