akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int l,r,d;
     cin>>l>>r>>d;
     int count =0;
     for(int i=l;i<=r;i++)
     {
         if(i%d==0)
         {
             count++;
         }
     }
cout<<count<<endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())

using namespace std;
typedef pair<int,int> P;

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}


int n,m;
vector<P> vec(10000);
int rec(int x, auto r){
  int t=0;
  r[x] = true;
  bool chk=true;
  REP(i,n+1){
    if (i!=0){
      if (!r[i]){
        chk = false;
      }
    }
  }
  if (chk){return 1;}
  REP(i,m){
    int f = vec.at(i).first;
    int s = vec.at(i).second;
    if (vec.at(i).first == x){
      if (!r[vec.at(i).second]){
        t += rec(vec.at(i).second, r);
      }
    } else if (vec.at(i).second == x){
      if (!r[vec.at(i).first]){
        t += rec(vec.at(i).first, r);
      }
    }
  }
  return t;
}

int main(){
  cin >> n >> m;
  vector<bool> reached(10);
  REP(i,10){
    reached[i] = false;
  }
  REP(i,m){
    cin >> vec.at(i).first >> vec.at(i).second;
  }
  int t = rec(1,reached);
  cout << t << endl;
  return 0;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    int i;
    for (i = 0; i < N; i++){
        string S;
        cin >> S;
        if (S == "Y"){
            cout << "Four" << endl;
            break;
            }
        else if (i == N - 1){
            cout << "Three" << endl;
            }
        else {
            continue;
            }
        }
    }

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main()
{
  bool N = 0, W = 0, S = 0, E = 0;
  string s;
  cin >> s;
  for(int i=0; i<s.size(); i++) {
    if( s[i] == 'N' ) N = 1;
    if( s[i] == 'W' ) W = 1;
    if( s[i] == 'S' ) S = 1;
    if( s[i] == 'E' ) E = 1;
  }
  if( N == S && W == E ) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int i,j,n,a,x,y,z,cnt,flg;
	char s[101],t[101];
	cin>>n>>s>>t;
	a=0;
	x=0;
	y=n;
	cnt=0;
	flg=0;
	for(i=0;i<n;i++){
		for(j=x;j<n;j++){
			if(s[j]==t[a]) cnt=cnt+1;
//			cout<<s[j]<<'|'<<t[a]<<endl;
			a=a+1;
		}
//		cout<<n-x<<'|'<<cnt<<endl;
		if(cnt==n-x){
			flg=1;
//			cout<<n<<cnt<<endl;
			break;
		}
		a=0;
		x=x+1;
		y=y+1;
		cnt=0;
	}
	if(flg==1) cout<<y<<endl;
	else cout<<n*2<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };

        
        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            var input = cin.SplitRead();
            int N = input[0];
            int M = input[1];
            int Q = input[2];
            var map = new long[N, N];
            for(var i = 0; i < N; i++)
            {
                for(var j = 0; j < N; j++)
                {
                    map[i, j] = 0;
                }
            }

            for(var i = 0; i < M; i++)
            {
                var tr = cin.SplitRead();
                map[tr[0] - 1, tr[1] - 1]++;
            }

            var d = new long[N + 1, N + 1];
            for(var i = 0; i <= N; i++)
            {
                d[0, i] = 0;
                d[i, 0] = 0;
            }

            for(var i = 1; i <= N; i++)
            {
                for(var j = 1; j <= N; j++)
                {
                    d[i, j] = d[i - 1, j] + d[i, j - 1] - d[i - 1, j - 1] + map[i - 1, j - 1];
                }
            }

            for(var i = 0; i < Q; i++)
            {
                var p = cin.SplitRead();
                int l = p[0];
                int r = p[1];
                Console.WriteLine(d[r, r] - d[l - 1, r] - d[r, l - 1] + d[l - 1, l - 1]);
            }

            
            //Console.Out.Flush();
        }

    }

   

    

    

    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }
}


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

ll N, K, ans;

