akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>
using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  int cnt = 1;
  while (A * cnt - (cnt - 1) < B){
    cnt++;
  }
  if (B == 1) {
    cnt = 0;
  }
  cout << cnt;
}

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


int main() {
  long long N, A, B, C, D, result;
  scanf ("%lld", &N);
  
  
  A = sqrt(N);
  while (1) {
  	if (N%A==0) break;
  	else A--;
  }
  
  B = N/A;
  
  result = A+B-2;
  
  printf("%lld", result);
  return 0;
}




Measured memory_bytes: 128
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : August 15, 2020 6:00 PM
 *    Problem Name  : B - Making Triangle
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc175/tasks/abc175_b
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
#define ll long long int 
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);

    ll n;
    cin >> n;

    ll arr[n+1];
    for(ll i=0; i<n; i++){
        cin >> arr[i];
    }

    sort(arr,arr+n);
    ll cnt=0;

    for(ll i=0; i<n; i++){
        for(ll j=i+1; j<n; j++){
            for(ll k=j+1; k<n; k++){
                if(((arr[i]+arr[j]) > arr[k]) && (arr[i]!=arr[j] && arr[j]!=arr[k]))
                    cnt++;
            }
        }
    }
    cout << cnt << endl;
    
    return 0 ;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define rep(i, end) for (long long int i=0; i<end; i++)
#define repp(i, begin, end) for (long long int i=begin; i<end; i+)
#define deb(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
using ll = long long int;
using vi = vector<int>;
using vll = vector<long long int>;
using vs = vector<string>;
void debv(vll x, ll size) {cout<<"[ "; rep(i, size) cout<<x[i]<<' '; cout <<']'<<endl;}
//====================================================================================================

int main()
{
    ll a, b;
    cin >> a >> b;

    ll ans;
    if(a>=13) ans = b;
    else if(6<=a && a<=12) ans = b / 2;
    else if(a<=5) ans = 0;

    cout << ans;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int A[3];
  int B[3]={5,5,7};
  cin>>A[0]>>A[1]>>A[2];
  sort(A,A+3);
  if(memcmp(A,B,sizeof A))cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
ac=[0]*N
wa=[0]*N
for i in range(M):
  p,s=input().split()
  p=int(p)-1
  if not ac[p]:
    if s>"AC":
      wa[p]+=1
    else:
      ac[p]=1
a=0
w=0
for i in range(N):
  if ac[i]:
    a+=1
    w+=wa[i]
print(a,w)


Measured memory_bytes: 4596
n, y = map(int, input().split())

for i in range(n+1):
    for j in range(n-i+1):
        if 1000*i + 5000*j + 10000*(n-i-j) == y:
            print(n-i-j, j, i)
            exit()
print(-1, -1, -1)



Measured memory_bytes: 9056
n, m = map(int, input().split())

l_max = 0
r_min = 10**6
for i in range(m):
    l, r = map(int, input().split())
    l_max = max(l_max, l)
    r_min = min(r_min, r)
    
if l_max <= r_min:
    print(r_min - l_max + 1)
else:
    print(0)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n, m, a, b, c, t;
typedef vector<vector<int> > matrix;

matrix multi(matrix a, matrix b){
  matrix res;
  res.resize(a.size());
  for (int i = 0; i < a.size(); i++) {
    res[i].resize(a[i].size(), 0);
    for (int j = 0; j < a[i].size(); j++) {
      for (int k = 0; k < a[i].size(); k++) {
        res[i][j] += a[i][k] * b[k][j];
        res[i][j] %= m;
      }
    }
  }
  return res;
}

void func(int t, matrix& mat){
  if(t == 0)return;
  int cnt = 1, size = 0;
  while(t > 2*cnt)cnt *= 2, size++;
  vector<matrix> doubling(size + 1);
  for (int i = 0; i <= size; i++) {
    doubling[i].resize(n);
    for (int j = 0; j < n; j++) {
      doubling[i][j].resize(n, 0);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      doubling[0][i][j] = mat[i][j];
    }
  }
  for (int i = 1; i <= size; i++) {
    doubling[i] = multi(doubling[i - 1], doubling[i - 1]);
  }

  while(t != 0){
    while(t < cnt){
      cnt /= 2;
      size--;
    }
    mat = multi(mat, doubling[size]);
    t -= cnt;
  }

  // for (int i = 0; i < doubling.size(); i++) {
  //   std::cout << "doubling:" << i << std::endl;
  //   for (int j = 0; j < n; j++) {
  //     for (int k = 0; k < n; k++) {
  //       std::cout << doubling[i][j][k] << " ";
  //     }
  //     std::cout  << std::endl;
  //   }
  // }
}

int calc(int i, vector<int> &s, matrix& mat){
  int res = 0;
  for (int j = 0; j < n; j++) {
    res += s[j] * mat[j][i];
    res %= m;
    //std::cout << res << " " << s[j] << std::endl;
  }
  return res;
}

int main(int argc, char *argv[]){
  while(cin >> n >> m >> a >> b >> c >> t, n){
    vector<int> s(n);
    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }
    if(t == 0){
      for (int i = 0; i < n - 1; i++) {
        std::cout << s[i] << " ";
      }
      std::cout << s[n - 1]<< std::endl;
      continue;
    }
    vector<int> ans(n);
    matrix mat(n, vector<int>(n, 0));
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if(i  == j){
          mat[max(0, j - 1)][i] = a;
          mat[min(n - 1, j + 1)][i] = c;
          mat[j][i] = b;
          continue;
        }
      }
    }
    func(t-1, mat);
    // for (int i = 0; i < n; i++) {
    //   for (int j = 0; j < n; j++) {
    //     std::cout << mat[i][j] << " ";
    //   }
    //   std::cout << std::endl;
    // }
    for (int i = 0; i < n; i++) {
      ans[i] = calc(i, s, mat);
    }
    for (int i = 0; i < n - 1; i++) {
      std::cout << ans[i]%m << " ";
    }
    std::cout << ans[n - 1] << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1500
