akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#include <math.h>
#include <iomanip>
#include <fstream>
#include <random>
#include <queue>
using namespace std;

inline void InitRand()
{
    srand((unsigned int)time(NULL));
}
int main() {
     InitRand();
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    string s;
    cin>>s;
    int sum=0;
    bool hata=0;
    bool hata2=0;
    for(int i=0;i<s.size();++i){
        if(hata==1){if(s[i]!='9'&&hata2==0){hata2=1;sum--;}sum+=9;}
        else{
            if(s[i]!='9'){hata=1;if(i>=1){sum--;sum+=9;}
                else{sum+=s[i]-'0';}}
            else{sum+=9;}
            
        }
        //cout<<sum<<endl;
    }
    cout<<sum<<endl;
    return 0;
}

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

void input_vector(std::vector<int>& v) {
  int N;
  int temp;
  std::cin >> N;
  for(int i = 0; i < N; ++i) {
    std::cin >> temp;
    v.push_back(temp);
  }
}

void print_vector(std::vector<int> v) {
  for(int i = 0; i < v.size()-1; ++i) {
    std::cout << v[i] << " ";
  }
  std::cout << v[v.size()-1] << std::endl;
}

void selectionSort(std::vector<int>& A) {
  int mi = 0;
  int count = 0;
  for(int i = 0; i < A.size(); ++i) {
    mi = i;
    for(int j = i; j < A.size(); ++j) {
      if( A[j] < A[mi] ) {
	mi = j;
      }
    }
    if( i != mi ) {
      std::swap(A[i], A[mi]);
      count += 1;
    }
  }
  print_vector(A);
  std::cout << count << std::endl;
}

int main() {

  std::vector<int> A;

  input_vector(A);
  selectionSort(A);

  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
    int n;
    cin>>n;
    ll ans = 0;
    for(int i=0;i<n;++i)
    {
        int t;
        cin>>t;
        ans += t-1;
    }
    cout<<ans<<'\n';
    return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

template <typename T>
struct BIT {
  int n;          // 配列の要素数(数列の要素数+1)
  vector<T> bit;  // データの格納先
  BIT(int n_) : n(n_ + 1), bit(n, 0) {}

  void add(int i, T x) {
    for (int idx = i; idx < n; idx += (idx & -idx)) bit[idx] += x;
  }

  T sum(int i) {
    T s(0);
    for (int idx = i; idx > 0; idx -= (idx & -idx)) s += bit[idx];
    return s;
  }
};

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  rep(i, 0, n) cin >> a[i];
  vector<int> pi(n + 1, -1);
  vector<vector<int>> ps(n);
  rep(i, 0, n) {
    int l = pi[a[i]];
    if (l != -1) ps[l].push_back(i);
    pi[a[i]] = i;
  }

  vector<vector<P>> qs(n);
  rep(qi, 0, q) {
    int l, r;
    cin >> l >> r;
    --l, --r;
    qs[l].emplace_back(r, qi);
  }
  vector<int> ans(q);
  BIT<int> seg(n);
  for (int x = n - 1; x >= 0; --x) {
    for (int y : ps[x]) seg.add(y, 1);
    for (P query : qs[x]) {
      int r = query.first, i = query.second;
      ans[i] = (r - x + 1) - seg.sum(r);
    }
  }
  arep(i, ans) cout << i << '\n';
  return 0;
}

Measured memory_bytes: 70912
#include <cstdio>
#include <cmath>

typedef long long ll;
typedef struct
{
    ll x;
    ll y;
} coordinary;
typedef struct
{
    coordinary c;
    ll r;
} barrier;
    
const ll MAX_N = 1000;
ll N;
barrier b[MAX_N + 2];

double distance(barrier b1, barrier b2)
{
    double answer = (double)(b1.c.x - b2.c.x) * (b1.c.x - b2.c.x);
    answer += (double)(b1.c.y - b2.c.y) * (b1.c.y - b2.c.y);
    answer = sqrt(answer) - b1.r - b2.r;
    if(answer < 0.0) return 0.0;
    return answer;
}

double min(double x, double y)
{
    return x < y ? x : y;
}

