akhauriyash/Code-Regression huggingface dataset:
#
#　　　　　　　　　　　　　　,. -─────────‐- .、
#　　　　　　　　　　　　 ／／￣￣＼　　　　　　／￣￣＼＼
#　　　　　　　　　　　／　　　　　　　　　　　　　　　　　　　　 ＼
#　　　　　　　　　 ／　　　　　　　　::::::::::::::::::::::::::::::::　　　　　　　＼
#　　　　　　　　／ 　　／ ／￣＼＼::::;;;;;;;;;;;;;;;;;:::::／／￣＼＼　　＼
#　　　　　　 ／　　　　|　 |.　┃　.|　| ::::;;;;;;;;;;;;;::::｜ |.　┃　.|　|　　　 ＼　　　　　　　　　　　　　　　　　　　　　
#　　　　　／ 　　　　　＼ ＼＿／／　::::::::::::::::::　＼＼＿／／　　　　　 ＼　　　　
#　　　 ／　　　　　..／￣￣＼　／　　　::｜::　　　＼　／￣￣＼..　　　　　＼
#　　 / 　 　 　 　 :::::　　　　　　|　　　　　 |　　　　　 |　　　　　　 :::::　　　　　 ヽ.　　　
#　　| 　　　　　　　　　　　　　　|　　　　　 |　　　　　 |　　　　　　　　　　　　　　|.
#　　| 　　　　　　　　　　　　　　＼＿＿／＼＿＿／ 　　　　　　　　　　　　　　|　　　　　　　　　　　　　　　　　
#　　| 　　　　　　　　　　　　　　　｜　　　　　　　｜　　　　　　　　　　　　　　　|
#　　| 　　　　　　　　　　　　　　　｜r─‐┬──､|　　　　　　　　　　　　　　　 |
#　　ヽ　　　　　　　　　　　　　　　 |/　　　|　　 　｜　　　　　　　　　　　　　　/
#　　　 ＼　　　　　　　　　　　　　 ＼　　　　　　／　　　　　　　　　　　　　／
#　　　　　＼ 　　　　　　　　　　　　　￣￣￣￣　　　　　　　　　　　　　／
#
#
import sys
input=sys.stdin.readline
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [input() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    A = LI()
    A_copy = []
    for i, a in enumerate(A,start=1):
        A_copy.append((a,i))

    A_copy.sort()
    if A_copy[-1][0] <= 0:
        print(N-1)
        #逆順cumsum
        for i in range(1,N)[::-1]:
            print(i+1,i)
            #A[i-1]+=A[i]
    elif A_copy[0][0] >= 0:
        print(N-1)
        #正順cumsum
        for i in range(1,N):
            print(i, i + 1)
            #A[i+1]+=A[i]
    elif abs(A_copy[0][0]) > abs(A_copy[-1][0]):
        print(2*N-1)
        min_index = A_copy[0][1]
        for i in range(N):
            print(min_index, i + 1)
            #A[i]+=A[min_index-1]
        for i in range(1,N)[::-1]:
            print(i + 1, i)
            #A[i-1]+=1A[i]
    else:
        print(2*N-1)
        max_index = A_copy[-1][1]
        for i in range(N):
            print(max_index, i + 1)
            #A[i]+=A[max_index-1]
        for i in range(1,N):
            print(i, i + 1)
            #A[i]+=A[i-1]
    
    #print(A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
#include <math.h>
using namespace std;
#define MAXSIZE 100005
#define PI 3.141592653589793
#define MOD_CONST 1000000007
typedef long long int lli;

int main(){
  string s;
  cin >> s;
  string ans = (s == "Sunny") ? "Cloudy" : (s == "Cloudy") ? "Rainy" : "Sunny";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s, t,u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (s==u) {
        cout << a - 1 << " " << b;
    }
    else {
        cout << a << " " << b - 1;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    
    
    ll n, k;
    cin >> n >> k;
    int cnt = 0;
    while(n > 0){
        n /= k;
        ++cnt;
    }
    cout << cnt << '\n';

    
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static long gcd(long m, long n) {
	    if(m < n) return gcd(n, m);
	    if(n == 0) return m;
	    return gcd(n, m % n);
	}

	private static long lcm(long m, long n) {
	    return m * n / gcd(m, n);
	}

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long A = Long.parseLong(sc.next());
    long B = Long.parseLong(sc.next());
    long C = Long.parseLong(sc.next());
    long D = Long.parseLong(sc.next());
    long ans = 0;

    long AparC = A % C == 0 ? A/C : A/C+1;
    long BparC = B/C;
    long cMinus = BparC - AparC + 1;

    long AparD = A % D == 0 ? A/D : A/D+1;
    long BparD = B/D;
    long dMinus = BparD - AparD + 1;

    long lcm = lcm(C, D);
    long AparLcm = A % lcm == 0 ? A/lcm : A/lcm+1;
    long BparLcm = B/lcm;
    long lcmMinus = BparLcm - AparLcm + 1;

    ans = B - A + 1 - (cMinus + dMinus - lcmMinus);
    System.out.println(ans);
  }
}

Measured memory_bytes: 21716
import sys
n = int(input())
print(0, flush=True)
f, m = "Female", "Male"
s = input()
if s == "Vacant":
    quit()
x = 0 if s == f else 1
high = n-1
low = 0
while high - low > 1:
    mid = (high + low) // 2
    print(mid, flush=True)
    s = input()
    if s == "Vacant":
        sys.exit()
    if mid % 2 == x:
        if s == f:
            low = mid
        else:
            high = mid
    else:
        if s == f:
            high = mid
        else:
            low = mid
print(high, flush=True)
sys.exit()

Measured memory_bytes: 3660
d = {}
for _ in range(int(input())):
	a = list(input().split())
	x = a[1]
	y = a[0]
	if y == "0":
		d[x] = a[2]
	elif y == "2":
		d[x] = 0
	else:
		print(d[x] if x in d else 0)


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

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

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

bool possible(const vector<ll>& A, ll s) {
  const int N = A.size();
  ll size = 0;
  REP(i, s+1) size += A[i];
  int pos = s + 1;
  while (pos < N && A[pos] <= 2 * size) {
    size += A[pos];
    pos++;
  }
  return pos == N;
}


int main2() {
  int N = nextLong();
  vector<ll> A(N);
  REP(i, N) A[i] = nextLong();
  sort(ALL(A));


  // for (int i = 0; i < N; i++) {
  //   cout << i << " " << possible(A, i) << endl;
  // }

  ll lo = -1;
  ll hi = N;
  while (hi - lo > 1) {
    ll mid = (hi + lo) / 2;
    if (possible(A, mid)) hi = mid; else lo = mid;
  }


  ll ans = N - hi;
  cout << ans << endl;
  return 0;
}

int main() {

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

Measured memory_bytes: 4000
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

vector<ll> Eratosthenes(const ll N) {
  bool is_prime[1000000 + 1];
  vector<ll> P;
  for (ll i = 0; i <= N; i++) {
    is_prime[i] = true;
  }
  for (ll i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (ll j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
  return P;
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  int n;
  cin >> n;
  lvec a(n);
  REP(i, n) { cin >> a[i]; }
  ll count1 = 0;
  ll count2 = 0;
  ll count4 = 0;
  REP(i, n) {
    if (a[i] % 4 == 0) {
      count4++;
    } else if (a[i] % 2 == 0) {
      count2++;
    } else {
      count1++;
    }
  }
  if (count4 + 1 >= count1) {
    count4 -= count1;
    if (count2 % 2 == 0) {
      puts("Yes");
    } else if (count4 + 1 >= count2 % 2) {
      puts("Yes");
    } else {
      puts("No");
    }
  } else {
    puts("No");
  }
  return 0;
}

Measured memory_bytes: 1024
import java.io.*;
public class Main{
	public static void main(String args[]){
    int a = 0,b = 0;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    try{
      String line = reader.readLine();
      String[] splitted = line.split(" ");
      a = Integer.parseInt(splitted[0]);
      b = Integer.parseInt(splitted[1]);
      
		}catch(Exception e){

    }
    if (a == b) {
      System.out.println("a == b");
    }
    if (a < b) {
      System.out.println("a < b");
    }
    if (a > b){
      System.out.println("a > b");
    }
    		
	}
}


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

using namespace std;

stack<char> S;
string input;

int main() {
    cin >> input;

    for (int i=0;i<input.length();i++){
        if (input[i] == '0' || input[i] == '1'){
            S.push(input[i]);
        }
        else{
            if (!S.empty()){
                S.pop();
            }
        } 
    }   

    stack<char> result;

    while (!S.empty()) {
        result.push(S.top());
        S.pop();
    }

    while (!result.empty()) {
        cout << result.top();
        result.pop();
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define CONCAT_(x,y) x##y
#define CONCAT(x,y) CONCAT_(x,y)
#define _v1 CONCAT(qyw1, __LINE__) // unique name in same line (otherwise use __COUNTER__)
#define _v2 CONCAT(qyw2, __LINE__)
#define forbits(i, m) for (int _v1 = m, i = __builtin_ctz(_v1); _v1 != 0; _v1 ^= _v1 & -_v1, i = __builtin_ctz(_v1))
#define forsubm(s, m) for (int s = m; s >= 0; s = !s ? -1 : m & (s - 1))
int __nextXZW(int v){int t=v|(v-1);int w=(t+1)|(((~t&-~t)-1)>>(__builtin_ctz(v)+1));return w;}
#define ksets(i, n, k) for (int i = (1u << k) - 1, max = i << (n - k); i <= max; i = __nextXZW(i))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9+7;
const ll N = 5e5+5, inf = 1e9+5000;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <atcoder/convolution>
using namespace atcoder;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n, m; cin >> n >> m;
  vector<ll> a(n), b(m);
  rep (i, n) cin >> a[i];
  rep (i, m) cin >> b[i];
  for (auto x : convolution(a, b)) cout << x << ' ';
  
  return 0;
}

Measured memory_bytes: 27244
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+9;
int a[N],ans;
signed main() {
	int n; scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	ans+=a[n]; n--; int tot=1;
	for(int i=n;i>=1;i--) {
		if(tot==n) break;
		else if(tot==n-1) ans+=a[i],tot++;
		else ans+=2*a[i],tot+=2;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 5388
#include<iostream>

using namespace std;

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		int x = 0, y = i;
		for (int j = 0; j < 5; j++) {
			x += y % 10;
			y /= 10;
		}
		if (a <= x && x <= b)
			sum += i;
	
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int red = 0;
    int blue = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'R') red ++;
        else blue ++;
    }
    if(red > blue) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!


int _find(string &a,string &b){
    
    for(int i=0;i<a.l();i++){
        if(a[i]!=b[i]){
            return (a[i]>b[i]) ? 1 : -1;
        }
    }
    return 0;
}
void equality(string &a,string &b){
    if(a.l()<b.l()){
        reverse(all(a));
        while(a.l()<b.l()){
            a.pb('0');
        }
        reverse(all(a));
    }
    
    if(a.l()>b.l()){
        reverse(all(b));
        while(a.l()>b.l()){
            b.pb('0');
        }
        reverse(all(b));
    }
}
void topRow(int m){
    for(int i=0;i<m+2;i++){
        cout<<"#";
    }cout<<endl;
}
void solve(){
    
    int n,m;
    cin>>n>>m;
    
    topRow(m);
    for(int i=0;i<n;i++){
        string str;
        cin>>str;
        cout<<"#"<<str<<"#"<<endl;
    }
    
    topRow(m);
}



int main() {
    faster;
    int t=1;
    // cin>>t;
    while(t-->0){
        solve();
    }
	return 0;
}

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

int main() {
  int n, k, q;
  cin>>n>>k>>q;
  int a[n];
  for (int i=0; i<n; i++) a[i] = 0;
  for (int i=0; i<q; i++) {
    int x;
    cin>>x;
    --x;
    ++a[x];
  }
  for (int i=0; i<n; i++) {
    if (k - q + a[i] > 0) {
      cout<<"Yes"<<endl;
    } else {
      cout<<"No"<<endl;
    }
  }
}

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

using namespace std;

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

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

void revive(deque<char>& res, int num) {  
  rep(i, num)
//    res.push_front(')');
  rep(i, num)
    res.push_front('(');
}

int main() {
  int N; cin >> N;
  string S; cin >> S;
  // Left to right
  {
    int count = 0;
    rep(i, N) {
      if (S[i] == '(') count++;
      if (S[i] == ')') count--;
      if (count < 0) count = 0;
    }
    rep(i, count) {
      S.push_back(')');
    }
  }

  N = S.size();
  deque<char> res;

  // Right to left
  {
    int count = 0;
    for (int i = N - 1; i >= 0; i--) {
      if (S[i] == ')') {
        if (count >= 0) {
          count++;
        } else {
          revive(res, -count);
          count = 1;
        }
        res.push_front(')');
      } else {
        count--;
        if (count >= 0) {
          res.push_front('(');
        }
      }
    }
    revive(res, -count);
    rep(i, count) {
      res.push_front('(');
    }
  }
  for (auto c: res) {
    cout << c;
  }
  puts("");
}


Measured memory_bytes: 256
s=list(input())
ATGC=['A','G','T','C']
counter=0
max_count=0

for i in s:
    if i in ATGC:
        counter+=1
    else:
        max_count=max(counter,max_count)
        counter=0
max_count=max(counter,max_count)
print(max_count)

Measured memory_bytes: 38384
s = input()
p = list(s) 
if p[len(p) - 1] == "?": #最後が？だったら
  p[len(p) - 1] = "D"  # Dにする

for i in range(len(p) - 1):
  if p[i] == "?":         # ？だったら
    if i == 0:            # 最初の文字
      if p[i + 1] == "D" or p[i + 1] == "?": # 二番目の文字がDか？
        p[i] = "P"
      else:                                   # 二番目の文字がDか？でなかったら
        p[i] = "D"
    else:
      p[i] = "D"          # D
print("".join(p))

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

/*

BIT: 区間和の更新や計算を行う構造体である.
初期値はすべて０である.

method:
sum(i): a_1 + a_2 + ... + a_iを計算して返す
add(i,x): a_i にxを加算する
時間計算量は sum, addともに O(log n)である.
*/

template <typename T>
struct BIT {
    
    int n;
    vector<T> bit;
    
    BIT(int n_): n(n_ + 1), bit(n,0) {}
    
    T sum(int i){
        T s(0);
        while (i > 0){
            s += bit[i];
            i -= (i & -i);
        }
        return s;
    }
    
    void add(int i, T x){
        while (i <= n){
            bit[i] += x;
            i += (i & -i);
        }
    }
    
};

int main(void){
   
   int n, q;
   cin >> n >> q;
   BIT<int> bit(n);
   
   for (int i = 0; i < q; i++){
       int com, x, y;
       cin >> com >> x >> y;
       
       if (com == 0){
           bit.add(x,y);
       }
       else{
           cout << bit.sum(y) - bit.sum(x-1) << endl;
       }
   }
}



Measured memory_bytes: 3124
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());

        System.out.println((int)(Math.ceil(n / 2.0)  * (n/2)));
    }
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define mod 1000000007
using namespace std;

int h,w;
vector<vector<int> > dp;
vector<vector<char> > wall;

int fun(int i,int j){
	if(i==0 && j==0)
		return 1;
	if(wall[i][j]=='#')
		return 0;
	if(dp[i][j]!=-1)
		return dp[i][j];
	int a=0;
	if(i>0)
		a=(a+fun(i-1,j))%mod;
	if(j>0)
		a=(a+fun(i,j-1))%mod;
	return dp[i][j]=a;
}

int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);cout.tie(NULL);
	
	cin>>h>>w;
	
	dp.assign(h,vector<int> (w,0));
	wall.assign(h,vector<char> (w));
	for (int i = 0; i < h; ++i)
	{
		for(int j=0;j<w;++j)
		cin>>wall[i][j];
	}

	// cout<<fun(h-1,w-1);
	// for (int i = 0; i < h; ++i)
	// {
	// 	for(int j=0;j<w;++j)
	// 		cout<<dp[i][j]<<" ";
	// 	cout<<'\n';
	// }

	dp[0][0]=1;
	for(int i=0;i<h;++i){
		for(int j=0;j<w;++j){
			if(wall[i][j]=='#')
				continue;
			if(i>0)
				dp[i][j] = (dp[i][j]+dp[i-1][j])%mod;
			if(j>0)
				dp[i][j] = (dp[i][j]+dp[i][j-1])%mod;
		}
	}
	cout<<dp[h-1][w-1];
	// cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
	return 0;
}

Measured memory_bytes: 5248
N = int(input())
A = list(map(int,input().split()))

bai_4 = 0
bai_2 = 0

for a in A:
    if a%4 == 0:
        bai_4 += 1
    elif a%2 == 0:
        bai_2 += 1

ch = N - bai_4 * 2 - bai_2

if ch <= 0:
    print('Yes')
elif ch == 1 and N%2 == 1:
    print('Yes')
else:
    print('No')


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

ll fact(ll n){
    if(n == 1){
        return 1;
    }else{
        return n * fact(n - 1);
    }
}

double dist(double x1, double y1, double x2, double y2){
    const double dx = (x1 - x2);
    const double dy = (y1 - y2);
    return sqrt(dx * dx + dy * dy);
}

void solve(
    long long N,
    std::vector<long long> x,
    std::vector<long long> y){

    double ans = 0;
    vector<ll> p(N);
    REP(i, N){
        p.at(i) = i;
    }
    do{
        REP(i, N - 1){
            ans += dist(
                x.at(p.at(i)),
                y.at(p.at(i)),
                x.at(p.at(i + 1)),
                y.at(p.at(i + 1))
            );
        }
    }while(next_permutation(p.begin(), p.end()));
    ans /= fact(N);
    printf("%.8f\n", ans);
}

// 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)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }
    solve(N, std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	char c;
    while ((c=getc(stdin))!=EOF) {
    	if('A'<=c && c<='Z') {
	        putchar(c-'A'+'a');
    	} else if('a'<=c && c<='z') {
    		putchar(c-'a'+'A');
    	} else {
    		putchar(c);
    	}
    }
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
using T = tuple<int, int, int>;

struct graph {
    bool visited[3]; // left, right, both
    int cost = -1;
    vector<int> next;
};

int n, m;
graph g[100010];
int s, t;

void bfs() {
    queue<T> q; // (dest, foot, cost)
    q.push(T(s, 2, 0));

    while(!q.empty()) {
        auto current = q.front(); q.pop();
        int node = get<0>(current);
        int foot = get<1>(current);
        int cost = get<2>(current);

        if(g[node].visited[foot])
            continue;

        g[node].visited[foot] = true;
        if(foot == 2) {
            g[node].cost = cost;
            cost++;            
        }

        foot = (foot + 1) % 3;
        for(auto n_next : g[node].next)
            q.push(T(n_next, foot, cost));
    }
}

int main() {
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        g[u].next.push_back(v);
    }
    cin >> s >> t;
    bfs();
    cout << g[t].cost << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;cin >> n;
	int b[n];
	for(int i = 1 ; i <= n-1 ; i++)
	{
		cin >> b[i];
	}
	int s = b[1]+b[n-1] ;//cout << s << endl;
	for(int i = 2 ; i <= n-1 ; i++)
	{
		if(b[i-1] >= b[i])s += b[i];
		else 
			s += b[i-1];
	}
	cout << s << endl;
}


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

int main() {
  string S, T;
  cin >> S >> T;
  
  if(T.compare(0,S.size(), S)) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define rep(i,n)       for(int i=0; i<n; i++)
#define clr(arr)       memset(arr, 0, sizeof arr)
#define all(x)         x.begin(), x.end()
const int MOD = 1e9 + 7;
template<class F, class S> ostream& operator<<(ostream &out, const pair<F, S> &p)
{
	return out << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out)
{
	out << '{';
	for (auto i = x.begin(); i != x.end(); i++)
		out << *i << (i == prev(x.end()) ? "" : ", ");
	return out << '}';
}
void dmp() {}
template<class T, class... Args> void dmp(T &&x, Args... args)
{
	cerr << x << ";  "; dmp(args...);
}
#ifdef SMIT
struct Nl {~Nl() {cerr << '\n';}};
#define debug(x...) cerr << (strcmp(#x, "") ? #x ":  " : ""), dmp(x), Nl(), cerr << ""
#else
#define debug(...) {}
#endif
// Yes you CAN
const int N = 101, M = 1e5 + 1;

int n, W, dp[N][M], w[N], v[N];


int knapsack(int n, int wt)
{
	if (n == -1 or wt == 0)
		return 0;
	if (dp[n][wt] != -1)
		return dp[n][wt];
	int include = INT_MIN, exclude = INT_MIN;
	if (wt - w[n] >= 0)
		include = v[n] + knapsack(n - 1, wt - w[n]);
	exclude = knapsack(n - 1, wt);
	return dp[n][wt] = max(include, exclude);
}
void solve()
{
// #define TEST
	memset(dp, -1, sizeof dp);
	cin >> n >> W;
	rep(i, n) cin >> w[i] >> v[i];
	cout << knapsack(n - 1, W) << endl;
}

int32_t main()
{
#ifdef SMIT
	freopen("/home/smit/Desktop/in.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(false); cin.tie(nullptr);

	int t = 1;
#ifdef TEST
	cin >> t;
#endif
	while (t--)
		solve();
}

Measured memory_bytes: 82560
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <list>
#include <cmath>
using namespace std;
#define rep(i,m,n) for (int i = (int) (m); i < (int) (n); i++)
#define rep1(i,m,n) for (int i = (int) (m); i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
long long int comb(long long int n,long long int r){
    vector<vector<long long int> > v(n+1,vector<long long int>(n+1,0));
    long long int i,j;
    rep(i,0,n+1){
        v.at(i).at(0)=1;
        v.at(i).at(i)=1;
    }
    rep(i,0,n+1){
        rep(j,0,i)v.at(i).at(j)=v.at(i-1).at(j-1)+v.at(i-1).at(j);
    }
    return v.at(n).at(r);
}
int main(void){
    int N,i,j=0,error=0;
    cin>>N;
    vector<int> data(N);
    rep(i,0,N)cin>>data.at(i);
    while(j<N && error==0){
        if(data.at(j)%2==0){
            if(data.at(j)%3!=0 && data.at(j)%5!=0)error++;
        }
        j++;
    }
    if(error==0)cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
}

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);
}

ll dp[55][55][3333];

int main(void){
	int n,k,i,j,l,r,t;
	ll ans = 0ll;
	dp[0][0][0] = 1ll;
	cin >> n >> k;
	for(i=0; i<n; ++i){
		for(j=0; j<=i; ++j){
			for(t=0; t<2525; ++t){
				add_mod(dp[i+1][j][t+j*2],(dp[i][j][t]*(j*2+1))%MOD);
				add_mod(dp[i+1][j+1][t+j*2],dp[i][j][t]);
				if(j>0){
					add_mod(dp[i+1][j-1][t+j*2],(((dp[i][j][t]*j)%MOD)*j)%MOD);
				}
			}
		}
	}
	cout << dp[n][0][k] << endl;
	return 0;
}


Measured memory_bytes: 71936
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#define ll long long int
#define MIN(x,y) (x)>(y)?(y):(x)
#define MAX(x,y) (x)>(y)?(x):(y)
#define ABS(x) (x)>0?(x):(-x)
#define mod 10000007
#define INF 1e9


int main(void){
	int n;
	scanf("%d",&n);
	int a[n];
	int pair[n];
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		a[i]--;
		pair[i]=0;
	}
	int ans=0;
	for(int i=0;i<n;i++){
		int x=a[i];
		if(pair[x])continue;
		if(a[x]==i){
			pair[x]=1;
			pair[i]=1;
			ans++;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
char s[10][10];
int main()
{
	int h,w,now=1;
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++)
		scanf("%s",s[i]+1);
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
			if(s[i][j]=='#')
			{
				if(j==now+1)
					now++;
				else if(now!=j)
				{
					printf("Impossible");
					return 0;
				}
			}
	}
	printf("Possible");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int inf = 1e9;

int main() {
	int x,y;
	cin>>x>>y;
	string ans ="No";
	seti g1={1,3,5,7,8,10,12},g2={4,6,9,11},g3 ={2};
	if(g1.count(x)&&g1.count(y))ans="Yes";
	else if(g2.count(x)&&g2.count(y))ans="Yes";
	else if(g3.count(x)&&g3.count(y))ans="Yes";
	cout<<ans<<endl;
}

Measured memory_bytes: 256
# D - Grid Coloring

H, W = map(int, input().split())
N = int(input())
A = list(int(a) for a in input().split())
color = []
for i, a in enumerate(A, 1):
    color.extend([i] * a)

grid = [[0] * W for _ in range(H)]

k = 0
for i in range(H):
    for j in range(W):
        if i%2:
            j = (W - 1) - j
        grid[i][j] = color[k]
        k += 1

for i in range(H):
    print(' '.join(map(str, grid[i])))

Measured memory_bytes: 3572
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

int A, B;
int kuti = 1;
int ans = 0;

int main() {
	cin >> A >> B;
	while (true) {
		if (kuti < B) {
			kuti += A - 1;
			ans++;
		}
		else break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <cerrno>
#include <cfenv>
#include <stack>
#include <math.h>
#include <iomanip>
#include <limits>
#include <queue>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<int> H(N);

    for(int i=0;i<N;i++){
        cin >> H[i];
    }

    int flag = 0;

    for(int i=0;i<N-1;i++){
        if(H[i+1]>H[i]){
            H[i+1]--;
        }
        else if(H[i+1] == H[i]){
        }
        else{
            flag = 1;
        }
    }

    if(flag){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<int,int> pii;
#define endl '\n'
#define F first
#define S second
const int MAX_N=3e3+3;
const int MOD=1000000007;

int n;
char s[MAX_N];
ll dp[MAX_N][MAX_N];
ll ans;

int main()
{
	scanf("%d",&n);
	scanf("%s",s+2);
	s[1]='<';
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='<') for(int j=1;j<=i;j++) dp[i][j]=(dp[i][j-1]+dp[i-1][j-1])%MOD;
		else for(int j=i;j>=1;j--) dp[i][j]=(dp[i][j+1]+dp[i-1][j])%MOD;
	}
	for(int i=1;i<=n;i++) ans=(ans+dp[n][i])%MOD;
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 68992
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
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)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int W,a,b;cin>>W>>a>>b;
    if(a+W < b) cout << b - (a+W);
    else if(b+W < a) cout << a - (b+W);
    else cout << 0;
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define ll long long

int main()
{
	ll N, A, B;
	cin >> N >> A >> B;

	if (A > B) cout << 0 << endl;
	else if (N == 1 && A!=B) cout << 0 << endl;
	else if (N == 1) cout << 1 << endl;
	else {
		ll min = A + B + (N - 2)*A, max = A + B + (N - 2)*B;
		cout << max - min + 1 << endl;
	}
	return 0;
}

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

int main() {
  for(int n; cin >> n && n;) {
    vector<pair<pair<int,int>,pair<int,char> > > v;
    for(int i = 0; i < n; ++i) {
      char t;
      cin >> t;
      int a = 0, b = 0;
      for(int j = 0; j < n-1; ++j) {
        int r;
        cin >> r;
        if(r == 0) ++a;
        else if(r == 1) ++b;
      }
      v.push_back(make_pair(make_pair(-a, b), make_pair(i, t)));
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < v.size(); ++i) {
      cout << v[i].second.second << endl;
    }
  }
  return 0;
}

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


def main(input_str):
    n, m, d = list(map(int, input_str.split(' ')))
    if d == 0:
        retval = (m - 1) * (n - d)/(n * n)
    else:
        retval =  (m - 1) * (n - d) * 2/(n * n)
    print(retval)
        

if __name__ == '__main__':
    try:
        main(input().strip())
    except EOFError:
        pass


Measured memory_bytes: 2940
n,m,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
x.append(X)
y.append(Y)
a = sorted(x)[-1]
b = sorted(y)[0]
if a < b:
	print("No War")
else:
	print("War")


Measured memory_bytes: 3060
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

def tobit(N):
    ret = 0
    for n in N:
        ret |= (1 << n)
    
    return ret

N, M = LI()
C = []
for i in range(M):
    a, b = LI()
    C.append([a, tobit([x-1 for x in LI()])])

dp = [INF] * (1 << N)
dp[0] = 0

for i in range(1 << N):
    for cost, key in C:
        dp[i | key] = min(dp[i | key], dp[i] + cost)

print(dp[-1] if dp[-1] != INF else "-1")


Measured memory_bytes: 42732
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);


const int N = 1e6 + 10;



int main(){
   IOS

    int n; cin>>n;

    vi a(n);

    unordered_map<int,vi> mp;
    
    for(int i = 0; i < n; i++){
        cin>>a[i];
    }

    sort(all(a));

    for(int i = 0; i < n; i++){
        mp[a[i]].pb(i);
    }

    vi cnt(n);

    for(int i = 0; i < n-1; i++){
        for(int j = 2 * a[i]; j <= a[n-1]; j+= a[i]){
            for (int k : mp[j]){
                cnt[k] += 1 + cnt[i];
                break;
            }
        }
    }


    int ans = 0;
    for(int i = 0; i < n; i++){
        if(mp[a[i]].size() == 1 and cnt[i] == 0)ans++;
    }
    cout<<ans<<"\n";









}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1) res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 64364
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<long long, long long>
using namespace std;
using ll = long long;
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; }
static const ll INF = 1e17;

