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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;

inline double nCr(const int n, int r) {

	if (n == 0) { return 0; }
    if (n == 1) { return 1; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }
	if (n == r) { return 1; }

	if (r > n / 2) { r = n / 2; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return(result);
}

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

    int a, b;
    if(N == 1) {
        a = 0;
    } else {
        a = nCr(N, 2);
    }

    if(M == 1) {
        b = 0;
    } else {
        b = nCr(M, 2);
    }

    cout << a + b << endl;
}

Measured memory_bytes: 256
cuicine = [int(input()) for i in range(5)]

r = [c % 10 for c in cuicine if c % 10 != 0]

r = sorted(r)

# print(r)

rmin = 0

if r != []:
  rmin = r.pop(0)

ans = sum(cuicine)

for i in r:
  ans += 10 - i

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
 
int main(){
ll n=read(),m=read(),d=read();
printf("%.10lf",1.0*((d!=0)+1)*(n-d)*(m-1)/(n*n));
}

Measured memory_bytes: 256
/*
=============================================================

------------------Welcome To My Code-------------------------

---------Ankit Kumar || IIITBH || CSE || 2018-2022-----------

=============================================================
*/

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

#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define w while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007
map<ll, ll>::iterator itr;
vector<ll>::iterator it, it1;
const double PI = 3.141592653589793238;

int main()
{
	FASTIO;
	ll t;


        ll i,j,k,x,y,z,m=0,n,a,b,c,c1=0,c2=0,flag=0,sum=0;
        string s,s1,str;
        cin>>s;
        FOR(i,s.size())
        {
            if(s[i]=='R')
            {
                c1++;
            }
            if(s[i]=='S')
            {
                m=max(c1,m);
                c1=0;
            }
        }
        m=max(c1,m);

        cout<<m;



}


Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <assert.h>
#include <vector>
 
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <climits>
#include <stack>
 
#define N 4
#define N2 16
 
using namespace std;
 
// const int N = 4;
// const int N2 = 16;
 
static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r', 'u', 'l', 'd'}; 
 
 
typedef struct Node
{
    int puzzle[N2];
    int space;
    int md;
    int depth;
    int pre;
} Node;
 

Node s_node;
Node cur_n;
int md[N2][N2];
int ans;

int get_md_sum(int *puzzle) {
    int sum = 0;
    for (int i = 0; i < N2; ++i)
    {
        if(puzzle[i] == N2) continue;
        sum += md[i][puzzle[i]-1];
    }
    return sum;
}