int main()
{
	cin >> N >> K;
	vector<ll>a(N), v(N + 1);
	rep(i, N)
	{
		cin >> a[i];
		v[i + 1] = a[i];
	}
	rep(i, N) v[i + 1] = max(v[i + 1], v[i]);
	ans = 112345678901;
	rep(bit, (1ll << N))
	{
		vector<ll>idxs;
		rep(i, N)
		{
			if (bit&(1ll << i)) idxs.push_back(i);
		}
		if (idxs.size() != K) continue;
		ll maxH = 0, res = 0;
		rep(i, K)
		{
			maxH = max(maxH, v[idxs[i]]);
			if (a[idxs[i]] <= maxH)
			{
				++maxH;
				res += maxH - a[idxs[i]];
			}
			else maxH = a[idxs[i]];
		}
		ans = min(ans, res);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;

public class Main
{
  static long y[];
  static int n;
  static int m;
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String sl[];


    sl = r.readLine().split(" ");
    n = Integer.parseInt(sl[0]);
    m = Integer.parseInt(sl[1]);

    Integer v[] = new Integer[n + m];
    y = new long[n + m];

    long a[] = new long[n];
    int b[] = new int[m];
    long c[] = new long[m];

    sl = r.readLine().split(" ");
    for(int i = 0; i < n; i++)
    {
      v[i] = i;
      a[i] = Long.parseLong(sl[i]);
      y[i] = a[i];
    }

    for(int i = 0; i < m; i++)
    {
      sl = r.readLine().split(" ");
      b[i] = Integer.parseInt(sl[0]);
      c[i] = Integer.parseInt(sl[1]);
      v[i + n] = i + n;
      y[i + n] = c[i];
    }

    class Comp implements Comparator<Integer>
    {
      @Override
      public int compare(Integer o1, Integer o2)
      {
        if(y[o1] > y[o2])
          return -1;
        else if(y[o1] < y[o2])
          return 1;
        return 0;
      }
    }

    Arrays.sort(v, new Comp());

    long cc = 0;
    int pp = -1;
    int vv = 0;
    int dd = 0;
    while(dd < n)
    {
      if(vv == 0)
      {
        pp++;
        if(v[pp] < n)
        {
          vv = 1;
        }
        else
        {
          vv = b[v[pp] - n];
        }
      }
      
      dd++;
      vv--;
      cc += y[v[pp]];
    }
    
    System.out.println(cc);
    
  }

}

Measured memory_bytes: 99240
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
from collections import defaultdict

num  = S()
for i in range(3):
    if num[i] == num[i+1]:
        print("Bad")
        break
else:
    print("Good")

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

using namespace std;

int main(){
    int N, K;
    while(cin >> N >> K){
        vector<int> A(N), B(N);
        for(int i=0;i<N;i++) cin >> A[i] >> B[i];
        long long res = 0;
        for(int i=0;i<N;i++){
            if((K&A[i]) == A[i]) res += B[i];
        }
        while(K){
            int curK = K;
            --K;
            long long sum = 0;
            for(int i=0;i<N;i++){
                if((K&A[i]) == A[i]) sum += B[i];
            }
            res = max(res, sum);
            K &= curK;
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author KY2001
 */


#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int bpm(int x, int y) {
  if (x == 0)
    return 0;
  else if (y == 0) {
    return 1;
  }
  int ans = 1;
  x %= MOD;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) {
      ans *= x;
      ans %= MOD;
    }
    x = x * x;
    x %= MOD;
  }
  return ans;
}

class CGridRepainting2 {
public:
  int solve(std::istream &cin, std::ostream &cout) {
    int H, W;
    cin >> H >> W;
    vector<string> s(H + 2);
    s[0] = string(W + 2, '.');
    rep(i, H) {
      string temp;
      cin >> temp;
      string temp2 = ".";
      temp2 += temp + ".";
      s[i + 1] = temp2;
    }
    s[H + 1] = string(W + 2, '.');
    FOR(i, 1, H + 1) {
      FOR(j, 1, W + 1) {
        if (s[i][j] == '#') {
          if (s[i + 1][j] == '.' && s[i - 1][j] == '.' && s[i][j + 1] == '.' && s[i][j - 1] == '.') {
            cout << "No" << endl;
            return 0;
          }
        }
      }
    }
    cout << "Yes" << endl;
  }
};


signed main() {
	CGridRepainting2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
static const long long INF = 1LL<<59;
static const long long MOD = (ll)1e9+7;

#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i, n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)((v).size())
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).begin(), (v).end())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}

void solve() {
    ll A, B;
    cin >> A >> B;
    if(A >= 13) {
        out(B);
    }else if (A >= 6 && A < 13) {
        out(B/2);
    }else {
        out(0);
    }
}

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

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int prime[10000];
int p[10000];
int c[10000];
int main() {
	for (int i = 2; i*i < 10000; i++) {
		for (int j = i*i; j < 10000; j += i) prime[j] = 1;
	}
	int cnt = 0;
	for (int i = 2; i < 10000; i++) {
		if (prime[i] == 0) {
			p[cnt] = i; cnt++;
		}
	}
	int n, q, z = 0;
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%d", &n); bool OK = true;
		for (int j = 0; j < cnt; j++) {
			if (n < p[j]*p[j])break;
			if (n%p[j] == 0)OK = false;
		}
		if (OK == true)z++;
	}
	printf("%d\n", z);
	return 0;
}

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

