akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iostream>
typedef long long ll;
using namespace std;
int main()
{
	int n, a = 0,w = 0,t = 0,r = 0;
	cin >> n;
	while(n--){
		string s;
		cin >> s;
		if(s == "AC"){
			a++;
		}
		else if(s == "WA"){
			w++;
		}
		else if(s == "TLE"){
			t++;
		}
		else if(s=="RE"){
			r++;
		}
	}
	cout << "AC x " << a << endl;
	cout << "WA x " << w << endl;
	cout << "TLE x " << t << endl;
	cout << "RE x " << r << endl;
}

Measured memory_bytes: 3644
/*PM1 問題１４*/
#include <stdio.h>

int main()
{
	double i = 0;
	double j = 0;
	double k = 0;

	scanf("%lf", &i);

	j = 3.141592653589*i*i;
	k = 2 * 3.141592653589*i;
	printf("%.6f %.6f", j, k);
	return 0;
}






Measured memory_bytes: 2072
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

char S[100];
int len;
int ans;

int main(void){

	char s[]="CODEFESTIVAL2016";

	scanf("%s",S);
	len=strlen(S);

	for (int i = 0; i < len; ++i)
	{
		if(S[i]!=s[i]){
			ans++;
		}
	}

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

	return 0;

}


Measured memory_bytes: 384
N, A = list(map(int, input().split(' ')))
x = list(map(int, input().split(' ')))
X = max(x)
X = max(X, A)

dp = [[[0 for s in range(N * X + 1)] for k in range(N + 1)] for j in range(N + 1)]

dp[0][0][0] = 1
for j in range(1, N + 1):
    for k in range(N + 1):
        for s in range(N * X + 1):
            if s < x[j - 1]:
                dp[j][k][s] = dp[j - 1][k][s]
            elif k >= 1 and s >= x[j - 1]:
                dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]]
#print(dp)
count = 0
for k in range(1, N + 1):
    #print(dp[N][k][k * A])
    count += dp[N][k][k * A]
print(count)

Measured memory_bytes: 96496
/**
 * @Author:      H S-J
 * @DateTime:    2017-09-16 20:17:01
 * @Description: 
 */
#include <bits/stdc++.h>
using namespace std;
#define MST(a, b) memset(a, b, sizeof(a));
#define CLR(a) MST(a, 0);
#define DBG(x) cout << '#' << " = " << (x) << endl;
#define ALL(x) x.begin(), x.end()
#define INS(x) inserter(x, x.begin())
#define lson(x) (x) << 1
#define rson(x) (x) << 1|1
#define pb push_back
#define rep(x, y, z) for (int x = y; x < z; ++x)
#define ech(x, y, z) for (auto x = z.begin(), y = z.end(); x != y; ++x)
#define lowbit(x) (x & (-x))
#define opr operator
#define _st first
#define _nd second
#define prior_q1(x) priority_queue<x>
#define prior_q2(x) priority_queue<x, vector<x>, greater<x> >
typedef long long LL;
typedef stringstream strstm;
LL a[333][333];
int n;
bool vis[333][333];
int main(int argc, char const *argv[]) {
    // ios::sync_with_stdio(0);cin.tie(0);
    while (cin >> n) {
        CLR(a); CLR(vis);
        rep (i, 0, n) rep (j, 0, n) cin >> a[i][j];
        bool ok = true;
        rep (k, 0, n) rep (i, 0, n) rep (j, 0, n) if(i != j && j != k && k != i) {
            if (a[i][j] > (a[i][k] + a[k][j])) ok = false;
            if (a[i][j] == (a[i][k] + a[k][j])) vis[i][j] = true;
        }
        if (!ok) {
            cout << "-1" << endl;
            continue;
        }
        LL ans = 0;
        rep (i, 0, n) rep (j, i + 1, n) if (!vis[i][j]) ans += a[i][j];
        cout << ans << endl; 
    }
    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
const int M = 2e5 + 5;
const int P = 1e9 + 7;
int a[M], w[M], dp[M];
inline int Mod(int x) {
	return x >= P ? x - P : x;
}
int main() {
	int n; cin >> n;
    for (int i = 1; i <= n; ++i) scanf("%d", a + i);
	dp[n] = w[a[n]] = 1;
	for (int i = n - 1; i > 0; --i) {
        if (a[i] == a[i + 1]){dp[i] = dp[i + 1];continue;}
		dp[i] = Mod(dp[i + 1] + w[a[i]]);
		w[a[i]] = dp[i];
	}
	cout << dp[1] << endl;
	return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    int maxL = 1;
    int minR = n;
    int l, r;

    for (int i = 0; i < m; ++i) {
        cin >> l >> r;
        maxL = max(maxL, l);
        minR = min(minR, r);
    }

    int ans = minR - maxL + 1;
    ans = max(ans, 0);
    cout << ans << endl;

}



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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int x;
  cin >> x;
  cout << "ai1333" << string(x/100, '3') << endl;

  return 0;
}



Measured memory_bytes: 3236
#https://qiita.com/drken/items/dc53c683d6de8aeacf5a(DP問題集)
#https://atcoder.jp/contests/dp/tasks/dp_a

N = int(input())
h = list(map(int,input().split()))
dp = [float("inf")]*N
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2,N,1):
    dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]))

print(dp[N-1])

Measured memory_bytes: 13980
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iomanip>