program example
	implicit none

	integer(8) A,B,K
    
    read(*,*) A,B,K

 	if(A+B>=K) then
    	if(A>=K) then
        	A=A-K
        else
        	B=A+B-K
        	A=0
        end if
    else
    	A=0
        B=0
    end if
    
    write(*,*) A,B

end program example

Measured memory_bytes: 384
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;

int main() {
    LL n, y;
    cin >> n >> y;

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n - i; j++) {
            for (int k = 0; k <= n - i - j; k++) {
                if (y == 10000 * i + 5000 * j + 1000 *k
                    and i + j + k == n) {
                    cout << i << " " << j << " " << k << endl;
                    return 0;
                }
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


Measured memory_bytes: 256
eval"N,M,*A="+`dd`.split*?,;f=->i{d=k=0;A.map{|a|d-=b=(0..99).find{|j|a>>j<=i};k+=a>>b};X=k--~i/2*d+=M;d>=0};f[(0..10**9).bsearch &f];p X

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

using namespace std;

int main() {
	string s[3];
	for (int i = 0; i < 3; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < 3; i++) {
		cout << s[i][i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
const int MAXN = 2e5;
const int INF = 1e9 + 7;
int a[200];
int fre;
int main() {
    int n;
    scanf("%d", &n);
    vector<int> v;
    for (int i = 1; i<= n; i++) {
        int x;
        scanf("%d", &x);
        if (x >= 3200) {
            fre++;
        } else if (x >= 2800) {
            a[1]++;
        } else if (x >= 2400) {
            a[2]++;
        } else if (x >= 2000) {
            a[3]++;
        } else if (x >= 1600) {
            a[4]++;
        } else if (x >= 1200) {
            a[5]++;
        } else if (x >= 800) {
            a[6]++;
        } else if (x >= 400) {
            a[7]++;
        } else if (x >= 1) {
            a[8]++;
        }
    }
    int cnt = 0;
    for (int i = 1; i <= 8; i++) {
        cnt += bool(a[i]);
    }
    
    cout << max((int)bool(fre), cnt)<< ' ' <<cnt + fre;
    
    return 0;
}

Measured memory_bytes: 256
function parseInt(x) parse(Int, x) end

function main()
	n = parseInt.(split(readline()))
	a = parseInt.(split(readline()))
	lh = 0
	rh = 0
	for i in 1:n[2]
		if a[i] < n[3]
			lh += 1
		else
			rh += 1
		end
	end
	print(min(lh, rh))
end

main()

Measured memory_bytes: 116104
S = list(input())

pattern1, pattern2 = [], []
for i in range(len(S)):
  if i % 2 == 0:
    pattern1.append('0')
    pattern2.append('1')
  else:
    pattern1.append('1')
    pattern2.append('0')

ham1, ham2 = 0, 0
for i in range(len(S)):
  if pattern1[i] != S[i]:
    ham1 += 1
  if pattern2[i] != S[i]:
    ham2 += 1
print(min(ham1, ham2))

Measured memory_bytes: 11432
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int cd = 0;
        for(int i = 1;i <= num;i++){
            cd+=i;
        }
        System.out.println(cd);
    }
}

Measured memory_bytes: 35476
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N;
    cin >> N;
    string s;
    cin >> s;
    int x = 0;
    int maxofx = 0;
    for (int i = 0; i < N; i++)
    {
        if (s[i] == 'I')
        {
            x++;
        }
        else
        {
            x--;
        }
        maxofx = max(maxofx, x);
    }
    cout << maxofx << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
   int a,t,i=0,j=0,s=0,min;
   int b[100];
   int c[100];
   int k[100];
   int l[100];
   
   scanf("%d%d",&a,&t);
   while(a>0){
      scanf("%d%d",&b[i],&c[j]);
      a--;i++;j++;
   }
   j--;i--;
    while(j>=0){
        if(c[j]<=t){
            k[s]=c[j];
            l[s]=b[j];
            s++;
        }
        j--;
    }
    
    if(s==0){
        printf("TLE");
        return 0;
    }
    s--;
    min=l[s];
    while(s>=0){
        if(min>l[s]){
            min=l[s];
        }
        s--;
    }
    printf("%d",min);
    return 0;
   }

Measured memory_bytes: 128
inp=lambda:list(map(int,input().split()))
import bisect as bi
n=int(input())
a=inp()
b=inp()
c=inp()
a.sort()
b.sort()
c.sort()
ans=0
for i in range(n):
    x=bi.bisect_left(a,b[i])
    y=n-bi.bisect_right(c,b[i])
    ans+=x*y
print(ans)


Measured memory_bytes: 22452
def f(x):
	return x == x[::-1]
S = input()

"""
l1 = (len(S)-1)//2
l2 = (len(S)+3)//2

S1 = S[:l1]
S2 = S[l2:]
"""

l = (len(S)-1)//2
S1 = S[:l]
S2 = S[l+1:]

if f(S) and f(S1) and f(S2):
	print("Yes")
else:
	print("No")


Measured memory_bytes: 3060
#include <stdio.h>
 
int main (void)
{
 
    int a;
 
    scanf("%d",&a);
    
    if(a>=10&&a<=999){
        
        a=a%10;
        }
    
    switch (a) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            printf("hon\n");
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            printf("pon\n");
            break;
        case 3:
            printf("bon\n");
            break;
 
    }
 
    return(0);
 
}

Measured memory_bytes: 1620
s = list(input())

#偶文字列かどうかの判定
for i in range(len(s)):
#    print(s)
    s.pop()
#    print(s)
    if len(s) % 2 != 0:
        pass
    else:
        if s == s[:len(s)//2] * 2:
            break

print(int(len(s)))


Measured memory_bytes: 2940
#include<iostream>

using namespace std;

int main(){
	int a[3],i,j,n;
	for(i=0;i<3;i++){
		cin>>a[i];
	}
	for(i=0;i<2;i++){
		for(j=i+1;j<3;j++){
			if(a[i]>a[j]){
				n=a[i];
				a[i]=a[j];
				a[j]=n;
			}
		}
	}
	cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
	return 0;
}

Measured memory_bytes: 1164
import sys
sys.setrecursionlimit(10000)


class SegmentTree():
    def __init__(self, array, f, ti):
        """
        Parameters
        ----------
        array : list
            to construct segment tree from
        f : func
            binary operation of the monoid
        ti : 
            identity element of the monoid
        """
        self.f = f
        self.ti = ti
        self.n = n = 2**(len(array).bit_length())
        self.dat = dat = [ti] * n + array + [ti] * (n - len(array))
        for i in range(n - 1, 0, -1):  # build
            dat[i] = f(dat[i << 1], dat[i << 1 | 1])

    def update(self, p, v):  # set value at position p (0-indexed)
        f, n, dat = self.f, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            p >>= 1
            dat[p] = f(dat[p << 1], dat[p << 1 | 1])

    def query(self, l, r):  # result on interval [l, r) (0-indexed)
        f, ti, n, dat = self.f, self.ti, self.n, self.dat
        res = ti
        l += n
        r += n
        while l < r:
            if l & 1:
                res = f(res, dat[l])
                l += 1
            if r & 1:
                r -= 1
                res = f(dat[r], res)
            l >>= 1
            r >>= 1
        return res



class UnionFind:
    def __init__(self, size):
        self.UF = list(range(size))
        self.SIZE = [1] * size  # 0-indexed

    def find(self, x):
        UF = self.UF
        stack = [x]
        while True:
            y = stack[-1]
            if UF[y] != y:
                stack += [UF[y]]
            else:
                break
        for s in stack:
            UF[s] = y
        return y

    def unite(self, x, y):
        is_same = self.is_same
        find = self.find
        SIZE = self.SIZE
        UF = self.UF
        if not is_same(x, y):
            X, Y = find(x), find(y)
            SX, SY = SIZE[X], SIZE[Y]
            if SX > SY:
                m = UF[X] = Y
            else:
                m = UF[Y] = X
            SIZE[m] = SX + SY
            SIZE[X + Y - m] = 0

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

    def scan_uf(self):
        find = self.find
        length = len(self.UF)
        for i in range(length):
            find(i)

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


N, K = [int(_) for _ in input().split()]
P = [int(_) for _ in input().split()]
STmax = SegmentTree(array=P, f=max, ti=-float('inf'))
STmin = SegmentTree(array=P, f=min, ti=float('inf'))
UF = UnionFind(N - K + 1)
for i in range(N - K):
    if P[i] == STmin.query(i, i + K) and P[i + K] == STmax.query(
            i + 1, i + K + 1):
        UF.unite(i, i + 1)
inc = 0
incK = []
for i in range(N - 2, -1, -1):
    if P[i] <= P[i + 1]:
        inc += 1
        if inc >= K - 1:
            incK += [i]
    else:
        inc = 0
for i in incK:
    UF.unite(incK[0], i)
UF.scan_uf()
print(len(set(UF.UF)))


Measured memory_bytes: 126720
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
template <typename T,typename E>
struct SegmentTree{
  using F = function<T(T,T)>;
  using G = function<T(T,E)>;
  int n;
  F f;
  G g;
  T ti;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(int n_,F f,G g,T ti):
    f(f),g(g),ti(ti){
    init(n_);
  }
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.assign(2*n-1,ti);
  }
  void build(int n_, vector<T> v){
    for(int i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  void update(int k,E a){
    k+=n-1;
    dat[k]=g(dat[k],a);
    while(k>0){
      k=(k-1)/2;
      dat[k]=f(dat[k*2+1],dat[k*2+2]);
    }
  }
  inline T query(int a,int b){
    T vl=ti,vr=ti;
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[(l++)-1]);
      if(r&1) vr=f(dat[(--r)-1],vr);
    }
    return f(vl,vr);
  }

  int find(int a,int b,function<bool(T)> &check,int k,int l,int r){
    if(!check(dat[k])||r<=a||b<=l) return -1;
    if(k>=n-1) return k-(n-1);
    int m=(l+r)>>1;
    int vl=find(a,b,check,k*2+1,l,m);
    if(~vl) return vl;
    return find(a,b,check,k*2+2,m,r);
  }
  
  int find(int a,int b,function<bool(T)> &check){
    return find(a,b,check,0,0,n);
  }
  
};
//END CUT HERE
signed AOJ_DSL2A(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n,q;
  cin>>n>>q;
  SegmentTree<int,int> rmq(n,
			   [](int a,int b){return min(a,b);},
			   [](int a,int b){++a;return b;},
			   INT_MAX);
  for(int i=0;i<q;i++){
    int c,x,y;
    cin>>c>>x>>y;
    if(c) cout<<rmq.query(x,y+1)<<endl;
    else rmq.update(x,y);
  }
  return 0;
}
/*
  verified on 2018/03/04
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A&lang=jp
*/

signed ARC038_C(){
  Int n;
  cin>>n;
  vector<Int> c(n,0),a(n,0);
  for(Int i=1;i<n;i++) cin>>c[i]>>a[i];
  
  SegmentTree<Int, Int>::F f=[](Int a,Int b){return min(a,b);};
  SegmentTree<Int, Int>::G g=[](Int a,Int b){return max(a,b);};
  SegmentTree<Int, Int> seg(n,f,g,-1);
  
  vector<Int> dp(n);
  dp[0]=0;
  seg.update(0,0);
  for(Int i=1;i<n;i++){
    function<bool(Int)> check=[&](Int x){return x<i-c[i];};
    dp[i]=seg.find(0,n,check);
    seg.update(dp[i],i);
  }
  
  Int ans=0;
  for(Int i=1;i<n;i++)
    if(a[i]&1) ans^=dp[i];
  
  cout<<(ans?"First":"Second")<<endl;
  return 0;
}

/*
  verified on 2018/01/30
  https://beta.atcoder.jp/contests/arc038/tasks/arc038_c
*/

signed main(){
  AOJ_DSL2A();
  //ARC038_C();
  return 0;
}



Measured memory_bytes: 3704
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll K,ans=1,P=7;
  cin>>K;
  
  REP(i,100000000){
    if(P%K==0){
      co(ans);
      return 0;
    }
    ans++;
    P=(P*10+7)%K;
  }
  co(-1);
  return 0;
}