int main() {
  int N,i,j=0;
  cin>>N;
  string op;
  for(i=0;i<N;i++){
    cin>>op;
    if(op=="Y"){
      j++;
      break;
    }
  }
  if(j)cout<<"Four"<<endl;
  else cout<<"Three"<<endl;
}

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

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

    int ans = 0;
    for( int i = 0; i < N; i++ ){
        for( int j = 0; j < N; j++ ){
            ans += D[i]*D[j];
        }
    }
    for( int i = 0; i < N; i++ ){
        ans -= D[i]*D[i];
    }
        ans /= 2;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N,A,B;
    cin >> N >> A >> B;
    cout << min(N*A,B);
    return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int dx[8] = {-1, 0, 1, 0, -1, -1, 1, 1};
int dy[8] = {0, -1, 0, 1, -1, 1, -1, 1};

int main() {
  int w, last = 4280;
  
  while(cin >> w, w != -1) {
    int money = 1150;  
    if(w > 30) {
      money += 160 * (w-30);
      w = 30;
    }
    if(w > 20) {
      money += 140 * (w-20);
      w = 20;
    }
    if(w > 10)  money += 125 * (w-10);

    cout << last - money << endl;
  }
}

Measured memory_bytes: 1160
#include<stdio.h>

signed main()
{
  int h,w;
  scanf("%d %d", &h, &w);

  char c[200][200];
  for ( int i = 0; i < h; ++i ) {
    scanf("%s",c[i]);
  }

  for ( int i = 0; i < h; ++i ) {
    printf("%s\n%s\n", c[i], c[i]);
  }

  return 0;
}

Measured memory_bytes: 256
class SegTree:
    """ define what you want to do with 0 index, ex) size = tree_size, func = min or max, sta = default_value """
    
    def __init__(self,size,func,sta):
        self.n = size
        self.size = 1 << size.bit_length()
        self.func = func
        self.sta = sta
        self.tree = [sta]*(2*self.size)

    def build(self, list):
        """ set list and update tree"""
        for i,x in enumerate(list,self.size):
            self.tree[i] = x

        for i in range(self.size-1,0,-1):
            self.tree[i] = self.func(self.tree[i<<1],self.tree[i<<1 | 1])

    def set(self,i,x):
        i += self.size
        self.tree[i] = x
        while i > 1:
            i >>= 1
            self.tree[i] = self.func(self.tree[i<<1],self.tree[i<<1 | 1])

    
    def get(self,l,r):
        """ take the value of [l r) with func (min or max)"""
        l += self.size
        r += self.size
        res = self.sta

        while l < r:
            if l & 1:
                res = self.func(self.tree[l],res)
                l += 1
            if r & 1:
                res = self.func(self.tree[r-1],res)
            l >>= 1
            r >>= 1
        return res

    def max_right(self, l, x):
        """[l,r) が ok であるような最大の r を返す"""
        if l == self.n:
            return l
        l += self.size
        res = self.sta
        check = True
        while check or (l & -l) != l:
            check = False
            while l%2 == 0:
                l >>= 1
            if not self.func(res,self.tree[l]) < x:
                while l < self.size:
                    l <<= 1
                    if self.func(res,self.tree[l]) < x:
                        res = self.func(res,self.tree[l])
                        l += 1
                return l - self.size
            res = self.func(res,self.tree[l])
            l += 1
        return self.n

    def min_left(self, r, x):
        """(r が ok であるような最小の r を返す"""
        if r == 0:
            return 0
        r += self.size
        res = self.sta
        check = True
        while check and (r & -r) != r:
            check = False
            r -= 1
            while (r > 1 and r%2):
                r >>= 1
            if not self.func(res, self.tree[r]) < x:
                while r < self.size:
                    r = 2*r + 1
                    if self.func(res, self.tree[r]) < x:
                        res = self.func(res, self.tree[r])
                        r -= 1
                return r + 1 - self.size
            res = self.func(self.tree[r],res)
        return 0

n,q = map(int,input().split())
a = list(map(int,input().split()))

seg = SegTree(n,max,-1)
seg.build(a)
for _ in range(q):
    t,x,v = map(int,input().split())
    if t == 1:
        seg.set(x-1,v)
    elif t == 2:
        print(seg.get(x-1,v))
    else:
        print(seg.max_right(x-1,v)+1)

Measured memory_bytes: 31388
#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

// read to vector
// for example M_RTV(as, int, n) expands to the below:
// ```
// vector<int> as(n);
// for(int lcnt = 0; lcnt < n; lcnt++) cin >> as[lcnt];
// ```
#define M_RTV(ident, type, cnt) \
    vector<type> ident(cnt);\
    do {\
        for(int lcnt = 0; lcnt < cnt; lcnt++) cin >> ident[lcnt];\
    } while(false)

// shorthand for range
#define M_RG(ident) ident.begin(), ident.end()