#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <list>

#include <cmath>
#include <algorithm>
#include <cassert>
#include <bitset>
#include <complex>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;

#define mp make_pair
#define pb push_back

const int maxn = 1e5+1;
int n, a[maxn];

int main()
{
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d", a+i);
  auto it = max_element(a+1, a+1+n);
  int base = *it;
  int mid = (base+1)/2;
  *it = 0;
  int ans=0;
  for (int i = 1; i <= n; ++i)
    {
      if (abs(mid-a[i]) < abs(mid-ans))
	ans = a[i];
    }
  printf("%d %d\n", base, ans);

}


Measured memory_bytes: 640
import itertools

N, A, B, C = map(int, input().split())

l = [int(input()) for _ in range(N)]

ans = 10**10
# [竹1の選択, 竹2の選択, ..., 竹Nの選択]
# 4**8==65536
for x in itertools.product([0, 1, 2, 3], repeat=N):
    # [不使用の竹の合計長さ、Aに使用する竹の合計長さ、Bに...、Cに...]
    bamboo = [0] * 4
    tmp = 0
    for i in range(N):
        # 始めて選ぶ場合はコストがかからない
        if x[i] in [1, 2, 3] and bamboo[x[i]] > 0:
            tmp += 10
        bamboo[x[i]] += l[i]

    # A,B,Cそれぞれについて、1本以上使う必要がある
    if 0 in bamboo[1:]:
        continue
    # 延長魔法 or 短縮魔法で調整
    tmp += abs(bamboo[1] - A) + abs(bamboo[2] - B) + abs(bamboo[3] - C)

    ans = min(ans, tmp)

print(ans)


Measured memory_bytes: 9072
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void YES()
{
	OUT("YES");
}
void NO()
{
	OUT("NO");
}
void YESNO(const bool cond)
{
	OUT(cond ? "YES" : "NO");
}

void Yes()
{
	OUT("Yes");
}
void No()
{
	OUT("No");
}
void YesNo(const bool cond)
{
	OUT(cond ? "Yes" : "No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

// 階乗を計算 O(N) (N=10^7 で O(10^7))
ll factorial(ll n)
{
	for (ll i = n - 1; i > 1; --i)
		n *= i;
	return n;
}

// nCrを計算 O(N) (N=10^7 で O(10^7))
ll ncr(const ll n, ll r)
{
	if (r * 2 > n) r = n - r;

	ll dividend = 1, divisor = 1;

	for (ll i = 1; i <= r; ++i) {
		dividend *= n - i + 1;
		divisor *= i;
	}

	return dividend / divisor;
}

// 素数判定 O(sqrt(N)) (N=10^7 で O(10^3))
bool isprime(const ll num)
{
    if (num < 2) return false;
    if (num == 2) return true;
    if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0) return false;
    }

    return true;
}

// 各桁の和を計算 O(logN) (N=10^7 で O(7))
ll digsum(ll n)
{
	ll sum = 0;
	while(n != 0){
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

//////////////////////////////

void Main()
{
	inll k;
	
	return OUT((k % 2 == 0) ? k/2 * k/2 : (k - 1)/2 * ((k - 1)/2+1));
}


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

ll visited[300001];
ll a[300001];
ll o[300001];

int main(){
    ll n,k; cin >> n >> k;
    for(ll i=1;i<=n;i++){
        cin >> a[i];
        visited[i]=-1;
    }
    ll now=1;
    ll ff=-1,f=-1;
    visited[1]=0;
    o[0]=1;
    for(ll i=1;i<=k;i++){
        now=a[now];
        o[i]=now;
        //cout << o[i] << endl;
        if(visited[now]!=-1){
            ff=visited[now];
            f=i-visited[now]; break;
        } 
        visited[now]=i;
    }
    //cout << ff << " " << f << endl;
    if(f==-1) cout << now << endl;
    else cout << o[(k-ff)%f+ff] << endl;
    return 0;
   
}

Measured memory_bytes: 7904
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.HashMap;
import java.util.ArrayList;

public class Main
{
	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
	}
	static void solve () {
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);
 
 		ArrayList<HashMap<Integer , Long>> ah =new ArrayList<>() ;
 		int n =fr.nextInt() ,i ,j ;	long a[] =new long[n] ,dm ;
 		for (i =0 ; i<n ; ++i)	{	a[i] =fr.nextLong() ;	ah.add(new HashMap<Integer , Long>()) ;		}
 		ah.get(n-1).put(0,0l) ;	ah.get(n-1).put(1,a[n-1]) ;
 		ah.get(n-2).put(0,0l) ;	ah.get(n-2).put(1 , Math.max(a[n-2] , a[n-1])) ;
 		for (i =3 ; i<=n ; ++i) {
 			j =i/2 ;	ah.get(n-i).put(0,0l) ;
 			dm =a[n-i] + ah.get(n-i+2).get(j-1) ;	dm =Math.max(dm , ah.get(n-i+1).get(j)) ;
 			ah.get(n-i).put(j , dm) ;
 			if (i%2==1) {
 				++j ;	dm =a[n-i] + ah.get(n-i+2).get(j-1) ;	ah.get(n-i).put(j,dm) ;
 			}
 		}
		op.println(ah.get(0).get(n/2)) ;	op.flush();	op.close();
	}
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br =new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st==null || (!st.hasMoreElements())) 
			{
				try
				{
					st =new StringTokenizer(br.readLine());
				}
				catch(IOException e)
				{
					e.printStackTrace();
				}
				
			}
			return st.nextToken();
		}

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next()) ;
		}
	}
}

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