Measured memory_bytes: 3540
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int n;
    string s;
    cin>>n;
    cin>>s;
    int max=0;
    int x=0;
    rep(i,0,s.size()-1){
        if(s[i]=='I') x++;
        else x--;
        if(max<x){
            max = x;
        }
    }
    cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 888
//do not think about past and stay in this moment
// organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long 
int prime[1000005];
void seive(){
	for(int i=2;i<1000005;++i){
		if(prime[i]==0)
		for(int j=2*i;j<1000005;j+=i)
			prime[j]=1;
	}
}			
int digit(int n){
	int xp=0;
	while(n!=0){
		n/=10;
		xp++;
	}
	return xp;
}
void q1(){
	string s,t;
	cin>>s>>t;
	cout<<t<<s;
}
void q2(){
	int a,b,k;
	cin>>a>>b>>k;
	int mn=min(a,k);
	a-=mn; k-=mn;
	mn=min(b,k);
	b-=mn; k-=mn;
	cout<<a<<" "<<b;
}
void q3(){
	int x;
	cin>>x;
	seive();
	while(prime[x])
	x++;
	cout<<x<<endl;
}
void q4(){
	
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t=1;
	while(t--)
	q1();
	return 0;
}
	


Measured memory_bytes: 256
/************
* 	@Just Another Source code by: ankit.sangwan1999
*	@created on: 22 May 2020
*/
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL) //;cout.tie(NULL)
#define ll long long
const int mod = 1e9+7;
#define endl '\n'