// https://qiita.com/EqualL2/items/b4683db7ab4e90545bb2
int ctoi(const char c){
    return (c-'0');
}

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

    int uresity = 0;
    uresity += 1000 * (x/500);
    x %= 500;
    uresity += 5 * (x/5);

    cout << uresity << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<vector>
#include<algorithm>

using namespace std;
const int INF = INT_MAX;

int n;		//配列の長さ
vector<int> a;		//a：入力される配列

//LISの長さを返す
int LIS() {
	vector<int> dp;		//dp[i]：長さiの単調増加な部分列の中でi番目の要素としてありうるものの最小値
	dp.assign(n, INF);     //dpをINFで初期化
	for (int i = 0; i < n; i++)*lower_bound(dp.begin(), dp.end(), a[i]) = a[i];		//配列を前から順番に見ていき、要素を更新していく（二分探索）
	return lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
}

int main() {
	cin >> n;
	a.assign(n, 0);
	for (int i = 0; i < n; i++)cin >> a[i];
	cout << LIS() << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int n;

int main() {
    cin >> n;
     vector<int> A(n, 0);
     for(int i = 0; i < n; ++i) cin >> A.at(i);

     bool flg = true;
     for(int i = 0; i < n; ++i) {
         if(A.at(i) % 2 == 0) {
             if(A.at(i) % 3 != 0 && A.at(i) % 5 != 0) {
                 flg = false;
                 break;
             }
         }
     }

     if(flg) cout << "APPROVED" << endl;
     else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc119/tasks/abc119_c
//2019-02-24
#include <bits/stdc++.h>
using namespace std;

int main(){
    int N, A, B, C;
    cin >> N >> A >> B >> C;

    vector<int> l(N);
    for (int i = 0; i < N; i++) {
        cin >> l.at(i);
    }
  

    int ans = 1000000007;
    int A_hon = 0, B_hon = 0, C_hon = 0;
    int A_zai = 0, B_zai = 0, C_zai = 0;

    for(int i = 0; i < (1 << 2*N); i++){
        A_hon = 0, B_hon = 0, C_hon = 0;
        A_zai = 0, B_zai = 0, C_zai = 0;
        for(int k = 0; k < N; k++){
            if((i & (1 << 2*k)) && (i & (1 << 2*k+1))){
                C_hon++;
                C_zai += l.at(k);
            } else if((i & (1 << 2*k+1))){
                B_hon++;
                B_zai += l.at(k);
            } else if((i & (1 << 2*k))){
                A_hon++;
                A_zai += l.at(k);
            }
        }
        if(A_hon * B_hon * C_hon > 0)
            ans = min(ans,10*(A_hon - 1)+ abs(A_zai - A)+10*(B_hon - 1)+ abs(B_zai - B)+ 10*(C_hon - 1)+ abs(C_zai - C));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next()),b=Integer.parseInt(sc.next());
        if(a<b){
            int tmp = a;
            a = b;
            b = tmp;
        }
        long tmpA = a,tmpB = b,tmp=0;
        while((tmp=tmpA%tmpB)!=0){
            tmpA = tmpB;
            tmpB = tmp;
        }
        long ans = (a/tmpB)*b;
        System.out.println(ans);
    }
}

Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int N;
	cin >> N;
	vl A(N);
	rep(i, N)
		cin >> A[i];
	sort(A.begin(), A.end(), greater<ll>());
	multiset<ll> Aset;
	ll ans = 0;
	rep(i, N)
		Aset.insert(A[i]);
	rep(i, N) {
		if (Aset.find(A[i]) == Aset.end())
			continue;
		Aset.erase(Aset.find(A[i]));
		ll Asum = 1;
		while (1) {
			if (A[i] < Asum)
				break;
			Asum *= 2LL;
		}
		ll Asub = Asum - A[i];
		if (Aset.find(Asub) != Aset.end()) {
			Aset.erase(Aset.find(Asub));
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11136
#include <stdio.h>

int main(void)
{
	unsigned long  n, i;
	unsigned long p = 1;
	unsigned long s = 1;
	scanf("%lu", &n);

	for (i = 1; i <= 9; i++)
		s = s * 10;
	s = (s + 7);

	for (i = 1; i <= n; i++)
	p = ((p * i) % s);

	printf("%lu", p);

	return 0;
}

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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

int main()
{
    // Fast_IO();
    ll n; cin >> n;
    ll a[n]; f(i,0,n-1) cin >> a[i];
    bool zero = false;
    f(i,0,n-1) if(a[i] == 0) zero = true;
    if(zero) {
    	cout << 0 << endl;
    	return 0;
    }
    ll ans = 1;
    bool exceed = false;
    f(i,0,n-1) {
    	double check = log10(ans) + log10(a[i]);
    	if(check > 18.1) {
    		exceed = true;
    		break;
    	}
    	ans *= a[i];
    	if(ans > 1000000000000000000) {
    		exceed = true;
    		break;
    	}
    }
    if(exceed) cout << -1;
    else cout << ans;
    return 0;
}

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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) (1 + (int)((a) - 1)/(int)(b))
#define int long long

signed main(){
    int x, a, b;
    cin >> x >> a >> b;
    cout << (x-a) % b << endl;
}

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

#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
#define FOR_ITER(x, a) for(auto x = a.begin(); x != a.end(); ++x)



using namespace std;
typedef unsigned char byte;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<ll, ll> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }

using namespace std;


int main(){
//    int n, l;
//    cin >> n >> k;
//    vector<bool> dislike(10, false);
//
//    FOR(i, 0, k) {
//        int t;
//        cin >> t;
//        dislike[t] = true;
//    }




int a, b;
cin >>a>>b;
a=(a+11)%13;
b=(b+11)%13;


if(a>b){
    cout << "Alice"<< endl;
}else if(a<b) {
cout << "Bob"<< endl;
}else {
cout << "Draw"<< endl;
}

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  queue<pair<string, int> > queue;
  for(int i=0;i < n;i++){
    string name; int time;
    cin >> name >> time;
    queue.push(make_pair(name,time));
  }
  int now = 0;
  while(!queue.empty()){
    if(queue.front().second <= q){
      now += queue.front().second;
      cout << queue.front().first << " " << now << endl;
      queue.pop();
    }else{
      queue.push(make_pair(queue.front().first, queue.front().second-q));
      now += q;
      queue.pop();
    }
  }
	return 0;
}

Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  V c(n, 0), s(n, 0), f(n, 0);
  REP(i, n-1) {
    cin >> c[i] >> s[i] >> f[i];
  }
  int t;
  REP(i, n-1) {
    t = 0;
    for (int j = i; j < n-1; j++) {
      if (t < s[j]) {
	t = s[j];
      }
      while (t%f[j] != 0) {
	t++;
      }
      t += c[j];
    }
    dump(t);
  }
  dump(0);
  return 0;
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
ll dp[110][11]={};
void bits (ll a,ll fix){
  string s="";
  while(a>0){
    char c='0'+a%2;
    a/=2;
    s+=c;
  }
  for(int i=s.size();i<fix;i++)
    s+='0';
  reverse(s.begin(),s.end());
  cout<<s<<endl;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll h,w,k;cin>>h>>w>>k;
  dp[0][0]=1;
  if(w==1){cout<<1<<endl;return 0;}
  for(int i=0;i<h;i++){
    for(int j=0;j<(1<<(w-1));j++){
      bool flag=true;
      for(int ii=1;ii<w-1;ii++){
	if( ((j&(1<<ii))&&(j&(1<<(ii-1)))) || ((j&(1<<ii))&&(j&(1<<(ii+1)))))
	  flag=false;
      }
      //if(w==3){
      //if(j==3)flag=false;
      //}
      if(flag){
	//bits(j,8);
	for(int ii=0;ii<w-1;ii++){
	  if((j&(1<<ii))){
	    dp[i+1][ii+1]+=dp[i][ii];
	    dp[i+1][ii+1]%=MOD;
	    dp[i+1][ii]+=dp[i][ii+1];
	    dp[i+1][ii]%=MOD;
	    ii++;
	  }else{
	    dp[i+1][ii]+=dp[i][ii];
	    dp[i+1][ii]%=MOD;
	  }
	}
	if(!(j&(1<<(w-2)))){
	  dp[i+1][w-1]+=dp[i][w-1];
	  dp[i+1][w-1]%=MOD;
	}
      }
    }
  }
  // for(int i=0;i<k;i++)cout<<dp[h][i]<<endl;
  cout<<dp[h][k-1]<<endl;
  return 0;
}


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

{
    int a,b,f;
    cin>>a>>b;
    f=a;
    if(a>b)
    {
        a=b;
        b=f;
    }
    if(a==1&&b==2)
        cout<<"3"<<endl;
    else if(a==1&&b==3)
        cout<<"2"<<endl;
    else
        cout<<"1"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
typedef long long ll;
using namespace std;

int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
    int p=0;
	// ユークリッドの方法
	while( m > n )
	{
        m = m/2;
        p+=1;
	}
	return p;
}
void count(ll x, ll y, ll b[200001][200001],ll a[200001])
{
    int j;
     
}
int main()
{
    int i,n,a[100],b[100],c[100],ans=0;
  	cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    for(i=0;i<n;i++){
        cin >> b[i];
    }
    for(i=0;i<n-1;i++){
        cin >> c[i];
    }
    for(i=0;i<n;i++){
        ans += b[a[i]-1];
        if(a[i] == a[i-1]+1){
            ans += c[a[i-1]-1];
        }
    }
          cout << ans;
}

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

namespace AtCoderMake.ABC167
{
    class ABC167D
    {
        static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split().Select((x) => long.Parse(x)).ToArray();
            var a = Console.ReadLine().Split().Select((x) => int.Parse(x)-1).ToArray();
            Dictionary<int, int> teledic = new Dictionary<int, int>();
            int ordinal = 0;
            int nextT = 0;
            int start = 0;
            int T = 0;
            int res = 0;
            while (1==1)
            {
                if (teledic.ContainsKey(nextT) == false)
                {
                    teledic.Add(nextT, ordinal);
                }
                else
                {
                    start = teledic[nextT];
                    T = ordinal - start;
                    break;
                }
                ordinal++;
                nextT = a[nextT];
            }
            if (nk[1] < start)
            {
                res = teledic.Keys.ToArray()[nk[1]];
            }
            else
            {
                var loopdic = new int[T];
                Array.Copy(teledic.Keys.ToArray(), start, loopdic, 0, T);
                res = loopdic[(nk[1] - start) % T];
            }
            Console.WriteLine(res+1);
        }
    }
}