void set_md() {
    for (int i = 0; i < N2; ++i)
    {
        for (int j = 0; j < N2; ++j)
        {
            md[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
        }
    }
}

void input_table() {
    s_node = Node();
    int in[N2];
    for (int i = 0; i < N2; ++i)
    {
        int tmp;
        scanf("%d", &tmp);
        // cin >> tmp;
        if(tmp == 0) {
            tmp = N2;
            s_node.space = i;
        }
        s_node.puzzle[i] = tmp;
    }
    set_md();
    s_node.md = get_md_sum(s_node.puzzle);
    s_node.depth = 0;
    s_node.pre = -10;
}

bool dfs(int limit) {
    stack<Node> st;
    st.push(s_node);

    while(!st.empty()) {
        Node cur_n = st.top();
        st.pop();
        if(cur_n.md == 0 ) {
            ans = cur_n.depth;
            return true;
        }
        if(cur_n.depth + cur_n.md > limit) continue;
        int s_x = cur_n.space / N;
        int s_y = cur_n.space % N;
        for (int i = 0; i < 4; ++i)
        {
            Node next_n = cur_n;
            int new_x = s_x + dx[i];
            int new_y = s_y + dy[i];
            if(new_x < 0  || new_y < 0 || new_x >= N || new_y >= N) continue; 
            if(max(cur_n.pre, i) - min(cur_n.pre, i) == 2) continue;
 
            //incremental manhattan distance
            next_n.md -= md[new_x * N + new_y][next_n.puzzle[new_x * N + new_y] - 1];
            next_n.md += md[s_x * N + s_y][next_n.puzzle[new_x * N + new_y] - 1];
 
            swap(next_n.puzzle[new_x * N + new_y], next_n.puzzle[s_x * N + s_y]);
            next_n.space = new_x * N + new_y;
            // assert(get_md_sum(new_n.puzzle) == new_n.md);
            // return dfs(new_n, depth+1, i);
            next_n.depth++;
            if(cur_n.depth + cur_n.md > limit) continue;
            next_n.pre = i;
            st.push(next_n);
            if(next_n.md == 0) {
                ans = next_n.depth;
                return true;
            }
        }
    }
    return false;
}

void ida_star() {
    for (int limit = s_node.md; limit < 1000; ++limit, ++limit)
    {
        // path.resize(limit);
        cur_n = s_node;
        if(dfs(limit)) {
            printf("%d\n", limit);
            return;
        }
    }
}
 
int main() {
    input_table();
    ida_star(); 
}

Measured memory_bytes: 3248
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
using namespace std;

int n, m, k;

struct UnionFind{

  vector<int> par;
  vector<int> rank; 
  vector<int> grp;

  UnionFind(){};
  UnionFind(int n){
    par.resize(n+1);
    rank.resize(n+1);
    grp.resize(n+1);
    for(int i=0;i<n+1;i++){
      par[i] = i;
      rank[i] = 0;
      grp[i] = -1;
    } 
  }

  int find(int a){
    if(par[a] == a){
      return par[a]; 
    } else {
      return par[a] = find(par[a]);
    }
  }
  
  void unite(int a, int b){
    a = find(a);
    b = find(b); 
    if(a == b) return;
    
    assert((grp[a] == grp[b]) || (grp[a] == -1) || (grp[b] == -1));

    if(rank[a] < rank[b]){
      par[a] = b;
    } else {
      par[b] = a;
      if(rank[a] == rank[b])rank[a]++;
    }
    
    int c = find(a);
    if(grp[a] != -1){
      grp[c] = grp[a];
    } else {
      grp[c] = grp[b];
    }

  }

  bool same(int a, int b){
    a = find(a);
    b = find(b);
    return (grp[a] == grp[b]);
  }

};

int main(){
  ios_base::sync_with_stdio(false);
  
  cin >> n >> m >> k;
  
  UnionFind tree(n+1);

  for(int i=0;i<k;i++){
    int r;
    cin >> r;
    
    if(r == 1){
      int a, b;
      cin >> a >> b;
      
      int aa = tree.find(a);
      int bb = tree.find(b);

      if(tree.same(a, b) || tree.grp[aa] == -1 || tree.grp[bb] == -1){
        tree.unite(a, b);
      } else {
        cout << i + 1 << endl;
        return 0;
      }

    } else {
      int c, x;
      cin >> c >> x;
    
      int cc = tree.find(c); 

      if(tree.grp[cc] == -1 || tree.grp[cc] == x){
        tree.grp[cc] = x;
      } else {
        cout << i + 1 << endl;
        return 0;
      }
    }
  }  
  
  cout << 0 << endl;

  return 0;
}




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

char s[20];
inline int min(int a, int b) { return a < b ? a : b; }

int main() {
    int n;
    scanf("%d", &n);
    int a = 0, b = 0, ans = 0;
    int temp = 0;
    for (int i = 1; i <= n; i++) {
        scanf("%s", s);
        int len = strlen(s);
        if (s[0] == 'B') b++;
        if (s[len - 1] == 'A') a++;
        if (s[0] == 'B' && s[len - 1] == 'A') temp++;
        for (int i = 0; i < len - 1; i++) {
            if (s[i] == 'A' && s[i+1] == 'B') ans++;
        }
    }
    if (a == b && temp == a && a != 0) a--;
    else a = min(a, b);
    printf("%d\n", ans + a);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int R_1_or_L_2(
    double x1,double y1,
    double x2,double y2,
    double x3,double y3){
  if(x1==x2)
    return (y1<y2)?
      (x3>x1?1:2):
      (x3<x1?1:2);

  if(y1==y2)
    return (x1<x2)?
      (y3<y1?1:2):
      (y3>y1?1:2);

  if(y3<(x3-x1)*(y2-y1)/(x2-x1)+y1)
    return (x1<x2)?1:2;

  return (x2<x1)?1:2;
}

int main(void){
  double x[4],y[4];
  char hoge;

  for(;scanf("%lf%c%lf%c%lf%c%lf%c%lf%c%lf%c%lf%c%lf",
        &x[0],&hoge,&y[0],&hoge,
        &x[1],&hoge,&y[1],&hoge,
        &x[2],&hoge,&y[2],&hoge,
        &x[3],&hoge,&y[3])==15;){
    if( ( R_1_or_L_2(x[0],y[0],x[1],y[1],x[3],y[3]) !=
          R_1_or_L_2(x[0],y[0],x[2],y[2],x[3],y[3])) &&
        ( R_1_or_L_2(x[1],y[1],x[0],y[0],x[3],y[3]) !=
          R_1_or_L_2(x[1],y[1],x[2],y[2],x[3],y[3])) &&
        ( R_1_or_L_2(x[2],y[2],x[0],y[0],x[3],y[3]) !=
          R_1_or_L_2(x[2],y[2],x[1],y[1],x[3],y[3])))
      printf("YES\n");
    else
      printf("NO\n");
  }

  return 0;
}

Measured memory_bytes: 0
object Main extends App {

  sealed trait Property

  case object Up extends Property

  case object Down extends Property

  case object Keep extends Property

  @scala.annotation.tailrec
  def loop(head: Int, tail: List[Int], property: Property, count: Int): Int = {
    if (tail.isEmpty) {
      count
    } else {
      val x :: xs = tail
      if (property == Keep) {
        loop(x, xs, if (head == x) Keep else if (head < x) Up else Down, count)
      } else if ((property == Up && head <= x) || (property == Down && x <= head)) {
        loop(x, xs, property, count)
      } else {
        loop(x, xs, Keep, count + 1)
      }
    }
  }

  val sc = new java.util.Scanner(System.in)
  val x :: xs = List.fill(sc.nextInt())(sc.nextInt())
  println(loop(x, xs, Keep, 1))

}


Measured memory_bytes: 62220
#include<stdio.h>
void main()
{
  int n;
  scanf("%d",&n);
  int a[n];
  int i,j,sum=0;
  for(i=1;i<=n;i++)
  {
    scanf("%d",&a[i]);
  }
  for(i=1;i<=n;i++)
  {
    for(j=i+1;j<=n;j++)
    {
      sum=sum+a[j]*a[i];
    }
  }
  printf("%d",sum);
}

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

int main(void){
    int X,Y;
    bool ans=false;
    
    cin >> X >> Y; //x:頭数、y:足の数

    int num_of_legs;    
    for(int i=0; i<=X; i++){
        //ツルの頭数をiとおいて足の数を調べる
        num_of_legs = 2*i+4*(X-i);
        if(num_of_legs==Y) ans = true;
    }

    if(ans==true) cout << "Yes\n";
    else cout << "No\n";
    return 0;
    
}

Measured memory_bytes: 3628
#方針: 連続するk本に点火するパターンを全部調べる
n, k = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)

p (0..n-k).map{|i| x[i+k-1] - x[i] + [x[i].abs, x[i+k-1].abs].min}.min

Measured memory_bytes: 11524
h,w=map(int, input().split())
s = ["."*(w+2)]+["."+input()+"." for i in range(h)]+["."*(w+2)]
ans='Yes'
for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j]=='#':
            if s[i-1][j]=='.' and s[i+1][j]=='.' and s[i][j-1]=='.' and s[i][j+1]=='.':
                ans='No'
                break