const int N = 3000;
long double arr[N];


signed main(){

    fastio;

    int n;
    cin>>n;

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

    long double dp[n+1][n+1];

    for(int i=0;i<=n;i++){ // ith toss
    	for(int j=0;j<=n;j++){ 
    		if(i==0 and j==0){
    			dp[i][j] = 1;
    		}
    		else if(j==0){
    			dp[i][j] = dp[i-1][j] * (1-arr[i-1]);
    		}
    		else if(i==0){
    			dp[i][j] = 0;
    		}
    		else{
    			dp[i][j] = dp[i-1][j]*(1-arr[i-1]) + dp[i-1][j-1]*arr[i-1];
    		}
    	}
    }

    long double ans = 0;

    for(int i=n-n/2;i<=n;i++){ // ith toss
    	ans += dp[n][i];
    }

    cout<<setprecision(10)<<ans;


    return 0;
}

Measured memory_bytes: 140928
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto itd=begin(ar); itd != end(ar); itd++) cout << "["s << itd - begin(ar) << "]:"s << *itd << endl
#define DUMPL(ar) for(auto itd=begin(ar); itd != end(ar); itd++) { cout << *itd; if(end(ar)-itd > 1) cout << ' '; } cout << endl
#define COUT(x) cout << (x) << endl
#define VCIN(ar) for(auto &vcin: (ar)) cin >> vcin
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ["s << i << "]回目---------------"s << endl
using namespace std;
// lint:64ビット 10^19

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

    int n, k, s;
    cin >> n >> k >> s;

    for(int i=0; i<k; i++){
        cout << s;
        if(i != n-1) cout << ' ';
    }
    for(int i=0; i<n-k; i++){
        if(s == 2 || s == 1) cout << s + 1;
        else cout << s-1;
        if(i != k-n-1) cout << ' ';
    }
    cout << endl;
    return 0;
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  vector<ll> a(n);
  for (ll i = 0; i < n; ++i) {
    cin >> a[i];
  }

  vector<ll> b(n);
  for (ll i = 0; i < n; ++i) {
    cin >> b[i];
  }

  ll ac = 0, bc = 0;
  for (ll i = 0; i < n; ++i) {
    if (a[i] < b[i]) ac += (b[i]-a[i])/2;
    else if (a[i] > b[i]) bc += a[i]-b[i];
  }
  
  if (ac >= bc) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 384
