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

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) { return '"' + s + '"'; }

string to_string(const char* s) { return to_string((string)s); }

string to_string(bool b) { return (b ? "true" : "false"); }

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(vector<A> v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) void(0)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k;
  cin >> k;
  int a = 7;
  int cnt = 1;
  int ten = 10;
  while (a % k != 0) {
    a += 7 * ten;
    a %= k;
    ten *= 10;
    ten %= k;
    cnt++;
    if (cnt > 1000000) {
      cout << -1 << '\n';
      return 0;
    }
  }
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 3628
mod=pow(10,9)+7
n,k=map(int,input().split())
mini,maxi=-1,-1
ranges=[[0,0]]
ans=0
for i in range(k,n+2):
    mini=(i*(i-1))//2
    maxi=((i)*(n+n-i+1))//2
    ans += (maxi-mini+1)%mod
    ans=ans%mod

print(ans)

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

using namespace std;

char s[100010];

int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1),last=1,ans=0;
	for(int i=2;i<=n;i++)
		if(s[i]!=s[last])
		{
			ans++;
			last=i;
		}
	printf("%d\n",ans);
}

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

int main() {
  int n;
  string res = "No";
  cin >> n;
  for(int i=1; i<10; ++i){
    for(int j=1; j<10; ++j){
      if(i*j == n){
        res = "Yes";
        goto loopend;
      }
    }
  }
  loopend:
  cout << res << endl;
  return 0;
}


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

const int N=50;
int n,m,k,x,ok[N][N];

int main()
{
	int i,j;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i)
	{
		scanf("%d",&k);
		for(j=1;j<=k;++j)
		{
			scanf("%d",&x);
			ok[i][x]=1;
		}
	}
	
	int cnt=0;
	for(j=1;j<=m;++j)
	{
		for(i=1;i<=n;++i)
			if(!ok[i][j])
				break;
		cnt+=(i>n);
	}
	printf("%d\n",cnt);
	
	return 0;
}

Measured memory_bytes: 256
a,b,c = map(int,input().split())
if a > b:
    tmp = a
    a = b
    b = tmp
if b > c:
    tmp = b
    b = c
    c = tmp
if a > b:
    tmp = a
    a = b
    b = tmp
print(str(a) + " " + str(b) + " " + str(c))
        

    