Measured memory_bytes: 52624
n=int(input())
h=list(map(int,input().split()))
for i in range(1,n):
	if h[i-1]-h[i]<=-1:
		h[i]-=1
	elif h[i-1]-h[i]==0:
		pass
	else:
		print("No")
		break
else:
	print("Yes")
	# print(h)





Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];

	ll mini = LINF, maxi = 0LL;
	for(ll i : a){
		mini = min(mini, i);
		maxi = max(maxi, i);
	}
	if(maxi- mini >= 2){
		puts("No");
		return 0;
	}else if(maxi == mini){
		if(maxi == n-1 || maxi <= n/2) puts("Yes");
		else puts("No");
		return 0;
	}

	ll cntMin = 0, cntMax = 0;
	for(ll i : a){
		if(i == mini) cntMin++;
		else cntMax++;
	}
	if(maxi >= cntMin+1 && maxi <= cntMin+cntMax/2) puts("Yes");
	else puts("No");

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int a, b;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b;
	a *= b;
	if(a % 2) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))

pre = 0
count = 0
for i in range(N):
  if(H[i] > pre):
    count += H[i] - pre
  pre = H[i]
print(count)
###例題からの答えの規則性見つけたタイプの解法

Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;    

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))    
#define OUT(P) cout << (P) << endl    
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl    
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;    
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)    
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)    
typedef long long ll;    