int main()
{
    long long a = 0;
    std::cin >> a;

    std::string sb;
    std::cin >> sb;

    auto dotIdx = sb.find('.');
    if (dotIdx != std::string::npos)
    {
        sb.erase(dotIdx + 3);
        sb.erase(dotIdx, 1);
    }
    auto b = std::stoi(sb);
    std::cout << a * b / 100;
}

Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<algorithm>
#include <string>
using namespace std;
int main()
{
    int n,S,ans=0,hyouka;
	vector<int> s;
    cin >> n;
    for(int i=0;i<n;i++)
	{
		cin>>S;
		s.push_back(S);
		ans+=s[i];
	}
	sort(s.begin(),s.end());
	for(int i=0;i<n;i++)
	{
		if(ans%10==0&&s[i]%10!=0)
			ans-=s[i];
		else if(ans%10!=0)
		{
			cout<<ans;
			return 0;
		}
	}
	cout<<"0";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
int INF = 1e9 + 1;
int MOD = 1e9+7;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main()
{
    int a,b;
  cin >> a >> b;
   if(b%a==0){
  cout << b + a; 
   }else{
   cout << b - a;
   }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl "\n"
#define all(v) v.begin(),v.end()
#define mp make_pair
#define mm(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define repn(i,a,b) for(ll i = a; i >= b; i--)
#define pb push_back
#define ff first
#define ss second
#define fto(k,m) for(auto k:m)
#define in_edges(m) repp(i, 1, m){ ll a, b; cin >> a >> b; adj[a].pb(b), adj[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define MOD 1000000007
#define sz(a) ll((a).size())
#define pii 3.1415926535897
#define quick ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// stoll(s);
int main()
{
    quick
	ll t;t=1;
    // cin >> t;
	while(t--){
        ll n; cin >>n;
        ll a[n];
        ll sum = 0;
        map<ll,ll>m;
        rep(i,0,n){
            cin >>a[i];
            m[a[i]]++;
            sum+=a[i];
        };
        ll q; cin >>q;
        while(q--)
        {
            ll u,v; cin >>u>>v;
            ll rem = m[u];
            sum-=(rem*u);
            sum+=(rem*v);
            m[u]=0;
            m[v]+=(rem);
            cout<<sum<<endl;
        }
    }
}

Measured memory_bytes: 10228
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
int main(){
	string s;
	cin>>s;
	int n = s.size();
	vector<vector<long long> > dp(n + 1, vector<long long> (13, 0));
	dp[0][0] = 1;
	for(int i = 0; i < n; ++i){
		if(s[i] == '?'){
			for(int j = 0; j < 10; ++j){
				for(int k = 0; k < 13; ++k){
					dp[i + 1][(10 * k + j) % 13] += dp[i][k];
					dp[i + 1][(10 * k + j) % 13] %= MOD;
				}
			}
		}
		else{
			int r = s[i] - '0';
			for(int k = 0; k < 13; ++k){
				dp[i + 1][(10 * k + r) % 13] += dp[i][k];
				dp[i + 1][(10 * k + r) % 13] %= MOD;
			}
		}
	}
	long long x = dp[n][5];
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
map<int,int>cnt;
int main()
{
    int n;
    cin>>n;
   int i,j,k,l;
   for(i=1;i<=100;i++)
   {
       for(j=1;j<=100;j++)
       {
           for(k=1;k<=100;k++)
           {
               l=(i+j+k)*(i+j+k)-(i*j+j*k+k*i);
               cnt[l]++;
           }
       }
   }
   for(i=1;i<=n;i++)
   cout<<cnt[i]<<endl;
}

Measured memory_bytes: 5472
#include<stdio.h>
int main(void)
{
	int n,k,c[100];
	int i,j,ii,jj;
	int max,sum,temp,m2;
	
	while(1)	{
		scanf("%d %d",&n,&k);
		if(n==0 && k==0)	break;
		for(i=0;i<n;i++)	{
			scanf("%d",&c[i]);
		}
		max=-1;
		for(i=0;i<n-k+1;i++)	{
			sum=1;
			for(j=i;j<i+k;j++)	{
				sum*=c[j];
			}
			if(max<sum)	max=sum;
		}
//		printf("max=%d\n",max);
		m2=max;
		for(i=0;i<n-1;i++)	{
			for(j=i+1;j<n;j++)	{
				temp=c[i];
				c[i]=c[j];
				c[j]=temp;
				for(ii=0;ii<n-k+1;ii++)	{
					sum=1;
					for(jj=ii;jj<ii+k;jj++)	{
						sum*=c[jj];
					}
//					printf("sum=%d\n",sum);
					if(m2<sum)	m2=sum;
				}
				temp=c[i];
				c[i]=c[j];
				c[j]=temp;
			}
		}
		printf("%d\n",m2-max);
	}
	return 0;
}


Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, A, B;
  cin >> K >> A >> B;
  int C = K;
  for(int i = 0; i < 1000; i++) {
    if(C <= B) {
      C += K;
    }
    else {
      C -= K; 
      break;
    }
  }
  if(A <= C) {
    cout << "OK" << endl;
  }
  else {
    cout << "NG" << endl;
  }
}


Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int n,k,ans=0,x;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		if(x>=k)ans++;
	}
	printf("%d\n",ans);
	return 0;	
}

