akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll H,W,h,w;
    cin>>H>>W>>h>>w;
    ll s[H][W];
    ll cnt=-h*w;
    rep(i,H){
        rep(j,W){
            if((i+1)%h==0&&(j+1)%w==0) s[i][j]=-1000000000;
            else{
                s[i][j]=1000000000/(h*w-1);
                if(i%h==0&&j%w==0){
                    ll x=1000000000%(h*w-1);
                    x--;
                    s[i][j]+=x;
                }
            }
        }
    }
    ll c=0;
    rep(i,H){
        rep(j,W) c+=s[i][j];
    }
    if(c>0){
        cout<<"Yes"<<endl;
        rep(i,H){
            rep(j,W) cout<<s[i][j]<<' ';
            cout<<'\n';
        }
    }else cout<<"No"<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え(=でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
*/

Measured memory_bytes: 4864
N = int(input())
h = list(map(int, input().split()))

dp = [0] * N
dp[0] = 0
dp[1] = abs(h[1]-h[0])

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

print(dp[-1])

Measured memory_bytes: 13980
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

ll R,G;

void solve(){
    cout << 2*G - R << endl;
}

int main(){
    cin >> R >> G;

    solve();
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int x1 = in.nextInt();
			int y1 = in.nextInt();
			int x2 = in.nextInt();
			int y2 = in.nextInt();

			int dx = x2-x1;
			int dy = y2-y1;

			int x3 = x2 - dy;
			int y3 = y2 + dx;
			int x4 = x3 - dx;
			int y4 = y3 - dy;

			out.printf("%d %d %d %d\n", x3, y3, x4, y4);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

	static long max(long... n) {
		long ret = n[0];
		for (int i = 0; i < n.length; i++) {
			ret = Math.max(ret, n[i]);
		}
		return ret;
	}

	static int max(int... n) {
		int ret = n[0];
		for (int i = 0; i < n.length; i++) {
			ret = Math.max(ret, n[i]);
		}
		return ret;
	}

	static long min(long... n) {
		long ret = n[0];
		for (int i = 0; i < n.length; i++) {
			ret = Math.min(ret, n[i]);
		}
		return ret;
	}

	static int min(int... n) {
		int ret = n[0];
		for (int i = 0; i < n.length; i++) {
			ret = Math.min(ret, n[i]);
		}
		return ret;
	}

}


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

int N;
vector<int> A;

int solve();

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

  solve();

  return 0;
}