int main(){
  int n; cin >> n;
  vector<P> v(n);
  rep(i, n){
    ll x, y; cin >> x >> y;
    v[i].first = x + y;
    v[i].second = x - y;
  }

  ll ans = 0;
  ll maxx = -INF, maxy = -INF, minx = INF, miny = INF;
  rep(i, n){
    chmax(maxx, v[i].first);
    chmax(maxy, v[i].second);
    chmin(minx, v[i].first);
    chmin(miny, v[i].second);
  }

  ans = max(maxx - minx, maxy - miny);
  cout << ans << endl;
}


Measured memory_bytes: 6360
#include<cstdio>
#include<cstring>
using namespace std;
const int N=1e5;
char s[N];
int n,ans;
int main()
{
	int i,j;
	scanf("%s",s);
	n=strlen(s);
	for (i=0;i<n-8;i++)
	  printf("%c",s[i]);
}

Measured memory_bytes: 128
(n, m) = map(int, input().split())
a = []
for _ in range(n):
    a.append(list(map(int, input().split())))
    a[-1].pop(0)

score = [0 for _ in range(m)]
for i in a:
    for food_index in i:
        score[food_index - 1] += 1
print(score.count(n))

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

int absolute(int a){
    if(a > 0){
        return a;
    }else{
        return -a;
    }
    
}