Measured memory_bytes: 256
a,b=map(int, input().split())
a=a%b
if a==0:
    print(0)
else:
    arr=[]
    arr.append(a)
    while True:
        a=abs(a-b)
        if sum(x == a for x in arr)==1:
            break
        else:
            arr.append(a)

    print(min(arr))

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

typedef long long ll;

const int M = (int)1e2;

char s[M + 5];

bool check(int l, int r)
{
    int k = (l + r) / 2;
    for(int i = l; i <= k; ++i) if(s[i] != s[r - i + l])    return 0;
    return 1;
}

int main()
{
    scanf("%s", s + 1);
    int n = strlen(s + 1);
    puts(check(1, n) && check(1, (n - 1) / 2) && check((n + 3) / 2, n) ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

#include <math.h>





int main(){

    long long int L, R, sum, i, j, tmp, tmp_i, tmp_j, min;
	

	scanf("%lld %lld", &L, &R);


	min = (L%2019)*(R%2019) % 2019;

	for (i = L; i<R; i++) {
		for (j = i + 1; j <= R; j++){
			tmp_i = i % 2019;
			tmp_j = j % 2019;
			tmp = tmp_i*tmp_j % 2019;
			if (min>tmp)
				min = tmp;
			if (min == 0){
				printf("0\n");
				return 0;
			}
		
		}
	}


	printf("%lld\n", min);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
   int n,k,x,y;
   int okane;
   cin>>n>>k>>x>>y;
   if(k<n){
       okane=k*x+(n-k)*y;
   }
   else{
       okane=x*n;
   }
   cout<<okane<<endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::{i32, i64, i128, u32, u64, u128, f64};
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use proconio::{input, marker::{Isize1, Usize1, Bytes, Chars}};

#[proconio::fastout]
fn main() {
    proconio::input!(
        x: i32,
    );
    println!("{}", 1 - x);
}


Measured memory_bytes: 2116
loop {
    n = gets.to_i
    break if n == 0
    a = b = 0
    (1..n).each{
        x, y = gets.split.map(&:to_i)
        if x > y
            a += x + y
        elsif x < y
            b += x + y
        else
            a += x
            b += y
        end
    }
    puts "#{a} #{b}"
}

Measured memory_bytes: 6104
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>	tree_set;
typedef long long ll;
typedef long double ld;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

ll mod=1e9 + 7;

int main()
{
    fast();
    ll n,d;
    cin>>n>>d;
    ll ans = n/(2*d+1) + (n%(2*d+1)==0?0:1);
    cout<<ans;
}



Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
xi = gets.split.map(&:to_i).sort

if n >= m
    puts 0
    exit
end

d = []
for i in 0..(xi.length-2)
    d << (xi[i] - xi[i+1]).abs
end
d.sort!
puts d[0..(d.length-1-(n-1))].inject(:+)


Measured memory_bytes: 10736
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<int, int> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };


int main() {

	int a, b;
	cin >> a >> b;
	if (a == b) {
		cout << "Draw" << endl;
	}
	else if (a == 1) {
		cout << "Alice" << endl;
	}
	else if (b == 1) {
		cout << "Bob" << endl;
	}
	else if (a > b) {
		cout << "Alice" << endl;
	}
	else if (a < b) {
		cout << "Bob" << endl;
	}

	
	return 0;
}

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

int main(){
  int h,w,n;cin >> h >> w >> n;
  if(n%max(h,w)==0){
    cout << n/max(h,w) << endl;
  }else{
    cout << n/max(h,w)+1 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define fo(i,n)         for(i=0;i<n;i++)
#define Fo(i,k,n)       for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << "," << #y << "=" << y << endl
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int N = 1e5 + 5, M = N;
//=======================

vi g[N];
int dp[N][2];//1-black 0-white

void ipgraph(int n, int m) {
	int i, u, v;
	while (m--) {
		cin >> u >> v;
		u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par) {
	dp[u][1] = 1; dp[u][0] = 1;
	for (int v : g[u]) {
		if (v == par) continue;
		dfs(v, u);
		dp[u][1] = ((dp[u][1] % mod) * (dp[v][0] % mod)) % mod;
		dp[u][0] = ((((dp[v][1] % mod) + (dp[v][0] % mod)) % mod ) * (dp[u][0] % mod)) % mod;
	}
	// dp[u][1] = !dp[u][1] ? 1 : dp[u][1];
	// dp[u][0] = !dp[u][0] ? 1 : dp[u][0];
}

void solve() {
	int i, j, n, m;
	cin >> n;
	ipgraph(n, n - 1);
	dfs(0, -1);
	// fo(i, n) {
	// 	deb(i);
	// 	deb2(dp[i][0], dp[i][1]);
	// }b
	cout << (dp[0][1] % mod + dp[0][0] % mod) % mod << "\n";
}

int32_t main()
{
	FIO;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
	return 0;
}





Measured memory_bytes: 17512
const main = (inputs) => {
  var N = inputs[0]-0;
  var sum = 0;
  var line = inputs[1].split(" ").map(v=>{sum+=v-0; return v-0;});

  var ans = sum;
  var t_sum=0;
  for(var i=0;i<N;i++){
    t_sum += line[i];
    ans = Math.min(ans, Math.abs(t_sum-(sum-t_sum)));
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));


Measured memory_bytes: 11468
// inputに入力データ全体が入る
function Main(input) {
	if(input[2] === input[3] && input[4] === input[5]) {
    console.log('Yes');
  } else {
    console.log('No');
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 22080
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

bool tf(string s, int l, int r){
	l--;
	r--;
	for(int i=0;l+i<=r-i;i++)
		if(s[l+i]!=s[r-i])
			return false;

	return true;
}

void solve(){
	int n;
	string s;
	cin>>s;
	n=s.size();
	if(tf(s,1,n) && tf(s,1,(n-1)/2) && tf(s,(n+3)/2,n))
		cout<<"Yes\n";
	else
		cout<<"No\n";
}

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

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<utility>
#include<stdbool.h>
using namespace std;
typedef long long ll;
#define N (1000000000+7)

int main(void) {
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	if (n <= k)cout << x*n << endl;
	else cout << x*k + y*(n - k) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

const double PI=(acos(-1));

int main(){
    string s;
    cin>>s;
    int n=s.size();
    int cnt0=0,cnt1=0;
    rep(i,n){
        if(s[i]=='1')++cnt1;
        else ++cnt0;
    }
    int diff=abs(cnt1-cnt0);
    cout<<n-diff<<endl;
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    string x;
    cin >> x;

    i64 s = 0, t = 0;
    for (auto& e : x) {
        if (e == 'S') {
            s++;
        } else if (s == 0) {
            t++;
        } else {
            s--;
        }
    }

    cout << s + t << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 720
#include<cstdio>
using namespace std;
int main(void){
   int h1,m1,s1;
   int h2,m2,s2;
   int ah,am,as;
   for(int i = 0;i < 3;i++){
      scanf("%d%d%d%d%d%d",&h1,&m1,&s1,&h2,&m2,&s2);
      as = s2 - s1; if(as < 0){ m2 -= 1; as += 60;}
      am = m2 - m1; if(am < 0){h2 -= 1; am += 60;}
      ah = h2-h1;
      printf("%d %d %d\n",ah,am,as);
   }
}

Measured memory_bytes: 1028
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String S = scan.next();
        System.out.println(solve(S));
    }
    private static String solve(String S) {
        char[] list = S.toCharArray();
        int[] use_chars = new int[26];
        for (int i = list.length - 1; 0 <= i; i--) {
            use_chars[(int)list[i]-97] += 1;
        }
        if(list.length < 26) {
            for(int i = 0; i < 26; i++) {
                if(use_chars[i] == 0) {
                    return S + (char) (i+97);
                }
            }
        }
        for (int i = list.length - 1; 0 <= i; i--) {
            int current = list[i] - 97;
            for(int j = current + 1; j < 26; j++) {
                if(use_chars[j] == 0) {
                    return S.substring(0, i) + (char) (j+97);
                }
            }
            use_chars[current] -= 1;
        }
        return "-1";

    }

}


Measured memory_bytes: 25044
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define ft first
#define sd second
#define get(t, x) get<x>(t)
#define pb push_back
#define len length
#define dbgn(x) cerr << #x << ": " << x << '\n'
#define dbg(x) cerr << #x << ": " << x << ' '
#define MAX 1100000

using namespace std;
using namespace __gnu_pbds;

using lli = long long int;
using pll = pair<lli, lli>;
using pli = pair<lli, int>;
using pii = pair<int, int>;
using mii = map<int, int>;
using ti3 = tuple<int, int, int>;
using pqpi_min = priority_queue<pii, vector<pii>, greater<pii>>;
using ost = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T>
void print(T* a, int sz) {for(int i=0;i<sz;++i) cerr<<a[i]<<' ';cerr<<endl;}
istream &operator>>(istream &is, pii &p) {is >> p.ft >> p.sd;return is;}
ostream &operator<<(ostream &os, const pii &p) {os << "[" << p.ft << ", " << p.sd << ']'; return os;}
//int+string
//cin.ignore();

constexpr int M = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;

int b[MAX/10];
void solve()
{
    int n,h,mxa=0,i,a,ans=0;
    cin>>n>>h;
    for(i=0;i<n;++i) cin>>a>>b[i],mxa=max(mxa,a);
    sort(b,b+n);
    i=n-1;
    while(i>=0 && h>0 && b[i]>mxa) h-=b[i--],++ans;
    if (h>0) ans+=(h+mxa-1)/mxa;
    cout<<ans;
}   
int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    // freopen("inp.txt","r",stdin);
    solve();
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;


int main() {
    int n;
    cin >> n;
    int sequence[n];
    for (int i = 0; i < n; i++) {
        cin >> sequence[i];
    }
    for (int i = n - 1; i > 0; i--) {
        cout << sequence[i] << " ";
    }
    cout << sequence[0] << endl;
}

Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
using namespace std;
long long N, A;
int main() {
	cin >> N >> A;
	long long ret = N;
	for (int i = 2; i <= 40; i++) {
		bool flag = false;
		for (int j = 1; !flag; j++) {
			for (int k = i; k >= 1; k--) {
				long long mul = 1;
				for (int l = 0; l < k; l++) mul *= j;
				for (int l = k; l < i; l++) mul *= j + 1;
				if (mul >= N) {
					ret = min(ret, i * (j + 1) - k + 1LL * A * (i - 1));
					flag = true; break;
				}
			}
		}
	}
	cout << ret << endl;
	return 0;
}

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

s = []

for i in range(H):

    S = list(input())
    s.append(S)

dis = [[float("inf")] * W for i in range(H)]

if s[0][0] == "#":
    dis[0][0] = 1
else:
    dis[0][0] = 0

for i in range(H):

    for j in range(W):

        if i != H-1:

            if s[i][j] == "." and s[i+1][j] == "#":

                dis[i+1][j] = min(dis[i][j] + 1,dis[i+1][j])

            else:
                dis[i+1][j] = min(dis[i][j],dis[i+1][j])

        if j != W-1:
            if s[i][j] == "." and s[i][j+1] == "#":

                dis[i][j+1] = min(dis[i][j] + 1,dis[i][j+1])

            else:
                dis[i][j+1] = min(dis[i][j],dis[i][j+1])

print (dis[-1][-1])


Measured memory_bytes: 43760
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
#define INF -99999999 
using namespace std;
 
int main(){
    ll N;
    string S;
    cin >> N >> S;
    ll a,b,c;
    a = b = c = 0;
    for (int i = 0; i < N; i++)
    {
        if(S[i] == 'R') a++;
        else if(S[i] == 'G') b++;
        else c++;
    }
    ll ans = a*b*c;
    for (ll i = 0; i < N; i++)
    {
        for (ll j = i+1; j < N; j++)
        {
            ll k = 2*j-i;
            if(k >= N) continue;
            else if(S[i] != S[j] && S[i] != S[k] && S[k] != S[j]) ans -= 1;
        }
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;

int N;

int main(){
    cin>>N;

    cout<<((N-1)/1000+1)*1000-N<<endl;
}

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

int main()
{
    int N;
    cin >> N;
    vector<pair<int, int>> A(N);
    rep(i, N) {
        int a;
        cin >> a;
        A[i] = make_pair(i, a);
    }

    sort(A.begin(), A.end(), [](pair<int, int> x, pair<int, int> y){return x.second > y.second;});

    for (int i = 0; i < N; i++) {
        if (A[0].first == i) cout << A[1].second << endl;
        else cout << A[0].second << endl;
    }


    return 0;
}

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

// input
int N;
vector<int> L, R;


void input() {
    cin >> N;
    L = R = vector<int>(N);
    rep(i, N) cin >> L[i] >> R[i];
}


int main() {
    input();
    int ans = 0;
    rep(i, N) ans += R[i] - L[i] + 1;
    cout << ans << endl;
}


Measured memory_bytes: 3572
#include <stdio.h>
#include <string.h>
#include <queue>

using namespace std;
const int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

int main(void){
	queue<int> qx, qy;
	int x, y, i, j, w, h, flag[20][20], count;
	char field[20][21];
	while(1){
		scanf("%d%d%*c",&w,&h);
		if(w == 0 && h == 0)
			break;
		memset(flag,0,sizeof(flag));
		for(i = 0;i < h;i++){
			for(j = 0;j < w;j++){
				field[i][j] = getchar();
				if(field[i][j] == '@')
					y = i, x = j;
			}
			getchar();
		}
		qx.push(x);
		qy.push(y);
		while(qx.size()){
			x = qx.front();
			y = qy.front();
			qx.pop();
			qy.pop();
			flag[y][x] = 1;
			for(i = 0;i < 4;i++){
				if(x + dx[i] >= 0 && x + dx[i] < w && y + dy[i] >= 0 && y + dy[i] < h && !flag[y + dy[i]][x + dx[i]] && field[y + dy[i]][x + dx[i]] == '.')
					qx.push(x + dx[i]), qy.push(y + dy[i]);
			}
		}
		count = 0;
		for(i = 0;i < h;i++){
			for(j = 0;j < w;j++)
				if(flag[i][j]) count++;
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 3912
from decimal import Decimal
'''
def main():
    a, b = input().split(" ")
    a = int(a)
    b = Decimal(b)
    print(int(a*b))
   '''
def main():
    a, b = input().split(" ")
    a = int(a)
    b = int(b.replace(".","") )
    print(a*b // 100)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9908
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );

		while(str.contains("ST")){
			if(str.indexOf("T")>str.length()/2-1){
				str = "";
			}else{
				str = str.replace("ST", "");
			}
		}

		System.out.println(str.length());

	}
}


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

int main () {
    int H,W;
    cin >> H >> W;
    char mat[H][W];
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> mat[i][j];
        }
    }

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cout << mat[i][j];
        }
        cout << '\n';
        for(int j=0; j<W; j++){
            cout << mat[i][j];
        }
        cout << '\n';
    }
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <stdio.h>
#include <string>

using namespace std;

int main()
{
    // int型の2次元配列(3×4要素の)の宣言
    vector<vector<int>> A(3, vector<int>(3));
    vector<vector<int>> Open(3, vector<int>(3));

    // 入力 (2重ループを用いる)
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> A.at(i).at(j);
        }
    }
    int N;
    cin >> N;
    vector<int> B(N);
    for (int k = 0; k < N; k++) {
        cin >> B.at(k);
    }
    for (int x = 0; x < N; x++) {
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if(B.at(x) == A.at(i).at(j)) {
                    Open.at(i).at(j) = 1 ;
                }
            }
        }
    }
    string Ans = "No";
    for (int i = 0; i < 3; i++) {
        if(Open.at(i).at(0) * Open.at(i).at(1) * Open.at(i).at(2) != 0){
            Ans = "Yes";
        }
    }
    for (int i = 0; i < 3; i++) {
        if(Open.at(0).at(i) * Open.at(1).at(i) * Open.at(2).at(i) != 0){
            Ans = "Yes";
        }
    }

    if(Open.at(0).at(0) * Open.at(1).at(1) * Open.at(2).at(2) != 0){
        Ans = "Yes";
    }
    if(Open.at(0).at(2) * Open.at(1).at(1) * Open.at(2).at(0) != 0){
        Ans = "Yes";
    }
    cout << Ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  int a = 1;
  
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  for (int i = 0; i < N + 1; i++) {
    a = vec.at(a - 1);
    if (a == 2) {
      a = i + 1;
      cout << a << endl;
      a = -1;
      break;
    }
  }    
  if (a != -1) 
    cout << -1 << endl;
}

Measured memory_bytes: 3764
#include<iostream>
#include<queue>
#include<algorithm>
#include<numeric>
#include<string>
#include<map>

using namespace std;
using int_greater_PQ = priority_queue<int,vector<int>,greater<int>>;

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

    int_greater_PQ A;
    for (size_t i = 0; i < N; i++)
    {
        int a;
        cin>>a;
        A.push(a);
    }

    multimap<int,int,greater<int>> BC;
    for (size_t i = 0; i < M; i++)
    {
        int B,C;
        cin>>B>>C;
        BC.emplace(C,B);
    }

    for (const auto& bc:BC)
    {
        int C=bc.first,B=bc.second;

        while (B>0)
        {
            if(C> A.top())
            {
                A.pop();
                A.push(C);
            }
            else
            {
                goto KIRISUTE;
            } 
            --B; 
        }       
    }
    KIRISUTE:

    long ans = 0;
    while (!A.empty())
    {
        ans+=A.top();
        A.pop();
    }
    

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 8308
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> lp;
typedef pair<ll,pair<ll,ll>> lpp;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
まっすぐk個まで進める：曲がったタイミングで精算

6 7 3
6 2 6 7
.@.@...
.@...@.
...@.@.
..@....
.@..@@@
..@....
*/

ll h,w,k,x3,x2,y3,y2,ans=1e18;
priority_queue<lp, vector<lp>, greater<lp> > qu;
ll dx[]={0,0,1,-1},dy[]={1,-1,0,0};


int main(void){
	cin>>h>>w>>k;
	cin>>x3>>y3>>x2>>y2;
	x3--;
	y3--;
	x2--;
	y2--;
	vector<string> s(h);
	vector<vector<vector<ll>>> d(h, vector<vector<ll>>(w, vector<ll>(4, 1e18)));
	rep(i,h)cin>>s[i];
	d[x3][y3][0]=0;
	qu.push({0, (w*x3 + y3)*4 + 0});
	while(!qu.empty()){
		auto a = qu.top();qu.pop();
		ll cur=a.second;
		ll x=a.second/4/w, y=(a.second/4)%w, v=a.second%4;
		rep(i,4){  // 向きを変える
			if(d[x][y][i] > (d[x][y][v] + k - 1) / k * k){  // 切り上げ
				d[x][y][i] = (d[x][y][v] + k - 1) / k * k;
				qu.push({d[x][y][i], (x*w+y)*4+i});
			}
		}
		ll xx=x+dx[v], yy=y+dy[v];
		if(0<=xx && xx<h && 0<=yy && yy<w &&
		d[xx][yy][v] > d[x][y][v] + 1 && s[xx][yy]!='@'){
			d[xx][yy][v] = d[x][y][v] + 1;
			qu.push({d[xx][yy][v], (xx*w+yy)*4+v});
		}
	}
	bool ok=false;
	rep(i,4){
		if(d[x2][y2][i]!=1e18){
			ok=true;
			ans=min(ans, (d[x2][y2][i] + k - 1) / k);  // ここ1e18にならないので注意（横着はできない）
		}
	}
	cout<<(ok? ans : -1)<<endl;
	return 0;
}

Measured memory_bytes: 143952
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	int N;
	cin >> N;
	string ans = "No";
	for (int cake = 0; cake <= 25; cake++) {
		for (int donut = 0; donut <= 14; donut++) {
			if (4 * cake + 7 * donut == N) ans = "Yes";
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3620
/* Stay hungry, stay foolish. */
/* Copyright by HenryLi */
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<sstream>
#include<stack>
#include<ctime>
#include<cmath>
#include<cctype>
#include<climits>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<iomanip>
#include<bitset>
#include<complex>
using namespace std;
template <class _T> inline void read(_T &_x) {
	int _t; bool _flag=false;
	while((_t=getchar())!='-'&&(_t<'0'||_t>'9')) ;
	if(_t=='-') _flag=true,_t=getchar(); _x=_t-'0';
	while((_t=getchar())>='0'&&_t<='9') _x=_x*10+_t-'0';
	if(_flag) _x=-_x;
}
typedef long long LL;
int main() {
	//freopen("fuck.in","r",stdin);
	//freopen("fuck.out","w",stdout);
	multiset<string> s;
	int a, b, c;
	read(a), read(b), read(c);
	for (int i = 1; i <= a; ++i) s.insert("a");
	for (int i = 1; i <= b; ++i) s.insert("b");
	for (int i = 1; i <= c; ++i) s.insert("c");
	while (s.size() > 1) {
		string t = *s.begin() + *--s.end();
		s.erase(s.begin()), s.erase(--s.end());
		s.insert(t);
	}
	cout << *s.begin() << endl;
	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
as = gets.chomp.split.map(&:to_i)
x = Hash.new(0)
s = 0

as.each do |i|
  x[i] += 1
end

x.each_value do |i|
  s += (i)*(i-1)/2
end

as.each do |i|
  minus = ((x[i]*(x[i]-1))-((x[i]-1)*(x[i]-2)))/2
  puts s-minus
end

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

int main(){
  int N;
  cin >> N;
  int V[N],C[N];
  int ans = 0;
  for(int i = 0;i < N;i++){
    cin >> V[i];
  }
  for(int i = 0;i < N;i++){
    cin >> C[i];
  }
  for(int i = 0;i < N;i++){
    int temp = V[i] - C[i];
    if(temp > 0)
      ans += temp;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 367
#define INF 100000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;
int main(){
    int x,y,z;
    cin>>x>>y>>z;
    OUT(z);
    OUT(x);
    OUT(y);
    return 0;
}

Measured memory_bytes: 256
/***
        ***Fresher***
    Md Mahfujur Rahman Khan
    Dept. of CSE
    CSE-28 Batch
    JU-48 Batch
    Jahangirnagar University

***/
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<climits>
#include<numeric>
#include<utility>
using namespace std;
#define V_ vector
#define Q_ queue
#define S_ set
#define ST_ stack
#define M_ map
#define DQ_ deque
/***PAIR***/
#define pii pair<ll,ll>
#define pci pair<char,ll>
#define psi pair<string, ll>
#define pis pair<ll,string>
#define pic pair<ll, char>
/***MAP***/
#define mii map<ll,ll>
#define msi map<string, ll>
#define mis map<ll, string>
#define mib map<ll,bool>
#define msb map<string,bool>
#define mci map<char, ll>
/***VECTOR***/
#define vi vector<ll>
#define vs vector<string>
/***ITERASTORS***/
#define ivi vector<ll> :: iterator
#define ivs vector<string> :: iterator
#define imii map<ll,ll> :: iterator
#define imsi map<string,ll> :: iterator
#define imis map<ll, string> :: iterator
#define imib map<ll, bool> :: iterator
#define imsb map<string, bool> :: iterator
#define imci map<char, ll> :: iterator
/*** FAST ***/
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/***FUNCTIONS AND MACROS***/
#define F first
#define S second
#define M_P(x, y) make_pair(x, y)
#define PB(x) push_back(x)
#define PP(x) push(x)
#define RSZ(n) resize(n)
#define POB pop_back()
#define P_ pop()
#define CL_ clear()
#define LEN_ length()
#define SZ_ size()
#define CNT(x) count(x)
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
#define B_ begin()
#define E_ end()
#define F_ front()
#define t_ top()
#define IN_ insert
#define ER_  erase
#define GT(x) getline(cin , x)
#define NL_   "\n"
#define SP_ " "
#define R_0 return 0
#define R_ return

#define ul unsigned long long int
#define ll long long int
/***
//prime fact
#define most_prime_loop 10001
#define most_prime_number 20000010
#define prime_MAX_arr 20000010/2
ll PRIME[prime_MAX_arr];
void seive()
{
    PRIME[0] = 0;
    for(auto &x: PRIME )
        x = 1;
    for(ll i= 3; i <= most_prime_loop; i+=2)
    {
        for(ll j = i*i; j <= most_prime_number; j+=2*i)
            PRIME[j/2] = 0;
    }
}
***/
#define fr(i, n) for( ll i = 0; i < n; i++)
#define fe(x, n) for( ll i = x; i <= n; i++)
#define fa(x,a)    for(auto &x : a)

#define pi acos(-1)

#define SR(x) sqrt(x)
#define IC   (ll)

const ll  inf = 1000000000;
ll i=0, T=0, N=0, tc =0, t= 0;
ll n=0, k=0;

int main()
{
    ll n;
    cin >> n;
    ll arr[n];
    fa(x, arr) cin >> x;
    sort(arr, arr+n, greater<ll>());
    ll a, b;
    a = b =0;
    for(ll i=0; i < n; i++)
    {
        if(!(i%2)) a += arr[i];
        else b+=arr[i];
    }
    cout << a - b;


    R_0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n,k,p[1000],l,r=0;
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++)scanf("%d",&p[i]);
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(p[i]>p[j]){
                l=p[i];
                p[i]=p[j];
                p[j]=l;
            }
        }
    }
    for(int i=0;i<k;i++)r+=p[i];
    printf("%d\n",r);
    return 0;
}

Measured memory_bytes: 1712
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}

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

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

long long L[87];

int main(void) {

	int N;
	cin >> N;

	L[0] = 2;
	L[1] = 1;
	for (int i = 2; i <= N; i++) {
		L[i] = L[i-1] + L[i-2];
	}
	cout << L[N] << endl;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
#define ll long long
using namespace std;
int main(){
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256