s = input()
n = len(s)
 
ans = 0
 
for bit in range(2 ** (n - 1)):
    f = s[0]
 
    for i in range(n - 1):
        if bit & (1 << i):
            f += "+"
        f += s[i + 1]
 
    ans += sum(map(int, f.split("+")))
 
print(ans)

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

using namespace std;


void eating_symbols_easy()
{
  string s;
  cin >> s;

  int cnt = 0;
  for (int i = 0; i < 4; ++i)
  {
    if (s[i] == '+') ++cnt;
    else --cnt;
  }
  cout << cnt << "\n";
}


void multiple_of_2_and_n()
{
  int n;
  cin >> n;

  if (n % 2 == 0) cout << n << "\n";
  else cout << 2 * n << "\n";
}


void task_scheduling_problem()
{
  vector<int> a(3);
  for (int i = 0; i < 3; ++i) cin >> a[i];

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

  cout << a[2] - a[0] << "\n";
}


void rated_for_me()
{
  int r;
  cin >> r;

  if (r < 1200) cout << "ABC\n";
  else if (r < 2800) cout << "ARC\n";
  else cout << "AGC\n";
}


void atcoder_crackers()
{
  int n, k;
  cin >> n >> k;

  if (n % k == 0) cout << 0 << "\n";
  else cout << 1 << "\n";
}


void garden()
{
  int a, b;
  cin >> a >> b;

  cout << (a - 1) * (b - 1) << "\n";
}


void train()
{
  int n, i;
  cin >> n >> i;

  cout << n - i + 1 << "\n";
}


void Pair()
{
  int k;
  cin >> k;

  if (k % 2 == 0) cout << k / 2 * k / 2 << "\n";
  else cout << k / 2 * (k / 2 + 1) << "\n";
}


void ABC333()
{
  int a, b;
  cin >> a >> b;

  if ((a == 1 && (b == 1 || b == 3)) || (a == 3 && (b == 1 || b == 3))) cout << "Yes\n";
  else cout << "No\n";
}


void maximize_the_formula()
{
  int a, b, c;
  cin >> a >> b >> c;

  int v_max = max({ a,b,c });
  cout << a + b + c + 9 * v_max << "\n";
}


void digit_sums()
{
  int n;
  cin >> n;

  int s = 0, tmp = n;
  while (tmp > 0)
  {
    s += tmp % 10;
    tmp /= 10;
  }
  if (n % s == 0) cout << "Yes\n";
  else cout << "No\n";
}


void maximum_difference()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];

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

  cout << a[n - 1] - a[0] << "\n";
}


int main()
{
  //eating_symbols_easy();
  //multiple_of_2_and_n();
  //task_scheduling_problem();
  //rated_for_me();
  //atcoder_crackers();
  //garden();
  //train();
  //Pair();
  //ABC333();
  //maximize_the_formula();

  //digit_sums();
  maximum_difference();
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();

        final Solver solver = new Solver();
        solver.solve(N);
    }
}

class Solver {
    public void solve(long N) {
        long odd = N % 2 == 0 ? N / 2 : N / 2 + 1;
        System.out.println(String.format("%f", odd / (double) N));
    }
}



Measured memory_bytes: 21844
#include <stdio.h>

int main()
{
	char s[10];
	int s_length = 0, max_length = 0;
	int i;

	scanf("%s", s);

	for (i = 0; s[i] != '\0'; i++)
	{
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T')	s_length++;
		else s_length = 0;
		if (s_length > max_length)	max_length = s_length;
	}

	printf("%d\n", max_length);
	return 0;
}

Measured memory_bytes: 128
package main
     
import (
    "fmt"
)
 
func main() {
    var s string
    fmt.Scan(&s)

    if s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi"   {
        fmt.Println("Yes")
    } else {
        fmt.Println("No")
    }
}

Measured memory_bytes: 512
function Main(input){
var inputArray=input.split(" ");
var a=inputArray[0];
    b=inputArray[1];
    cArray=[1,2,3];
    
for (var c in cArray){
 var x= a*b*c
 if (x%2=== 1){
 return 'Yes';
 }
}
return 'No';
}

console.log(Main(require("fs").readFileSync("/dev/stdin", "utf8")))


