akhauriyash/Code-Regression huggingface dataset:
//Bismillahir-Rahmanir-Rahim
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int llu;
#define f1(i,n) for(i=1;i<=n;i++)
#define f(i,n) for(i=0;i<n;i++)
#define Max 1000009
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
     ll n,k,i,j,r=0,w=0,rn=0,wn=0,op=0;
     string s;
     cin>>n>>s;
     f(i,n)
     {
         if(s[i]=='R')
            r++;
         else w++;
     }
     if(w==n||r==n)
        cout<<0<<endl;
     else{
            i=0,j=n-1;
     while(i<j)
     {
         while(i<n&&s[i]=='R')
         {
             i++;
         }
         while(j>=0&&s[j]=='W')
            j--;
         if(i<j)
         {
             op++;
             swap(s[i],s[j]);
         }
     }
     cout<<op<<endl;
     }

}













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

int main() {
  int a, b;
  cin >> a >> b;
  int N = 0;
  for (int i = 0; i < max(a, b); i++) {
    N *= 10;
    N += min(a, b);
  }
  cout << N << endl;
}

Measured memory_bytes: 3616
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
typedef unsigned long long ull;
const ull INF = 1e18;
using namespace std;

int main(){
    vs lst;
    string tmp;
    int n,l;
    cin>>n>>l;
    rep(i,0,n){
        cin>>tmp;
        lst.push_back(tmp);
    }
    sort(lst.begin(),lst.end());
    rep(i,0,n){
        cout<<lst[i];
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
double X[10], Y[10];

double kaizyo(int a, int c) {
  double b = 1ll;
  rep(i, c) {
    b *= a;
    a--;
  }
  return b;
}

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

  cin >> N;
  rep(i, N) cin >> X[i] >> Y[i];
  int a[N] = {};
  rep(i,N) a[i] = i;
  double sum = 0.0; 
  do {
    double distance = 0.0;
    rep(i, N) {
      if (i==0) continue;
      int now = a[i],pre = a[i-1];
      double d = sqrt(pow(X[now]-X[pre], 2)+pow(Y[now]-Y[pre], 2));
      sum+=d;
    }
  } while(next_permutation(a, a + N));
  sum /= kaizyo(N, N);
  cout << fixed << setprecision(8) << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int t=0;
    int sum=0;
    for(int i=0;i<n;i++){
        int u;
        cin>>u;
        sum+=u;
        t=max(t,u);
    }
    sum-=t;
    if(t<sum)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int mod = 1000000007;

int main(){
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}


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




int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long long n, ans = 0;
    cin >> n;
    for(int i = 1; i * 1LL * i <= n; i++){
        if(n % i == 0){
            long long x = i - 1;
            if(x != 0 && n / x == n % x){
                ans += x;
            }
            if(i != n / i){
                x = n / i - 1;
                if(x != 0 && n / x == n % x){
                    ans += x;
                }
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#import <Foundation/Foundation.h>
typedef NSInteger Int;
Int f(Int x){
	Int result = 0;
	while(x>0){
		result += x%10;
		x/=10;
	}
	return result;
}
int main() {
	Int n;
	scanf("%ld",&n);
	Int ans = NSIntegerMax;
	for(Int a=1;a<=(n+1)/2;a++){
		Int b = n-a;
		ans = MIN(ans, f(a)+f(b));
	}
	printf("%ld\n",ans);
}

Measured memory_bytes: 5480
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

int main(){FIN;
	ll n,m; cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2;
	
	return 0;
}

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

using namespace std;

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

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

  int count = 0;
  for (int i = 0; i + 2 < n; ++i)
  {
    if (p[i] < p[i + 1])
    {
      if (p[i + 1] < p[i + 2]) ++count;
    }
    else
    {
      if (p[i + 1] > p[i + 2]) ++count;
    }
  }
  cout << count << endl;
}

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

#ifdef LOCAL
#include "../debug.h"
#else
#define debug(x...) 141
#endif
#define forn(i,x,n) for(int i = x; i < n; ++i)
#define forit(it, m) for(auto it = m.begin(); it!=m.end(); ++it)
typedef long long ll;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n,d,ans=0,x,y;

    cin>>n>>d;
    forn(i,0,n)
    	cin>>x>>y, ans+=x*x+y*y<=d*d;
    cout<<ans<<'\n';
    
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;

struct Node 
{
	int key; 
	Node *right, *left, *parent;
};

Node *root, *NIL;

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

Node *treeMinimum(Node *root)
{
	while (root->left != NIL) root = root->left;
	return root;
}

Node *treeSuccessor(Node *root)
{
	if (root->right != NIL) return treeMinimum(root->right);
	Node *x = root->parent;
	while (x != NIL && root == x->right)
	{
		root = x;
		x = x->parent;
	}
	return x;
}

void treeDelete(Node *key)
{
	Node *x;
	Node *y;

	if (key->left == NIL || key->right == NIL) y = key;
	else y = treeSuccessor(key);

	if (y->left != NIL) x = y->left;
	else x = y->right;

	if (x != NIL) x->parent = y->parent;

	if (y->parent == NIL) root = x;
	else 
	{
		if (y == y->parent->left) y->parent->left = x;
		else y->parent->right = x;
	}

	if (y != key) key->key = y->key;
	free(y);
}

void insert(int key) 
{
	Node *x = root;
	Node *y = NIL;
	Node *z = new Node();

	z->key = key;
	z->left = NIL;
	z->right = NIL;

	while (x != NIL)
	{
		y = x;
		if (z->key < x->key) x = x->left;
		else x = x->right;
	}

	z->parent = y;
	if (y == NIL) root = z;
	else 
	{
		if (z->key < y->key) y->left = z;
		else y->right = z;
	}
}

void inorder(Node *root) 
{
	if (root == NIL) return;
	inorder(root->left);
	cout << " " << root->key;
	inorder(root->right);

}

void preorder(Node *root)
{
	if (root == NIL) return;
	cout << " " << root->key;
	preorder(root->left);
	preorder(root->right);
}

int main() 
{
	int n, key;
	string str;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> str;
		if (str == "find")
		{
			cin >> key;
			Node *t = find(root, key);
			if (t != NIL) cout << "yes" << endl;
			else cout << "no" << endl;
		}
		else if (str == "insert")
		{
			cin >> key;
			insert(key);
		}
		else if (str == "print")
		{
			inorder(root);
			cout << endl;
			preorder(root);
			cout << endl;
		}
		else if (str == "delete")
		{
			cin >> key;
			treeDelete(find(root, key));
		}
	}

	return 0;
}

Measured memory_bytes: 21856
using System;
using System.Collections.Generic;

enum occupant
{
build, floor, room, number
}

class Program
 {


     
     static void Main(string[] args)
     {
         int data0 = 0, data1 = 0, data2 = 0;

         String nyuryoku;
         string[] data = new string[4];
         int[,,] room = new int[4,3,10];

         nyuryoku = Console.ReadLine();
         data0 = int.Parse(nyuryoku);


         for (int i = 0 ; i < data0 ; i++)
         {
             nyuryoku = Console.ReadLine();
             data = nyuryoku.Split(' ');
             room[int.Parse(data[(int)occupant.build])-1,int.Parse(data[(int)occupant.floor])-1,int.Parse(data[(int)occupant.room])-1] = room[int.Parse(data[(int)occupant.build])-1,int.Parse(data[(int)occupant.floor])-1,int.Parse(data[(int)occupant.room])-1] + int.Parse(data[(int)occupant.number]);
         }

         for (int i = 0;i < 4;i++)
         {
             for (int j = 0;j < 3;j++)
             {
                 Console.WriteLine(" {0} {1} {2} {3} {4} {5} {6} {7} {8} {9}",room[i,j,0],room[i,j,1],room[i,j,2],room[i,j,3],room[i,j,4],room[i,j,5],room[i,j,6],room[i,j,7],room[i,j,8],room[i,j,9]);
             }
             if( i != 3)
             Console.WriteLine("####################");
         }
      }
 }



Measured memory_bytes: 17720
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    x = INT()

    m = x % 11
    if m == 0: a = 0
    elif 0 < m <= 6: a = 1
    else: a = 2

    print((x//11)*2 + a)


if __name__ == '__main__':
    main()

Measured memory_bytes: 38640
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>

using namespace std;

#define l first
#define r second
#define int long long

int n;
string s;
int q;
long long pr[1500000];
vector<pair<int, int> > keks;
long long prr[1500000];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> s;
    for (int i = 0; i < s.size(); i++)
    {
        if (i)
        pr[i] = pr[i - 1]; pr[i] += s[i] == 'M';
        if (s[i] == 'C') keks.push_back({i, pr[i]});
    }
    for (int i = 0; i < keks.size(); i++)
    {
        if (i) prr[i] = prr[i - 1];
        prr[i] += keks[i].second;
    }
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        int k = 0;
        cin >> k;
        long long ans = 0;
        int l = -1, l2 = -1;
        for (int j = 0; j < s.size(); j++)
        {
            if (s[j] == 'D')
            {
                while (l + 1 < keks.size() && keks[l + 1].first < j + k) l++;
                while (l2 + 1 < keks.size() && keks[l2 + 1].first < j) l2++;
                ans += prr[l] - (l2 >= 0 ? prr[l2] : 0) - (l - l2) * pr[j];
            }
        }
        cout << ans << "\n";
    }
}

Measured memory_bytes: 36748
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
using namespace std;
int a = 0, b = 0, c = 0, d = 0, e[60][60], f[100200], g[100200], h[100200], counto = 0,counto2=0, ans =1 , x[100] = {}, y, z;
int64_t ab[10000] = {}, abc = 0, abcd = 0;
pair<int, int>manji[101] = {};
char rikka, toka[150][150] = {};
vector<int> train, code;
vector<char>aka, ao;
string saya, homu, kyok, mami[108], mado[100];
bool gg = true ,ap=false;
bool exist[100200];
int main() {
	cin >> a>>b>>c;
	for (int i = 0; i < b; i++) {
		cin >> f[i];
		if (f[i] > c) {
			counto2++;
		}
		else { counto++; }
		//cout << counto << ' ' << counto2 << endl;
	}
	cout << min(counto, counto2) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
 
const int maxn = 2e3 + 20;
const int maxm = maxn * maxn + 20;
const int mod = 1e9 + 7;

int dp[maxn][maxn] , fac[maxm] , caf[maxm];

inline void mkay(int &a)
{
	if(a >= mod)
		a -= mod;
	else if(a < 0)
		a += mod;
}

int bpw(int a , int b)
{
	if(!b)
		return 1;
	int x = bpw(a , b / 2);

	x = 1LL * x * x % mod;
	if(b&1)
		x = 1LL * x * a % mod;

	return x;
}

int c(int s , int r)
{
	if(r < 0 || r > s)
		return 0;

	return 1LL * fac[s] * caf[r] % mod * caf[s - r] % mod;
}

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

	fac[0] = 1;
	for(int i = 1; i < maxm; i++)
		fac[i] = 1LL * fac[i - 1] * i % mod;

	caf[maxm - 1] = bpw(fac[maxm - 1] , mod - 2);
	for(int i = maxm - 1; i > 0; i--)
		caf[i - 1] = 1LL * caf[i] * i % mod;

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

	if(k == 1)
		return cout << 1 << endl , 0;

	dp[0][0] = 1;
	for(int j = 0; j <= n; j++)
		for(int i = 0; i <= j; i++)
		{
			mkay(dp[i + 1][j] += 1LL * dp[i][j] * (n - i) % mod * c(n * k - (k - 1) * i - j - 1 , k - 2) % mod);
			mkay(dp[i][j + 1] += dp[i][j]);
		}

	cout << dp[n][n] << endl;
}


















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

int main () {
  string s; cin >> s;
  
  s.pop_back();
  s.pop_back();
  string l = s.substr(0, s.size()/2);
  string r = s.substr((s.size()/2), s.size()/2);
  while (l != r) {
    s.pop_back();
    s.pop_back();
    l = s.substr(0, s.size()/2);
    r = s.substr((s.size()/2), s.size()/2);
  }
  cout << s.size() << endl;
}
  

Measured memory_bytes: 256
import numpy as np


flag = False
arr = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        if b in arr[j]:
            idx = arr[j].index(b)
            arr[j][idx] = 0

arr = np.array(arr)
for s in arr:
    if sum(s) == 0:
        flag = True
arr = np.rot90(arr)
for s in arr:
    if sum(s) == 0:
        flag = True
if arr[0][0] + arr[1][1] + arr[2][2] ==0:
    flag = True
if arr[2][0] + arr[1][1] + arr[0][2] == 0:
    flag = True
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 12492
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int x,y,X,Y;

int main(){
	cin>>x>>y>>X>>Y;
	cout<<X+y-Y<<' '<<Y+X-x<<' '<<x+y-Y<<' '<<y+X-x<<endl;
}

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

vector<vector<int>> g;
vector<int> dp;
void dfs(int u, int p) {
    if (p < 0) dp[u] = 0;
    for (int v: g[u]) if (v != p) {
        dp[v] = dp[u] + 1;
        dfs(v, u);
    }
}

int main() {
    int n; cin >> n;
    int u, v; cin >> u >> v; u--, v--;
    g.resize(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b; cin >> a >> b; a--, b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    dp.resize(n);
    dfs(u, -1);
    auto du = dp;
    dfs(v, -1);
    auto dv = dp;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (du[i] < dv[i]) ans = max(ans, dv[i] - 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10752
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
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);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int K = in.nextInt();
            int[] D = new int[10];
            for (int i = 0; i < K; i++) {
                D[in.nextInt()] = 1;
            }

            int ans = calc(N, D, 0, 0);
            out.println(ans);
        }

        private int calc(int N, int[] D, int v, int n) {
            if (n > 5) {
                return 99999;
            }
            if (N <= v) {
                return v;
            }
            int ret = 99999;
            for (int i = 0; i < D.length; i++) {
                if (D[i] == 1) {
                    continue;
                }
                ret = Math.min(ret, calc(N, D, i * (int) Math.pow(10, n) + v, n + 1));
            }
            return ret;
        }

    }
}



Measured memory_bytes: 21844
import Data.List
import Data.Array
import Data.Maybe
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS8
 
getInts :: IO [Int]
getInts = (map parseInt . BS8.words) <$> BS.getLine 
    where parseInt = fst . fromJust . BS8.readInt
 
solve :: Int -> [Int] -> Int
solve k = sum . drop k . sortBy (flip compare) . map length . group . sort
 
main :: IO ()
main = do
    [n, k] <- getInts
    ls <- getInts
    print (solve k ls)

Measured memory_bytes: 32124
#include<cstdio>
#include<list>
#include<algorithm>
using namespace std;
const int MAXN=105;

int n,A[MAXN],ans[MAXN];

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&A[i]);
    for(int i=n;i>=1;i--)
    {
        int k=-1;
        for(int j=i;j>=1;j--)
            if(A[j]==j)
            {k=j;break;}
        if(k==-1)
        {
            puts("-1");
            return 0;
        }
        ans[i]=k;
        for(int j=k;j<=i;j++)
            A[j]=A[j+1];
    }
    for(int i=1;i<=n;i++)
        printf("%d\n",ans[i]);

    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

char S[200001],T[200001];
//int minSx[200000],maxSx[200000],minSy[200000],maxSy[200000],minTx[200000],maxTx[200000],minTy[200000],maxTy[200000];
int main(){
  int H,W,N,sr,sc,i,flag = 1;
  int minx =0,maxx=0,miny=0,maxy=0;
  scanf("%d %d %d",&H,&W,&N);maxx = W-1;maxy = H-1;
  scanf("%d %d",&sr,&sc);sr--;sc--;
  scanf("%s",S);
  scanf("%s",T);
  for(i = N-1;i >=0;i--){
    /*minSx[i]=minSx[i-1];
    maxSx[i]=maxSx[i-1];
    minSy[i]=minSy[i-1];
    maxSy[i]=maxSy[i-1];
    minTx[i]=minTx[i-1];
    maxTx[i]=maxTx[i-1];
    minTy[i]=minTy[i-1];
    maxTy[i]=maxTy[i-1];
    switch(S[i]){
      case 'L':minSx[i]++;break;
      case 'R':maxSx[i]++;break;
      case 'U':minSy[i]++;break;
      case 'D':maxSy[i]++;break;
    }
    if(sr-minTy[i]+maxSy[i]>=H||
       sr+maxTy[i]-minSy[i]<0||
       sc-minTx[i]+maxSx[i]>=W||
       sc+maxTx[i]-minSx[i]<0){
      flag = 0;break;
    }
    switch(T[i]){
      case 'L':minTx[i]++;break;
      case 'R':maxTx[i]++;break;
      case 'U':minTy[i]++;break;
      case 'D':maxTy[i]++;break;
    }
    printf("%d,%d,%d,%d,%d,%d,%d,%d\n",minSx[i],maxSx[i],minSy[i],maxSy[i],minTx[i],maxTx[i],minTy[i],maxTy[i]);
*/
    switch(T[i]){
      case 'L':if(maxx < W-1){maxx++;}break;
      case 'R':if(minx > 0){minx--;}break;
      case 'U':if(maxy < H-1){maxy++;}break;
      case 'D':if(miny > 0){miny--;}break;
    }
    switch(S[i]){
      case 'L':minx++;break;
      case 'R':maxx--;break;
      case 'U':miny++;break;
      case 'D':maxy--;break;
    }
    if(maxx < minx||maxy < miny){
      flag = 0;break;
    }
  }
  if(minx > sc||maxx<sc||miny > sr||maxy < sr){flag = 0;}
  printf(flag?"YES\n":"NO\n");
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>

#define H 104
#define W 104

#define C 2

int w, h;
char map[W][H];			//	マップ
int dx[2][6] = {{0, 0, 1, 1, 1, -1}, {0, 0, 1, -1, -1, -1}};
int dy[2][6] = {{-1, 1, -1, 0, 1, 0}, {-1, 1, 0, -1, 0, 1}};

int check(int nx, int ny)
{
	if (nx >= 0 && nx <= w + 1 && ny >= 0 && ny <= h + 1){
		return (1);
	}
	return (0);
}

void getWay(int x, int y)
{
	int i;
	
	map[x][y] = C;
	
	for (i = 0; i < 6; i++){
		int nx = x + dx[(y + 1) % 2][i];
		int ny = y + dy[(y + 1) % 2][i];
		
		if (check(nx,ny)){
			if (map[nx][ny] == 0){
				getWay(nx, ny);
			}
		}
	}
}

int main(void)
{
	int i, j, k;
	int length = 0;
	
	memset(map, 0, sizeof(map));
	scanf("%d%d", &w, &h);
	for (i = 0; i < h; i++){
		for (j = 0; j < w; j++){
			scanf("%d", &map[j + 1][i + 1]);
		}
	}
	
	getWay(0, 0);
	
	for (i = 0; i <= h + 1; i++){
		for (j = 0; j <= w + 1; j++){
			
			if (map[j][i] == 1){
				for (k = 0; k < 6; k++){
					int nx = j + dx[(i + 1) % 2][k];
					int ny = i + dy[(i + 1) % 2][k];
					
					if (check(nx, ny)){
						if (map[nx][ny] == C){
							length++;
						}
					}
				}
			}
		}
	}
	
	printf("%d\n", length);
	
	return (0);
}

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

ll f(int x, int y){
    if(y == 0) return x;
    else return f(y, x%y);
}
ll gcd(int a, int b, int c){
    return f(f(a, b), c);
}

int main(void){
    int k;
    ll ans = 0;
    cin >> k;
    for(int a = 1; a <= k; a++){
        for(int b = 1; b <= k; b++){
            for(int c = 1; c <= k; c++){
                ans += gcd(a, b, c);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let n = read!(usize);
    let a = read![[i64]];

    let mut b = VecDeque::new();
    for i in 0..n {
        if (i + n) % 2 == 0 {
            b.push_back(a[i]);
        } else {
            b.push_front(a[i]);
        }
    }

    println!(
        "{}",
        b.into_iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}


Measured memory_bytes: 18548
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var M = input[1];
            var A = ReadArrayInt();
            Array.Sort(A);
            Array.Reverse(A);
            var matNum = new int[] { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
            var dp = new int[N + 1];
            for (int i = 1; i <= N; i++)
            {
                dp[i] = int.MinValue;
                for (int j = 0; j < M; j++)
                {
                    if (matNum[A[j]] <= i)
                    {
                        dp[i] = Math.Max(dp[i - matNum[A[j]]] + 1, dp[i]);
                    }
                }
            }
            var rem = N;
            var ans = new int[dp[N]];
            for (int i = 0; i < dp[N]; i++)
            {
                for (int j = 0; j < M; j++)
                {
                    if (matNum[A[j]] <= rem && dp[rem - matNum[A[j]]] == dp[rem] - 1)
                    {
                        ans[i] = A[j];
                        rem -= matNum[A[j]];
                        break;
                    }
                }
            }

            Console.WriteLine(string.Join("", ans));
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s;
	cin>>s;
	reverse(s.begin(),s.end());
	s.push_back('0');
	ll dp[1000010][2];
	for(ll i=0;i<1000010;i++){
		for(ll j=0;j<2;j++){
			dp[i][j]=inf;
		}
	}
	dp[0][0]=0;
	for(ll i=0;i<s.size();i++){
		ll now=s[i]-'0';
		//cout<<now<<endl;
		for(ll j=0;j<2;j++){
			now=now+j;
			for(ll k=0;k<10;k++){
				if(k>=now){
					dp[i+1][0]=min(dp[i+1][0],dp[i][j]+k+k-now);
				}
				else{
					dp[i+1][1]=min(dp[i+1][1],dp[i][j]+k+k-now+10);					
				}
			}
		}
	}
	cout << dp[s.size()][0];
	// your code goes here
	return 0;
}

Measured memory_bytes: 20064
#include <iostream>//
#include <algorithm>
#include <set>

int n;
int a[2020];

using namespace std;

struct tri {
    int a, b, c;

    tri(int aa, int bb, int cc) {
        a = aa;
        b = bb;
        c = cc;
    }
};

bool operator<(tri aa, tri bb) {
    if (aa.c < bb.c)
        return true;
    else if (aa.c == bb.c) {
        if (aa.b < bb.b)
            return true;
        else if (aa.b == bb.b) {
            if (aa.a < bb.a)
                return true;
        }
    }
    return false;
}

set<tri> ss, s2;

int main() {
    int n;
    long long cnt = 0;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    sort(a, a + n);
/*
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            for (int k = j + 1; k < n; ++k) {
                if (a[k] < a[i] + a[j]) {
                    tri t = tri(a[i], a[j], a[k]);
                    ss.insert(t);
                }
            }
        }
    }
*/

    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            for (int k = j + 1; k < n; ++k) {
                if (a[k] < a[i] + a[j]) {
                    ++cnt;
                }
            }
        }
    }

    //cout << ss.size() << endl;
    //cout << s2.size() << endl;
    cout << cnt;

    return 0;
}
// Created by Kevin Weng on 2019/10/28.
//



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

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var N = IO.GetInt();
            var X = IO.GetIntList();
            var sortedX = X.OrderByDescending(x => x).ToList();
            double B = (1.0 * sortedX[N / 2] + sortedX[N / 2 - 1]) / 2;
            for(int i = 0; i < N; i++)
            {
                if (X[i]<=B) { Console.WriteLine(sortedX[N/2-1]); }
                else { Console.WriteLine(sortedX[N/2]); }
            }

            //Console.Write(ans);
        }
    }


    static class IO
    {
        static public string GetString() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> GetStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> GetIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> GetLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteStrings<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
    }
}

Measured memory_bytes: 41032
import java.util.Scanner;

public class Main{

    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        Integer n = Integer.parseInt(scan.next());
        Integer d = Integer.parseInt(scan.next());
 
        int x = n/(2*d+1);
        int mod = n%((2*d+1));

        if(mod == 0)
            System.out.println(n/(2*d+1));
        else
            System.out.println(n/(2*d+1)+1);
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
int main(){
    double r,s,l;
    scanf("%lf",&r);
    s = (double) r*r*3.141592653589;
    l = (double) 2*r*3.141592653589;
    printf("%.6f %.6f\n",s,l);
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        int l, r;
        cin >> l >> r;
        sum += r - l + 1;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <string.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define REP1(i,n) for(int i=1;i<=(n);++i)

#define SORT(V) sort((V).begin(), (V).end())

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<pair<int, int> > VPII;
typedef long long LL;
typedef vector<long long> VL;
typedef pair<long long,long long> PLL;
typedef vector<pair<long long,long long> > VPLL;
int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1};


int H, W;
char M[50][50];
int D[50][50];

int bfs() {
  REP(x, W) {
    REP(y, H) {
      D[x][y] = -1;
    }
  }
  queue<PII> q;
  q.push(MP(0, 0));
  D[0][0] = 1;
  while (!q.empty()) {
    int x = q.front().ST;
    int y = q.front().ND;
    // cerr << x << "," << y << endl;
    if (x == W - 1 && y == H - 1) {
      return D[x][y];
    }
    q.pop();
    REP(i, 4) {
      int nx = x + dx[i];
      int ny = y + dy[i];
      if (0 <= nx && nx < W && 0 <= ny && ny < H) {
        if (D[nx][ny] == -1 && M[nx][ny] == '.') {
          D[nx][ny] = D[x][y] + 1;
          q.push(MP(nx, ny));
        }
      }
    }
  }
  return -1;
}

int main() {
  cin >> H >> W;
  int w = 0;
  REP(y, H) {
    REP(x, W) {
      cin >> M[x][y];
      if (M[x][y] == '.') {
        ++w;
      }
    }
  }
  int m = bfs();
  if (m == -1) {
    cout << -1 << endl;
  } else {
    cout << w - m << endl;
  }
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main(){
  int N;
  cin >> N;
  rep(i, 9){
    if(N % (i+1) == 0 && N / (i+1) <= 9){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }


int main() {
    int n; cin >> n;
    vector<pll> arms;
    rep(i, n){
        ll x, l; cin >> x >> l;
        ll left = x-l, right = x+l;
        arms.emplace_back(right, left);
    }
    sort(all(arms));
    ll res = 0, place = -INF*100;
    rep(i, n){
        ll left = arms[i].second, right = arms[i].first;
        if(left >= place){
            res++;
            place = right;
        }
    }
    cout << res << ln;
}

Measured memory_bytes: 2420
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}

ll d[200010];
ll t[200010];
int main(){
	int n,m;
	scanf("%d",&n);
	rep(i,0,n)scanf("%lld",d+i);
	scanf("%d",&m);
	rep(i,0,m)scanf("%lld",t+i);
	sortup(d,n);
	sortup(t,m);
	int pos=0;
	rep(i,0,m){
		while(pos<n&&d[pos]<t[i])pos++;
		if(d[pos]==t[i])pos++;
		else{
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	
}


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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 100 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;
char a[N][N];
int dp[N][N];

void solve(int testCase){

    scanf("%d %d" , &n , &m);

    for(int i = 1 ; i <= n ; i ++){
            scanf("%s" , a[i] + 1);
    }

    for(int i = 0 ; i < N ; i ++){
            a[i][0] = a[0][i] = '.';
    }

    for(int i = 0 ; i < N ; i ++){
            for(int j = 0 ; j < N ; j ++){
                    dp[i][j] = dp[i][j] = 2e9;
            }
    }
    dp[0][1] = 0;
    dp[1][0] = 0;

    for(int i = 1 ; i <= n ; i ++){
            for(int j = 1 ; j <= m ; j ++){

                    if(a[i][j] == '.'){
                            dp[i][j] = min(dp[i][j-1] , dp[i-1][j]);
                    }
                    else {
                            if(a[i-1][j] == '#'){
                                    dp[i][j] = min(dp[i][j] , dp[i-1][j]);
                            }
                            else {
                                    dp[i][j] = min(dp[i][j] , 1 + dp[i-1][j]);
                            }

                            if(a[i][j-1] == '#'){
                                    dp[i][j] = min(dp[i][j] , dp[i][j-1]);
                            }
                            else {
                                    dp[i][j] = min(dp[i][j] , 1 + dp[i][j-1]);
                            }
                    }
            }
    }

    printf("%d\n" , dp[n][m]);

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 256
# coding:utf-8
n = int(input())
a = list(map(int, input().split()))
ans = 1

if 0 in a:
    print(0)
    exit()

for i in range(n):
    ans = ans * a[i]
    if ans > 10**18:
        print(-1)
        exit()

print(ans)


Measured memory_bytes: 21640
#include<bits/stdc++.h>
using namespace std;
int S,n,tri[20],son[1001000][3],val[1001000][3],cnt,res[1001000];
bool tag[1001000];
void build(int x,int y){
	if(y==n)return;
	for(int i=0;i<3;i++)val[x][i]=i,son[x][i]=++cnt,build(cnt,y+1);
}
void pushdown(int x){
	if(!tag[x])return;
	for(int i=0;i<3;i++){
		tag[son[x][i]]^=1;
		if(val[x][i])val[x][i]^=3;
	}
	tag[x]=0;
}
void Salsa(){
	tag[0]^=1;
}
void Rumba(int x,int y){
	if(y==n)return;
	pushdown(x);
	for(int i=0;i<3;i++){
		val[x][i]++;
		if(val[x][i]==3)val[x][i]=0,Rumba(son[x][i],y+1);
	}
}
void Calc(int x,int y,int z,int w){
	if(y==n){res[z]=w;return;}
	pushdown(x);
	for(int i=0;i<3;i++)Calc(son[x][i],y+1,z+tri[y]*i,w+val[x][i]*tri[y]);
}
char s[1001000];
int main(){
	scanf("%d",&n),build(0,0),tri[0]=1;
	for(int i=1;i<=n;i++)tri[i]=tri[i-1]*3;
	scanf("%s",s),S=strlen(s);
	for(int i=0;i<S;i++)if(s[i]=='S')Salsa();else Rumba(0,0);
	Calc(0,0,0,0);for(int i=0;i<tri[n];i++)printf("%d ",res[i]);
	return 0;
}

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

using namespace std;

#define MAXN 400
#define INF 0x3f3f3f3f
typedef long long LL;

int main()
{
    int a, b, c, d, e, f, ans1 = 0, ans2 = 0, res1, res2;
    int i, j, k, l;
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
    for(i = 0; i * 100 * a <= f; ++i)
        for(j = 0; j * 100 * b + i * 100 * a <= f; ++j)
            for(k = 0; k * c + j * 100 * b + i * 100 * a <= f; ++k)
                for(l = 0; l * d + k * c + j * 100 * b + i * 100 * a <= f; ++l){
                    res1 = l * d + k * c + j * 100 * b + i * 100 * a;
                    res2 = l * d + k * c;
                    if(res2 * 100 > e * (res1 - res2)) continue;
                    if(ans2 * res1 <= ans1 * res2) ans1 = res1, ans2 = res2;
                }
    printf("%d %d\n", ans1, ans2);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#ifdef DEBUG
#define line() cout << "[" << __LINE__ << "] ";
#define dump(i) cout << #i ": " << i << " ";
#define dumpl(i) cout << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int n, q;
    cin >> n >> q;

    string s;
    cin >> s;
    int a[n];
    rep(i, n) a[i] = 0;
    rep(i, 1, n)
    {
        a[i] = a[i - 1];
        if (s[i] == 'C' && s[i - 1] == 'A')
        {
            a[i]++;
        }
    }
    rep(i, q)
    {
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        cout << a[r] - a[l] << endl;
    }
    return 0;
}


Measured memory_bytes: 1408
n, k = map(int,input().split())
p = list(map(int,input().split()))

a = sum(p[0:k])
b = a
c = a

for i in range(n-k):
    b -= p[i]
    b += p[i+k]
    if c < b:
        c = b
        
print((c+k) / 2)

Measured memory_bytes: 25060
#include <iostream>
#include <algorithm>
using namespace std;
int  gcd( int a,int b){
	if (a%b==0){
		return b;
    }
	else{ 
        return gcd(b,a%b);
    }
}
int N;
int a[100010];
int main() { 
    cin>>N;
    for(int i=0;i<N;i++) cin>>a[i];
    //1番小さい数と２番目に小さい数を見つけるためにソート
    sort(a,a+N);
    int min_gcd=a[0];
    int remove_index=0;

    //a[0]とのgcdを取り一番小さくなったindexを書き換えたい
    for(int i=1;i<N;i++){
        int s=gcd(a[0],a[i]);
        if(s<min_gcd) {
            min_gcd=s;
            remove_index=i;
        }
    }

    //1,まずはa[0]を書き換えた時
    int ans1=a[1];
    for(int i=1;i<N;i++){
        ans1=gcd(ans1,a[i]);
    }

    //2,それ以外、つまりa[remove_index]を取り除いた時のgcd
    int ans2=a[0];
    for(int i=0;i<N;i++){
        if(i==remove_index) continue;
        ans2=gcd(ans2,a[i]);
    }

    //1,2の大き方が答え
    cout<<max(ans1,ans2)<<endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
using namespace std;


int main(){
  long long n;
  cin >> n;
  if(n <= 6){
    cout << 1 << endl;
  }else if(n <= 11){
    cout << 2 << endl;
  }else{
    if(n%11 == 0){
      cout << ((n)/11)*2  << endl;

    }else if(n%11 <= 6){
      cout << ((n)/11)*2 +1 << endl;

    }else{
      cout << ((n)/11)*2 + 2 << endl;

    }
  }
  return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=3e5+9;


int main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    string s;
    map<string,int>cnt;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        cnt[s]++;
    }
    cout<<"AC x "<<cnt["AC"]<<'\n';
    cout<<"WA x "<<cnt["WA"]<<'\n';
    cout<<"TLE x "<<cnt["TLE"]<<'\n';
    cout<<"RE x "<<cnt["RE"]<<'\n';



    return 0;
}


Measured memory_bytes: 3664
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265359

using namespace std;

/*ll powMod(ll a, ll y)
{
    ll ans = 1;
    
    while (y > 0) 
    { 
        if (y & 1) 
            ans = (ans*a) % MOD; 
  
        y = y>>1;
        a = (a*a) % MOD; 
    } 
    return ans;
}*/

/*ll modInv(ll a)
{
    return powMod(a, MOD-2);	
}*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    int n = s.length();
    if (s[n-1] == 's') cout << s + "es" << endl;
    else cout << s + "s" << endl;
    return 0;
}




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

using ll = long long;
using P = pair<int, int>;

int main()
{
    int N;
    cin >> N;
    if (N >= 30)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;


int main()
{
	string s;
	cin >> s;
	sort(s.begin(), s.end());

	string t;
	cin >> t;
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());

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

	
	
}

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

int main() {
  
  int N, M;
  cin >> N >> M;
  int sum = 0;
  vector<int> A(M);
  
  for(int i = 0; i < M; i++) {
    cin >> A.at(i);
    
  }
  
  for(int i = 0; i < M; i++) {
    sum += A.at(i);
  }
  
  if(N >= sum) {
    cout << N - sum <<endl;
  }
  
  else{
    cout << "-1" <<endl;
  }
  return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>          // printf(), scanf()

int
extgcd(int a, int b, int* x, int* y)
{
	int d = a;
	if (b != 0)
	{
		d = extgcd(b, a % b, y, x);
		*y -= (a / b) * *x;
	}
	else
	{
		*x = 1;
		*y = 0;
	}

	return d;
}

int
main(int argc, char** argv)
{
	int a, b;
	int x = 0, y = 0;

	scanf("%d %d", &a, &b);
	extgcd(a, b, &x, &y);
	printf("%d %d\n", x, y);
	return 0;
}

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

int main(){
    int A, B, C;
    while(cin>>A>>B>>C){
        int t = 0;
        if(A==B)
            t++;
        if(A==C)
            t++;
        if(B==C)
            t++;
        if(t==1)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}



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

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

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

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

    cout << lcm(n, 360) / n << endl;
    
    return 0;
}

Measured memory_bytes: 3600
n,x=map(int,raw_input().split())
a=map(int,raw_input().split())
ans=float('inf')
b=[[float('inf')]*n for _ in xrange(n)]
for i in xrange(n):
    b[i][0]=a[i]
for i in xrange(n):
    for j in xrange(1,n):
        b[i][j]=min(b[i][j-1],a[(i-j)%n])
for j in xrange(n):
    tmp=0
    for i in xrange(n):
        tmp+=b[i][j]
    ans=min(ans,tmp+j*x)
print(ans)

Measured memory_bytes: 82588
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

void solve()
{
	ll n, m, x;
	cin >> n >> m >> x;
	v64 cost(n, 0);
	vector<v64> A(n, v64(m, 0));
	for (int i = 0; i < n; i++)
	{
		cin >> cost[i];
		for (int j = 0; j < m; j++)
			cin >> A[i][j];
	}
	ll ans = 1e18;
	for (int i = 0; i < (1 << n); i++)
	{
		v64 res(m, 0);
		ll c = 0;
		for (int j = 0; j < n; j++)
		{
			if (i & (1 << j))
			{
				c += cost[j];
				for (int k = 0; k < m; k++)
					res[k] += A[j][k];
			}
		}
		bool flag = true;
		for (int elt : res)
		{
			if (elt < x)
			{
				flag = false;
				break;
			}
		}
		if (flag)
			ans = min(ans, c);
	}
	if (ans == 1e18)
		ans = -1;
	cout << ans << ln;
	return;
}

int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve();
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 3664
#include <stdio.h>

int mysqrt(int n) {
	int left,right;
	long long mid;
	if(n==0)return 0;
	if(n<0)return -1;
	left=1;right=n;
	while(left<=right) {
		mid=(left+right)/2;
		if(mid*mid==n)return mid;
		else if(mid*mid<n)left=mid+1;
		else right=mid-1;
	}
	return left-1;
}

int horieyui(int asumikana) {
	int s = mysqrt(asumikana);
	return s * s == asumikana;
}

int main(void) {
	int N, D;
	int X[16][16];
	int i, j;
	int count = 0;
	if (scanf("%d%d", &N, &D) != 2) return 1;
	for (i = 0; i < N; i++) {
		for (j = 0; j < D; j++) {
			if (scanf("%d", &X[i][j]) != 1) return 1;
		}
	}
	for (i = 0; i < N; i++) {
		for (j = i + 1; j < N; j++) {
			int k;
			int sum = 0;
			for (k = 0; k < D; k++) {
				int delta = X[i][k] - X[j][k];
				sum += delta * delta;
			}
			if (horieyui(sum)) count++;
		}
	}
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 128