print(ans)

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

int main()
{
	int N, K;
	long long ans = 0;
	cin >> N >> K;
	vector<long long> H(N + 5, 0);

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

	sort(H.begin(), H.end(), greater<>());

	for (int i = K; i < N; i++)
	{
		ans += H[i];
	}

	cout << ans << endl;
	return 0;
}

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

int dp[2001][2001];

int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  string s;
  while(cin >> s){
    int n = s.size();

    memset(dp,0,sizeof(dp));
    rep(i,n){
      rep(j,n){
	if(s[i] == s[n-1-j])dp[i+1][j+1] = dp[i][j]+1;
	else dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
      }
    }

    int m = dp[n][n];
    string pal;
    int a = n, b = n;
    while(a!=0 && b!=0 && (int)pal.size()<(m+1)/2){
      if(a>0 && b>0 && dp[a][b] == dp[a-1][b-1]+1 && s[a-1]==s[n-b])pal += s[--a], --b;
      else if(a>0 && dp[a][b] == dp[a-1][b])a--;
      else if(b>0 && dp[a][b] == dp[a][b-1])b--;
    }
    
    for(int i=m/2-1;i>=0;i--)pal += pal[i];
    cout << pal << endl;
  }
}

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

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

    static class RemainderMinimization2019 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            HashSet<Long> set = new HashSet<>();
            long l = in.nextLong();
            long r = in.nextLong();

            if (r - l > 2019) {
                out.println(0);
                return;
            }
            long result = Long.MAX_VALUE;

            for (long i = l; i < r; i++) {
                for (long j = i + 1; j <= r; j++) {
                    result = Math.min(result, i * j % 2019);
                }
            }
            out.println(result);
        }

    }
}



Measured memory_bytes: 35788
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long

#define INF 999999999

using namespace std;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
// input
int a,b,c;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> a >> b >> c;
    
    if(a == b){
        cout << c << "\n";
    }
    
    else if (b == c){
        cout << a << "\n";
    }
    else{
        cout << b << "\n";
    }
    
}

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

using namespace std;

const int N = 1e5 + 5;

typedef complex <double> cd;
const double PI = acos(-1);

typedef long long ll;

void fft(vector <cd> & a, bool invert) {
  int n = a.size();
  for(int i = 1, j = 0; i < n; i++) {
    int bit = n >> 1;
    for(; j & bit; bit >>= 1) {
      j ^= bit;
    }
    j ^= bit;
    if(i < j) {
      swap(a[i], a[j]);
    }
  }
  for(int len = 2; len <= n; len <<= 1) {
    double ang = 2 * PI / len * (invert ? -1 : 1);
    cd wlen(cos(ang), sin(ang));
    for(int i = 0; i < n; i += len) {
      cd w(1);
      for(int j = 0; j < len / 2; j++) {
        cd u = a[i + j], v = a[i + j + (len / 2)] * w;
        a[i + j] = u + v;
        a[i + j + (len / 2)] = u - v;
        w *= wlen;
      }
    }
  }
  if(invert) {
    for(cd &x : a) {
      x /= n;
    }
  }
}

vector <ll> multiply(vector <ll> a, vector <ll> b) {
  vector <cd> fa(a.begin(), a.end());
  vector <cd> fb(b.begin(), b.end());
  int n = 1;
  while(n < a.size() + b.size()) n <<= 1;
  fa.resize(n), fb.resize(n);
  fft(fa, false), fft(fb, false);
  for(int i = 0; i < n; i++) {
    fa[i] *= fb[i];
  }
  fft(fa, true);
  vector <ll> result(n);
  for(int i = 0; i < n; i++) {
    result[i] = round(fa[i].real());
  }
  return result;
}