Measured memory_bytes: 7372
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(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;
int main()
{
  ll n,a,b;
  cin >> n >> a >> b;

  if((b-a)%2==0){
    cout << (b-a)/2 << "\n";
  }
  else{
    ll c = n-b+1+(b-a-1)/2;
    ll d = a + (b-a-1)/2;
    ll res = min(c,d);
    cout << res << "\n";
  }
  return 0;
}


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

using namespace std;

int main(){
    long long int A,B,C,ans=0;
    cin >> A >> B >> C;

    if(C<=A+B){
        cout << B + C << endl;
    }else{
        cout << B + min(C,(A+B)+1) << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int x=0;
		int y=0;
		int l = s.nextInt();
		int a = s.nextInt();
		int b = s.nextInt();
		int c = s.nextInt();
		int d = s.nextInt();
		
		if(a % c != 0)	x++;
		if(b % d != 0)	y++;
		if((int)a/c >= (int)b/d)	l -= (int)(a/c)+x;
		else	l-= (int)(b/d)+y;
		System.out.println(l);

	}

}

Measured memory_bytes: 17296
use std::io::*;
use std::str::FromStr;
use std::cmp::{min, max};
use std::mem::swap;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin_lock = stdin.lock();
    let s = stdin_lock
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

static DX: &'static [i32] = &[0, 0, 1, -1];
static DY: &'static [i32] = &[1, -1, 0, 0];

fn main() {
    let n: usize = read();

    let mut x: Vec<[usize; 2]> = (0..n).map(|i| [i, read()]).collect();

    x.sort_by_key(|item| item[1]);

    let mut mid = n / 2;

    let mut ans = vec![0; n];

    for i in 0..n {
        if i == mid {
            mid -= 1;
        }

        ans[x[i][0]] = x[mid][1];
    }

    for i in 0..n {
        println!("{}", ans[i]);
    }
}

fn pow_mod(mut n: u64, mut exp: u64, m: u64) -> u64 {
    let mut t = 1;

    n %= m;

    while exp > 1 {
        if exp & 1 == 1 {
            t *= n;
            t %= m;
        }

        n *= n;
        n %= m;
        exp >>= 1;
    }

    (n * t) % m
}

Measured memory_bytes: 14460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const string yes = "Yes";
const string no = "No";

int main()
{
  ll N;
  scanf("%lld",&N);
  vector<ll> H(N);
  for(int i=0; i<N; i++){
    scanf("%lld",&H[i]);
  }

  if (N == 1) {
    cout << yes << endl;
    return 0;
  }

  for (int i=N-1; i>0; i--) {
    ll d = H[i-1]-H[i];
    if (d>=2) {
      cout << no << endl;
      return 0;
    }
    if (d==1) {
      H[i-1]--;
    }
  }
  cout << yes << endl;

  return 0;
}


Measured memory_bytes: 1024
use std::io::stdin;

macro_rules! read {
    ($t: ty) => {{
        let mut line = String::new();
        stdin().read_line(&mut line);
        line.trim().parse::<$t>().unwrap()
    }};
    ($($t: ty), *) => {{
        let mut line = String::new();
        stdin().read_line(&mut line);
        let mut iter = line.split_whitespace();
        (
            $(iter.next().unwrap().parse::<$t>().unwrap(), )*
        )
    }}
}
macro_rules! reads {
    ($e:expr, $t:ty) => {{
        let mut v = vec![];
        for _ in 0..$e {
            let mut line = String::new();
            stdin().read_line(&mut line);
            v.push(line.trim().parse::<$t>().unwrap());
        }
        v
    }};
}

fn main() {
    let a = read!(u32);
    let b = read!(u32);
    let c = read!(u32);
    let d = read!(u32);
    let e = read!(u32);
    let v = vec![a, b, c, d, e];

    let mut idx = 0;
    let mut min = 100;

    for i in 0..v.len() {
        let mut md = v[i] % 10;
        if md == 0 { md = md + 10; }
        if min > md {
            idx = i;
            min = md;
        }
    }

    let mut sum = 0;

    for i in 0..v.len() {
        sum = sum + v[i];
        if i != idx {
            sum = sum + (10 - v[i] % 10) % 10;
        }
    }

    println!("{}", sum);
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#define I 1000000
using namespace std;
int x[100], z[100], y[99][20], h[100], a, b, c, d, e, f, i, j, k; string S;
int main() {
	while (true) {
		for (i = 0; i < 100; i++) { x[i] = I;}
		memset(y, 0, sizeof(y));
		memset(h, 0, sizeof(h));
		cin >> a >> b >> c;
		if (a == 0) { break; }
		for (i = 0; i < c; i++) {
			cin >> d >> e >> f >> S;
			if (S[0] == 'W') {
				y[d][e] ++;
			}
			else {
				x[d] += I;
				x[d] -= f + 1200 * y[d][e];
			}
		}
		for (i = 1; i <= a; i++) { z[i] = x[i]; }
		sort(x + 1, x + a + 1);
		for (i = a; i >= 1; i--) {
			for (j = 1; j <= a; j++) {
				if (z[j] == x[i] && h[j]==0) {
					cout << j << ' ' << (x[i] + I - 1) / I - 1 << ' ' << (100 * I - x[i]) % I << endl;
					h[j] = 1;
				}
			}
		}
	}
}

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

#define REP(i,n) for(int i=0;i<n;++i)
#define PRINT(a) printf("%.8f %.8f\n", (a).x, (a).y)

struct Point { double x, y; };

void koch(int n, Point p1, Point p2) {
  double th =  60.0 * M_PI / 180.0;
  Point s = {
    (2.0 * p1.x + 1.0 * p2.x) / 3.0,
    (2.0 * p1.y + 1.0 * p2.y) / 3.0
  };
  Point t = {
    (1.0 * p1.x + 2.0 * p2.x) / 3.0,
    (1.0 * p1.y + 2.0 * p2.y) / 3.0
  };
  Point u = {
    (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x,
    (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y
  };

  if (n == 0) return;

  koch(n - 1, p1, s); PRINT(s);
  koch(n - 1, s, u); PRINT(u);
  koch(n - 1, u, t); PRINT(t);
  koch(n - 1, t, p2);
}

int main() {
  int n;
  Point p1 = {0.0, 0.0}, p2 = {100.0, 0.0};

  cin >> n;

  PRINT(p1);
  koch(n, p1, p2);
  PRINT(p2);

  return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;
const double PI=3.14159265358979323846;

void solve() {
    double A,B,H,M;
    cin >> A >> B >> H >> M;
    H += M/(double)60;
    if (H > 12) H-=12;
    int n = H,m = M;
    double rad = min(abs(((n%12)*30.0)+(m*0.5)-(m*6.0)),360-abs(((n%12)*30.0)+(m*0.5)-(m*6.0))) ;

    cerr << rad << endl;
    double x= 2*B*A*cos(((double)rad/180)*PI );
    cerr << x << endl;
    double cc = (B*B)+(A*A)-x;
    cout << fixed << setprecision(19) << sqrt(cc) << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 4216
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int maxn =1e5+50;
int a[maxn];
int b[maxn*3];
int maxx,minn;
bool cmp(int a,int b)
{
    return a>b;
}
void output(int x)
{
    cout << x << endl;
}
void solve()
{
    int ma=0;
    for(int i=minn-1;i<=maxx;i++)
    {
        ma=max(ma,b[i]);
        //cout << i << "  " << b[i] << endl;
    }
    output(ma);
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n,cmp);
    maxx=a[0];
    minn=a[n-1];
    /*map<int,int>b;
    */
    memset(b,0,sizeof(b));
    for(int i=0;i<n;i++)
    {
        for(int j=-1;j<=1;j++)
        {
            b[a[i]+j]++;
            //cout << a[i]+j << " " << b[a[i]+j] << endl;
        }
    }
    solve();
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;
#define MAX_NUM 1000010


void do_calc(int *numPrime){
  for(int i=2;i<=MAX_NUM;i++){
    bool flag = false;

    for(int j=2;j<=sqrt(i);j++){
      if(i%j==0){
	flag = true;
	break;
      }
    }
      
    if(flag){
      numPrime[i] = numPrime[i-1];
      continue;
    }else{
      numPrime[i] = numPrime[i-1] + 1;
    }
  }
}
  


int main(){
  int n;
  int numPrime[MAX_NUM];

  do_calc(numPrime);
  while(cin >> n){
    cout << numPrime[n] << endl;
  }
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 200005;

int n, k;
int h[N];

int main() {

	FAST;

	cin >> n >> k;
	for (int i = 1; i <= n; i ++) {
		cin >> h[i];
	}
	sort(h + 1, h + n + 1);
	intt sum1 = 0;
	for (int i = n; i >= max(n - k + 1, 1); i --) {
		sum1 += h[i];
	}
	intt sum2 = 0;
	for (int i = 1; i <= n; i ++) {
		sum2 += h[i];
	}
	cout << sum2 - sum1 << '\n';
	return 0;
}

Measured memory_bytes: 1024
#include <cmath>
#include <iostream>
 
template <typename T>
struct Point { 
    T x, y;
    explicit constexpr Point() : x(0), y(0) {}
    explicit constexpr Point(T _x, T _y) : x(_x), y(_y) {}
    const Point operator + (const Point& p) const { return Point(x + p.x, y + p.y);}
    const Point operator - (const Point& p) const { return Point(x - p.x, y - p.y);}
    Point& operator *= (const T& p) { x *= p, y *= p; return *this;}
    Point& operator += (const T& p) { x += p, y += p; return *this;}
    Point& operator -= (const T& p) { x -= p, y -= p; return *this;}
    Point& operator /= (const T& p) { x /= p; y /= p; return *this;}
    Point& operator += (const Point& p) { x += p.x, y += p.y; return *this;}
    Point& operator -= (const Point& p) { x -= p.x, y -= p.y; return *this;}
    const T dot(const Point& q) { return x * q.x + y * q.y;}
    const T norm() { return sqrt(x * x + y * y);}
    friend std::ostream& operator<<(std::ostream& os, const Point& p) { os << "(" << p.x << ", " << p.y << ")"; return os;}
};
 
#include <vector>
#include <iomanip>
#include <functional>
#include <tuple>
#include <algorithm>
using namespace std;
using Pt = Point<double>;
const double INF = 1e18;
const double EPS = 1.0e-11;
bool eq(double a, double b) { return fabs(a - b) <= EPS;}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n_;
    cin >> n_;
    vector<Pt> points(n_);
    for(auto& p : points)
        cin >> p.x >> p.y;
    sort(points.begin(), points.end(), [](const Pt& l, const Pt& r) {
            return eq(l.x, r.x) ? l.y < r.y : l.x < r.x;
        });
    function<double(int, int)> closest = [&](int id, int n) {
        if(n <= 1) return INF;
        int m = n / 2;
        double boundX = points[id + m].x;
        double res = min(closest(id, m), closest(id + m, n - m));
        auto fit = points.begin() + id;
        inplace_merge(fit, fit + m, fit + n, [](const Pt& l, const Pt& r) {
                return  eq(l.y, r.y) ? l.x < r.x : l.y < r.y;
            });
        vector<int> memo;
        for(int i = id; i < id + n; ++i) {
            if(fabs(boundX - points[i].x) >= res) continue;
            for(int j = -1 + memo.size(); j >= 0; --j) {
                Pt p = points[i] - points[memo[j]];
                if(p.y >= res) break;
                res = min(res, p.norm());
            }
            memo.emplace_back(i);
        }
        return res;
    };
    cout << fixed << setprecision(10) << closest(0, n_) << endl;
    return 0;
}

Measured memory_bytes: 6908
n = int(input())
A = list(map(int,input().split()))
x = A[0]
for i in range(1,n):
    if i % 2 == 0:
        x -= A[i]
    else:
        x += A[i]
x = x//2
ans = [2*(A[0]-x)]
for i in range(1,n):
    ans.append(2*x)
    x = A[i]-x
print(" ".join(map(str,ans)))

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

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

  long int sum=0;
  for(int i=1;i<=N;++i){
    if(i%3!=0 && i%5!=0){
      sum = sum + i;
    }
  }
  cout<<sum<<endl;
 
    
}

Measured memory_bytes: 3584
import java.util.*;

class Main{           
  
   public static void main(String[] args){
         Scanner sc = new Scanner(System.in);  
         
     HashMap<Integer, String[]> keyMap = new HashMap<Integer, String[]>();

     String[] str1 = {".",",","!","?"," "};
     keyMap.put(1,str1);
     String[] str2 = {"a","b","c"};
     keyMap.put(2,str2);
     String[] str3 = {"d","e","f"};
     keyMap.put(3,str3);
     String[] str4 = {"g","h","i"};
     keyMap.put(4,str4);
     String[] str5 = {"j","k","l"};
     keyMap.put(5,str5);
     String[] str6 = {"m","n","o"};
     keyMap.put(6,str6);
     String[] str7 = {"p","q","r","s"};
     keyMap.put(7,str7);
     String[] str8 = {"t","u","v"};
     keyMap.put(8,str8);
     String[] str9 = {"w","x","y","z"};
     keyMap.put(9,str9);
     
     
     int n = sc.nextInt();
     
     for(int i = 0;i < n;i++){
         String array = sc.next();
         for(int j = 0;j < array.length();j++){
             int key = Character.getNumericValue(array.charAt(j));
             if(key != 0){
                 String [] map = keyMap.get(key);
                 int push = -1;
                 while(key != 0){
                     push++;
                     j++;
                     key = Character.getNumericValue(array.charAt(j));
                 }
                 
                 push %= map.length;
                 
                 System.out.print(map[push]);
                 
             }             
         }                  
         System.out.println();
     }
     
   }         
         
 }
  

Measured memory_bytes: 29160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    ll N; cin >> N;
    vector<ll> x(N), y(N), u(N), v(N);
    for (ll i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
        u[i] = x[i] + y[i];
        v[i] = x[i] - y[i];
        //cout << u[i] << " " << v[i] << endl;
    }
    ll ans = max(vmax(u) - vmin(u), vmax(v) - vmin(v));
    cout << ans << endl;
}


Measured memory_bytes: 9588
#include<iostream>
#include<vector>
#include<cmath>
#include<limits.h>
#include<algorithm>
#include<cstring>
using namespace std;

const long long inf=1e12;

int main()
{
  int n,t;
  cin>>n>>t;
  long long pricesum=0;
  
  vector<int> w(n),p(n);
  for(int i=0;i<n;i++)
  {
    cin>>w[i]>>p[i];
    pricesum+=p[i];
  }
  vector<vector<long long> > dp(n+1,vector<long long> (pricesum+1,inf));
  
  
  dp[0][0]=0;
  for(int i=1;i<=n;i++)
  {
    for(int j=0;j<=pricesum;j++)
    {
      if(j>=p[i-1])
      {
        dp[i][j]=min(w[i-1]+dp[i-1][j-p[i-1]],dp[i-1][j]);
      }
      else
        dp[i][j]=dp[i-1][j];
  }
  }
    long long ans=LLONG_MIN;
    long long ansprice=0;
    for(int j=1;j<=pricesum;j++)
      {
          if((dp[n][j]<=t)&&(ans+dp[n][j]>ans))
          {
              ans=ans+dp[n][j];
              ansprice=j;
          }
          
          
      }
    
  cout<<ansprice<<endl;
  return 0;
}


Measured memory_bytes: 80256
#include<stdio.h>

int main(void){
    int e,f,g,i;
    while(scanf("%d%d",&e,&f) , e != 0){
        i = 0;
        if(e < f){
            g = e;
            e = f;
            f = g;
        }
        while(1){
            g = e % f;
            e = f;
            f = g;
            i++;
            if(f == 0){
                break;
            }
        }
        printf("%d %d\n",e,i);
    }
    return 0;
}

Measured memory_bytes: 600
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 2e5+7;

int main()
{
  
    int a,b,h,m;
    scf(a),scf(b),scf(h),scf(m);
    
    dd pi=3.1415926535897932384626433;
    
    dd  x=2*pi*((h/12.0)+(m/720.0));
    
    dd y=(pi*m)/30;
    
    dd t=abs(x-y);
    
    dd ans=sqrt(a*a+b*b-2*a*b*cos(t));
    
    cout<<fixed<<setprecision(11)<<ans<<endl;
    

}

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

int main(){
    int n;
    while( cin >> n ){
        int m = 1, c = 0;
        while(n > 0){
            if( n%2 ){
                if( c ) cout << ' ';
                cout << m;
                c = 1;
            }
            m *= 2;
            n /= 2;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#include <cassert>
#include <chrono>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<long long int> vll;
typedef vector<pair<int, int> > vpi;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

void solve() {
    int n;
    cin >> n;
    FOR (i, 1, n+1) {
        ll cnt = 0;
        for (int j = 1; j*j <= i; j++) {
            for (int k = 1; k*k <= i; k++) {
                ll temp = 4*i - 3*j*j - 3*k*k -2*j*k;
                if (temp >= 0) {
                    ll sq = sqrt(temp);
                    if (sq*sq == temp and (sq - j - k)%2 == 0 and (sq - j - k)/2 >= 1)
                        cnt++;
                }
            }
        }
        cout << cnt << "\n";
    }
}

int main() {
    #ifdef LOCAL
    auto t1 = std::chrono::high_resolution_clock::now();
    #endif

    io;
    int t = 1;
    tc(t) {
        solve();
    }

    #ifdef LOCAL
    auto t2 = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::milliseconds>( t2 - t1 ).count();

    std::cout << "Time Taken: " << duration << "\n";
    #endif

}
//check for edge cases in limits
//printing double may print 1.223232e9 like values, beware of that


Measured memory_bytes: 3572