Measured memory_bytes: 5592
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int a,b,n,s;
	div_t d;
	while(scanf("%d%d%d",&a,&b,&n)==3)
	{
		a %= b;
		s = 0;
		while(n--)
		{
			d = div(a*10,b);
			s += d.quot;
			a = d.rem;
		}
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 0
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
soinsu = factorization(int(input()))
if soinsu[0][0]==1:
  print(0)
  exit()
answer=0
for i in range(len(soinsu)):
  x = soinsu[i][1]
  j = 0
  while x >= 0 :
    j+=1
    x -= j
  else:answer += j-1
print(answer)

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

// vector<vector<ll> > b(300000, vector<ll>(300000, 0));
// vector<ll> h(300000, 0);
// vector<ll> w(300000, 0);

int main() {
  IN (ll, H);
  IN (ll, W);
  IN (ll, M);
  map<pair<int, int>, int> hw;
  vector<ll> h(H, 0);
  vector<ll> w(W, 0);
  REP(i, M) {
    IN(ll, tmp_h);
    tmp_h--;
    IN(ll, tmp_w);
    tmp_w--;
    hw[make_pair(tmp_h, tmp_w)] = 1;
    // b.at(tmp_h).at(tmp_w) = 1;
    h.at(tmp_h)++;
    w.at(tmp_w)++;
  }

  vector<ll> max_h = {};
  ll max_val_h = 0;
  REP(i, H) {
    if (h.at(i) > max_val_h) {
      max_val_h = h.at(i);
      max_h.clear();
      max_h.push_back(i);
    }
    else if (h.at(i) == max_val_h) max_h.push_back(i);
  }
  vector<ll> max_w = {};
  ll max_val_w = 0;
  REP(i, W) {
    if (w.at(i) > max_val_w) {
      max_val_w = w.at(i);
      max_w.clear();
      max_w.push_back(i);
    }
    else if (w.at(i) == max_val_w) max_w.push_back(i);
  }

  ll max = 0;
  REP(i, max_h.size()) {
    REP(j, max_w.size()) {
      ll tmp = h.at(max_h.at(i)) + w.at(max_w.at(j));
      bool flag = true;
      if (hw.count(make_pair(max_h.at(i), max_w.at(j)))) {
        flag = false;
      }
      // if (b.at(max_h.at(i)).at(max_w.at(j)) == 1) tmp--;
      // if (tmp > max) max = tmp;
      if (flag) {
        cout << tmp << endl;
        return 0;
      } else {
        max = tmp - 1;
      }
    }
  }
  cout << max << endl;

  return 0;
}


Measured memory_bytes: 35072
#include<bits/stdc++.h>
#define maxn 30
#define u32d unsigned int
#define LL   long long
#define INF  0x7FFFFFFF
using namespace std;

int nums[1000]; 
int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> nums[i];
	}
	int ans = 0;
	for(int i = 1; i < n - 1; ++i){
		if((nums[i] > nums[i - 1]) ^ (nums[i] > nums[i + 1])){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

int main()
{
    int a,b;
    cin >> a >> b;
    if(b<a){
        cout << a-1;
    }else{
        cout << a;
    }
    }


Measured memory_bytes: 3608
#include <iostream>
#include <map>

using namespace std;

int main ( void )
{
	int n;

	while ( cin >> n, n )
	{
		map<char, char> t;

		for (int i = 0; i < n; ++i)
		{
			char a, b;
			cin >> a >> b;
			t[a] = b;
		}

		int m;
		cin >> m;

		for (int i = 0; i < m; ++i)
		{
			char c;
			cin >> c;
			if ( t.count(c) )
				cout << t[c];
			else
				cout << c;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1188
import java.util.*;

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

        for (int i = 0; i < S.length; i++) {
            char tmp = S[0];
            for (int j = 0; j < S.length - 1; j++) {
                S[j] = S[j + 1];
            }
            S[S.length - 1] = tmp;
            if (String.valueOf(S).equals(T)) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");

    }
}


Measured memory_bytes: 21844
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int q = sc.nextInt();
        int[] t = new int[q];
        int[] f = new int[q];
        String[] c = new String[q];
        for (int i = 0; i < q; i++) {
            t[i] = sc.nextInt();
            if (t[i] == 1) {
                continue;
            }
            f[i] = sc.nextInt();
            c[i] = sc.next();
        }

        Deque<String> queue = new ArrayDeque<>();
        queue.addFirst(s);
        boolean reversed = false;
        for (int i = 0; i < q; i++) {
            if (t[i] == 1) {
                reversed = Boolean.logicalXor(reversed, true);
                continue;
            }
            if (f[i] == 1 && !reversed || f[i] == 2 && reversed) {
                queue.addFirst(c[i]);
                continue;
            }
            queue.addLast(c[i]);
        }
        StringBuilder sb = new StringBuilder();
        int qlen = queue.size();
        for (int i = 0; i < qlen; i++) {
            if (!reversed) {
                sb.append(queue.removeFirst());
                continue;
            }
            String str = queue.removeLast();
            if (s.equals(str)) {
                str = new StringBuilder(str).reverse().toString();
            }
            sb.append(str);
        }
        System.out.println(sb.toString());
    }

}


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

int main(){
  int a, b, c, x, y, z, ans;

  cin>>a>>b>>c;

  if(a > b) x = a - b;
  else x = b - a;

  if(b > c) y = b - c;
  else y = c - b;

  if(c > a) z = c - a;
  else z = a - c;

  ans = x + y;
  if(ans > y + z) ans = y + z;
  if(ans > z + x) ans = z + x;

  cout<<ans<<endl;

  return 0;
}


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

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

    int n;
    cin >> n;

    int ans = n;
    for(int i = 0; i < 2; i++){
        ans *= n;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

namespace AtCoder.ABC110
{
    public class A
    {
        public static void Solve()
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            Console.WriteLine((a * b) % 2 == 0 ? "No" : "Yes");
        }    
    }
}

namespace AtCoder {
    class Program
    {
        static void Main(string[] args)
        {
            ABC110.A.Solve();
        }
    }
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n, m;
int x[MAX_N];

map<int, vector<int>> container;
map<int, int> consume;
map<int, int> whole;
set<int> visited;

int ans;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &m);

  for (int i = 0; i < n; ++i) {
    scanf("%d", &(x[i]));
  }

  for (int i = 0; i < n; ++i) {
    container[x[i] % m].push_back(x[i]);
  }

  for (auto &e : container) {
    whole[e.first] = e.second.size();

    map<int, int> cnt;

    for (auto &d : e.second) {
      cnt[d] += 1;
    }

    for (auto &d : cnt) {
      consume[e.first] += d.second / 2;
    }
  }

  ans = 0;

  for (auto &e : whole) {
    int key = e.first;
    int opposite_key = (m - key) % m;

    if (visited.find(key) != visited.end() ||
        visited.find(opposite_key) != visited.end())
      continue;

    visited.insert(key);
    visited.insert(opposite_key);

    if (opposite_key == key) {
      ans += whole[key] / 2;
    } else {
      if (whole.find(opposite_key) == whole.end()) {
        ans += consume[key];
        continue;
      }

      int x = key;           // bigger
      int y = opposite_key;  // smaller

      if (whole[x] < whole[y]) {
        swap(x, y);
      }

      int diff = abs(whole[x] - whole[y]);
      int actual_consumed_pair = min(diff / 2, consume[x]);

      ans += actual_consumed_pair;  // duplicate pair consume
      ans += whole[y];
    }
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 25600
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

map<char, char> mp;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string s1, s2;
    if (sx < tx) {
        rep(i, tx - sx) s1.push_back('R');
    }
    else {
        rep(i, sx - tx) s1.push_back('L');
    }
    if (sy < ty) {
        rep(i, ty - sy) s1.push_back('U');
        s2.push_back('D');
    }
    else {
        rep(i, sy - ty) s1.push_back('D');
        s2.push_back('U');
    }
    if (sx < tx) {
        rep(i, tx - sx) s2.push_back('R');
        s2.push_back('R');
    }
    else {
        rep(i, sx - tx) s2.push_back('L');
        s2.push_back('L');
    }
    if (sy < ty) {
        rep(i, ty - sy) s2.push_back('U');
        s2.push_back('U');
    }
    else {
        rep(i, sy - ty) s2.push_back('D');
        s2.push_back('D');
    }
    if (sx < tx) s2.push_back('L');
    mp['R'] = 'L';
    mp['L'] = 'R';
    mp['U'] = 'D';
    mp['D'] = 'U';
    cout << s1;
    rep(i, s1.length()) {
        cout << mp[s1[i]];
    }
    cout << s2;
    rep(i, s2.length()) {
        cout << mp[s2[i]];
    }
    cout << endl;



    return 0;
}
//UURRURRDDDLLDLLULUUURRURRDDDLLDL
//RRRUUULLLDDDDRRRRUUUULULLLLDDDDR

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

int main(){
  int N,M;
  cin >> N >> M;
  vector< vector<int> > s(M);
  int k;
  for(int i=0;i<M;i++){
    cin >> k;
    s.at(i).resize(k);
    for(int j=0;j<k;j++){
      cin >> s.at(i).at(j);
      s.at(i).at(j)--;
    }
  }
  vector<int> p(M);
  for(int i=0;i<M;i++){
    cin >> p.at(i);
  }
  int ans=0;
  for(int i=0;i<(1<<N);i++){
    bool flag=true;
    for(int j=0;j<M;j++){
      int c=0;
      for(int x : s.at(j)){
        if((i>>x)&1){
          c++;
        }
      }
      c%=2;
      if(c!=p.at(j)){
        flag=false;
      }
      if(!flag){
        break;
      }
    }
    if(flag){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
int main() {
    string S;
    cin >> S;
    if(S == "ABC") cout << "ARC" << endl;
    if(S == "ARC") cout << "ABC" << endl;
    return 0;
}



Measured memory_bytes: 3592
n = int(input())
b = list(map(int,input().split()))
a = [0]*n
a[0] = b[0]
a[n-1] = b[n-2]
if n >= 3:
    for i in range(2,n):
        a[i-1] = min(b[i-1],b[i-2])
print(sum(a))

Measured memory_bytes: 9152
A,B,C,D = map(int, input().split())
import fractions
F=(C*D)//fractions.gcd(C,D)
A = A-1
Ans0 = B - B//C - B//D + B//F
Ans1 = A - A//C - A//D + A//F
print(Ans0-Ans1)


Measured memory_bytes: 5048
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
import itertools
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

N,X,T = MI()

time = 0
takoyaki = 0
while takoyaki < N:
    time += T
    takoyaki += X

print(time)


Measured memory_bytes: 27020
#include<bits/stdc++.h>
using namespace std;
#define Set(a,b) memset(a,b,sizeof(a))
template<class T>inline void init(T&x){
  x=0;char ch=getchar();bool f=0;
  for(;ch>'9'||ch<'0';ch=getchar()) if(ch=='-') f=1;
  for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch-48);
  if(f) x=-x;
  return;
}
typedef long long ll;
typedef double db;
const int mod=998244353,G=3,phi=998244352;
const int N=5e5+10;
int C[N];
int n,m;
int id[N],l[N],r[N];
int tr[N],ans[N],ls[N];
#define lowbit(a) ((a)&(-a))
inline void Add(int p,int x){for(;p<=n;p+=lowbit(p)) tr[p]+=x;}
inline int Query(int p){int s=0;for(;p;p-=lowbit(p)) s+=tr[p];return s;}
inline bool cmp(int x,int y){return r[x]<r[y];}
int main(){
  init(n),init(m);
  for(int i=1;i<=n;++i) init(C[i]);
  for(int i=1;i<=m;++i) init(l[i]),init(r[i]),id[i]=i;
  sort(id+1,id+1+m,cmp);
  int nowr=0;
  for(int i=1;i<=m;++i) {
    int I=id[i];
    while(nowr<r[I]) {
      ++nowr;int c=C[nowr];
      if(ls[c]) Add(ls[c],-1);
      Add(nowr,1);ls[c]=nowr;
    }
    ans[I]=Query(r[I])-Query(l[I]-1);
  }
  for(int i=1;i<=m;++i) cout<<ans[i]<<endl;
}


Measured memory_bytes: 17364
#include<bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
#define pii pair<pi,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define lli long long int
#define f(i,a,b) for (lli i = a; i <= b; i++)
#define fr(i,a,b) for (lli i = a; i >= b; i--)
#define s(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define p(x)	printf("%d",x)
#define pl(x)	printf("%lld",x)
#define ss(s)	scanf("%s",s)
#define mod 1000000007
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

void solve()
{
	lli n, k, ans = 0;
	sl(n), sl(k);
	lli price[n];
	f(i, 0, n - 1)
	sl(price[i]);
	sort(price, price + n);
	lli j = 0;
	while (k--)
		ans += price[j++];
	pl(ans), printf("\n");
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	IOS;
	lli t = 1;
	// sl(t);
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 3828
import functools
import fractions

def main():
  if 'get_ipython' not in globals():  
    # For Subsession
    N = int(input())
    A = list(map(int, input().split()))
  else:
    # N = 3
    # A = [7,6,8]
    N = 3
    A = [12,15,18]
    # N = 3
    # A = [1,1000000000,1000000000]

  AL = [0] * N    
  AR = [0] * N
  for i in range(N):
    if i != 0:
      AL[i] = fractions.gcd(AL[i-1],A[i])
    else:
      AL[i] = A[i]
    j = N - i - 1
    if j!= N - 1:
      AR[j] = fractions.gcd(AR[j+1],A[j])
    else:
      AR[j] = A[j]
      
  if 'get_ipython' in globals():   
    print(AL)
    print(AR)
  
  x = 0
  for i in range(N):
    if i == 0:
      tmp = AR[i+1]
    elif i == N - 1:
      tmp = AL[i-1]
    else:
      tmp = fractions.gcd(AL[i-1],AR[i+1])
    if tmp > x: x = tmp
  
  print(x)
    
main()

Measured memory_bytes: 16132
#include<bits/stdc++.h>
#define ll long long
#define xd long double
#define mx 103
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define SL(x) scanf("%d",&x)
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define CLR(x) memset(x,0,sizeof(x))
#define pll pair<ll,ll>
#define pb push_back
using namespace std;
ll a[mx];
int main(){
    IO;
    ll n,k;
    cin>>n>>k;
    fr(i,0,n-1)cin>>a[i];
    sort(a,a+n);
    ll x=0;
    ll y=0;
    fr(i,0,n-1){
        x+=a[i];
        if(x<=k and i!=(n-1))y++;
        else if(x==k and i==n-1)y++;
        else break;
    }
    cout<<y<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    string s; cin >> s;

    int ans = 0;
    int tmp = 0;

    rep(i,s.size()){
        if(s[i] == 'A' ||s[i] == 'T' ||s[i] == 'G' ||s[i] == 'C' ){
            tmp++;
        }
        else{
            ans = max(tmp,ans);
            tmp = 0;
        }
    }

    ans = max(tmp,ans);

    dunk(ans);
}
    


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

using namespace std;

struct SegmentTree {
    int n;
    int type;
    vector<int> st;
    int NEUTRO;
    void init(int _, int __, int ___) {
        n =  _;
        st.resize(5 * _);
        NEUTRO = ___;
        type = __;
    }
    SegmentTree() {}
    
    int ope(int x, int y) {
        if(type == 0) return max(x,y);
        if(type == 1) return min(x,y);
        if(type == 2) return x + y;
        return 0;
    }

    void update(int pos,int value){
        for (st[pos+=n]= value; pos > 1; pos>>=1) {
            st[pos>>1] = ope(st[pos],st[pos^1]);
        }
    }
    // interval[l,r)
    int query(int l,int r){
        int ans = NEUTRO;
        r++;
        for (l += n,r +=n ; l < r ; l >>= 1,r >>= 1){
            if(l&1) ans = ope(ans,st[l++]);
            if(r&1) ans = ope(ans,st[--r]);
        }
        return ans;
    }
};

int v[200010];

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

    for (int i = 0; i < n; ++i)
        cin >> v[i];

    SegmentTree st;
    st.init(n, 2, 0);
    
    int ans = 0;
    
    for (int i = 0; i < n; ++i) {
        st.update(v[i], 1);
        ans += (st.query(v[i], n) == i + 1);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		//?????£?????????
		String strInput = null;

		int intProv = 0;

		int[] intNumList = new int[3];

		boolean NumOk = false;
		try {
			//??\????????????????????????
			BufferedReader strLine = new BufferedReader(new InputStreamReader(System.in));
			strInput = strLine.readLine();

			String[] strNumList = strInput.split(" ");

			//int????????????
			for (int i = 0; i < strNumList.length; i++) {
				intNumList[i] = Integer.parseInt(strNumList[i]);
			}

			//??\?????°???????????§??????
			for (int i = 0; i < intNumList.length; i++) {
				if (intNumList[i] >= 1 && intNumList[i] <= 10000) {

					NumOk = true;
				}else{
					NumOk = false;
					break;
				}
			}

			if (NumOk) {

				for (int i = 0; i < intNumList.length; i++) {

					for (int j = i + 1; j < intNumList.length;j++) {

						if(intNumList[i] >= intNumList[j]){

							//??°????????\?????????
							intProv =  intNumList[i];
							intNumList[i] = intNumList[j];
							intNumList[j] = intProv;
						}
					}
				}
				//???????????????
				System.out.println(intNumList[0] + " " + intNumList[1] + " " + intNumList[2]);
			}
		}catch (IOException e1) {
			System.out.println(e1);
		}catch (NumberFormatException e2) {
			System.out.println(e2);
		}

	}

}

Measured memory_bytes: 24108
#include <cstdio>
#include <algorithm>

typedef long long i64;

const int N = 200000 + 10;

int n, k, m;
int a[N], b[N];

i64 sorted[N];

int bit[N];

void add(int p) {
  for (; p <= m; p += p & -p) ++bit[p];
}

int query(int p) {
  int res = 0;
  for (; p; p ^= p & -p) res += bit[p];
  return res;
}

int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]), a[i] -= k;
  static i64 sum[N];
  for (int i = 1; i <= n; ++i) sorted[i] = sum[i] = sum[i - 1] + a[i];
  sorted[m = n + 1] = 0;
  std::sort(sorted + 1, sorted + m + 1);
  m = std::unique(sorted + 1, sorted + m + 1) - sorted - 1;
  for (int i = 0; i <= n; ++i) b[i] = std::lower_bound(sorted + 1, sorted + m + 1, sum[i]) - sorted;
  i64 ans = 0;
  for (int i = 1; i <= n; ++i) {
    add(b[i - 1]);
    ans += query(b[i]);
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 5632
N = int(input())
A = []
A += list(map(int,input().split()))
S = 0
k = 0

Dum = 0
Gum = 0

for i in range(0, N-1):
    Dum += A[i]
    Gum += Dum * A[i+1]

print(Gum % 1000000007)

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

int main(){
  int N;
  int K;
  cin >> N >> K;
  
  int out=0;
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    out += min(x, K-x)*2;
  }
  
  cout << out << 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;
int mod = 1000000007;

void solve();

int main(void){
    int N, C;
    cin >> N >> C;
    vector<int> grid[3];
    int D[C+1][C+1];
    rep(i, C) rep(j, C) cin >> D[i+1][j+1];
    rep(i, N){
        rep(j, N){
            int temp; cin >> temp;
            grid[(i+j+2) % 3].push_back(temp);
        }
    }

    if(N == 1){
        cout << 0 << endl;
        return 0;
    }
    //rep(i, grid[0].size()) cout << grid[0][i] << endl;
    pair<int, int> choice[3][3];
    rep(i, 3){
        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
        int loop = grid[i].size();
        rep(j, C){
            int acc = 0;
            rep(k, loop){
                acc += D[grid[i][k]][j+1]; 
            }
            pq.push(make_pair(acc, j+1));
        }
        rep(j, 3){
            choice[i][j] = pq.top();
            pq.pop();
        }
    }

    //問題は最適色がかぶっている時
    //2番目に最適なのも被っている可能性がある
    //3番目まで調べればOK
    //rep(i, 3) rep(j, 3) cout << choice[i][j].second << " "; cout << endl;
    //rep(i, 3) rep(j, 3) cout << choice[i][j].first << " "; cout << endl;

    int loop = 27;
    int res = mod;
    rep(i, loop){
        int val = i;
        vector<int> work;
        rep(j, 3){
            work.push_back(val % 3);
            val /= 3;
        }
        if(choice[0][work[0]].second != choice[1][work[1]].second && choice[1][work[1]].second != choice[2][work[2]].second && choice[2][work[2]].second != choice[0][work[0]].second){
            int eval = choice[0][work[0]].first + choice[1][work[1]].first + choice[2][work[2]].first;
            if(eval < res) res = eval;
        }
    }
    cout << res << endl;

    return 0;
}

void solve(){}

Measured memory_bytes: 1520
#include <stdio.h>

int		sum_up(int nb)
{
	int sum;
	sum = 0;
	if (nb == 10000)
		sum = 1;
	if (nb >= 1000 && nb < 10000)
	{
		sum += nb % 10;
		nb /= 10;
		sum += nb % 10;
		nb /= 10;
		sum += nb % 10;
		nb /= 10;
		sum += nb % 10;
	}
	if (nb >= 100 && nb < 1000)
	{
		sum += nb % 10;
		nb /= 10;
		sum += nb % 10;
		nb /= 10;
		sum += nb % 10;
	}
	if (nb >= 10 && nb < 100)
	{
		sum += nb % 10;
		sum += nb / 10;
	}
	return (sum);
}

int		main(void)
{
	int n;
	int a,b;
	int sum;
	scanf("%d%d%d", &n,&a,&b);
	int i = 1;
	sum = 0;
	while (i <= n)
	{
		if (i < 10)
		{
			if (i >= a && i <= b)
				sum += i;
		}
		else if (i >= 10)
		{
			if (sum_up(i) >= a && sum_up(i) <= b)
				sum += i;
		}
		i++;
	}
	printf("%d", sum);
	return (0);
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  int N;
  int i;
  scanf("%d", &N);
  int a[200010], b[200010];
  for (i = 0; i < N; i++) {
    scanf("%d", &a[i]);
    b[i] = a[i];
  }
  sort(a, a+N);
  double med = ((a[N/2-1]+a[N/2])*1.0)/2;
  for (i = 0; i < N; i++) {
    if (b[i] >= med) {
      printf("%d\n", a[N/2-1]);
    } else {
      printf("%d\n", a[N/2]);
    }
  }
  return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;

#define PI 3.141592653589793238462643383279
#define abs(x) ((x)<0?(-(x)):(x))
typedef long long Int;
double x[108000], y[108000];
bool ok[1080000];
double ans[1080000];
Int n;
double hoge(Int a, Int b, Int c){
	double ax = x[b] - x[a], ay = y[b] - y[a];
	double bx = x[c] - x[a], by = y[c] - y[a];
	return acos(
							(ax*bx+ay*by)/sqrt(ax*ax+ay*ay)/sqrt(bx*bx+by*by)
							);
}
Int area(Int a, Int b, Int c){
	Int ax = x[b] - x[a], ay = y[b] - y[a];
	Int bx = x[c] - x[a], by = y[c] - y[a];
	return abs(ax * by-  ay * bx);
}

bool inner(Int x, Int a, Int b, Int c){
	if(x ==  a || x == b || x == c)return false;
	if(area(a,b,c) == 0)return 0;
	return area(x, a, b) + area(x, b, c) + area(x, c, a) == area(a, b, c);
}

int main(){
	cin >> n;
	for(Int i = 0;i < n;i++){
		cin >> x[i] >> y[i];
	}

	for(Int i = 0;i < n;i++){
		ok[i] = true;
		for(Int j = 0;j < n;j++){
			for(Int k = 0;k < n;k++){
				for(Int l = 0;l < n;l++){
					if(inner(i,j,k,l))ok[i] = false;
				}
			}
		}
	}

	for(Int i = 0;i < n;i++){
		for(Int j = 0;j < n;j++){
			for(Int k = 0;k < n;k++){
				if(i == j || i == k)continue;
				ans[i] = max(ans[i], hoge(i, j, k));
			}
		}
	}
	for(Int i = 0;i < n;i++){
		if(!ok[i])cout << 0 << endl;
		else printf("%.10lf\n", (PI - ans[i]) / PI / 2);
	}
	return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
  
int main() {
    string s;
    cin >> s;
    ll n = s.size();
    
    if(s == "zyxwvutsrqponmlkjihgfedcba") {
        out(-1);
        re0;
    }

    string ans = "";
    if(n == 26) {
        string tmp = s;
        next_permutation(all(tmp));
        rep(i, 26) {
            if(s[i] != tmp[i]) {
                ans = tmp.substr(0, i+1);
                break;
            }
        }
    }
    else {
        vl c(26);
        rep(i, n) {
            c[s[i] - 'a'] = 1;
        }
        ans = s;
        rep(i, 26) {
            if(c[i] == 0) {
                char c1 = i + 'a';
                ans = ans + c1;
                break;
            }
        }
    }

    out(ans);
    re0;
}

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

int main(){
    long long x;
    scanf("%lld",&x);
    long long ans=(x/11)*2;
    if(x%11>6){
        ans+=2;
    }
    else if(x%11>0) ans+=1;
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 128
h,w=map(int,input().split())
cnt=0
ans=[]
a=[list(map(int,input().split())) for _ in range(h)]
for i in range(h):
    for j in range(w-1):
        if a[i][j]%2:
            a[i][j+1]+=1
            ans.append([i+1,j+1,i+1,j+2])
            cnt+=1
for i in range(h-1):
    if a[i][w-1]%2:
        a[i+1][w-1]+=1
        ans.append([i+1,w,i+2,w])
        cnt+=1
print(cnt)
for i in ans:
    print(*i)

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

int main(){
    int N;
    cin >> N;
    int d[N];
    for (int i=0; i<N; i++) {
        cin >> d[i];
    }
    sort(d, d+N);

    int ans = d[N/2] - d[N/2-1];

    cout << ans << endl;

}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
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 pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << "[line : " << __LINE__ <<"]"<< pp(x)
#define dg2(x,y) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y)
#define dg3(x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x , y) memset(x , y , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b;
  cin >> a >> b;
  cout << max(0ll ,a - 2*b);

}

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

int main() {
    double a, b, t;
    cin >> a >> b >> t;
    int ans = (t+0.5)/a;
    ans *= b;
    cout << ans << endl;
    return 0;
}

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

import sys
input = sys.stdin.buffer.readline

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int,input().split())
uf = UnionFind(N)

for i in range(M):
    A, B = map(int,input().split())
    uf.union(A-1,B-1)

ans = 0
for i in range(N):
    ans = max(ans, uf.size(i))
print(ans)

    

Measured memory_bytes: 74024
#include <vector>
#include <iostream>
#include <queue>

using namespace std;

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

    vector<vector<int>> graph(n);

    for(int i = 0; i < n; i++ ){
        int v, k;
        cin >> v >> k;
        for(int j = 0; j < k; j++){
            int v2;
            cin >> v2;
            graph[v-1].push_back(v2-1);
        }
    }

    vector<int> d(n, -1);
    queue<int> q;
    q.push(0);
    d[0] = 0;

    while(!q.empty()){
        int cur = q.front();
        q.pop();
        for(int i = 0; i < graph[cur].size(); i++ ){
            int next = graph[cur][i];
            if(d[next] == -1){
                d[next] = d[cur]+1;
                q.push(next);
            }
        }
    }

    for(int i = 0 ; i < n; i++ ){
        cout << i+1 << " " << d[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long int ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(i, n) for (ll i = 1; i < (ll)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef vector<ll> vi;
typedef vector<vi> vvi;
const ll INF = (ll)1 << 60;

int main(){
    ll n, W;
    cin >> n >> W;
    vi w(n+1), v(n+1);
    rep(i, n){
        cin >> w.at(i) >> v.at(i);
    }
    vvi d(n+2, vi(W+1));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < W; j++){
            d.at(i).at(j) = 0;
        }
    }
    rep(i, n+1){
        rep(j, W+1){
            if(w.at(i) <= W && j >= w.at(i)){
                d.at(i+1).at(j) = max(d.at(i).at(j), d.at(i).at(j-w.at(i)) + v.at(i));
            }
            else {
                d.at(i+1).at(j) = d.at(i).at(j);
            }
        }
    }

    cout << d.at(n).at(W) << endl;
    return 0;
}

Measured memory_bytes: 81024
#include<bits/stdc++.h>
    #define M 1000000007
    #define pb push_back
    #define pi 3.1415926536
    #define mp make_pair
    #define ub upper_bound
    #define lb lower_bound
    #define mem0(a) memset(a,0,sizeof(a))
    #define all(a) a.begin(),a.end()
    #define ll long long
    #define vec vector <int>
    #define pii pair<int,int>
    using namespace std;
    int main()
    {
    	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    	ll n=0,m=0,a1=0,a=0,b=0,ma=0,x=0;
    	cin>>n>>m;
    	for (int i = 0; i < m; ++i)
    	{
    		cin>>b;
    		if(i==0)
    			a1=b;
    		else if(i==(m-1))
    		{
    			x=max(b-a,a1+n-b);
    		}
    		else
    			x=(b-a);
    		a=b;
    		ma=max(x,ma);
    	}
    	cout<<n-ma;
    	return 0;
    }

Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (true)
		{
			int n = sc.nextInt(),
				m = sc.nextInt();
			if (n == 0 && m == 0) break;
			int ans[] = new int[m];
			for (int i = 0; i < n; i++)
			{
				{
				for (int j = 0; j < m; j++)
					ans[j] += sc.nextInt();
				}
			}
			boolean first = true;
			for (int i = n; i >= 0; i--)
			{
				for (int j = 0; j < m; j++)
				{
					if (ans[j] == i)
					{
						if (first) first = false;
						else System.out.print(" ");
						System.out.print(j+1);
					}
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,y;
	cin >> x >> y;
	int turn = 0;
	int minx = 0;
	int miny = 0;
	int maxx = 1;
	int maxy = 1;
	while(true){
		if( minx <= x  && x < maxx && miny <= y  && y < maxy){
			break;
		}
		switch(turn%4){
			case 0:// R
				maxx += max(maxx-minx, maxy-miny);
				break;
			case 1:// U
				maxy += max(maxx-minx, maxy-miny);
				break;
			case 2:// L
				minx -= max(maxx-minx, maxy-miny);
				break;
			case 3:// D
				miny -= max(maxx-minx, maxy-miny);
				break;
		}
		++turn;
	}
	
	
	// 1:red, 2:yellow, 3:blue
	cout << (turn%3+1) <<endl;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

//auto mod int
using ll = long long;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}

  mint comb(int r){//O(r)で間に合うようなrのみ使用可能
    mint x=1,y=1;
    for(int i=0;i<=r-1;i++){
      y*=*this-i;
      x*=i+1;
    }
    return y/x;
  }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


signed _main(){
  int N,K; cin >> N >> K;
  mint ans=0;
  for(int i=K;i<=N+1;i++){
    ans+=mint(N+1+N+1-i+1)*mint(i)/mint(2)-mint(i+1)*mint(i)/mint(2)+mint(1);
    //cout << ans.x << endl;
  }
  cout << ans.x << endl;
  return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

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

    int n;
    cin >> n;

    vi a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    sort(all(a));
    
    const int nax = 1e6 + 2;
    vector<bool> ok(nax, true);
    vector<bool> before(nax, false);
    set<int> x;
    trav(y,a) x.insert(y);
    int cnt = 0;    
    for(int i = 0; i < n; i++) {
        int num = a[i];
        if(before[num]) ok[num] = false;
        if(ok[num]) {
            before[num] = true;
            for(int j = 2 * num; j < nax; j += num) {
                ok[j] = false;
            }
        }
    }

    for(int i = 1; i < nax; i++) {
        if(x.count(i) && ok[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

typedef unsigned long long  ULL;
typedef long long LL;

#define pb push_back
#define mp make_pair
#define reset(a, b) memset(a, b, sizeof(a))
#define rep(i,b) for(int i=0; i<b; i++)
#define F first 
#define S second

 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int T;
//    cin>>T;
    T=1;
    while(T--){
       
       int n;
       cin>>n;
       cout<<(2*M_PI*n);
    }
    
    return 0;
}

Measured memory_bytes: 3780
import java.util.Scanner;

class Main {
	@SuppressWarnings("resource")
	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
        String s="";
        while(in.hasNext()) s+=in.nextLine();
        s=s.toLowerCase();
		char[] a={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
        for(char c:a){
        	int r=0;
        	for(int i=0;i<s.length();i++){
            	if(s.charAt(i)==c) r+=1; 
        	}
        	System.out.println(c+" : "+r);
        }
	}
}

Measured memory_bytes: 26116
from itertools import product

def solve(n, FF, PP):
    return max(
        sum(P[sum(i & f for i, f in zip(I, F))] for F, P in zip(FF, PP))
        for I in list(product(range(2), repeat=10))[1:]
    )

_n = int(input())
_FF = [list(map(int, input().split())) for _ in range(_n)]
_PP = [list(map(int, input().split())) for _ in range(_n)]
print(solve(_n, _FF, _PP))


Measured memory_bytes: 43484
def f(x):
    c = 1

    while x >= c:
        x -= c
        c += 1

    return c - 1


N = int(input())

ans = 0
for i in range(2, round(N**.5)):
    x = 0

    while N%i == 0:
        x += 1
        N //= i

    if x > 0:
        ans += f(x)


if N > 1:
    ans += 1

print(ans)


Measured memory_bytes: 9448
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

typedef struct _treeNode{
  struct _treeNode *right;
  struct _treeNode *left;
  struct _treeNode *parent;
  int key;
}Node;

Node *root;

void insert(int);
void inorder(Node*);
void preorder(Node*);
Node* find(Node*,int);

int main(){
  int command_N;
  int key;
  char command[10];
  Node *fi;

  scanf("%d",&command_N);
  for(int i=0;i<command_N;i++){
    scanf("%s",command);
    if(strcmp(command,"insert")==0){
      scanf("%d",&key);
      insert(key);
    }
    else if(strcmp(command,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(strcmp(command,"find")==0){
      scanf("%d",&key);
      fi=find(root,key);
      if(fi!=NULL){
        printf("yes\n");
      }
      else{
        printf("no\n");
      }
    }
  }

return 0;
}

void insert(int key){
  Node *in;
  Node *current=root;
  Node *pre=NULL;

  in=(Node*)malloc(sizeof(Node));
  in->key=key;
  in->left=NULL;
  in->right=NULL;

  while(current!=NULL){
    pre=current;
    if(in->key<current->key){
      current=current->left;
    }
    else{
      current=current->right;
    }
  }
  in->parent=pre;
  if(pre==NULL){ //空
    root=in;
  }else{
    if(in->key<pre->key){
      pre->left=in;
    }else{
      pre->right=in;
    }
  }
}

void inorder(Node *node){
  if(node==NULL) return;
  inorder(node->left);
  printf(" %d",node->key);
  inorder(node->right);
}

void preorder(Node *node){
  if(node==NULL) return;
  printf(" %d",node->key);
  preorder(node->left);
  preorder(node->right);
}

Node* find(Node *node,int key){
  while(node!=NULL && key!=node->key){
    if(key<node->key){
      node=node->left;
    }
    else node=node->right;
  }
  return node;
}



Measured memory_bytes: 20540
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <string>
#include <stack>
#include <tuple>

using namespace std;
typedef long long ll;

int main()
{
    int n,l;
    cin >> n >> l;
    vector<string> s(n);
    for (int i = 0; i < n; i++) cin >> s[i];
    sort(s.begin(), s.end());
    for (int i = 0; i < n; i++)
    {
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vl p(m), y(m);
    vvl val(n);  // val[v] : p[i] = v であるようなiについてのy[i]の値を集めたもの
    rep(i, m) {
        cin >> p[i] >> y[i];
        p[i]--;
        val[p[i]].pb(y[i]);
    }

    rep(v, n) {
        sort(all(val[v]));
        val[v].erase(unique(all(val[v])), val[v].end());
    }

    rep(i, m) {
        ll v = p[i];
        printf("%06d", v+1);
        ll id = lower_bound(all(val[v]), y[i]) - val[v].begin();
        printf("%06d\n", id+1);
    }
    
    re0;
}

Measured memory_bytes: 8576