int main() {
  int n; cin >> n;
  ll m; cin >> m;
  vector <ll> a(N, 0), b(N, 0);
  for(int i = 0; i < n; i++) {
    int x; cin >> x;
    a[x]++; b[x]++;
  }
  vector <ll> res = multiply(a, b);
  ll ans = 0;
  for(int i = 2 * N - 1; i >= 1; i--) {
    if(res[i]) {
      ans += min(m, res[i]) * i;
      m -= min(m, res[i]);
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 13896
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n; cin>>n;
	int ans = (n/500)*1000;
	n = n%500;
	ans += (n/5)*5;
	cout<<ans;
	
	
	return 0;
}


Measured memory_bytes: 256
def function(n, list1):
  total = sum(list1)
  if n >= total:
    return n - total
  else:
    return -1
  
line1 = input().split()
n = int(line1[0])
line2 = input().split()
list1 = [int(i) for i in line2]
print(function(n, list1))

Measured memory_bytes: 9880
q = int(input())

import sys
input = sys.stdin.readline
# ヒープキュー（最小値・最大値の取得）
from heapq import heappop,heappush
left = []
right = []

lsum = 0
rsum = 0
q1_num = 0
b = 0
for _ in range(q):
    qs = tuple(map(int, input().split()))
    if(qs[0]==1):
        b += qs[2]
        if(q1_num == 0):
            heappush(left, qs[1] * -1)
            lsum += qs[1]
            q1_num += 1
            continue
        elif(q1_num%2==1):
            tmp = heappop(left) * -1
            lsum -= tmp

        else:
            tmp = heappop(right)
            rsum -= tmp
        less =  min(tmp, qs[1])
        more =  max(tmp, qs[1])
        heappush(left, less * -1)
        heappush(right, more)
        lsum += less
        rsum += more
        q1_num += 1

    else:
        num = rsum - lsum + b
        tmp = heappop(left) * -1
        if(q1_num%2==1):
            num += tmp
        heappush(left, tmp * -1)
        print(' '.join(map(str, [tmp, num])))


Measured memory_bytes: 11260
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextInt();
        long b = sc.nextInt();
        long c = sc.nextInt();
        String k = sc.next();
        if (k.length()<=19){
            long K = Long.parseLong(k);
            if (K%2==1){
                System.out.println(b-a);
            }else {
                System.out.println(a-b);
            }
        }else System.out.println("Unfair");


    }
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,ans[500000];

int main()
{
	cin>>n;
	repn(i,200)
	{
		repn(j,200)
		{
			repn(k,200)
			{
				ans[i*i+j*j+k*k+i*j+i*k+j*k]++;
			}
		}
	}
	repn(i,n) cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 4520
#include <iostream>
#include <vector>

#ifdef _VSCODE_DEBUG
    #include <fstream>
#endif

using ull = unsigned long long;

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

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

int main(){
    #ifdef _VSCODE_DEBUG
        std::ifstream in("input.txt");
        std::cin.rdbuf(in.rdbuf());
    #endif
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    // input data
    int N;
    std::cin >> N;
    std::vector<ull> T(N);
    for (int i=0; i<N; ++i) std::cin >> T[i];

    // lcm
    if (N == 1) {
        std::cout << T[0] << "\n";
        return 0;
    }

    ull ans=T[0];
    for (int i=1; i<N; ++i) ans = lcm(ans, T[i]);
    std::cout << ans << "\n";
    return 0;
}

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

using namespace std;

int main() {
	string s; cin >> s;
	int n = s.size();
	for(int i = 0; i < n; i++) {
		if(i<n-1 && s[i] == s[i+1]) {
			cout << i+1 << " " << i+2;
			return 0;
		}
		if(i<n-2 && s[i] == s[i+2]) {
			cout << i+1 << " " << i+3;
			return 0;
		}
	}

	cout << "-1 -1";
}

Measured memory_bytes: 3688
// 高橋君と見えざる手
#include <iostream>
#include <algorithm>
using namespace std;

int n,t;
int a,b[100000];

int main(){
    cin>>n>>t;
    int min_a=1000000000;
    for(int i=0;i<n;i++){
        cin>>a;
        b[i]=a-min_a;
        min_a=min(min_a,a);
    }
    sort(b,b+n);
    int ans=0;
    for(int i=n-1;i>=0;i--){
        if(b[i]==b[n-1]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MOD=998244853;
int n,m;
int maxl=0,minr=1e9+7;
int main()
{
    cin>>n>>m;
    int l,r,ans=0;
    for(int i=0;i<m;i++)
    {
        cin>>l>>r;
        maxl=max(maxl,l);
        minr=min(minr,r);
    }
    if(minr>=maxl)
    	ans=minr-maxl+1;
    cout<<ans<<endl;
    return 0;
}



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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using plglg = pair<ll, ll>;
using tlglglg = tuple<ll, ll, ll>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
inline void yesno(bool ok, string yes = "Yes", string no = "No") {cout << (ok?yes:no) << endl;}


signed main() {
    //my-code
    ll n; cin >> n;
    ll ans = 0;
    ll a = 1;
    ll b;
    while (a < n) {
        b = 1;
        while (a*b < n) {
            ans += 1;
            b++;
        }
        a++;
    }

    print(ans);

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
 
int main()
{
	string S;
	cin >> S;
	string result = "Yes";

	for (int i = 0; i < S.size(); i++) {
		if (i % 2 == 0) {
			if (S[i] != 'R' && S[i] != 'U' && S[i] != 'D') {
				result = "No";
				break;
			}
		}
		else {
			if (S[i] != 'L' && S[i] != 'U' && S[i] != 'D') {
				result = "No";
				break;
			}
		}
	}

	cout << result;
 
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int h, w, H, W;
	while (1)
	{
		scanf("%d %d", &H, &W);
		if (H ==0 && W == 0)
			break;
		for (h = 0; h < H; h++)
		{
			for (w = 0; w < W; w++)
			{
				if (h == 0 || h == H - 1 || w == 0 || w == W - 1)
				{
					printf("%c",'#');
				} else {
				printf("%c", '.');
				}
			}
			putchar('\n');
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 576
H,W=gets.split.map &:to_i
c=10.times.map{gets.split.map &:to_i}
A=H.times.map{gets.split.map &:to_i}
10.times{|k|10.times{|i|10.times{|j|c[i][j]=[c[i][j],c[i][k]+c[k][j]].min}}}
p A.each.map{|a|a.each.map{|i|i==-1?0:c[i][1]}.inject :+}.inject :+

Measured memory_bytes: 3068
/*input
73


*/
 
 
 
#include <bits/stdc++.h>
using namespace std;
 
 
 
#define int long long int
#define rep(i,n) \
    for(int i = 0; i < n; i++)
#define rep2(i, a, b) \
    for(int i = a; i < b; i++)
#define all(c) \
    c.begin(), c.end()
#define init(arr, num) \
    memset(arr, num, sizeof(arr))
#define fast\
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inputFile \
    freopen("input.txt", "r", stdin); 
#define outputFile \
    freopen("output.txt", "w", stdout);
#define modM 1000000007
#define PI 3.1415926535897932
#define F first
#define S second 
#define pb push_back   
 
#ifdef gaviria
#define TRACE
#endif
#ifdef TRACE
#define trace(...) _f(#VA_ARGS, __VA_ARGS_)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
 
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
typedef unordered_set<int> usi;
 
ll i,j,k,c=0,m;
ll n;

void solve() 
{

cin>>n;

cout<<2*PI*n;




}










            












     
 
 
 
 
signed main()
{
 
    // inputFile;
    fast;
    int T = 1;
//cin >> T;

    while(T--){

      
        solve();

        cout << endl;
        
        
 
    }
    
    
    return 0;
 
}

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  string n;cin>>n;

  rep(i,1,n.size()-1){
    if(n[i-1]==n[i]&&n[i]==n[i+1]){
      out("Yes");
      return 0;
    }
  }

  out("No");




  return 0;
}


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

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

	int cnt = 0;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) {
				if (L[i] != L[j] && L[i] != L[k] && L[k] != L[j]) {
					if (i != j && i != k && k != j) {
						if (L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[k] + L[i] > L[j]) cnt++;
					}
				}
			}
		}
	}
	cout << cnt/6 << endl;
	

	return 0;
}

Measured memory_bytes: 3592
function main(input) {
  var s = input[0].split("");
  var t = input[1].split("");

  var ans = 0;
  for(var i=0;i<s.length;i++){
    ans += (s[i]==t[i]?1:0);
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').split("\n"))


Measured memory_bytes: 22964
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll n, a[200100];
ll pos[200100];

int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		pos[a[i] - 1] = i;
	}
	ll ans = 0;
	set<ll> sl;
	sl.insert(-1);
	sl.insert(n);
	rep(i, n) {
		set<ll>::iterator it = sl.upper_bound(pos[i]);
		it--;
		set<ll>::iterator it2 = it;
		it++;
		ans += (i + 1)*(pos[i] - *it2)*(*it - pos[i]);
		sl.insert(pos[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 12800
#include <stdio.h>
#include <math.h>

typedef struct{
  double x;
  double y;
} Point;

void koch(int,Point,Point);

int main(int argc, char const *argv[]) {

  Point a,b; // a(0,0) b(100,0)??????
  int n;

  scanf("%d",&n);

  a.x = 0;
  a.y = 0;
  b.x =100;
  b.y = 0;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;
}

void koch(int n, Point a, Point b){

  if( n == 0 ){
    return;
  }

  Point s,t,u;
  double th = M_PI * 60.0 / 180.0;

  s.x = (2.0*a.x + 1.0*b.x) / 3.0;
  s.y = (2.0*a.y + 1.0*b.y) / 3.0;
  t.x = (1.0*a.x + 2.0*b.x) / 3.0;
  t.y = (1.0*a.y + 2.0*b.y) / 3.0;
  u.x = (t.x-s.x)*cos(th) - (t.y-s.y)*sin(th) + s.x;
  u.y = (t.x-s.x)*sin(th) + (t.y-s.y)*cos(th) + s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);

}

Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
	int n;
	int syakkinn=100000;
	int i;
	scanf("%d",&n);
	for(i=0;i<n;i++) {
		syakkinn*=1.05;
		if(syakkinn%1000!=0)syakkinn+=1000;
		syakkinn-=syakkinn%1000;
	}
	printf("%d\n",syakkinn);
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
  int n,m; cin>>n>>m;
  Graph g(n);
  rep(i,m){
    int a,b; cin>>a>>b; a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  ll count=0;
  vi x(n); rep(i,n) x[i]=i;
  do{
    bool m_judge=true;
    rep(i,n-1){
      bool judge=false;
      for(auto y :g[x[i]]){
        if(y==x[i+1]) judge=true;
      }
      if(!judge){
        m_judge=false;
        break;
      }
    }
    if(m_judge) count++;
  }while(next_permutation(x.begin()+1,x.end()));
  cout<<count;
}


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

#define endl '\n'
#define ll long long
#define LSB __builtin_ctzll
#define sc(a) scanf("%d",&a)
#define MSB 63-__builtin_clzll
#define scl(a) scanf("%lld",&a)
#define BITS __builtin_popcountll
#define mem(a , v)  memset(a , v , sizeof(a))
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1e9+7;
const int MAX = 1e5+55;
const int INF = 1e9+77;
const ll INFINF = 1e18+1e17;
const double PI = acos(-1.0);
vector<int> months = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

ll power(ll x,ll y){
         if(y==0)
         return 1;
         ll s=power(x,y/2);
         s*=s;
         if(y&1)
         s*=x;
         return s;
}


int n,m;
char x[1001][1001];
ll dp[1001][1001];

bool valid(int i,int j){
     return (i>=0&&i<n&&j>=0&&j<m&&x[i][j]=='.');
}


ll solve(int i,int j){
     if(i==n-1&&j==m-1){
        return 1;
     }


     ll &res=dp[i][j];
     if(res!=-1){
        return res;
     }

     res=0;
     if(valid(i+1,j)){
        res+=solve(i+1,j)%MOD;
     }
     if(valid(i,j+1)){
        res+=solve(i,j+1)%MOD;
     }

     return res%MOD;


}



int main(){

//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//freopen("input.txt" , "r" , stdin);
//freopen("output.txt" , "w" , stdout);



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



    mem(dp,-1);
    cout<<solve(0,0)%MOD;








     return 0;

}


Measured memory_bytes: 9088
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y
n,k = inm()
p = inl()
p = sorted(p)
print(sum(p[:k]))


Measured memory_bytes: 9192
N=int(input())
*A,=map(int,input().split())

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

from collections import*
C=Counter(S)
ans=0
for v in C.values():
    ans+=v*(v-1)//2

print(ans)

Measured memory_bytes: 44220
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i,start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
double dp[301][301][301];
ll N,vis[301][301][301];


double solve(ll x,ll y,ll z){
	
	if(vis[x][y][z]) 
		return dp[x][y][z];
	
	vis[x][y][z] = 1;

	if(x == 0 && y == 0 && z == 0) 
		return dp[x][y][z] = 0;

	ll sum = x + y + z;
	double tot = (N - sum)/(double)(sum);

	if(x != 0) 
		tot += x*((solve(x-1,y,z) + 1)/(double)(sum));
	if(y != 0) 
		tot += y*((solve(x+1,y-1,z) + 1)/(double)(sum));
	if(z != 0) 
		tot += z*((solve(x,y+1,z-1) + 1)/(double)(sum));

	return dp[x][y][z] = tot;

}

ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main(){

	ll a[4] = {0};

	cin >> N;

	for(ll i = 1;i<=N;i++){
		ll x;
		cin >> x;
		a[x]++;
	}

	printf("%.9lf\n",solve(a[1],a[2],a[3]));

	return 0;
}

Measured memory_bytes: 218504
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    H, W, K = in_nn()
    a = [list(in_s()) for _ in range(H)]
    ans = [[0 for _ in range(W)] for _ in range(H)]
    stb = []

    for y in range(H):
        for x in range(W):
            if a[y][x] == '#':
                stb.append((x, y))

    for i, (x, y) in enumerate(stb):
        ans[y][x] = i + 1

    for i, (x, y) in enumerate(stb):
        l = x
        while l != 0:
            if ans[y][l - 1] == 0:
                l -= 1
            else:
                break

        r = x
        while r != W - 1:
            if ans[y][r + 1] == 0:
                r += 1
            else:
                break

        u = y
        while u != 0:
            if sum(ans[u - 1][l:r + 1]) == 0:
                u -= 1
            else:
                break

        d = y
        while d != H - 1:
            if sum(ans[d + 1][l:r + 1]) == 0:
                d += 1
            else:
                break

        for yy in range(u, d + 1):
            for xx in range(l, r + 1):
                ans[yy][xx] = i + 1

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


if __name__ == '__main__':
    main()


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

int main(){
int a,b;
cin>>a>>b;
int ans=0;
ans=max(a+b,a-b);
ans=max(ans,a*b);
cout<<ans<<endl;

}


Measured memory_bytes: 256
H,W = list(map(int,input().split()))
import numpy as np
A = np.zeros([H,W])
ans = np.zeros([H,W]).astype(np.unicode)
for i in range(H):
    ans[i,:] = [x for x in input()]
    A[i,:] = [1 if x=='#' else 0 for x in ans[i,:]]

rw = np.all(A == 0, axis = 1)
cl = np.all(A == 0, axis = 0)

ans = ans[~rw,:]
ans = ans[:,~cl]
for i in range(ans.shape[0]):
    print("".join(ans[i,:]))

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

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, k, q;
    cin >> n >> k >> q;
    int a[q];
    vector<int> players(n);
    for (int i = 0; i < q; i++) {
        cin >> a[i];
        players[a[i] - 1]++;
    }
    for (auto &p : players) {
        if (q - p < k) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
}


Measured memory_bytes: 1408
import sys

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():
    mod = 1000000007
    
    N = ii()
    A = lmi()

    mz_count = 0 # minus or zero
    mz_min = 10 ** 10
    ans = 0
    for i in A:
        if i <= 0:
            mz_count += 1
            i = -i
        ans += i
        if mz_min > i:
            mz_min = i
    
    if mz_count % 2 == 0:
        print(ans)
    else:
        print(ans - 2 * mz_min)    

    return

main()


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

int main(){
    int r, c;
    cin >> r >> c;
    vector<vector<int>> d(r+1, vector<int>(c+1));
    int sumr, suml;

    for (int i = 0; i < r; i++)
    {
        sumr=0;
        for (int j = 0; j < c; j++)
        {
            cin >> d.at(i).at(j);
            sumr += d.at(i).at(j);
        }
        d.at(i).at(c) = sumr;
    }

    for (int i = 0; i < c+1; i++)
    {
        suml=0;
        for (int j = 0; j < r; j++)
        {
            suml += d.at(j).at(i);
        }
        d.at(r).at(i) = suml;
    }
    
    for (int i = 0; i < r+1; i++)
    {
        for (int j = 0; j < c+1; j++)
        {
            cout << d.at(i).at(j);
            if(j==c) cout << endl;
            else cout << " ";
        }
    }
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define int LL
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
int lcm(int a,int b)
{
	return a/__gcd(a,b)*b;
}
const int MAX_N=305; 
int g[MAX_N][MAX_N];
bool need[MAX_N][MAX_N];
int n;
signed main()
{
	memset(need,true,sizeof(need));
	cin>>n;
	For(i,1,n)
	{
		For(j,1,n)
		{
			cin>>g[i][j];
		}
	}
	For(k,1,n)
	{
		For(i,1,n)
		{
			For(j,1,n)
			{
				if(g[i][k]+g[k][j]<g[i][j])
				{
					puts("-1");
					return 0;
				}
			}
		}
	}
	For(k,1,n)
	{
		For(i,1,n)
		{
			For(j,1,n)
			{
				if(k==i || i==j || k==j)continue;
				if(g[i][k]+g[k][j]==g[i][j])need[i][j]=false;
			}
		}
	}
	int ans=0;
	For(i,1,n)
	{
		For(j,1,n)
		{
			ans+=need[i][j]*g[i][j];
		}
	}
	cout<<ans/2<<endl;
	return 0;
}




Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    vector<ll>A(3);
    cin >>A[0]>>A[1]>>A[2];
    sort(all(A));
    if(A[0]==5&&A[1]==5&&A[2]==7){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }



    return 0;
    

}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}

#define MAX_N 200005
vector<int> pre_G[MAX_N];
vector<int> G[MAX_N];
int par_[MAX_N];
int flag_netsukigi[MAX_N];
void make_netsukigi(int r){
    queue<int> que;
    que.push(r);
    flag_netsukigi[r] = 1;
    par_[r] = -1;

    while(que.size() > 0){
        int x = que.front();
        que.pop();
        flag_netsukigi[x] = 1;
        rep(i,pre_G[x].size()){
            if(flag_netsukigi[pre_G[x][i]] == 0){
                par_[pre_G[x][i]] = x;
                G[x].push_back(pre_G[x][i]);
                que.push(pre_G[x][i]);
            }
        }
    }
}

const int INF = 1001001001;
int n;
int a[MAX_N];
int dp[MAX_N];
int ans[MAX_N];

void dfs(int x){
    int ite = lower_bound(dp, dp+n, a[x]) - dp;
    int keep = dp[ite];
    dp[ite] = a[x];
    ans[x] = lower_bound(dp, dp+n, INF) - dp;


    rep(i,G[x].size()){
        int y = G[x][i];
        dfs(y);
    }

    dp[ite] = keep;
}

int main() {
    cin >> n;
    rep(i,n){
        cin >> a[i];
    }

    rep(i,n-1){
        int x, y;
        scanf("%d%d", &x, &y);
        x--; y--; // 0-indexにするため.
        pre_G[x].push_back(y);
        pre_G[y].push_back(x);
    }

    make_netsukigi(0);

    fill(dp, dp+n, INF);


    dfs(0);

    rep(i,n){
        cout << ans[i] << endl;
    }
    
    return 0;
}
 
 



Measured memory_bytes: 38032
N,M = map(int,input().split())
data = []

for i in range(M):
    data.append([i]+list(map(int,input().split())))

count = [0] * (N+1)

data.sort(key = lambda x:x[2])

ans = [0] * M

for i in range(M):
    count[data[i][1]] += 1
    y = [0] * (6-len(list(str(data[i][1])))) + list(str(data[i][1]))
    z = [0] * (6-len(list(str(count[data[i][1]])))) + list(str(count[data[i][1]]))
    ans[data[i][0]] = list(map(int,y + z))

#print(ans)
for i in range(M):
    print("".join(map(str,ans[i])))

Measured memory_bytes: 43456
#include <iostream>
using namespace std;
#define MAX 300

int dp[MAX],cost;

void rate(){
    fill(dp,dp+MAX,0);
    dp[0] = 1;
    
    for(int i = 1 ; i <= 17 ; i++){
        for(int j = 0 ; i*i+j <= MAX ; j++){
            if(dp[j]) dp[i*i+j] += dp[j];
        }
    }
}

void inp(){
    rate();
    while(cin >> cost,cost){
        cout << dp[cost] << endl;
    }
}

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

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

int main() {
  ll N;
  cin >> N;
  ll F = N / 3;
  ll B = N / 5;
  ll FB = N / 15;
  ll sum = N * (N+1) / 2;
  ll exc = F * (F+1) * 3 / 2 + B * (B+1) * 5 / 2 - FB * (FB+1) * 15 / 2;
  
  cout << sum - exc << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <map>
#include <tuple>
#include <regex>

using namespace std;

constexpr int M = 1000000007;

// NG : AGC, A*GC, AG*C, ACG, GAC

int count_strs(int n) {
  vector<map<string, int>> dp(n + 1);
  vector<string> ok3 = {"AAA","AAG","AAC","AAT","AGA","AGG","AGT","ACA","ACC","ACT","ATA","ATG","ATC","ATT","GAA","GAG", "GAT","GGA","GGG","GGC","GGT","GCA","GCG","GCC","GCT","GTA","GTG","GTC","GTT","CAA","CAG","CAC","CAT","CGA","CGG","CGC","CGT","CCA","CCG","CCC","CCT","CTA","CTG","CTC","CTT","TAA","TAG","TAC","TAT","TGA","TGG","TGC","TGT","TCA","TCG","TCC","TCT","TTA","TTG","TTC","TTT"};
  for (auto&& s : ok3)
    dp[3][s] = 1;
  regex c_ng("(.AG)|(A.G)|(AG.)|(.GA)");
  for (int i = 3; i < n; i++) {
    for (auto&& p : dp[i]) {
      int pats; string s;
      tie(s, pats) = p;
      auto stail = s.substr(1, 3);
      dp[i + 1][stail + 'A'] += pats;
      dp[i + 1][stail + 'A'] %= M;
      dp[i + 1][stail + 'T'] += pats;
      dp[i + 1][stail + 'T'] %= M;
      if (!regex_match(begin(s), end(s), c_ng)) {
        dp[i + 1][stail + 'C'] += pats;
        dp[i + 1][stail + 'C'] %= M;
      }
      if (s[1] != 'A' || s[2] != 'C') {
        dp[i + 1][stail + 'G'] += pats;
        dp[i + 1][stail + 'G'] %= M;
      }
    }
  }

  int result = 0;
  for (auto&& p : dp[n]) {
    result += p.second;
    result %= M;
  }
  return result;
}



int main() {
  int n;
  cin >> n;
  cout << count_strs(n) << endl;
}


Measured memory_bytes: 896
#include<iostream>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;

int main() {
  long N;
  long K;

  cin >> N;
  cin >> K;
  long A[N];
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  
  mp::cpp_int num_of_arrays = K*(K-1)/2;
  mp::cpp_int count = 0;
  
  long all_array[N];
  long rear[N];
  
  long all_array_count = 0;
  long rear_count = 0;
  long all_sum = 0;
  long rear_sum = 0;
  
  for (int i=0; i<N; i++) {
    for (int j=0; j<N; j++) {
      if (A[i] > A[j]) {
        all_array_count++;
        if (j > i) rear_count++;
      }
    }
    all_array[i] = all_array_count;
    rear[i] = rear_count;
    all_array_count = 0;
    rear_count = 0;
  }
  
  for (int i=0; i<N; i++) {
    rear_sum += rear[i];
    all_sum += all_array[i];
  }
  
  count = rear_sum * K + all_sum * num_of_arrays;
  
  cout << count % (1000000000+7);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int R = scanner.nextInt();
		if (R < 1200)
			System.out.println("ABC");
		else if (R < 2800)
			System.out.println("ARC");
		else
			System.out.println("AGC");
		scanner.close();
	}
}

Measured memory_bytes: 23124