int main()
{
    ll xt, yt;
    scanf("%lld %lld %lld %lld", &b[0].c.x, &b[0].c.y, &xt, &yt);
    scanf("%lld", &N);
    for(int i = 1; i <= N; i++){
        scanf("%lld %lld %lld", &b[i].c.x, &b[i].c.y, &b[i].r);
    }
    b[N + 1].c.x = xt;
    b[N + 1].c.y = yt;

    bool visited[N + 2] = { false };
    double d[N + 2];
    for(int i = 1; i <= N + 1; i++){
        d[i] = distance(b[i], b[0]);
    }
    
    while(!visited[N + 1]){
        int min_i = N + 1;
        double min_d = d[N + 1];
        for(int i = 1; i <= N + 1; i++){
            if(!visited[i]){
                if(d[i] < min_d){
                    min_i = i;
                    min_d = d[i];
                }
            }
        }
        visited[min_i] = true;
        for(int i = 1; i <= N + 1; i++){
            if(!visited[i]){
                d[i] = min(d[i], min_d + distance(b[min_i], b[i]));
            }
        }
    }
    printf("%.10lf\n", d[N + 1]);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
struct ope{
    int a;
    int b;
    int c;
    int d;
};
signed main(void){
    int h,w;cin>>h>>w;
    int G[h][w];
    rep(i,h)rep(j,w){
        cin>>G[i][j];
    }
    bool have=false;
    int nowh=0,noww=0;
    vector<ope>Ans;
    int count=0;
    rep(c,h*w-1){
        if(nowh%2==0){
            if(noww==w-1){
                if(G[nowh][noww]%2==1){
                    Ans.push_back({nowh+1,noww+1,nowh+2,noww+1});
                    count++;
                    nowh++;
                    G[nowh][noww]++;
                }
                else nowh++;
            }
            else{
                if(G[nowh][noww]%2==1){
                    Ans.push_back({nowh+1,noww+1,nowh+1,noww+2});
                    count++;
                    noww++;
                    G[nowh][noww]++;
                }
                else noww++;
            }
        }
        
        
        else{
            if(noww==0){
                if(G[nowh][noww]%2==1){
                    Ans.push_back({nowh+1,noww+1,nowh+2,noww+1});
                    count++;
                    nowh++;
                    G[nowh][noww]++;
                }
                else nowh++;
            }
            else{
                if(G[nowh][noww]%2==1){
                    Ans.push_back({nowh+1,noww+1,nowh+1,noww});
                    count++;
                    noww--;
                    G[nowh][noww]++;
                }
                else noww--;
            }
        }
    }
    cout<<count<<endl;
    rep(x,Ans.size()){
        ope t=Ans[x];
        cout<<t.a<<' '<<t.b<<' '<<t.c<<' '<<t.d<<endl;
    }
    
    
}

Measured memory_bytes: 8176
S = list(input())
a = len(S)
b = 0
c = 0
for i in range(a):
    if c==0:
        if b%2==0:
            b += 1
            if S[i]=="L":
                c += 1
        else:
            b += 1
            if S[i]=="R":
                c += 1

if c == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<stdio.h>


int G[101][101], A[101], B[101], n;

void f(int a, int b){
  int i;
  A[a] = b;
  for(i = 1; i <= B[a]; i++){
    if(b + 1 < A[G[a][i]]) f(G[a][i], b + 1);
  }
}

int main(){
  int i, j, m;

  scanf("%d", &n);

  for(i = 1; i <= n; i++){
    A[i] = 100000000;
    scanf("%d", &m);
    scanf("%d", &B[m]);

    for(j = 1; j <= B[m]; j++) scanf("%d", &G[m][j]);
  }

  f(1, 0);

  for(i = 1; i <= n; i++){
    if(A[i] == 100000000) A[i] = -1;
  }

  for(i = 1; i <= n; i++) printf("%d %d\n", i, A[i]);

  return 0;
}

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

const int N=100003;

bool eratosthenes(bool prime[N],int i){
    rep(i,N) prime[i]=1;
    prime[0]=prime[1]=0;
    rep(i,N){
        if(prime[i]){
            for(int j=i+i;j<N;j+=i){
                prime[j]=0;
            }
        }
    }
    return prime[i];
}

int main() {
    int x; cin >> x;
    int ans=0;
    bool prime[N];
    for(int i=x;i<=N;i++){
        if(eratosthenes(prime,i)) {
            ans=i;
            break;
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
int main(void){
  int i,j,c=0,l,y,t,f;
  char w[7][6],m[201];
  for(i=1;i<=5;i++){
    for(j=1;j<=5;j++){
      w[i][j]=(char)('a'+c);
      c++;
    }
  }
  w[6][1]='z';
  w[6][2]='.';
  w[6][3]='?';
  w[6][4]='!';
  w[6][5]=' ';
  while(scanf("%s",m)!=EOF){
    f=0;
    l=strlen(m);
    if(l%2){
      puts("NA");
      continue;
    }
    for(i=0;i<l;i++){
      if(i%2==0){
	if(m[i]>'6'||m[i]=='0'){
	  f=1;
	  break;
	}
      }
      else{
	if(m[i]>'5'||m[i]=='0'){
	  f=1;
	  break;
	}
      }
    }
    if(f){
      puts("NA");
      continue;
    }
    for(i=0;i<l/2;i++){
      y=m[2*i]-'0';
      t=m[2*i+1]-'0';
      printf("%c",w[y][t]);
    }
    puts("");
  }
  return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main()
{
	int n,a,b,p,x=0,y=0,z=0;
	cin >> n >> a >> b;
	rep(i,n){
		cin >> p;
		if(p<=a) x++;
		else if(p<=b) y++;
		else z++;
	}
	cout << min(x,min(y,z)) << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n = INT()
G = [[]for i in range(n)]   
position = [[]for i in range(n)]
for i in range(n):
    a, b= MAP()
    position[i] = (i, a, b)
position_x = sorted(position, key = lambda x:x[1])
position_y = sorted(position, key = lambda x:x[2])

for i in range(1,n):
    G[position_x[i][0]].append((position_x[i][1]-position_x[i-1][1], position_x[i-1][0]))
    G[position_x[i-1][0]].append((position_x[i][1]-position_x[i-1][1], position_x[i][0]))
    G[position_y[i][0]].append((position_y[i][2]-position_y[i-1][2], position_y[i-1][0]))
    G[position_y[i-1][0]].append((position_y[i][2]-position_y[i-1][2], position_y[i][0]))

def prim(G):
    res = 0
    used = [False]*n
    que = []
    heapq.heapify(que)
    used[0] = True
    for Gs in G[0]:
        heapq.heappush(que,Gs)
    while(len(que) > 0):
        cost, vertex = heapq.heappop(que)
        if used[vertex]:continue
        res += cost
        used[vertex] = True
        for Gs in G[vertex]:
            if used[Gs[1]]:continue
            heapq.heappush(que,Gs)
    return res

print(prim(G))

Measured memory_bytes: 112432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
void solve(void)
{
  int n;
  cin >> n;
  vector<int> L(n);
  rep(i, n) cin >> L[i];
  sort(L.begin(), L.end());
  int ans = 0;
  rep(i, n - 2)
  {
    for (int j = i + 1; j < n - 1; ++j)
    {
      //二分探索する
      int a = L[i];
      int b = L[j];
      int c = a + b;
      int l = j;
      int r = n;
      int mid = (l + r) / 2;

      while (r - l > 1)
      {
        mid = (l + r) / 2;
        if (L[mid] >= c)
          r = mid;
        else
          l = mid;
      }

      // cout << i << ":" << j << "  " << c << " " << L[mid] << endl;
      ans += l - j;
    }
  }
  cout << ans << endl;
}
int main(void) { solve(); }


Measured memory_bytes: 3616
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
typedef long long int LL;
using namespace std;

int main(int argc, char const *argv[]) {
    int N, W;
    cin >> N >> W;
    vector<int> weight(N), value(N);
    vector<vector<LL>> sum_value(N + 1, vector<LL>(W + 1));
    for (int i = 0; i < N; i++) {
        cin >> weight[i] >> value[i];
    }
    for (int i = 0; i <= N; i++) {
        for (int w = 0; w <= W; w++) {
            if (i == 0) {
                sum_value[i][w] = 0LL;
            } else {
                if (w >= weight[i - 1]) {
                    sum_value[i][w] = max(sum_value[i - 1][w], sum_value[i - 1][w - weight[i - 1]] + (LL) value[i - 1]);
                } else {
                    sum_value[i][w] = sum_value[i - 1][w];
                }
            }
        }
    }
    cout << sum_value[N][W] << endl;
    return 0;
}

Measured memory_bytes: 80256
import itertools
n, m, q = map(int, input().split())
abcd = [tuple(map(int, input().split())) for _ in range(q)]
ans = 0
for com in itertools.combinations_with_replacement(range(1, m + 1), n):
    score = sum([d for a, b, c, d in abcd if com[b - 1] - com[a - 1] == c])
    ans = max(ans, score)
print(ans)

Measured memory_bytes: 9092
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int main(void)
{
  
    int K, N;
    cin >> N >> K;
    int length[N] = {0};
    for(int i = 0; i < N; i++)
    {
        cin >> length[i];
    }

    sort(length , length + N, greater<int>());
    int sum = 0;
    for(int i = 0; i < K; i++)
    {
        sum += length[i];
    }
    cout << sum <<endl;

    return 0;
}


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

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline T gcd(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T lcm(T a,T b){return a*b/gcd(a,b);}

const ll INF = 1LL << 60;


int main(){
  int n;
  cin >> n;
  int a[1000000];
  FOR(i,n){
    cin >> a[i];
  }
  int x=0,sum=0;
  FOR(i,n){
    sum+=abs(x-a[i]);
    x=a[i];
    if(i==n-1){
      sum+=abs(a[i]-0);
    }
  }
  bool hantei[1000000];
  FOR(i,n){
    if(i==0){
      if((0<=a[i] && a[i]<=a[i+1]) ||(a[i+1]<=a[i] && a[i]<=0)){
        hantei[i]=1;
      }
    }else if(i==n-1){
      if((0<=a[i] && a[i]<=a[i-1]) ||(a[i-1]<=a[i] && a[i]<=0)){
        hantei[i]=1;
      }
    }else{
      if((a[i-1]<=a[i] && a[i]<=a[i+1]) ||(a[i+1]<=a[i] && a[i]<=a[i-1])){
        hantei[i]=1;
      }
    }
  }
  FOR(i,n){
    if(hantei[i]){
      cout << sum << endl;
    }else{
      cout << sum-min(abs(a[i-1]-a[i]),abs(a[i+1]-a[i]))*2 << endl;
    }
  }

}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
#define INF 1e9
#define INFL 1e16
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
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; }
 
arr<int> land;
int ans;
int h, w;

void dfs(int x, int y){
    land[x][y] = 0;
    FOR(i, -1, 2){
        FOR(j, -1, 2){
            if(i==0 && j==0) continue;
            if(x+i < 0 || x+i >= h || y+j < 0 || y+j >= w) continue;
            if(land[x+i][y+j]==1){
                dfs(x+i, y+j);
            }
        }
    }
}

int main()
{
    while(1){
        cin >> w >> h;
        if(w==0 && h==0) break;
        land.resize(h);
        rep(i, h) land[i].resize(w);

        rep(i, h) rep(j, w) cin >> land[i][j];
        ans = 0;
        rep(i, h) rep(j, w){
            if(land[i][j]==0) continue;
            ans++;
            dfs(i, j);
        }
        pr(ans);
    }
    return 0;}


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

using namespace std;

#define MOD 1000000007
#define N 3003
#define M 102
#define ll long long 
#define ld long double
#define pb push_back
#define ff first
#define ss second

int dp[N][N];

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    string s, t, ans;
    cin>>s>>t;
    int n = s.length();
    int m = t.length();
    int i, j;
    for(i=0; i<=n; i++){
        for(j=0; j<=m; j++){
            if(i == 0 || j == 0){
                dp[i][j] = 0;
            }
            else if(s[i-1] == t[j-1]){
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    ans = "";
    i = n; j = m;
    while(i > 0 && j > 0){
        if(s[i-1] == t[j-1]){
            ans += s[i-1]; 
            i--; j--; 
        }
        else if(dp[i-1][j] > dp[i][j-1]){
            i--;
        }
        else{
            j--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout<<ans;
	return 0;
}

Measured memory_bytes: 35456
/// wa ^3^

#pragma GCC optimize("O3")

#include<bits/stdc++.h>
                           
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

template<typename T> istream 
&operator>>(istream &a, vector<T> &v) { 
for (auto& x : v) a >> x; return a; }

void stndrtn() {
#ifdef accepted
    freopen(".in", "r", stdin);
#endif        
}

const bool flag = 0;

void maincode() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i] >> b[i];
    ll ans = 0, d = 0;
    for (int i = n-1; ~i; --i) {
        a[i] += d;
        if (a[i] % b[i]) {
            ll val = (a[i]/b[i]+1)*b[i]-a[i];
            ans += val, d += val;
        }
    }
    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int ts = 1;
    if (flag) 
        cin >> ts;
    while (ts--)
        maincode(); 
    return 0;
}



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

int main(){
  int n;
  cin >> n;
  string s[n];
  rep(i,n) cin >> s[i];
  vector<int> a(n), m(n);
  rep(i,n) {
    for(auto c : s[i]) {
      if(c == '(') a[i]++;
      else {
        a[i]--;
        m[i] = min(a[i],m[i]);
      } 
    }
  }
  int dif = 0;
  rep(i,n) dif += a[i];
  if(dif) {
    cout << "No" << endl;
    return 0;
  }
  int cur = 0;
  vector<P> mp, mm;
  rep(i,n) {
    if(m[i] >= 0) cur += a[i];
    else {
      if(a[i] >= 0) mp.push_back(P(m[i],a[i]));
      else if(a[i] != m[i]) mm.push_back(P(m[i],a[i]));
    }
  }
  sort(mp.begin(),mp.end(),greater<P>());
  sort(mm.begin(),mm.end());
  for(auto p : mp) {
    if(cur + p.first < 0) {
      cout << "No" << endl;
      return 0;
    }
    cur += p.second;
  } 
  for(auto p : mm) {
    if(cur + p.first < 0) {
      cout << "No" << endl;
      return 0;
    }
    cur += p.second;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 42236
n,k = list(map(int, input().split()))
x = list(map(int, input().split()))

# 連続するK地点を選ぶ
cost = 10**18
for i in range(0, n-k+1):
    left = x[i]
    right = x[i+k-1]
    if left < 0 and right < 0:
        cost = min(cost , abs(left))
    elif left > 0 and right > 0:
        cost = min(cost, abs(right))
    else:
        cost = min(cost, min(2 * abs(right) + abs(left), 2 * abs(left) + abs(right)))

print(cost)

Measured memory_bytes: 19936
S = input()
T = input()

len_s = len(S)
len_t = len(T)

result = len_t
i = 0

while (i <= len_s - len_t):
    diff = 0
    for j, c in enumerate(T):
        if (c != S[i + j]):
            diff += 1
    result = min(result, diff)
    i += 1

print(result)



Measured memory_bytes: 73156
using System;
using System.Collections.Generic;
using System.Collections;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;

//namespace _1_A
//{
class Program
{
    static void Main(string[] args)
    {

        string en = Console.ReadLine();
        double r = double.Parse(en);
        
        Console.WriteLine((r * r * Math.PI).ToString("f6") + " " + ((r + r) * Math.PI).ToString("f6"));

        //Console.Read();
    }
}
//}

Measured memory_bytes: 9228
import java.util.*

object MainKt {
	@JvmStatic
	fun main(args: Array<String>) {
		val scanner = Scanner(System.`in`)
		val a = scanner.nextInt()
		val b = scanner.nextInt()
		val k = scanner.nextInt()

		var ans = 1
		var n=0
		for (i in 100 downTo 1) {
			if (a%i==0 && b%i==0) {
				n++
				if (n==k) {
					ans = i
					break
				}
			}
		}
		println(ans)

	}
}

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

#define ll long long

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int rd=0,sd=0,cnt=0,i;
	string s;
	cin >> s;
	
	for(i=0;i<3;i++)
	{
		if(s[i]=='S'&&i==1) cnt++;
		if(s[i]=='R') rd++;
	}
	
	if(cnt>0&&rd>1) rd--;
	
	cout << rd << endl;
	
	return 0;
}


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

int main() {
  int n, x;
  cin >> n;
  int a[n + 1];
  for (int i = 0; i < n; i++) {
    cin >> x;
    a[x] = i + 1;
  }
  for (int i = 1; i <= n; i++) cout << a[i] << " ";
  cout << '\n';
  return 0;
}


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

int main() {
    ll L, R;
    cin >> L >> R;
    R = min(R, L+2019);
    int ans = 2018;
    for(ll i = L; i <= R; i++){
        for(ll j = i+1; j <= R; j++){
            int x = i*j%2019;
            ans = min(ans, x);
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

using namespace std;

#include <atcoder/modint>

using mint = atcoder::modint998244353;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(...) DBG2::print(#__VA_ARGS__, __LINE__, __VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

const mint TEN = 10;
vector<mint> P10;
const mint inv9 = mint(9).inv();

const long long NEUTRAL_VAL = 0;
struct SegmentTreeNode {
   mint val;
   int len;
   bool delay_flag;
   char delay_val;
   SegmentTreeNode(int _val = NEUTRAL_VAL, int _len = 0)
      : val(_val), len(_len), delay_flag(false), delay_val(0) { }
   SegmentTreeNode operator+(const SegmentTreeNode& R) const {
      SegmentTreeNode res;
      res.val = this->val * P10[R.len] + R.val;
      res.len = this->len + R.len;
      return res;
   }
   void update(int L, int R, char d) {
      delay_flag = true;
      delay_val = d;
      val = (P10[R-L+1] - 1) * inv9 * (d-'0');
   }
   void propagate(SegmentTreeNode& pL, SegmentTreeNode& pR, int L, int R) {
      if (delay_flag) {
         pL.update(L, (L+R)/2, delay_val);
         pR.update((L+R)/2+1, R, delay_val);
         delay_flag = false;
         delay_val  = 0;
      }
   }
};

class SegmentTree {
   int N;
   vector<SegmentTreeNode> tree;

   void _build(const string& S, int node, int L, int R) {
      if (L == R) {
         tree[node] = SegmentTreeNode(S[L]-'0', 1);
         return;
      }
      _build(S, 2*node, L, (L+R)/2);
      _build(S, 2*node+1, (L+R)/2+1, R);
      tree[node] = tree[2*node] + tree[2*node+1];
   }
   void _update(int p, int q, char val, int node, int L, int R) {
      if (q < L || p > R) return;
      if (p <= L && R <= q) {
         tree[node].update(L, R, val);
         return;
      }
      tree[node].propagate(tree[2*node], tree[2*node+1], L, R);
      _update(p, q, val, 2*node, L, (L+R)/2);
      _update(p, q, val, 2*node+1, (L+R)/2+1, R);
      tree[node] = tree[2*node] + tree[2*node+1];
   }
public:
   SegmentTree(const string& S) {
      N = S.size();
      int NUM_NODES = 4*N+1;
      tree = vector<SegmentTreeNode>(NUM_NODES);
      _build(S, 1, 0, N-1);
   }
   void update(int p, int q, char val) {
      _update(p, q, val, 1, 0, N-1);
   }
   mint query() {
      return tree[1].val;
   }
};


int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int N, Q;
   cin >> N >> Q;
   string S(N, '1');

   P10.assign(N+1, 0);
   P10[0] = 1;
   FOR(n, 1, N)
      P10[n] = P10[n-1] * 10;

   SegmentTree ST(S);
   FOR(q, 1, Q) {
      int L, R, D;
      cin >> L >> R >> D;
      --L, --R;
      ST.update(L, R, '0'+D);
      mint res = ST.query();
      cout << res.val() << '\n';
   }

   return 0;
}


Measured memory_bytes: 13516
/**
 *    author:  FromDihPout
 *    created: 2020-08-16
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    vector<pair<int,int>> ADJ = {{1,0}, {-1,0}, {0,1}, {0,-1}};
    
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    for (int i = 0; i < h; i++) {
        cin >> a[i];
    }
    
    int black = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            black += a[i][j] == '#';
        }
    }
    
    queue<pair<int,int>> q;
    q.push({0, 0});
    a[0][0] = '#';
    int dist = 1;
    bool reached = false;
    while (!q.empty()) {
        int len = q.size();
        for (int i = 0; i < len; i++) {
            pair<int,int> pos = q.front();
            q.pop();
            if (pos.first == h-1 && pos.second == w-1) {
                reached = true;
                break;
            }
            for (auto p : ADJ) {
                int x = pos.first + p.first, y = pos.second + p.second;
                if (x < 0 || x >= h || y < 0 || y >= w) continue;
                if (a[x][y] == '#') continue;
                q.push({x, y});
                a[x][y] = '#';
            }
        }
        if (reached) break;
        dist++;
    }
    
    int ans = -1;
    if (reached) {
        ans = (h * w) - dist - black;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>

int rot[5][7] = {
{0,1,2,3,4,5,6},{0,2,6,3,4,1,5},{0,4,2,1,6,5,3},{0,3,2,6,1,5,4},{0,5,1,3,4,6,2}};
int assign[7];		// サイコロの1～6の各面に割り当てる数字
int tr['Z'];

void dice_init(int *a)
{
	int i;
	int t[5] = {0,'N','E','W','S'};
	for (i = 1; i <= 6; i++) assign[i] = a[i];
	for (i = 1; i <= 4; i++) tr[t[i]] = i;
}

char s[102];
int main()
{
	int i, k1, k2;
	int a[7], dice[2][7];
	char *p;

	for (i = 1; i <= 6; i++) scanf("%d", a+i);
	dice_init(a);
	scanf("%s", p=s);
	for (i = 1; i <= 6; i++) dice[0][i] = rot[0][i];
	for (k1 = 0, k2 = 1; *p; k1 = k2, k2 = !k2) {
		for (i = 1; i <= 6; i++) dice[k2][i] = dice[k1][rot[tr[*p]][i]];
		p++;
	}
	printf("%d\n", assign[dice[k1][1]]);
	return 0;
}



Measured memory_bytes: 2108
import math

n, d = map(int , input().split())
points = [list(map(int, input().split())) for i in range(n)]

distances = []
for i in points:
  distance = math.sqrt(i[0]**2 + i[1]**2)
  if distance <= d:
    distances.append(distance)

ans = len(distances)
print(ans)

Measured memory_bytes: 51720
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

const int N=105;
int mm[N];


int main(){	
	fastio;
	int n;cin>>n;
	FER(i,1,n+1)cin>>mm[i];
	int c=0;
	FER(h,1,101){
		FER(i,0,n){
			if(mm[i]<h&&mm[i+1]>=h)c++;
		}
	}
	cout<<c<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
//const ll MOD = 1e9 + 7;

ll mod = 998244353;

const int MAX = 2 * 1e5 + 5; // 適宜
const int MOD = mod;


ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int mainsolve(){

    COMinit();

    ll n,m,k;
    cin >> n >> m >> k;

    if(n==1){
        cout << m << endl;
        return 0;
    }
    if(m == 1){
		if(k == n-1){
			cout << 1 << endl;
			return 0;
		}
		else{
			cout << 0 << endl;
			return 0;
		}

    }

    ll res = 0;

    vector<ll> mpow(n+5);
    mpow[0] = 1;
    rep(i,n+4) mpow[i+1] = (mpow[i] * (m-1)) % mod;

    rep(i,k+1){
        ll tmp = COM(n-1,i) * m % mod;
        (tmp *= mpow[n-1-i]) %= mod;
        (res += tmp) %= mod;

        // res += COM(n-1,i) * m * mpow[n-1-i];

    }

    cout << res << endl;
    return 0;

}

int main(){

	return mainsolve();
}

Measured memory_bytes: 9608
# include <bits/stdc++.h>
# define fi first
# define se second
# define ll long long

using namespace std ;

int n, x, ans ;
vector < int > vc ;

int main() {
    cin >> n ;
    for( int i = 0 ; i < n ; i ++ ) {
        cin >> x ;
        vc.push_back(x) ;
    }
    for( int i = 1 ; i < n-1 ; i ++ ) {
        if( max({vc[i], vc[i-1], vc[i+1]}) != vc[i] && min( {vc[i], vc[i+1], vc[i-1]} ) != vc[i]) ans ++ ;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
    int n,m;
    while(1){
        cin >> n >> m;
        if(n ==0 && m==0) break;
        vector<pair<int, int> > vec(n+1);
        rep(i,n){
            int d,p;
            cin >> d >> p;
            vec[i] = make_pair(p,d);
        }
        sort(vec.begin(),vec.end(),greater<pair<int,int> >());
        int i=0;
        while(m > 0){         
            vec[i].second--;
            m--;
            if(vec[i].second == 0) i++;
            if(vec.size() == i) break;
        }
        int ans = 0;
        rep(i,vec.size()){
            ans += vec[i].first * vec[i].second;
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;


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

	int H, W;
	cin >> H >> W;
	vector<vector<char>> s(H, vector<char>(W));
	int white = 0;
	REP(i, H)REP(j, W) {
		cin >> s[i][j];
		if (s[i][j] == '.') white++;
	}
	queue<vector<int>> qu;
	qu.push({ 0,0 });
	vector<vector<int>> dis(H, vector<int>(W, 0));
	vector<vector<bool>> conf(H, vector<bool>(W, false));
	while (!qu.empty()) {
		int i = qu.front()[0];
		int j = qu.front()[1];
		int k = dis[i][j];
		if (i == H - 1 && j == W - 1) {
			cout << white - dis[i][j] - 1 << "\n";
			return 0;
		}
		if (i + 1 < H && !conf[i + 1][j] && s[i + 1][j] == '.') {
			qu.push({ i + 1,j });
			conf[i + 1][j] = true;
			dis[i + 1][j] = k + 1;
		}
		if (i - 1 >= 0 && !conf[i - 1][j] && s[i - 1][j] == '.') {
			qu.push({ i - 1,j });
			conf[i - 1][j] = true;
			dis[i - 1][j] = k + 1;
		}
		if (j + 1 < W && !conf[i][j + 1] && s[i][j + 1] == '.') {
			qu.push({ i ,j + 1 });
			conf[i][j + 1] = true;
			dis[i][j + 1] = k + 1;
		}
		if (j - 1 >= 0 && !conf[i][j - 1] && s[i][j - 1] == '.') {
			qu.push({ i ,j - 1 });
			conf[i][j - 1] = true;
			dis[i][j - 1] = k + 1;
		}
		qu.pop();
	}
	cout << -1 << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vl = vector<ll>; using vvl = vector<vl>;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
const ll INF = 9223372036854775807;

int main() {
  int c;cin >> c;
  cout << c+c*c+c*c*c << endl;
}

Measured memory_bytes: 3592
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    a.sort(reverse=True)
    print(sum(a[0::2]) - sum(a[1::2]))


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int calc(int x){
  int res = 0;
  while(x % 100 == 0){
    res++;
    x /= 100;
  }
  return res;
}

int main(){
  int d, n;
  cin >> d >> n;
  int count = 0;
  int value = 1;
  while(true){
    int res = calc(value);
    if(res == d)  count++;
    if(count == n) break;
    value++;
  }
  cout << value << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{

    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt();
        System.out.println((int)((1900 * m + 100 * (n - m)) * Math.pow(2, m)));
    }
}

Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

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


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int a,b,c;
	cin>>a>>b>>c;
	a++;
	cout<<(a-b)*(a-c)<<endl;
}

	


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

#define sz(x) (int)(x.size())
#define FOR(x,y,z) for(int x = y; x <= z; x++)
#define int long long

const int N = 1e5 + 2, inf = 1e18;

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 

    int x, n;
    map<int,int> given;

    cin >> x >> n;
    int ans = -1, diff = inf;
    FOR(i,1,n){
        int u;
        cin >> u;
        given[u] = true;
    }
    FOR(i,-200,200){
        if(!given[i]){
            if(diff > (abs(x - i))){
                diff = abs(x - i);
                ans = i;
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 3616
#include<string>
#include<iostream>

int main(){
  std::string a;
  std::string b;
  int count=0;
  std::cin>>a>>b;
  for(int i=0;i<a.length();i++){
    if(a[i]==b[i])continue;
    else count++;
  }
  std::cout<<count<<std::endl;
  return 0;
}
  

Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+1e3;

int read()
{
	int s=0;
	char c=getchar();
	while (c<'0'||'9'<c) c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return s;
}
void write(int x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(int x)
{
	write(x);
	putchar('\n');
}
int n,a[N];
bool check(int m)
{
	pair<int,int>Min(INT_MAX,INT_MAX);
	for (int i=1;i<=2*n-2;i++)
	if ((a[i]>=m)==(a[i+1]>=m))
	Min=min(Min,make_pair(min(abs(n-i),abs(n-i-1)),(int)(a[i]>=m)));
	if (Min.first==INT_MAX) return a[1]>=m;
	return Min.second;
}

int main()
{
	n=read();
	for (int i=1;i<=2*n-1;i++) a[i]=read();
	int l=0,r=2*n-1;
	while (l<=r)
	{
		int mid=(l+r)/2;
		if (check(mid)) l=mid+1;
				   else r=mid-1;
	}
	print(r);

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using ll = int_fast64_t;
const int MOD = 1e9+7;

int main(){
        int n, k;
        scanf("%d %d", &n, &k);
        n++;
        ll ans = 0;
        for(ll i=k; i<=n; i++) {
                ans += (n-i) * i % MOD + 1;
                ans %= MOD;
        }
        printf("%ld\n", ans);
        return 0;
}

Measured memory_bytes: 3824
package main

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

func solve() {
	n := getInt()
	xs := getIntSlice(n)
	b1, b2 := func() (int, int) {
		tmp := make([]int, n)
		copy(tmp, xs)
		sort.Ints(tmp)
		return tmp[(n-1)/2], tmp[(n-1)/2+1]
	}()

	for _, x := range xs {
		ans := 0
		if x <= b1 {
			ans = b2
		} else {
			ans = b1
		}
		fmt.Fprintln(wr, ans)
	}
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

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

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

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

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	if(s.back()=='s')s=s+"es";
	else s=s+"s";

	cout<<s;
	
	
	return 0;
}

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

int main()
{
    vector<string> S(3);
    rep(0, i, 3)
    {
        cin >> S[i];
    }
    cout << S[0][0] << S[1][1] << S[2][2] << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))

l = [True] * n
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    #print(h[a],h[b])
    if h[a] >= h[b]:
        l[b] = False
    if h[a] <= h[b]:
        l[a] = False

#print(l)
print(l.count(True))

Measured memory_bytes: 19960
n = int(input())
A = list(map(int, input().split()))
mval = float('inf')
minus_cnt = 0
isZero = False
ans = 0

for a in A:
    if a < 0: minus_cnt += 1
    if a == 0: isZero
    mval = min(mval, abs(a))
    ans += abs(a)

if isZero or minus_cnt % 2 == 0: print(ans)
else: print(ans - mval*2)


Measured memory_bytes: 14284
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
	int n;

	while (cin >> n, n){
		vector<int> v;
		for (int i = 0; i < n; i++){
			int t;
			cin >> t;
			v.push_back(t);
		}

		int total = 32;
		int i = 0;
		while (total){
			total -= (total - 1) % 5;
			cout << total << endl;
			total = fmax(total - v[i % n], 0);
			cout << total << endl;
			i++;
		}
	}

	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main(void)
{
    int a,b,t;
    cin >> a >> b >> t;

    cout << (int)floor((t + 0.5) / a) * b << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define me0(a) memset(a,0,sizeof(a))
#define me1(a) memset(a,-1,sizeof(a))
#define op freopen("in.txt", "r", stdin)
#define pii pair<int,int>
#define mp(x,y) make_pair(x,y)
using namespace std;
const int INF = 0x3f3f3f3f;
typedef unsigned long long ULL;
typedef long long LL;
void read(int& val) { int x = 0; int bz = 1; char c; for (c = getchar(); (c<'0' || c>'9') && c != '-'; c = getchar()); if (c == '-') { bz = -1; c = getchar(); }for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48; val = x * bz; }
const int mod=1e9+7;
const int maxn =1e6+11;


int n;
map<string,int>mpp;
int main(){
    int n;
    read(n);
    mpp["AC"]=0;
    mpp["WA"]=0;
    mpp["TLE"]=0;
    mpp["RE"]=0;

    fo(i,1,n){
        string s;cin>>s;
        mpp[s]++;
    }

    cout<<"AC"<<" x "<<mpp["AC"]<<endl;
    cout<<"WA"<<" x "<<mpp["WA"]<<endl;
    cout<<"TLE"<<" x "<<mpp["TLE"]<<endl;
    cout<<"RE"<<" x "<<mpp["RE"]<<endl;

    return 0;
}

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

// --------------------------------------------------------------------------------
#define fastio	ios_base::sync_with_stio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define deb(name,value) cout <<"->>  "<<name<< "= " <<value<<" "
#define frepi(a,b,k) for(int i=a;i<=b;i+=k)
#define frepj(a,b,k) for(int j=a;j<=b;j+=k)
// --------------------------------------------------------------------------------


void solve_main()
{
    ll n;cin>>n;
    ll ans = 0;
    frepi(1,n,1)
    {
    	if(i%3==0 || i%5==0)
    	{
    		continue;
    	}
    	ans+=i;
    }
    cout<<ans;
}

int main()
{
	// #ifndef ONLINE_JUDGE
 //    	freopen("/home/suryakant/input.txt","r",stdin);
 //        freopen("/home/suryakant/output.txt","w",stdout);
 //    #endif
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve_main();
    }
    
}

Measured memory_bytes: 3620
N, Q = map(int, input().split())
queries = []
for i in range(Q):
    v, w = map(int, input().split())
    queries.append([v, w])

if N == 1:
    for v, w in queries:
        print(min(v, w))
else:
    for v, w in queries:
        if 1 in [v, w]:
            print(1)
        else:
            # v < w にする
            v, w = min(v,w), max(v, w)
            v -= 2
            w -= 2
            v_parents = [v]
            isReported = False
            while v > 0:
                v_parents.append(v // N - 1)
                v = v//N-1
            while w > 0:
                w = w // N-1
                if w in v_parents:
                    print(w+2)
                    isReported = True
                    break
            if not isReported:
                print(1)
        

Measured memory_bytes: 71384
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
const int N = 2e5 + 10;
 
int n, m, k;
 
int main()
{
  scanf("%d%d%d", &n, &m, &k);
  vector <ll> a(n+1,0);
  vector <ll> b(m+1,0);
  for (int i = 1, x; i <= n; ++i) scanf("%d", &x), a[i] = a[i - 1] + x;
  for (int i = 1, x; i <= m; ++i) scanf("%d", &x), b[i] = b[i - 1] + x;
  
  int j = m;
  ll ans = 0;
  for (int i = 0; i <= n; ++i)
  {
    if (a[i] > k) break;
    while (a[i] + b[j] > k) j --;
    ans = max(ans, i + j + 0LL);
  }
  
  printf("%lld\n", ans);
  
  return 0;
} 

Measured memory_bytes: 6424
def solve(n, m, price_list):
    rest = m
    price_list.sort()
    ans = 0
    for v, c in price_list:
        if c >= rest:
            ans += (v * rest)
            print(ans)
            exit()
        ans += (v * c)
        rest -= c

n, m = map(int,input().split())
price_list = []
for i in range(n):
    a, b = map(int, input().split())
    price_list.append([a,b])

solve(n, m, price_list)    

Measured memory_bytes: 20056
#include <iostream>
#include <string>
using namespace std;
const string s1="YES",s2="NO";
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int num=a*100+b*10+c;
	puts((num%4==0)?s1.c_str():s2.c_str());
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	while(1){
		int a,b;
		char op;
		scanf("%d %c %d",&a,&op,&b);
		switch(op){
			case '+':
			printf("%d\n",a+b);
			break;
			case '-':
			printf("%d\n",a-b);
			break;
			case '*':
			printf("%d\n",a*b);
			break;
			case '/':
			printf("%d\n",a/b);
			break;
			case '?':
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 2040
# -*- coding: utf-8 -*-
"""
Created on Thu May 14 00:52:36 2020

@author: shinba
"""

n,m = map(int,input().split())

ans = 0

if n >= 2 and m >= 2:
    ans += (n-2)*(m-2)
else:
    if n == 1 and m == 1:
        ans = 1
    else:
        ans = max(m,n) - 2
    
print(ans)


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

using namespace std;

#define int long long

const int INF = 1e18;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, m;
    cin >> n >> m;
    int a, b;
    vector <pair <int, int> > v;
    for (int i = 0; i < m; ++i) {
    	cin >> a >> b;
    	v.push_back({b, a});
    }
    sort(v.begin(), v.end());
    int ans = 0, last = -1;
    for (int i = 0; i < v.size(); ++i) {
    	if (v[i].second >= last) {
    		++ans;
    		last = v[i].first;
    	}
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
using namespace std;
 
int main() {
  long long i, N, res = 1;
  cin >> N;
  
  for (i = 1; i <= N; ++i) {
    res = res*i % (10*10*10*10*10*10*10*10*10 + 7);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256