int main(void) {
    // insert code here...
    int num;
    cin >> num;
    
    int height[num];
    for(int i = 0; i < num; i++){
        cin >> height[i];
        
    }
    
    int min[num];
    min[0] = 0;
    min[1] = absolute(height[1] - height[0]);
    
    for(int i = 2; i < num; i++){
        int a = absolute(height[i] - height[i-1]);
        int b = absolute(height[i] - height[i-2]);
        
        if(min[i-1] + a < min[i-2] + b){
            min[i] = min[i-1] + a;
        }else{
            min[i] = min[i-2] + b;
        }
        
    }
    
//    for(int i = 0; i < num; i++){
//        cout << min[i] << endl;
//    }
    
    cout << min[num - 1] << endl;
    
    return 0;
}


Measured memory_bytes: 1024
implicit none

integer y,m
character s*10

read(5,'(a)') s
read(s(1:4),*) y
read(s(6:7),*) m



if(y.lt.2019) then
write(6,*) "Heisei"
else if(y.eq.2019 .and. m .le.4) then
write(6,*) "Heisei"
else
write(6,*) "TBD"
endif
 
end

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define N 1000+20
int a[N];
int main()
{
	int n,sum = 0;
	cin >> n;
	for (int i = 0; i < 2 * n; i++)
	{
		cin >> a[i];
	}
	sort(a, a + 2*n);
	for (int i = 0; i < 2 * n; i+=2)
	{
		sum += a[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 3544
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		if((a*100 + b*10 + c) % 4 == 0){
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 23892
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    vector<bool> s(f + 1), t(f + 1);
    for (int i = 0; i <= f; i += 100 * a) {
        for (int j = i; j <= f; j += 100 * b) {
            s[j] = true;
        }
    }
    for (int i = 0; i <= f; i += c) {
        for (int j = i; j <= f; j += d) {
            t[j] = true;
        }
    }
    
    double r = 0;
    int x = 0, y = 0;
    for (int i = 0; i <= f; i += 100) {
        if (!s[i]) continue;
        for (int j = 0; i + j <= f && 100 * j <= e * i; ++j) {
            if (!t[j]) continue;
            double l = double(j) / (i + j);
            if (l >= r) {
                r = l;
                x = i;
                y = j;
            }
        }
    }
    cout << x + y << ' ' << y << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	int k = sc.nextInt();
      	ArrayList<Integer> p = new ArrayList<Integer>();
		ArrayList<Integer> min = new ArrayList<Integer>();
      for(int i=0;i<n;i++){
      	p.add(sc.nextInt());}
      int plen = p.size();
      for(int i = 0;i<plen;i++){
        int minint=p.get(0);
        for(int j = 0;j<p.size();j++){
        	if(p.get(j)<minint){
            		minint=p.get(j);
            		}
        		}
        	min.add(minint);
        	int num = p.indexOf(minint);
        	p.remove(num);
      	}
      int ans=0;
      for(int i=0;i<k;i++){
        ans=ans+min.get(i);
      }
      System.out.println(""+ans);
	}
}

Measured memory_bytes: 40884
#include<iostream>
using namespace std;
int main()
{
	int a,b,c=0;
	cin>>a>>b;
	for(int i=0;i<b;i++)
	{
		int t;
		cin>>t;
		c+=t;
	}
	if(c>=a)
	cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
n,m = map(int,input().split())
A = []
B = []
C = []
D = []
for x in range(n):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
for y in range(m):
    c,d = map(int,input().split())
    C.append(c)
    D.append(d)
for i in range(n):
    d = []
    for j in range(m):
        d.append(abs(A[i]-C[j])+abs(B[i]-D[j]))
    print(d.index(min(d))+1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define MAXN 100000
#define MAXP 670000
#define MAXA 10000000
#define pii pair<int,int>
#define MP(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))


using namespace std;
void get(int &v)
{
	char c;
	while((c=getchar())!=EOF&&isdigit(c)==0);
	v=c-'0';
	while((c=getchar())!=EOF&&isdigit(c))
		v=(v<<1)+(v<<3)+c-'0';
	return ;
}
int get()
{
	int v;
	char c;
	while((c=getchar())!=EOF&&isdigit(c)==0);
	v=c-'0';
	while((c=getchar())!=EOF&&isdigit(c))
		v=(v<<1)+(v<<3)+c-'0';
	return v;
}
int q[3];
int main()
{
	int n,last=0;
	for(get(n);n;n--)
		switch(get()&3)
		{
			case 0:q[0]++;break;//4
			case 2:q[1]++;break;//2
			default:q[2]++;break;//1,3
		}
	while(q[0]||q[1]||q[2])
	{
		if(last==0)
		{
			if(q[2])
				q[2]--,last=2;
			else if(q[1])
				q[1]--,last=1;
			else if(q[0])
				q[0]--,last=0;
		}
		else if(last==1)
		{
			if(q[1])
				q[1]--,last=1;
			else if(q[0])
				q[0]--,last=0;
			else
				break;
		}
		else if(last==2)
		{
			if(q[0])
				q[0]--,last=0;
			else
				break;
		}
	}
	if(q[0]||q[1]||q[2])
		puts("No");
	else
		puts("Yes");
	return 0;
}
//g++ -g c.cpp -o c

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

long int M = 1e+7;
int main(void){
    int n;
    cin >> n ;
    vi a(n);
    rep(i,n-1){
        int tmp;
        cin >> tmp;
        a[tmp-1]++;
    }
    rep(i,n){
        cout << a[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3672
n,m=map(int,input().split())
xyz=[list(map(int,input().split())) for i in range(m)]
ans=[0 for i in range(n+1)]
h=[[] for i in range(n+1)]
for i in xyz:
  x,y,z=i
  h[x].append(y)
  h[y].append(x)
fa=0
i=1
while(i<=n):
  if(ans[i]==0):
    q=[i]
    ans[i]=1
    fa+=1
    while(len(q)>0):
      t=q.pop()
      for j in h[t]:
        if(ans[j]==0):
          q.append(j)
          ans[j]=1
    i+=1 
  else:
    i+=1
print(fa)

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

N=input()

#約数列挙
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)
    return divisors

def func(a,b):
    return a**5-b**5

L=make_divisors(N)
for yakusu in L:
    for a in range(10**3):
        b=a-yakusu
        if func(a,b)==N:
            print a,b
            quit()


Measured memory_bytes: 86976