akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>  
#include<cmath>  
#include<iostream>  
#include<cstring>  
#include<iostream>  
#include<cstdlib>  
#include<string>  
using namespace std;  
#define LL long long   
const int MaxN = 1e5 + 7;  
LL a[MaxN], b[MaxN];    
LL x[MaxN], v[MaxN];  
  
int main()  
{  
    LL n, c;  
    scanf("%lld %lld", &n, &c);  
    for(int i = 1; i <= n; i++)   
        scanf("%lld %lld", &x[i], &v[i]);  
      
    for(LL i = 1; i <= n; i++)   
        a[i] = a[i - 1] + v[i] - (x[i] - x[i - 1]);  // 顺时针走到i点时的能量  
    x[n + 1] = c;  
    for(LL i = n; i >= 1; i--)   
        b[i] = b[i + 1] + v[i] - (x[i+1] - x[i]);  // 逆时针走到i点时的能量  
  
    for(LL i = 2; i <= n; i++)   
        a[i] = max(a[i-1], a[i]);  //走或者不走（和走之前的值进行比较）  
    for(LL i = n-1; i >= 1; i--)   
        b[i] = max(b[i], b[i + 1]);  
    //注意a[i],b[i]含义的变化 
    LL ans = 0;  
    for(LL i = 1; i <= n; i++) {  
        ans = max(ans, a[i] - x[i] + b[i + 1]);  // 顺时针走后并返回一次的值  
        ans = max(ans, b[i] - (c - x[i]) + a[i - 1]);  // 逆时针走后返回一次的值  
        ans = max(ans, a[i]);  // 顺时针的最大值  
        ans = max(ans, b[i]); //逆时针的最大值  
    }  
  
    printf("%lld\n", ans);  
} 
/*
题目大意： 一个圈上有寿司，走的路程长度为消耗的能量，吃的的寿司为得到的能量，问最多获得能量是多少。

分析：

人走的方式有四种方式；

1、顺时针走，得到最大值

2、逆时针走，得到最大值

3、先顺时针，再返回起点，再逆时针

4、先逆时针，再返回起点，再顺时针

人为了得到最大能量，最多返回一次

首先计算出顺时针走到每个点的值a[i], 再计算出逆时针的每个点最终的能量值b[i]。 

若有返回，如顺时针则为a[i] - x[i] (回到起点消耗下x[i]) , 然后加上逆时针走到b[i + 1]的值。即a[i] - x[i] + b[i + 1];

然后四种情况进行一次比较*/

Measured memory_bytes: 3328
#include<stdio.h>

int main()
{
	int a,b;
	scanf("%d%d\n",&a,&b);
	if(a < b)
	printf("a < b\n");
	if(a > b)
	printf("a > b\n");
	if(a == b)
	printf("a == b\n");
	return 0;
}


Measured memory_bytes: 2128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
const int N = 12, M = 1001;
long long INF = 1LL << 60;
vector<long long> dp(1 << N, INF);
int cost[M];
int key[M];
int n, m;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //e
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> cost[i];
    int b;
    cin >> b;
    int x = 0;
    for (int j = 0; j < b; j++) {
      int c;
      cin >> c;
      x |= (1 << (c - 1));
    }
    key[i] = x;
  }
  dp[0] = 0;
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 0; j < m; j++) {
      dp[i | key[j]] = min(dp[i | key[j]], dp[i] + cost[j]);
    }
  }
  cout << (dp[(1 << n) - 1] == INF ? -1 : dp[(1 << n) - 1]) << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define m 1000000007