int sum_digits(int num);    
template <class T>    
vector<T> copy_vector(vector<T> vec);    
int gcd(int a, int b);    

int main() {    
    int r, d;
    vector<int>xs(11, 0);
    cin >> r >> d >> xs[0];
    

    for(int i=1; i<11; i++) {
        xs[i] = r * xs[i-1] - d;
    }
    for(int i=1; i<11; i++) {
        cout << xs[i] << endl;
    }
    return 0;
}    

/******************************/    
/***** DECRARED FUNCTIONS *****/    
/******************************/    

int sum_digits(int num) {    
    int rtn = 0;    
    while(num != 0) {    
        int tmp = num % 10;    
        rtn += tmp;    
        num /= 10;    
    }    
    return rtn;    
}    

// vectorのコピー    
template <class T>    
vector<T> copy_vector(vector<T> vec) {    
    vector<T> rtn;    
    rtn.reserve(vec.size());    
    copy(vec.begin(), vec.end(), back_inserter(rtn));    
    return rtn;    
}    

// ユークリウッドの互除法    
int gcd(int a, int b) {    
    if(b==0) return a;    
    else return gcd(b, a % b);    
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
#define All(a) (a).begin(),(a).end()
#define RAll(a) (a).rbegin(),(a).rend()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数


//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}



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

	int n, m;
	cin >> n >> m;
	vector<int> a = vector<int>(n);

	int sum = 0;
	REP(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	sort(RAll(a));

	REP(i, m) {
		if (a[i] < (sum + 4*m-1) / (4 * m)) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
option = int(input())
ref_t, tmp_id = (int(n) for n in input().split())
height = list((int(n) for n in input().split()))

ave_t = []
for i in range(option):
  ave_t.append(abs(tmp_id - (ref_t - height[i] * 0.006)))

print(ave_t.index(min(ave_t)) + 1)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;

#define SZ(v) int(v.size())
#define ALL(v) begin(v), end(v)

using i64 = int64_t;
using II = std::pair<int, int>;

#ifdef DEBUG
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int N; cin >> N;
    vector<int> A(N);
    for (auto &a : A) cin >> a;
    
    int exor = 0;
    for (auto &a : A) exor ^= a;

    for (auto &a : A) cout << (exor ^ a) << ' ';
    cout << '\n';
}



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

ll val[200010];
ll res[200010];

vector<vector<ll>> edge;

void saiki(int p, int now, int v){
    res[now] = v + val[now];
    for (auto e : edge[now]) {
        if(e==p)continue;
        saiki(now, e, v + val[now]);
    }
}

int main() {
    ll n,q;
    std::cin >> n>>q;
    for (int i = 0; i < n; i++) {
        val[i] = 0;
        res[i] = 0;
        edge.push_back({});
    }
    
    for (int i = 0; i < n-1; i++) {
        ll a,b;
        std::cin >> a>>b;
        a--;b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    for (int i = 0; i < q; i++) {
        ll p,x;
        std::cin >> p>>x;
        p--;
        val[p] += x;
    }
    saiki(-1,0,0);
    for (int i = 0; i < n-1; i++) {
        std::cout << res[i]<<" ";
    }
    std::cout << res[n-1] << std::endl;
}


Measured memory_bytes: 30060
$N = gets.chomp.to_i
while $N > 0 do
  arr = []
  gets.split(' ').each do |value|
    arr.push(value.to_i)
  end
  arr.sort!
  if (arr[0] ** 2 + arr[1] ** 2) == arr[2] ** 2
    puts 'YES'
  else
    puts 'NO'
  end
  $N -= 1
end

Measured memory_bytes: 6112
import numpy as np

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

s = np.zeros(ww+1, dtype=np.int64)
for i in range(n):
    w, v = map(int, input().split())
    s[w:] = np.maximum(s[w:], s[:-w] + v)

print(s[ww])

Measured memory_bytes: 17952
import java.util.*

object MainKt {
	@JvmStatic
	fun main(args: Array<String>) {
		val scanner = Scanner(System.`in`)
		val n = scanner.nextInt()
		var ws = IntArray(n)
		var sum = 0
		for (i in 0..n-1) {
			ws[i]=scanner.nextInt()
			sum+=ws[i]
		}
		var s1 = 0
		var d = Integer.MAX_VALUE
		for (i in 0..n-1){
			s1+=ws[i]
			if (s1<=sum/2){
				d = sum-(2*s1)
			}else {
				d = Math.min(d,2*s1-sum)
				break
			}
		}
		println(d)
	}
}

Measured memory_bytes: 29732
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
#define testing 1
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto it : v) cerr << it << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto it : v) cerr << "{"  << it.f << ',' << it.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9+500
#define oo (ll)1e18+500
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
template <typename T> void chmax(T& a, T b) {
	a = max(a, b);
}
template <typename T> void chmin(T& a, T b) {
	a = min(a, b);
}
#define MAXN
#if !testing
#define cerr if(0)cout
#endif
ll A[100005];
int32_t main() {
	IAMSPEED
	ll n,k; cin >> n >> k;
	FOR(i,1,n) {
		cin >> A[i];
	}
	ll ans = oo;
	FOR(i,1,n) {
		if(i+k-1 > n) break;
		chmin(ans, llabs(A[i]) + llabs(A[i+k-1]-A[i]));
		chmin(ans, llabs(A[i+k-1]) + llabs(A[i+k-1] - A[i]));
	}
	cout<<ans;
}


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

int main() {
  int n;
  string s;
  
  cin >> n >> s;
  
  if(n % 2 != 0){
    cout << "No" << endl;
  } else {
    n /= 2;
    bool a = true;
    
    for(int i=0;i<n;i++){
      if(s[i] != s[i+n]) a = false;
    }
    
    if (a == true) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long int
#define rp
#define pi 	3.14159265358979323846
#define M 1000000
/*
was buried because of depression
     now time to rise up
        music is life
*/

//bruteforce to check prime
/*bool checkprime(ll j)
{
    if(j<=1)
        return false;
    else if(j==2)
        return true;
    else if(j%2==0)
        return false;
    else
    {
        bool prime=true;
        int divisor=3;
        int upperlimit=sqrt(j)+1;
        while(divisor<=upperlimit)
        {
            if(j%divisor==0)
                return false;
            divisor+=2;
        }
        return prime;
    }
}*/
/*int main()
{
    int n,a,i,c=0;
    vector<int>v;
    cin>>n;
    while(n--)
    {
        cin>>a;
        v.pb(a);

    }
    sort(v.begin(),v.end());
    int min=v[0];
    int max=v[n-1];
    for(i=0; i<v.size(); i++)
    {

        if(v[i]>min && v[i]<max)
            c++;

    }
    cout<<c<<endl;

    return 0;
}*/
/*bool prime[M];
bool isprime(ll n)
{
    if(n<2)return false;
    if(n==2)return true;
    if(n%2==0)return false;
    return prime[n]==false;
}
bool seive(ll n)
{
    for(int i=3;i*i<=n;i+=2)
    {
        if(prime[i]==false)
        {
            for(int j=i*i;j<=n;j+=i)
                prime[j]=true;
        }

    }
}*/

int main()
{
int n;
cin>>n;
cout<<n*n<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
int main(){
long long n;cin>>n;long long a[n];long long minint=99999999,minval=0,minval2=0,sum=0;
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n;i++)
{     minint=min(minint,a[i]);
    if(a[i]==minint) sum++;
}
cout<<sum<<endl;
return 0;
}


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

using namespace std;

char decode(char c, int n) {
  if ('a' <= c && c <= 'z') {
    if (c - 'a' >= n) 
      return c-n;
    else 
      return decode('Z', n-(c-'a'+1));
  }
  if ('A' <= c && c <= 'Z') {
    if (c - 'A' >= n)
      return c-n;
    else
      return decode('z', n-(c-'A'+1));
  }
}

int main() {
  int len;
  while(cin >> len, len) {
    int list[len];
    for(int i=0; i<len; i++)
      cin >> list[i];
    string s;
    cin >> s;
    for(int i=0; i<s.size(); i++)
      s[i] = decode(s[i],list[i%len]);
    cout << s << endl;
  }
}

Measured memory_bytes: 1208
import sys
sys.setrecursionlimit(10**6)

N,K = map(int,input().split())
list = list(map(int,input().split()))

ans = 1

def dfs(N):
    global ans
    if N <= 0:
        return ans
    ans += 1
    return dfs(N-(K -1))

print(dfs(N-K))

Measured memory_bytes: 49688
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdlib>  
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
using namespace std;

int main(){
  string s;
  cin >> s;
  int n = s.size();
  
  int xCount=0;
  for(int i = 0; i<n; i++){
    if(s.substr(i,1)=="x"){
      xCount++;
    }
  }
  if(xCount>7){
    cout<<"NO";
  }else{
    cout<<"YES";
  }
    
}

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;


int main(){
  int N;
  cin >> N;
  int max_X, min_X, max_Y, min_Y;
  max_X = 0;
  min_X = 2000000000;
  max_Y = -1000000000;
  min_Y = 1000000000;
  
  int x,y;
  for(int i = 0; i<N; i++){
    cin >> x >> y;
    max_X = max(max_X, x+y);
    min_X = min(min_X, x+y);
    max_Y = max(max_Y, x-y);
    min_Y = min(min_Y, x-y);
  }
  
  cout << max(max_X-min_X, max_Y-min_Y);
  
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const int MAX = 3e5 + 1;

int H, W, M, vsum[MAX], hsum[MAX];
map<pair<int, int>, int> m;

void build() {
	scanf("%d %d %d", &H, &W, &M);
	for (int i = 0; i < M; i++) {
		int h, w;
		scanf("%d %d", &h, &w);
		hsum[h]++, vsum[w]++;
		m[{h, w}] = 1;
	}
}

void solve() {
	int hi = max_element(hsum + 1, hsum + H + 1) - hsum;
	int vi = max_element(vsum + 1, vsum + W + 1) - vsum;

	int ans = -1;
	for (int i = 1; i <= W; i++)
		ans = max(ans, hsum[hi] + vsum[i] - m[{hi, i}]);
	for (int i = 1; i <= H; i++)
		ans = max(ans, hsum[i] + vsum[vi] - m[{i, vi}]);

	printf("%d", ans);
}

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

Measured memory_bytes: 62368
#include <stdio.h>

int main(void){
   int a,b,i,n;
   scanf("%d%d",&a,&b);
   char str[a+b];
   scanf("%s",str);


   for(i=0;i<a;i++)
      if((str[i]<'0')||(str[i]>'9')){printf("No\n");return 0;}

   if(str[i]!='-'){printf("No\n");return 0;}

   for(i+=1;i<a+b;i++);
      if((str[i]<'0')||(str[i]>'9')){printf("No\n");return 0;}


   printf("Yes\n");
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;

int main(void) {
	int M;
	cin >> M;
	for (int mi = 0; mi < M; mi++) {
		long long moneyInit;
		int nen;
		int typeNum;
		cin >> moneyInit >> nen >> typeNum;

		long long maxMoney = moneyInit;
		for (int ti = 0; ti < typeNum; ti++) {
			bool isHukuri;
			double rate;
			long handling;
			cin >> isHukuri >> rate >> handling;

			long long money = moneyInit;
			long long interest = 0;
			for (int ni = 0; ni < nen; ni++) {
				if (isHukuri) {
					money += money * rate;
					money -= handling;
				}else {
					interest += money * rate;
					money -= handling;
				}
			}

			maxMoney = max(maxMoney, money + interest);
		}

		cout << maxMoney << endl;
	}

	return 0;
}

Measured memory_bytes: 1232