int solve(){
  double low = 0.0;
  for(int i = 0; i< N;i++){
    low += 1.0 /A.at(i);
  }
  cout << 1.0 / low << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lowbit(i) ((i)&-(i)) 

using namespace std;

int n,bit[100100];

void add(int i,int x)
{
	while(i<=n)
	{
		bit[i]+=x;
		i+=lowbit(i);
	}
}

int sum(int x)
{
	int s=0;
	while(x>0)
	{
		s+=bit[x];
		x-=lowbit(x);
	}
	return s;
}

int main()
{
	int q;
	scanf("%d%d",&n,&q);
	memset(bit,0,sizeof(bit));
	for(int i=0;i<q;i++)
	{
		int com,x,y;
		scanf("%d%d%d",&com,&x,&y);
		if(com==0) add(x,y);
		else printf("%d\n",sum(y)-sum(x-1));
	}
	return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
ll umin(ll a ,ll b)
{
	if(a>b)return b;return a;
}
int main()
{
	ll n,k;cin >> n;cin >> k;
	if(n==1)
		return cout << 0,0;
	ll a[n];ll b[n];
	for(ll i=0;i<n;i++)
	{
		cin >> a[i];b[i]=1e17;
	}b[0]=0;
	b[1]=abs(a[0]-a[1]);
	for(ll i=2;i<n;i++)
	{
		for(ll j =1;j<=umin(i,k);j++)
		b[i]=umin(b[i],b[i-j]+abs(a[i]-a[i-j]));
	}cout << b[n-1];
	//for(ll i=0;i<n;i++)cout << b[i] << " " ;
	return 0;
}

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

int main()
{
    long long int N;
    long long int K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        A[i]--;
    }
    vector<int> seen(N, false);
    int now = 0;
    vector <int> path;
    while (seen[now] != true)
    {
        seen[now] = true;
        path.push_back(now);
        now = A[now];
    }
    long long int roop_num;
    int roop_start = find(path.begin(), path.end(), now) - path.begin();
    int roop = path.size() - roop_start;
    if(K < roop_start) {
        cout << path[K] + 1 << endl;
    } else {
        roop_num = (K - roop_start) % roop + roop_start;
        cout << path[roop_num] + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 5892
#include<bits/stdc++.h>
#define INF 2147483647
#define lli long long int
#define MOD 1000000007
#define pb push_back

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

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


int main() {
	
	int a,b; cin >> a >> b;
	int x,y;

	int d = extgcd(a,b,x,y);

	cout << x <<" "<< y << endl;


	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
// #include <numeric>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;

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

ll n, ans=0;

template<typename T>
map<T, ll> factoring(T x) {
	map<T, ll> res;
	for(ll i=2;i*i<=x;i++){
    	while(x%i==0){
			x/=i;
			res[i]++;
		}
	}
	if(x!=1) res[x]++;
	return res;
}

int main()
{
	FAST;

	cin >> n;
	vector<ll> cnt(111,0);
	reps(i,n){
		for (auto p:factoring(i)) {
			cnt[p.first]+=p.second;
		}
	}

	if (cnt[2]>=74) ans++;

	for(int i=2;i<111;++i) {
		for(int j=2;j<111;++j)
			if (i!=j&&cnt[i]>=2&&cnt[j]>=24) ans++;
	}

	for(int i=2; i<111;++i){
		for(int j=0;j<111;++j)
			if(i!=j&&cnt[i]>=4&&cnt[j]>=14) ans++;
	}

	for (int i=2; i<111;++i)
		for (int j=2; j<111; ++j)
			for (int k=2; k<j; ++k)
				if(i!=j&&i!=k&&cnt[i]>=2&&cnt[j]>=4&&cnt[k]>=4) ans++;

	cout << ans << "\n";

	return 0;
}

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

int main() {
  long long N;
  cin >> N;
  
  long long A,B;
  for (long long i = 1; i <= sqrt(N) + 1; i++) {
    if (N % i == 0){
      A = i;
      B = N / i;
    }
  }
  cout << A + B - 2 << endl;
}
  

  
 



Measured memory_bytes: 3656
#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;
int main() {
	int w,n,c=1;
	while (scanf("%d",&w)) {
		if (w==0) break;
		scanf("%d",&n);
		int W[n],V[n];
		for (int i=0; i<n; i++) scanf("%d%*c%d",&V[i],&W[i]);
		int dp[n+1][w+1];
		int rw=1001,rv=0;
		for (int i=0; i<=w; i++) dp[n][i]=0;
		for (int i=n-1; i>=0; i--) {
			for (int j=0; j<=w; j++) {
				if (W[i]>j) dp[i][j]=dp[i+1][j];
				else {
					int r1=dp[i+1][j],r2=dp[i+1][j-W[i]]+V[i];
					if (r2>=r1) {
						if (rv<r2) {
							rv=r2;
							rw=j;
						} else if (rv==r2) {
							rw=min(rw,j);
						}
						dp[i][j]=r2;
					} else {
						dp[i][j]=r1;
					}
				}
			}
		}
		printf("Case %d:\n%d\n%d\n",c++,rv,rw);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv){
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	int n; cin >> n;
	vd a(n); rep(i,n) cin>> a[i];
	double s;
	rep(i,n) s+=1.0/a[i];
	out16(1.0/s);
}




Measured memory_bytes: 256
#include <stdio.h>
int main () {
  int N, D;
  scanf("%d%d", &N, &D);
  int ans = 0, k = N;
  for (int i = D + 1; i <= N; i += D + D + 1) {
    k = i;
    ans++;
  }
  if (ans == 0 || k + D < N) {
    ans++;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
    int a , b;
    cin >> a >> b;
    if (a < b){
        for (int i = 0 ; i < b ; i++)
            cout << a;
    }
    else{
        for (int i = 0 ; i < a ; i++)
        cout << b;
    }
    return 0;
}

Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.List

distance :: (Int,Int) -> (Int,Int) -> (Int,Int)
distance (x,y) (i,j) = (minimum [j-i,abs (x-i)+1+abs (y-j),abs (y-i)+1+abs (x-j)]-1,1)

main :: IO ()
main = do
    (n,x,y) <- (\vec -> (vec VU.! 0, vec VU.! 1, vec VU.! 2)) . VU.unfoldrN 3 readInt <$> BS.getLine
    VU.mapM_ print $ VU.accum (+) (VU.replicate (n-1) 0) [distance (x,y) (i,j) | i <- [1..n-1], j <- [i+1..n]]
    

readInt :: BS.ByteString -> Maybe (Int,BS.ByteString)
readInt xs = do
    (x,ys) <- BS.readInt xs
    return (x,BS.tail ys)

Measured memory_bytes: 2428
#include <utility>
#include <iostream>
#include <vector>
#include <deque>
#include <numeric>

using namespace std;

long long lcm(long long a, long long b){
    long long x, tmp, r;
    
    x = a * b;

    /* 自然数 a > b を確認・入替 */
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }

    /* ユークリッドの互除法 */
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
	
  	return (long long) x/b;
}

int main(void) {

    long long a, b, c, d;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;

    long long l = lcm(c, d);
    long long c_num = (b/c) - ((a-1)/c);
    long long d_num = (b/d) - ((a-1)/d);
    long long l_num = (b/l) - ((a-1)/l);
    long long ans = (b - a + 1) - c_num - d_num + l_num;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   /// https://ideone.com/Fd5s8n

   ll x;
   cin>>x;
   ll a[4000];
   a[0]=100;
   for(int i=1;;i++){
    a[i]=a[i-1]+a[i-1]/100;
    if(a[i]>=x){
        cout << i << endl;
        return 0;
    }
   }
    return 0;

}


Measured memory_bytes: 3620
n, m = gets.split.map(&:to_i)
p = []
y = []
pi = Hash.new{|h,k| h[k] = []}
m.times do
  pp, yy = gets.split.map(&:to_i)
  p << pp
  y << yy
  pi[pp] << yy
end

yh = Hash.new{}
pi.keys.each do |k|
  pi[k].sort!
  pi[k].each_with_index do |yy, i|
    yh[yy] = i+1
  end
end

m.times do |i|
  pp = p[i]
  yy = y[i]
  o = yh[yy]
  puts "%06d%06d" % [pp, o]
end


Measured memory_bytes: 25340
str = gets.chomp
q = gets.to_i

ARGF.each_line do |line|
  op, a, b, p = line.chomp.split
  a = a.to_i
  b = b.to_i
  str_length = str.length
  
  case op
  when "print"
    puts str.slice(a..b)
  when "reverse"
    str = str.slice(0...a) + str.slice(a..b).reverse + str.slice((b+1)..str_length)
  when "replace"
    str = str.slice(0...a) + p + str.slice(b+1..str_length)
  end
end

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    clock_t start = clock();
    ll D;
    cin >> D;
    vector<ll> C(26);
    rep(i, 26) cin >> C[i];
    vector<vector<ll>> S(D, vector<ll>(26));
    rep(i, D) {
        rep(j, 26) {
            cin >> S[i][j];
        }
    }
    vector<ll> T(D);

    rep(i, D) {
        ll r = rand() % 26;
        T[i] = r + 1;
    }
    vector<ll> last(26, 0);

    ll sum = 0;
    auto f = [&] {
        sum = 0;
        last.assign(26, 0);
        rep(d, D) {
            ll t = T[d];
            sum += S[d][t - 1];
            last[t - 1] = d + 1;
            rep(i, 26) {
                sum -= C[i] * ((d + 1) - last[i]);
            }
        }
        return sum;
    };
    ll ans = -INF;
    clock_t end = clock();
    double time = (end - start) / 1000;
    while (time <= 1980) {
        ll r = rand() % 23;
        r++;
        ll d = rand() % 365;
        ll old = T[d];
        T[d] = r;
        ll res = f();
        if (res > ans) {
            ans = res;
        }else {
            T[d] = old;
        }
        // cout << ans << '\n';
        end = clock();
        time = (end - start) / 1000;
    }
    // cout << time << '\n';
    rep(d, D) {
        cout << T[d] << '\n';
    }
}

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


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

using namespace std;

int N;
int dp[100000];

int main()
{
	cin >> N;
	dp[0] = 0;
	for (int i = 1; i < N + 1; i++) {
		dp[i] = dp[i-1] + 1;
		for (int j = 6; i - j >= 0; j *= 6) {
			if (dp[i-j] + 1 < dp[i]) {
				dp[i] = dp[i-j] + 1;
			}
		}
		for (int j = 9; i - j >= 0; j *= 9) {
			if (dp[i-j] + 1 < dp[i]) {
				dp[i] = dp[i-j] + 1;
			}
		}
	}
	for (int i = N; i <= N; i++)
	cout << dp[i] << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
#define ll long long
using namespace std;
 
int main(){
int x;
cin>>x;
if(x>=400&&x<=599)cout<<"8";
if(x>=600&&x<=799)cout<<"7";
if(x>=800&&x<=999)cout<<"6";
if(x>=1000&&x<=1199)cout<<"5";
if(x>=1200&&x<=1399)cout<<"4";
if(x>=1400&&x<=1599)cout<<"3";
if(x>=1600&&x<=1799)cout<<"2";
if(x>=1800&&x<=1999)cout<<"1";
 
 
 
 
 
return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int D; cin >> D;
    vector<int> c(27);
    for (int i = 1; i < 27; i++) {
        cin >> c[i];
    }

    vector<vector<int>> s(D+1, vector<int> (27));
    for (int i = 1; i < D+1; i++) {
        for (int j = 1; j < 27; j++) {
            cin >> s[i][j];
        }
    }

    vector<int> t(D+1);

    ll score = 0;
    vector<int> last(27, 0);
    int M;
    int MJ;
    for (int i = 1; i < D+1; i++) {
        M = 0;
        for (int j = 1; j < 27; j++) {
            if(s[i][j] + c[j] * (i-last[j]) > M){
                M = s[i][j] + c[j] * (i-last[j]);    
                MJ = j;
            }
        }
        t[i] = MJ;
        score += s[i][MJ];
        last[MJ] = i;
        for (int j = 1; j < 27; j++) {
            score -= c[j] * (i - last[j]);
        }
    }
    
    //ここまでが貪欲解の導出
    //ここから微調整

    // そのコンテストが開催された日の集合
    vector<set<int>> day(27, set<int> ());
    for (int i = 1; i < D+1; i++) {
        day[t[i]].insert(i);
    }
    for (int i = 1; i < 27; i++) {
        day[i].insert(0);
        day[i].insert(D+1);
    }

    //更新作業
    //i回目の更新では、i%D日目の開催をt[i%D]+7i%26に変更し、差分が正だったら更新
    int CNT = 5000000;
    int dd, qq;
    int d1, d2;
    auto itr1 = day[1].lower_bound(0);
    dd = 1;
    ll diff;
    for (int i = 0; i < CNT; i++) {
        diff = 0;
        
        day[t[dd]].erase(dd);

        qq = rand() % 26 + 1;

        diff += s[dd][qq];
        diff -= s[dd][t[dd]];
        
        itr1 = day[qq].lower_bound(dd);
        d2 = *itr1;
        itr1--;
        d1 = *itr1;
        diff += c[qq] * (dd - d1) * (d2 - dd);

        itr1 = day[t[dd]].lower_bound(dd);
        d2 = *itr1;
        itr1--;
        d1 = *itr1;
        diff -= c[t[dd]] * (dd - d1) * (d2 - dd);

        //差分が正なら更新
        if(diff > 0){
            // tとsetを更新
            t[dd] = qq;
            day[qq].insert(dd);
        }
        else{
            day[t[dd]].insert(dd);
        }

        //ddを更新
        dd++;
        if(dd == D+1) dd = 1;

    }
    for (int i = 1; i < D+1; i++) {
        printf("%d\n", t[i]);
    }

}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define F first
#define S second
int dy[]={0,0,1,-1,1,-1,1,-1};
int dx[]={1,-1,0,0,1,-1,-1,1};

signed main(){
  int n,a,b;
  cin>>n>>a>>b;
  cout<<min(a*n,b)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

typedef long long int64;



int main() {
    int n,k,r,s,p;
    int64 ans = 0;
    string t;

    cin >> n >> k;
    cin >> r >> s >> p;
    cin >> t;

    map<char, int64> win;
    win['r'] = p;
    win['p'] = s;
    win['s'] = r;


    vector<vector<int64>> dp(n+1, vector<int64> (3, 0));

    for (int i=0; i<n; i++) {
        if (i < k) ans += win[t[i]];
        else if (t[i-k] != t[i]) ans += win[t[i]];
        else t[i] = '-';
    }

    cout << ans << endl;
}

Measured memory_bytes: 5824
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int ans = 0;
    
    if(A == B && B == C){
      ans = 1;
    }else if(A == B || B == C || C == A){
      ans = 2;
    }else{
      ans = 3;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
int a,b;
string s,t,u;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>s>>t>>a>>b>>u;
	if(u==s)
		cout<<a-1<<' '<<b<<endl;
	else
		cout<<a<<' '<<b-1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <string>
#include <sstream>
#include <iomanip>
#include <functional>

using namespace std;

int main() {

    int k,t;
    int sum=0;
    std::cin >> k >> t ;
    vector<int> a(t);
    for (size_t i = 0; i < t; i++) {
      std::cin >> a[i];
      if (2*a[i]-1>k) {
        sum+=2*a[i]-1-k;
      }
    }
    std::cout << sum << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include  <iostream>
#include <cstring>
#include <cstdlib>


using namespace std;

long long int power(int x,int n){
  long long int out = 1;
  for(int i=0;i<n;i++){
    out *= x;
  }
  return out;
}

int main(){
  string N;
  cin >> N;
  int dig_num  = strlen(N.c_str());
  int n = 0;
  //cout << strlen(N.c_str()) << endl;
  if(dig_num %2 == 0){
    n = dig_num -1;
    n = n/2 + n%2;
    cout << (power(100,n) - 1 )/99 * 9 << endl;
    return 0;
  }else{
    n = dig_num - 2;
    n = n/2 + n%2;
    int cmp = 0;
    int N_int = atoi(N.c_str());
    cmp = N_int - power(10,dig_num-1) + 1;
    cout << (power(100,n) - 1)/99*9 + cmp << endl;
  }
  return 0;
}

Measured memory_bytes: 256
package main

import(
    "fmt"
)

func main() {
    var n int
    fmt.Scan(&n)
    word := "No"
    for i:=1;i<=9;i++ {
        for j:=i;j<=9;j++ {
            if n == i*j {
                word = "Yes"
            }
        }
    }

    fmt.Println(word)
}


Measured memory_bytes: 512
using System;
class aoj
{
    static void Main()
    {
        while (true)
        {
            string a = Console.ReadLine();
            if (String.IsNullOrEmpty(a)) break;
            string[] b = a.Split(' ');
            double[] c = new double[8];
            for(int i = 0; i < 8; i++)
            {
                c[i] = double.Parse(b[i]);
            }
            if (c[1] >= c[5] && c[1] <= c[7]|| c[3] >= c[5] && c[3] <= c[7]||c[1]<=c[5]&&c[7]<=c[3])
            {
                if (c[0] >= c[4] && c[0] <= c[6] || c[2] >= c[4] && c[2] <= c[6] || c[0] <= c[4] && c[6] <= c[2])
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
            else
                Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 9188
#include<bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
int n;
vector<int> L(2005);
int BS(int a,int b){
    int l=0,r=n-1;
    while(r-l>1){
        if(L.at(a)+L.at(b)<=L.at((l+r)/2)){
          r=(l+r)/2;
        }
        else l=(l+r)/2;
    }
    if(L.at(a)+L.at(b)>L.at(n-1)) return n-1;
    else return l;
}
int main(){
    cin >> n;
    rp(i,n) cin >> L.at(i);
    auto ite=L.begin();
    sort(ite,ite+n);
    int ctr=0;
    rp(i,n-2){
        for(int j=i+1; j<n-1; j++){
            ctr+=BS(i,j)-j;
        }
    }
    cout << ctr << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int sum=0;
    char x;
    while(1){
        scanf("%c", &x);
        if(x=='\n'){
            break;
        }
        sum=sum+(x-48);
    }
    if(sum%9==0){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;

}

Measured memory_bytes: 1576
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>
#define REP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >
#define init(a,b) memset((a), (b), sizeof((a)))
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;


template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
typedef pair<int,int> pii;

inline bool IN(int x, int y, int w, int h)
{
    return 0 <= x && x < w && 0 <= y && y < h;
}


int main()
{

	vi l;
	rep(i,10){
		int tmp;
		cin >> tmp;
		l.pb(tmp);
	}
	sort(l.begin(),l.end(),greater<int>());
	cout << l[0] << endl;
	cout << l[1] << endl;
	cout << l[2] << endl;

	return 0;
}

Measured memory_bytes: 1220
n = int(input())
a_lst = list(map(int, input().split()))

cnt = 0
for a in a_lst:
  if a % 4 == 0:
    cnt += 2
  elif a % 2 == 0:
    cnt += 1
  else:
    pass

if cnt // 2 >= n // 2:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 20108
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int D;
    cin >> D;
    vector<int>c(26);
    for(int i = 0; i < 26; i++) {
        cin >> c[i];
    }
    vector<vector<int>>s(D,vector<int>(26));
    for(int i = 0; i < D; i++) {
        for(int j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    vector<int>t(D);
    for(int i = 0; i < D; i++) {
        t[i] = rand()%26+1;
    }
    int ans = 0;
    vector<int>Last(26);
    for(int i = 0; i < D; i++) {
        ans+=s[i][t[i]-1];
        Last[t[i]-1] = i+1;
        for(int j = 0; j < 26; j++) {
            ans-=c[j]*(i+1-Last[j]);
        }
    }
    int Z = 1000;
    for(int i = 0; i < Z; i++) {
        int d = rand()%D+1;
        int q = rand()%26+1;
        int ord = ans;
        int X = 0;
        int Y = 0;
        int A = 0;
        int B = 0;
        ans+=s[d-1][q-1]-s[d-1][t[d-1]-1];
        for(int j = 0; j < D; j++) {
            if(t[j] == t[d-1]) {
                if(j == d-1) {
                    Y = j+1;
                }
                else {
                    X = j+1;
                }
                A = j+1;
            }
            if(t[j] == q) {
                Y = j+1;
                B = j+1;
            }
            ans-=c[t[d-1]-1]*(j+1-X)-c[t[d-1]-1]*(j+1-A);
            ans+=c[q-1]*(j+1-B)-c[q-1]*(j+1-Y);
        }
        if(ans < ord) {
            ord = ans;
            t[d-1] = q;
        }
        else {
            ans = ord;
        }
    }
    int M = 3000000;
    for(int i = 0; i < M; i++) {
        int d = rand()%D+1;
        int q = rand()%26+1;
        int ord = ans;
        int X = 0;
        int Y = 0;
        int A = 0;
        int B = 0;
        ans+=s[d-1][q-1]-s[d-1][t[d-1]-1];
        for(int j = 0; j < D; j++) {
            if(t[j] == t[d-1]) {
                if(j == d-1) {
                    Y = j+1;
                }
                else {
                    X = j+1;
                }
                A = j+1;
            }
            if(t[j] == q) {
                Y = j+1;
                B = j+1;
            }
            ans-=c[t[d-1]-1]*(j+1-X)-c[t[d-1]-1]*(j+1-A);
            ans+=c[q-1]*(j+1-B)-c[q-1]*(j+1-Y);
        }
        if(ans > ord) {
            ord = ans;
            t[d-1] = q;
        }
        else {
            ans = ord;
        }
    }
    for(int i = 0; i < D; i++) {
        cout << t[i] << endl;
    }
}



Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  vector<P> a(n);
  rep(i,n) {
    cin >> a[i].second >> a[i].first;
  }
  sort(all(a));
  ll sum = 0;
  bool ok = true;
  rep(i,n) {
    sum += a[i].second;
    debug(a[i].first, a[i].second, sum);
    if (a[i].first < sum) {
      ok = false; break;
    }
  }
  auto yes = [&]() {
    cout << "Yes\n";
  };
  auto no = [&]() {
    cout << "No\n";
  };
  if (ok) yes();
  else no();
  return 0;
}

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

using namespace std;

struct Tag {
    int amount;
    int cost;
    Tag(int a, int c) : amount(a), cost(c) {}
};
Tag BASE[] = {
    Tag(2, 380), Tag(3, 550), Tag(5, 850),
    Tag(2*5, 380*5*80/100), Tag(3*4, 550*4*85/100), Tag(5*3, 850*3*88/100)
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    while(true) {
        int N;
        cin >> N;
        if(!N) break;
        vector<int> dp(N/100 + 1, INT_MAX/2);
        dp[0] = 0;
        for(int i = 0; i <= N/100; ++i) {
            for(int j = 0; j < 6; ++j) {
                int prev = i - BASE[j].amount;
                if(prev >= 0) {
                    dp[i] = min(dp[i], dp[prev] + BASE[j].cost);
                }
            }
        }
        cout << dp[N/100] << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
N, M = map(int, input().split())
switches_bulbs_connection = {}

for i in range(M):
    switches_bulbs_connection[i] = list(map(int, input().split()))[1:]
p = list(map(int, input().split()))
count = 0
flag = 0

for i in range(2 ** N):  # スイッチのon/offについてビット全探索
    switch_on_off = [0] * N
    bulb_stat = [0] * M
    for j in range(N):
        if (i >> j) & 1:
            switch_on_off[j] += 1  # 各スイッチがonかoffか
    for k in range(M):  # 電球kについて調べる
        tmp = switches_bulbs_connection[k]
        for switch in tmp:
            if switch_on_off[switch-1]:
                bulb_stat[k] += 1
    for l in range(M):
        if bulb_stat[l] % 2 == p[l]:
            flag += 1
    if flag == M:
        count += 1
    flag = 0

print(count)


Measured memory_bytes: 74220
//https://codeforces.com/problemset/problem/1095/E
#include<bits/stdc++.h>

using namespace std;


#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))
#define  nl "\n";
#define  ll  long long

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






template <class T> inline T biton(T n, T pos)
{
	return n | ((T)1 << pos);
}
template <class T> inline T bitoff(T n, T pos)
{
	return n & ~((T)1 << pos);
}
template <class T> inline T ison(T n, T pos)
{
	return (bool)(n & ((T)1 << pos));
}
template <class T> inline T gcd(T a, T b)
{
	while (b)
	{
		a = a % b;
		swap(a, b);
	}
	return a;
}
template <class T> inline T bigmod(T p, T e, T m)
{
	T ret = 1;
	for (; e > 0; e >>= 1)
	{
		if (e & 1)
			ret = (ret * p) % m;
		p = (p * p) % m;
	}
	return (T)ret;
};

#define DEBUG

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
	cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " is " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define debug(...)
#endif




void solve()
{
	int a, b;
	cin >> a >> b;
	cout << a * b << nl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(10);
	cout.tie(nullptr);
	cin.tie(nullptr);

	int t = 1;

	while (t--)
	{
		solve();
	}

	return 0;
}

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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

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

void Main(){
    int X; cin >> X;
    int l = lcm(X,360);
    int ans = l/X;
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
#include<array>
#include<vector>
struct trie{
	struct node{
		array<int,26>next;
		int cnt;
		bool id;
		node():cnt(0),id(false){next.fill(-1);}
	};
	vector<node>v;
	trie(){v.push_back(node());}
	bool add(const string&s)
	{
		int p=0;
		for(int i=0;i<s.size();i++)
		{
			v[p].cnt++;
			int j=s[i]-'a';
			if(v[p].next[j]<0)
			{
				v[p].next[j]=v.size();
				v.push_back(node());
			}
			p=v[p].next[j];
		}
		v[p].cnt++;
		v[p].id=true;
		return true;
	}
};
int N,Q;
string s[1<<17];
int A[1<<17],T[1<<17][26][26];
main()
{
	cin>>N;
	trie P;
	for(int i=0;i<N;i++)
	{
		cin>>s[i];
		P.add(s[i]);
	}
	for(int i=0;i<N;i++)
	{
		int p=0;
		for(int j=0;j<s[i].size();j++)
		{
			if(P.v[p].id)A[i]++;
			char y=s[i][j];
			for(char x='a';x<='z';x++)
			{
				if(x==y)continue;
				int idx=P.v[p].next[x-'a'];
				if(idx>=0)T[i][x-'a'][y-'a']+=P.v[idx].cnt;
			}
			p=P.v[p].next[s[i][j]-'a'];
		}
	}
	cin>>Q;
	for(;Q--;)
	{
		int k;string p;cin>>k>>p;
		k--;
		int ans=A[k];
		for(int i=0;i<26;i++)for(int j=i+1;j<26;j++)
		{
			ans+=T[k][p[i]-'a'][p[j]-'a'];
		}
		cout<<ans+1<<endl;
	}
}

Measured memory_bytes: 284284
#include <stdio.h>
#include<math.h>
int main()
{
 long int x,y,i;

scanf("%ld%ld",&x,&y);

if((x+y)%3==0 || x%3==0 || y%3==0 )
{
    printf("Possible");
}else{
    printf("Impossible");
}
    return 0;
}


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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << min(b / a, c) << endl;
  return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define mt make_tuple
#define foreach(it, a) for(__typeof(a.begin()) it=a.begin(); it!=a.end(); it++)
#define forn(i, a) for(int i=0; i<a; i++)
#define INF 1e9
#define all(x) x.begin(), x.end()
#define MOD 1e9+7 

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef unsigned int uint;

int N, par[100005], ranks[100005], a, b, cnt=0;
ll res=0;

struct town
{
	int x, y, id;
	town(int a, int b, int c)
	{
		x=a;
		y=b;
		id=c;
	}
	town(){}
}T[100005], rT[100005];

struct Node
{
	ll cost;
	int x;
	int y;
	Node(ll a, int b, int c)
	{
		cost=a;
		x=b;
		y=c;
	}
	Node(){}
}fin[300005];

inline bool cmp(const Node&a, const Node&b)
{
	return a.cost<b.cost;
}
inline bool cmpx(const town&a, const town&b)
{
	return a.x<b.x;
}
inline bool cmpy(const town&a, const town&b)
{
	return a.y<b.y;
}
void init()
{
	for(int i=0; i<N; i++)
		par[i]=i, ranks[i]=0;
}

inline int find(int x)
{
	return par[x]==x?x:par[x]=find(par[x]);
}

inline bool unite(int x, int y)
{
	x=find(x), y=find(y);
	if(x==y)
		return  false;
	if(ranks[x]<ranks[y])
		par[x]=y;
	else
	{
		par[y]=x;
		if(ranks[x]==ranks[y])
			ranks[x]++;
	}
	return true;
}

int main() 
{
	scanf("%d", &N);
	init();
	for(int i=0; i<N; i++)
	{
		scanf("%d %d", &a, &b);
		T[i]=town(a, b, i);
		rT[i]=T[i];
	}
	sort(T, T+N, cmpx);	
	sort(rT, rT+N, cmpy);	
	
	for(int i=0; i<N-1; i++)
	{
		fin[cnt++]=Node(min(abs(T[i].x-T[i+1].x), abs(T[i].y-T[i+1].y)), T[i].id, T[i+1].id);
		fin[cnt++]=Node(min(abs(rT[i].x-rT[i+1].x), abs(rT[i].y-rT[i+1].y)), rT[i].id, rT[i+1].id);
	}
	sort(fin, fin+cnt, cmp);
/*	for(int i=0; i<cnt; i++)
	{
		cout<<fin[i].cost<<" "<<fin[i].x<<" "<<fin[i].y<<endl;
	}*/
	for(int i=0; i<cnt; i++)
	{
		res+=unite(fin[i].x, fin[i].y)*fin[i].cost;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 8192
#include <iostream>

int main(){
  int N;
  std::cin >> N;
  long sum = 0;
  for(int i = 1; i <= N; ++i){
    if(i % 3 != 0 and i % 5 != 0){
      sum += i;
    }
  }
  std::cout << sum << std::endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const int MAX_N = 100000;
const int MAX_V = 100000;
int N;
int V[MAX_N];

int solve() {
    map<int, int> even, odd;
    REP(i,1,MAX_V) {
        even[i] = 0;
        odd[i] = 0;
    }
    REP(i,0,N) {
        if (i % 2 == 0) {
            even[V[i]]++;
        } else {
            odd[V[i]]++;
        }
    }
    vector<pair<int,int> > even_vector, odd_vector;
    REP(i,1,MAX_V) {
        even_vector.push_back(make_pair(-even[i],i));
        odd_vector.push_back(make_pair(-odd[i],i));
    }
    sort(all(even_vector));
    sort(all(odd_vector));
    if (even_vector[0].second == odd_vector[0].second) {
        return min(N + even_vector[0].first + odd_vector[1].first, N + even_vector[1].first + odd_vector[0].first);
    } else {
        return N + even_vector[0].first + odd_vector[0].first;
    }
}

signed main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N;
    REP(i,0,N) cin >> V[i];
    cout << solve() << "\n";
    return 0;
}



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

int color(std::vector<std::vector<int> > v) {
	std::vector<int> color(v.size(), 0);
	int count = 0, color_count = 1;
	for (int i = 0; i <= 2000; i++) {
		for (size_t j = 0; j < v.size(); j++) {
			for (size_t k = j + 1; k < v.size(); k++) {
				if (v[j][k] == i && ((color[k] == 0 || color[j] == 0) || (color[k] != color[j]))) {
					if (color[k] == 0) {
						if (color[j] != 0) {
							color[k] = color[j];
						} else {
							color[k] = color[j] = color_count;
							color_count++;
						}
					} else {
						if (color[j] == 0) {
							color[j] = color[k];
						} else {
							int num = color[j];
							std::replace(color.begin(), color.end(), num, color[k]);
						}
					}
					count += i;
				}
			}
		}
	}
	return count;
}

int main() {
	int num;
	std::cin >> num;

	std::vector<std::vector<int> > v(num);

	for (int i = 0; i < num; i++) {
		for (int j = 0; j < num; j++) {
			int n;
			std::cin >> n;
			v[i].push_back(n);
		}
	}

	std::cout << color(v) << std::endl;

	return 0;
}

Measured memory_bytes: 1316
countLetters :: String -> Char -> Int
countLetters str c = length $ filter (== c) str

main :: IO ()
main = do
    s <- getLine
    let
        north = countLetters s 'N'
        west = countLetters s 'W'
        south = countLetters s 'S'
        east = countLetters s 'E'
        a = if north > 0 then south > 0 else True
        b = if west > 0 then east > 0 else True
        c = if south > 0 then north > 0 else True
        d = if east > 0 then west > 0 else True
    putStrLn $ if a && b && c && d then
        "Yes"
        else
        "No"

Measured memory_bytes: 508
#include<stdio.h>

int main(){
  int i, j, temp, flag, N, A[100], count = 0;
  scanf("%d", &N);
  if(N >= 1 && N <= 100){
    for(j = 0; j < N; j++)
      scanf("%d", &A[j]);
    i = 0;
    flag = 1;
    while(flag){
      flag = 0;
      for(j = N - 1; j > i; j--){
	if(A[j] < A[j-1]){
	  temp = A[j];
	  A[j] = A[j-1];
	  A[j-1] = temp;
	  flag = 1;
	  count++;
	}
      }
      i++;
    }
    for(j = 0; j < N; j++){
      if(j != N-1) printf("%d ", A[j]);
      else printf("%d\n", A[j]);
    }
    printf("%d\n", count);
  }
  return 0;
}



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

int main(){
    int N,count=1,j=1;
    cin >> N;
    vector<int> a(N+1);
    for(int i=1;i<=N;i++)cin >> a.at(i);
    while(a.at(j)!=2){
        j = a.at(j);
        count++;
        if(count>N)break;
    }
    if(count > N)cout << -1 << endl;
    else cout << count << endl;
    return 0;
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
//	"time"
)




var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
    buf := make([]byte, 0, 1000000)
    for {
        l, p, e := rdr.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    return string(buf)
}  

func stringToArr(str string )[]string{
   return strings.Split( str," ")	
}

func atoi(str string)int{
	 ret,_ := strconv.Atoi(str)
	 return ret
}
func atoi2(str []string)[]int{

	ret:= make([]int,len(str))

	for i,v := range(str){
		ret[i] = atoi(v)
	}
	return ret
}




func main (){
//	start := time.Now()
   
s:= atoi2 (stringToArr( readLine()))
 
N:=s[0]
X:=s[1]
T:=s[2]

r:= N / X

if( N % X > 0){
	r++
}
fmt.Println(r* T)
    
   //n,_ := strconv.Atoi( readLine());
   //l:= strings.Split( readLine(), " ");

   /*
   for i:=0; i<n ;i++ {

   }
	
   for i:=1; i<n ;i++ {
	 
   }
 
   for i:=0; i<n ;i++ {
fmt.Println ( person[i].childrenNumber)
   }*/

 //  end := time.Now()
 //  fmt.Printf("%fç§’\n", (end.Sub(start)).Seconds())

}

Measured memory_bytes: 1844
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
using namespace std;
typedef pair<int64_t, int64_t> P;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    rep(i, 0, N) cin >> p.at(i);
    int maxi = 0;
    rep(i, 0, K){
        maxi += p.at(i);
    }
    int dop = maxi;
    rep(i, K, N){
        dop = dop - p.at(i - K) + p.at(i);
        maxi = max(maxi, dop);
    }
    double D = (double)(maxi + K) / 2;
    cout << fixed << setprecision(7) << D << endl;
}

Measured memory_bytes: 1024