using namespace std;
int main() {
    ll n;cin>>n;
    vector<ll>a(n);
    ll c=0,t=0;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        t+=a[i];
        // t=(t%m+a[i]%m)%m;
    }
    // cout<<t<<endl;
    for(ll i=0;i<n;i++)
    {
        t=t-a[i];
        // c+=a[i]*t;
        c=((c%m)+((a[i]%m)*(t%m))%m)%m;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 4832
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>
#include <queue>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, 0, n)cin >> a[i];
	bool can = false;
	list<ll> b;
	rep(i, 0, n) {
		if (can) {
			b.push_front(a[i]);
			can = false;
		}
		else {
			b.push_back(a[i]);
			can = true;
		}
	}
	if (n % 2) {
		for (auto i = b.rbegin();i != b.rend();i++) {
			cout << *i << " ";
		}
	}
	else {
		for (auto i : b) {
			cout << i << " ";
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 9984
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
    int n,a,b;
    cin >> n >> a >> b;
    vector<int> array(3,0);
    int temp,i;
    for(i = 0;i <n;++i){
        cin >> temp;
        if(temp <= a){
            ++array.at(0);
        }else if(temp <= b){
            ++array.at(1);
        }else{
            ++array.at(2);
        }
    }
    sort(array.begin(),array.end());
    cout << array.at(0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

void Solve(){
	int n;
	cin >> n;
	vector<vector<int>> c(n,vector<int>(n));
	REP(i,0,n) REP(j,0,n) cin >> c[i][j];
	ll ans=0;
	REP(i,0,n) REP(j,0,i) ans+=min(c[i][j],c[j][i]);
	cout << ans << endl;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	Solve();
	return 0;
}

Measured memory_bytes: 1264
import math

def isprime(num):
    if num == 2:
        return True
    if num == 1 or num % 2 == 0:
        return False
    i = 3
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False
    return True


def count_prime_numbers(number_list):
    cnt = 0
    for target in number_list:
        if isprime(target):
            cnt += 1
    return cnt

N = int(input())
A = [int(input()) for i in range(N)]
print(count_prime_numbers(A))

Measured memory_bytes: 7976
#include <iostream>
#include <limits.h>
#include <string>

using namespace std;
int main(void){
    int n, ans = 0;
    string s;
    cin >> n;
    cin >> s;
    while (ans <= n) {
        if (s[ans] == 'x') {
            ans++;
            if (s[ans] == 'x') break;
            else ans++;
        }
        else ans++;
    }
    if (ans > n) ans = n;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3344
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string.h>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <math.h>
#include <assert.h>
#define ff first
#define ss second
#define ll long long
#define mod 998244353
using namespace std;
ll k, n, ma, a[200009];
int main () {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//    freopen("task2-test-input.txt", "r", stdin);
//    freopen("task2-test-output.txt", "w", stdout);
    cin>>k>>n;
    ma = 0;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        if(i > 1) {
            ll dist = a[i] - a[i - 1];
            ma = max(ma, dist);
        }
        if(i == n) {
            ll dist = k - a[i] + a[1];
            ma = max(ma, dist);
        }
    }
    cout<<k - ma;
}


Measured memory_bytes: 1792
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.trim().split("\n");
	n = input[1].split(' ').map((n) => (parseInt(n)))
	ans = 0
	n.forEach((i) => {
		ans += i - 1
	})

	//出力
	console.log(ans)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require('fs').readFileSync('./input.txt', 'utf-8'));

Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
int main()
{
     int a,b,c;
     cin>>a>>b;
    if(a%(2*b+1)==0)
    {
          c=a/(2*b+1);
    }
    else
    {
          c=a/(2*b+1)+1;
    }
    cout<<c<<endl;
      return 0;
}


Measured memory_bytes: 256
/*
    NO 
        TIME 
            TO 
                DIE
                    --007
                            */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli mod=998244353;
#define OS //single input use oeis
lli INF=1e17;
lli eps=1e-8;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcountll(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctzll(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clzll(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffsll(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
int fmx(int x, int y) { return (((y-x)>>(31))&(x^y))^y; }
int fmi(int x, int y) { return (((y-x)>>(31))&(x^y))^x; }
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,z,k,x,m,d,y,q,b,c;
const double pi=3.14159265358979323846;
// double dp[100005];
 
// bool cmp
lli dp[200005];
lli back[200005];
lli ans[200005];
int main()
{

 IO;
 OS;
 lli a,b,c,x,y;
 cin>>x>>y>>a>>b>>c;
 lli red[a+1];
 for(int i=1;i<=a;i++)
    cin>>red[i];

 lli green[b+1];

 for(int i=1;i<=b;i++)
    cin>>green[i];

 lli colo[c+1];
 for(int i=1;i<=c;i++)
    cin>>colo[i];

sort(red+1,red+a+1,greater<lli>());
sort(green+1,green+b+1,greater<lli>());
multiset<lli,greater<lli>> ss;
for(int i=1;i<=min(a,x);i++)
ss.insert(red[i]);

for(int i=1;i<=min(b,y);i++)
ss.insert(green[i]);

for(int i=1;i<=c;i++)
ss.insert(colo[i]);

lli anss=0;
for(int i=1;i<=x+y;i++)
anss+=*ss.begin(),ss.erase(ss.begin());
 

 cout<<anss;
}

Measured memory_bytes: 15744
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int c = sc.nextInt();
        char[][] board = new char[r + 2][c + 2];
        
        for (char[] b : board) {
            Arrays.fill(b, '.');
        }
        
        for (int i = 1; i <= r; i++) {
            String str = sc.next();
            for (int j = 1; j <= c; j++) {
                board[i][j] = str.charAt(j - 1);
            }
        }
        
        boolean canClear = true;
        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                if (!check(board, i, j)) {
                    canClear = false;
                    break;
                }
            }
            
            if (!canClear) break;
        }
        
        if (canClear) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
    
    public static boolean check(char[][] board, int i, int j) {
        // 自身の上下左右マスに#があればtrue
        
        if (board[i][j] == '.') return true;
        if (board[i - 1][j] == '#') return true;
        if (board[i + 1][j] == '#') return true;
        if (board[i][j - 1] == '#') return true;
        if (board[i][j + 1] == '#') return true;
        return false;
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#define x first
#define y second
using namespace std;
typedef pair<int, int> PII;
int h,w;
int dirx[4] = {0, -1, 0, 1};
int diry[4] = {-1, 0, 1, 0};

int bfs(int i, int j, vector<vector<int>> maze)
{
    queue<PII> q;
    q.push({i, j});
    maze[i][j] = 1;
    int dist = 0;
    while(!q.empty())
    {
        bool flag = false;
        int len = q.size();
        for(int k = 0; k < len; k ++)
        {
            PII temp = q.front();
            q.pop();
            for(int m = 0; m < 4; m ++)
            {
                int new_x = temp.x + dirx[m];
                int new_y = temp.y + diry[m];
                if(new_x < 0 || new_x >= h || new_y < 0 || new_y >= w || maze[new_x][new_y] == 1) continue;
                q.push({new_x, new_y});
                flag = true;
                maze[new_x][new_y] = 1;
            }
        }
        if(flag) dist ++;
    }
    return dist;
}

int main()
{
    cin >> h >> w;
    vector<vector<int>> maze(h, vector<int>(w, 0));
    for(int i = 0; i < h; i ++)
    {
        string temp;
        cin >> temp;
        for(int j = 0; j < w; j ++)
        {
            if(temp[j] == '#') maze[i][j] = 1;
        }
    }
    int res = 0;
    for(int i = 0; i < h; i ++)
    {
        for(int j = 0; j < w; j ++)
        {
            if(maze[i][j] == 0){
                res = max(res, bfs(i, j, maze));
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        int res = 0;
        for(int i=0; i<S.length(); i++){
            if(S.charAt(i)!= T.charAt(i)) res++;
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 41204
import itertools

N = int(input())
S = input()
hidarikara = [0]
for i,c in enumerate(S):
    if S[i] == "W":
         hidarikara.append( hidarikara[i] + 1  )
    else:
        hidarikara.append(hidarikara[i])
S = S[::-1]

migikara = [0]

for i,c in enumerate(S):
    if S[i] == "E":
         migikara.append( migikara[i] + 1  )
    else:
        migikara.append(migikara[i])
anss = [migikara[i] + hidarikara[N-1-i] for i in range(N)]
print(min(anss))

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

using namespace std;

int main(){
	int N = 0;
	cin >> N;
	int sum = 0;
	vector<int> s(N);
	for (unsigned int i = 0; i < N; ++i){
		cin >> s[i];
		sum += s[i];
	}
	if (sum % 10 != 0){
		cout << sum << endl;
		return 0;
	}

	sort(s.begin(), s.end(), [](const int &a, const int&b){ return a < b; });
	for (int i = 0; i < s.size(); ++i){
		if ((sum - s[i]) % 10 != 0){
			cout << sum - s[i] << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

template<class Ty>
using passive_queue = priority_queue<Ty, vector<Ty>, greater<Ty>>;

struct Problem {

	UL S[1001][11][11] = {};

	void Solve() {
		UL H, W, K; cin >> H >> W >> K;
		rep(y, H) rep(x, W) {
			char c; cin >> c;
			S[x + 1][0][y + 1] = S[x + 1][0][y] + S[x][0][y + 1] - S[x][0][y];
			if (c == '1') S[x + 1][0][y + 1]++;
		}
		for (UL s = 1; s < H; s++) {
			for (UL t = s + 1; t <= H; t++) {
				rep(x, W + 1) S[x][s][t] = S[x][0][t] - S[x][0][s];
			}
		}

		UL ans = 100000;
		for (UL y = (1 << H); y < (1 << (H + 1)); y += 2) {
			UL i = 0;
			UL tmp = 0;
			bool ng = false;
			for (UL x = 0; x < W; x++) {
				bool cut = false;
				UL q = 0;
				for (UL j = 1; j <= H; j++) {
					if (y & (1 << j)) {
						if (S[x + 1][q][j] - S[i][q][j] > K) cut = true;
						q = j;
					}
				}
				if (cut) {
					if (i == x) { ng = true; break; }
					tmp++; i = x; x--;
				}
			}
			if (ng) continue;
			rep(j, H) if (y & (1 << j)) tmp++;
			ans = min(ans, tmp);
		}

		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 3e3 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int a, b;
  cin >> a >> b;
  swap(a, b);
  cout << (b / a) + (b % a != 0);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  ll  long long
int main()
{
    ll i,j,n,c=0,m;
    cin>>n;
    for(i=1;i<=(n/i);i++)
    {
        if(n%i==0)
        {
            ll d=n/i;
            ll val=(i-1)+(d-1);
            if(c==0)
            {
                m=val;
            }
            else
            {
                m=min(val,m);
            }
        }
    }
    cout<<m<<"\n";
    return 0;
}


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

#ifndef __TOPCYBERFLOWER
#define debug(...) 0
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif

#define TYPEMAX(type)   numeric_limits<type>::max()
#define TYPEMIN(type)   numeric_limits<type>::min()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main(void){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int a,b; cin>>a>>b;
    for(int i=1;i<=10000;i++){
        if(8*i/100==a && 10*i/100==b){
            cout<<i;
            return 0;
        }
    }
    cout<<-1;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int,input().split())
p = [0] * m
s = [0] * m
for i in range(m):
    p[i], s[i] = map(str, input().split())
for i in range(m):
    p[i] = int(p[i])

ans1 = 0
ans2 = 0

aclis = [0] * (n+1)
walis = [0] * (n+1)


for i in range(m):
    if s[i] == 'AC':
        aclis[p[i]] = 1



    elif aclis[p[i]] == 0 and s[i] == 'WA':
        walis[p[i]] += 1
ans1 = aclis.count(1)
#print(aclis)
#print(walis)

for i in range(n+1):
    if aclis[i] == 1:
        ans2 += walis[i]


print(ans1, ans2)

Measured memory_bytes: 20432
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (10000)
#define MOD (1000000007)

typedef struct
{
    ll a;
    ll b;
    ll c[12];
}key;

key ks[MAXN];
ll dp[MAXN+1][1<<12];

int main(void)
{
    ll n,m;
    scanf("%ld %ld",&n,&m);

    for(int i=0;i<m;i++)
    {
        scanf("%ld %ld",&(ks[i].a),&(ks[i].b));
        for(int j=0;j<ks[i].b;j++)
        {
            scanf("%ld", &(ks[i].c[j]));
        }
    }

    for(ll j=0;j<1<<n;j++)
    {
        dp[0][j] = INT64_MAX;
    }
    dp[0][0] = 0;

    for(int i=0;i<m;i++)
    {
        ll m = 0;
        for(ll j=0;j<ks[i].b;j++)
        {
            m |= 1L << (ks[i].c[j] -1);
        }
        for(ll j=0;j<1<<n;j++)
        {
            dp[i+1][j] = dp[i][j];
        }

        for(ll j=0;j<1<<n;j++)
        {
            if(dp[i][j]==INT64_MAX) continue;
            dp[i+1][j|m] = min(dp[i][j]+ks[i].a,dp[i+1][j|m]);
        }
    }
    if(dp[m][(1<<n)-1]==INT64_MAX)
    {
        printf("-1\n");
        return 0;
    }
    
    printf("%ld\n", dp[m][(1<<n)-1]);
    return 0;
}


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

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

  int n;
  cin >> n;

  map<string,int> mp;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;

    ++mp[s];
  }

  int x = 0;
  for (auto e : mp) x = max(x, e.second);
  for (auto e : mp) if (e.second == x) cout << e.first << '\n';

  return (0);
}


Measured memory_bytes: 19248
#include <bits/stdc++.h>
#include<cmath>
using namespace std;
typedef long long int l1;
typedef vector <int> vi;
typedef vector <long long int> v1;
#define pb push_back
#define iter(i,a,b) for(i=a;i<b;i++)

int main()
{
    ios_base::sync_with_stdio(false);      //for fast cin and cout streams
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    while(test--)
{
int n,m;
cin>>n>>m;
int i,j,flag=0;
for(i=0;i<=n;i++)
{
  if((4*n-2*i)==m)
  {
    flag=1;
    break;
  }
  else 
    continue;
}
if(flag==1)
  cout<<"Yes";
      else
        cout<<"No";
   

}

return 0;
}






Measured memory_bytes: 3640
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
#define inf 0x3f3f3f3f
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20];
	int len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
int a[maxn];
int val[maxn],len[maxn];
int n,tp;
void push(int x)
{
	if(!tp||val[tp])val[++tp]=0,len[tp]=x;
	else len[tp]+=x;
}
void pop(int x)
{
	while(tp&&len[tp]<=x)x-=len[tp--];
	if(x)len[tp]-=x;
}
int inc(int limit)
{
	int x=0;
	while(tp&&val[tp]==limit-1)x+=len[tp--];
	if(!tp)return 0;
	if(len[tp]==1)++val[tp];
	else --len[tp++],val[tp]=val[tp-1]+1,len[tp]=1;
	if(x)val[++tp]=0,len[tp]=x;
	return 1;
}
int check(int mid)
{
	tp=0;
	for(int i=1;i<=n;i++)
		if(a[i]>a[i-1])push(a[i]-a[i-1]);
		else{
			pop(a[i-1]-a[i]);
			if(!inc(mid))return 0;
		}
	return 1;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	int l=1,r=n;
	while(l<r){
		int mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	writeln(l);
	return 0;
}

Measured memory_bytes: 896
#!/usr/bin/env python3
#ABC133 C

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
def LI(): return list(map(int,sys.stdin.readline().split()))
def LIR(n): return [LI() for _ in range(n)]
mod = 2019

l,r = LI()
mi = float('inf')
if r - l >= 2019:
    print(0)
else:
    for i in range(l+1,r+1):
        for j in range(l,i):
            mi = min(mi,(i*j)% mod)
    print(mi)


Measured memory_bytes: 40556
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e15;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pii;

void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const ll MAXN = 1e6 + 10;
const ll N = 4000 + 10;
const ll MN = 200 + 10;
const ll mod = 1e6;

ll a[MAXN * 2];

int main()
{
	faster();
	ll n , x;
	cin >> n >> x;
	ll cnt = 1;
	if(x != 1 && x != 2 * n - 1)
	{
		cout << "Yes\n";
		set <int> s;
		a[n - 1] = x;
		a[n - 2] = x - 1;
		a[n] = x + 1;
		for (int i = 1; i <= 2 * n - 1; i++)
		{
			if(i < x - 1 || i > x + 1)
				s.insert(i);
		}
		for (int i = 0; i < 2 * n - 1; i++)
		{
			if(a[i] == 0)
			{
				a[i] = *s.begin();
				s.erase(s.find(a[i]));
			}
			cout << a[i] << endl;
		}
	}
	else
		cout << "No\n";
}

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

template<int MOD>
class mod_int {
	unsigned x;
public:
	mod_int() : x(0) { }
	mod_int(int sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	mod_int(long long sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	mod_int &operator+=(mod_int that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
	mod_int &operator-=(mod_int that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	mod_int &operator*=(mod_int that) { x = (unsigned long long)x * that.x % MOD; return *this; }
	mod_int &operator/=(mod_int that) { return *this *= that.inverse(); }

	mod_int operator+(mod_int that) const { return mod_int(*this) += that; }
	mod_int operator-(mod_int that) const { return mod_int(*this) -= that; }
	mod_int operator*(mod_int that) const { return mod_int(*this) *= that; }
	mod_int operator/(mod_int that) const { return mod_int(*this) /= that; }

	bool operator==(const mod_int& that) const { return x == that.x; }

	mod_int inverse() const {
		long long a = x, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		return mod_int(u);
	}
};

template<int MOD>
istream& operator >> (istream& is, mod_int<MOD>& val) {
	long long x;
	is >> x; val = x;
	return is;
}

template<int MOD>
ostream& operator << (ostream& os, const mod_int<MOD>& val) {
	os << val.get();
	return os;
}

const int mod = 1e9 + 7;
using mint = mod_int<mod>;

mint dp[101][100001];
mint sum[101][100002];

int main()
{
	int N, K;
	cin >> N >> K;
	dp[0][0] = 1;
	for (int i = 0; i <= K; i++) {
		sum[0][i + 1] = sum[0][i] + dp[0][i];
	}
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		for (int j = 0; j <= K; j++) {
			dp[i + 1][j] = sum[i][j + 1] - sum[i][max(j - a, 0)];
		}
		for (int j = 0; j <= K; j++) {
			sum[i + 1][j + 1] = sum[i + 1][j] + dp[i + 1][j];
		}
	}
	cout << dp[N][K] << endl;
	return 0;
}


Measured memory_bytes: 79104
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
double pi = 3.141592653589793;
ll mod = 1000000007;

int main() {
    int N;
    cin >> N;
    double t[N], v[N];
    for (int i = 0; i < N; i++) {
        cin >> t[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }
    int slim[N + 1], elim[N + 1];
    slim[0] = 0;
    elim[N] = 0;
    for(int i = 0; i < N; i++) {
        slim[i + 1] = min(slim[i] + t[i], v[i]);
        elim[N - i - 1] = min(elim[N - i] + t[N - 1 - i], v[N - 1 - i]);
    }
    double ans = 0;
    for(int i = 0; i < N; i++){
        int s = min(slim[i], elim[i]);
        int e = min(slim[i + 1], elim[i + 1]);
        double m = (t[i] - abs(s - e)) * 0.5 + max(s, e);
        if(m <= v[i]) {
            ans += 0.5 * (s + m) * (m - s) + 0.5 * (m + e) * (m - e);
        } else {
            ans += v[i] * t[i] * 1.0 - 0.5 * (v[i] - s) * (v[i] - s) - 0.5 * (v[i] - e) * (v[i] - e);
        }
    }
    printf("%.2f", ans);
    printf("\n");
}



Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE


void solve(void)
{
  string s1,s2;
  cin>>s1>>s2;
  int A,B;
  cin>>A>>B;
  map<string,int> mp;
  mp[s1] = A;
  mp[s2] =B;
  string ss;cin>>ss;
  mp[ss] --;
  cout<<mp[s1]<<" "<<mp[s2]<<endl;

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
          int n,m,s;
          
          int max=0;
          int i, j;
          while(1){
                    int p[1000]={0};
                    scanf("%d %d", &n, &m);
                    if(n+m==0) break;
                    for(i=0;i<m;i++){
                              for(j=0;j<n;j++){
                                        scanf("%d", &s);
                                        p[j]+=s;
                                        if(max<p[j]) max=p[j];
                              }      
                    }
                    
                    printf("%d\n", max);
                    max=0;
          }
          
}


Measured memory_bytes: 2008
#include <bits/stdc++.h>
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 1e5 + 5;
int n, h[N], dp[N];
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	fw (i, 0, n) cin >> h[i];
	memset(dp, 63, sizeof dp);
	dp[0] = 0;
	fw (i, 0, n) {
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
		if (i + 2 < n) dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
	}
	cout << dp[n - 1];
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
  int n,value,sum=0;
  int max=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> value;
    if(value > max){
      sum += (max+value)/2;
      max = value;
    }
    else
      sum += value;
  }
  cout << sum << endl;
  return 0;
}
      
  

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

constexpr int MAX_N = 300;
int n;
int w[MAX_N];
int memo[MAX_N][MAX_N + 1];

int dfs(const int l, const int r) {
	if(l >= r) return 0;
	int &res = memo[l][r];
	if(res != -1) return res;

	res = dfs(l + 1, r);
	for(int i = l + 1; i < r; i += 2) {
		const int width = i - l - 1;
		if(abs(w[l] - w[i]) <= 1 && dfs(l + 1, i) == width) {
			res = max(res, dfs(i + 1, r) + width + 2);
		}
	}
	return res;
}

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(cin >> n && n) {
		for(int i = 0; i < n; ++i) {
			cin >> w[i];
		}
		memset(memo, -1, sizeof(memo));
		cout << dfs(0, n) << endl;
	}
	return EXIT_SUCCESS;
}

Measured memory_bytes: 3464
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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; }
using Edge = pair<int, ll>;
using Graph = vector<vector<Edge>>;
int q, k, n;
vector<ll> cost_k; // コスト表

// 頂点kを根として全てのノードへのコストをdfs
void dfs(const Graph &G, int v, int parent, ll dist) {
    cost_k[v] = dist;
    for(auto next : G[v]) {
        if(next.first == parent) continue;
        dfs(G, next.first, v, dist + next.second);
    }
}

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

    cin >> n;
    Graph G(n);
    rep(i, n-1) {
        int a, b, c; cin >> a >> b >> c;
        a--; b--;
        G[a].push_back(make_pair(b, c));
        G[b].push_back(make_pair(a, c));
    }
    cin >> q >> k;
    cost_k.resize(n);
    k--;
    dfs(G, k, -1, 0);
    rep(i, q) {
        int x, y; cin >> x >> y;
        x--; y--;
        cout << cost_k[x] + cost_k[y] << endl;
    }
}


Measured memory_bytes: 15872
from sys import stdin
c = str(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
#A, B, C = map(int, stdin.readline().rstrip().split())
#S = [list(map(int, stdin.readline().rstrip().split())) for _ in range(h)]#hの定義を忘れずに
list = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
print(list[list.index(c)+1])


Measured memory_bytes: 2940
n,x,y = map(int,input().split())
k = [0]*(n)

for i in range(1,n):
  for j in range(i+1,n+1):
    if i < x and j <= x:
      k[j-i] += 1
    elif i >= y and j > y:
      k[j-i] += 1
    elif x <= i < y and x<j<=y:
      ind = min(j-i,abs((i-x))+abs((y-j))+1)
      k[ind] += 1
    elif i < x and x<j<=y:
      ind = min(j-i,abs((x-i))+abs((y-j))+1)
      k[ind] += 1
    elif x<=i<y and y<j:
      ind = min(j-i,abs((i-x))+1+abs((j-y)))
      k[ind] += 1
    elif i< x and j > y:
      ind = (x-i) + 1 + (j-y)
      k[ind] += 1
      
for i in range(1,n):
  print(k[i])

Measured memory_bytes: 3444
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

const int MAX=2e6+1; //nCrのnのMAX+1
ll fac[MAX],finv[MAX],inv[MAX];

void cominit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<MAX;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll com(int n,int k){ //1≦k≦n≦10^7
  if (n<k) return 0;
  if (n<0||k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
//Add cominit(); in main function.

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

int main(){
  cominit();
  int k; cin >> k;
  string s; cin >> s;
  int n=s.size();
  k=k+n;
  ll ans=0;
  for(int i=n;i<=k;i++){
    ans+=rui(26,k-i)*com(i-1,n-1)%mod*rui(25,i-n)%mod;
    ans%=mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 52160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void bfs(int x) {
	int cnt = 1;
	queue<ll>Q;
//	if(x <= 9)printf("%d\n", x);
	for(int i = 1; i <= 9; i++) {
		Q.push(i);
	}
	while(1) {
		ll t = Q.front();Q.pop();
		if(cnt == x) {
			printf("%lld\n", t);
			return ;
		} 
//		printf("%d\n", t);
		if(t % 10 == 9) {
			Q.push(t * 10 + 8);
			Q.push(t * 10 + 9);
		}
		else if(t % 10 == 0) {
			Q.push(t * 10);
			Q.push(t * 10 + 1);
		}
		else {
			for(ll j = t % 10 - 1;j <= t % 10 + 1; j++) {
				Q.push(t * 10 + j);
			}
		}
		++cnt;
	}
}
int main() {
	int k;
	cin >> k;
	bfs(k);
	return 0;
} 

Measured memory_bytes: 5192
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
Graph G(10);

bool is_exited(vector<int> vec, int val){
    bool flag = false;
    for (int i = 0; i < vec.size(); ++i){
        if (vec[i] == val){
            flag = true;
            break;
        }
    }
    return flag;
}


int main(void){
    //////////////////////////
    // 方針
    // すべての順列を書き出す
    //////////////////////////


    // 入力
    int N, M; scanf("%d", &N); scanf("%d", &M);
    int a, b;
    for(int i = 0; i < M; ++i){
        scanf("%d", &a);
        scanf("%d", &b);
        --a; --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    ////////////////////////

    int ans = 0;
    vector<int> v(N);
    iota(v.begin(), v.end(), 0);
    do {
        
        bool flag = true;
        if (v[0] != 0) break;
        int x, nx;
        for (int i = 0; i < N-1; ++i){
            x = v[i];
            nx = v[i+1];
            if (!is_exited(G[x], nx)) flag = false;
        }
        if(flag)  ++ans;
        
        //for(auto x : v) cout << x << " "; cout << "\n";    // v の要素を表示

            
    }while(next_permutation(v.begin(), v.end()));

    printf("%d\n", ans);

   //////////////////////////
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using vll = vector<ll>;
using vvll = vector<vll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
using plli = pair<ll, int>;
using vplli = vector<pair<ll, int>>;
using pllll = pair<ll, ll>;
using vpllll = vector<pair<ll, ll>>;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

//pow(llpow,modpow)
template <class T>
ll llpow(ll x, T n)
{
    ll ans = 1;
    if (x == 0)
        ans = 0;
    while (n)
    {
        if (n & 1)
            ans *= x;
        x *= x;
        n >>= 1;
    }
    return ans;
}
long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
template <class T>
inline T gcd(T x, T y)
{
    if (y == 0)
        return x;
    else
    {
        return gcd(y, x % y);
    }
}
//最小公倍数
template <class T>
inline T lcm(T x, T y) { return x / gcd(x, y) * y; }
//逆元
long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i - 1; i >= (ll)end_i; i--)

long long INF = 1LL << 60;
vi is_p(10000000 + 1, 0);
template <class T>
vector<pair<long long, long long>> primefact(T x)
{
    vector<pair<long long, long long>> ret;
    ll cpyx = x;
    for (long long i = 1; i * i <= x; i++)
    {
        if (x % i == 0)
        {
            vector<long long> alt = {i, x / i};
            if (alt[0] == alt[1])
                alt[1] = 1;
            for (long long j = 0; j < alt.size(); j++)
            {
                if (is_p[alt[j]])
                {
                    pair<long long, long long> t = make_pair(alt[j], 0);
                    while (cpyx % alt[j] == 0)
                    {
                        cpyx /= alt[j];
                        t.second++;
                    }
                    ret.push_back(t);
                }
            }
        }
    }
    return ret;
}
int main()
{
    ll N;
    cin >> N;
    ll cnt=0;
    rep(i, 1, N + 1)
    {
        for (ll j = i ; j <= N; j += i)
        {
            is_p[j]+= 1;
        }
    }
    ll ans = 0;
    rep(i, 1, N + 1)
    {
        ans+=i*is_p[i];
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int N, A;
  cin >> N >> A;
  
  if (N%500 <= A) {
    cout << "Yes" << endl;
  }
  
  if (N%500 > A) {
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
// 109 A - ABC333 2018/09/08
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int a , b; cin >> a >> b;
    bool odd=false;
    for(int c=1;c<=3;++c){
        if(( a * b * c) % 2 !=0) odd=true;
    }
    cout << ( odd ? "Yes" : "No") << endl;
}

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

int main() {
	int x, y;
	while (cin >> x >> y,x||y) {
		cout << min(x, y) << ' ' << max(x, y) << endl;
	}
}

Measured memory_bytes: 3084
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  string s;cin>>s;
  s[3]='8';
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
    int n,x,rmin,res = -1000000000,r;
    bool check = false;
    cin >> n;
    cin >> r;
    rmin = r;
    x = r;
    for(int i = 0;i < n - 1;i++){
        cin >> r;
        if(x <= r){
            check = true;
            res = max(res,r - rmin);
        }
        else{
            rmin = min(rmin,r);
            res = max(res,r - x);
        }
        x = r;
    }
    if(check){
    cout << res << endl;
    }
    else cout << res << endl;
    return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>

int main(){
	int n;
	scanf("%d",&n);
	int pre=n+1;
	int ans=0;
	for(int i=0;i<n;i++){
		int t;
		scanf("%d",&t);
		if(t<pre){
			pre=t;
			ans++;
		}
	}
	printf("%d",ans);
}

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

typedef long int lint;
typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(t, c) for (auto&& t : c)
#define ALL(c) begin(c), end(c)
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define fk first
#define sv second

const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  int res = 0;
  cin >> s;

  REP(i, s.size()) {
    char a = s[i];
    if (a == '+' ) {
      res++;
    } else {
      res--;
    }

  }
  cout << res;
}

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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int x, n;
	cin >> x >> n;
	vector<int> a(n);
	int ans = -1;
	int best = 1e9;
	for (int i = 0; i < n; ++i){
		cin >> a[i];
	}
	set<int> s(a.begin(), a.end());
	for (int i = 0; i <= 101; ++i){
		if (s.find(i) == s.end()){
			if (abs(x - i) < best){
				ans = i;
				best = abs(x - i);
			}
		}
	}
	cout << ans << '\n';
}




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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> inline T gcd(T a, T b) {
  return __gcd(a, b);
}

template<typename T> inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}

template<typename T> inline T floor(T a, T b) {
  return floor(a / b) * b <= a ? floor(a / b) : floor(a / b) - 1;
}

template<typename T> inline T ceil(T a, T b) {
  return floor(a + b - 1, b);
}

template<typename T> inline T round(T a, T b) {
  return floor(a + b / 2);
}

template<typename T> inline T mod(T a, T b) {
  return a - floor(a, b) * b;
}

template<typename T> inline T factorial(T n) {
  return n <= 1 ? 1 : factorial(n - 1) * n;
}

template<typename T> inline T square(T n) {
  return n * n;
}

template<typename T> inline T cube(T n) {
  return n * n * n;
}

template<typename T> inline T norm(T x1, T y1, T x2, T y2) {
  return square(x1 - x2) + square(y1 - y2);
}

inline long long sqrt(long long n) {
  return sqrt((long double)n);
}

int main() {
  int64_t n, x;
  cin >> n >> x;
  auto g = gcd(n, x);
  n /= g;
  x /= g;
  cout << (3 * n - 3) * g << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int x,y ,a;
  scanf("%d %d",&x,&y);
  
  while(x != 0 || y !=0) {
    if(x > y) {
      a = x;
      x =y;
      y = a;
    } 
    printf("%d %d\n",x , y);
    scanf("%d %d" ,&x,&y);
 
  }
  return 0;
}



Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define MAX 100005
#define endl "\n"
lli arr[MAX];
bool flag[MAX];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lli arr[6];
	lli temp;
	lli a;
	for(lli i = 0; i<5; i++){
		cin>>temp;
		if(temp == 0){
			a = i+1;
		}
	}
	cout<<a<<endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;

ll L,R,ans=1e9;
vector<ll> a;
bool use[2019];

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> L >> R;
    for(ll i=L; i<=R; i++){
        if( use[ i%2019 ] ) break;
        use[ i%2019 ] = true;
        a.pb( i%2019 );
    }

    for(ll i=0; i<a.size(); i++) for(ll j=i+1; j<a.size(); j++) ans=min( ans , (a[i]*a[j])%2019 );
    cout << ans;

    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;
typedef pair<int,int> pii;
typedef pair<pii,pii> state;

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

int main(){
  int w,h;
  while(cin >> w >> h, w){
    int ax,ay,bx,by;
    cin >> ax >> ay >> bx >> by;
    state init(pii(ax,ay),pii(bx,by));
    
    vector< vector<int> > g(h+2,vector<int>(w+2,1));
    rep(i,h)rep(j,w){
      cin >> g[i+1][j+1];
    }

    queue<state> q;
    q.push(init);
    map<state, int> d;
    d[init] = 0;

    int ans = 1000;
    while(q.size()){
      state cur = q.front(); q.pop();
      if(ax==bx && ay==by){
	ans = d[cur]; break;
      }

      if(d[cur]==99)continue;
      ax = cur.first.first; ay = cur.first.second;
      bx = cur.second.first; by = cur.second.second;

      rep(a,4){
	int nax = ax+dx[a], nay = ay+dy[a];
	int nbx = bx-dx[a], nby = by-dy[a];

	if(g[nay][nax])nay = ay, nax = ax;
	if(g[nby][nbx])nby = by, nbx = bx;

	state nxt(pii(nax,nay),pii(nbx,nby));
	if(d.count(nxt))continue;

	d[nxt] = d[cur] + 1;
	q.push(nxt);
      }
    }

    if(ans>=100)cout << "NA" << endl;
    else cout << ans << endl;
  }
}

Measured memory_bytes: 12176
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#define INF 0x3f3f3f3f
#define ll long long
#define EPS 1e-8
using namespace std;
int ar[100005];
int main()
{
    //freopen("stdin.in","r",stdin);
    //freopen("stdout.out","w",stdout);
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",&ar[i]);
    }
    int ans = INF;
    for(int i=1;i+k-1<=n;i++){
        int r = i+k-1;
        int tmp = ar[r]-ar[i]+min(abs(ar[i]),abs(ar[r]));
        ans = min(tmp,ans);
    }
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 512